Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-admin-mcp-issues-band-outside.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions src/docs/design/admin-mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/adminmcp/adminmcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."}
Expand Down
7 changes: 6 additions & 1 deletion src/pkg/adminmcp/tools_band_ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
)

Expand Down
43 changes: 43 additions & 0 deletions src/pkg/adminmcp/tools_band_ops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
36 changes: 36 additions & 0 deletions src/pkg/dashboard/admin_mcp_band_keys_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
Loading