From 19354e63e3465e62bc8d69671bfd886a44fa7f8e Mon Sep 17 00:00:00 2001 From: Danathar Date: Fri, 6 Nov 2026 07:52:12 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(adminmcp):=20issues=5Fby=5Fb?= =?UTF-8?q?and=20accepts=20the=20outside=20band=20it=20reports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The issues Overview export answers with a sixth band, "outside" (open issues the scanner kept off the agent queues), in bands[] and on rows. issues_by_band returned it with its count and refused band=outside as unknown: adminmcp keeps its own copy of the band keys and the copy had only the five donut bands. issueBandKeys gains "outside". A dashboard test compares both tools' band keys with what the export can answer, so the copy cannot drift again. prs_by_band is unchanged. Co-Authored-By: Claude Fable 5.1 Signed-off-by: Danathar --- .../fixed-admin-mcp-issues-band-outside.md | 1 + src/docs/design/admin-mcp.md | 2 + src/pkg/adminmcp/adminmcp.go | 2 +- src/pkg/adminmcp/tools_band_ops.go | 7 ++- src/pkg/adminmcp/tools_band_ops_test.go | 43 +++++++++++++++++++ src/pkg/dashboard/admin_mcp_band_keys_test.go | 36 ++++++++++++++++ 6 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 changelog.d/fixed-admin-mcp-issues-band-outside.md create mode 100644 src/pkg/dashboard/admin_mcp_band_keys_test.go diff --git a/changelog.d/fixed-admin-mcp-issues-band-outside.md b/changelog.d/fixed-admin-mcp-issues-band-outside.md new file mode 100644 index 0000000000..35f243a751 --- /dev/null +++ b/changelog.d/fixed-admin-mcp-issues-band-outside.md @@ -0,0 +1 @@ +- Admin MCP: `issues_by_band` accepts `band: "outside"`. The issues Overview export has a sixth band, `outside`, for open issues the scanner kept off the agent queues, and the tool returned it in `bands[]` with its count and on the rows themselves. Asking for it was refused as `unknown band "outside"`, because the tool's own list of band names had only the five donut bands, so those issues could be read only by paging through every row. `prs_by_band` is unchanged; pull requests have no such band. diff --git a/src/docs/design/admin-mcp.md b/src/docs/design/admin-mcp.md index 220ec4b671..9487f02575 100644 --- a/src/docs/design/admin-mcp.md +++ b/src/docs/design/admin-mcp.md @@ -337,6 +337,8 @@ the usual `limit`. returned in full, even when `band` or `held` filters `rows[]` down, so a caller can map "Confirm & close" to `band=done` without knowing the `hive/*` label names. An unknown `band` gets the same `{"type":"refusal",...}` shape as `refuse_operation`, listing the valid keys. +Every key `bands[]` can carry is a valid `band`: for issues that includes `outside`, the open +issues the scanner kept off the agent queues, which the export adds after the donut's five. The tool never forwards `band`, `held`, `offset`, or `limit` to the Overview endpoint itself — that would compute `bands[]` counts and `rows[]` over only the already-filtered subset — so it fetches every band and row and filters/pages `rows[]` itself, disclosing `rows_truncated` and diff --git a/src/pkg/adminmcp/adminmcp.go b/src/pkg/adminmcp/adminmcp.go index cb4532efa8..dc0d41c303 100644 --- a/src/pkg/adminmcp/adminmcp.go +++ b/src/pkg/adminmcp/adminmcp.go @@ -433,7 +433,7 @@ func inputSchema(name string) map[string]any { props = advisorRecordsSchema() case ToolIssuesByBand: props["repo"] = map[string]any{"type": "string", "description": "owner/name; unset reads every repo this hive tracks."} - props["band"] = map[string]any{"type": "string", "enum": issueBandKeys} + props["band"] = map[string]any{"type": "string", "enum": issueBandKeys, "description": "A band key from bands[]. outside is the open issues the scanner kept off the agent queues; each such row's bucket says why."} props["stale"] = map[string]any{"type": "boolean"} props["held"] = map[string]any{"type": "boolean", "description": "Filter rows to held (held=true) or unheld (held=false) issues before the limit cap, so held rows are not silently dropped by it; unlike `repo`, this does not change bands[] counts."} props["offset"] = map[string]any{"type": "integer", "minimum": 0, "description": "Rows to skip; pass the previous answer's next_offset to read the next page past the limit cap."} diff --git a/src/pkg/adminmcp/tools_band_ops.go b/src/pkg/adminmcp/tools_band_ops.go index b3ea50df0b..e9a3d1e08f 100644 --- a/src/pkg/adminmcp/tools_band_ops.go +++ b/src/pkg/adminmcp/tools_band_ops.go @@ -19,8 +19,13 @@ const ( // cannot import pkg/dashboard — dashboard imports adminmcp to serve the admin // MCP endpoint — so the band-read tools carry their own copy of the valid // keys, in the fixed order the Overview endpoints already return bands[] in. +// +// The issues export has one band beyond issueBandOrder: "outside" +// (overviewBandOutside), the open issues the scanner kept off the agent +// queues. It comes back in bands[] with a count like the others, so it is a +// band a caller can ask for. var ( - issueBandKeys = []string{"ready", "in-progress", "agent-filed", "waiting", "done"} + issueBandKeys = []string{"ready", "in-progress", "agent-filed", "waiting", "done", "outside"} prBandKeys = []string{"waiting", "eligible", "blocked", "in-review", "open", "draft"} ) diff --git a/src/pkg/adminmcp/tools_band_ops_test.go b/src/pkg/adminmcp/tools_band_ops_test.go index 1222b8554d..f71f051256 100644 --- a/src/pkg/adminmcp/tools_band_ops_test.go +++ b/src/pkg/adminmcp/tools_band_ops_test.go @@ -316,3 +316,46 @@ func TestBandReadResultRefusesNegativeOffset(t *testing.T) { t.Fatalf("result = %#v, want a refusal for a negative offset", out) } } + +// The issues export answers with a sixth band, "outside", in bands[] and on +// rows. issues_by_band listed it with its count and then refused band=outside +// as unknown, so those rows could only be read unfiltered. +func TestIssuesByBandAcceptsTheOutsideBand(t *testing.T) { + response := func() map[string]any { + return map[string]any{ + "kind": "issues", + "bands": []any{ + map[string]any{"key": "ready", "label": "Unclaimed", "count": float64(1)}, + map[string]any{"key": "outside", "label": "outside", "rule": "open issue the scanner kept off the agent queues", "count": float64(2)}, + }, + "rows": []any{ + map[string]any{"number": float64(1), "band": "ready"}, + map[string]any{"number": float64(2), "band": "outside", "bucket": "filtered"}, + map[string]any{"number": float64(3), "band": "outside", "bucket": "blocked"}, + }, + } + } + out, err := BandReadResult(ToolIssuesByBand, response(), map[string]any{"band": "outside"}) + if err != nil { + t.Fatal(err) + } + body, ok := out.(map[string]any) + if !ok { + t.Fatalf("band=outside was refused: %#v", out) + } + if rows, _ := body["rows"].([]any); len(rows) != 2 { + t.Fatalf("band=outside returned %d rows, want the 2 outside rows", len(rows)) + } + if bands, _ := body["bands"].([]any); len(bands) != 2 { + t.Fatalf("bands[] was filtered: %#v", body["bands"]) + } + + // Pull requests have no such band. + out, err = BandReadResult(ToolPrsByBand, response(), map[string]any{"band": "outside"}) + if err != nil { + t.Fatal(err) + } + if refusal, ok := out.(RefusalData); !ok || refusal.Kind != RefusalKindInvalidArgument { + t.Fatalf("prs_by_band band=outside = %#v, want a refusal", out) + } +} diff --git a/src/pkg/dashboard/admin_mcp_band_keys_test.go b/src/pkg/dashboard/admin_mcp_band_keys_test.go new file mode 100644 index 0000000000..a71507aaed --- /dev/null +++ b/src/pkg/dashboard/admin_mcp_band_keys_test.go @@ -0,0 +1,36 @@ +package dashboard + +import ( + "reflect" + "testing" + + "github.com/hivecommons/hive/pkg/adminmcp" +) + +// adminmcp cannot import this package, so issues_by_band and prs_by_band carry +// their own copy of the band keys. The copy must be every band the Overview +// export can answer with: when it missed "outside", the tool listed that band +// in bands[] and refused it as a filter. +func TestAdminMCPBandKeysAreTheBandsTheOverviewExportAnswersWith(t *testing.T) { + want := map[string][]string{ + adminmcp.ToolIssuesByBand: append(append([]string{}, issueBandOrder...), overviewBandOutside), + adminmcp.ToolPrsByBand: append([]string{}, prBandOrder...), + } + for _, tool := range adminmcp.Tools() { + name, _ := tool["name"].(string) + keys, ok := want[name] + if !ok { + continue + } + props, _ := tool["inputSchema"].(map[string]any)["properties"].(map[string]any) + band, _ := props["band"].(map[string]any) + got, _ := band["enum"].([]string) + if !reflect.DeepEqual(got, keys) { + t.Errorf("%s accepts bands %v, the Overview export answers with %v", name, got, keys) + } + delete(want, name) + } + for name := range want { + t.Errorf("tool %s not found", name) + } +}