Commit bc4b892
authored
fix(rust-guard): handle GraphQL-format search results and bot-author filtering (#2403)
## Problem
The MCP server v0.32.0+ returns search results in **two different
formats**:
| Format | Keys | Source |
|--------|------|--------|
| REST | `total_count`, `items` | Standard GitHub Search API |
| GraphQL | `totalCount`, `issues`/`pull_requests`, `pageInfo` | GraphQL
API |
The guard only handled the REST format, causing three related failures:
### 1. Empty GraphQL search results bypass metadata handling
`is_search_result_wrapper()` only checked for `total_count` (REST).
GraphQL responses with `totalCount` weren't recognized as search
wrappers, so empty results bypassed the server metadata handler that
assigns properly-scoped `writer_integrity`.
### 2. GraphQL items not extracted in response_items.rs
The legacy `response_items.rs` path only checked for the `items` key.
GraphQL format uses `issues` and `pull_requests` keys, so items fell
through to the single-object fallback with `none` integrity.
### 3. Empty search results with bad scope in default_labels
`response_paths.rs` returned `Some(PathLabelResult)` with zero labeled
paths for empty searches, bypassing `lib.rs` metadata detection. The
`default_labels` used `none_integrity("")` producing `none:` tags with
empty scope that never match agent DIFC tags.
## Changes
- **helpers.rs**: `is_search_result_wrapper()` now detects both
`total_count` and `totalCount`. Added `search_result_total_count()`
helper for format-agnostic count access.
- **response_items.rs**: Added `issues` and `pull_requests` key checks
for item extraction.
- **response_paths.rs**: Returns `None` for empty search results (defers
to lib.rs metadata handler). Uses actual repo scope in `default_labels`
instead of empty string.
- **lib.rs**: Uses `search_result_total_count()` instead of hardcoded
`total_count`.
- **mod.rs**: Added 3 new tests (GraphQL format detection, total count
extraction, bot-author integrity for both formats).
## Testing
- 163 Rust guard tests pass (3 new)
- `make agent-finished` passes (Go build, lint, unit + integration
tests)
Relates to github/gh-aw#225335 files changed
Lines changed: 581 additions & 17 deletions
File tree
- guards/github-guard/rust-guard/src
- labels
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
668 | 668 | | |
669 | 669 | | |
670 | 670 | | |
671 | | - | |
672 | | - | |
673 | | - | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
674 | 676 | | |
675 | | - | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
676 | 687 | | |
677 | 688 | | |
678 | 689 | | |
| |||
0 commit comments