fix(httpclient): map Counter scope params and issues.count.scope capability (#7250)

#7210 (OSS HTTP client wire/encode layers) and #7199 (Counter scope —
ParentID, NoParent, ExcludeTypes, ExcludeStatus behind issues.count.scope)
merged back to back without a rebase, leaving main red on the client's
parity gates: the count encoder table left the four new CountRequest
members unclassified, the published parent/no_parent/exclude_type/
exclude_status parameters had no driving field, and the client's
capability vocabulary lacked the server's new behavior token.

- encode: countTable maps the four scope members as params, spelled as
  the server's countFilters decodes them; countFilters emits them.
- encode/skew: --no-parent / --exclude-status flag mapping for the
  unknown_parameter refusal.
- wire: CapCountScope mirrors httpapi.CapIssuesCountScope and joins
  behaviorCapabilities; the vocabulary test pins it by name and order.
- roundtrip: scope members round-trip through the server decoder
  (ParentID and NoParent in separate cases, as the role refuses both).

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Julian Knutsen 2026-10-05 08:31:08 -07:00 • committed by GitHub
commit edafcbce1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 72 additions and 7 deletions

View file

@ -415,6 +415,14 @@ func (b *builder) countFilters(req issueops.CountRequest) {
b.metadata(req.MetadataFields)
b.str("has_metadata_key", req.HasMetadataKey)
// The issues.count.scope members (upstream #7199), in the server's own
// countFilters order. Each is emitted only when populated, so a request that
// sets none of them stays byte-identical to what a pre-scope server accepts.
b.str("parent", req.ParentID)
b.boolean("no_parent", req.NoParent)
b.list("exclude_type", req.ExcludeTypes)
b.list("exclude_status", req.ExcludeStatus)
}
// GetTarget encodes a detail lookup onto GET /v0/beads/issues/{id}, returning

View file

@ -274,6 +274,12 @@ func roundTripCases() []roundTripCase {
MetadataFields: map[string]string{"team": "core", "wave": "3"},
HasMetadataKey: "team",
// The issues.count.scope members (#7199). NoParent is the one left out:
// the role refuses it beside ParentID, so it rides its own case below.
ParentID: "bd-epic1",
ExcludeTypes: []string{"gate", "molecule"},
ExcludeStatus: []string{"closed", "deferred"},
}
// Values that have to survive percent-encoding, a `=` inside a metadata
@ -313,6 +319,20 @@ func roundTripCases() []roundTripCase {
// `all` is a status the count takes literally and the server forwards
// verbatim; it is not the listing's boolean of the same spelling.
{"countIssues/the literal all status", OpCountIssues, "", issueops.CountRequest{Status: "all"}},
// The issues.count.scope members (#7199). ParentID and NoParent are
// mutually exclusive at the ROLE, so they ride separate cases; the two
// exclusion lists carry more than one entry each so a decoder that kept
// only the first value would be a mismatch rather than a coincidence.
{"countIssues/scope under a parent", OpCountIssues, "", issueops.CountRequest{
ParentID: "bd-epic1",
ExcludeTypes: []string{"gate", "molecule"},
ExcludeStatus: []string{"closed", "deferred"},
}},
{"countIssues/scope at the top level", OpCountIssues, "", issueops.CountRequest{
NoParent: true,
ExcludeTypes: []string{"epic"},
ExcludeStatus: []string{"blocked"},
}},
{"countIssues/byGroup/a dimension over an empty predicate", OpCountIssues, "byGroup", issueops.CountByGroupRequest{GroupBy: issueops.CountGroupStatus}},
{"countIssues/byGroup/a dimension over the whole predicate", OpCountIssues, "byGroup", issueops.CountByGroupRequest{Filter: countEverything, GroupBy: issueops.CountGroupLabel}},

View file

@ -82,6 +82,7 @@ var paramFlag = map[string]string{
"desc_contains": "desc-contains",
"empty_description": "empty-description",
"exclude_label": "exclude-label",
"exclude_status": "exclude-status",
"exclude_type": "exclude-type",
"has_metadata_key": "has-metadata-key",
"id": "id",
@ -100,6 +101,7 @@ var paramFlag = map[string]string{
"metadata_field": "metadata-field",
"no_assignee": "no-assignee",
"no_labels": "no-labels",
"no_parent": "no-parent",
"notes_contains": "notes-contains",
"parent": "parent",
"priority": "priority",

View file

@ -108,7 +108,7 @@ const (
//
// countIssues is why it exists: CountByGroupRequest carries the scalar
// predicate BY NAME (`Filter`) plus the dimension, so its table would
// otherwise have to restate twenty-three classifications the count table
// otherwise have to restate every classification the count table
// already makes — two copies of one partition, which is the drift every
// other gate here is written to prevent.
//
@ -418,8 +418,7 @@ func queryTable() Table {
// does the most damage: a listing that widened returns rows a caller can look
// at, and a count that widened returns a NUMBER, which carries no evidence of
// the set it came from. So the partition here was measured against the
// document rather than assumed — every one of CountRequest's twenty-three
// members is published by GET /v0/beads/issues:count, and the count's
// document rather than assumed — every one of CountRequest's members is published by GET /v0/beads/issues:count, and the count's
// vocabulary is total.
//
// THE COUNT'S PLANE VOCABULARY IS NARROWER THAN THE LISTING'S — `include_infra`
@ -496,6 +495,20 @@ func countTable() Table {
// ListRequest.HasMetadataKey/ReadyRequest.HasMetadataKey. Missing
// here for the same reason IncludeEphemeral was: no entry at all.]
param("HasMetadataKey", "has_metadata_key"),
// [Added: the four scope members of upstream #7199 (behavior token
// issues.count.scope). The server decodes them in reads.go
// countFilters exactly as spelled here — parent and exclude_type as
// the listing reads them, no_parent and exclude_status by this
// surface's own boolean/list conventions. Against a server that does
// not advertise issues.count.scope these parameters answer 400
// unknown_parameter (skew.go case 3); the capability pre-flight that
// refuses them LOCALLY before the dial belongs to the count role
// client, which reads wire.CapCountScope off the handshake snapshot.]
paramTo("ParentID", "parent", "ParentID"),
paramTo("NoParent", "no_parent", "NoParent"),
paramTo("ExcludeTypes", "exclude_type", "ExcludeTypes"),
paramTo("ExcludeStatus", "exclude_status", "ExcludeStatus"),
},
}
}
@ -506,7 +519,7 @@ func countTable() Table {
// It is NOT primary — the count table above owns the operation's parameter set
// — and it classifies two members, because that is all CountByGroupRequest has.
// The predicate travels through the count table by delegation (DispNested)
// rather than by a second enumeration of the same twenty-three fields.
// rather than by a second enumeration of the same fields.
func countByGroupTable() Table {
return Table{
Op: OpCountIssues, Shape: "byGroup",

View file

@ -123,6 +123,25 @@ const CapProjectEnforce = "project.enforce"
// server's, so the mirror is what makes the two land together.
const CapListSort = "issues.list.sort"
// CapCountScope is the behavior capability announcing that countIssues honors
// the four scope parameters `parent`, `no_parent`, `exclude_type` and
// `exclude_status` (upstream #7199), spelled exactly as httpapi's
// CapIssuesCountScope (held to it by TestTheProjectIdentityVocabularyMatchesTheServer).
// Like CapListSort it names parameters on an existing operation —
// issues.count is already countIssues' per-operation token — so it rides here
// rather than on opCapability.
//
// Nothing in this package reads it yet: the encoder table maps the four
// members (encode.countTable), and the count role client that dials
// countIssues is what must consult it — refusing LOCALLY with a typed
// capability error naming this token, before any network call, when a request
// populates ParentID, NoParent, ExcludeTypes or ExcludeStatus and the
// handshake snapshot does not advertise it (httpapi.CapIssuesCountScope's doc
// states that obligation and the downstream fallback it protects). It is
// declared now for the same reason CapListSort was: the capability-union
// parity gate compares this client's whole vocabulary with the server's.
const CapCountScope = "issues.count.scope"
// CapBatchApplyLarge is the behavior capability announcing that issues.batchApply
// accepts a batch larger than the compiled-in floor (100 items), up to the
// raised ceiling (1000), spelled exactly as httpapi's constant of the same name
@ -255,7 +274,7 @@ func (e *WireRevisionSkewError) Unwrap() error { return ErrWireRevisionSkew }
// union(opCapability tokens, this) set-equal with httpapi.Capabilities(), which is
// what makes the server change and this client change land together: the parity
// test goes red the moment one ships without the other.
var behaviorCapabilities = []string{CapProjectEnforce, CapBatchApplyLarge, CapListSort}
var behaviorCapabilities = []string{CapProjectEnforce, CapBatchApplyLarge, CapListSort, CapCountScope}
// CapabilityFor reports the capability token gating op, and whether op is on
// this client's map at all. An operation with no token — liveness, the

View file

@ -142,6 +142,9 @@ func TestTheProjectIdentityVocabularyMatchesTheServer(t *testing.T) {
if CapListSort != httpapi.CapIssuesListSort {
t.Errorf("CapListSort = %q, server says %q", CapListSort, httpapi.CapIssuesListSort)
}
if CapCountScope != httpapi.CapIssuesCountScope {
t.Errorf("CapCountScope = %q, server says %q", CapCountScope, httpapi.CapIssuesCountScope)
}
if CapBatchApplyLarge != httpapi.CapBatchApplyLarge {
t.Errorf("CapBatchApplyLarge = %q, server says %q", CapBatchApplyLarge, httpapi.CapBatchApplyLarge)
}
@ -179,8 +182,8 @@ func TestTheProjectIdentityVocabularyMatchesTheServer(t *testing.T) {
// literal is spelled out member by member rather than compared against the
// server's own slice: a mirror checked against the thing it mirrors passes
// however both of them move.
if !slices.Equal(behaviorCapabilities, []string{httpapi.CapProjectEnforce, httpapi.CapBatchApplyLarge, httpapi.CapIssuesListSort}) {
t.Errorf("behaviorCapabilities = %v, want the server's project.enforce, issues.batchApplyLarge and issues.list.sort tokens", behaviorCapabilities)
if !slices.Equal(behaviorCapabilities, []string{httpapi.CapProjectEnforce, httpapi.CapBatchApplyLarge, httpapi.CapIssuesListSort, httpapi.CapIssuesCountScope}) {
t.Errorf("behaviorCapabilities = %v, want the server's project.enforce, issues.batchApplyLarge, issues.list.sort and issues.count.scope tokens", behaviorCapabilities)
}
}