* feat(roles): BatchGetter role and issues:batchGet route (S7)
Adds BatchGetter.GetMany(ids) -> {Issues, Missing}, a one-snapshot,
order-preserving, deduped, 1000-id-capped batch read, wired through all
three library legs (dolt, embedded dolt, uow) behind the existing
hook/telemetry decorator chain, plus the POST /v0/beads/issues:batchGet
HTTP route (spec, apigen, wire-shape golden, issues.batchGet capability
token). Conformance contract (RunBatchGetter*, 12 cases) passes on all
three legs against real backends. No HTTP client leg yet (waits on the
generator / PR #7247); left as a documented seam on BatchGetter's doc
comment.
CLI GetIssuesByIDs call sites are left unmigrated this slice and marked
with TODO(batchgetter) comments: every call site reads an unbounded id
list today, and GetMany's 1000-id cap has no chunking/fallback in any
caller yet, so swapping them in now would add a new, unhandled failure
mode to already-shipped CLI paths (export, import, molecule port,
ready-explain, wisp sweep).
Verified via three live-mutate guards against
internal/storage/issueops/batchget.go (disabling the cap check, dropping
the Missing append, and replacing ordered iteration with map iteration):
each turns the embedded-dolt contract red, confirming the cap, Missing
reporting, and order-preservation assertions actually catch a break.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(roles): close S7 review gaps — revision on wire, BUILD sync, handler tests
Addresses the S7 Opus review's FIX-FIRST items on BatchGetter/issues:batchGet:
HIGH
- batchGetResponse now projects apigen.BatchGetIssue (types.BatchGetIssue +
NewBatchGetIssue), carrying `revision` per issue the way IssueDetails does;
spec, apigen and the wire-shape golden regenerated (additive, no
wire_revision bump).
- make bazel-sync: the 12 files missing from BUILD.bazel srcs are back in
sync across 9 BUILD.bazel files.
- New internal/httpapi/batch_get_test.go: success incl. revision, missing
ids, empty arrays not null, unknown member refused, missing/null ids
refused, query parameter refused, 1001 ids refused with the full request
reaching the role, 1000 ids accepted.
MED
- RunBatchGetterAcceptsExactlyTheCap pins the cap boundary (> vs >=).
- RunBatchGetterHydratesLabels pins Labels survive projection.
- RunBatchGetterReadsOneSnapshot renamed to
RunBatchGetterSharesOneReadStructurally with a doc that no longer
overclaims atomicity; a real interleaving test needs a hook on the frozen
roleFixtureKit, out of scope here.
- Doc comments across ExecuteGetMany, GetManyResult.Issues and the
BatchGetter interface now say hydration is labels only.
LOW
- failBatchGetErr's doc no longer claims blank entries are "already caught".
- PR #7247 references kept.
Re-ran build/vet/gofmt/lint, make api-check, make bazel-sync(-check), the
full internal/httpapi suite, and all three conformance legs (dolt via the
pinned local server, embeddeddolt, uow) plus targeted cmd/bd serve tests —
all green. Live-mutate-guard reverified: cap >=, dropping Missing from the
response, and clearing Labels each now fail the relevant test.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(roles): sync client vocabulary and repo gates with issues:batchGet
The S7 route landed on the server without the sibling tables that hold
the rest of the tree set-equal with the server's surface, so five
tests and two manifest gates went red on the PR head:
- httpclient/wire: mirror batchGetIssues into the client vocabulary,
CLASSIFIED, not wired, the way the wire wave and #7250's
issues.count.scope landed: OpBatchGetIssues, its issues.batchGet
token on opCapability, its identity row, and the first-slice skew
dimension 35 -> 36 (TestCapabilityTableMatchesTheServerRouteTable).
- httpclient/wire: BatchGetIssue is the first golden.json schema with
a `revision` member that needs no legacy-integer tolerance — the
route postdates #6053 and types.BatchGetIssue declares Revision a
string, and a pre-#6053 server never advertises issues.batchGet, so
Preflight refuses before any body is decoded. Exempt it with that
reason in a new revisionSchemaExempt table rather than adding an
issues[] rewrite no legacy server can reach; the gate refuses an
entry that is both covered and exempt, a stale exemption, and an
empty reason.
- httpclient/encode: give the oracle's role set a BatchGetter stub —
httpapi.Listen requires the whole set, so all three oracle tests
failed to bind.
- storage/uow: exempt IssueUseCase.GetMany from the notifying-parity
partition as a read, the reason hook_batch_getter.go gives.
- shard manifest: place TestBatchGetterContract in the 15-shard
embedded storage block (generator --write, incremental).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(roles): pin the BatchGetter pure tier and the spec ids caps
Review fixes, iteration 1. The review approved with no blocker or major
finding and three minors, and this commit takes all three. It changes
tests and one comment only, and every new assertion was mutation-probed
with go test -overlay.
- storage/issueops: add batchget_test.go, the database-free tier that
FinishGetMany's doc already claimed ("pinned without a database") but
that no test supplied. It pins:
- the cap is checked before the blank scan (an over-cap request with
a blank at position 0 answers *TooManyIDsError);
- the bound is inclusive;
- dedupe keeps the first mention, does not trim, and never writes
through the caller's slice;
- Issues and Missing both follow request order;
- both slices are never nil;
- ExecuteGetMany refuses one id repeated past the cap before any
query (a sqlmock with no expectations).
Ten mutants were each killed by exactly their intended test, with the
rest of the package green: last-mention, sort, trim, in-place dedupe,
blank-before-cap, >=, nil Missing, nil Issues, dedupe-before-validate
and validate-after-query.
- httpapi: TestSpecDefaultsMatchSharedConstants now checks ids.maxItems
against the enforced bound on the two request bodies that carry an
`ids` list: batchGetIssues against issueops.MaxGetManyIDs, and
deleteIssues against maxDeleteIDs. Each body is reached through its
operation's own requestBody $ref. Setting either constant to 999 turns
only this test red. The spec's other list caps (batch
create/close/apply items, dependency edge lists) stay ungated, as
before.
- cmd/bd/serve.go: the batchGetter field comment said its accessor
"does NOT recurse through the hook decorator". HookFiringStore.
BatchGetter does recurse to the inner getter; it just doesn't wrap
the result. The comment now says that.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
84 lines
4.3 KiB
Go
84 lines
4.3 KiB
Go
package httpapi
|
|
|
|
import (
|
|
"github.com/steveyegge/beads/internal/eventsjournal"
|
|
"github.com/steveyegge/beads/internal/httpapi/apigen"
|
|
"github.com/steveyegge/beads/internal/types"
|
|
"github.com/steveyegge/beads/issueops"
|
|
)
|
|
|
|
// Compile-time proof that the generated wire types ARE the canonical structs,
|
|
// not mirrors of them. There is no Go-to-Go mapping layer on this surface: the
|
|
// CLI's --json output, the JSONL interchange and the HTTP bodies all marshal
|
|
// one struct, so a new types.Issue field appears on the wire automatically
|
|
// instead of silently vanishing.
|
|
//
|
|
// These assignments (not conversions — a conversion between two structurally
|
|
// identical structs compiles) fail the BUILD if oapi-codegen ever emits a
|
|
// mirror struct or aliases a schema to the wrong type. That is not
|
|
// hypothetical: v2.6.0 drops a component's x-go-type when the component also
|
|
// carries allOf, and an allOf-composed IssueWithCounts generated
|
|
// `type IssueWithCounts = types.Issue` — the ready endpoint would have shipped
|
|
// bare issues with the count fields silently gone. The spec repeats property
|
|
// lists instead of composing for exactly this reason (see the note at the top
|
|
// of internal/httpapi/spec/openapi.v0.yaml); this file is what makes a
|
|
// regression loud.
|
|
var (
|
|
_ apigen.Issue = types.Issue{}
|
|
_ apigen.IssueWithCounts = types.IssueWithCounts{}
|
|
_ apigen.IssueDetails = types.IssueDetails{}
|
|
_ apigen.BatchGetIssue = types.BatchGetIssue{}
|
|
_ apigen.IssueWithDependencyMetadata = types.IssueWithDependencyMetadata{}
|
|
_ apigen.Dependency = types.Dependency{}
|
|
_ apigen.TreeNode = types.TreeNode{}
|
|
_ apigen.Comment = types.Comment{}
|
|
_ apigen.BondRef = types.BondRef{}
|
|
_ apigen.Statistics = types.Statistics{}
|
|
|
|
// The cycle pair is pinned to the ROLE package rather than to
|
|
// internal/types, because that is where its canonical structs live: the
|
|
// role's result IS what `bd dep cycles --json` marshals.
|
|
_ apigen.Cycle = issueops.Cycle{}
|
|
_ apigen.CycleMember = issueops.CycleMember{}
|
|
|
|
// Same reason, one role over: BlockingAnnotator's result element IS what
|
|
// `bd list` renders its decoration from.
|
|
_ apigen.IssueBlocking = issueops.IssueBlocking{}
|
|
|
|
// The journal record is pinned to neither internal/types nor a role package
|
|
// but to the journal's own leaf: eventsjournal.Record is what
|
|
// `bd events tail` prints one of per line, and the committed golden fixture
|
|
// is a byte-level pin on that encoding. This assignment is what stops a
|
|
// regenerated mirror from quietly giving GET /v0/beads/events a record shape
|
|
// the golden never sees.
|
|
_ apigen.EventRecord = eventsjournal.Record{}
|
|
|
|
// The envelopes carry the canonical types too — pinning the schema is not
|
|
// enough if a page's items resolve to something else.
|
|
_ []types.IssueWithCounts = apigen.ReadyPage{}.Items
|
|
_ []types.IssueWithCounts = apigen.IssuesPage{}.Items
|
|
_ []types.IssueWithCounts = apigen.QueryPage{}.Items
|
|
_ types.Issue = apigen.ClaimResponse{}.Issue
|
|
_ types.Statistics = apigen.StatsResponse{}.Summary
|
|
_ []issueops.Cycle = apigen.CyclesPage{}.Items
|
|
_ []types.TreeNode = apigen.DependencyTreePage{}.Items
|
|
|
|
// The envelopes that are NOT pages resolve their items the same way and are
|
|
// pinned for the same reason: one whose items generated as a mirror struct
|
|
// would put a second wire shape for one fact on this surface, silently.
|
|
// DependencyEdges is here because wave 2 shipped without it (bd-5o3gt);
|
|
// every envelope on this surface whose items are a canonical struct is now
|
|
// pinned.
|
|
_ []types.Dependency = apigen.DependencyEdges{}.Items
|
|
_ []issueops.IssueBlocking = apigen.BlockingAnnotations{}.Items
|
|
_ []types.Issue = apigen.BatchCreateResponse{}.Items
|
|
_ []types.BatchGetIssue = apigen.BatchGetIssuesResult{}.Issues
|
|
|
|
_ []eventsjournal.Record = apigen.EventsPage{}.Records
|
|
)
|
|
|
|
// SettingsPage.Items and BatchCreateRequest.Items are deliberately absent:
|
|
// their element schemas (Setting, BatchCreateItem) carry no x-go-type, because
|
|
// neither has a canonical Go struct whose JSON encoding is that contract. There
|
|
// is nothing to weld them to, so a pin here would assert a compatibility domain
|
|
// that does not exist.
|