feat(list): bd list --no-assignee, --title and --id over http behind per-parameter tokens (S15b) (#7550)

* feat(list): bd list --no-assignee, --title and --id over http behind per-parameter tokens (S15b)

Over http `bd list --no-assignee`, `--title` and `--id` refused: the list
encoder had no listIssues parameter for ListRequest.NoAssignee,
TitleSearch or IDFilter (B3 #11). All three are maintainer-city cutover
blockers: gc's default on_boot hook runs
`bd list --no-assignee --status=in_progress ...` on every agent boot, the
PR-intake formula lists by `--title "$SUBJECT"`, and the pr-review skill
by `--id <ids>`.

The library entry is unchanged: issueops.Reader.List, whose bodies
already apply all three through workapi.BuildListFilter, the same entry
the local route reads through.
- Server: GET /v0/beads/issues decodes `no_assignee`, `title` and `id`
  into those ListRequest members (`id` handed over as written; the role
  splits, trims and de-duplicates, as countIssues already does). Each is
  behind its own new behavior token, issues.list.noAssignee,
  issues.list.title and issues.list.id (additive, wire_revision stays 2):
  each is a separate caller's dependency, and a refusal names exactly the
  one it needed. The spec parameters cite their tokens; apigen and the
  wire-shape golden are regenerated.
- Client: the encoder maps the three members to their parameters, and
  httpReader.List refuses a request carrying one BEFORE dialing, with
  ErrUnsupported{Capability: <token>}, unless the handshake advertises
  that token (refuseUnservedSearch generalised to one table,
  tokenedListFilters, with bd search's `q`). Never a round trip an older
  server answers unknown_parameter, never a wider listing.
- ErrHTTPUnsupported's text names the capability when it has one, as the
  portable sentinel does, so `bd list` says which token the server lacks.
- The three E-ListRequest ledger rows retire; the ledger is re-rendered.

The id scope unparks the served Reader contract: the sixteen cases parked
on E-ListRequest.IDFilter now run against the in-process server. Twelve
pass as written; four still park, each now on the member it actually
needs (Offset twice, PinnedFlag, ExcludeTypes). The served refusal sweep
asserts SpecPrefix where it asserted IDFilter.

Tests (failing first): handler test that each parameter reaches the
storage filter; client tests that each member rides its parameter behind
its token and refuses pre-dial, zero dials, naming its token, against a
server lacking it; round-trip and vocabulary gates; capability lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(backend/http): the four maintainer-city list shapes end to end; corpus marks relabelled SRV-1 (S15b)

TestE2E_ListScopeFiltersOverHTTP runs the corpus shapes gc-list-on-boot,
gc-list-on-boot-workflow, mc-list-title and mc-list-id through the real
bd against the in-process server (which advertises the three new tokens)
and requires each to answer an embedded workspace's rows and exactly the
rows it names: --no-assignee leaves out an assigned in-progress row on
the same lane, --title is case-insensitive, --id lists a closed id under
--all. Against the MC production server's handshake shape each shape
exits non-zero naming its token and never dials listIssues.

The corpus suite masks the served side to reference_server.json, the
deployed bd 1.3.0 surface, which advertises none of the tokens, so the
four shapes now get the named pre-dial refusal there. Their marks move
from S6c+S15b to SRV-1 with that reason, like mc-search. With a scratch
profile that adds the three tokens and parameters (not committed) exactly
these four shapes report "now passes; remove the pending mark" and
nothing else changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(list): adopt bd-enterprise's listIssues `id` contract: repeatable, issues.list.ids (S15b)

bd-enterprise already publishes listIssues `id` (E9-S2): a REPEATABLE
parameter, one id per value, behind `issues.list.ids`, with its client
sending IDFilter split into one value per member. The first cut of S15b
took ONE comma-separated `id` behind `issues.list.id`, so the same
parameter name had two incompatible meanings: an OSS client's "a,b" is a
400 on an enterprise server, and the enterprise rebase onto main would
collide. OSS now publishes enterprise's contract unchanged:
- Server: listIDFilter (ported verbatim) decodes the repeated `id` into
  ListRequest.IDFilter's comma set; more than 200 values, an empty value,
  a comma, leading or trailing whitespace, a control character or an
  over-long id is a 400 `invalid_argument` on `id`. The spec parameter is
  enterprise's (array, maxItems 200); apigen and the wireshape golden are
  regenerated.
- Token: CapListIDs = "issues.list.ids", the enterprise spelling and name
  on both sides.
- Client: the encoder splits the set the way the role does (splitIDSet)
  and sends one `id` per member; the pre-dial gate fires only when the set
  names an id.
- Tests: list_ids_test.go is enterprise's id cases (the exact set reaches
  storage, the 200 bound is served, every refusal beside its control, the
  spec bound matches the constant); the handler, client, round-trip and
  e2e cases move to the repeated shape and the new token.

`no_assignee` and `title` are unchanged. Served tier, http e2e (including
TestE2E_ListScopeFiltersOverHTTP) and corpus_served_test pass; with a
scratch reference profile advertising the three tokens exactly the four
S15b shapes report "now passes".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian Knutsen 2026-10-14 00:18:00 +00:00 • committed by GitHub
commit e6a891b900
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 861 additions and 164 deletions

View file

@ -32,6 +32,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
description and metadata are unchanged, and omitting the flag (or passing
`0`) is byte-identical to today's output. JSON output is untouched;
`--include-comments` still streams every comment there.
- `GET /v0/beads/issues` accepts `no_assignee`, `title` and a repeatable `id`
(one id per value, at most 200), each behind its own new capability token
(`issues.list.noAssignee`, `issues.list.title`, `issues.list.ids`; additive,
no wire_revision bump; `id` and its token are bd-enterprise's contract,
adopted unchanged), and applies them through
the same Reader role a local `bd list` reads through. Over a connected HTTP
workspace `bd list --no-assignee`, `--title` and `--id` now work instead of
refusing. Against a server that does not advertise a flag's token the
client refuses before dialing, and the refusal names the token (every
capability refusal over HTTP now names its token).
- `GET /v0/beads/issues` accepts `q`, `bd search`'s free text, behind the
new `issues.list.search` capability token (additive; no wire_revision
bump). `issueops.ListRequest` gains `Query`, with `SearchIssues`' meaning

View file

@ -253,7 +253,10 @@ different backend needs `--force`.
`bd search`, `bd show --current` and `bd recompute-blocked` work over HTTP
too, each in its own way. `bd search` asks the server's listing with its text (`q`, behind the `issues.list.search` capability) and
refuses before dialing against a server that does not advertise it.
refuses before dialing against a server that does not advertise it. `bd list
--no-assignee`, `--title` and `--id` likewise ride the listing's
`no_assignee`, `title` and repeatable `id`, each behind its own capability
(`issues.list.noAssignee`, `issues.list.title`, `issues.list.ids`).
`bd show --current` finds the actor's in-progress or hooked issue through the
server's boolean query. `bd recompute-blocked` is a no-op that exits 0: the
server maintains `is_blocked` on every write, and repairing a stale flag is

View file

@ -32,6 +32,7 @@ go_test(
srcs = [
"attach_test.go",
"e2e_cli_test.go",
"e2e_list_filters_test.go",
"e2e_mol_test.go",
"e2e_recompute_blocked_test.go",
"e2e_remote_roles_test.go",

View file

@ -259,11 +259,11 @@ shapes:
- id: gc-list-on-boot
source: gc workquery.go on_boot recovery (--no-assignee)
args: [list, --metadata-field, gc.routed_to=pool-a, --status=in_progress, --no-assignee, --json]
pending: {slice: "S6c+S15b", reason: "list stub (B3 #1); --no-assignee refused by the list encoder (B3 #11)"}
pending: {slice: "SRV-1", reason: "S15b sends --no-assignee as listIssues no_assignee behind issues.list.noAssignee, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListScopeFiltersOverHTTP); remove the mark when reference_server.json is upgraded"}
- id: gc-list-on-boot-workflow
source: gc workquery.go on_boot recovery, workflow lane
args: [list, --metadata-field, gc.run_target=pool-a, --metadata-field, gc.kind=workflow, --status=in_progress, --no-assignee, --json]
pending: {slice: "S6c+S15b", reason: "list stub (B3 #1); --no-assignee refused by the list encoder (B3 #11)"}
pending: {slice: "SRV-1", reason: "S15b sends --no-assignee as listIssues no_assignee behind issues.list.noAssignee, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListScopeFiltersOverHTTP); remove the mark when reference_server.json is upgraded"}
- id: mc-list-meta-status
source: mc assets snapshot.md (list --json --limit --metadata-field --status)
args: [list, --json, --limit, "50", --metadata-field, gc.routed_to=pool-a, --status, open]
@ -284,11 +284,11 @@ shapes:
- id: mc-list-title
source: mc mol-normalized-issue-pr-v1 (list --all --include-infra --json --limit --title)
args: [list, --all, --include-infra, --json, --limit, "10", --title, "Routed open task"]
pending: {slice: "S6c+S15b", reason: "list stub (B3 #1); --title is a text filter the list encoder refuses (B3 #11)"}
pending: {slice: "SRV-1", reason: "S15b sends --title as listIssues title behind issues.list.title, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListScopeFiltersOverHTTP); remove the mark when reference_server.json is upgraded"}
- id: mc-list-id
source: mc skills/pr-review (list --all --id --json --limit)
args: [list, --all, --id, "e2e-r1,e2e-a1", --json, --limit, "0"]
pending: {slice: "S6c+S15b", reason: "list stub (B3 #1); --id refused by the list encoder (B3 #11)"}
pending: {slice: "SRV-1", reason: "S15b sends --id as listIssues id behind issues.list.ids, which the reference server does not advertise, so the client refuses before dialing (pinned passing against the current server by backend/http TestE2E_ListScopeFiltersOverHTTP); remove the mark when reference_server.json is upgraded"}
- id: mc-list-assignee-status
source: mc review summaries (list --assignee --json --limit --status)
args: [list, --assignee, alice, --json, --limit, "10", --status, open]

View file

@ -0,0 +1,113 @@
//go:build cgo
package bdhttp_test
import (
"slices"
"strings"
"testing"
)
// listScopeShapes are the four maintainer-city `bd list` shapes S15b serves,
// one per corpus shape (backend/http/corpus/testdata/corpus.yaml), with the
// token each needs and the titles each must answer on the scope seed:
// - gc-list-on-boot: gc's default on_boot hook, run on every agent boot;
// - gc-list-on-boot-workflow: the same recovery, workflow lane;
// - mc-list-title: the PR-intake formula's `--title "$SUBJECT"`;
// - mc-list-id: the pr-review skill's `--id <ids>`.
var listScopeShapes = []struct {
corpusID string
args []string
token string
want []string
}{
{"gc-list-on-boot",
[]string{"list", "--metadata-field", "gc.routed_to=pool-a", "--status=in_progress", "--no-assignee", "--json"},
"issues.list.noAssignee", []string{"orphan-ip"}},
{"gc-list-on-boot-workflow",
[]string{"list", "--metadata-field", "gc.run_target=pool-a", "--metadata-field", "gc.kind=workflow", "--status=in_progress", "--no-assignee", "--json"},
"issues.list.noAssignee", []string{"orphan-wf"}},
// Case-insensitive substring, every status.
{"mc-list-title",
[]string{"list", "--all", "--include-infra", "--json", "--limit", "10", "--title", "CHILD-A"},
"issues.list.title", []string{"child-a"}},
// A closed id in the set is listed under --all; ids outside it are not.
{"mc-list-id",
[]string{"list", "--all", "--id", "{child-c},{loner}", "--json", "--limit", "0"},
"issues.list.ids", []string{"child-c", "loner"}},
}
// seedListScope adds the on_boot recovery rows to the shared seed: one
// unassigned in-progress row per lane, and an ASSIGNED in-progress row on the
// routed lane, which --no-assignee must leave out.
func (f *remoteRolesFixture) seedListScope() {
f.t.Helper()
ip := f.create("orphan-ip", "-t", "task")
f.mustRun(nil, "update", ip, "-s", "in_progress", "--set-metadata", "gc.routed_to=pool-a")
wf := f.create("orphan-wf", "-t", "task")
f.mustRun(nil, "update", wf, "-s", "in_progress", "--set-metadata", "gc.run_target=pool-a", "--set-metadata", "gc.kind=workflow")
owned := f.create("owned-ip", "-t", "task", "-a", "worker")
f.mustRun(nil, "update", owned, "-s", "in_progress", "--set-metadata", "gc.routed_to=pool-a", "--set-metadata", "gc.run_target=pool-a", "--set-metadata", "gc.kind=workflow")
}
// TestE2E_ListScopeFiltersOverHTTP is S15b. `bd list --no-assignee`, `--title`
// and `--id` refused over http (the list encoder had no parameter for them);
// they now ride listIssues' `no_assignee`, `title` and `id`, each behind its
// own behavior token, and the server applies them through the same Reader
// role a local `bd list` reads through. Each corpus shape must answer the
// rows an embedded workspace answers, and exactly the rows it names.
//
// Against a server that lacks a token (the MC production server's handshake
// shape, which predates all three) each shape refuses BEFORE dialing
// listIssues, naming the token, rather than answering a wider listing.
func TestE2E_ListScopeFiltersOverHTTP(t *testing.T) {
skipUnlessEmbeddedDolt(t)
bin := buildBD(t)
addr := startE2EServer(t)
remote := newHTTPFixture(t, bin, addr)
local := newEmbeddedFixture(t, bin)
for _, f := range []*remoteRolesFixture{remote, local} {
f.seed()
f.seedListScope()
}
for _, shape := range listScopeShapes {
t.Run(shape.corpusID, func(t *testing.T) {
r := remote.run(nil, remote.expand(shape.args)...)
if r.code != 0 {
t.Fatalf("http: bd %s failed (exit %d): stderr=%s", strings.Join(shape.args, " "), r.code, r.stderr)
}
l := local.mustRun(nil, local.expand(shape.args)...)
got, want := remote.titlesOf(r.stdout), local.titlesOf(l.stdout)
if !slices.Equal(got, want) {
t.Errorf("http rows %v, embedded rows %v", got, want)
}
if !slices.Equal(got, shape.want) {
t.Errorf("http rows %v, want exactly %v", got, shape.want)
}
})
}
t.Run("MC server mask refuses before dialing", func(t *testing.T) {
proxyAddr, counter := startMaskingProxy(t, addr, mcContextMask)
f := newHTTPFixture(t, bin, proxyAddr)
f.ids = remote.ids // same workspace behind the proxy
for _, shape := range listScopeShapes {
counter.reset()
r := f.run(nil, f.expand(shape.args)...)
if r.code == 0 {
t.Errorf("%s: bd %s exited 0 against a server lacking %s: %s", shape.corpusID, strings.Join(shape.args, " "), shape.token, r.stdout)
continue
}
if !strings.Contains(r.stderr, shape.token) {
t.Errorf("%s: the refusal does not name %s: stderr=%s", shape.corpusID, shape.token, r.stderr)
}
for _, p := range counter.snapshot() {
if p == "GET /v0/beads/issues" {
t.Errorf("%s: dialed listIssues against a server lacking %s: %v", shape.corpusID, shape.token, counter.snapshot())
break
}
}
}
})
}

View file

@ -47,7 +47,7 @@ the behavior.
## Summary
264 rows: 204 refuse, 34 degrade, 26 retired.
261 rows: 201 refuse, 34 degrade, 26 retired.
## Whole-behavior divergences (D9 ledger)
@ -178,9 +178,7 @@ The listing publishes far more filters than the v0 wire does; every one the wire
| ID | Kind | Field / flag | Divergence | Why | Spec | Pinned test |
|---|---|---|---|---|---|---|
| E-ListRequest.TitleSearch | refuse | `ListRequest.TitleSearch` | a title search refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.SpecPrefix | refuse | `ListRequest.SpecPrefix` | a spec-id prefix restriction refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.IDFilter | refuse | `ListRequest.IDFilter` | an explicit id set on the LISTING refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml); the exact-ids question is getIssue's, reached through the SearchIssues bridge's exact-ids shape (D11), not through a listing filter | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.LabelPattern | refuse | `ListRequest.LabelPattern` | a glob label filter refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) — listReadyWork does publish label_pattern, which is exactly why the absence here has to refuse rather than fall through | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.LabelRegex | refuse | `ListRequest.LabelRegex` | a regex label filter refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) — as for LabelPattern, listReadyWork publishes label_regex and the listing does not | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.TitleContains | refuse | `ListRequest.TitleContains` | a title substring filter refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
@ -197,7 +195,6 @@ The listing publishes far more filters than the v0 wire does; every one the wire
| E-ListRequest.DueAfter | refuse | `ListRequest.DueAfter` | a due-after bound refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.DueBefore | refuse | `ListRequest.DueBefore` | a due-before bound refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.EmptyDesc | refuse | `ListRequest.EmptyDesc` | the empty-description predicate refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.NoAssignee | refuse | `ListRequest.NoAssignee` | the unassigned predicate refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) — listReadyWork publishes `unassigned`; the listing does not | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.NoLabels | refuse | `ListRequest.NoLabels` | the no-labels predicate refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.Priority | refuse | `ListRequest.Priority` | an exact priority filter refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) — listReadyWork publishes `priority`; the listing does not | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |
| E-ListRequest.PriorityMin | refuse | `ListRequest.PriorityMin` | a minimum-priority bound refuses | listIssues publishes no such parameter (internal/httpapi/reads.go handleListIssues; internal/httpapi/spec/openapi.v0.yaml) | D9 L12, D7, D8 | TestEncoderHonorsEveryTableDisposition |

View file

@ -91,6 +91,7 @@ go_test(
"get_issue_test.go",
"large_batch_apply_test.go",
"list_comments_omitted_test.go",
"list_ids_test.go",
"list_sort_test.go",
"memories_test.go",
"metadata_cas_test.go",

View file

@ -1101,7 +1101,7 @@ type ContextResponse struct {
// OPTIONAL, and absent means only that this server does not disclose its filesystem layout — never that it has no workspace. A client MUST NOT require it, MUST NOT treat absence as an error, and has no use for the value beyond display: it is a path on the SERVER's filesystem, which the client cannot open. Identify the workspace by `project_id` and `database`, which are required.
BeadsDir *string `json:"beads_dir,omitempty"`
// Capabilities The tokens this server advertises: the OPERATIONS it implements, derived from its route table, and the server-wide BEHAVIORS it enforces. v0's operation vocabulary is `ready.list`, `ready.count`, `issues.list`, `issues.query`, `issues.count`, `issues.get`, `issues.related`, `issues.create`, `issues.addComment`, `issues.batchClose`, `issues.claim`, `issues.claimNext`, `issues.release`, `issues.close`, `issues.reopen`, `issues.update`, `issues.sweep`, `issues.delete`, `issues.batchGet`, `issues.reclaim`, `issues.batchCreate`, `issues.batchApply`, `stats.get`, `config.list`, `config.get`, `config.set`, `config.unset`, `dependencies.cycles`, `dependencies.list`, `dependencies.count`, `dependencies.blocking`, `dependencies.tree`, `dependencies.add`, `dependencies.remove`, `memories.list`, `memories.get`, `memories.remember`, `memories.forget`, `events.list`, `events.watch`, `issues.casMetadata`, `issues.advanceMolecule`; the behavior tokens are `project.enforce`, which announces that a `Bd-Project-Id` stamp for the wrong workspace is refused here rather than silently ignored, `issues.batchApplyLarge`, which announces that `POST /v0/beads/issues:batchApply` accepts the RAISED envelope — up to 1000 items (`ApplyBatchRequest.items.maxItems`), a 16 MiB body, and (for a request over 100 items) a run budget that EXTENDS to an operator-configured ceiling (`bd serve --large-apply-ceiling`, 5 minutes by default) — rather than the original 100-item, 4 MiB bound. The ceiling is a flat whole-run budget, not a value scaled by item count: a 101-item request and a 1000-item request both get the same extended budget. A request at or under 100 items is unaffected either way and keeps the server's ordinary deadline exactly as before. A client that checks for this token before sending a plan over 100 items learns whether THIS server accepts it without paying for a round trip an older server would refuse anyway, and `issues.list.sort`, which announces that `GET /v0/beads/issues` accepts the `sort` query parameter (two closed, pageable total orders — see that parameter) rather than silently answering `unknown_parameter`, and `issues.count.scope`, which announces that `GET /v0/beads/issues:count` accepts `parent`, `no_parent`, `exclude_type`, and `exclude_status` (see those parameters) rather than silently answering `unknown_parameter` for all four, `issues.sweep.wispsPlane`, which announces that `POST /v0/beads/issues:sweep` accepts the `wisps-plane` value of `tier` rather than silently answering `invalid_value`, `issues.sweep.liveDependents`, which announces that the same operation accepts `protect_live_dependents` and answers `skipped.live_dependent` rather than silently answering `unknown_parameter`, `issues.sweep.limit`, which announces that it accepts `limit` and answers `remaining` rather than silently answering `unknown_parameter`, `issues.batchApply.depAddLineage`, which announces that a `dep_add` item on `POST /v0/beads/issues:batchApply` accepts `has_spawner` and `thread_id` (see `ApplyDepAddItem`) rather than a `400` naming the member unknown, and `issues.update.allowTemplate`, which announces that `PATCH /v0/beads/issues/{id}` accepts `allow_template` (see `UpdateIssueRequest`) rather than a `400` naming the member unknown, and `issues.create.defaultPriority`, which announces that a create (`POST /v0/beads/issues`, `issues:batchCreate` and `issues:batchApply` create items) with no `priority` member stores the default P2 rather than P0, and `issues.close.autoCloseMolecule`, which announces that `POST /v0/beads/issues/{id}:close` and `POST /v0/beads/issues:batchClose` accept `auto_close_molecule` and answer `auto_closed_molecule` and `molecule_auto_close_refusal` rather than a `400` naming the member unknown, and `issues.list.search`, which announces that `GET /v0/beads/issues` accepts `q`, `bd search`'s free text (see that parameter), rather than silently answering `unknown_parameter`. One behavior token is CONDITIONAL rather than build-level: `policy.external_dependencies` announces that this server's ready, claim, claim-next, close, blocking and dependency-tree operations already apply bd's external-dependency policy (an issue blocked by an unsatisfied `external:<project>:<capability>` dependency is neither ready, claimable nor closable without force). A server advertises it only when it enforces that policy; a client that sees it must not apply the policy again, and a client that does not see it applies the policy itself. The list grows additively, and an operation never appears here unless it is fully implemented. This is how a client checks for an operation or a behavior — never the version string.
// Capabilities The tokens this server advertises: the OPERATIONS it implements, derived from its route table, and the server-wide BEHAVIORS it enforces. v0's operation vocabulary is `ready.list`, `ready.count`, `issues.list`, `issues.query`, `issues.count`, `issues.get`, `issues.related`, `issues.create`, `issues.addComment`, `issues.batchClose`, `issues.claim`, `issues.claimNext`, `issues.release`, `issues.close`, `issues.reopen`, `issues.update`, `issues.sweep`, `issues.delete`, `issues.batchGet`, `issues.reclaim`, `issues.batchCreate`, `issues.batchApply`, `stats.get`, `config.list`, `config.get`, `config.set`, `config.unset`, `dependencies.cycles`, `dependencies.list`, `dependencies.count`, `dependencies.blocking`, `dependencies.tree`, `dependencies.add`, `dependencies.remove`, `memories.list`, `memories.get`, `memories.remember`, `memories.forget`, `events.list`, `events.watch`, `issues.casMetadata`, `issues.advanceMolecule`; the behavior tokens are `project.enforce`, which announces that a `Bd-Project-Id` stamp for the wrong workspace is refused here rather than silently ignored, `issues.batchApplyLarge`, which announces that `POST /v0/beads/issues:batchApply` accepts the RAISED envelope — up to 1000 items (`ApplyBatchRequest.items.maxItems`), a 16 MiB body, and (for a request over 100 items) a run budget that EXTENDS to an operator-configured ceiling (`bd serve --large-apply-ceiling`, 5 minutes by default) — rather than the original 100-item, 4 MiB bound. The ceiling is a flat whole-run budget, not a value scaled by item count: a 101-item request and a 1000-item request both get the same extended budget. A request at or under 100 items is unaffected either way and keeps the server's ordinary deadline exactly as before. A client that checks for this token before sending a plan over 100 items learns whether THIS server accepts it without paying for a round trip an older server would refuse anyway, and `issues.list.sort`, which announces that `GET /v0/beads/issues` accepts the `sort` query parameter (two closed, pageable total orders — see that parameter) rather than silently answering `unknown_parameter`, and `issues.count.scope`, which announces that `GET /v0/beads/issues:count` accepts `parent`, `no_parent`, `exclude_type`, and `exclude_status` (see those parameters) rather than silently answering `unknown_parameter` for all four, `issues.sweep.wispsPlane`, which announces that `POST /v0/beads/issues:sweep` accepts the `wisps-plane` value of `tier` rather than silently answering `invalid_value`, `issues.sweep.liveDependents`, which announces that the same operation accepts `protect_live_dependents` and answers `skipped.live_dependent` rather than silently answering `unknown_parameter`, `issues.sweep.limit`, which announces that it accepts `limit` and answers `remaining` rather than silently answering `unknown_parameter`, `issues.batchApply.depAddLineage`, which announces that a `dep_add` item on `POST /v0/beads/issues:batchApply` accepts `has_spawner` and `thread_id` (see `ApplyDepAddItem`) rather than a `400` naming the member unknown, and `issues.update.allowTemplate`, which announces that `PATCH /v0/beads/issues/{id}` accepts `allow_template` (see `UpdateIssueRequest`) rather than a `400` naming the member unknown, and `issues.create.defaultPriority`, which announces that a create (`POST /v0/beads/issues`, `issues:batchCreate` and `issues:batchApply` create items) with no `priority` member stores the default P2 rather than P0, and `issues.close.autoCloseMolecule`, which announces that `POST /v0/beads/issues/{id}:close` and `POST /v0/beads/issues:batchClose` accept `auto_close_molecule` and answer `auto_closed_molecule` and `molecule_auto_close_refusal` rather than a `400` naming the member unknown, `issues.list.search`, which announces that `GET /v0/beads/issues` accepts `q`, `bd search`'s free text (see that parameter), rather than silently answering `unknown_parameter`, and `issues.list.noAssignee`, `issues.list.title` and `issues.list.ids`, which announce that `GET /v0/beads/issues` accepts `no_assignee`, `title` and the repeatable `id` respectively (`bd list --no-assignee`, `--title` and `--id`; see those parameters) rather than answering `unknown_parameter`. One behavior token is CONDITIONAL rather than build-level: `policy.external_dependencies` announces that this server's ready, claim, claim-next, close, blocking and dependency-tree operations already apply bd's external-dependency policy (an issue blocked by an unsatisfied `external:<project>:<capability>` dependency is neither ready, claimable nor closable without force). A server advertises it only when it enforces that policy; a client that sees it must not apply the policy again, and a client that does not see it applies the policy itself. The list grows additively, and an operation never appears here unless it is fully implemented. This is how a client checks for an operation or a behavior — never the version string.
//
// THIS LIST IS BUILD-LEVEL, NOT WORKSPACE-LEVEL, apart from the conditional `policy.external_dependencies` above, which depends on how this server composed its roles rather than on the build. It says which operations this binary serves, and for every entry but two that is the whole answer. `events.list` and `events.watch` are the exceptions: the durable events journal is a per-workspace setting that is OFF by default, so a server that advertises them may still refuse every request to both with 409 `events_journal_disabled` — correctly, because the operations exist and the workspace has no journal. A consumer of either MUST treat the capability as "this server speaks it" and the 409 as "not on this workspace", and must not read the capability as a promise that records will arrive.
Capabilities []string `json:"capabilities"`
@ -2417,6 +2417,19 @@ type ListIssuesParams struct {
// Behind the `issues.list.search` behavior token: an older server answers `unknown_parameter` for this name. A client with the handshake's capabilities cached refuses a search locally against a server that does not advertise the token, rather than paying for that round trip.
Q *string `form:"q,omitempty" json:"q,omitempty"`
// NoAssignee Only issues with no assignee: `bd list --no-assignee`, handed to the role as written beside the other filters.
//
// Behind the `issues.list.noAssignee` behavior token: an older server answers `unknown_parameter` for this name. A client with the handshake's capabilities cached refuses the request locally against a server that does not advertise the token, rather than paying for that round trip or listing assigned issues as well.
NoAssignee *bool `form:"no_assignee,omitempty" json:"no_assignee,omitempty"`
// Title Case-insensitive substring match on the title: `bd list --title`. It narrows the listing and lifts none of its default exclusions.
//
// Behind the `issues.list.title` behavior token: an older server answers `unknown_parameter` for this name. A client with the handshake's capabilities cached refuses the request locally against a server that does not advertise the token, rather than paying for that round trip or answering the unnarrowed listing.
Title *string `form:"title,omitempty" json:"title,omitempty"`
// Id Restrict to these canonical ids (repeat the parameter). AND-ed with every other filter, including the default exclusions, so a caller addressing rows regardless of status, type or tier also sends all=true, include_templates, include_gates, include_infra and include_ephemeral. At most 200 values; an id longer than storage holds, an empty one, one with leading or trailing whitespace, or one carrying a control character or a comma is a 400 `invalid_argument` on `param: "id"` — each value is matched exactly as sent, never trimmed or split. An id that names no row is simply not matched. Advertised by the behavior token `issues.list.ids`.
Id *[]string `form:"id,omitempty" json:"id,omitempty"`
// Sort Which of the two served total orders this page is in. `created` is `(created_at DESC, id ASC)`; `priority` is `(priority ASC, created_at DESC, id ASC)` — `bd list`'s flagless ordering, and the order `bd list --sort priority` produces.
//
// THE DEFAULT IS `created` AND WILL NOT CHANGE. It is what this operation served before this parameter existed, so moving it would alter which rows a truncated page contains for every client written against that behavior, with no error to notice it by.

View file

@ -0,0 +1,197 @@
package httpapi
import (
"net/http"
"net/url"
"reflect"
"slices"
"strconv"
"strings"
"testing"
"github.com/steveyegge/beads/internal/types"
)
// listIssues' repeatable `id` (IDFilter, behind issues.list.ids). The member
// was already on issueops.ListRequest; what these pin is the TRANSPORT — the
// repeated parameter reaching the role as the comma set it splits, and the
// bounds the document states being enforced before a request reaches storage.
// The contract and these cases are bd-enterprise's (E9-S2), adopted unchanged
// (its copy of this file also covers include_comments, which OSS does not
// publish).
// TestListIDsReachStorageAsTheExactSet pins the decode: repeated `id` values
// arrive on the storage filter as exactly those ids, and nothing else about the
// request moves. The default exclusions stay in place (the parameter is AND-ed
// with them), which is why the import pre-read sends the five include flags.
func TestListIDsReachStorageAsTheExactSet(t *testing.T) {
filter := listSortOf(t, "?id=bd-2&id=bd-1&id=bd-wisp-9")
if want := []string{"bd-2", "bd-1", "bd-wisp-9"}; !slices.Equal(filter.IDs, want) {
t.Errorf("filter.IDs = %v, want %v", filter.IDs, want)
}
if len(filter.ExcludeStatus) == 0 {
t.Error("an id scope dropped the default status exclusions; the document says `id` is AND-ed with them")
}
// The control: no `id` is no id scope at all, not an empty one.
if got := listSortOf(t, "").IDs; len(got) != 0 {
t.Errorf("a request with no `id` reached storage with IDs = %v, want none", got)
}
// Every exclusion off: the shape the client's bulk reads send. The filter
// keeps the id set and NOTHING ELSE that could narrow it — not merely the
// suppressions known today, which is why the check is every field of the
// filter rather than a list of them: a suppression added to the listing
// tomorrow that none of the five flags lifts has to fail here, or the
// import pre-read misses that row kind without a sound.
all := listSortOf(t, "?id=bd-1&all=true&include_templates=true&include_gates=true&include_infra=true&include_ephemeral=true")
if !slices.Equal(all.IDs, []string{"bd-1"}) {
t.Errorf("filter.IDs = %v, want [bd-1]", all.IDs)
}
if extra := setFilterFields(all, "IDs", "Limit", "SortBy"); len(extra) != 0 {
t.Errorf("the every-row-kind request still narrows the id set: %s set on the storage filter %+v", strings.Join(extra, ", "), all)
}
}
// setFilterFields names every field of a storage filter that is set — a
// non-empty slice or map, a non-nil pointer, a true bool, a non-empty string, a
// non-zero number — other than the ones skipped.
func setFilterFields(f types.IssueFilter, skip ...string) []string {
v := reflect.ValueOf(f)
var set []string
for i := range v.NumField() {
name := v.Type().Field(i).Name
if slices.Contains(skip, name) {
continue
}
field := v.Field(i)
switch field.Kind() {
case reflect.Slice, reflect.Map:
if field.Len() > 0 {
set = append(set, name)
}
default:
if !field.IsZero() {
set = append(set, name)
}
}
}
return set
}
// TestListIDsAtTheBoundIsServed is the inclusive edge of maxItems: exactly 200
// ids is a request the document admits.
func TestListIDsAtTheBoundIsServed(t *testing.T) {
filter := listSortOf(t, "?"+idQuery(maxListIDs))
if len(filter.IDs) != maxListIDs {
t.Errorf("len(filter.IDs) = %d, want %d", len(filter.IDs), maxListIDs)
}
}
func idQuery(n int) string {
v := url.Values{}
for i := range n {
v.Add("id", "bd-"+strconv.Itoa(i+1))
}
return v.Encode()
}
// TestListIDsRefusals pins every refusal the member
// carries, each beside a control that differs in exactly the refused value, so a
// 400 cannot be read as some other parameter's.
func TestListIDsRefusals(t *testing.T) {
long := strings.Repeat("x", types.MaxFieldLen+1)
for _, tc := range []struct {
name string
path string
control string
param string
}{
{
name: "more ids than maxItems",
path: "/v0/beads/issues?" + idQuery(maxListIDs+1),
control: "/v0/beads/issues?" + idQuery(maxListIDs),
param: "id",
},
{
// The role splits the joined set on commas, so a value carrying
// one would silently address ids the caller never named.
name: "an id carrying a comma",
path: "/v0/beads/issues?id=" + url.QueryEscape("bd-1,bd-2"),
control: "/v0/beads/issues?id=bd-1&id=bd-2",
param: "id",
},
{
name: "an id carrying a control character",
path: "/v0/beads/issues?id=" + url.QueryEscape("bd-1\n"),
control: "/v0/beads/issues?id=bd-1",
param: "id",
},
{
name: "an empty id",
path: "/v0/beads/issues?id=bd-1&id=",
control: "/v0/beads/issues?id=bd-1",
param: "id",
},
{
// The role trims every member of the set, so a padded value
// would silently address the trimmed id — a row the caller never
// named, while the padded one (which storage can hold) is missed.
name: "an id with leading whitespace",
path: "/v0/beads/issues?id=" + url.QueryEscape(" bd-1"),
control: "/v0/beads/issues?id=bd-1",
param: "id",
},
{
// Unicode whitespace too: the rule is strings.TrimSpace's, the
// role's own trim, not an ASCII-space check.
name: "an id with trailing non-breaking space",
path: "/v0/beads/issues?id=" + url.QueryEscape("bd-1\u00a0"),
control: "/v0/beads/issues?id=bd-1",
param: "id",
},
{
name: "an id longer than storage holds",
path: "/v0/beads/issues?id=" + long,
control: "/v0/beads/issues?id=" + long[:types.MaxFieldLen],
param: "id",
},
} {
t.Run(tc.name, func(t *testing.T) {
ts, rec := newReadServer(t, Config{})
resp := ts.get(t, tc.path)
if resp.StatusCode != http.StatusBadRequest {
t.Fatalf("GET %s: status = %d, want 400", tc.path, resp.StatusCode)
}
body := decodeBody(t, resp)
if body["code"] != string(CodeInvalidArgument) || body["param"] != tc.param || body["reason"] != string(ReasonInvalidValue) {
t.Errorf("body = %v, want invalid_argument/invalid_value on param %s", body, tc.param)
}
if n := len(rec.searchFilters()); n != 0 {
t.Errorf("%d list queries ran; a refused request must not reach storage", n)
}
if got := ts.get(t, tc.control); got.StatusCode != http.StatusOK {
t.Fatalf("control GET %s: status = %d, want 200; body=%v", tc.control, got.StatusCode, decodeBody(t, got))
}
})
}
}
// TestListIDsBoundMatchesTheSpec holds the document's number to the constant
// the handler enforces, so the two cannot drift: a spec that said 300 would be
// refused by the server it documents at a number no reader predicted.
func TestListIDsBoundMatchesTheSpec(t *testing.T) {
doc := loadSpec(t)
so, ok := specOps(t, doc)[OpListIssues]
if !ok {
t.Fatalf("operation %q missing from the spec", OpListIssues)
}
schema := mapAt(t, specParam(t, so, "id"), "schema")
if got, ok := schema["maxItems"].(int); !ok || got != maxListIDs {
t.Errorf("listIssues id maxItems = %v, want %d", schema["maxItems"], maxListIDs)
}
if !slices.Contains(Capabilities(), CapListIDs) {
t.Errorf("Capabilities() does not advertise %s", CapListIDs)
}
}

View file

@ -1,6 +1,7 @@
package httpapi
import (
"fmt"
"net/http"
"strings"
@ -355,6 +356,9 @@ func (s *Server) handleListIssues(w http.ResponseWriter, r *http.Request) {
Status: q.csv("status"),
IssueType: q.str("type"),
Assignee: q.str("assignee"),
// `bd list --no-assignee`, behind issues.list.noAssignee
// (CapIssuesListNoAssignee).
NoAssignee: q.boolean("no_assignee"),
Labels: q.list("label"),
LabelsAny: q.list("label_any"),
@ -362,6 +366,14 @@ func (s *Server) handleListIssues(w http.ResponseWriter, r *http.Request) {
ParentID: q.str("parent"),
// `bd list --title`, behind issues.list.title (CapIssuesListTitle).
TitleSearch: q.str("title"),
// `bd list --id`, behind issues.list.ids (CapListIDs). The id scope
// arrives as a repeated parameter and reaches the role as the
// comma-separated set issueops.ListRequest.IDFilter is. The join is
// lossless only because listIDFilter refuses a comma inside a value.
IDFilter: listIDFilter(q),
Brief: q.boolean("brief"),
AllFlag: q.boolean("all"),
IncludeTemplates: q.boolean("include_templates"),
@ -449,6 +461,54 @@ func (s *Server) handleListIssues(w http.ResponseWriter, r *http.Request) {
writeJSON(w, body)
}
// maxListIDs bounds listIssues' repeatable `id` filter. It is the spec's
// `maxItems`, and TestListIDsBoundMatchesTheSpec holds the two together.
const maxListIDs = 200
// listIDFilter decodes listIssues' repeatable `id` filter into the comma-separated
// set issueops.ListRequest.IDFilter takes. The contract is bd-enterprise's
// (E9-S2), adopted unchanged.
//
// Every value is bounded the way a path id is (customMethodTarget): longer than
// the column holds, or carrying a control character, names no row that can
// exist. Unlike the path, a malformed value here is a 400 naming `id` rather
// than a 404 — there is no single resource to be missing — and two more shapes
// are refused because of what the role does with the joined set: a COMMA,
// because the role splits the set on commas and a value carrying one would
// silently address two ids the caller never named; and LEADING OR TRAILING
// WHITESPACE, because the role trims every member, so a padded value would
// silently address the trimmed id — a different one from the id named.
func listIDFilter(q *query) string {
vals := q.list("id")
if len(vals) == 0 {
return ""
}
if len(vals) > maxListIDs {
q.invalid("id", fmt.Sprintf("at most %d id values per request; got %d", maxListIDs, len(vals)))
return ""
}
for _, id := range vals {
switch {
case strings.TrimSpace(id) == "":
q.invalid("id", "an id value is empty")
return ""
case strings.Contains(id, ","):
q.invalid("id", fmt.Sprintf("%q carries a comma; repeat the parameter once per id instead", id))
return ""
case strings.ContainsFunc(id, isControlChar):
q.invalid("id", "an id value carries a control character")
return ""
case strings.TrimSpace(id) != id:
q.invalid("id", fmt.Sprintf("%q has leading or trailing whitespace; send the canonical id", id))
return ""
case types.CheckFieldLen("id", id) != nil:
q.invalid("id", fmt.Sprintf("an id value is longer than %d characters", types.MaxFieldLen))
return ""
}
}
return strings.Join(vals, ",")
}
// handleQueryIssues answers GET /v0/beads/issues:query.
//
// The EXPRESSION IS NOT PARSED HERE. Parsing, evaluation, the predicate

View file

@ -3,6 +3,7 @@ package httpapi
import (
"context"
"net/http"
"slices"
"strings"
"sync"
"testing"
@ -500,3 +501,51 @@ func TestTheEphemeralPlaneParameterIsTheSkewSignal(t *testing.T) {
t.Errorf("body = %v, want param=include_ephemerals reason=unknown_parameter", body)
}
}
// TestListForwardsTheScopeFilters is the handler half of S15b: listIssues'
// `no_assignee` (issues.list.noAssignee), `title` (issues.list.title) and `id`
// (issues.list.ids, repeatable) reach the storage seam through the Reader role as the
// ListRequest members `bd list --no-assignee`, `--title` and `--id` set, and
// their absence narrows nothing.
func TestListForwardsTheScopeFilters(t *testing.T) {
for _, tc := range []struct {
name, path string
check func(t *testing.T, f types.IssueFilter)
}{
{"absent narrows nothing", "/v0/beads/issues", func(t *testing.T, f types.IssueFilter) {
if f.NoAssignee || f.TitleSearch != "" || len(f.IDs) != 0 {
t.Errorf("filter = {NoAssignee:%v TitleSearch:%q IDs:%v}, want none set", f.NoAssignee, f.TitleSearch, f.IDs)
}
}},
{"no_assignee", "/v0/beads/issues?no_assignee=true&status=in_progress", func(t *testing.T, f types.IssueFilter) {
if !f.NoAssignee {
t.Error("no_assignee=true did not reach the filter")
}
}},
{"title", "/v0/beads/issues?title=Routed+open+task", func(t *testing.T, f types.IssueFilter) {
if f.TitleSearch != "Routed open task" {
t.Errorf("TitleSearch = %q, want %q", f.TitleSearch, "Routed open task")
}
if f.TitleContains != "" {
t.Errorf("title leaked into TitleContains = %q", f.TitleContains)
}
}},
{"id is repeatable, one id per value", "/v0/beads/issues?id=e2e-r1&id=e2e-a1&all=true", func(t *testing.T, f types.IssueFilter) {
if !slices.Equal(f.IDs, []string{"e2e-r1", "e2e-a1"}) {
t.Errorf("IDs = %v, want [e2e-r1 e2e-a1]", f.IDs)
}
}},
} {
t.Run(tc.name, func(t *testing.T) {
ts, rec := newReadServer(t, Config{})
if resp := ts.get(t, tc.path); resp.StatusCode != http.StatusOK {
t.Fatalf("GET %s: status = %d, want 200", tc.path, resp.StatusCode)
}
filters := rec.searchFilters()
if len(filters) != 1 {
t.Fatalf("search calls = %d, want 1", len(filters))
}
tc.check(t, filters[0])
})
}
}

View file

@ -132,6 +132,40 @@ const CapIssuesCountScope = "issues.count.scope"
// is never widened into an unsearched listing.
const CapIssuesListSearch = "issues.list.search"
// CapIssuesListNoAssignee and CapIssuesListTitle are the behavior
// capabilities that advertise GET /v0/beads/issues' `no_assignee` and `title`
// parameters (reads.go, spec OpListIssues): `bd list --no-assignee` and
// `--title`, carried as issueops.ListRequest's NoAssignee and TitleSearch and
// applied by the same Reader role (workapi.BuildListFilter) the local route
// reads through. Like CapIssuesListSearch each names a PARAMETER added to an
// existing operation, so each rides behaviorCapabilities and is the token its
// parameter's OpenAPI description cites for
// TestNewParameterOnExistingOperationHasABehaviorToken.
//
// One token per parameter rather than one for the set: each is a separate
// cutover dependency of a separate caller (gc's on_boot recovery, the PR-intake
// formula; CapListIDs below is the pr-review skill's), and a client names
// exactly the one a refused request needed.
//
// The client (internal/httpclient) refuses a request carrying either locally
// against a server that does not advertise its token, with ErrUnsupported
// naming the token: an older server answers the parameter with
// `unknown_parameter`, and dropping it would answer a WIDER listing than asked
// for (for gc's on_boot recovery, every in-progress bead, assigned or not).
const (
CapIssuesListNoAssignee = "issues.list.noAssignee"
CapIssuesListTitle = "issues.list.title"
)
// CapListIDs is the behavior capability that advertises the repeatable `id`
// filter on listIssues (issueops.ListRequest.IDFilter; `bd list --id`). It
// rides beside `issues.list` for the reason CapIssuesListSort does: the
// operation already exists, and what this announces is one more member it
// understands. The contract — one id per value, at most maxListIDs values,
// each matched exactly as sent — and the token's spelling are bd-enterprise's
// (E9-S2), adopted unchanged so the two servers publish one `id`.
const CapListIDs = "issues.list.ids"
// CapIssuesSweepWispsPlane is the behavior capability that advertises the
// `wisps-plane` value of SweepRequest.tier (sweep.go, spec SweepRequest.tier):
// a third, wider tier that clears the whole wisps table plus any durable bead
@ -1000,6 +1034,7 @@ var behaviorCapabilities = []string{
CapIssuesSweepWispsPlane, CapIssuesSweepLiveDependents, CapIssuesSweepLimit,
CapBatchApplyDepAddLineage, CapIssuesUpdateAllowTemplate, CapIssuesCreateDefaultPriority,
CapIssuesCloseAutoCloseMolecule, CapIssuesListSearch,
CapIssuesListNoAssignee, CapIssuesListTitle, CapListIDs,
}
// Capabilities lists what this build advertises in ContextResponse.capabilities:

View file

@ -638,7 +638,8 @@ func TestCapabilitiesAdvertiseEveryImplementedOperation(t *testing.T) {
want = append(want, "project.enforce", "issues.batchApplyLarge", "issues.list.sort", "issues.count.scope",
"issues.sweep.wispsPlane", "issues.sweep.liveDependents", "issues.sweep.limit",
"issues.batchApply.depAddLineage", "issues.update.allowTemplate", "issues.create.defaultPriority",
"issues.close.autoCloseMolecule", "issues.list.search")
"issues.close.autoCloseMolecule", "issues.list.search",
"issues.list.noAssignee", "issues.list.title", "issues.list.ids")
slices.Sort(want)
if !slices.Equal(got, want) {
t.Errorf("capabilities = %v, want %v", got, want)

View file

@ -1318,6 +1318,55 @@ paths:
that round trip.
schema:
type: string
- name: no_assignee
in: query
description: >-
Only issues with no assignee: `bd list --no-assignee`, handed to
the role as written beside the other filters.
Behind the `issues.list.noAssignee` behavior token: an older server
answers `unknown_parameter` for this name. A client with the
handshake's capabilities cached refuses the request locally against
a server that does not advertise the token, rather than paying for
that round trip or listing assigned issues as well.
schema:
type: boolean
default: false
- name: title
in: query
description: >-
Case-insensitive substring match on the title: `bd list --title`.
It narrows the listing and lifts none of its default exclusions.
Behind the `issues.list.title` behavior token: an older server
answers `unknown_parameter` for this name. A client with the
handshake's capabilities cached refuses the request locally against
a server that does not advertise the token, rather than paying for
that round trip or answering the unnarrowed listing.
schema:
type: string
- name: id
in: query
description: >-
Restrict to these canonical ids (repeat the parameter). AND-ed with
every other filter, including the default exclusions, so a caller
addressing rows regardless of status, type or tier also sends
all=true, include_templates, include_gates, include_infra and
include_ephemeral. At most 200 values; an id longer than storage
holds, an empty one, one with leading or trailing whitespace, or one
carrying a control character or a comma is a 400 `invalid_argument`
on `param: "id"` — each value is matched exactly as sent, never
trimmed or split. An id that names no row is simply not matched.
Advertised by the behavior token `issues.list.ids`.
style: form
explode: true
schema:
type: array
maxItems: 200
items:
type: string
- name: sort
in: query
description: >-
@ -8247,10 +8296,16 @@ components:
`POST /v0/beads/issues:batchClose` accept `auto_close_molecule`
and answer `auto_closed_molecule` and
`molecule_auto_close_refusal` rather than a `400` naming the
member unknown, and `issues.list.search`, which announces that
member unknown, `issues.list.search`, which announces that
`GET /v0/beads/issues` accepts `q`, `bd search`'s free text (see
that parameter), rather than silently answering
`unknown_parameter`. One behavior token is
`unknown_parameter`, and `issues.list.noAssignee`,
`issues.list.title` and `issues.list.ids`, which announce that
`GET /v0/beads/issues` accepts `no_assignee`, `title` and the
repeatable `id` respectively (`bd list --no-assignee`, `--title`
and `--id`; see those parameters) rather than answering
`unknown_parameter`. One
behavior token is
CONDITIONAL rather than build-level: `policy.external_dependencies`
announces that this server's ready, claim, claim-next, close,
blocking and dependency-tree operations already apply bd's

View file

@ -5775,6 +5775,15 @@
"style": "form",
"explode": true
},
{
"schema": "param:listIssues",
"member": "query:id",
"type": "array",
"required": false,
"item_type": "string",
"style": "form",
"explode": true
},
{
"schema": "param:listIssues",
"member": "query:include_ephemeral",
@ -5847,6 +5856,15 @@
"style": "form",
"explode": true
},
{
"schema": "param:listIssues",
"member": "query:no_assignee",
"type": "boolean",
"required": false,
"style": "form",
"explode": true,
"default": "false"
},
{
"schema": "param:listIssues",
"member": "query:parent",
@ -5885,6 +5903,14 @@
"style": "form",
"explode": true
},
{
"schema": "param:listIssues",
"member": "query:title",
"type": "string",
"required": false,
"style": "form",
"explode": true
},
{
"schema": "param:listIssues",
"member": "query:type",

View file

@ -117,6 +117,7 @@ go_test(
"insecure_credential_guard_test.go",
"lifecycle_create_test.go",
"lifecycle_update_test.go",
"list_scope_test.go",
"list_search_test.go",
"list_sort_test.go",
"metadatacas_test.go",

View file

@ -35,6 +35,7 @@ import (
"reflect"
"sort"
"strconv"
"strings"
"time"
"github.com/steveyegge/beads/internal/types"
@ -289,6 +290,7 @@ func ListParams(req issueops.ListRequest) (url.Values, error) {
b.str("status", req.Status)
b.str("type", req.IssueType)
b.str("assignee", req.Assignee)
b.boolean("no_assignee", req.NoAssignee)
b.list("label", req.Labels)
b.list("label_any", req.LabelsAny)
@ -296,6 +298,8 @@ func ListParams(req issueops.ListRequest) (url.Values, error) {
b.str("parent", req.ParentID)
b.str("q", req.Query)
b.str("title", req.TitleSearch)
b.list("id", splitIDSet(req.IDFilter))
b.boolean("all", req.AllFlag)
b.boolean("include_templates", req.IncludeTemplates)
@ -314,6 +318,28 @@ func ListParams(req issueops.ListRequest) (url.Values, error) {
return b.done()
}
// splitIDSet reads ListRequest.IDFilter's comma-separated set the way the role
// does (workapi.BuildListFilter: split on commas, trim, drop empties and
// repeats) and hands back one member per listIssues `id` value, which is the
// repeatable shape the server takes (issues.list.ids). A set naming no id
// sends no `id` at all.
func splitIDSet(set string) []string {
if set == "" {
return nil
}
var out []string
seen := map[string]bool{}
for _, id := range strings.Split(set, ",") {
id = strings.TrimSpace(id)
if id == "" || seen[id] {
continue
}
seen[id] = true
out = append(out, id)
}
return out
}
// QueryParams encodes a boolean-expression query onto
// GET /v0/beads/issues:query.
func QueryParams(req issueops.QueryRequest) (url.Values, error) {

View file

@ -108,10 +108,7 @@ func listRequestRows() []Row {
return refusal("E-ListRequest."+field, tyListRequest, field, what, why, fieldSpec)
}
rows := []Row{
listRefusal("TitleSearch", "a title search refuses", noWireList),
listRefusal("SpecPrefix", "a spec-id prefix restriction refuses", noWireList),
listRefusal("IDFilter", "an explicit id set on the LISTING refuses",
noWireList+"; the exact-ids question is getIssue's, reached through the SearchIssues bridge's exact-ids shape (D11), not through a listing filter"),
listRefusal("LabelPattern", "a glob label filter refuses",
noWireList+" — listReadyWork does publish label_pattern, which is exactly why the absence here has to refuse rather than fall through"),
listRefusal("LabelRegex", "a regex label filter refuses",
@ -130,8 +127,6 @@ func listRequestRows() []Row {
listRefusal("DueAfter", "a due-after bound refuses", noWireList),
listRefusal("DueBefore", "a due-before bound refuses", noWireList),
listRefusal("EmptyDesc", "the empty-description predicate refuses", noWireList),
listRefusal("NoAssignee", "the unassigned predicate refuses",
noWireList+" — listReadyWork publishes `unassigned`; the listing does not"),
listRefusal("NoLabels", "the no-labels predicate refuses", noWireList),
listRefusal("Priority", "an exact priority filter refuses",
noWireList+" — listReadyWork publishes `priority`; the listing does not"),

View file

@ -176,13 +176,18 @@ func roundTripCases() []roundTripCase {
Status: "open,in_progress",
IssueType: "bug",
Assignee: "agent-7",
// Beside Assignee on purpose: the wire carries both as written and the
// role decides what the pair means.
NoAssignee: true,
Labels: []string{"alpha", "beta"},
LabelsAny: []string{"gamma"},
ExcludeLabels: []string{"delta", "epsilon"},
ParentID: "bd-epic1",
Query: "login bug",
ParentID: "bd-epic1",
Query: "login bug",
TitleSearch: "Routed open task",
IDFilter: "bd-1,bd-wisp-9,bd-42",
AllFlag: true,
IncludeTemplates: true,

View file

@ -326,12 +326,19 @@ func listTable() Table {
param("Status", "status"),
paramTo("IssueType", "type", "IssueType"),
param("Assignee", "assignee"),
refused("TitleSearch", "E-ListRequest.TitleSearch"),
// TitleSearch, IDFilter and NoAssignee (S15b) are each behind their own
// behavior token — issues.list.title, issues.list.ids,
// issues.list.noAssignee: httpReader.List refuses a request carrying
// one, before dialing, unless the handshake advertises its token
// (role_reader.go refuseUnservedListFilters). IDFilter is split the
// way the role splits it and sent as the repeatable `id`, one value
// per member (bd-enterprise's contract, adopted unchanged).
paramTo("TitleSearch", "title", "TitleSearch"),
refused("SpecPrefix", "E-ListRequest.SpecPrefix"),
refused("IDFilter", "E-ListRequest.IDFilter"),
paramTo("IDFilter", "id", "IDFilter"),
// Behind issues.list.search: httpReader.List refuses a request
// carrying it, before dialing, unless the handshake advertises the
// token (role_reader.go refuseUnservedSearch).
// token (role_reader.go refuseUnservedListFilters).
param("Query", "q"),
param("Labels", "label"),
param("LabelsAny", "label_any"),
@ -354,7 +361,7 @@ func listTable() Table {
refused("DueAfter", "E-ListRequest.DueAfter"),
refused("DueBefore", "E-ListRequest.DueBefore"),
refused("EmptyDesc", "E-ListRequest.EmptyDesc"),
refused("NoAssignee", "E-ListRequest.NoAssignee"),
paramTo("NoAssignee", "no_assignee", "NoAssignee"),
refused("NoLabels", "E-ListRequest.NoLabels"),
dropped("SkipLabels", "E-ListRequest.SkipLabels",
"the wire hydrates labels either way; dropping the opt-out costs a join and hands the caller more data, never less"),

View file

@ -39,6 +39,13 @@ func (e *ErrHTTPUnsupported) Error() string {
if e.ServerURL == "" {
return e.Unsup.Error()
}
// A capability refusal names its token, as the portable sentinel does:
// "Reader.List" alone cannot tell a caller which of a listing's tokened
// filters the server lacks.
if e.Unsup.Capability != "" {
return fmt.Sprintf("operation %q not supported by the http backend (capability %q not advertised by bd serve at %s)",
e.Unsup.Op, e.Unsup.Capability, e.ServerURL)
}
return fmt.Sprintf("operation %q not supported by the http backend (bd serve at %s)",
e.Unsup.Op, e.ServerURL)
}

View file

@ -0,0 +1,100 @@
package httpclient
import (
"errors"
"slices"
"strings"
"testing"
"github.com/steveyegge/beads/internal/httpapi/apigen"
"github.com/steveyegge/beads/internal/httpclient/wire"
"github.com/steveyegge/beads/internal/storage"
"github.com/steveyegge/beads/issueops"
)
// listScopeCases are S15b's three ListRequest members, each with the
// listIssues parameter it rides and the behavior token that gates it:
// `bd list --no-assignee` (gc's on_boot recovery), `--title` (the PR-intake
// formula) and `--id` (the pr-review skill).
var listScopeCases = []struct {
name, param, token string
set func(*issueops.ListRequest)
want []string
}{
{"NoAssignee", "no_assignee", wire.CapListNoAssignee,
func(r *issueops.ListRequest) { r.NoAssignee = true }, []string{"true"}},
{"TitleSearch", "title", wire.CapListTitle,
func(r *issueops.ListRequest) { r.TitleSearch = "Routed open task" }, []string{"Routed open task"}},
{"IDFilter", "id", wire.CapListIDs,
// Split the way the role splits it, one `id` value per member.
func(r *issueops.ListRequest) { r.IDFilter = "e2e-r1, e2e-a1,e2e-r1" }, []string{"e2e-r1", "e2e-a1"}},
}
// TestListScopeFiltersRideTheirParametersBehindTheirTokens is S15b's client
// half: each member reaches listIssues as its own parameter once the
// handshake advertises its token.
func TestListScopeFiltersRideTheirParametersBehindTheirTokens(t *testing.T) {
for _, tc := range listScopeCases {
t.Run(tc.name, func(t *testing.T) {
served := &apigen.ContextResponse{Capabilities: []string{"issues.list", tc.token}}
w := newCountingWire(`{"items":[],"has_more":false}`)
limit := 10
req := issueops.ListRequest{Limit: &limit}
tc.set(&req)
if _, err := listRoleWithSnapshot(t, w, served).List(t.Context(), req); err != nil {
t.Fatalf("List: %v", err)
}
if got := w.query(t)[tc.param]; !slices.Equal(got, tc.want) {
t.Errorf("query[%s] = %v, want %v (full query: %v)", tc.param, got, tc.want, w.query(t))
}
})
}
}
// TestListScopeFiltersRefuseLocallyWhenTheServerLacksTheToken is the skew
// side: against a server that does not advertise a member's token (the
// deployed reference server, for one), a request carrying it refuses BEFORE
// dialing with the typed capability error naming that token. Sending it would
// cost a guaranteed 400 unknown_parameter; dropping it would answer a wider
// listing than asked for — for gc's on_boot recovery, every in-progress bead,
// assigned or not.
func TestListScopeFiltersRefuseLocallyWhenTheServerLacksTheToken(t *testing.T) {
for _, tc := range listScopeCases {
t.Run(tc.name, func(t *testing.T) {
// Every token but this one: each member is gated by its own.
var caps []string
for _, other := range listScopeCases {
if other.token != tc.token {
caps = append(caps, other.token)
}
}
masked := &apigen.ContextResponse{Capabilities: append([]string{"issues.list", wire.CapListSort}, caps...)}
w := newCountingWire(`{"items":[],"has_more":false}`)
req := issueops.ListRequest{}
tc.set(&req)
_, err := listRoleWithSnapshot(t, w, masked).List(t.Context(), req)
var unsup *storage.ErrUnsupported
if !errors.As(err, &unsup) {
t.Fatalf("List error = %v, want *storage.ErrUnsupported", err)
}
if unsup.Capability != tc.token || unsup.Op != "Reader.List" {
t.Errorf("refusal = {Op: %q, Capability: %q}, want {Reader.List, %s}", unsup.Op, unsup.Capability, tc.token)
}
if !strings.Contains(err.Error(), tc.token) {
t.Errorf("refusal text %q does not name %s; a user cannot tell which filter the server lacks", err, tc.token)
}
if len(w.dialed) != 0 {
t.Errorf("dialed %d times, want 0: a pre-dial refusal must never reach the wire", len(w.dialed))
}
// A listing without the member is unaffected by the missing token.
limit := 10
if _, err := listRoleWithSnapshot(t, w, masked).List(t.Context(), issueops.ListRequest{Limit: &limit}); err != nil {
t.Fatalf("List without %s against the same server: %v", tc.name, err)
}
if q := w.query(t); q.Has(tc.param) {
t.Errorf("a listing without %s sent %s: %v", tc.name, tc.param, q)
}
})
}
}

View file

@ -6,6 +6,7 @@ import (
"context"
"net/http"
"slices"
"strings"
"github.com/steveyegge/beads/internal/httpapi/apigen"
"github.com/steveyegge/beads/internal/httpclient/encode"
@ -63,7 +64,7 @@ func (r httpReader) Ready(ctx context.Context, req issueops.ReadyRequest) (issue
// List serves listIssues, through the pager in list_walk.go.
func (r httpReader) List(ctx context.Context, req issueops.ListRequest) (issueops.IssuePage, error) {
if err := r.refuseUnservedSearch(ctx, req); err != nil {
if err := r.refuseUnservedListFilters(ctx, req); err != nil {
return issueops.IssuePage{}, err
}
params, err := encode.ListParams(req)
@ -73,28 +74,53 @@ func (r httpReader) List(ctx context.Context, req issueops.ListRequest) (issueop
return r.store.walkIssues(ctx, params, req)
}
// refuseUnservedSearch is the pre-dial gate for ListRequest.Query, which rides
// listIssues' `q` only on a server advertising issues.list.search. An older
// server answers `q` with 400 unknown_parameter, so a search against it is
// refused HERE, with the typed capability error naming the token: never a
// round trip that is refused anyway, and never the unsearched listing passed
// off as the search.
// tokenedListFilters are the ListRequest members listIssues carries only on a
// server advertising a behavior token of their own, each with that token:
// `bd search`'s text (S26) and `bd list --title`, `--id` and `--no-assignee`
// (S15b). Order decides which token a request carrying several names; each
// refusal is complete on its own, so any order is honest.
var tokenedListFilters = []struct {
token string
set func(issueops.ListRequest) bool
}{
{wire.CapListSearch, func(r issueops.ListRequest) bool { return r.Query != "" }},
{wire.CapListNoAssignee, func(r issueops.ListRequest) bool { return r.NoAssignee }},
{wire.CapListTitle, func(r issueops.ListRequest) bool { return r.TitleSearch != "" }},
// An id set naming no id (only commas and blanks) sends no `id`, so it
// needs no token.
{wire.CapListIDs, func(r issueops.ListRequest) bool {
return strings.TrimSpace(strings.ReplaceAll(r.IDFilter, ",", "")) != ""
}},
}
// refuseUnservedListFilters is the pre-dial gate for the tokened members. An
// older server answers each one's parameter with 400 unknown_parameter, so a
// request carrying one against a server that does not advertise its token is
// refused HERE, with the typed capability error naming that token: never a
// round trip that is refused anyway, and never a wider listing (the
// unsearched one, every in-progress bead instead of the unassigned ones, the
// whole workspace instead of an id set) passed off as the answer.
//
// listIssues is a baseline operation, so dispatch preflights nothing for it;
// this is the one handshake a search costs, and a request without Query never
// asks for it.
func (r httpReader) refuseUnservedSearch(ctx context.Context, req issueops.ListRequest) error {
if req.Query == "" {
return nil
// this is the one handshake a tokened request costs, and a request without
// any of these members never asks for it.
func (r httpReader) refuseUnservedListFilters(ctx context.Context, req issueops.ListRequest) error {
var snap *apigen.ContextResponse
for _, f := range tokenedListFilters {
if !f.set(req) {
continue
}
if snap == nil {
var err error
if snap, err = r.store.snapshot(ctx); err != nil {
return err
}
}
if snap == nil || !slices.Contains(snap.Capabilities, f.token) {
return r.store.unsupportedCapability("Reader.List", f.token)
}
}
snap, err := r.store.snapshot(ctx)
if err != nil {
return err
}
if snap != nil && slices.Contains(snap.Capabilities, wire.CapListSearch) {
return nil
}
return r.store.unsupportedCapability("Reader.List", wire.CapListSearch)
return nil
}
// Get serves getIssue, including the two landed include parameters that retired

View file

@ -239,13 +239,13 @@ func TestReadRolesRefuseWhatTheWireCannotCarry(t *testing.T) {
t.Fatalf("IssueReader(): %v", err)
}
_, err = reader.List(ctx, issueops.ListRequest{IDFilter: "bd-1"})
_, err = reader.List(ctx, issueops.ListRequest{SpecPrefix: "docs/"})
var inexpressible *InexpressibleError
if !errors.As(err, &inexpressible) {
t.Fatalf("List with an IDFilter = %v, want *InexpressibleError", err)
t.Fatalf("List with a SpecPrefix = %v, want *InexpressibleError", err)
}
if inexpressible.Refused.Row.Field != "IDFilter" {
t.Errorf("the refusal names %q, want IDFilter", inexpressible.Refused.Row.Field)
if inexpressible.Refused.Row.Field != "SpecPrefix" {
t.Errorf("the refusal names %q, want SpecPrefix", inexpressible.Refused.Row.Field)
}
if inexpressible.Refused.Row.SpecRow == "" || inexpressible.Refused.Row.Why == "" {
t.Error("the refusal carries a ledger row with no reason or no citation")

View file

@ -15,9 +15,9 @@ import (
// The Counter contract, run through the http client against a real bd serve.
//
// NOTHING IS PARKED HERE, and on this role that is a statement rather than a
// happy accident. Every case scopes itself with IDFilter — the count publishes
// `id` where the LISTING does not, which is why the Reader family parks nine
// cases on E-ListRequest.IDFilter and this one parks none — and every filter the
// happy accident. Every case scopes itself with IDFilter — the count has
// always published `id` (the listing gained it, behind issues.list.ids, with
// S15b) — and every filter the
// contract reaches for is a parameter this operation carries. The plane cases in
// particular cross whole: `include_infra` is one flag on the wire and one flag
// on the request, and what it MEANS is four decisions the server's own role

View file

@ -27,11 +27,11 @@ import (
// asserted through the same composition.
//
// Almost every List case in reader_contract.go scopes itself with IDFilter, and
// listIssues publishes no id parameter, so those cases are parked next door and
// their behaviors are pinned HERE instead — same assertions, scoped by a label,
// which the wire does carry. What is not restated here is anything the contract
// case actually runs: this file exists to close the gap the parking opened, not
// to grow a second contract.
// until S15b listIssues published no id parameter, so those cases were parked
// next door and their behaviors were pinned HERE instead — same assertions,
// scoped by a label. The id scope now rides `id` (issues.list.ids) and the
// contract cases run as written beside these; the label-scoped twins stay as
// the form of the same assertions a server without that token can still run.
// listScope mints a label nothing else in the package uses.
func listScope(name string) string { return servedIssuePrefix + "-ls-" + name }
@ -1472,7 +1472,7 @@ func TestServedReaderRefusesTheFiltersTheWireCannotCarry(t *testing.T) {
field string
req issueops.ListRequest
}{
{"IDFilter", issueops.ListRequest{IDFilter: listID("refuse", "a")}},
{"SpecPrefix", issueops.ListRequest{SpecPrefix: "docs/"}},
{"ReadyFlag", issueops.ListRequest{ReadyFlag: true}},
{"Offset", issueops.ListRequest{Offset: 1}},
{"PinnedFlag", issueops.ListRequest{PinnedFlag: true}},
@ -1519,9 +1519,8 @@ func seedListWisp(t *testing.T, ctx context.Context, c *servedComposition, id, s
// TestServedReaderListIncludeEphemeralMergesThePlanesUnderALabelScope is
// RunReaderListIncludeEphemeralMergesThePlanesIntoOneOrder with the id scope
// swapped for a label one, which is the swap this whole file exists to make:
// the contract case scopes itself with IDFilter and listIssues publishes no id
// parameter (E-ListRequest.IDFilter), so the case is parked next door and its
// behavior is pinned here instead.
// the contract case scopes itself with IDFilter, which was parked next door
// until S15b put `id` on listIssues; both run now.
//
// WHAT IT IS ABOUT is not admission but ORDER. That the flag admits wisps at
// all is already covered by RunReaderListDefaultExclusionsAndTheirOverrides,

View file

@ -22,24 +22,23 @@ import (
// survives the JSON round trip. The seed handles are the reference store's, so
// a filter this client dropped answers with rows no case seeded.
//
// WHAT IS PARKED, and it is one cause with many names: `ListRequest.IDFilter`
// is the scoping tool almost every List case reaches for, and listIssues
// publishes no id parameter (E-ListRequest.IDFilter). Refusing it is correct —
// dropping it would answer about the whole workspace — but a case that scopes
// itself with it cannot run over this wire at all. Each parked case names the
// field that refused, and the refusal ITSELF is asserted below in
// TestServedReaderRefusesTheFiltersTheWireCannotCarry, so the parking never
// stands in for an unpinned behaviour.
// WHAT IS PARKED: `ListRequest.IDFilter` is the scoping tool almost every List
// case reaches for, and until S15b listIssues published no id parameter, so
// those cases parked on E-ListRequest.IDFilter. It now rides `id` behind
// issues.list.ids, which this in-process server serves, and they run as
// written. What still parks is a case whose SUBJECT (or one arm) is a member
// the wire refuses — Offset, ReadyFlag, PinnedFlag, ExcludeTypes, WispType,
// SkipCounts — and each names that member's row. The refusals THEMSELVES are
// asserted in TestServedReaderRefusesTheFiltersTheWireCannotCarry, so the
// parking never stands in for an unpinned behaviour.
// readParkBead is the bead every READ-side park cites, and it is a different
// constant from the write side's parkBead because it is a different decision
// with a different retirement.
//
// The write parks retire when the wire grows the members it deliberately
// withholds, or never. These retire when the wire grows a way to SCOPE a
// listing by id — the upstream ask D8 row 1 records alongside the `sort`
// parameter — at which point almost all of them go at once. Folding the two
// into one constant would have said they move together, which they do not.
// withholds, or never. These retire one member at a time as the wire grows a
// parameter for it; the id scope that held most of them retired with S15b.
const readParkBead = "ga-pcwtq"
func servedReaderFixture(t *testing.T, name string) conformance.ReaderFixture {
@ -127,37 +126,29 @@ func TestServedReaderReadySetOwnsItsStatusPinnedAndTemplateDecisions(t *testing.
}
func TestServedReaderOffsetSkipsTheRowsBeforeThePage(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the List arm scopes itself with IDFilter, which listIssues publishes no parameter for; the Offset "+
"refusal this wire answers with instead is pinned by TestServedReaderRefusesTheFiltersTheWireCannotCarry")
skipKnownDivergence(t, "E-ListRequest.Offset", readParkBead,
"the case's subject is Offset, which neither listIssues nor listReadyWork publishes (its id scope now "+
"rides `id`); the Offset refusal this wire answers with instead is pinned by "+
"TestServedReaderRefusesTheFiltersTheWireCannotCarry")
conformance.RunReaderOffsetSkipsTheRowsBeforeThePage(t, t.Context(), servedReaderFixture(t, "rdr"))
}
func TestServedReaderListDefaultExclusionsAndTheirOverrides(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"every arm scopes itself with IDFilter, and two of them additionally set PinnedFlag/NoPinnedFlag, "+
"which listIssues publishes no parameters for")
skipKnownDivergence(t, "E-ListRequest.PinnedFlag", readParkBead,
"two arms set PinnedFlag/NoPinnedFlag, which listIssues publishes no parameters for (the id scope "+
"every arm uses now rides `id`)")
conformance.RunReaderListDefaultExclusionsAndTheirOverrides(t, t.Context(), servedReaderFixture(t, "rdr"))
}
func TestServedReaderListRejectsATypeOutsideTheWorkspaceVocabulary(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the built-in-type arm scopes itself with IDFilter; the vocabulary refusal itself is served (the "+
"server validates against its own authoritative vocabulary, which is what heals L7 for this query)")
conformance.RunReaderListRejectsATypeOutsideTheWorkspaceVocabulary(t, t.Context(), servedReaderFixture(t, "rdr"))
}
func TestServedReaderListNaturalNumericIDSortTrimsAfterTheFetch(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with IDFilter; the natural-numeric order it pins is exercised over this wire "+
"by TestServedReaderListAppliesTheClientSideDisplayOrder")
conformance.RunReaderListNaturalNumericIDSortTrimsAfterTheFetch(t, t.Context(), servedReaderFixture(t, "rdr"))
}
func TestServedReaderListKeysetPositionResumesTheCreatedDescIDAscOrder(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with IDFilter; the skip-forward walk it pins is exercised over this wire by "+
"TestServedReaderListKeysetPositionSkipsForward, which is the same assertion under a label scope")
conformance.RunReaderListKeysetPositionResumesTheCreatedDescIDAscOrder(t, t.Context(), servedReaderFixture(t, "rdr"))
}
@ -176,9 +167,6 @@ func TestServedReaderListReadyFlagRefusesAFilterItCannotCarry(t *testing.T) {
}
func TestServedReaderListEmptyPageIsWellFormed(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the List arm scopes itself with IDFilter; the empty-page shape is pinned over this wire by "+
"TestServedReaderListEmptyPageIsWellFormedUnderALabelScope")
conformance.RunReaderListEmptyPageIsWellFormed(t, t.Context(), servedReaderFixture(t, "rdr"))
}
@ -190,8 +178,9 @@ func TestServedReaderListQueryMatchesTheTitleOrTheID(t *testing.T) {
}
func TestServedReaderListMaxRowsIsHonored(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with IDFilter; the cap it pins is honored over this wire and exercised by "+
skipKnownDivergence(t, "E-ListRequest.Offset", readParkBead,
"one arm drives the cap behind an Offset, which listIssues publishes no parameter for (its id scope "+
"now rides `id`); the cap is honored over this wire and exercised by "+
"TestServedReaderListMaxRowsBoundsWireRowsFetched")
conformance.RunReaderListMaxRowsIsHonored(t, t.Context(), servedReaderFixture(t, "rdr"))
}
@ -200,14 +189,11 @@ func TestServedReaderListSkipCountsDropsTheCardinalitiesAndNothingElse(t *testin
skipKnownDivergence(t, "E-ListRequest.SkipCounts", readParkBead,
"the knob is DROPPED rather than refused (the wire hydrates the three cardinalities either way, and "+
"every text rendering of `bd list` sets it, so refusing would kill the default listing over http); "+
"the case additionally scopes itself with IDFilter")
"its id scope rides `id` (issues.list.ids)")
conformance.RunReaderListSkipCountsDropsTheCardinalitiesAndNothingElse(t, t.Context(), servedReaderFixture(t, "rdr"))
}
func TestServedReaderListLimitBoundaryUnderASortTheDatabaseCanExpress(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with IDFilter; the limit boundary under created order is pinned over this "+
"wire by TestServedReaderListLimitBoundaryUnderALabelScope")
conformance.RunReaderListLimitBoundaryUnderASortTheDatabaseCanExpress(t, t.Context(), servedReaderFixture(t, "rdr"))
}
@ -218,83 +204,49 @@ func TestServedReaderListReadyFlagCarriesTheAssigneeAndPriorityFilters(t *testin
}
// TestServedReaderListIncludeEphemeralMergesThePlanesIntoOneOrder is the plane
// contract client wave ga-mijra brought into range, and it parks for the same
// reason every List case here parks: it scopes itself with IDFilter, which
// listIssues publishes no parameter for.
//
// The behavior it asserts is pinned by
// TestServedReaderListIncludeEphemeralMergesThePlanesUnderALabelScope, which is
// the same fixture — alternating planes, every Limit cut, the keyset walk —
// with the id scope swapped for a label one, plus the plane-identity assertion
// contract client wave ga-mijra brought into range. It scopes itself with
// IDFilter, which rides listIssues' `id` behind issues.list.ids (S15b), so it
// runs as written; TestServedReaderListIncludeEphemeralMergesThePlanesUnderALabelScope
// is the same fixture under a label scope, plus the plane-identity assertion
// the contract does not make.
func TestServedReaderListIncludeEphemeralMergesThePlanesIntoOneOrder(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with ListRequest.IDFilter and listIssues publishes no id parameter; "+
"the merged-plane order, the Limit cuts and the keyset walk are asserted under a label scope by "+
"TestServedReaderListIncludeEphemeralMergesThePlanesUnderALabelScope")
conformance.RunReaderListIncludeEphemeralMergesThePlanesIntoOneOrder(t, t.Context(), servedReaderFixture(t, "rdr"))
}
// The FIVE remaining List parks, each named so the wiring lock counts the
// contract as accounted for rather than merely absent, and each deleted in one
// line the day its row retires.
//
// Three of them park on the id scope alone, which is this family's one cause.
// The other two would park even under a label scope, because their SUBJECT is a
// member the wire refuses — so each names that member instead.
// The id-scoped List cases that parked on E-ListRequest.IDFilter until S15b
// put `id` on listIssues (issues.list.ids). They run as written now; the two
// below them still park, because their SUBJECT is a member the wire refuses.
func TestServedReaderListCountsAreBlocksOnlyWhereGetCountsEveryEdge(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with IDFilter; the blocks-only rule it pins is exercised over this wire by "+
"the cardinality assertions in TestServedReaderReadyPageIsThePrefixOfTheUnboundedAnswerCountsIncluded, "+
"whose `family` row carries a parent-child and a relates-to edge and still reports zero dependencies")
conformance.RunReaderListCountsAreBlocksOnlyWhereGetCountsEveryEdge(t, t.Context(), servedReaderFixture(t, "rdr"))
}
func TestServedReaderListKeysetPositionNarrowsWithoutReplacingTheOtherPredicates(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with IDFilter — its shadow rows share every timestamp with the scoped ones "+
"and are excluded by the id set ALONE, which is the whole mechanism by which a widened position "+
"is caught, so a label scope would not stand in for it")
conformance.RunReaderListKeysetPositionNarrowsWithoutReplacingTheOtherPredicates(t, t.Context(), servedReaderFixture(t, "rdr"))
}
func TestServedReaderListKeysetWalkOverAnOversizedGroupLosesNothingAndRepeatsNothing(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with IDFilter; the keyset walk it pins is exercised over this wire by "+
"TestServedReaderListKeysetPositionSkipsForward and by TestServedReaderListWalksMultiplePages, "+
"both under a label scope")
conformance.RunReaderListKeysetWalkOverAnOversizedGroupLosesNothingAndRepeatsNothing(t, t.Context(), servedReaderFixture(t, "rdr"))
}
// The priority-order walk parks on the same row as the created-order one
// above, with a narrower stand-in beside it: the sort=priority pushdown is
// pinned under a label scope by TestServedReaderListFallsBackToTheWalkWithoutTheCapability,
// and resuming a priority keyset position — the pager's keysetFilter
// (list_walk.go) deciding priority first and the (created_at, id) pair only at
// the position's own priority — by TestServedReaderListPriorityKeysetPositionResumesThePriorityOrder.
// What neither covers is the WALK this case drives page after page over an
// oversized equal-key run, which stays unexercised over this wire until
// IDFilter (or a label-scoped rewrite) lets it run.
// The priority-order walk over an oversized equal-key run, page after page:
// the sort=priority pushdown (TestServedReaderListFallsBackToTheWalkWithoutTheCapability)
// and one resumed priority keyset position
// (TestServedReaderListPriorityKeysetPositionResumesThePriorityOrder) do not
// cover the WALK, which this id-scoped case drives now that `id` is served.
func TestServedReaderListPriorityKeysetWalkOverAnOversizedEqualKeyRunLosesNothingAndRepeatsNothing(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with IDFilter, which listIssues publishes no parameter for, so its one-shot "+
"read is refused before the walk begins; the sort=priority pushdown is pinned under a label scope by "+
"TestServedReaderListFallsBackToTheWalkWithoutTheCapability, and one resumed priority keyset position by "+
"TestServedReaderListPriorityKeysetPositionResumesThePriorityOrder")
conformance.RunReaderListPriorityKeysetWalkOverAnOversizedEqualKeyRunLosesNothingAndRepeatsNothing(t, t.Context(), servedReaderFixture(t, "rdr"))
}
// TestServedReaderListMaxRowsBoundaryIsLimitPlusOffset names OFFSET rather than
// the id scope it also carries, because Offset is the one this case could not
// be rewritten around: the whole point is to drive the cap along the OFFSET
// TestServedReaderListMaxRowsBoundaryIsLimitPlusOffset parks on OFFSET: the
// whole point is to drive the cap along the OFFSET
// axis with the limit held still, and listIssues publishes no offset parameter.
// The LIMIT axis of the same boundary runs over this wire in
// TestServedReaderListMaxRowsBoundsWireRowsFetched.
func TestServedReaderListMaxRowsBoundaryIsLimitPlusOffset(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.Offset", readParkBead,
"the case moves the cap along the Offset axis, and listIssues publishes no offset parameter (it "+
"scopes itself with IDFilter besides); the cap's Limit axis is driven over this wire by "+
"the case moves the cap along the Offset axis, and listIssues publishes no offset parameter; "+
"the cap's Limit axis is driven over this wire by "+
"TestServedReaderListMaxRowsBoundsWireRowsFetched")
conformance.RunReaderListMaxRowsBoundaryIsLimitPlusOffset(t, t.Context(), servedReaderFixture(t, "rdr"))
}
@ -314,9 +266,6 @@ func TestServedReaderListWispTypeNarrowsTheAdmittedPlaneRatherThanAdmittingIt(t
}
func TestServedReaderListStatusAcceptsACommaSeparatedORSet(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with IDFilter; the OR set it pins is exercised over this wire by "+
"TestServedReaderListStatusORSetUnderALabelScope, which drives the same three status shapes")
conformance.RunReaderListStatusAcceptsACommaSeparatedORSet(t, t.Context(), servedReaderFixture(t, "rdr"))
}
@ -337,18 +286,10 @@ func TestServedReaderListStatusAcceptsACommaSeparatedORSet(t *testing.T) {
// their rows through one function. TestBriefListingsStampTheProjectionMarker
// asserts that door-by-door; these assert what a projected row must contain.
// TestServedReaderListBriefDropsTheFreeFormTextAndNothingElse parks for the
// reason every List case here parks — it scopes itself with IDFilter, and
// listIssues publishes no id parameter — NOT for anything about the projection.
//
// The projection half is asserted over this wire by the ready sibling below,
// which drives the identical assertReaderBriefRow through the same encoder and
// the same row lift, under a label scope instead of an id one.
// TestServedReaderListBriefDropsTheFreeFormTextAndNothingElse scopes itself
// with IDFilter, which rides `id` (issues.list.ids), and the ready sibling below
// drives the identical assertReaderBriefRow under a label scope.
func TestServedReaderListBriefDropsTheFreeFormTextAndNothingElse(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the case scopes itself with IDFilter; the projection it pins — the six heavy columns empty, the "+
"identity fields and the three cardinalities intact, and IsLitePartial set — is asserted over this "+
"wire by TestServedReaderReadyBriefDropsTheFreeFormTextAndNothingElse under a label scope")
conformance.RunReaderListBriefDropsTheFreeFormTextAndNothingElse(t, t.Context(), servedReaderFixture(t, "rdr"))
}
@ -442,8 +383,9 @@ func TestServedReaderGetPopulatesRowVersionForAGuardedWrite(t *testing.T) {
}
func TestServedReaderDoesNotMutateTheCallerRequest(t *testing.T) {
skipKnownDivergence(t, "E-ListRequest.IDFilter", readParkBead,
"the List leg of the tripwire scopes itself with IDFilter; the promise is exercised over this wire "+
"by TestServedReaderDoesNotMutateTheCallerRequestOverTheWire")
skipKnownDivergence(t, "E-ListRequest.ExcludeTypes", readParkBead,
"the List leg of the tripwire sets ExcludeTypes, which listIssues publishes no parameter for (its id "+
"scope now rides `id`); the promise is exercised over this wire by "+
"TestServedReaderDoesNotMutateTheCallerRequestOverTheWire")
conformance.RunReaderDoesNotMutateTheCallerRequest(t, t.Context(), servedReaderFixture(t, "rdr"))
}

View file

@ -163,6 +163,22 @@ const CapCountScope = "issues.count.scope"
// `unknown_parameter`, and is never widened into the unsearched listing.
const CapListSearch = "issues.list.search"
// CapListNoAssignee, CapListTitle and CapListIDs are the behavior
// capabilities announcing that listIssues honors `no_assignee`, `title` and the
// repeatable `id` (`bd list --no-assignee`, `--title`, `--id`;
// issueops.ListRequest's NoAssignee, TitleSearch and IDFilter), spelled exactly
// as httpapi's CapIssuesListNoAssignee, CapIssuesListTitle and CapListIDs. The
// Reader's List reads them off the handshake snapshot and refuses a request
// carrying a member LOCALLY, with a typed capability error naming that
// member's token, when the server does not advertise it — never a round trip
// an older server answers `unknown_parameter`, never a wider listing than
// asked for.
const (
CapListNoAssignee = "issues.list.noAssignee"
CapListTitle = "issues.list.title"
CapListIDs = "issues.list.ids"
)
// 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
@ -392,6 +408,7 @@ var behaviorCapabilities = []string{
CapSweepWispsPlane, CapSweepLiveDependents, CapSweepLimit,
CapBatchApplyDepAddLineage, CapIssuesUpdateAllowTemplate, CapIssuesCreateDefaultPriority,
CapCloseAutoCloseMolecule, CapListSearch,
CapListNoAssignee, CapListTitle, CapListIDs,
}
// CapabilityFor reports the capability token gating op, and whether op is on

View file

@ -151,6 +151,15 @@ func TestTheProjectIdentityVocabularyMatchesTheServer(t *testing.T) {
if CapListSearch != httpapi.CapIssuesListSearch {
t.Errorf("CapListSearch = %q, server says %q", CapListSearch, httpapi.CapIssuesListSearch)
}
if CapListNoAssignee != httpapi.CapIssuesListNoAssignee {
t.Errorf("CapListNoAssignee = %q, server says %q", CapListNoAssignee, httpapi.CapIssuesListNoAssignee)
}
if CapListTitle != httpapi.CapIssuesListTitle {
t.Errorf("CapListTitle = %q, server says %q", CapListTitle, httpapi.CapIssuesListTitle)
}
if CapListIDs != httpapi.CapListIDs {
t.Errorf("CapListIDs = %q, server says %q", CapListIDs, httpapi.CapListIDs)
}
if CapCountScope != httpapi.CapIssuesCountScope {
t.Errorf("CapCountScope = %q, server says %q", CapCountScope, httpapi.CapIssuesCountScope)
}
@ -205,10 +214,12 @@ func TestTheProjectIdentityVocabularyMatchesTheServer(t *testing.T) {
httpapi.CapIssuesSweepWispsPlane, httpapi.CapIssuesSweepLiveDependents, httpapi.CapIssuesSweepLimit,
httpapi.CapBatchApplyDepAddLineage, httpapi.CapIssuesUpdateAllowTemplate, httpapi.CapIssuesCreateDefaultPriority,
httpapi.CapIssuesCloseAutoCloseMolecule, httpapi.CapIssuesListSearch,
httpapi.CapIssuesListNoAssignee, httpapi.CapIssuesListTitle, httpapi.CapListIDs,
}) {
t.Errorf("behaviorCapabilities = %v, want the server's project.enforce, issues.batchApplyLarge, issues.list.sort, "+
"issues.count.scope, issues.sweep.wispsPlane, issues.sweep.liveDependents, issues.sweep.limit, "+
"issues.batchApply.depAddLineage, issues.update.allowTemplate, issues.create.defaultPriority, issues.close.autoCloseMolecule and issues.list.search tokens", behaviorCapabilities)
"issues.batchApply.depAddLineage, issues.update.allowTemplate, issues.create.defaultPriority, issues.close.autoCloseMolecule, issues.list.search, "+
"issues.list.noAssignee, issues.list.title and issues.list.ids tokens", behaviorCapabilities)
}
}