* feat(journalops): the mutation journal becomes the third facade namespace
The durable mutation journal's read side is now a role. `journalops` is a
leaf package beside `issueops` and `memoryops` holding Row, Page,
TruncatedError/TruncatedCode and `Journal`, whose doc comment is the
specification: since-exclusive, seq-ascending, limit 0 uncapped with the
wire's cap named as the handler's, a head that comes with its rows and never
decreases, a caught-up checkpoint, and a typed truncation naming a resumable
window.
NOTHING CHANGES BEHAVIOR. The four names in `internal/storage` become
ALIASES of the leaf — `type EventsJournalCursor = journalops.Journal` and its
three siblings — so every implementation, every errors.As site and every
caller compiles unchanged. The alias direction is what avoids the import
cycle: the leaf imports context and fmt and cannot name internal/storage, so
the canon goes down and the alias goes up. Outside storage.go and the
conformance tier, the only non-test edits in this change are COMMENTS.
The role brings the apparatus a role owes:
- backend/conformance/journal_contract.go, six cases over a fixture carrying
the role, the activation switch, a prune, and a mutation kit that is
exhaustive against the engine's closed op vocabulary.
- Wirings on all three legs (dolt, embeddeddolt, uow), so #5499's
entrypoint-scoped lock passes with every leg running every case.
- journalops added to the conformance census's facadePackages. That is the
#5459 demand side, and the role that needed it: `Journal` is handed out by
NO accessor — a front door type-asserts for it — so only a source parse can
see it. issueops.Importer is the precedent.
EventsJournalAccessor and EventsJournalConfigurer stay in internal/storage.
Retention and activation are operator surface, and a server documented to
publish the journal and never retain it must not hold a delete.
Net deletion on the bespoke side: TestEventsJournalPageReportsTheHead is
subsumed by the contract and is gone. TestEventsJournalRestartAndRetentionBoundary
stays, because it observes ReadEventsInTx — the accessor's second read body,
deliberately not on the role — and a mutation of one is invisible to the other.
Mutation-measured, per case, on the embedded leg: an inclusive checkpoint, a
head derived from the page, an untyped truncation, a head taken from MAX(seq)
of surviving rows, and a dropped engine-only op each redden exactly the arm
named for them, and a fixture whose activation hook is a no-op reddens all
six. Reading the head BEFORE the rows leaves all six green — that promise is
declared unpinnable in the contract header rather than faked.
Refs ga-fvya1, ga-2yaqp.4.
* docs(journalops): fix three comment-precision findings from review
All comments, plus one test-only compile-time pin block.
1. journal_facade_test.go told a misassembled causal story: it used the
CURSOR de-aliasing as its example and then attributed the breakage to
errors.As. Those are two different failures. Measured, both:
de-aliasing the interface builds the WHOLE TREE clean and breaks nothing
behavioral — what it costs is the claim that one role has one name — while
the error's dangerous shape is not the bare defined type (which loses
Error() and fails to build) but the COPY-PASTE TWIN, which compiles in
silence and stops crossing errors.As for everything holding the leaf's
spelling. Rewritten to say that straight.
2. The seq commit-order unpinnable declaration cited "the dolt package's own
journal tests" for the server-mode half. Those are single-threaded. The
actual pin is internal/storage/domain/db/journal_seq_test.go —
TestEventsJournal_CommitOrderedGaplessSeq drives two OVERLAPPING
transactions on independent connections, and
TestEventsJournal_ConcurrentWritersGaplessNoDup a racing batch. Cited
correctly, and the single-threaded ones named as NOT the pin.
3. EveryMutationKindLandsARow's runs-last ordering is load-bearing but held
by convention: a reorder compiles, passes, and silently gives up the only
coverage that a journal keeps recording after a full prune. It was stated
in the dispatch table and the three leg wirings; it is now stated at the
case itself, where somebody editing a leg file is actually looking.
And the compile-time half of the alias pin, which fires before any test runs:
a pointer conversion per name. The pointer form is not decoration — for the
three structs a plain assignment would do, but for the INTERFACE it would be
blind, since interface-to-interface assignment goes by method set and a
de-aliased cursor still accepts a journalops.Journal. Watched fail: the
de-aliased interface, which nothing else in the tree catches.
---------
Co-authored-by: Review Sim <ci@beads.test>
Three beads (ga-uwix0.1, ga-2yaqp.5, ga-2yaqp.6) plus a fable review round.
Docs and spec prose only: all 19 touched .go files are gofmt-normalized,
comment-stripped byte-identical to main. The one exception is deliberate and
reviewed — scripts/check_doc_freshness_test.go gains a data row, because the
delegated gate ruling required it.
ga-uwix0.1 — #5516 gave bd serve optional bearer auth and made it MANDATORY
beyond loopback; fifteen prose sites still said the opposite. The three the
council named are reworded to the stronger true form (the actor is not the
authenticated principal even where a bearer is required; a shared token admits
a client to the WHOLE surface and grants no narrower right). The sweep for a
fourth found eight more in five spellings the audit's grep could not reach,
including claim.go's "any client can claim as any name", release.go's
no-AUTHORIZATION variant, and six memory/settings-plane sites where the true
statement is sharper: a bearer decides WHO may call, never what a caller who
is let in may read. The review round found four more in the CHANGELOG's
UNRELEASED section, which round one had misclassified as released history —
they would have shipped false in the same release as the auth entry.
The serve runbook's "Binding beyond loopback" section was actionably wrong: it
said the flag "prints a warning and changes nothing else", and its refusals
table quoted a string not in the binary. Rewritten against a build, with every
flag, error string, event name and reason value produced by running the
command. It gains the operational trap nobody had written down: /healthz is
auth-exempt and GET /v0/beads/ready is not, so an unauthenticated readiness
probe earns a 401 forever while liveness stays green. The runbook is now IN
scripts/check-doc-freshness.sh, pinned to the four files it is read against.
ga-2yaqp.5 — nine prose defects, every count re-derived rather than trusted;
three of the audit's own numbers had moved again. 38 route rows and 36
capability-bearing ones; thirteen pinned schemas, not twelve or seven; six
missing entries in the no-query-parameter list, not five; twenty-eight role
accessors, not twenty-seven; nineteen patch members, not thirteen. Two prose
"code counts" were counting paragraphs. CodeAlreadyClaimed claimed the holder
is always attached when only one of four producers always attaches it and
releaseIssue never does. MetadataCAS's leaf contradicted its own shipped wire.
The path/operationId inversion is now recorded where a spec author looks.
ga-2yaqp.6 — the role checklist refreshed against what this wave's additions
actually cost, traced to real commits. Step 10 sent people to a name list
#5460 deleted. The "four more edits" claim was stated twice and undercounted
both times: the two freshest wire slices share a nine-file core plus
roles_test.go. The step-with-no-number gained the fact that explains its
instances — write-role decorators wrap, read-role decorators recurse, so the
call lands on the stub, and both real instances are reads. The wave got its
first CHANGELOG entry: six new public operations, not three, and zero new role
accessors in the window.
Review verdict: FIX-REQUIRED then all items addressed. The reviewer
live-falsified the strong auth form and failed to break it, and confirmed
every recount re-derives exact.
* fix(githooks): build golangci-lint with the repo's Go, not golangci-lint's
The pre-commit hook ran `go run golangci-lint@v2.10.1`. For a pkg@version
build the go command honours the TARGET module's toolchain directive, so
GOTOOLCHAIN=auto downgraded to go1.25.12 — and golangci-lint built by
go1.25 refuses this repo's `go 1.26.5` at config load:
go: github.com/golangci/golangci-lint/v2@v2.10.1 requires go >= 1.25.0; switching to go1.25.12
Error: can't load config: the Go language version (go1.25) used to build golangci-lint is lower than the targeted Go version (1.26.5)
Every Go commit failed there, so the hook taught six-plus contributors to
reach for --no-verify — the one habit a lint gate must never train.
CI never hit it because actions/setup-go installs the go.mod version and
exports GOTOOLCHAIN=local, so its `go install ...@v2.10.1` compiles the
linter with go1.26.5. Pinning GOTOOLCHAIN to the go directive reproduces
that resolution on any host, including one whose base toolchain is older
than the repo's target (where a bare GOTOOLCHAIN=local would pin the
linter to that older toolchain instead).
Verified on a real staged Go change: red before with the message above,
`0 issues.` after, and still exit 1 on a planted errcheck violation.
Bead: ga-2ltro.13
* ci: lint PRs for what they introduce, sweep the whole tree on main
Both PR lint gates linted the whole tree: the `lint` job left
only-new-issues at its false default, and pr-lint-wrapper ran
`make ci-pr-lint` over ./... . So a single lint word landing on main —
twice this wave, once a prose misspell — turned EVERY open PR red for a
change it did not make, and each author had to either fix someone else's
line or wait.
The tradeoff, recorded beside the job: a pre-existing issue in untouched
code no longer blocks a PR, and because "new" is measured off the diff, a
violation carried in by a MOVE or a rename does. What it buys is that a
main-side word now reds main's own run, where it belongs. main.yml
already runs both jobs unscoped on every push, so whole-tree coverage —
including the GOOS=windows cross-lint — is unchanged; only its blast
radius moves.
The wrapper takes its scope from BD_LINT_NEW_FROM_MERGE_BASE, set only
by pr.yml, so `make ci-pr-lint` run by hand still sweeps the tree. That
makes the local wrapper STRICTER than the PR gate rather than equal to
it, which is what LINTING.md and CI_CLEANUP_PLAN.md said before and no
longer would: both now state the two-lane contract and say the local
run's extra strictness is deliberate. Their freshness markers move with
the workflow and wrapper files they are pinned to.
Bead: ga-uwix0.2
---------
Co-authored-by: Julian Knutsen <ci@beads.test>
* refactor(serve): make the next role a compile error in the serve stubs
serveIssueRoles took a whole storage.DoltStorage, so the test stubs that
stand in for a store satisfied it the only affordable way: embed the
interface and leave it nil. Every accessor a stub had not declared then
arrived as a promoted method on a nil interface — a segfault inside role
extraction, not a compile error.
It has landed twice in one PR cycle, both on GraphCounter. First in
serve_source_test.go, then in serve_store_identity_test.go, where no local
-run pattern names the test and only a full cmd/bd shard found it.
So the function now asks for serveRoleSource: the accessor subset it
actually reaches, which a whole store still satisfies. Both stubs declare
that subset and assert it, and the store they must still BE — the
decorator chain takes one, and backends.Backend.Open returns one — comes
from an embed one level deeper that their own accessors shadow. Adding a
role to the loop is now:
cannot use (*serveRolesStore)(nil) ... does not implement
serveRoleSource (missing method GraphCounter)
ADDING_AN_ISSUEOPS_ROLE.md's "step with no number" listed these two stubs
among the surfaces to grep for by hand; it now says this pair is taken
care of and the rest still are not.
Swept the embed pattern across cmd/bd for a third instance reaching this
path: none.
Bead: ga-c3g45
* fix(httpapi): check the batch closer, the one role with a positional result
internal/httpapi has checked wrappers for Reader, BatchCreator, Lifecycle,
Claimer and Releaser, but the batch closer went out unwrapped — on the
reasoning that CloseBatchResult is a value and its issue pointer is
forwarded rather than dereferenced. True, and it is why there is no panic
here to prevent. What it left unguarded is the thing this role owns that
none of the others do: an array the client reads POSITIONALLY.
Two shapes reached the wire as answers rather than faults, and they fold
at different scopes:
- An outcome count that does not match the request cannot be walked
against the caller's items at all. Projected anyway it reports one
item's answer under another item's id for the rest of the array,
silently, inside a 200. Whole-batch 500, never a partial projection —
checkedBatchCreator's refusal exactly.
- An outcome carrying neither a row nor a refusal has no honest wire
shape: `code`'s absence promises `issue`, so it projects as a success
with no row, which is the shape closeOutcome's `default` branch
already refuses to produce. Folded into THAT item, because this batch
is not all-or-nothing — the survivors have committed, and failing the
request would hide durable closes.
The fold corrects a copy: the outcomes slice is the role's, and one that
answers from a prepared result would otherwise carry this server's
correction into everything it hands back afterwards.
No wire shape changes and no spec changes; make api-check is a no-op, and
the error classification order in failBatchClose is untouched.
Bead: ga-39tl5
---------
Co-authored-by: Julian Knutsen <ci@beads.test>
* Add issueops.GraphCounter: how many edges, in one named direction (ga-itny5)
The graph counts are the last read on the storage surface with no role behind
them. `storage.DoltStorage` publishes CountDependents, CountDependencies and
CountDependentsByStatus as three methods that differ only in a direction and a
narrowing, and every one of them is a raw method a front door can call with no
decorator, no probe and no plane story. This is their facade.
ONE METHOD, AND THE DIRECTION IS IN THE REQUEST. The raw seam spells the
direction in the METHOD NAME, which is the one thing a request field can get
wrong, so `EdgeCountRequest.Direction` is REQUIRED and an empty one is
ErrValidation before anything is read — including for a request that names no
ids at all, which is otherwise the empty answer EdgeReader gives. There is no
`both`: the two numbers are over different edge sets, summing them
double-counts an edge between two requested anchors, and a paired answer would
make Status — which narrows by a row only the inbound direction has — govern
half an answer silently. internal/workapi's detail assembly already makes two
calls for the pair today, so nothing pays a round trip it was not paying.
STATUS IS INBOUND-ONLY AND SAYS SO RATHER THAN BEING IGNORED. Narrowing by
status means joining the far end of an edge to the row holding its status, and
an OUTBOUND edge's far end may be a row this database does not hold — an
"external:" reference or a foreign-repository id, both of which
DependencyEditor accepts. A status filter there would silently drop every
dangling edge, which is the class of edge EdgeReader exists to return verbatim.
The raw seam has the same asymmetry: CountDependentsByStatus exists and
CountDependenciesByStatus does not.
A MISSING ANCHOR IS A FLAG, NOT ErrNotFound. 0 is the common answer — most
issues have no edges in at least one direction — so an id typo would never
surface, and a batch that failed on one absent id would discard the answers for
the ids that were found. That is EdgeReader's rule, and it is what forces the
existence probe and the tally into ONE transaction.
WHAT IS EXCLUDED, since the never-append rule makes each one a decision. The
COMMENT count is genuinely consumed — `bd show` prints it beside the two edge
counts — and is still out: a comment has no direction, no type and no far end,
so every field of the request below IDs would be meaningless to it. CountEvents
has no caller in the tree at all and follows the journal. GetDependencyCounts
is expressible as two calls with Types set to the blocking type, and naming it
as a method would have added a map-shaped answer no wire operation can carry.
THREE LEGS, ONE BODY. All three reach issueops.ExecuteEdgeCount — the two
stores wrap it in their own read transaction, the unit of work reaches it
through the domain repository, whose runner publishes exactly the DBTX method
set — so the contract header says one reading plus two engine checks and three
wrapper checks, not "three backends agree". Validation moved INSIDE that body
for the same reason: with one body there is no second implementation for a
per-leg check to belong to.
FACADE ONLY. No HTTP operation: the wire half follows in the graph-counts wire
slice per the program's council gating. No `bd` command either, and that is the
larger of the two decisions — the numbers are printed today through
internal/workapi's detail seam, which an HTTP handler shares, so moving it is a
change with its own parity argument. Both absences are written into the leaf
doc beside the promises, as VersionReconciler writes down its absent HTTP half
and BatchApplier its absent CLI.
Contract: 14 cases, wired on all three legs. Mutation-checked — a constant
count reddens 7 including both per-direction cases, ignoring the direction
reddens the 4 inbound ones, and dropping the ephemeral plane reddens the 2
cross-plane ones. The pure halves (the request vocabulary, the missing-anchor
rule, the SQL shape) are pinned without a database beside the body.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Review: reattach the Importer note, cite the collision, size the id list
Three corrections, none behavioral.
The four-line note about Importer's uow-only accessor was left stranded above
the GraphCounter row by this slice's insertion, where it asserted three things
that are false of it: GraphCounter IS a storage.DoltStorage accessor, a
store-built backend CAN fill its field, and importer_contract.go's header says
nothing about it. Moved back onto the row it describes.
"Nothing in this contract's reach can produce one" reads too easily as "it
cannot happen". A cross-table id collision is real and constructed:
TestDependentRecordsCrossTableCollision seeds one logical edge into both
dependency tables and names the two production paths that make them — a wisp
promoted to durable, and two Dolt clones merged. The leaf now cites it and says
what this role promises against it (the sum) versus what
CountDependentRecords' question is (the distinct total).
And EdgeCountRequest.IDs says out loud that it carries no size cap, which
EdgeReadRequest.IDs also does not: the bound belongs to the wire operation,
where the request arrives from somewhere else and the cost of an unbounded one
is a stranger's. ApplyBatchRequest.Items makes the same split explicitly.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Review Sim <ci@beads.test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* Add issueops.BatchApplier: one plan, one transaction
A heterogeneous, ORDERED list of creates, updates, closes and edges applied
as one durable act. Each of BatchCreator, BatchCloser and DependencyEditor is
one verb repeated, so a caller that needs two of them needs two transactions
with a window in between; this role's unit is a PLAN.
The role, the two bodies, both decorators and the accessors on every
implementer. The wire half and the conformance contract land beside this.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Close the empty-commit-message hole a no-op batch could open
ApplyBatchCommitMessage now reads the write as well as the result. The counts
are ItemResult.Changed, which is what a CALLER observes; a request can still
write a durable row with every count at zero — a same-type edge re-add
rewrites that edge row's metadata, a re-close can settle blocked state. An
empty message for one of those is an unlabelled Dolt commit on the store legs
and a rollback of a real write on the unit-of-work leg.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Give BatchApplier the contract its two bodies justify
Thirty-nine cases over three legs and TWO independent bodies — the store legs
share issueops.ApplyBatchInTx, the unit-of-work leg cannot reach it, and the
contract header says so rather than claiming three backends agree.
The end-gate case is the one that could not have been written before: every
edge in it is legal when it is written, and only a re-validation against the
closure the whole request produced refuses the pair.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Publish batchApply on v0, and delete batchCreate's false promise
The spec first, the types from it, the handler against the types. The item
union is a TAGGED single-shape object rather than a oneOf, because the
document's x-go-type doctrine forbids composition keywords; the create item
publishes sender, metadata, status, ephemeral and no_history, none of which
batchCreateIssues has — which is why no measured caller could use that one.
The wire result stays lean: ids, changed and a revision. The hydrated
snapshot on the Go contract is what the completion hooks consume, and hooks
never fire on this surface.
OQ2: batchCreateIssues' description claimed a dependency target could name an
earlier item of the same batch. It never could — the server mints the ids and
a wire item has no name — so the paragraph is deleted rather than qualified.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Partition the two new dependency probes on the recorder's surface
The gate halves BatchApplier re-runs are repository PROBES — an ancestry walk
and a reachability walk — so recordingDepUC declares neither and the parity
test has to say so out loud rather than let embedding answer for it.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Teach the proxied topology's capability golden about batchApply
The one expectation stored as data outside the package whose gates would
otherwise have caught it — which is what its own header warns about.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Restore the CAS hook case, mint 409 already_exists, and stop over-claiming
Three fixes from review.
The rebase that brought MetadataCAS in left `case *hookMetadataCAS:` with an
EMPTY BODY: a Go type switch does not fall through, so RoleFiresHooks answered
FALSE for it and #5473's Listen refusal was silently disarmed. The compiler,
vet, lint and CI all pass on that. The case is restored and — because it had no
precondition of its own, which is why nothing caught it — serve_source_test now
pins CAS the way it pins the other four, with its peel assertion.
An occupied explicit create id becomes 409 already_exists rather than 400. The
body is well-formed and stays well-formed; what refuses it is state the client
must READ, and recovery is to look at that state. A dead 409 retires for free
where a narrowed 400 breaks clients.
Two headers claimed all three legs share the store body — every clause false,
one citing the contract header as agreeing when it says the opposite — and the
plan file gave a placement reason that is MetadataCAS's, not this role's. The
end-gate claim in ADDING_AN_ISSUEOPS_ROLE.md is narrowed to the true thing: the
two LEAF checks are shared, the orchestration around them forks.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Give the scheduling-edge set one definition, in types
Four packages walked {blocks, conditional-blocks, parent-child} under four
names — isSchedulingEdge, isSchedulingDep, isSchedulingDependency, and the
isApplySchedulingEdge this branch added as the fourth. Adding a fifth
scheduling type was four edits with nothing to catch a missed one.
It goes in internal/types rather than the issueops leaf the review named,
because internal/storage/issueops imports internal/storage/domain, so domain
cannot import back and two of the four copies would have survived there. Beside
the Dep* constants themselves, every walker reaches it: nine call sites, one
definition, one edit for a fifth type.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Review Sim <ci@beads.test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* Add issueops.MetadataCAS: compare-and-set over one metadata key
The one coordination primitive missing at every layer. Everything the
metadata plane holds is written through Lifecycle.Update, which has no way
to say "only if", so every caller that needs a guarded write composes a
transaction, a read and an update by hand — and each one has to get the
composition right. Gas City emulates it client-side with RunInTransaction +
GetIssue + UpdateIssue for exactly that reason, and the comment it left
behind names the gap: "the upstream storage layer exposes no
conditional-UPDATE ... WHERE primitive".
The role is a state transition stated as a pair. Expected is the key's value
before, Value is its value after, and nil on either side means the key is
ABSENT there: a conditional create is (nil -> value), a conditional delete
is (value -> nil), and a caller that can take a lease can return it to the
state its own acquire tests for. Equality is canonical, so a caller cannot
lose a swap to its own formatter; numbers compare as their source literal,
because decoding through float64 equates two int64s past 2^53 and that is
the silent false match a compare-and-set exists to prevent.
A MISMATCH IS AN ANSWER, not an error: Swapped false, Current carrying the
value that refused it, nil error. That is the one place this diverges from
PROPOSAL-cas-conditional-update.md, which specifies a typed error and a loud
non-zero exit for the assignee/status guards. Its argument is a CLI one — a
swallowed refusal in a shell script is the bug class it was written for —
and a non-zero exit is the front door's enforcement, which the HTTP handler
here still owes and pays. The role's designed caller is a retry loop, for
which a lost race is the ordinary path, and an error cannot hand back
Current without a bespoke type every caller must errors.As before it can
read the one field it needs.
All three legs share one body (internal/storage/issueops), so this is one
reading plus two wrapper checks rather than three backends agreeing. The
wrapper check earned its keep: the unit-of-work leg rolled an ephemeral swap
back, because the shared body reported "no durable tables changed" and that
leg's commit message is what commits the SQL transaction as well as what
versions it. MetadataCASWrite now carries the two facts separately.
The HTTP half lands with the role per the 2026-08-05 scope decision:
POST /v0/beads/issues/{id}:casMetadata, spec first. A lost race is a 200
carrying swapped:false, so the operation has no conflict code; an omitted
`expected`/`value` member means absent and a member holding null is a value,
which is why the handler reads raw members.
No bd command yet: the primary consumer is an embedder, and a CLI front door
is additive. No .golangci.yml entry, for the reason memoryops gives — the
body is an …InTx function no front door can reach.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Review: read Current from the row, and let a client read a present null
Two shape fixes, both of which would have been expensive to change after
anyone depended on them.
A *json.RawMessage wire member cannot READ a present null: encoding/json
nils the pointer before UnmarshalJSON runs, so a generated client decoding
{"swapped":false,"current":null} gets the same value it gets for an omitted
member — and on this operation those mean opposite things. A retry loop
against a null-valued key would read "absent", swap with expected omitted,
mismatch, and livelock on a stream of 200s. x-go-type-skip-optional-pointer
makes the member a bare json.RawMessage, which is an Unmarshaler and
receives the literal; the wire is unchanged in both directions, which is
exactly why nothing else catches the regression, so the decode is now
pinned. nullable: true beside it, for the validating gateway in front of
somebody's server.
The number rule was defended in three places as protecting int64s past 2^53
from a float64 round-trip. It protects nothing: the metadata column decodes
through float64 itself — measured, 9007199254740993 stores as ...992, 1.0 as
1, -0.0 as 0, 1e300 as three hundred and one digits. The false justification
is gone from all three sites and replaced with what the probe actually
showed, plus the guidance it implies: compose an Expected from a previous
Current, and prefer a string for a coordination token.
That guidance was not true yet, because Current was the REQUEST's bytes
rather than the row's — so "what you get is what a later read sees" was
false, and a loop feeding Current back compared its own spelling against the
substrate's forever. Current is now re-read inside the deciding transaction
on every path. One extra SELECT, one statable invariant.
Three contract cases, each watched to fail: Current is the column's bytes
and a Current-driven loop converges (mutant: answer from the plan);
the history entry names the request's actor, counted per actor because
created_at is second-granularity and an ORDER BY decided this case on a coin
toss when it was first written (mutant: stamp a constant); a wisp swap
writes no durable event row, which two layers had been holding by
coincidence with nothing asserting either.
Also: the serializer-omits-null footgun in the spec (an absent `value` is a
DELETE, and Jackson/Pydantic/omitempty all omit nulls by default),
canonicalizeForContract's own float64 blind spot named in the coverage
paragraph, and the leaf now says corrupt stored metadata is an untyped error
— a 500 — because the request was well formed and the issue exists.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* Close the three capability holes CI found, and one my sweep could not
All three are the same shape: a surface that loses the new role silently,
and none of them is reachable from the package tests I ran locally.
internal/storage/uow's notifying wrapper is the important one. Its
recordingIssueUC inherited CompareAndSetMetadataKey from the embedded use
case, so a swap through a notifying unit of work recorded nothing and the
hook the DoltStorage chain fires for the same write was lost. Its
notifyingProvider did not answer MetadataCAS at all, so a caller's type
assertion simply stopped matching and the wrapper dropped the capability
along with its hooks. Both are now declared, and the recorder reads the
use case's own "a row write landed" rather than inferring it from the
request — which is strictly better than what the hook decorator can do, and
snapshots anyPlane because this role resolves a wisp id itself.
cmd/bd's serveIdentityStore is the second stub store to nil-panic on the
promoted accessor, after serveRolesStore in the same commit. And
serve_proxied_integration_test.go carries a SECOND hardcoded capabilities
golden, whose own comment says two literals that must match are one literal
— it was right, and it was still missed.
My local sweep ran the metadata-cas contract on all three legs but not the
whole internal/storage/uow package, which takes nine minutes; that is where
the parity guards live. Ran it whole this time.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* docs: name the step with no number — the surfaces that EMBED
A new accessor arrives on every embedder promoted rather than declared, so
the build stays green and the first symptom is a nil dereference in somebody
else's stub. Four such places caught this role after its own slice was
green: RoleFiresHooks, both halves of uow's notifying wrapper, and two
cmd/bd stub stores. Grep for the embed, not for the interface — and run
internal/storage/uow whole, because the parity guards live there and the
package takes nine minutes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Review Sim <ci@beads.test>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
GET /v0/beads/events:watch holds a text/event-stream response open and emits
each committed mutation as it lands, so a consumer learns about a write when it
happens instead of on its next interval. It is a SIBLING of the paged read, not
a mode of it: `follow=true` would have given one operationId two media types,
two lifetimes, two limit rules and two capacity stories, and a client generated
from the document could not have described either.
THE CURSOR IS STILL THE CONTRACT, which is what makes this cheap to publish.
The server keeps no per-consumer state and remembers no subscription; a stream
is the `since` reads a poller would have performed, performed on its behalf
against the same ReadEventsJournalPage through the same read-only cursor. Every
event carries `id: <seq>`, so the checkpoint a client holds while streaming is
the number it would have held while polling, and `Last-Event-ID` — the header a
browser's EventSource resends by itself — takes exactly the value `since` takes.
That header WINS over the parameter, because the client that sends it did not
choose to: an EventSource reconnects to the URL it was built with, so honoring
`since` there would replay every record since the consumer started, on every
reconnect, forever. A nonempty unparseable one is a 400 naming the header rather
than a silent fallback, which would start a stream somewhere the client did not
ask for and never tell it; an EMPTY one means "no id yet" and defers to `since`,
because a client that always sets the header sends it empty on its first
connect and refusing that would break the request the header exists to serve.
Delivery is at-least-once against the client's own checkpoint: exactly once and
in order within a stream, duplicates only across a reconnect. No engine or
storage change — this consumes the poll read path.
EVERY REFUSAL IS DECIDED BEFORE THE FIRST BYTE — validation, the disabled 409,
the flush check, the stream cap, and then the first read, which is what turns a
pruned-past cursor into the paged read's own 410 rather than a 200 that
immediately reports its own failure. Exactly one failure can arrive after the
status is spent: a prune racing an open stream, emitted as a NAMED `truncated`
event carrying the 410's own body in the same encoding on one line (asserted
against Write's output, not merely agreeing with it), behind a raised `retry`
and followed by a close. Naming only the exception is what lets a bare
`onmessage` consumer treat an unrecognized event as "stop, this is not a
record"; one that ignores it does not lose records silently, it stalls loudly on
connect-time 410s, slowly. The other unreportable failure — a stored payload
that will not encode — ends the stream too, and names its seq in the log,
because it will end every stream that reaches that row and nothing else would
say which one it is.
THREE LIMITS HAD TO MOVE, and the middle one is the trap.
- requestDeadline (60s) does not apply to a streaming row. For every other
operation it is the backstop against a request holding resources forever;
here it would do nothing but sever the stream. Each READ carries a 15s
deadline instead — a liveness budget rather than a database one, since it
also bounds how long a stream can go without a heartbeat and how long it can
ignore a shutdown.
- http.Server.ReadTimeout (30s) had to be cleared per request, BEFORE the
connect read. There is no WriteTimeout on this server — statusWriter rolls a
deadline forward before every write, which bounds one stalled write rather
than a stream, and needs nothing here — but ReadTimeout is a deadline on the
WHOLE request, and net/http keeps a background read running while a handler
writes: the read that notices a disconnect. Its expiry cancels the request
context, so an idle stream would end itself at thirty seconds with no client
involved, and a database wedged during the connect read would be booked as
`client_closed`. Clearing it costs no disconnect detection — a client that
leaves still produces a read error — and a peer that vanishes without a FIN
is reaped by TCP keepalive, which Go's listener enables by default
(measured: 15s idle, 15s interval, 9 probes; ~150s).
- The database slot moves from the request to the read. Sixteen slots and
forty-eight stream places means one slot per open stream would let a handful
of idle consumers starve every other operation for hours with /healthz
green; a stream now takes a slot for the moment of each poll and gives it
back, and slot pressure delays a pass instead of ending a stream.
Streams are capped at 48, SIXTEEN BELOW the 64-connection limit, and the gap is
load-bearing arithmetic rather than caution: LimitListener returns a connection
slot only when the connection closes, which is after the handler returned and
after this counter came down, so a cap at maxConns could never be observed — the
connect that should earn the 503 would never be accepted, and neither would the
poll it is told to fall back to, nor a mutation, nor a fresh-connection
/healthz. The headroom makes the refusal deliverable; `events_watch_admitted`
carries the live gauge on every connect so accumulation is visible before the
cliff. Each stream jitters its own poll phase by ±10%, because consumers
reconnect together after a restart on one shared `retry` and a fixed interval
would march them into a single read burst per second forever. And a graceful
shutdown signals its streams (RegisterOnShutdown) rather than waiting them out;
the loop consults that signal and the client on EVERY pass, including the
draining ones, so a week-old backlog stays cancellable within one batch.
Tests: handler-level over live delivery (mutations land AFTER the connect),
id=seq, heartbeats, Last-Event-ID precedence including a stale header against a
live `since` and the empty-header polarity, the 400/409/410 connect legs, a
prune under an open stream, the cap and its 503, the cap's headroom against
maxConns, backlog drains cancelled by both a hangup and a shutdown, slot release
on every exit, a stream sharing a single-slot semaphore with a paged read, the
flusher refusal, the read-deadline clear and its ordering against the connect
read, jitter spread, and a clean drain with a stream open — all under -race.
Framing is pinned against a record whose payload carries literal newlines, a CR
and a `data:` line of its own. Two e2e legs through a real `bd serve`: mutate on
one connection while streaming on another under a 10s arrival bound, then
reconnect with Last-Event-ID and require the resume, plus the disabled refusal.
Mutated and each caught: the mid-stream truncated event, Last-Event-ID
precedence, the empty-header polarity, the cap decrement, the cap's headroom,
the drain-cancel fast path, the read-deadline clear and its ordering, the poll
jitter, the shutdown exit, and the deadline exemption.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Agent-Signature: claude-code-claude-opus-5[1m]-unknown-reasoning on behalf of julianknutsen
Follow-up to the four-slice deduplication pass (#5398, #5399, #5405, #5406).
No behaviour change.
That pass retired ~700 lines net, and its reviews found about a dozen coverage
losses and six tests that could not fail — every one of them green under
go build, go vet, go test and golangci-lint. The reasoning that caught them
lived in review transcripts and a scratch directory. Written down nowhere, the
next pass rediscovers it by shipping the loss first.
The engdoc section states each rule as the check that would have caught the
failure earlier: a mutation verdict is only true of the body you mutated; a
wrapper is a composition the contract structurally cannot see; write a residue
from the decision surface rather than the mutants you happened to run, since
half of what one such residue missed were POSITIVE assertions; ask what the
fixture makes unobservable, because every fixture-defect case had correct
assertions; never let a role-answer assertion replace a raw-row one; cite by
symbol, not line.
scripts/mutation-equivalence.sh is the tool. It ran the entire pass from a
scratch directory, which means it would not have survived it.
A fact-check review then found more wrong with this change than with anything it
describes. The section cited `runTransaction`, which does not exist in the dolt
package — while teaching symbol citation. It claimed no contract case reads
is_blocked; there are 45 references across ten files, several added by the pass
it describes. Three of its counts did not reconcile with the merged record, and
one was curated to make a sentence read true. All corrected, with the counts now
qualified and the pull requests named as the record.
The same review demonstrated three false-REDUNDANT routes in the script — the
one wrong answer that costs coverage — plus a guard that refused the repo only
by accident, and would have hard-reset the caller's own checkout on a slightly
different setup. Build failures and timeouts are now reported UNUSABLE rather
than read as catches; checkout and reset failures are fatal rather than
measuring a different commit; off-file mutations are fatal; A == B is refused;
and the worktree must be a detached scratch worktree of the repo.
A seventh guard came from using it: it measures HEAD, not the working tree, so
uncommitted work is invisible and the run reads INCONCLUSIVE. It now warns.
doc.go still opened with "the three reads ... and the one write, POST
/v0/beads/issues/{id}:claim" and stated that "the claim OPERATION is the
only mutation this surface has". bd-serve-v0.md still opened its surface
section with "Six operations" over a six-row table, sized the server
under "Claim throughput — the claim is the only mutation in v0", and
scoped the no-hooks and no-auto-commit contracts to the claim alone. The
route table serves twenty-seven operations, eleven of them writes. Both
pages name themselves sources of truth, and bd-serve-v0.md's own header
rule says nothing in it may contradict the spec, doc.go or the reader
role — so this was the rule violating itself.
The counts are not corrected, they are removed. routes.go is the router,
TestSpecRouteParity welds it to the spec by exact set equality in both
directions, and capabilities is derived from the same table: a fourth
copy of the list, spelled in prose, can only ever go stale — as this one
did, silently, across five merged PRs. Both pages now describe the
MECHANISM and point at it. What replaces the table in bd-serve-v0.md is
the surface's shape, which is what a design page is for and which does
not change when an operation is added: what answers from the process,
how reads reach roles, the two spellings a write comes in, and the
posture every write shares.
Statements that were true only of the claim are widened where the code
widened them (the JSON content type is enforced for every body-carrying
operation; hooks fire for no write; the idempotent-write commit skip is
the re-claim, the re-close and the reopen) and narrowed where they were
overstated (the reader property covers three named reads, not "all"
reads — the count, the query, stats, config, memories and the dependency
reads are on sibling roles). The design page's error table gains the
three codes the wave added, with the extension members each carries and
the absence that distinguishes the two dependency_cycle refusals.
Also sweeps the seven stale "one write on this surface" comments in
claim.go, claim_test.go, roles_test.go and update_test.go, and reads.go's
"the three read operations" header over a file that now holds five.
No wire change, no behavior change.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Both files had their Last reviewed markers refreshed today without the content
gaps being closed, so the freshness signal is currently green on two docs that
are missing real material.
azure-devops.md — `ado.reconcile_interval` is undocumented. It is real,
user-tunable config (internal/ado/reconcile.go, default 10) setting how many
syncs pass between automatic reconciliation scans, and the doc already documents
the `--reconcile` flag that forces one. Adds a Reconciliation section, and notes
that `ado.syncs_since_reconcile` is beads' own counter rather than a setting.
otel-data-model.md — claims a complete schema but lists 7 of 111 storage spans,
so the issueops role surface is invisible to anyone instrumenting from it.
Rather than 100+ prose sections that would drift again, state the rule the code
follows — span name is "storage." + operation name, which is also the
db.operation attribute (InstrumentedStorage.op) — and inventory both families:
72 direct storage.<Method> spans and 39 storage.<Role>.<Method> spans.
Also records why the families do not double-count: the role decorators wrap the
UNINSTRUMENTED store (IssueLifecycle calls Unwrap() before wrapping), so one
logical operation emits one span on either path and the counters stay
comparable.
No behaviour change; documentation catching up to the code.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Add append-only provenance_events log and bd provenance CLI
A generic primitive for capturing work provenance — the base commit a
worktree forked from, which actor touched a bead when, what landed it —
as an append-only event log keyed to an issue. Inert by default: nothing
writes it unless a producer (git hook, orchestrator, CI) opts in.
- Migration 0052: provenance_events (CHAR(36) UUID pk, FK issues
ON DELETE CASCADE ON UPDATE CASCADE, indexes on issue_id/ref/kind).
Sibling to events, per the wisp_events precedent for purpose-specific
event tables rather than overloading the field-mutation audit log.
ON UPDATE CASCADE so a bd rename (which updates issues.id in place)
does not hard-fail the FK, matching the other aux tables (0042).
- Append-only at the event level: only record/log/by-ref operations, no
UPDATE or DELETE of an individual event. An event's lifecycle is bound
to its issue — removed only if the issue is deleted (ON DELETE CASCADE),
identical to the events audit table (0005).
- Opaque actor/ref (bd never interprets them); only kind and ref_kind are
structurally validated (ZFC). occurred_at (event-time) is separate from
created_at (ingest-time). A reserved 'ingest-backfill' source is rejected
so a producer cannot forge a derived event.
- Idempotent record via a content-addressed deterministic id, so a producer
firing twice is harmless; an event with neither a ref nor occurred_at is
rejected at the store boundary (no stable id otherwise). occurred_at is
truncated to whole seconds for both the id basis and the stored value, so
the id stays reproducible from the stored row (the column is bare DATETIME,
second precision) — a sub-second --at records idempotently.
- bd provenance record|log|by-ref; logic shared in issueops, both Dolt
stores delegate (mirrors the events pattern). The record command calls the
exported ValidateProvenanceEvent for early CLI feedback, with the store as
the real boundary.
- ADR-0003 records the rationale (why not extend events, why opaque ids,
event-level append-only vs issue-bound cascade, distributed-merge note).
CGO tests cover round trip, idempotency, sub-second-at idempotency, opaque
field round-trip, and the validation guards.
* Fix provenance CLI lint and review nits
Return JSON output errors from provenance commands, silence Cobra usage/error duplication on the new command group, document deterministic provenance IDs accurately, and add the composite issue/occurred_at index promised by the design.
Agent-Signature: codex-gpt-5.5-high on behalf of matt wilkie
* fix-merge(provenance): renumber to 0063, drop pinned-doc artifacts, stage provenance_events, ADR to engdocs
Maintainer-side rebase tail for PR 4461 after 505 commits of drift; author's
blockers were all fixed on 2026-07-08.
Co-authored-by: sjarmak <sjarmak@users.noreply.github.com>
Agent-Signature: claude-code-sonnet-builder on behalf of maphew
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix-merge(provenance) round 2: backend contract aliases + latest-migration mock shape
Two more surfaces main grew after the 7/27 approval:
- backend public-contract completeness ratchet (#5321) requires aliases
for types reachable from the contract: add ProvKind + ProvenanceEvent
- schema lock tests script sqlmock against the LATEST migration's body
shape; latest is now 0063 (plain CREATE TABLE -> ExecContext), not
0062's bare CALL (-> DrainCall/QueryContext)
---------
Co-authored-by: sjarmak <sjarmak@users.noreply.github.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
memoryops needed one sentinel — ErrValidation — and the value the whole repo
matches lived in issueops. So the memory leaf imported the issue package for
one errors.New and pulled internal/types in behind it, claiming memory sits
downstream of issues. It does not: the two are sibling planes over one config
table.
beadserrors now declares the vocabulary that belongs to no plane in
particular — ErrValidation, ErrNotFound, ErrNotInitialized, the ErrUnsupported
type — and issueops re-exports it by alias, exactly as internal/storage and
backend already re-export from issueops. 141 qualified ErrValidation
references across the tree, zero edited: a Go alias preserves identity.
memoryops now depends on beadserrors and context, nothing more.
What belongs down there is what a leaf for a plane nobody has written yet
would need. ErrCloseBlocked and ErrDependencyCycle name issue concepts and
stay in issueops.
beadserrors imports stdlib and nothing else, enforced by a strict depguard
rule rather than asked for in a comment, because it sits beneath every leaf
and whatever it imports is imported by all of them.
Answers Q4 from #5387.
The memory commands get the treatment the sixteen issue commands got in #5378:
a role interface in a leaf package, conformance-tested at all three backends,
with the CLI routes and the HTTP handlers as thin callers over one
implementation.
memoryops is its own namespace rather than an addition to issueops. The two
planes share a config table and nothing else; a memory whose key shadows a
settings name is still a memory, and that separation is now the role's,
pinned by its contract, rather than a filter each caller reapplies.
Closes an unauthenticated disclosure found on the way: memory content was
served in cleartext on GET /v0/beads/config, and reachable through two more
doors — `bd config show` and `bd info --json`, the latter republished into
agent transcripts by MCP get_schema_info. Enumeration is now filtered at the
shared seam (workapi.FilterSettingsEnumeration); `bd config show` is left
alone deliberately, since an operator asks for it by name.
Two wire contracts were settled after the review council, recorded in full on
the PR: the search parameter is spelled `search` rather than `q`, because
issues:query already publishes `q` as a boolean expression and one surface
must not spell two questions one name; and getMemory keeps its 404, because
the status reports the distinction the front door already reports and
`bd recall` exits 1 on a miss where `bd config get` exits 0.
* docs: re-review and bump the three 90-day-stale freshness markers
azure-devops.md, json-schema.md, and otel-data-model.md all carried
Last reviewed: 2026-05-08 — exactly 91 days old today, so the doc-flags
freshness gate went red on every branch at once. Each doc was genuinely
re-reviewed against its Freshness source paths on main; drift found and
fixed:
- azure-devops.md: proxied-server mode note (ado sync/status/projects
hard-error there); --parent and --project flags documented; duplicate
--issues row dropped; real ado.org error text quoted; ado.pat's
yaml-only secret storage noted. Source bug found during review filed
separately: the cmd-level config reader cannot see a yaml-only PAT,
so the documented Quick Start fails on main (bd-wvf77).
- json-schema.md: bd show/close/update --json return top-level ARRAYS
(contract-test-pinned); jq recipes fixed accordingly; envelope
pagination key documented; show's always-present revision field and
import's unchanged counter added; error envelope (optional code/hint,
envelope-mode shape, stdout paths, exit 1) corrected; deprecation
notice's tty-only condition noted.
- otel-data-model.md: hard opt-in via BD_OTEL_ENABLED + standard OTel
SDK env vars (BD_OTEL_* legacy); console-only trace export; dolt span
attrs (shared doltSpanAttrs, dolt.remote, dolt.force_push,
dolt.conflicts, dolt.merge_with_strategy); facade-wave storage role
spans; seven new Dolt metrics; AI attrs (bd.ai.duration_ms, 4-attempt
retry); appendix re-pinned to current main.
scripts/check-doc-freshness.sh passes locally.
* docs(otel): complete claim_verify_lost op label enumeration; qualify retry policy as compact-only
Review findings on #5394: op also takes guarded-update
(claim_verify.go:113) and ready-claim (issues.go:439); the retry-policy
sentence describes compact's loop, find_duplicates makes one unretried
call.
Five files collided. Four were textual; the fifth was a semantic collision
that no textual resolution would have caught, and it is the reason this is a
merge rather than a rebase — resolving it once beats resolving it 25 times.
THE SEMANTIC ONE. main grew a second bd serve arm (serveSourceStore) that
serves a registered backend from the store the root command already opened,
wiring httpapi.Config from two role accessors. This series grew that same
Config from two roles to thirteen and made Listen refuse a PARTIAL set. Both
sides are individually correct and merge cleanly as text; together they bind
nothing — every registered-backend serve fails at startup with "no database
source". Caught by main's own two serve tests, which is what those tests are
for.
serveIssueRoles now returns the whole set as a struct rather than a growing
list of unnamed results, so a role added to Config without being added here
is a compile error at the call site instead of a startup failure. It stays a
struct rather than an httpapi.Config because the gate test in serve_test.go
requires every httpapi.Config literal in cmd/bd to sit in a function that
consulted serveDatabaseSource, and the extraction has not.
Two test doubles needed the new accessors. serveRolesStore returns nil for
the eleven it does not exercise, which is honest: it never reaches Listen,
and reader and claimer are enough to pin the peel DEPTH that test is about,
since serveIssueRoles peels once and calls every accessor on that one value.
serveIdentityStore does reach Listen, so its roles must be non-nil; they
embed their interfaces rather than implementing them, keeping that file's
stated preference for a nil-panic naming the method over a stub that
answered.
THE TEXTUAL FOUR.
.golangci.yml — both sides edited the same forbidigo path lists. Resolved as
set arithmetic against the merge base rather than by picking a side, then
verified programmatically: every addition from either side survives and every
removal from either side survives.
CHANGELOG.md — unioned.
create_proxied_server.go — rerere replayed a prior resolution; verified by
reading that it carries both main's refusal text and this series' CreateOnly
lifecycle flag rather than one at the cost of the other.
serve.go and serve_test.go — took main's substantive rewrites, re-applying
this series' corrections on top: the extended unauthenticated-surface warning
now names bulk delete, and the roles paragraph says "every role accessor"
rather than "both".
serve_test.go's AST gate keys off Reader+Claimer as the roles-source signal.
That is sound for the question it asks — which database source did this
Config name — but the pair is now hand-maintained against a thirteen-role
struct, so it carries a note pointing at bd-lidlu.
`bd dep tree` had two implementations of one walk. The direct route resolved a
partial id, opened a prefix-routed store and called store.GetDependencyTree; the
proxied route took the id verbatim, opened a unit of work and called the use
case. Each then carried its own copy of the `both`-direction merge, the status
prune, the mermaid and human rendering and the empty-tree wording. The copies
agreed, which is the only reason nobody noticed that a `both` walk was two
independent reads with nothing spanning them. Both now build one
issueops.WalkTreeRequest and ask for the role.
THE ROLE, and both its neighbours said in advance why it had to be one.
Relations and EdgeReader each exclude the tree in the same words -- "a recursive
walk has a depth, a cycle policy and a node shape of its own" -- and all three
are on this contract: MaxDepth, the first-visit rule, TreeNode. It is not
CycleDetector either: a cycle has NO anchor and a tree is nothing but its
anchor, and the two disagree about what an edge is -- this walk follows every
type except `relates-to`, the cycle report follows `blocks` and
`conditional-blocks` only -- so one workspace can honestly have no cycles and a
tree that revisits a node.
ONE BODY, THREE LEGS, AND THAT IS ONE VOTE. Unlike every other role in
backend/conformance, all three implementations reach the same function: the two
stores wrap issueops.WalkDependencyTreeInTx in five lines around their own
transaction and the unit of work reaches it through a new domain repository
method. So TestTreeWalkerContract x 3 is one reading of the walk plus an engine
check, not three backends agreeing, and the contract file says so at the top.
What the legs still buy is the WRAPPERS, which is where every measured drift in
this graph family has actually lived -- so the refusals assert SENTINELS rather
than message text and the cap case asserts the typed error's fields. The parts
that decide what the answer MEANS are pure (ValidateWalkTreeRequest,
PruneTreeByStatus, MergeBidirectionalTree) and are pinned without a database.
TWO USER-VISIBLE CHANGES ON THE PROXIED ROUTE, both in the owner's Q11 set, both
in CHANGELOG.md.
PARTIAL IDS RESOLVE. `bd dep tree a1b2` worked on a direct workspace and
failed on a team server, because this route passed the argument to storage
verbatim. It resolves in its own short-lived read unit of work before the role
is asked for anything, so a lookup that finds nothing reports the lookup
failure rather than a provider that cannot offer a surface.
--max-rows IS HONORED. It used to be refused outright ("not supported in
proxied-server mode") because the unit-of-work path threaded no cap. The cap
is on the role's request now, so the shared body enforces it for all three
backends and the flag means the same thing wherever the command runs. It is
still POST-HOC -- a tree walk has no query filter to thread a cap through --
and both the leaf doc and --help say so. The shared --max-rows help text
forked for this (addRoutedMaxRowsFlag): the proxied-server refusal is still
true for the eight other commands that take the flag.
A DEFECT FIX NOT ON THAT LIST, recorded as AMBIGUITIES.md A-twk-1: a `both` walk
now sees ONE database state on every route, where it used to be two
unsynchronised reads that could show half an edit.
Q7 IS OBEYED. --show-all-paths stays a no-op -- accepted, ignored, and now
DOCUMENTED as ignored -- and TreeNode.Truncated stays always-false for the same
reason. The one-visit rule that makes both dead is now a stated promise
(TreeResult.Nodes) and a conformance case (RendersASharedSubtreeOnce), so
implementing either as a side effect of a later refactor fails a test instead of
shipping.
CONFORMANCE. backend/conformance/tree_walker_contract.go holds fifteen cases
citing the leaf doc by line, run at all three implementations with ZERO parks:
45 subtests green. Seeding a cycle takes raw SQL for the reason the
cycle-detector contract records -- no supported write creates one -- so that one
case uses the fixture's Exec hook.
HTTP. GET /v0/beads/dependencies/tree, spec first and the types generated
against it. TreeNode is x-go-type-pinned to internal/types, so `bd dep tree
--json` and the response body are one compatibility domain, and
DependencyTreePage's Items are pinned in pinning.go -- the trap wave 2 fell into
with DependencyEdges (bd-5o3gt), not repeated here. A root that names nothing is
a 404, which is the difference from GET /v0/beads/dependencies: one anchor
leaves no other answer to preserve. No max_rows on the wire; the cap is a CLI
circuit breaker. `capabilities` gains dependencies.tree, and TreeWalker becomes
a required field of the store-shaped httpapi.Config, which costs the in-tree
tests a line each and no shipped caller anything (bd serve builds a provider).
NOT TOUCHED: the legacy DetectCycles seam bd-5g4f2 is about. This walk reads
GetDependencyTreeInTx and never AppendBlockingGraphInTx, so the two-cycle-answers
problem is exactly where it was.
Verified: build, vet, gofmt clean; golangci-lint 0 issues; make api-check green;
TestTreeWalkerContract 15/15 at dolt, embeddeddolt and uow; internal/httpapi 0
failures including the eight new tree-route cases; the pure tree_walk tests
green; TestEmbeddedMaxRowsNonListPaths green (DepTreeMaxRows still exits 2);
BEADS_TEST_PROXIED_SERVER=1 TestProxiedServerDep2 green including the four new
Tree cases; TestProxiedLookup* green; TestCorpusGolden green.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`bd init` had two implementations of what a workspace's identity IS. The direct
route read issue_prefix out of the config plane at init.go:1358 and _project_id
four hundred lines later, decided adopt-vs-write with two helper predicates, and
wrote both keys by name. The proxied route called domain.BootstrapUseCase, which
held its own list of which keys an identity is made of, wrote them
unconditionally, and folded the Dolt remote into the same call. The two agreed on
the key names and disagreed on the rule, and no test compared them.
ONLY THE IDENTITY SEAM IS A ROLE. Everything else init does — creating .beads/,
writing metadata.json and config.yaml, initializing git, installing hooks,
starting a Dolt server — CREATES the substrate or the workspace around it, and a
role is reached through an accessor ON a store, so it cannot be what makes the
store exist. init.go alone is 3,060 lines; this commit touches the part that
happens inside the database.
TWO ROLES, AGAINST THE VersionReconciler PRECEDENT. That one is a read and a
write on one role because they are two shapes of one question, and every word of
that is true here too. The test that separates them is different: can one caller
be entitled to the READ and not the WRITE? Here yes, and not hypothetically —
`bd init --team-server` adopts a bts-provisioned identity and is forbidden to
write one, and a gateway credential may be read-only. Those paths now hold an
InitVerifier and never obtain a Bootstrapper, which the type system checks;
with one role they would hold the writer and the suppression would stay where it
is today, in three should* predicates on the CLI.
Q8 ANSWERED IN THE ROLE. Bootstrap over an already-identified substrate is
ErrAlreadyIdentified, carried by an *AlreadyIdentifiedError naming what was
found, decided from the same read the write would have followed inside ONE
transaction. Either marker is enough: a substrate several rigs share carries a
prefix one of them chose, and overwriting it renames every id the others are
about to mint. The guard now sits below both front doors instead of in front of
one, so gateway and adopt paths inherit it, and re-identifying is something
somebody asks for rather than something init does twice.
THE ROLE OWNS THE IDENTITY AND NOTHING ELSE. BootstrapProject wrote six values;
BootstrapRequest carries two. The fingerprints, the synced-at marker and the
recorded binary version are refreshed on EVERY init, adopt or not — a fresh clone
of an already-identified database needs its own fingerprints precisely because it
bootstrapped nothing — so a refusable one-time write would mean either a refusal
that stops recording them or a write that is no longer one-time. bd_version has a
second reason: it is VersionReconciler's key. The Dolt remote left too; it is
where the database syncs to, not what it is, and putting them in one call is what
let a remote that could not be created fail a bootstrap that had already
succeeded. domain.BootstrapUseCase is DELETED and domain.ConfigUseCase gains
SetMetadata, the write half of the GetMetadata it already published, so the
unit-of-work body can read, refuse and write in one transaction.
THE DEFECT. Proxied `bd init` against a database another rig had already
identified rewrote both markers with its own derived values. It verifies and
adopts now, printing the direct route's existing line, with the role's refusal as
the backstop. The direct route's two identity reads also became one snapshot, so
the prefix it adopts and the project id it reconciles against can no longer come
from either side of a concurrent write; shouldConsultInitProjectID still gates
whether the id is USED, so which identities init adopts is unchanged.
CONFORMANCE. backend/conformance/bootstrapper_contract.go holds twelve cases —
both roles in one file, because every promise on either is a statement about the
other — run at all three implementations with ZERO PARKS and zero divergences.
They deliberately do not re-test the decision: the validator's and the refusal's
whole tables are pinned without a database in internal/workapi/bootstrap_test.go.
What only a real backend can show is asserted instead: that the identity is there
for the NEXT caller (a new transaction on the unit-of-work backend), that a
refusal and a validation failure leave the markers EXACTLY as they were, that the
verifier reports an unreadable identity as an error rather than as an empty one,
and that a bootstrap costs at most one version-control entry. Two independent
bodies plus an engine check, not three votes: dolt and embeddeddolt share
internal/storage/issueops.BootstrapInTx and VerifyIdentityInTx and differ only in
how they reach a transaction. The bodies live there rather than in an importable
store<role> package because the read and the write it qualifies must see one
snapshot, which storage.DoltStorage cannot express — so there is no constructor
for a depguard entry to deny.
NO HTTP OPERATION, and that is a decision. A server can only serve a database it
is already bound to, and binding it required the identity this role writes, so
the only caller that could reach such an endpoint would be asking a running
server to identify a workspace that is by construction already identified — which
is the refusal. Bootstrapping over an unauthenticated surface is a different risk
class from reading one. The read half already has an endpoint:
ContextResponse.project_id on GET /v0/beads/context is InitVerifier's answer, on
the wire, today. Recorded in both leaf docs and in the checklist.
USER-VISIBLE, for the wave's changelog pass: proxied init adopts instead of
overwriting on a shared database; `bd init` no longer heals a substrate carrying
a prefix and no project id, which is Q8 as written; an explicit BEADS_DIR outside
the repo now gets a project id written from its own metadata.json instead of
being left half-identified. Reasoning and the alternatives are in
/data/tmp/sd-server/AMBIGUITIES.md as A-ini-0..7.
A-ini-0 IS A FALSE PREMISE IN THE BRIEF, not a finding about the code: bd-zl3u8,
bd-jtp1h and bd-yby99 do not exist in the workspace at BEADS_DIR. Verified by two
bd binaries failing to open it and by a direct SQL read of all 5,603 issues.
Everything else the brief asserted about the code checked out, so the spec used
was the brief plus Q8 plus A2.
Verified: build, vet, gofmt clean; golangci-lint 0 issues (its unparam check is
what found resolveInitIssuePrefix's now-dead `write` return, removed here);
TestBootstrapperContract 12/12 at dolt, embeddeddolt and uow; internal/workapi,
internal/storage, internal/telemetry, internal/jira, issueops, the root layering
pins and the whole internal/storage/domain and internal/storage/uow packages
green; internal/httpapi green and `make api-check` clean with no spec or
generated diff; TestInit* and TestResolveInit*/TestApplyInitGateway* and
TestCorpusGolden and TestDoctor* green under BEADS_TEST_EMBEDDED_DOLT=1;
TestProxiedServerExternalCreate, TestProxiedServerPing and TestProxiedServerUpdate
green under BEADS_TEST_PROXIED_SERVER=1, each of which runs
`bd init --proxied-server` in its harness; TestProxiedLookup green.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`bd purge` selected closed wisps in one transaction and deleted them in
another. A bead closed, unpinned or cited in the window between the two was
judged on one state and acted on in a different one — the TOCTOU the bead
names — and the proxied twin held a second copy of the whole flow: its own
candidate filter, its own glob match, its own closed_at recheck, its own
reference scan and 190 lines of output kept character-identical to the direct
route's by hand.
PURGE AND PRUNE ARE ONE CAPABILITY, which the design left open and the code
answers plainly: both routes already ran ONE function with a `purgeScope`
struct choosing the tier. So issueops.Sweeper has ONE method, reached through
store.Sweeper() and the provider's own accessor, and SweepRequest.Tier selects
the plane — `ephemeral` is purge, `durable` is prune, and the two are disjoint
by construction. What genuinely differed became request fields rather than a
second role: the require-a-filter refusal keys on Tier, and the citation
protection is ASKED FOR (ProtectReferenced) instead of being inferred from a
command name, which is what the shared body did (`scope.cmdName == "prune"`).
Q9 ANSWERED IN THE ROLE. The require-a-filter gate is
workapi.ValidateSweepRequest, below every front door: a durable sweep with
neither a cutoff nor an id pattern is ErrValidation. It is a safety invariant,
not presentation — without it a second front door is one handler away from an
unguarded mass delete, which is exactly what this commit's HTTP operation would
otherwise have been. The CLI keeps its friendly message, and says in place that
it is there for the WORDING while the guard is the role's; the contract case is
what proves the guard survives that branch being deleted.
THE DEFECT, AND ITS PRICE. The whole sweep is now one transaction, so the set
the result describes IS the set it deleted. That gives up the server-backed
store's batched wisp deletion (200 per transaction, added for Dolt's 10s write
timeout after bd-2ehd and ff-tqm): a sweep too large now fails WHOLE. That is
the better failure — the partial one it replaces reported a deleted count of
ZERO while having deleted rows — and the other two backends already worked this
way. It is written down as a promise WITH its cost, and recorded for sign-off.
TWO MORE DEFECTS the single call site removed. `--dry-run` passed force=false
to the delete where the real run passed force=true, so a preview could FAIL
over dependents the sweep would have orphaned — and the CLI answered that
failure with zeros. And `filepath.Match`'s error was discarded on both routes,
so `--pattern '['` printed "No closed beads to prune" and exited 0; it is now
ErrValidation quoting the pattern.
THE CONTRACT IS WHAT WAS DELETED, not what was reported.
backend/conformance/sweeper_contract.go holds ten cases, each citing the leaf
doc, run at all three backends with ZERO PARKS and zero divergences. Every case
that acts asserts row counts through QueryScalar rather than trusting the
result the sweep reported about itself, which on a destructive operation is the
assertion that matters; every case scopes itself with an id pattern, because a
sweep is asked of a whole TIER and an unscoped one would clear the next case's
seeds. They are TWO INDEPENDENT BODIES plus an engine check: dolt and
embeddeddolt share internal/storage/issueops.SweepInTx and differ only in how
they reach a transaction, and the unit-of-work provider reaches the same four
questions through the domain use cases.
THE HTTP OPERATION, spec first (per bd-jtp1h's A2 scope decision):
POST /v0/beads/issues:sweep, capability `issues.sweep` — the first DESTRUCTIVE
operation on a surface that was reads plus one claim. It is a collection-level
custom method with a body rather than DELETE with a query string, because a
dropped query parameter widens what is erased where an unknown body member is
refused by name. The handler decodes six members and calls the role; it does
not implement the safety gate, the tier vocabulary or the glob, all of which
are the role's ErrValidation reaching the wire as a 400 through failSweepErr.
No component carries allOf and none is x-go-type-pinned — there is no canonical
Go struct whose JSON encoding is this body, since the CLI publishes these
numbers under `purged_count`/`pruned_count` — so the projection is tested
instead. `bd serve --help` grew a DESTRUCTIVE OPERATIONS section and the
--allow-non-loopback warning now says peers can bulk-delete closed beads.
`bd gc` keeps the closed-candidate recheck by calling the SAME pure function
the role calls (workapi.FilterSweepCandidates), so the two cannot drift; the
reference matcher and its 10K-body budget moved to internal/workapi with the
scan. cmd/bd/purge.go and purge_proxied_server.go LEFT the forbidigo exception
list, which is how a role commit proves its front doors reached the role.
USER-VISIBLE, for the wave's changelog pass: the version-control label for a
sweep is now `bd: sweep <n> <tier> bead(s)` on both routes, where proxied wrote
`bd: prune <n> bead(s)` and direct wrote `bd: delete <n> issue(s)` — an HTTP
sweep is not `bd prune`, so the label names the operation and the tier from
every door; a malformed `--pattern` now exits non-zero; `--dry-run` no longer
refuses over dependents the real sweep orphans; and `bd serve` gains a
bulk-delete endpoint. Reasoning and the alternatives are in
/data/tmp/sd-server/AMBIGUITIES.md as A-swp-1..9.
Verified: build, vet, gofmt clean; golangci-lint 0 issues; make api-check
(regenerate-and-diff plus the httpapi suite) green; TestSweeperContract 10/10 at
dolt, embeddeddolt and uow; the internal/workapi, internal/storage and
internal/telemetry suites; TestEmbeddedPurge, TestEmbeddedPurgeConcurrent,
TestEmbeddedPrune, TestPrune_protectsBeadCitedByCustomStatusBead and
TestEmbeddedGC under BEADS_TEST_EMBEDDED_DOLT=1; TestProxiedServerPrune under
BEADS_TEST_PROXIED_SERVER=1; TestProxiedLookup*; and the root layering pins.
The protocol corpus has no purge/prune case to account for.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The version markers had two implementations of one rule. The direct route read
bd_version and bd_version_max out of the metadata plane in
cmd/bd/version_tracking.go, compared them with doctor.CompareVersions and wrote
them back; the proxied route opened a unit of work and called a ReconcileVersion
method on the config use case, which held its own copy of the same comparison,
the same two downgrade guards and the same high-water rule. The two agreed, but
nothing made them agree and no test compared them. Both now ask for a role, and
the difference between the routes is which accessor answers.
THE ROLE BELONGS TO NO COMMAND, and it is the only one in this programme that
does not. It fires from PersistentPreRun on EVERY startup, on both routes,
before the command the user typed has run — which is exactly why it went
unnoticed: `bd version` prints two strings, opens no store and reaches none of
this, so the state machinery was hiding behind a command that does not use it.
THAT ORIGIN IS A CONSTRAINT ON THE PROMISES, not a piece of history, and the
leaf doc says so where a reader will meet it. A role that runs before every
command pays for itself on every command, so it does two point reads on the path
that changes nothing, loads no configuration, takes no lock, repairs nothing —
and, the clause that matters most, it NEVER refuses the command in front of it.
A downgrade is an OUTCOME with a nil error, because an older binary is allowed
to use a workspace a newer one has opened; a genuine failure is an error the
CALLER logs and walks past, which both front doors do at debug level. A role
whose callers must ignore its errors has to say so where the promise is made
rather than leave each caller to decide.
TWO METHODS, ONE ROLE. RecordedVersion and ReconcileVersion are two shapes of
one question — the write's promise IS a statement about what a later read
returns — which is what the governing rule permits a role to be born with, and
WorkspaceConfig set the precedent. It is not padding: the direct front door
needs the READ alone. autoMigrateOnVersionBump probes a read-only store first so
an already-current workspace never pays for the writable open, and before this
commit that probe read the metadata key by hand — the "CLI knows the storage
key" shape this programme exists to remove, on the hottest path in the codebase.
WHY IT IS NOT WorkspaceConfig WITH TWO MORE KEYS. Two planes, two lifetimes. A
workspace setting is durable and travels with the database; these two markers
are dolt-ignored, do not survive a clone and are deliberately different per
machine. Publishing them through the settings plane would put a value that
cannot be shared behind an interface whose whole promise is that its values are.
ONE DECISION, THREE SUBSTRATES. workapi.PlanVersionReconcile is the pure planner
every implementation decides through; domain.ConfigUseCase LOSES ReconcileVersion
and gains SetLocalMetadata, the write half of the GetLocalMetadata it already
published, so the unit-of-work body can read, plan and write in ONE transaction.
Deleting the use-case method is what makes the rule single-sourced rather than
duplicated under a role.
CONFORMANCE. backend/conformance/version_reconciler_contract.go holds nine cases
run at all three implementations with ZERO parks and zero divergences. They
deliberately do NOT re-test the decision: the planner's whole table — upgrade,
no-op, both refusals, the catch-up to the mark, the dotted comparison in which
1.2.0 and 1.2.0-rc1 are equal — is pinned without a database in
internal/workapi/versionreconcile_test.go, and repeating it here would be
testing one pure function three times over three sql-servers. What only a real
backend can show is asserted instead: that a recorded marker is there for the
next caller (a new transaction on the unit-of-work backend), that a refusal and
a validation failure write NOTHING, that reconciliation adds no history entry at
all, and that a reconciliation which CANNOT COMPLETE reports an error and leaves
both markers standing. Two independent bodies plus an engine check, not three
votes: dolt and embeddeddolt share internal/workapi/storeversionreconciler.
The fixture carries one hook the frozen roleFixtureKit cannot supply, built at
each wiring site the way CycleDetectorFixture.Exec is: the two states that
matter most — a recorded version BELOW the high-water mark, and its catch-up —
are states the role can never produce, so they are seeded past it.
THIS IS THE FIRST COVERAGE THE DIRECT ROUTE'S RECONCILIATION HAS EVER HAD. Its
round-trip tests (MigratesVersion, AlreadyMigrated, RefusesDowngrade,
TracksMaxVersion) were deleted with the SQLite backend and never replaced; the
note recording that is still in cmd/bd/version_tracking_test.go. The seven
subtests of the deleted use-case method go with it, replaced by the exhaustive
planner table plus nine cases at three backends.
NO HTTP OPERATION, and that is a decision rather than an omission — recorded in
the leaf doc and as A-ver-2 for the owner. The markers are clone-local: they
describe the machine holding the database, so a remote client reading them
learns something it cannot compare against anything it holds. The one version
fact a client CAN act on, the serving binary's release, is already published as
ContextResponse.bd_version, which the document already names as the only field a
client may compare as a version. A write endpoint is worse: reconciliation is an
effect of a PROCESS STARTING, and a client asking a server to record the
client's version would be asking it to lie about which binary holds the
database. If the owner wants a read-only GET /v0/beads/version, the role, the
accessor and both bodies are already here.
NO USER-VISIBLE CHANGE. Every outcome is identical; only three debug lines
moved. One accidental behaviour became deliberate: a binary whose Version string
is empty used to be handled by the downgrade guard on a populated workspace and
by an equality short-circuit on an empty one, and is now an explicit
ErrValidation that writes nothing either way.
ENFORCEMENT. storeversionreconciler joins the cmd-bd-role-constructors deny
list. The version path never named types.IssueFilter, so there is no forbidigo
exception to remove. engdocs/ADDING_AN_ISSUEOPS_ROLE.md gains the two things
this role taught the checklist: a role may honestly have NO HTTP surface, and a
contract case may need a fixture hook for a state the role cannot produce.
Verified: build, vet, gofmt clean; golangci-lint 0 issues;
TestVersionReconcilerContract green at dolt (9/9), embeddeddolt (9/9) and uow
(9/9); the planner unit tests, both decorator enumerations, the root layering
pins, internal/jira and the internal/storage/domain/db config suite green;
internal/httpapi green and `make api-check` clean with no spec or generated
diff; TestReconcileVersionPersistsAcrossUOW green; TestProxiedLookup green;
`-run 'TestTrackBdVersion|TestAutoMigrateOnVersionBump|TestGetVersionsSince|TestMaybeShowUpgradeNotification|TestInitDoltMetadata'`
green under BEADS_TEST_EMBEDDED_DOLT and TestProxiedServerContext /
TestProxiedServerInfo green under BEADS_TEST_PROXIED_SERVER; TestCorpusGolden
green, so no command's JSON moved.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`bd ready --limit 100` prints "showing 100 of 412", and the 412 came from
nowhere in particular. The direct route computed it inline: unwrap past the
storage decorators, type-assert to storage.ReadyWorkCounter, and fall back to
an unbounded ready query when the assertion missed — twice, once in the --json
branch and once in the text one, with two different fallbacks. The proxied
route could not compute it at all and published no `total` key, so the same
script read a number under one workspace topology and nothing under another.
THE ROLE. issueops.ReadyCounter, reached through store.ReadyCounter() and the
provider's own accessor. It answers a question neither neighbour can: Reader
answers with a PAGE and its verdict is has-more ("did the limit hide
anything"), where this is "how many" — strictly larger, and already published
output, so collapsing the two would change what a shipped surface says. Counter
answers a predicate over one table, and the ready predicate is blocker-aware:
it reads the dependency graph and the wisp tier, which no CountRequest can
describe. Counter's own doc already said the count of ready work would be its
own role for that reason.
It takes issueops.ReadyRequest VERBATIM, the precedent ClaimNextRequest set, so
a listing, a claim and a count ask ONE question of ONE set. Limit and Offset are
ErrValidation for the reason a claim refuses them: a cardinality has no page, so
a limit would answer "how many of the first N" and an offset would subtract the
rows it skipped from the size of a set that still holds them.
THE CONTRACT IS AN IDENTITY, not a resemblance:
CountReady(r).Total == len(Reader.Ready(r with Limit=0).Items)
at every implementation. backend/conformance/ready_counter_contract.go holds
seven cases, each citing the leaf doc by line, run at all three backends with
ZERO parks. They are TWO independent bodies plus an engine check: dolt and
embeddeddolt share internal/workapi/storereadycounter (one indexed COUNT(*) per
plane minus their overlap), and the unit-of-work provider is genuinely separate
code that runs the unbounded ready query and takes its length — which is why
the wisp-tier case is written the way it is, since that is where a COUNT and
the page it sizes are assembled by different arithmetic.
A DEFECT THIS FOUND, and it is not the count's. `bd ready`'s directory-label
default (GH#541) never reached the ReadyClaimer role. claimNextRequest re-ran
the gatherer's own emptiness test against in.filter — and the gatherer had
already written the default INTO that filter, so the test saw a non-empty label
set and skipped. The branch could never fire. In a directory with
`directory.labels` configured, `bd ready --claim` therefore claimed from the
WHOLE ready front while `bd ready` beside it listed only the configured scope:
exactly the "hand an agent work the listing never offered it" that
ReadyClaimer's contract exists to forbid. The gatherer now RECORDS its decision
(readyInput.dirLabels) and both roles read it, so there is one answer instead of
two derivations of it. Caught by writing the count's own test for the same
line, and pinned by cmd/bd/ready_role_request_test.go.
WHAT ELSE CONVERGED. Both routes and both output modes now ask one question
through one accessor: the direct route's two inline epilogues become one call,
and the proxied route's `pagination.total` exists for the first time. The
"showing X of N" text a human reads and the total a script parses are the same
number by construction. cmd/bd no longer names storage.ReadyWorkCounter at all
— the capability is required by the store body's PARAMETER TYPE, so a backend
that cannot size the ready set fails to compile instead of falling back to a
mega-query at runtime.
THE HTTP OPERATION, spec first (per bd-jtp1h's A2 scope decision):
GET /v0/beads/ready:count, capability `ready.count`, answering
`ReadyCount {total}`. It publishes no `limit` and no `sort`: a cardinality has
no page and no order, and the handler sends the listing's own sort default so
the request stays the listing's request rather than one that resembles it. The
filter vocabulary is decoded by ONE function shared with GET /v0/beads/ready
(readyFilters), so the two operations cannot admit different parameters — which
is what the identity rests on over the wire.
`TestCountReadyAndListReadyAdmitTheSameFilters` compares the two predicates
built from one query string. No component here carries allOf and none is
x-go-type-pinned: the pinned seven are canonical Go structs whose JSON encoding
IS the contract, and there is no canonical struct for this number — the CLI
publishes it inside its own stdout envelope, which is not a wire type — so
pinning would weld the body to a CLI presentation type rather than prevent a
drift. The generated output was read to confirm it (a struct with `Total
int64`, not an alias), which is the v2.6.0 trap this document warns about.
httpapi.Config's ROLES database source grows a REQUIRED third member. That is
the sharp edge for the next role commit and is now written down in
engdocs/ADDING_AN_ISSUEOPS_ROLE.md as step 13: a Config carrying the old pair
would bind and then nil-dereference on the first request that reached the new
handler, so Listen refuses it with the same message a half-set pair gets.
USER-VISIBLE, for the wave's changelog pass: proxied `bd ready --json --limit N`
now publishes `pagination.total`; `bd ready --claim` now honours the
directory-label scope on both routes.
Verified: build, vet, gofmt clean; golangci-lint 0 issues; make api-check
(regenerate-and-diff plus the httpapi suite) green; TestReadyCounterContract
7/7 at dolt, embeddeddolt and uow; the httpapi package suite; the direct-route
`bd ready` suites under BEADS_TEST_EMBEDDED_DOLT=1 and the proxied ones under
BEADS_TEST_PROXIED_SERVER=1, including the pagination envelope that now asserts
the total; TestProxiedLookup*; and the ready protocol-corpus tests, which are
byte-identical.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`bd dep list a b c --direction=down` asks a different question from every
other dep read: it answers with RAW EDGE ROWS keyed by source, for many
anchors at once, and it has to say per anchor whether that anchor exists.
Both routes answered it off-role — the direct one out of
GetDependencyRecordsForIssues, the proxied one out of a unit of work — and
neither could tell "this issue has no dependencies" from "there is no such
issue".
THE ROLE. Relations is the near sibling and it cannot answer this. It is
SINGLE-ANCHOR, it answers with the ISSUES on the far end of an anchor's
edges, and an edge whose target this database has no row for — an
`external:` reference, an id in another repository — is silently not a
neighbor. A missing anchor is ErrNotFound there, which a batch cannot use
without discarding the anchors it did find. Different answer shape,
different miss policy, different arity: three, so a new role and a new
accessor rather than a second Relations method. Q12 confirmed the split
against merging it with BlockingAnnotator, which answers a derived
best-effort decoration rather than stored rows.
The direction is OUTGOING only and there is no parameter for it. The inbound
bulk read is a different read against a different key with its own
cross-table de-duplication, and no front door asks for it; a direction
nothing sets would be a promise nothing checks.
TWO DEFECTS THE ADOPTION FIXES, both of them the same shape — a silent
change of JSON document:
- the KNOWN DEFECT. The direct route's batched read fell through to the
hydrated neighbor listing on ANY error, so a transient failure turned
`bd dep list a b --json` from an array of dependency records into an
array of ISSUES, with no error and no warning.
- the same fall-through fired whenever routing split the anchors across
stores, so a cross-rig batch emitted that other document every time. The
role is reached per store now and the answers merge back into argument
order, so a routed batch and a local one have one shape.
Also fixed on both routes: `--type` used to test emptiness BEFORE filtering,
so an anchor whose every edge the filter rejected printed a header with no
rows under it. The role filters, so it prints "has no dependencies".
USER-VISIBLE, approved in the Q11 batch: PROXIED `bd dep list` NOW REPORTS
GHOST ANCHORS. It used to hand the raw arguments to the dependency use case,
which keys its answer by source and has no entry for an id that names
nothing, so a typo printed "<id> has no dependencies" and a script read a
clean graph. The role probes each anchor, so a typo now prints the warning
the direct route has always printed for an argument it could not resolve —
on stderr, in both modes, which is what leaves `--json` the flat array of
dependency records the command documents. The proxied route still resolves
nothing: ids go to the role exactly as the caller spelled them, because that
route has never done partial-id resolution.
One behaviour had no prior decision behind it and is recorded as Q15 rather
than chosen quietly: a repeated anchor now collapses onto its first mention,
where the old loop over a keyed map printed it twice.
CONFORMANCE. backend/conformance/edge_reader_contract.go holds fourteen
cases, each citing the leaf doc by line, run at all three implementations
with ZERO parks. They are TWO independent bodies plus an engine check, not
three: dolt and embeddeddolt both call storage/issueops.ExecuteEdgeRead
inside their own read transaction, and the unit-of-work provider is the
second body — it probes existence through two batched by-id use-case reads
where the stores run one batched EXISTS over both tables.
The store-backed body is an InTx function rather than an
internal/workapi/store<role> package, which is a documented deviation from
the twelve-step checklist and the reason is Relations': the anchor probe and
the edge read must share ONE transaction, or an anchor can be reported
missing by a probe that raced a create the edge read then saw. That cannot
be expressed above storage.DoltStorage. engdocs/ADDING_AN_ISSUEOPS_ROLE.md
now names that variant, including why it needs no depguard entry — the
shared function takes a transaction, so no front door can call it.
HTTP. GET /v0/beads/dependencies is new canonical surface, spec written
first and the types generated from it. `items` is an array of the already
x-go-type-pinned `Dependency`, so the CLI's `--json` and this body stay one
compatibility domain; the new `DependencyEdges` envelope carries no allOf,
so the oapi-codegen v2.6.0 pin-dropping trap does not apply, and the
generated `Dependency` is still an alias. A ghost anchor is on `missing`
rather than a 404, for the reason the role reports it per anchor. There is
no `limit` and no cursor: `bd dep list` has none either, so the QUESTION is
bounded instead — at most 100 `issue_id` values — which bounds the work
without truncating an answer a client could not then page.
httpapi.Config's roles source grows from two roles to three, and Listen
refuses a partially-set set for the reason it already refused a half-set
pair: the missing role is a nil dereference in a handler on a live server.
Verified: build, vet, gofmt clean; golangci-lint 0 issues; make api-check
clean; TestEdgeReaderContract green at dolt (14/14), embeddeddolt (14/14)
and uow (14/14); ./internal/httpapi green; TestCorpusGolden green, so the
committed `bd dep list --json` fixture is byte-identical; TestEmbeddedDep
and TestProxiedServerDep2 green with their gates set; TestProxiedLookup
green.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`bd dep cycles` had two implementations of one sweep and the post-add cycle
warning had two more. The direct route walked store.DetectCycles; the proxied
route walked the same lossy slice off the use case; and dep.go and
dep_proxied_server.go each carried a copy of the arrow-path warning. The two
copies agreed, which is the only reason nobody noticed that the slice they
agreed about was map-ordered and silently shortened. All four now build one
issueops.DetectCyclesRequest and ask for the role.
THE ROLE. A cycle has no ANCHOR. Every Relations request names a source and
answers with that source's neighbours; this one is asked of the whole graph and
answers with paths, so a Relations request type would have carried an anchor
field a sweep must ignore. Its own role and its own accessor per the governing
rule.
TWO USER-VISIBLE CHANGES, both ruled on by the owner (Q4, Q5), both recorded in
CHANGELOG.md.
Q4 CANONICAL OUTPUT. Every source of nondeterminism is removed, not just the
order of the answer, because ordering the answer would not have been enough:
a depth-first enumeration records one cycle per BACK EDGE, and which edges are
back edges depends on the walk. The roots came off a Go map and the adjacency
lists out of an unordered SQL read, so two runs against an unchanged database
could disagree about which cycles EXIST, not merely about their order. The
walk is now sorted at both, each path is rotated to its lowest id, and the
paths are sorted against each other.
Q5 HONEST PARTIAL. A member the database cannot describe used to be dropped
from the path, so a 3-cycle rendered as a 2-cycle and looked complete, and a
wholly undescribable cycle vanished from the report and from the
`Found N dependency cycles` count. Every member is now carried with its id,
its DESCRIPTION is omitted rather than the member, and the cycle is marked
Partial. There is no separate total, because there is no cycle the slice
omits -- the reading of "still counted" is recorded in AMBIGUITIES.md
(A-cyc-1) along with what it would cost to add one.
`bd dep cycles --json` therefore emits a new shape: an array of
{members:[{id, issue?}], partial} where it emitted an array of arrays of
issues. The protocol corpus has no dep-cycles capture, so nothing was pinned
to the old bytes.
WHERE THE BODY LIVES, and why it is not a store<role> package. The work is a
graph read plus a hydration that must see one snapshot, and a transaction is
not reachable through storage.DoltStorage. So the sharing happens one level
down at issueops.DetectCycleReportInTx -- the function both stores' legacy
DetectCycles already call -- with a five-line accessor in each store package
and a new domain repository method for the unit of work. Two wrappers over one
function is still ONE vote. The parts that decide what the answer MEANS are
pure (CanonicalCyclePaths, BuildCycles) and pinned without a database.
CONFORMANCE. backend/conformance/cycle_detector_contract.go holds eight cases
citing the leaf doc by line, run at all three implementations with ZERO parks:
24 subtests green.
SEEDING ONE TAKES RAW SQL, which is a fact about the system rather than a
shortcut. No supported write can create a cycle -- the editor's per-edge probe,
its whole-graph gate and the storage seam all refuse -- so there is no verb that
produces the state this role reports. And foreign keys (dependencies.issue_id
-> issues, wisp_dependencies.issue_id -> wisps) mean an undescribable member is
reachable only with foreign_key_checks off. That is not academic: those are
exactly the paths a cycle arrives by. Recorded as AMBIGUITIES.md A-cyc-2 with
the alternative if the owner would rather the contract not write that way.
HTTP. GET /v0/beads/dependencies/cycles, spec first and the types generated
against it. Cycle and CycleMember are x-go-type-pinned to the ROLE package, so
the CLI's --json element and the HTTP item are one struct; the bijection test
grew a per-schema import path to cover them and immediately caught a missing
json tag on Partial. No allOf on either component (the v2.6.0 trap), verified
in the generated output: both emit `type X = issueops.X`. No limit and no
cursor -- truncating would shrink the count, which is the number an operator
acts on -- so has_more is documented as always false. httpapi.Config's roles
source now requires the third role beside Reader and Claimer, refused at Listen
for the reason a half-set pair is.
ONE DEFECT FIXED BESIDE THE TWO RULINGS: proxied `bd link` ran its cycle sweep
and its title lookups INSIDE the write transaction, so the warning described a
graph nobody else could see. It now runs them after the commit, through
depEdgeFeedback, which is where the dep routes already did it.
Verified: build, vet, gofmt clean; golangci-lint 0 issues; make api-check
green; TestCycleDetectorContract 8/8 at dolt, embeddeddolt and uow;
internal/httpapi 0 failures including the five new cycle-route cases;
TestProxiedLookup* green; TestEmbeddedDep* green;
BEADS_TEST_PROXIED_SERVER=1 TestProxiedServerDep* green; TestCorpusGolden
green.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`bd config` had two implementations of the same four verbs. The direct route
called store.SetConfig/GetConfig/GetAllConfig/DeleteConfig in cmd/bd/config.go;
the proxied route opened its own unit of work and called the config use case in
config_proxied_server.go, then printed the same lines a hundred lines away. Both
now build an issueops request and ask for the role, and the difference between
the two routes is which accessor answers.
THE ROLE. issueops.WorkspaceConfig is the workspace's DURABLE SETTINGS PLANE:
the key-value rows the workspace database holds. It is born with four methods
because read, write, remove and enumerate over ONE keyed namespace are four
shapes of one question — the governing rule forbids appending to a role, not a
role being born whole — and because their promises are statements about each
other: SetSetting's promise is about what a later GetSetting returns, and
UnsetSetting's about what a later ListSettings omits.
The methods are GetSetting/ListSettings/SetSetting/UnsetSetting rather than
Get/List/Set/Unset, and that is not verbosity. Reader already has Get and List,
and the decorator conformance tests drive ONE sentinel that implements every
role at once; two roles with the same method name and different signatures make
that sentinel unwritable. The collision was the design telling us the short
names belong to issues.
ONLY THE KV SLICE IS A ROLE, and the rest is a deliberate no. `bd config show`,
`drift`, `apply` and `validate` are multi-source diagnostics over config.yaml,
environment variables, git config, this plane and server state at once. Three of
those five sources are files on the CLIENT's filesystem, which a server
answering for a remote workspace can never read, so a substrate role claiming to
answer them would be claiming to see something it cannot. `bd config set-many`
is off the role too, for a different reason: it exists to make N keys ONE Dolt
commit, the role writes and commits one setting per call, and
TestProxiedServerConfigSetMany pins the difference. A batched write is a
separate capability, exactly as `bd create --file` stays off Lifecycle.Create.
TWO LIVE DEFECTS FIXED.
1. THE PROJECTION, which is the Q11 user-visible change. Reads of the custom
status and type vocabularies are TABLE-first: they consult custom_statuses
and custom_types and fall back to the config string only when the table is
empty. The store backends have always rewritten the table in the same
transaction as the row; the unit-of-work backend wrote only the string. So
on a team server `bd config set types.custom "session"` reported success,
`bd config get` read it back, `bd doctor` re-verified against the string and
reported all-OK, and `bd create -t session` answered "invalid issue type"
for as long as the workspace lived. Fixed where dab71c5eb fixed it — in the
config repository, so the row and its projection commit together — and
verified by reverting the fix and watching ProjectsCustomStatuses and
ProjectsCustomTypes fail on uow alone.
2. `bd config set-many issue_prefix=x` re-prefixed the workspace. The
single-key verb refuses the prefix in both spellings and points at
`bd init --prefix`, `bd bootstrap` and `bd rename-prefix`; set-many
partitioned its pairs by source and wrote the database ones straight
through, so it never saw that guard. Beads created before the write and
after it disagreed about their own namespace with nothing to reconcile
them. The refusal is now in the role for every caller that goes through it,
and at set-many's front door because it does not.
THE BRIEF'S THIRD PREMISE IS FALSE, and it is worth saying so: "uow SetConfig
skips issue_prefix normalization" is not true at this base.
configSQLRepositoryImpl.SetConfig has trimmed the trailing hyphen since the file
was created (4fcbd5882, verified with git log -L). The normalization half needed
no fix; the custom-table half did, and dab71c5eb is NOT in this base.
WHAT ELSE CONVERGED. The status.custom parse lived in THREE places (both routes
of `bd config set` plus set-many) and is now one; the routing that stays at the
front door — which source owns a key, and whether writing it would leak a secret
into git — stays there, because those are questions about files on this machine.
CONFORMANCE. backend/conformance/workspaceconfig_contract.go holds fourteen
cases run at all three implementations with ZERO parks. Its shape is
deliberately not the issue contracts': there are no rows to seed, so it asserts
PRECEDENCE (which of two writes a later read sees, and whether a refusal leaves
the earlier value standing) and SIDE EFFECTS. Every projection case reads the
TABLE through QueryScalar rather than reading the setting back through the role,
because reading it back through the role is exactly the check that passed on the
backend where nothing took effect. Two independent bodies plus an engine check,
not three votes: dolt and embeddeddolt share
internal/workapi/storeworkspaceconfig.
TWO ASYMMETRIES ARE PINNED RATHER THAN FIXED, because all three backends agree
and closing either is a user-visible change this slice was not approved for.
UnsetSetting does not undo SetSetting's projection, so removing types.custom
leaves the custom types applying (bd-yby99.33); and `bd config unset
issue_prefix` is not refused where `bd config set` is (bd-yby99.34). Both are
stated in the leaf doc and asserted by a case, so neither can drift or be closed
on one backend while the owner decides.
HTTP. GET /v0/beads/config and GET /v0/beads/config/{key}, spec-first, taking
the v0 surface from six operations to eight. A setting whose KEY marks it as
credential-bearing — notion.token is database-backed — is published with
`redacted: true` and NO value: withheld values are omitted rather than masked,
which is the document's own "verbatim or absent" rule, and the CLI is unchanged
because its caller already holds the database while this surface has no
authentication. There is no HTTP WRITE, and that is the honest answer rather
than a hedge: `bd config set` routes most keys to config.yaml or git config
before the database is reached, so a server-side PUT of `export.auto` would
return 200 and land a row nothing reads. `Setting` is the one unpinned response
component, with the reason in the document beside it — the CLI marshals an
ad-hoc map, so there is no canonical struct to pin to, and minting one would
mean changing `bd config get --json` in order to satisfy a rule about not
changing it. All three are recorded in AMBIGUITIES.md as A-cfg-1..3.
ENFORCEMENT. storeworkspaceconfig joins the cmd-bd-role-constructors deny list.
`bd config` never named types.IssueFilter, so there is no forbidigo exception to
remove. engdocs/ADDING_AN_ISSUEOPS_ROLE.md gains what step 12 now costs since
the owner's scope decision: the spec operation, the route row, the Op constant
and operationCodes row, the capability token, and the Config field that a
store-shaped database source must now carry.
Verified: build, vet, gofmt clean; golangci-lint 0 issues;
TestWorkspaceConfigContract green at dolt (14/14), embeddeddolt (14/14) and uow
(14/14); the workapi validator unit tests, the two decorator enumerations, the
root layering pins and internal/jira green; internal/httpapi green and
`make api-check` clean; TestProxiedLookup green; `-run Config` green under
BEADS_TEST_EMBEDDED_DOLT and, under BEADS_TEST_PROXIED_SERVER, green except
TestConfigValidateReadOnlyIsHermetic, which fails identically on a pristine base
worktree under the same filter and passes standalone on both. TestCorpusGolden
green, so `bd config --json` is byte-identical to the committed corpus.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* feat(serve): serve a registered backend from the store bd already opened
`bd serve` was the one command that did not use bd's own store-creation
path. Ordinary CLI commands dispatch the workspace open through
`backends.Lookup` (cmd/bd/store_factory.go, and PersistentPreRunE inlines
the same arm), so `bd list` and `bd create` already work on any registered
backend. `runServe` instead built a unit-of-work provider of its own,
hard-wired to Dolt's SQL wire — and `serveModeGate` classified a registered
workspace as EMBEDDED and refused it before construction even started.
Serve now creates nothing. On the registered arm it takes
`httpapi.Config.Reader` and `Config.Claimer` off the store PersistentPreRunE
already opened, so there is one creation path rather than two: a second
handle would double the pools and self-conflict with any backend holding an
exclusive workspace lock. The store's lifecycle stays where it was —
PersistentPostRunE closes it, after runServe returns and therefore after the
server has drained.
The roles come from BENEATH the hook decorator (one `HookFiringStore.Unwrap`,
never `storage.UnwrapStore`, which would drop the telemetry layer too). A
store's accessors hand out its decorators by design, so the obvious
`store.IssueClaimer()` returns a claimer that runs the workspace's on_update
script for every claim it lands — exactly what this server documents it does
not do. `httpapi.Listen` refuses a hook-firing role, so getting this wrong is
a startup error rather than a silent subprocess per claim.
`serveModeGate` becomes `serveDatabaseSource`: one function that is both the
gate and the wiring decision, so the two cannot disagree about one workspace.
It consults the registry BEFORE any Dolt-mode signal, matching the order the
store open already resolves them in — a registered workspace opens its
registered store even with BEADS_DOLT_SHARED_SERVER=1 exported, and resolving
it the other way here would build a Dolt provider over a non-Dolt store. That
ordering also closes a latent CGO_ENABLED=0 bug: `isEmbeddedMode` is a
constant false there, so the old gate ADMITTED a registered workspace and
handed it to `resolveServerModeUOWTopology`, which either failed with a
misleading Dolt error or connected to a defaulted host and served the wrong
database.
The embedded-Dolt refusal is unchanged and unweakened: same typed
`ErrUnsupported{Op: "serve", Backend: "embedded-dolt"}`, same message, same
permanence — its commit protocol runs outside the SQL transaction, so this
server's per-request atomicity would be a lie there.
The classification now runs after `GetContextInfo`, because it reads the
workspace's configuration. A directory with no workspace at all therefore
reports that rather than reporting the embedded refusal for a workspace
nobody found.
TestServeBuildsOnlyAProviderBackedServer pinned the world this replaces and
could not be satisfied, only rewritten.
TestServeNamesOneDatabaseSourcePerServerItBuilds keeps the property it
actually protected: every httpapi.Config in cmd/bd names exactly one complete
database source, both arms exist, and a roles-backed one is built only inside
a function that consults serveDatabaseSource.
Agent-Signature: claude-opus-5
Co-authored-by: CI Bot <ci@beads.test>
* fix(serve): make the registered-backend arm honest about itself
Four findings, three of them things this arm asserted and one it never
proved.
THE IDENTITY HANDSHAKE LIED. GET /v0/beads/context reported
backend="dolt", dolt_mode="embedded", database="beads" for a registered
workspace — a confident description of the exact topology bd serve
refuses to serve, on the one endpoint automation is told to trust for a
server's identity, while the startup line beside it named the registered
backend correctly. The cause was the shared projection: it hardcoded the
backend to "dolt" and copied the Dolt fields unconditionally, and both of
those DEFAULT rather than fail. The fix is in that projection rather
than in runServe, because `bd context`, `bd context --json` and this
endpoint all read identity through domain.PublishedContext so they cannot
name one workspace differently; correcting the value in serve would have
made HTTP truthful and left the CLI printing `backend: dolt` in the same
directory. There were TWO copies of the hardcode — the contextinfo use
case and `bd context`'s direct route — so the policy is now one method,
domain.ContextInfo.SetBackendIdentity, that both call, and a test
compares what the two routes publish for one workspace. A registered
backend reports the EMPTY string for dolt_mode and database: bd does not
implement the backend and cannot know which database its Open settled on,
so any non-empty value is the same lie made quieter. No wire field is
renamed, retyped or dropped; both stay required strings and the v0 shape
is unchanged, spec and generated types untouched.
THE ARM'S CORE PROPERTY IS NOW PINNED. Nothing distinguished "serve
answers from the store bd already opened" from "serve opens a second
store": same reads, same claims, same handshake, same clean shutdown, and
replacing `store` with a self-opened handle compiled and passed
everything. Two assertions close it. The registry now hands back stores
whose readers answer with an issue named after the open that produced
them, so GET /v0/beads/ready says WHICH store the server is on; and the
end-to-end test counts opens through the registry and requires exactly
one for the process, which catches the leak the substitution leaves
behind. The stated mutant fails both.
`bd --readonly serve` IS REFUSED. It had degraded differently and
silently on each source: on the store source the root command opens
through backend.OpenReadOnly and serve took its claimer off that store,
so the server bound, went on advertising `issues.claim` — the capability
set comes off the route table and cannot see a CLI flag — and answered
every claim 500 with the issue left open; on the provider source serve
builds its own writable provider, so the flag bought nothing and every
claim landed. The gate runs before the workspace is resolved, so the
answer cannot depend on the topology. Narrowing the advertised capability
set instead was rejected as a wire change: `capabilities` is the
documented pre-flight a client checks, and making an operation's presence
depend on a flag on the process that started the server gives a client
something it cannot discover before connecting. Refusing is also what bd
already does one layer down for a backend that cannot guarantee
mutation-free access.
Agent-Signature: claude-opus-5
Co-authored-by: CI Bot <ci@beads.test>
* docs(serve): label the readonly refusal as breaking, and stop over-claiming
Three corrections from the verification pass, none of them code-behavior:
CHANGELOG: the --readonly serve refusal was filed under Fixed. On a Dolt
SQL-server workspace it is a BREAK, not a fix: the flag was a silent no-op
there and the server bound fully writable, so anyone scripting
`bd --readonly serve` as a "safe" read server loses it on upgrade. Moved to
Changed, marked BREAKING, and it now says what to do instead.
bd context: mode/database are Dolt-only now, and printing bare labels with
nothing after them reads on a terminal as though bd failed to determine them
rather than as though they do not apply. Omitted when empty, like every other
optional field in that block.
context_identity_test.go: the parity test's comment claimed it compares what
both `bd context` routes publish. It does not — it rebuilds the snapshot and
calls applyContextBackend directly, so it pins the shared projection, not
contextCmd's own wiring. Recorded as an explicit NOT COVERED note rather than
left to read as more coverage than exists.
Also worth recording: the lint check reported earlier was near-vacuous.
`golangci-lint --new-from-rev=HEAD` on a committed clean tree diffs against
itself. Re-run against the real merge base it is genuinely 0 issues.
Agent-Signature: claude-opus-5
Co-authored-by: CI Bot <ci@beads.test>
---------
Co-authored-by: CI Bot <ci@beads.test>
`bd count` had two implementations of the same command. The direct route
built a types.IssueFilter in cmd/bd/count.go, loaded the workspace list
config and applied the --include-infra policy; the proxied route did all
four again in count_proxied_server.go and executed against the use case.
Both now build an issueops.CountRequest and ask for the role, and the
difference between the two routes is which accessor answers.
THE ROLE. Counts are NUMBERS; Reader answers PAGES OF ISSUES. Different
question, so its own role per the governing rule rather than a counted
variant on Reader: a count has no order, no page and no cursor, and a
request type carrying paging fields a count must ignore is the shape that
makes a caller believe --limit 10 bounded the answer. Count and
CountByGroup are two shapes of ONE question and cannot be separated in
practice - the grouped answer carries the scalar Total, because label
buckets overlap and the sum is wrong - so the role is born with both.
WHAT CONVERGED, beyond the duplication:
- the wisp-tier policy. BuildCountFilter is now the single definition of
what `bd count` means, beside BuildListFilter, and the GH#4387
cardinality-parity test moved from cmd/bd to internal/workapi where it
compares the two SHARED builders instead of a CLI helper against one
of them.
- the grouped Total. "use the scalar count, not the sum, because label
buckets overlap" lived in cmd/bd; an HTTP surface adding grouped
counts would have had to rediscover it.
- the config load. It happens inside the role, and only under
IncludeInfra, so a plain count still makes one query.
CONFORMANCE. backend/conformance/counter_contract.go holds twelve cases,
each citing the leaf doc by line, run at all three implementations with
ZERO parks. They are TWO independent votes plus an engine check, not
three: dolt and embeddeddolt both hand back internal/workapi/storecounter,
and the unit-of-work provider is the second body.
ENFORCEMENT. cmd/bd/count.go no longer names types.IssueFilter, so `count`
LEAVES the forbidigo exception list - the hole it needed is closed rather
than merely unused. The reader-constructor depguard rule becomes
cmd-bd-role-constructors and gains storecounter, so it is a list the next
role extends by one line instead of a rule per role.
NO HTTP HANDLER EXISTS for count. `bd serve` publishes /healthz,
/v0/beads/context, /v0/beads/ready, /v0/beads/issues, /v0/beads/issues/{id}
and POST /v0/beads/issues/{id}:claim, and the spec is Tier-1 ratified, so
none was invented.
THE PER-ROLE COST, which no design budgeted, is now written down in
engdocs/ADDING_AN_ISSUEOPS_ROLE.md: twelve steps derived from this commit,
naming the accessor line in internal/storage/storage.go, the hook and
telemetry wrappers, the two store accessors, the unit-of-work source, the
three conformance wirings, the five places each decorator enumeration
lists a role, and the two lint edits. Every later new-role commit follows
it.
Verified: build, vet, gofmt clean; golangci-lint 0 issues;
TestCounterContract green at dolt (12/12), embeddeddolt (12/12) and uow
(12/12); TestEmbeddedCount* and TestProxiedServerCount* green with their
gates set; TestCorpusGolden green, so `bd count --json` is byte-identical
to the committed protocol corpus.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Let httpapi.Config take the issue roles as a database source
bd serve could only be built from a unit-of-work provider: Config.Provider
was the only database field, and Listen refused a nil one. A backend whose
facade is a STORE — which is the shape the storage/backends registry seam
already has — had no way to be served at all, even though its accessors
return exactly the two roles the handlers now use.
Config gains Reader and Claimer beside Provider, and Listen takes exactly
one complete source: a provider, or both roles. Serving a store-backed
workspace is now Config{Reader: rd, Claimer: cl} from that store's own
IssueReader()/IssueClaimer(), with no unit-of-work provider invented in
between.
The provider path is byte-identical. reader() and claimer() still wrap the
provider per request in timedProvider and build the roles over that wrapper,
so uow_ms keeps measuring what it always measured and both timing tests keep
pinning it. On the roles path there is nothing to time — this server opens no
units of work — and 0.000 is the true value, so the startup line gains a
db=provider/db=roles field to make the zero attributable rather than silent.
The pool_* fields and the PoolTuner call stay behind the provider for the
same reason: the pool belongs to whatever the backend is.
A half-set pair is refused rather than tolerated. A reader with no claimer
would bind, answer every read, and fail the one write on this surface with a
nil dereference inside a handler.
No handler, route, spec or generated type changes: the wire is untouched, and
cmd/bd/serve.go still builds the provider it always did. The remaining piece —
serveModeGate narrowing plus a store-backed arm in runServe — waits on the
first registered store-shaped backend, and on resolving that cmd/bd's store
chain fires hooks on a landed claim, which bd serve documents that it does not.
Agent-Signature: claude-opus-5
Co-authored-by: CI Bot <ci@beads.test>
* Make the role seam's guarantees structural again, or loud
Config.Reader/Claimer took three guarantees that the provider seam enforced
by construction and turned them into prose contracts on caller-supplied
code. Two of them can be checked here and now are; the third cannot be
checked here at all, and the docs stop claiming otherwise.
A role that answers with nothing is no longer dereferenced. handleGetIssue
wrote *details and handleClaim wrote *result.Issue on the strength of a
property the provider path could not violate: s.reader() could only return
uow.NewIssueReader(...), whose Get routes through workapi.GetIssueOrWisp,
and that function exists precisely so no caller is ever handed a nil issue
with a nil error. A configured role is ordinary code. checkedReader and
checkedClaimer (roles.go) now wrap every role this server hands a handler,
from EITHER database source — unconditionally, so that "there is no other
way to reach the dereference" is the reason it is safe rather than a
separate belief about how the provider path behaves. A reader with no
detail view is folded into the documented miss and answers the same 404
body an absent issue does, byte for byte. A claimer that reports success
without a row has no documented reading, so it is the generic 500 — with
the fault in the log as an error and a request_error line beside it, which
is what the panic it replaces did not produce.
Listen refuses a role that fires the workspace's hooks. bd serve documents
that hooks do not fire, and a store's accessors hand out its decorators by
design — IssueClaimer recurses so that a CLI claim keeps its on_update — so
store.IssueClaimer() on bd's own chain (HookFiringStore ->
InstrumentedStorage -> raw) returns exactly the claimer that voids that
contract, silently, for as long as the process is up. The Config doc gave
that line verbatim as the intended pattern; it now names the store value to
take roles from instead, and storage.RoleFiresHooks lets checkDatabaseSource
refuse the other one at startup rather than trusting the paragraph.
The embedded-Dolt refusal keeps CLI-side enforcement, and the docs stop
grounding it in a structural fact it no longer has. It was structural while
Listen took a provider or nothing: there is no unit-of-work provider for
that backend, so an embedded-backed server was not constructible. The roles
source makes one constructible, and internal/httpapi cannot close that — a
role is an interface, and every check available at that layer is a
self-declaration by the same caller-supplied code being checked, which is
the trust it would be replacing rather than a replacement for it. So
serveModeGate is now the only enforcement point, and bd-serve-v0.md,
SERVE_RUNBOOK.md and serve.go say so plainly, with the permanence
re-grounded on the backend's commit protocol — a property of the backend
rather than of what has been written so far. The precondition a caller owns
is stated on Config.Reader/Claimer, and
TestServeBuildsOnlyAProviderBackedServer pins against cmd/bd's source that
bd names no database source but the provider that gate vouched for.
No wire change: internal/httpapi/spec and internal/httpapi/apigen are
untouched, and both new answers use codes v0 already publishes.
Agent-Signature: claude-opus-5
Co-authored-by: CI Bot <ci@beads.test>
---------
Co-authored-by: CI Bot <ci@beads.test>
* feat: add MiniMax provider support via Anthropic-compatible API
- Add MINIMAX_API_KEY env var support as fallback for ANTHROPIC_API_KEY
in both compact (haiku.go) and find-duplicates command
- Add ai.base_url config key (BD_AI_BASE_URL env) for custom API endpoints
- Add MINIMAX_BASE_URL env var for MiniMax-specific base URL override
- Default to https://api.minimax.io/anthropic when MINIMAX_API_KEY is used
- Add DefaultAIBaseURL() helper to internal/config
- Add unit tests for new MiniMax key resolution and base URL override paths
- Fix TestNew_NilConfig and TestNew_NoAPIKeyFallsToDryRun to also clear
MINIMAX_API_KEY to maintain expected dry-run fallback behavior
Supported models: MiniMax-M2.7, MiniMax-M2.7-highspeed
* fix(compact): complete MiniMax provider integration
Add shared Anthropic-compatible key and base URL resolution so compact auto mode and AI duplicate detection accept MINIMAX_API_KEY with the MiniMax base URL default. Update help/docs and tests for key precedence and base URL behavior.
Co-authored-by: octo-patch <octo-patch@github.com>
_codex-gpt-5.5-medium on behalf of CI Bot_
* docs: refresh MiniMax CLI reference pages
Regenerate website CLI reference pages after updating compact and find-duplicates help for MiniMax provider support.
_codex-gpt-5.5-medium on behalf of CI Bot_
* docs: regenerate CLI reference against pinned release tag
The upstream docs pipeline now pins CLI reference generation to a
released tag (docs/cli-docs.pin -> v1.1.0) rather than building from
the current checkout, so the published docs describe the latest
release instead of unreleased branch changes. Since the MiniMax
provider work in this branch has not shipped in a release yet,
regenerating against the pin reverts the MiniMax-specific wording in
these three files back to the v1.1.0 text. This is expected under the
new pin-based pipeline, not a regression of the MiniMax feature: the
Go source (cmd/bd/compact.go, cmd/bd/find_duplicates.go) still
reflects MiniMax support, and these docs will pick it up once
docs/cli-docs.pin is bumped past a release that includes it.
Co-authored-by: octo-patch <octo-patch@github.com>
Agent-Signature: claude-fable-5-high on behalf of maphew
* fix(minimax): provider-aware model default, single-var key hint, test env guard
Post-refresh review fixes (codex gpt-5.6-sol, high) on the MiniMax provider
branch:
- A MiniMax-selected key (MINIMAX_API_KEY) now gets a MiniMax-served default
model (MINIMAX_MODEL env > MiniMax-M2) instead of the Claude default that
MiniMax's Anthropic-compatible endpoint does not host — key-only setup
works without also configuring ai.model. Explicit ai.model still wins.
- The git-tracked-config secret hint for ai.api_key interpolates into an
'export %s=...' template; 'A or B' would shell-assign to B alone. Hint
the primary var only.
- ai_method_missing_key_error integration subtest now also skips when
MINIMAX_API_KEY is set, preserving its no-live-API boundary.
Co-authored-by: octo-patch <octo-patch@github.com>
Agent-Signature: claude-fable-5-high on behalf of matt wilkie
---------
Co-authored-by: octo-patch <octo-patch@github.com>
Co-authored-by: CI Bot <ci@beads.test>
Co-authored-by: matt wilkie <maphew@gmail.com>
Consolidate test execution and design guidance around the smallest trustworthy seam, narrow doubles, semantic versus persistence conformance, strict E2E admission, and proportional verification. Convert the former philosophy documents to compatibility pointers.
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of CI Bot
Co-authored-by: CI Bot <ci@beads.test>
engdocs/design/bd-serve-v0.md states the contract and the decisions behind
it: the six operations, the error-code vocabulary and the one-way-door rule
on it, the cursor's four normative properties (including that misuse is not
detectable), the loopback posture and its three bounds, and the no-hooks and
no-auto-commit decisions as contract rather than gaps. It carries across the
SHARED / ENFORCED-and-by-what / NOT-ENFORCED claim from httpapi/doc.go and
issueops/reader.go verbatim in substance and deliberately does not
strengthen it - this epic shipped an overstated version three times.
engdocs/SERVE_RUNBOOK.md is the operator half: the fixed-port recommendation
with the honest note that --addr 127.0.0.1:0 carries NO mutual exclusion,
the readiness probe (/healthz is liveness only), the SIGHUP/supervisor note,
the ambiguous-shutdown re-claim recovery and why a re-claim is safe by
construction, the connection-budget arithmetic for a shared external Dolt
server, and the request-log field list.
Both address generic automation clients and orchestrators. Every decision is
motivated from the API contract - a client that substring-matched claim
conflicts should switch to the typed 409 - and no downstream consumer,
product or fork is named.
The CHANGELOG entry is the user-facing announcement of the same surface.
DOC_INVENTORY gains a row for each new file, and the runbook a Last-reviewed
marker naming the constants it tabulates.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Test (Embedded Dolt Storage) ran the ~84-function internal/storage/embeddeddolt
suite (minus TestConformance) as a single unsharded job, ~24.3min and the
longest pole in every Main/PR-Risk run per engdocs/CI_CLEANUP_PLAN.md and
mybd-t8l8; it timeout-red'd upstream main at its 30m suite budget twice on
2026-07-28 (mybd-jobt).
Extends the existing test-embedded-cmd manifest-driven scheme
(embedded-test-shard.sh + embedded-cmd-test-shards.txt, already 20-way) to the
storage job: new embedded-storage-test-shard.sh discovers top-level Test*
functions in internal/storage/embeddeddolt/*_test.go (excluding
TestConformance, which stays in its own job), consults a committed manifest
(embedded-storage-test-shards.txt) for balance, and hash-falls-back for
newly-added tests. No per-test timing data exists for this suite, so the
manifest assigns the 83 discovered tests round-robin over the alphabetically
sorted list for 5 shards (17/17/17/16/16), which spreads related families
(the 7 TestEmbeddedMergeAndSettle*, ~11 TestEmbeddedMigrat(e|ion)*, 4
TestSearchIssues_MaxRows_*) across shards instead of clustering them.
test-embedded-storage becomes a 5-way matrix job in both main.yml and
pr-risk.yml, per-shard timeout-minutes: 15 and -test.timeout=15m (half the
old 30m budget, matching that each shard carries roughly 1/5 of the tests and
~2-3 of the ~11 migration-chain tests that motivated the original 20m/30m
budget per bd-lrgn1). Job id test-embedded-storage and its BEADS_TEST_EMBEDDED_DOLT
env stay the same, so pr-risk.yml's ci-gate needs/CI_GATE_REQUIRED wiring
(TEST_EMBEDDED_STORAGE) is unaffected by the matrix split; only the job's
display name changes shape, from "Test (Embedded Dolt Storage)" to
"Test (Embedded Dolt Storage N/5)". Updated the two required-check-name
references to that in engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md and
engdocs/CI_TEST_SURFACE_AUDIT.md.
Conformance (core/audit, ~14min each, mybd-ae0n) is left alone: TestConformance
is sharded by sub-test path via -test.run '^TestConformance$/^Audit$', a
different mechanism from this manifest's exact top-level function-name
matching, so it does not extend naturally in this commit.
Agent-Signature: claude-fable-5-high on behalf of maphew
* feat(storage): be-uwvs.1 lite SELECT shape foundation
Add IssueFilter.Lite + IssueSelectColumnsLite + HeavyDropList +
ScanIssueLiteFrom so listing paths can opt out of materializing heavy
TEXT columns (description, design, acceptance_criteria, notes, payload,
waiters). Default Lite=false preserves today's behavior everywhere;
Lite=true (once wired to a call site) would return issues with
IsLitePartial=true and heavy fields blank.
A schema-parity test (cols(Lite) ∪ HeavyDropList == cols(Full)) guards
against future IssueSelectColumns drift, and happy-path tests exercise
both scan helpers.
Out of scope (per bead): CLI wiring, WorkFilter.Lite,
per-backend correctness tests, benchmark — those are be-uwvs.{2,3,4,5}.
Refs: be-uwvs (designer §1/§4/§5), be-jp5s (architecture D2/R-07).
Note (rework, PR #3906): this commit is quad341's original patch
cherry-picked onto current main, minus its internal/storage/issueops/
search.go hunk. That hunk targeted searchTableInTx, which #4150
("perf(id_parser): narrow SearchIssues to id-only projection", merged
2026-07-04) replaced with a generic searchProjection[T] dispatch; the
old hunk has no target to apply to and is dropped here rather than
force-merged. search.go is therefore unchanged by this commit — no
caller can reach the Lite branch yet. The follow-up commit re-homes the
filter.Lite switch inside the new projection system.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore: release gate PASS for be-uwvs.1 (lite SELECT foundation)
* rework(storage): re-home lite SELECT switch into projection dispatch (PR #3906)
Re-homes quad341's filter.Lite SELECT-shape switch (PR #3906) into the
generic searchProjection[T] dispatch that #4150 ("perf(id_parser): narrow
SearchIssues to id-only projection", merged 2026-07-04) introduced in
internal/storage/issueops/search.go, replacing the searchTableInTx
function the PR originally patched.
- internal/storage/issueops/search.go: add issueLiteProjection, a
searchProjection[*types.Issue] literal mirroring issueProjection but
with columns()->IssueSelectColumnsLite and scan()->ScanIssueLiteFrom.
SearchIssuesInTx now selects issueProjection or issueLiteProjection
based on filter.Lite before calling the shared searchInTx wrapper, so
the Lite branch gets wisp-merge, id-shrink Pattern B, and label/dep
hydration for free, same as the full projection. No new top-level
function and no patched SQL-string branch inside searchTableInTxT,
matching the PR's own "adding a narrow-projection variant means adding
a projection literal" design note already on issueProjection/idProjection.
- internal/storage/issueops/scan.go: classify the two column groups added
to IssueSelectColumns since this PR's original patch predates them:
`row_lock` (optimistic-concurrency token) and the `leases.lease_expires_at`
/ `leases.heartbeat_at` overlay (migration 0054, joined via
sqlbuild.LeaseJoin). Both are small, non-TEXT, routing-relevant columns,
so both go into IssueSelectColumnsLite/ScanIssueLiteFrom rather than
HeavyDropList, matching the maintainer review's reasoning for the lease
columns and extending it to row_lock (not discussed in the review because
it wasn't yet on main when the review was written). issueLiteProjection
sets joinLeases: true so the FROM clause gets the LEFT JOIN these columns
require.
Verification (2026-07-23, current upstream/main = 1bbca0c1f):
- go build -tags gms_pure_go ./... -> clean
- go vet -tags gms_pure_go ./... -> clean
- gofmt -l on changed files -> clean
- go test -tags gms_pure_go -run 'Lite|IssueSelectColumns' \
./internal/storage/... -> PASS
(TestIssueSelectColumns_LitePlusHeavyEqualsFull,
TestScanIssueLiteFrom_LeavesHeavyFieldsBlank,
TestScanIssueFrom_PopulatesHeavyFields,
TestIssueSelectColumns_MatchClassic)
- go test -tags gms_pure_go ./internal/storage/issueops/... -> PASS
- go test -tags gms_pure_go ./internal/storage/embeddeddolt/... \
./internal/storage/schema/... \
./internal/storage/versioncontrolops/... \
./internal/types/... -> PASS
Scope preserved from the PR: foundation only. filter.Lite still has no
caller on main (grepped for `.Lite = true` / `Lite: true` outside this
diff -- none found); CLI wiring (bd list / bd dep tree / bd dep graph
--json / WorkFilter.Lite) remains deferred to be-uwvs.2+ per the PR body.
Rework of gastownhall/beads#3906 (feat/be-uwvs.1-lite-select-foundation by
quad341), per maphew's 2026-07-05 review comment on that PR, which
identified #4150 as the timing conflict and named the lease columns as
needing classification.
Agent-Signature: claude-sonnet-medium on behalf of maphew
* chore(storage): drop stale release-gate artifact from PR #3906
release-gates/be-uwvs.1-gate.md is a contributor-process artifact from
the original PR (contains stale fork references) and isn't something
this repo's process wants carried on the branch; docs/EXTENDING.md stays
as the legitimate caller-contract doc introduced by this PR.
Per Opus review (APPROVE-WITH-NITS) on the rework in
rework(storage): re-home lite SELECT switch into projection dispatch
(6882a4513).
Agent-Signature: claude-sonnet-medium on behalf of maphew
* docs(storage): note domain/db path doesn't honor filter.Lite yet
Per Codex review: the proxied-server (domain/db) path —
issueSQLRepositoryImpl.searchTable / fetchIssuesByIDs in
internal/storage/domain/db/issue_search.go — always issues the full
issueSelectColumns SELECT and scanIssue scanner, ignoring filter.Lite
entirely. Confirmed: neither function references filter.Lite.
Adjudicated as document-and-defer, no code change: no domain/db caller
sets Lite=true yet, so this is graceful degradation (correct results,
no lite optimization) rather than a bug, and wiring Lite through
domain/db belongs to the be-uwvs.2+ CLI-wiring follow-up alongside the
rest of the caller work.
- docs/EXTENDING.md: new "Backend coverage" subsection under the Lite
SELECT shape contract; also fixes the "SELECT dispatch" bullet, which
still named the pre-#4150 searchTableInTx function, to name the
current issueProjection/issueLiteProjection dispatch.
- internal/types/types.go: same one-liner added to the IssueFilter.Lite
field doc comment.
Agent-Signature: claude-sonnet-medium on behalf of maphew
* fix(storage): be-uwvs.1 wire less comparator into issueLiteProjection
issueLiteProjection was missing the less: sqlbuild.Less field that
issueProjection carries, per maphew's 2026-07-24 review comment on
PR #3906 flagging this as the remaining follow-up once #4160 landed.
Without it, searchInTx's merge branch (issues+wisps) has no comparator
to re-sort the concatenation of two independently-ordered legs before
trimming to filter.Limit when a Lite search takes that path — the trim
would keep whichever leg happens to come first regardless of sort rank,
unlike the full (non-Lite) projection which already re-sorts correctly.
Also relocates the PR's new docs/EXTENDING.md to engdocs/EXTENDING.md:
the file's own text says "It is not user-facing; it is for code that
embeds bd or talks to the storage layer directly," and
test/docsync.TestEveryDocsPageIsPublished requires every docs/ page to
carry a docs.json navigation entry (Mintlify-published) or live under
engdocs/ instead. engdocs/ is the existing home for this class of
internal contract doc, so move it there rather than adding a new
docs.json entry or exemption. Updates the two code comments that
pointed at the old path.
Verification (2026-07-25, rebased onto current origin/main):
- go build ./... -> clean
- go build -tags gms_pure_go ./... -> clean
- go vet ./... -> clean
- go test ./internal/storage/issueops/... ./internal/types/... ./test/docsync/...
-> PASS
- go test ./... (full suite) -> only pre-existing,
environment-induced failures unrelated to this diff (verified identical
on a clean origin/main baseline checkout: internal/beads, internal/config,
internal/configfile, cmd/bd/doctor TMPDIR/shared-dolt-server/config-leak
artifacts of this sandbox, plus TestCommitBeadsConfigSkipsGitHooks). Docker
unavailable in this environment, so the cgo/Dolt-backed gate tests in
cmd/bd (lite_filter_spy-based) self-skip, same as on baseline.
Rebased gastownhall/beads#3906 (feat/be-uwvs.1-lite-select-foundation)
onto current origin/main; the only conflict was the additive
IssueFilter struct-field collision with #3908/#4160's MaxRows/
MaxRowsSource (both kept).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* test(issueops): be-yrtwi regression test for issueLiteProjection merge-sort
issueLiteProjection was missing the less: sqlbuild.Less comparator that
issueProjection carries (fixed in 64778027e), so sortMergedResults
silently no-op'd on the issues+wisps merge branch and trimToSearchLimit
kept issues-leg concatenation order instead of the true globally-sorted
top-N. No test exercised IssueFilter{Lite: true} through SearchIssuesInTx
end-to-end, so this bug had no regression guard.
Adds a sqlmock-based end-to-end test (matching this package's existing
convention — no test in internal/storage/issueops uses a live DB) that
seeds an issues leg and a wisps leg where the true created_at-DESC top-2
lives entirely in the wisps leg, and asserts SearchIssuesInTx returns
that true order rather than the stale issues-leg rows. Verified this
fails against the pre-64778027e state (temporarily stripped less: and
confirmed red) and passes with it restored.
* fix(storage): classify leases.granted_node into IssueSelectColumnsLite (PR #3906)
Merging upstream/main into the PR #3906 rework branch (feat/be-uwvs.1-lite-
select-foundation) brought in wy-jpd3.7's replica-aware leases, which added
leases.granted_node to LeaseSelectColumns and therefore to IssueSelectColumns
(sqlbuild package). TestIssueSelectColumns_LitePlusHeavyEqualsFull caught the
drift: the new column was in neither IssueSelectColumnsLite nor HeavyDropList,
so the schema-parity invariant (lite ∪ drop == full) broke.
granted_node is a small, non-TEXT lease-overlay column — the same class as
lease_expires_at/heartbeat_at, which IssueSelectColumnsLite already retains
(see #4150) — so it belongs in the lite list, not HeavyDropList. Adds it to
IssueSelectColumnsLite, scans it in ScanIssueLiteFrom into
issue.LeaseGrantedNode (mirroring ScanIssueFrom), and updates the sqlmock
column/row fixtures in search_lite_merge_test.go (be-yrtwi's issueLiteProjection
merge-sort regression test) to the new column count.
This is downstream of #4160's `less: sqlbuild.Less` comparator wiring on
issueLiteProjection, already present on this branch and preserved by the
merge (search.go issueLiteProjection literal) — this commit only follows up
the schema-parity fallout from bringing that history in. Bead mybd-hu2k.
Agent-Signature: claude-fable-5-medium on behalf of matt wilkie
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
* /{engdocs,examples,go.mod}: bump go version
* deps: bump golang.org/x/text to v0.39.0 (GO-2026-5970)
govulncheck against today's vuln DB flags GO-2026-5970 (infinite loop on
invalid input in x/text, reachable via internal/routing), published after
this PR's original clean scan. Bump x/text to the fixed v0.39.0 (with its
MVS sibling x/* minimums) and re-tidy examples/library-usage, which
builds against the parent via a replace directive and would otherwise
fail with missing go.sum entries.
examples/bd-example-extension-go is left untouched: it already fails
'go build' (needs go mod tidy) at the PR's base state, so its tidy is
pre-existing follow-up work, not fallout from this bump.
Verified: CGO_ENABLED=0 go build -tags gms_pure_go ./cmd/bd; both
example modules build; go test ./internal/routing; govulncheck now
reports 0 affecting vulnerabilities.
Agent-Signature: claude-fable-5-high on behalf of maphew
---------
Co-authored-by: matt wilkie <maphew@gmail.com>
* docs(pipeline): pin the generated CLI docs to the released bd; repair main's CLI reference
The #4874 squash-merge raced the docs-autofix bot: the bot had pushed a
regeneration from main's source onto the PR branch, so the squash landed a
contradictory mix — the release-aligned hand-written docs plus a CLI
reference re-documenting unreleased commands and flags, with docs.json
referencing four pages (heartbeat, migrate-personal, reclaim, unclaim)
whose files do not exist. That broken nav fails the docsync guard on main
and on every branch cut from it. This restores the intended end state of
#4874 and lands the pin that prevents the race from recurring.
- Regenerate the CLI reference from a bd built from the v1.1.0 tag (CI's
canonical pure-Go build), removing the unreleased commands/flags and
fixing the dangling nav entries.
- docs/cli-docs.pin names the release tag; scripts/resolve-docs-bd.sh
builds and caches a canonical pure-Go bd from that tag, fetching the tag
first in shallow CI checkouts.
- generate-cli-docs.sh, check-doc-flags.sh, and check-cli-docs-drift.sh
resolve bd through the pin and ignore a supplied binary while pinned
(BD_DOCS_IGNORE_PIN=1 bypasses), so the drift gates and the autofix bot
now enforce docs-match-release instead of docs-match-main.
- tools/docsmint detects the pre-overhaul Docusaurus staging layout that
bd <= v1.1.0 emits and converts it to the generic form before its normal
Mintlify transform (tested); removable once the pin reaches a release
whose emitter writes build/cli-docs.
- check-doc-flags.sh: run without timeout(1) on macOS instead of failing
Check 4.
- Decision record: engdocs/decisions/2026-07-17-docs-release-pin.md; the
beads-docs skill §8 updated to match.
* lint: annotate gosec G705 false positive in the docsmint legacy bridge
Same class as the existing nav-splice annotation: a developer tool writing
repo Markdown, not a web-output sink.
Per the decision record: no parallel run and no cutover PR. Removes
website/ (including the four versioned doc snapshots — current-only
versioning; snapshots remain in git history), deploy-docs.yml,
generate-llms-full.sh (Mintlify serves llms.txt natively), the ci-website
package gate (Makefile target, scripts/ci/website.sh, the package-website
jobs and their aggregate-gate entries in pr.yml/main.yml/release.yml, the
ci-measurements suite, detect-package-gates wiring), and the release-time
docs snapshot flow (snapshot-release-docs.sh, check-docs-version.sh, their
call sites in update-versions.sh/check-versions.sh, RELEASING.md section
rewritten for the Mintlify reality).
Drift machinery now covers exactly the Mintlify artifacts:
check-cli-docs-drift.sh pathspecs/fingerprint, docs-autofix-push.sh
allowlist, and check-doc-flags.sh scans drop the website/llms paths. The
beads-docs skill's generated-content and verification sections updated to
the bd-generic + docsmint pipeline.
NOTE for merge time: if branch protection requires the 'Package Gate
(website)' check by name (rather than the aggregate gate), drop it from
the required checks or PRs will wait forever.
Gates: docsync PASS, generate-cli-docs.sh --check PASS, freshness PASS.
Twelve settled decisions: generic-MD-only emitter, all-in on Mintlify (no
parallel run), committed generated output, Go post-processor, current-only
versioning, redirects instead of pointer stubs (accepting 404s from
already-released binaries), printed-path string fixes on this branch,
disposition confirmations, no bd tracking from this clone, Excalidraw
machinery port, push-without-PR, and this record's home.
Sixteen same-ground pairs reconciled: the ported website page won and every
fact living only in the older docs/ original was merged in before deleting
it (INSTALLING, SETUP, ARCHITECTURE, CONFIG, GIT_INTEGRATION, ADVANCED,
TROUBLESHOOTING, FAQ, MOLECULES, ROUTING, MULTI_REPO_AGENTS, and the five
agent-integration guides). The two divergent FAQs are now one canonical
FAQ with the comparison-first framing leading and pre-1.0 version gating
removed.
The routing pair inverted: the ported page described a routing system that
does not exist (bd routes, bd hydrate, .beads/routes.jsonl); the page was
rebuilt from the accurate sources (ROUTING.md + MULTI_REPO_AGENTS.md)
against the real surface (routing.mode config, role detection,
repos.primary/additional hydration, --repo override).
Every claim was verified against the Go source or the generated CLI
reference. Phantom surfaces removed across the corpus: bd pin/hook/pour/
wisp/routes/hydrate/reserve/lock/merge/stats, bd hooks status, bd vc
conflicts/log, bd dolt set shared-server, fictional beads_* MCP tool names
(real names taken from beads-mcp server.py), import.orphan_handling and
export.error_policy config keys, database.wal_mode/cache_size, stale
.beads/dolt/sql-server.log paths, and SQLite-era file paths. Notable
corrections: min_hash_length default is 3, .beads/metadata.json is
git-tracked, tombstone status is removed, wisps live in the main database
under an ephemeral flag.
Freshness markers moved with their content (configuration, ide-setup) and
the freshness gate + DOC_INVENTORY ledger now point at the new locations.
Load-bearing anchors preserved: #branchless-workflows-jujutsu--jj,
#circuit-breaker-server-appears-down-failing-fast, #extensible-database,
#multi-repo-hydration. Pointer stubs remain at docs/{SETUP,INSTALLING,
GIT_INTEGRATION}.md because released binaries print those paths
(allowlisted in the docsync guard).
Gates: go test ./test/docsync PASS; generate-cli-docs.sh --check PASS;
check-doc-freshness.sh PASS; mint broken-links: no broken links; mint dev
serves all sections (11 routes spot-checked at 200).
- mint.sh + make docs-dev: local preview of the docs/ Mintlify site
(Node 22 handling modeled on the Gas City wrapper).
- test/docsync: Go guard keeping docs/ and docs.json in exact
correspondence — every nav entry has a file, every page is in the nav
(tiny stub allowlist for paths released bd binaries print), published
pages use root-relative extensionless links that resolve, and engdocs/
plus curated root markdown keep exact GitHub-style paths. Wired into
make check-docs.
- .github/workflows/docs-mintlify.yml: docsync + baseline-aware
mint broken-links check on PRs touching docs/**.
- Retire scripts/sync-website-docs.sh and its mirror-drift gate: the six
mirrored files now live once in the Mintlify site; the committed
Docusaurus mirrors stay frozen so the parallel-run site keeps building.
- Repoint inbound links to moved docs across README, guides, examples,
npm-package, plugin resources, and Go comments; add docs/SYNC_CONCEPTS.md
pointer stub (bd's agent templates print that path). Runtime strings in
cmd/bd (prime.go, store_factory_nocgo.go, init_git_hooks.go) still print
old paths — covered by stubs, flagged in the PR.
Port the website's current (non-versioned) authored pages into docs/ as
Mintlify pages: frontmatter title as H1 (body H1s removed), Docusaurus
admonitions converted to Mintlify components, root-relative extensionless
links, mermaid fences kept as-is. website/docs/** is untouched and keeps
serving the Docusaurus site until cutover.
git-mv the user-facing docs/ originals with no website twin into the new
IA (core-concepts/, architecture/, workflows/, recovery/, multi-agent/,
integrations/, reference/), converted to Mintlify form. The six files
previously mirrored by sync-website-docs.sh now live once in the site.
ERROR_HANDLING.md and CONTRIBUTOR_NAMESPACE_ISOLATION.md move to engdocs/
(contributor pattern guide and design doc per content review).
Pointer stubs remain at docs/{DOLT,STORAGE-BACKENDS,PLUGIN,RECOVERY,
JSON_SCHEMA}.md because released bd binaries print those paths; QUICKSTART
and DOLT-BACKEND stay as existing pointer stubs.
Corrected while porting: the intro's storage diagram claimed data lives at
.beads/dolt/; embedded mode (the default) uses .beads/embeddeddolt/
(internal/storage/embeddeddolt/store.go), server mode uses .beads/dolt/.
Relocate contributor- and maintainer-facing material out of docs/ so the
directory can become the user-facing Mintlify site. Moves preserve subpaths
(adr/, design/, staged-for-removal/ intact). messaging.md, UI_PHILOSOPHY.md,
and AGENT_SIGNING.md move per their DOC_INVENTORY dispositions (design doc,
design philosophy, maintainer convention).
Inbound links updated repo-wide: root guides, CONTRIBUTING, AGENTS,
workflows, lint config, scripts (check-doc-freshness now resolves the
inventory at engdocs/DOC_INVENTORY.md), Go comments, and the synced website
metadata page (regenerated via sync-website-docs.sh + generate-llms-full.sh).
The emitted help text in cmd/bd/init_safety_help.go still references
docs/adr/0002-init-safety-invariants.md; changing it would change bd's
runtime output, which is out of scope for this branch (flagged in the PR).