* feat(roles): BatchGetter role and issues:batchGet route (S7)
Adds BatchGetter.GetMany(ids) -> {Issues, Missing}, a one-snapshot,
order-preserving, deduped, 1000-id-capped batch read, wired through all
three library legs (dolt, embedded dolt, uow) behind the existing
hook/telemetry decorator chain, plus the POST /v0/beads/issues:batchGet
HTTP route (spec, apigen, wire-shape golden, issues.batchGet capability
token). Conformance contract (RunBatchGetter*, 12 cases) passes on all
three legs against real backends. No HTTP client leg yet (waits on the
generator / PR #7247); left as a documented seam on BatchGetter's doc
comment.
CLI GetIssuesByIDs call sites are left unmigrated this slice and marked
with TODO(batchgetter) comments: every call site reads an unbounded id
list today, and GetMany's 1000-id cap has no chunking/fallback in any
caller yet, so swapping them in now would add a new, unhandled failure
mode to already-shipped CLI paths (export, import, molecule port,
ready-explain, wisp sweep).
Verified via three live-mutate guards against
internal/storage/issueops/batchget.go (disabling the cap check, dropping
the Missing append, and replacing ordered iteration with map iteration):
each turns the embedded-dolt contract red, confirming the cap, Missing
reporting, and order-preservation assertions actually catch a break.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(roles): close S7 review gaps — revision on wire, BUILD sync, handler tests
Addresses the S7 Opus review's FIX-FIRST items on BatchGetter/issues:batchGet:
HIGH
- batchGetResponse now projects apigen.BatchGetIssue (types.BatchGetIssue +
NewBatchGetIssue), carrying `revision` per issue the way IssueDetails does;
spec, apigen and the wire-shape golden regenerated (additive, no
wire_revision bump).
- make bazel-sync: the 12 files missing from BUILD.bazel srcs are back in
sync across 9 BUILD.bazel files.
- New internal/httpapi/batch_get_test.go: success incl. revision, missing
ids, empty arrays not null, unknown member refused, missing/null ids
refused, query parameter refused, 1001 ids refused with the full request
reaching the role, 1000 ids accepted.
MED
- RunBatchGetterAcceptsExactlyTheCap pins the cap boundary (> vs >=).
- RunBatchGetterHydratesLabels pins Labels survive projection.
- RunBatchGetterReadsOneSnapshot renamed to
RunBatchGetterSharesOneReadStructurally with a doc that no longer
overclaims atomicity; a real interleaving test needs a hook on the frozen
roleFixtureKit, out of scope here.
- Doc comments across ExecuteGetMany, GetManyResult.Issues and the
BatchGetter interface now say hydration is labels only.
LOW
- failBatchGetErr's doc no longer claims blank entries are "already caught".
- PR #7247 references kept.
Re-ran build/vet/gofmt/lint, make api-check, make bazel-sync(-check), the
full internal/httpapi suite, and all three conformance legs (dolt via the
pinned local server, embeddeddolt, uow) plus targeted cmd/bd serve tests —
all green. Live-mutate-guard reverified: cap >=, dropping Missing from the
response, and clearing Labels each now fail the relevant test.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(roles): sync client vocabulary and repo gates with issues:batchGet
The S7 route landed on the server without the sibling tables that hold
the rest of the tree set-equal with the server's surface, so five
tests and two manifest gates went red on the PR head:
- httpclient/wire: mirror batchGetIssues into the client vocabulary,
CLASSIFIED, not wired, the way the wire wave and #7250's
issues.count.scope landed: OpBatchGetIssues, its issues.batchGet
token on opCapability, its identity row, and the first-slice skew
dimension 35 -> 36 (TestCapabilityTableMatchesTheServerRouteTable).
- httpclient/wire: BatchGetIssue is the first golden.json schema with
a `revision` member that needs no legacy-integer tolerance — the
route postdates #6053 and types.BatchGetIssue declares Revision a
string, and a pre-#6053 server never advertises issues.batchGet, so
Preflight refuses before any body is decoded. Exempt it with that
reason in a new revisionSchemaExempt table rather than adding an
issues[] rewrite no legacy server can reach; the gate refuses an
entry that is both covered and exempt, a stale exemption, and an
empty reason.
- httpclient/encode: give the oracle's role set a BatchGetter stub —
httpapi.Listen requires the whole set, so all three oracle tests
failed to bind.
- storage/uow: exempt IssueUseCase.GetMany from the notifying-parity
partition as a read, the reason hook_batch_getter.go gives.
- shard manifest: place TestBatchGetterContract in the 15-shard
embedded storage block (generator --write, incremental).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(roles): pin the BatchGetter pure tier and the spec ids caps
Review fixes, iteration 1. The review approved with no blocker or major
finding and three minors, and this commit takes all three. It changes
tests and one comment only, and every new assertion was mutation-probed
with go test -overlay.
- storage/issueops: add batchget_test.go, the database-free tier that
FinishGetMany's doc already claimed ("pinned without a database") but
that no test supplied. It pins:
- the cap is checked before the blank scan (an over-cap request with
a blank at position 0 answers *TooManyIDsError);
- the bound is inclusive;
- dedupe keeps the first mention, does not trim, and never writes
through the caller's slice;
- Issues and Missing both follow request order;
- both slices are never nil;
- ExecuteGetMany refuses one id repeated past the cap before any
query (a sqlmock with no expectations).
Ten mutants were each killed by exactly their intended test, with the
rest of the package green: last-mention, sort, trim, in-place dedupe,
blank-before-cap, >=, nil Missing, nil Issues, dedupe-before-validate
and validate-after-query.
- httpapi: TestSpecDefaultsMatchSharedConstants now checks ids.maxItems
against the enforced bound on the two request bodies that carry an
`ids` list: batchGetIssues against issueops.MaxGetManyIDs, and
deleteIssues against maxDeleteIDs. Each body is reached through its
operation's own requestBody $ref. Setting either constant to 999 turns
only this test red. The spec's other list caps (batch
create/close/apply items, dependency edge lists) stay ungated, as
before.
- cmd/bd/serve.go: the batchGetter field comment said its accessor
"does NOT recurse through the hook decorator". HookFiringStore.
BatchGetter does recurse to the inner getter; it just doesn't wrap
the result. The comment now says that.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
bd delete's single-id path resolves the row with
resolveAndGetIssueForMutation BEFORE calling deleter.Delete() and the
per-id lock fence #7244 added. On a real Dolt sql-server, a same-token
--if-revision racer that loses that fence can find the row already
gone at that pre-flight check, which returned an unclassified exit 1
("issue %s not found") instead of routing through
classifyIfRevisionFailure/reportIfRevisionFailure like every other
--if-revision loser. This is why TestSharedServerDeleteIfRevisionSingleWinner/same_token
is flaky.
classifyIfRevisionFailure already had a storage.ErrNotFound branch
anticipating exactly this gap (mc-zndi7.73); delete.go's pre-flight
check just needed to call it when --if-revision is set, reporting
precondition_failed / ExitGuardMismatch (13) instead of a bare
"not found".
Checked the proxied delete path (delete_proxied_server.go): it has no
separate pre-flight check and already routes deleter.Delete()'s error
through reportIfRevisionFailure, so no gap there.
Adds:
- TestClassifyIfRevisionFailureNotFoundSentinel: unit test pinning
classifyIfRevisionFailure/reportIfRevisionFailure's handling of the
bare storage.ErrNotFound sentinel.
- TestIfRevisionDeletePreflightGoneIsPreconditionFailed: embedded CLI
test that deterministically reproduces the same pre-flight code path
a losing racer hits (delete the row out from under a stale
--if-revision token), without depending on actual concurrency.
Fixes mc-zndi7.81.
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
* fix(dolt): serialize guarded deletes against each other (mc-zndi7.73)
On a Dolt sql-server, two concurrent `bd delete --if-revision R --force`
requests for the same row were both landing: Dolt's commit-time merge
treats two concurrent transactions that each delete the same row as
identical diffs and lands both with no conflict, so every same-token
racer exited 0 instead of exactly one. A delete racing an update/close
already produced a real write conflict (the racing write's row_lock
bump is a genuine edit Dolt's merge must reconcile against the delete),
but deleter.go used withWriteTx (no retry), so the loser surfaced a raw
Dolt Error 1213 instead of being retried and reclassified as a version
mismatch.
Fix: a per-id delete fence (GET_LOCK/RELEASE_LOCK, Dolt/MySQL built-in
session primitives) serializes guarded deletes on a real Dolt
sql-server, so a same-token loser's existence probe now runs only after
the winner's delete has already committed and finds the row gone,
failing through the ordinary NotFoundError path. The fence pins ONE
*sql.Conn for GET_LOCK, the retried write, and RELEASE_LOCK, because
setupTestStore's tests (and any store configured with a pool of one)
run with MaxOpenConns=1, and a two-connection design would deadlock
under it. withRetryTx/commitWriteTx are generalized (withRetryTxOn/
commitWriteTxOn) to run their shared retry-and-commit body against
either the pool or this one pinned connection. deleter.go also now
uses withRetryTx instead of the non-retrying withWriteTx, so a delete
racing an update/close is retried like every other guarded write.
classifyIfRevisionFailure (cmd/bd/if_revision.go) gains a
storage.ErrNotFound case, mapping the row-vanished-from-under-the-guard
outcome to precondition_failed/ExitGuardMismatch on both the proxied
routes (which have no pre-write existence check) and this same-token
delete race.
No schema or migration change: GET_LOCK/RELEASE_LOCK are built-in
Dolt/MySQL session primitives, the same idiom
schema.MigrateUpWithLock already uses for migrations, reimplemented
standalone in internal/storage/dolt/delete_fence.go to avoid borrowing
the schema package's migration-flavored timeout and error sentinels.
Adds real concurrency race tests in the style of #7233's
shared_server_if_revision_concurrency_test.go: same-token deletes,
delete vs close, delete vs update, on both the shared-server and
proxied routes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(uow): serialize guarded deletes against each other on the proxied route (mc-zndi7.73)
internal/storage/dolt's new per-id delete fence only covers the
shared-server/direct-CLI route. The proxied-server (and bd serve)
route goes through internal/storage/uow instead, a completely
separate deleter implementation that shares no code with the dolt
package, so it had the exact same bug: two concurrent guarded deletes
of the same row both landed, because Dolt's commit-time merge treats
two identical "row absent" diffs as non-conflicting.
Fix: a twin fence (internal/storage/uow/delete_fence.go) applied
around the write whenever req.ExpectedVersion is set. Unlike the
dolt-package fence, this one uses two independent connections (one for
GET_LOCK/RELEASE_LOCK, one drawn normally by the retried write) rather
than pinning a single connection: no cmd/bd call site ever constrains
this package's pool to one connection, so a dedicated lock connection
cannot starve the write. The fence unwraps d.provider via the existing
uow.UnwrapProvider helper first, because the real proxied chain always
wraps the bare *doltSQLProvider in a notifyingProvider and then an
externaldeps uowProvider before handing it to NewDeleter.
No code changes were needed in cmd/bd/if_revision.go: a losing
racer's existence probe already returns the same NotFoundError/
storage.ErrNotFound classifyIfRevisionFailure already maps to
precondition_failed for the shared-server race.
Also fixes internal/storage/dolt/version_scope_completeness_test.go's
TestTxMintingWrappersScopeVersionedHistory, broken by the prior
mc-zndi7.73 commit's withRetryTxOn/commitWriteTxOn split: the BeginTx
call (and the versioned-history scope call beside it) moved from
commitWriteTx's own body down into commitWriteTxOn, so the guard's
hardcoded txMintingWrappers list needed to name the new function that
actually mints the transaction.
No schema or migration change: GET_LOCK/RELEASE_LOCK are the same
built-in Dolt/MySQL session primitives the dolt-package fence uses.
Agent-Signature: claude-code-claude-sonnet-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* chore(bazel): sync BUILD files for mc-zndi7.73's new delete-fence sources
make bazel-sync, picking up internal/storage/dolt/delete_fence.go and
the two cmd/bd race-test files added by the prior commit (missed
there) plus this commit's new internal/storage/uow/delete_fence.go.
Agent-Signature: claude-code-claude-sonnet-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
TestProxiedServerOutageReconnectAcceptanceMatrix/external-tcp flaked in the
Bazel proxied-server tier with "Condition never satisfied: bd reconnect after
upstream restart" (5 CI failures, every one external-tcp, never the unix
case).
The restore step SIGKILLed the old socat front and immediately started a
replacement on the same TCP port. Kill only queues the signal: on a loaded
host the old socat can still hold the listener when the replacement calls
bind, so the replacement exits with EADDRINUSE. Its stderr went nowhere and
the "remained alive" check passed on the unreaped pid, so the endpoint
refused every connection and each bd attempt correctly failed with the
proxy's upstream-unreachable report until the 10s window ran out. The unix
case removes and rebinds a fresh socket path, so it cannot hit this.
The bridge is now a small type that tracks socat's exit: stop() kills and
waits for exit (the listener is released by then), and startOutageBridge
waits for socat's own "listening on" notice (-d -d), retrying a socat that
exits before listening. The reconnect loop reports the last bd error and the
bridge log on failure instead of a bare "condition never satisfied".
Product behaviour is unchanged: the proxy reports a refused upstream and
reconnects as soon as the endpoint is back.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(httpapi): wire-shape signal — wire_revision, floor header, golden digest, param tokens
S0 of the HTTP role-parity program: give a client a single place to learn
whether this build's wire shape has moved under it, and give CI a gate that
catches an undocumented move.
- GET /v0/beads/context reports wire_revision (bumps only on a non-additive
response-shape change) and min_client_wire_revision. An optional
Bd-Wire-Revision request header lets a client declare the revision it was
built for; checkWireRevision refuses a declared revision below the floor
with 400 invalid_argument/reason=wire_revision_unsupported and a
min_wire_revision field, on every route but /healthz (wireRevisionExempt) —
including the identity handshake, where catching the mismatch is cheapest.
Absent header is today's behavior; malformed value is invalid_value, never
wire_revision_unsupported. The floor lives in Server.minClientWireRevision
(defaulting to the MinClientWireRevision constant) so a test can raise it.
- internal/httpapi/wireshape: a golden digest over every response's every
content-type schema (including application/problem+json) across the whole
spec, keyed by schema+member. TestWireShapeDigest fails closed when a
member's JSON name or type changes without wire_revision bumping to match;
regenerate with `go run ./internal/httpapi/wireshape/cmd/gendigest`.
- GET /v0/beads/issues' `sort` parameter now carries the issues.listSort
capability token, the same convention `capabilities` entries use.
TestNewParameterOnExistingOperationHasABehaviorToken requires every new
parameter on an existing operation to carry one, checked against a
write-once grandfather baseline (testdata/pretoken_parameters.json) of
parameters that predate the rule; TestUntokenedParameterRuleFires proves
the checker itself against a synthetic fixture.
- Docs: engdocs/design/bd-serve-v0.md gets a "The wire-shape signal" section;
CHANGELOG.md gets an Added entry.
Live-mutated and reverted three RED demonstrations during development:
retyping api_version in the spec failed TestWireShapeDigest; short-circuiting
checkWireRevision's floor comparison failed
TestWireRevisionBelowFloorRefusesEveryEnforcedRoute; adding an untokened
query parameter to listIssues failed
TestNewParameterOnExistingOperationHasABehaviorToken. All three now pass
against the unmutated tree.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(httpapi): rename issues.listSort to issues.list.sort, harden token rule
Opus review of 12c5144ca (HIGH-1, MEDIUM-5):
- Rename the capability token issues.listSort -> issues.list.sort to match
bd-enterprise's client (httpstore/wire/handshake.go:121, DESIGN.txt S4e),
and widen capabilityToken to accept an optional third segment.
- untokenedParameters() now requires the extracted token to be one
Capabilities() actually serves, not just backtick-shaped text. This
catches real false positives that existed in the spec already
(workapi.DefaultReadyLimit, status.custom) which only shape-matched the
old regex; they're added to the pretoken baseline as genuinely
pre-existing untokened parameters.
- Extend the rule to request body members (new
testdata/pretoken_request_body_members.json baseline) and exempt
brand-new operations via a frozen testdata/pretoken_operations.json
snapshot.
- Add TestPretokenBaselinesNeverGrow pinning all three baseline sizes so
a future change can't hand-add an exemption instead of a token.
- Update spec prose for the widened rule scope.
go test ./internal/httpapi/... and the reviewer's pmut.py all pass as
expected: plain/bogus modes go RED, reuse (real-but-unrelated token) stays
green, matching the review's literal ask ("a token must be one advertised
by Capabilities()").
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(wireshape): close four digest-coverage gaps, add gendigest write guard
Opus review of 12c5144ca (HIGH-2, MEDIUM-4). The digest only tracked
Type/Format/Enum/Required on direct properties, missing:
- nullable: true (never read at all)
- array item shape (Issue.labels items string->integer was invisible;
only object-shaped items got recursed into)
- additionalProperties value shape (IssueCount.groups)
- request bodies entirely (Compute() only walked responses, so
DeleteIssuesRequest.expected_version string->integer, the other half
of #6053, was invisible)
Also added defensive oneOf flattening alongside the existing allOf merge
(dormant today -- grep confirms this spec uses oneOf nowhere -- but no
longer silently invisible if that changes).
Extracted the golden-vs-computed comparison into wireshape.Compare(),
shared by TestWireShapeDigest and the new wireshape.SafeToWrite(), which
gendigest now calls before writing: it refuses to overwrite golden.json
with changed/removed entries unless the candidate's wire_revision is
strictly greater than the existing golden's. Pure additions always write.
TestSafeToWrite exercises both guard directions.
golden.json is regenerated. This single regen is a one-time exception to
the new guard, done by writing the digest directly rather than through
gendigest: confirmed via a throwaway diff (not checked in) that every one
of the 57 "changed" entries differs only in the NEW fields the wider walk
now populates (ItemType/ItemFormat/Nullable/AdditionalProps*) -- every
pre-existing Type/Format/Required/Enum value is byte-identical. Nothing on
the wire changed; the measurement got more precise. Bumping
CurrentWireRevision for this would have written a false "the protocol
changed here" entry into the revision history table. Going forward, any
REAL change the guard now reports uses the normal bump-then-regenerate
path, same as before.
Verified against the reviewer's mut.py: nested_type, nullable,
nullable_issue, array_items, addlprops, request_body and format all go RED
on TestWireShapeDigest, each reverted after confirming.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(httpapi): make bd_version wire_revision inference advisory
Opus review of 12c5144ca (HIGH-3). The spec told a client inferring
wire_revision from bd_version to use the release cutoff >= 1.3.0, and said
nothing about what happens when that inference is wrong -- which it
demonstrably is for real builds already in the field:
- main builds up to commit b3ef65c85 report bd_version 1.2.2 (below any
1.3.0 cutoff) while already sending the string-typed revision/
expected_version shape (#6053).
- 1.3.0-rc.N pre-release builds sort BELOW the release cutoff 1.3.0 under
plain string comparison despite already carrying the string shape.
- The bd-enterprise compatibility line at d3ab32773462 reports bd_version
1.1.0 while also sending strings.
Moved the cutoff to >= 1.3.0-rc.1 (compared as semver-with-prerelease,
which at least captures the rc builds), documented both named exceptions
inline, and made the whole inference explicitly ADVISORY: a client must
accept revision/expected_version as either a string or a number whenever
wire_revision is absent (or probe directly) rather than let the inferred
value choose a decoder, and must never refuse solely because the inferred
revision is 0. Mirrored into engdocs/design/bd-serve-v0.md.
This is spec/doc prose only -- there is no server-side inference code to
change, since this server always sends wire_revision directly; the
inference is guidance for clients reading a pre-signal server's response
(this server, past builds, or an unrelated implementation).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(httpapi): LOW-7/8/9/10 review follow-ups for wire-revision signal
LOW-7: WireRevisionUnsupported now also sets Problem.wire_revision (this
server's CurrentWireRevision) and Problem.bd_version on the
wire_revision_unsupported refusal, alongside the existing
min_wire_revision, so a client logging the refusal has this server's
full self-description without a second /v0/beads/context call.
LOW-8: gazelle + make bazel-sync add the BUILD.bazel entries the prior
commits were missing: wire_revision.go/wire_revision_test.go in
internal/httpapi's srcs, new BUILD.bazel files for wireshape and
wireshape/cmd/gendigest, and a testdata glob on httpapi's go_test so
the pretoken_*.json baselines are visible under `bazel test`. Verified
with `bazel build //internal/httpapi/...` and
`bazel test //internal/httpapi/... --test_env=BEADS_TEST_SKIP=dolt`
(both green) and `python3 tools/bazel/go_srcs.py --check` (clean).
LOW-9: narrowed CHANGELOG.md and engdocs/design/bd-serve-v0.md to
describe the digest's actual final coverage (format/enum/required/
nullable, array items, additionalProperties, request bodies, $ref/
allOf/oneOf recursion, the SafeToWrite revision-bump guard) and the
token rule's actual final shape (three pinned baselines, request-body
members, Capabilities()-membership validation, new-operation
exemption) instead of the original, narrower claims.
LOW-10: Bd-Wire-Revision now parses via a strict decimal-only
parseStrictNonNegativeInt (no leading '+', no leading zero except a
bare "0") instead of strconv.Atoi alone, so two different header
bytes can no longer name the same revision. New malformed-header test
cases: "+1", "01", "007".
Regenerated apigen/types.gen.go (make api-gen) for the new Problem
fields and wireshape/testdata/golden.json (go run
.../wireshape/cmd/gendigest) for the two new additive Problem members;
the latter wrote cleanly through SafeToWrite itself, since both are
pure additions.
go test ./... and bazel test //internal/httpapi/... both green.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(httpapi): re-review LOW follow-ups — retirement test, gendigest -init, docs
1. TestRetiredRevisionsStayBelowTheFloor pins the PRESENCE guarantee the
wire_revision property doc relies on: CurrentWireRevision >= 2 (so 0
and 1 stay permanently retired) and MinClientWireRevision <=
CurrentWireRevision (so this build's own floor never refuses every
request against itself).
2. gendigest now refuses to create a golden.json that does not exist yet
unless run with -init. Previously a missing file (moved testdata,
wrong path, accidental delete) was indistinguishable from a real first
run and silently wrote a fresh golden with no revision history checked
against anything. writeGolden() is extracted out of main() so this is
covered directly: TestWriteGoldenRequiresInitWhenMissing,
TestWriteGoldenInitCreatesWhenMissing,
TestWriteGoldenIgnoresInitWhenGoldenExists (the existing-golden path is
still governed only by SafeToWrite, -init or not).
3. Narrowed the two remaining stale claims that still described the
digest's original, narrower coverage: the wire_revision property's
prose in openapi.v0.yaml (regenerated into apigen/types.gen.go via
make api-gen) and wireshape/doc.go now both list nullable, array item
shape, additionalProperties value shape, request bodies, and
$ref/allOf/oneOf recursion, plus the new -init guard.
go test ./internal/httpapi/... and make api-check both green;
bazel test //internal/httpapi/... (httpapi, wireshape, and the new
gendigest test target) green; python3 tools/bazel/go_srcs.py --check
clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* feat(wireshape): cover operation parameters in the wire-shape digest
The digest previously walked only response and request-body schemas, so a
type, enum, required, or removal change on one of the spec's 138 operation
parameters (123 query, 14 path, 1 header) passed the gate silently — the
open item from PR review on #7182.
Each parameter is now recorded as its own Entry, keyed by
"param:"+operationId / location+":"+name (operation-scoped, not
schema-scoped, since two operations' same-named parameter are independent
wire contracts), capturing type, array item shape, enum, required, style,
explode and default. Adding a parameter stays additive; removing,
retyping, narrowing its enum, or changing required/style/explode/default
now trips SafeToWrite exactly like a response or request-body change.
Verified against the live spec: retyping listIssues' `limit` query
parameter from integer to string now fails TestWireShapeDigest (confirmed
red, then reverted — not part of this commit). golden.json regenerated via
gendigest; the new parameter entries are a pure addition, no wire_revision
bump needed. Added TestParameterMutationsAreCaught (remove/retype/narrow-
enum against real golden entries) and updated wireshape's doc.go, the
`wire_revision` spec prose, and the CHANGELOG to describe the new
coverage.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(wireshape): review fixes — stale-golden and lowered-revision arms, effective param serialization, digest boundary
Maintainer fixup from the adopt-pr review loop (iterations 1 and 2), on
top of e17ba924f.
- goldenDrift (A, I): TestWireShapeDigest's comparison moves into a
goldenDrift helper. An addition alongside a moved wire_revision no
longer passes with a stale golden: it asks for a regenerate, as a
changed or removed entry after a bump already did. Every message now
names response/request-body members AND parameters, and TestGoldenDrift
pins each arm. This takes only the test half of the stranded fixup
(adopt-pr/bd-47kdge/stranded-fixup-528cd6095); its doc half, which says
parameters are outside the digest, is false since e17ba924f and is not
replayed (J).
- Lowered wire_revision (D): a CurrentWireRevision LOWER than the
golden's is a wrong constant, not a stale golden, so goldenDrift says to
restore it instead of regenerating, and SafeToWrite (so gendigest)
refuses any write at a lower revision, whatever the entries.
- Effective style/explode (B): walkParam records style and explode with
OpenAPI 3.0's defaults filled in (form for query/cookie, simple for
path/header; explode defaults to style == form). Adding `explode: false`
to a query array that relied on form's implicit explode is now a
changed entry, while spelling out a default changes nothing.
testdata/golden.json is regenerated with -init: 111 parameter entries
change only in style/explode (96 to form/true, 15 to simple), 828
entries before and after, wire_revision stays 2. The golden is new in
this PR and unreleased, so this needs no bump.
- TestWalkParam (H): a package-internal table test
(wireshape_internal_test.go) pins every field walkParam extracts,
through a computeFrom(document, revision) seam that Compute now wraps:
per-location defaults, $ref'd parameters and items, format, nullable and
default, content parameters, and the nil returns.
TestEffectiveSerializationIsCompared pins B end to end through Compare
and SafeToWrite. BUILD.bazel embeds the library in the go_test, which is
gazelle's own output.
- Required inputs and the digest boundary (C, E, F; docs only): all five
prose surfaces (openapi.v0.yaml's wire_revision description and the
regenerated apigen/types.gen.go, wireshape/doc.go, CHANGELOG.md,
engdocs/design/bd-serve-v0.md) now say that a new REQUIRED request
input is recorded as an ordinary addition and needs its own review,
that value constraints and member-level composition are outside the
digest, and that object and content parameters are recorded only as
their container. bd-serve-v0.md also gains the parameter coverage it
was missing.
- G: a brand-new operation is permanently exempt from the
capability-token rule; its own review decides its capability story.
- Iteration 2 (nit): walkParam's comment now says that the location
default it records as a `content` parameter's style and explode is a
placeholder, since OpenAPI 3.0 applies style and explode only to a
parameter described by `schema`. All 138 operation parameters in the
spec use `schema`, so the golden does not change.
Validated: go test ./internal/httpapi/... (gms_pure_go), make api-check,
go vet for linux/windows/darwin, gofmt, git diff --check, gazelle on the
package (no drift), make bazel-sync-check, and bazel test
//internal/httpapi/wireshape/... in the local processwrapper sandbox
(2 of 2 pass). Overlay mutation probes: dropping the added-after-bump
arm, the lowered-revision arm, SafeToWrite's lowered check, or the
effective-default fill each turns the new tests red.
Iteration 2 changes only that comment; go test
./internal/httpapi/wireshape/... (gms_pure_go), go vet, gofmt and git
diff --check pass again.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(count): add Counter scope fields (S8) — ParentID, NoParent, ExcludeTypes, ExcludeStatus
Extends issueops.CountRequest with ParentID, NoParent, ExcludeTypes and
ExcludeStatus, closing the gap where bd count could not express the
filters bd list already has, forcing downstream consumers like gc to
fall back to listing everything just to get a count.
- issueops.Counter: four new CountRequest fields, documented against the
List equivalents they mirror (ParentID/ExcludeTypes) or newly define
(NoParent, ExcludeStatus has no List counterpart). Status "all" is
pinned as equivalent to unset, matching BuildListFilter's own "all" and
preserving count/list cardinality parity (the role's reason to exist).
- internal/workapi.BuildCountFilter: maps the four fields onto the one
types.IssueFilter builder all three storage legs (dolt, embeddeddolt,
uow) already share via internal/storage/issueops and sqlbuild, so no
per-leg storage code was needed.
- cmd/bd: --parent, --no-parent, --exclude-type, --exclude-status flags.
- HTTP: adds parent/no_parent/exclude_type/exclude_status to GET
/v0/beads/issues:count, behind the new issues.count.scope behavior
token (routes.go), wired in reads.go's countFilters, documented in
openapi.v0.yaml with per-parameter tokens and an extended capabilities
description. gendigest confirms a byte-identical golden.json: query
parameters are outside the wire-shape digest's scope, so this is a
zero-diff, no-revision-bump change as expected.
- backend/conformance: four new Counter contract cases (ParentID scoping,
NoParent's edge-only semantics vs ParentID's edge-or-dotted-id match,
ExcludeTypes composing with include_infra's own exclusions, and
ExcludeStatus), run identically against all three storage legs via a
new CounterFixture.AddDependency hook shared with ReaderFixture.
Verified: go build ./...; go test ./internal/httpapi/... ./internal/workapi/...
./issueops/... and the Counter contract on all three legs (dolt via
testcontainers, embeddeddolt, uow via local dolt binary); make api-gen
(additive-only apigen diff) and make api-check; go vet and golangci-lint
clean; gofmt clean; gazelle diff empty (no new files/imports). Mutation
testing: dropping issues.count.scope from behaviorCapabilities turns
TestCapabilitiesAdvertiseEveryImplementedOperation,
TestSpecCapabilityVocabularyMatchesTheRouteTable and
TestNewParameterOnExistingOperationHasABehaviorToken red; no-op'ing
ExcludeStatus in BuildCountFilter turns
TestBuildCountFilterExcludeStatusTakesNamesAsWritten and the
embeddeddolt ExcludeStatusNarrowsThePredicate conformance case red. Both
reverted and reconfirmed green.
Deviation: DESIGN.txt's literal text would make count --status all an
ErrValidation; shipped behind a test and a doc comment instead, since
"all" already means "every status" on both count and list and rejecting
it would break the count/list parity this role exists to guarantee.
S3/S4 note: no OSS HTTP client exists yet to enforce capability-token
skew. A doc comment on CapIssuesCountScope in routes.go specifies the
required behavior once one lands: check issues.count.scope against the
cached handshake capabilities and refuse locally with a typed
ErrUnsupported{Capability} before sending any of the four new params to
an older server.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(count): S8 review follow-ups — refusal parity, exclude-status validation, doc fixes, parity tests
Addresses the Opus review's six required changes for S8 (bd count scope
fields):
1. BuildCountFilter now refuses ParentID+NoParent together as ErrValidation,
matching bd list's CLI refusal wording; wired through the role, the CLI,
and invalid_argument classification in internal/httpapi/reads.go.
2. Status:"all" is documented in DESIGN.txt as every status, matching List's
no-filter reading (count/list cardinality parity) — a coordinator decision
recorded in beads-design/DESIGN.txt, outside this worktree.
3. ExcludeStatus names are now validated against the workspace vocabulary
(built-in statuses plus workspace-custom ones); an unknown name is
ErrValidation instead of a silent no-op, since a typo here would overcount.
4. Fixed openapi.v0.yaml and issueops/reader.go doc claims about bd list
--parent's default tree-walk vs. the one-level role answer that bd count
--parent agrees with (confirmed by tracing list_show_filter_modes.go); fixed
an Oxford-comma nit in routes.go and the spec.
5. Added storage-level count == len(List) parity tests for ParentID, NoParent
and ExcludeTypes (List has no ExcludeStatus counterpart), plus wisp-child
and closed-child contract cases, across all three backends (dolt,
embeddeddolt, uow). CounterFixture gained a List hook for this.
6. Extended the routes.go skew note: gc's ErrCountUnsupported fallback to List
is now named explicitly, with a note that S3/S4 must add a skew test that
masks the token and asserts the fallback fires.
Also fixed RunCounterExcludeStatusNarrowsThePredicate's now-stale "unrecognized
status excludes nothing" assertion to expect ErrValidation instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(count): PR #7199 review follow-ups — exclude-status config load, ParentID doc swap
Addresses bee's REQUEST-CHANGES on gastownhall/beads#7199 (S8):
1. BLOCKER: storecounter.filter and uow.countFilter only loaded the
workspace list config when IncludeInfra was set, so BuildCountFilter's
ExcludeStatus validation refused a workspace's own custom status unless
the caller also passed the unrelated IncludeInfra flag. Both legs now
load the config when IncludeInfra OR len(ExcludeStatus) > 0, with
comments corrected to say so. Added leg-level regression tests (the
conformance fixture cannot drive a workspace-configured custom status)
on embeddeddolt and uow, reproducing the reviewer's CLI repro directly,
plus an HTTP-level probe in cmd/bd's real-Dolt proxied count test.
2. issueops.ReadyRequest.ParentID's comment had been overwritten with the
one-level direct-children wording that belongs to ListRequest.ParentID;
Ready actually walks all descendants via GetDescendantIDsInTx (GH#3396).
Restored the descendants comment on ReadyRequest.ParentID and moved the
one-level explanation to ListRequest.ParentID, which had none.
Verified: make api-check; dolt-server, embeddeddolt and uow Counter
contract legs (BEADS_TEST_DOLT_SERVER=local with a pinned dolt binary for
uow; Docker for the dolt-server leg); the new proxied HTTP exclude_status
probe (BEADS_TEST_PROXIED_SERVER=1).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* chore(wireshape): add the countIssues scope parameters to the wire-shape golden
#7182 now digests operation parameters. The four new issues:count parameters
(parent, no_parent, exclude_type, exclude_status) are additive entries, so no
wire_revision bump is needed; regenerated with gendigest.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(conformance): register the S8 count-scope cases with RunRoleContracts (adopt-pr #7199)
The PR adds nine RunCounter* contract cases to counter_contract.go and wires
them into the three in-tree TestCounterContract legs, but not into the
Counter row of roleContractCases. TestRoleContractCasesCoverEveryContractCase
derives the expected set from source, so it fails on the PR head, and an
external backend running RunRoleContracts would never see the new cases.
Register them in source-declaration order (after
RunCounterAnUnknownStatusMatchesNothing), which the same guard enforces.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(count): correct the S8 scope docs the review found wrong (adopt-pr #7199)
Comment and spec-description fixes only; no behavior change. Review-loop
iterations 1 and 2 of the #7199 relaunch.
- ListRequest.ParentID (issueops/reader.go) said "DIRECT children only
... the same one-level clause". The sqlbuild clause has two arms and
neither walks: the parent-child edge arm stops at one level, but the
dotted-prefix arm (`id LIKE CONCAT(?, '.%')` for rows with no
parent-child edge) reaches every edge-less dotted id at any depth, which
RunReaderListParentReachesEveryDescendantAndOnlyItsOwn pins with an
edge-less X.1.1. State both arms, and say the CLI tree view re-runs the
clause against the store once per level (findAllDescendants calls
SearchIssues, not the role). Document ListRequest.NoParent, which had no
doc. The contributor's ReadyRequest.ParentID text is kept; only its
cross-reference to this field changes from "one-level" to "non-walking".
- CountRequest.NoParent (issueops/counter.go) and the count flag comment
(cmd/bd/count.go) said NoParent counts rows with "neither" an edge nor a
dotted prefix. Its SQL checks only the edge table, so an edge-less X.1
is counted by both --parent X and --no-parent, as bd list lists it.
- RunCounterExcludeStatusNarrowsThePredicate's header said an
unrecognized name "excludes nothing rather than failing" while its body
asserts ErrValidation. The header now matches the body.
- The OpCountIssues entry in problem.go's operationCodes said the role has
"exactly one reachable refusal". It has three: an invalid metadata key,
an unrecognized exclude_status name, and parent with no_parent (named
no_parent), all classified by invalidFilterParam. The code set is
unchanged.
- BuildCountFilter's header said cfg is "only read under IncludeInfra".
It is also read to validate ExcludeStatus against the workspace's
custom statuses, which is why both callers load it when ExcludeStatus is
non-empty.
- The countIssues `parent` description in openapi.v0.yaml carried the
same one-level claim as ListRequest.ParentID; it now states both arms.
types.gen.go is regenerated (make api-gen); make api-check passes.
Review fixes (iteration 2), still comment and spec text only:
- The iteration-1 problem.go rewrite called all three count refusals
ErrValidation. Only the exclude_status and parent-with-no_parent
refusals wrap issueops.ErrValidation (internal/workapi/count.go). The
metadata-key refusal is ValidateMetadataFilters' plain fmt.Errorf
chain, so errors.Is(err, ErrValidation) is false for it; it reaches the
wire as a 400 only because invalidFilterParam matches message prefixes.
The comment now says that, so a later move to typed errors cannot trust
it and demote the metadata-key refusal to a 500. The sentinel itself is
not added here: ValidateMetadataFilters is shared with the list and
ready builders.
- invalidFilterParam's comment on the count rows pointed at the
metadata-key rows as "above"; they come after it in the switch.
- The countIssues `parent` description said the CLI tree mode walks
"every edge-linked descendant". findAllDescendants re-runs the full
two-arm predicate per level, so it also descends through edge-less
dotted ids; it now says "every descendant reachable through either
arm". types.gen.go is regenerated; make api-check passes.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(wireshape): re-record the count scope params under the base's param digest (adopt-pr #7199)
The base branch (feat/wire-revision-signal, #7182be1f0bad72) now digests
the effective style/explode of scalar query parameters. This PR's golden
entries for countIssues query:parent and query:no_parent were written by
the old algorithm, so after the base refresh TestWireShapeDigest reported
them as "changed without a wire_revision bump".
No bump is owed: all four count-scope entries (parent, no_parent,
exclude_type, exclude_status) are additions this PR introduces and are
absent from the base golden. golden.json was reset to the base copy and
regenerated with `go run ./internal/httpapi/wireshape/cmd/gendigest`. The
result is four pure additions against the base (+35/-0); parent and
no_parent gain "style": "form" and "explode": true, and wire_revision
stays 2.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ci: place the PR's new embedded counter test in the shard manifest
TestCounterExcludeStatusAcceptsAWorkspaceCustomStatusWithoutIncludeInfra,
added to internal/storage/embeddeddolt in f23bf5ddbf, is a new top-level
embedded storage test. The 15-shard block of
.github/scripts/embedded-storage-test-shards.txt must list every
discovered test exactly once. Without the entry,
TestStorageEmbeddedShardManifestGeneratorNotStale (scripts/) fails, both
on the reviewed head 89a387de6c and on the merge. CI never ran the check
on this PR: pr.yml runs only for PRs based on main, release/** or
hotfix/**, and this PR was based on feat/wire-revision-signal until the
retarget.
Generated with
`python3 scripts/ci/gen_embedded_storage_shard_manifest.py 15 --weights=duration --write`.
The incremental write adds this one line, in shard 4, and moves no other
test.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.local>
* test(cli): close mc-zndi7.76's --if-revision single-winner test gaps
T4.4 exercised the Update guard against the library only; embedded CLI
tests never catch a CLI wiring bypass because bd's local exclusive
flock serializes every mutation regardless of whether --if-revision is
actually threaded through. This closes the remaining mc-zndi7.76 gaps:
- gap 1 (mutant MA): new Lifecycle contract cases
(RunLifecycleUpdateExpectedVersionSingleWinnerWithDisjointColumnsUnderConcurrency,
RunLifecycleCloseExpectedVersionSingleWinnerUnderConcurrency,
RunLifecycleUpdateExpectedVersionSingleWinnerAcrossUpdateAndCloseUnderConcurrency),
wired into all three backends (dolt, embeddeddolt, uow).
- gap 2 (mutant MC): a new dolt-server-tier CLI concurrency test,
TestSharedServerIfRevisionSingleWinner, spawning N real bd
subprocesses that race update/close/assign --if-revision against one
shared, unlocked Dolt server. Delete is deliberately excluded --
its production guard is independently known-broken under real
concurrency and is tracked as its own schema-touching fix,
mc-zndi7.73.
- gap 4 (mutants ML/MO/MD1/MD2): close's --if-revision bypass now has
CLI-level coverage for --continue/--suggest-next/--claim-next
rejection, cascade-delete fencing, and a proxied-route stale-guard
refusal.
TDD: hand-applying mutant MC (dropping update.go's ExpectedVersion
wiring) reproduces the bug report's symptom exactly -- 10/10
concurrent racers exit 0 instead of 1 winner + 9 guard refusals.
Restoring the real code returns to exactly 1 winner, confirmed across
4 repeated real-container runs plus -race.
Gates: gofmt, go vet, go build (both tags), golangci-lint (native,
0 issues), bazel go_srcs.py --check, and targeted go test runs
(embeddeddolt/dolt/uow lifecycle contract suites and the full set of
cmd/bd if-revision tests) all green, with and without -race, against a
real dolthub/dolt-sql-server:2.2.0 container.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* build(bazel): sync cmd/bd BUILD.bazel srcs for the new if-revision test files
make bazel-sync-check only validates the go_srcs.py-managed filegroups,
not gazelle's own go_test srcs list, so the two new test files from the
previous commit were invisible to Bazel. CI's BUILD-sync and go-test
equivalence gates caught it; this is gazelle's own generated diff,
applied via the CI job's uploaded bazel-sync-patch artifact.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Makes the repo's agent and contributor surface describe developing beads, not using bd, and requires every PR to link a documented issue.
- Contributor-only root AGENTS.md with a routing table; cmd/bd/AGENTS.md and engdocs/AGENTS.md seam files; CLAUDE.md symlinks so Claude Code loads nested files.
- Bug and feature issue forms, a PR template that requires Closes #, CONTRIBUTING sections for the triage and pipeline labels, and the opt-in fork-cache during dev setup.
- ROADMAP.md for 1.4: versioned beads (#6132), Graph Preview 2 (#7170), contributor onboarding (#7228).
- docsync guards: root AGENTS.md at or under 20 KB; every AGENTS.md symlinked, routed, and with resolving links, paths, and guard-test names.
Agent-Signature: claude-code-claude-opus-5-5-high on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(gate): ordinary commands wait out maintenance, with writer fairness
Ordinary bd commands take the workspace (and physical-root) gate SHARED and
never waited for it, so while another process held it EXCLUSIVELY — bd init
(~8s), backup restore, migrate, bootstrap — they failed at once with "a
maintenance operation is running". In shared-server mode every project
shares one physical-root gate, so another project's bd init broke every bd
command on the machine for its duration.
Ordinary commands now wait:
- up to 15s by default; BEADS_GATE_WAIT_TIMEOUT (Go duration or bare
seconds, same convention as BEADS_INIT_GATE_TIMEOUT) overrides it, and 0
restores fail-fast;
- one "waiting for another bd process ..." notice after 2s (shared with bd
init's notice);
- Ctrl-C aborts the wait. A canceled wait used to fall through to the
shared fail-open path ("continuing ungated"); it is now a hard error;
- past the bound, the same error naming the holder, the wait, and the knob.
Git hooks stay fail-fast: `bd hooks run` and the bd export/import children
the hooks spawn run with BD_GIT_HOOK=1, treat failure as a warning, and must
not stall a commit or checkout for 15s.
Writer fairness (internal/workspacegate). flock/LockFileEx give no queueing,
and acquisition is non-blocking polling, so a steady stream of overlapping
shared holders could keep a waiting exclusive acquirer (bd init) out past
its bound. A per-gate intent lock (<gate>.intent) fixes that: a waiting
exclusive acquirer whose first try is busy takes the intent lock
exclusively while it polls, and waiting shared acquirers probe it before
every attempt and wait while it is held. The exclusive waiter then waits
only for in-flight holders to drain. The intent is an OS lock, so a crashed
waiter's intent dies with it; its advisory sidecar is ignored when the lock
is free, and intent-lock errors other than "busy" degrade to the old
behavior. Fail-fast acquisitions (Wait <= 0) ignore the queue entirely, so
hooks and BEADS_GATE_WAIT_TIMEOUT=0 behave exactly as before. The intent
lock is taken only while acquiring its gate, directly before it in
AcquireAll's sorted order, so it adds no lock-order cycles.
Nested bd (bd orphans running bd close, hooks fired by git that bd runs)
would deadlock against the queue: the child queues behind an exclusive
waiter that is waiting for the child's parent. A bd process holding its
gates shared exports BEADS_GATE_SHARED_HOLDER_PID; a child whose recorded
ancestor is alive skips the queue (it cannot help the waiter anyway).
Tests: workspacegate fairness (a continuous shared stream no longer starves
an exclusive waiter; verified to fail without the queue), intent lifecycle,
stale intent from a SIGKILLed process, cancellation while queued,
InheritedSharedHold. cmd/bd: holder released after ~3s lets a command
through with one notice; past-bound error text; fail-fast modes (0, hooks);
Ctrl-C is not fail-open; a new command queues behind a waiting bd init
while a child of a shared holder does not; env parsing.
TestSharedServerConcurrent runs a late bd init of a new project during the
client workloads, so both directions are exercised against a real server.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(gate): a queued exclusive waiter may delay shared commands, never fail them
Review follow-up (B1). A doomed exclusive waiter — bd init or restore
blocked behind a long-lived shared holder such as `bd list --watch`,
`bd events tail --follow`, an open `bd edit` editor, or a beads.OpenGated
embedder — held the writer-fairness intent lock for its whole budget, so
every NEW ordinary command deferred to it and failed with "queued for
exclusive access" even though nothing held the gate exclusively. Before
the fairness change those commands ran normally.
Two bounds fix it while keeping the fairness win:
- An exclusive waiter drops the intent lock after maxIntentHold (10s)
without getting the gate and keeps polling unqueued. In-flight ordinary
commands drain far faster than that.
- The final attempt of a waiting shared acquisition tries the gate even
while intent is held, so a shared acquisition fails only when the gate
itself is held exclusively.
With the final attempt ignoring intent, AcquireAll's 1ns floor for an
exhausted budget is dead code (a Wait-0 attempt behaves the same), so it is
back to 0. queuedDetail drops an intent sidecar left by a dead process (on
Windows its removal can fail while another process is reading it).
Tests: the doomed-waiter scenario (both bounds; each fails with its bound
removed), intent lock order across a two-gate set in both directions, an
exhausted AcquireAll budget, two exclusive waiters handing off the intent,
and BEADS_GATE_SHARED_HOLDER_PID inherited through a real subprocess.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(gate): 30s shared wait, 60s init wait, accurate errors, hook pinning
Review follow-ups for the shared gate wait (S1-S5 and nits), on top of the
workspacegate fix that keeps a queued exclusive waiter from failing
ordinary commands.
- Ordinary commands wait up to 30s by default (was 15s). Queued
maintenance operations run one after another (two inits fanned out
across shared-server projects hold the gate back to back, 10-15s each
under load) and a waiting command waits for all of them. Documented in
configuration.md and CHANGELOG, including BEADS_GATE_WAIT_TIMEOUT=0 for
scripts that relied on fail-fast.
- bd init waits up to 60s by default (was 30s). Safe only now that a
waiting init stops queueing others after 10s.
- Error text: a shared acquisition now fails only when the gate is held
exclusively, so "running" is accurate; in shared-server mode it says
"the shared server (possibly from another project)", and the detail
still names the holder when known.
- hooks.go: the hookSubprocessEnv / bd import comments listed BD_GIT_HOOK's
consumers without the gate wait, which now reads it to stay fail-fast.
TestHookSubprocessEnvKeepsGateFailFast pins that hook subprocesses carry
it and therefore never wait on the gate.
- bd edit's $EDITOR (which can outlive bd by hours) no longer inherits
BEADS_GATE_SHARED_HOLDER_PID.
- Test hygiene: the cmd/bd test binary never advertises the marker
(in-process command tests run beside tests that spawn bd) and clears any
inherited one in TestMain; the notice-delay test runs in 1s, not 3s.
- TestSharedServerConcurrent's late init keeps a 30s bound so the 60s
default cannot mask a fairness regression.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(cli): guarded close replays molecule auto-close and open-children warning
mc-zndi7.75: runCloseDirectIfRevision/runCloseProxiedIfRevision bypass bd
close's batch architecture entirely (BatchCloseItem carries no per-item
ExpectedVersion), so they also bypassed two state-derived post-close
contracts that the batch route performs for every close:
1. Molecule auto-close (autoCloseCompletedMolecule / its proxied twin
autoCloseProxiedCompletedMolecule). Without replaying it here, a guarded
close of a molecule's last step left the molecule root stranded open
forever.
2. The "warning: closing X with N open child issue(s) still active" line
printed when --force waives the engine's open-children refusal.
Both routes now replay this work after a successful guarded close, exactly
as close.go's batch path and closeProxiedRunPostClose do, on both a real
close and an idempotent re-close (the proxied post-close work runs in its
own unit of work, mirroring autoCloseProxiedCompletedMolecule's existing
batch-route contract).
The third item in mc-zndi7.75 — gating on_close hook firing on Changed — is
deliberately NOT implemented here: hookIssueOperations.Close (embedded) and
recordingIssueUC.CloseIssueChecked (proxied) both fire on_close
unconditionally on success, including an idempotent re-close, by explicit,
independently pinned design in internal/storage/hook_issue_operations_test.go
("close no-op still fires close" — "Do not 'unify' this either") and
internal/storage/uow/notifying_test.go ("a re-close still reports the close"
— "THE BATCH COMPOSITIONS DISAGREE WITH THIS ONE, deliberately"). Only the
batch closers gate on Changed, to stop a replayed teardown batch from
re-running on_close once per item on every pass (ga-2yaqp.1) — a hazard this
single-id guarded close doesn't share. Reusing that gating here would
contradict both pinned invariants rather than fix a bug, so it's documented
in place and left for human review instead of changed unilaterally.
Adds CLI integration tests for both routes: guarded re-close healing a
stranded-open molecule root, and guarded --force close warning on open
children.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* build(bazel): sync cmd/bd BUILD.bazel for the new --if-revision close tests
make bazel-sync (bazel run //:gazelle) after adding
close_if_revision_embedded_test.go and close_if_revision_proxied_test.go.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
* fix(cli): --if-revision outranks the reassign fence; recognize bare ErrVersionMismatch
Fixes two post-merge review findings on #7203 (max review 37acca96db):
mc-zndi7.74: a lost --if-revision race on an assignee edit reported the
bd-98s5c live-claim reassign fence's policy refusal (exit 1, no machine
code) instead of precondition_failed (exit 13), because update.go,
update_proxied_server.go, assign.go and mutate_proxied_server.go each ran
an advisory pre-read fence check against their own earlier issue snapshot
before the properly-ordered guarded write underneath (which already checks
ExpectedVersion before the fence) got a chance to run. Added
ifRevisionAlreadyStale to skip the advisory check when the caller's own
pre-read is already stale against --if-revision, letting the guarded write
report the correct outcome.
mc-zndi7.78: classifyIfRevisionFailure recognized a revision mismatch only
via the typed *issueops.VersionMismatchError (errors.As). bd-enterprise's
HTTP client maps a 409 precondition_failed to the bare
issueops.ErrVersionMismatch sentinel instead, which bypassed the classifier
and surfaced as a generic error. Added an errors.Is fallback that reports
precondition_failed with expected_revision from the --if-revision flag
value and current_revision omitted (gascity tolerates the omission).
New regression tests (embedded + proxied routes) reproduce the .74 race
deterministically: claim an issue as a foreign holder to advance its
revision past a caller's stale --if-revision, then assert the guarded
write reports precondition_failed rather than falling through to the
live-claim refusal naming the holder. Both fail on an unpatched
git-archive copy of origin/main and pass on this branch.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* build(bazel): auto-sync BUILD files
Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/37258672420
(`make bazel-sync`: gazelle, tools/bazel/go_srcs.py, bazel mod tidy).
Only BUILD.bazel, MODULE.bazel and MODULE.bazel.lock are ever pushed; see
scripts/bazel-autofix-push.sh.
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
TestMaybeAutoBackup_WalkErrorArmsIntervalThrottle pinned the walk-error
re-arm in maybeAutoBackup by forcing runBackupExport's old post-sync
GetCurrentCommit call to fail. #7044 (874e2866f) collapsed that into a
single pre-sync CurrentCommit read, so the forced failure point no
longer exists and the test failed deterministically on every run.
Swap the failure point for one that still exists after #7044: the sync
itself succeeds (still proving fail-open — BackupDatabase gets called),
but the destination goes read-only immediately afterward, so
runBackupExport's post-sync saveBackupState (the call that would record
the new watermark) fails and never reaches disk. The only persisted
watermark write left standing is maybeAutoBackup's own walk-error
re-arm, so the test is still mutation-sensitive to removing it
(verified locally: deleting the re-arm reproduces the old failure).
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Record the commit read before BackupToDir as the newest revision guaranteed
to be in the snapshot. A commit landing during sync then remains pending for
the next backup instead of being hidden by an advanced watermark.
Agent-Signature: codex-gpt-5-unknown-reasoning on behalf of Rongjun GENG
TestResetCommandFlagsRestoresEveryFlag read its expected values from the
live flag variables. The root pre-run fills some of those from config
without marking the flag Changed (doltAutoCommit, main.go:1224), so when
an in-process command ran earlier in the binary the baseline for
--dolt-auto-commit was "on", and the reset under test correctly put it
back to "". PR Core (wrapper timing) has failed on that assertion on
every fork PR since #7185.
The test now calls resetCommandFlags before taking its baseline.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Follow-up to #6380 (bd kv list --prefix). Both capability-discovery hops
fall back silently, and both modes re-filter in-process with
kvPairsWithPrefix, so a lost SQL-side fast path printed the same rows and
failed no existing test.
- Extract wireProxiedUOWProvider, the unit-of-work twin of
wireStorageDecorators, so the proxied provider chain that main.go builds
is unit-testable; main.go now calls it. No behavior change.
- TestKVListProxiedPrefixReadSurvivesProviderChain drives
runKVListProxiedServer through that chain (hook runner on and off) over a
prefix-capable stub use case and fails on any GetAllConfig scan;
TestKVListProxiedPrefixAbsentCapabilityFallsBack keeps it honest.
- TestEmbeddedKV/kv_list_prefix_json and
TestProxiedServerKV/list_prefix_json run the real command with sibling
keys (mail.dog.* vs mail.doggerel.*) and an unmatched prefix.
- bdKVListJSON now fails on output with no JSON object instead of returning
an empty map, so a "no pairs" check cannot pass vacuously.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(cli): add --if-revision compare-and-swap guard to update/close/assign/delete
Adds --if-revision <int64> to `bd update`, `bd close`, `bd assign` and
`bd delete`, reusing the existing opaque row_lock token published as
IssueDetails.Revision and the library's own ExpectedVersion compare-and-swap
support. A mismatch writes nothing and exits 13 (ExitGuardMismatch); with
--json the stderr envelope carries integer expected_revision/current_revision
fields deployed callers decode directly, never a quoted string. An
unsupported backend reports conditional_write_unsupported and exits 1
instead of silently dropping the guard. The guard composes with
--if-assignee/--if-status (every guard must hold) and is refused alongside
label or parent edits and alongside more than one id, matching the existing
--if-assignee rules. `bd assign` is newly routed through the checked
Lifecycle path to gain CAS support it previously had none of at all.
Implements Item 4 (compare-and-swap through the CLI, gastownhall/beads#4682)
from the BEADS-JOURNAL-PLAN.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* chore(bazel): regenerate cmd/bd BUILD.bazel for if_revision/close_if_revision
gazelle hadn't picked up if_revision.go, close_if_revision.go,
if_revision_test.go, and if_revision_embedded_test.go, so Bazel's bd_lib
and bd_test targets failed to build with "undefined: parseIfRevisionFlag"
and friends while plain `go build`/`go test` worked fine. Ran `make
bazel-sync` (bazel run //:gazelle; go_srcs.py; bazel mod tidy) to pick up
the new files; only cmd/bd/BUILD.bazel's srcs lists changed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* test(cli): update update-guard parity strings for --if-revision
TestParityUpdateGuardsRequireFieldUpdate and TestParityUpdateGuardsRejectClaim
pinned the exact stderr text of update.go's pre-write guard short-circuits.
Adding --if-revision to those guard messages (update.go/update_input.go)
changed "--if-assignee/--if-status" to "--if-assignee/--if-status/--if-revision"
in both, which this PR's own change to the guard text had not updated here —
caught by CI's dolt-server tier, not by the targeted if_revision* test runs.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
* wy-1rrwt8: add 'bd kv list --prefix' — SQL-side key-prefix filter for scoped kv reads
Downstream mail transports read the whole kv store (3.4MB, ~1988 mail.*
envelopes on the wyvern fleet) for every inbox render. This adds a --prefix
flag to 'bd kv list' that pushes the filter into SQL on stores that support
it, via an optional domain.ConfigPrefixReader interface discovered by type
assertion — no existing storage interface or test double changes shape, and
every path falls back to GetAllConfig plus in-process filtering.
- issueops: ConfigPrefixLikeQuery + ConfigPrefixPattern (LIKE with explicit
ESCAPE '!' — the engine does not honor backslash as a default escape) and
GetConfigByPrefixInTx.
- domain: ConfigPrefixReader optional interface; use-case impl delegates to
the repo fast path or filters GetAllConfig.
- domain/db, dolt, embeddeddolt: SQL-side GetConfigByPrefix.
- telemetry: instrumented passthrough preserving the capability.
- cmd/bd: --prefix on kv list, both classic and proxied-server paths;
kvPairsWithPrefix re-checks on every path so output is identical whichever
path served the read.
* build(bazel): list the PR's new test files in go_test srcs (make bazel-sync)
kv_prefix_test.go (cmd/bd) and config_prefix_test.go
(internal/storage/issueops) are new, untagged test files. Both packages'
BUILD.bazel files were generated on main after the PR's commit was written,
and the rebase onto main did not re-run gazelle, so neither go_test listed
them: bd_test and issueops_test reported PASSED with "no tests to run" for
TestKVPairsWithPrefix and TestConfigPrefixPattern, and bazel.yml's "BUILD
files in sync" step fails on that drift in the required bazel-test lane.
Generated by `make bazel-sync`, which rewrote only these two rows. Both files
import only the standard library, so no deps change.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(kv): engage the --prefix SQL fast path through the decorator chain
Maintainer review fixup for PR #6380.
The SQL push-down this PR exists to deliver was unreachable on bd's default
direct/embedded path. `bd kv list --prefix` asserted `store.(configPrefixReader)`
on the outermost decorator, but wireStorageDecorators unconditionally interposes
externaldeps.Store and (hooks on, the default) HookFiringStore, both of which
embed the storage.DoltStorage *interface* — and GetConfigByPrefix is
deliberately not declared there. The assertion could never succeed, so every
direct-mode prefix read silently took the GetAllConfig full-table fallback.
Output was identical, so nothing errored, logged, or failed a test, while the
flag help and command Long text asserted the opposite.
This carries the prior review lineage's fixup 9ca3caeb9, stranded when the PR
was relaunched, plus what this review iteration found missing from it:
- cmd/bd: discover the capability through storage.UnwrapStore, the repo's
documented idiom for optional-interface assertions (~50 existing call
sites), in configPrefixReaderFor. The direct-mode read itself is extracted
as readKVListConfig so the regression test drives the command's own read:
with only the helper under test, reverting the call site to the bare
`store.(configPrefixReader)` assertion still left the whole suite green.
- cmd/bd: chain-level regression test over wireStorageDecorators covering all
four telemetry/hooks configurations, plus the negative case proving a store
without the capability is still reported incapable. The stub counts full
reads, so a fallback fails the test even though it returns the same rows.
Verified non-vacuous: a bare assertion in the helper or in
readKVListConfig, a disabled fast path, a dropped kv. prefix, or a method
added only to the mirror interface each fail all four configurations; a
peel that stops at InstrumentedStorage fails the telemetry-on negative case.
- dolt, embeddeddolt, telemetry: compile-time pins against
domain.ConfigPrefixReader, so method-set drift on any implementation is a
build error instead of a silent reversion to full scans. The cmd/bd
mirror's own pin checks one direction only (a method added just to the
mirror still compiles); its comment now says so and names the test that
covers the other direction.
- domain/db: delegate GetConfigByPrefix to issueops.GetConfigByPrefixInTx like
the sibling stores, instead of a second scan loop over the shared query
constant.
- telemetry: record the deliberate trade — peel-to-raw keeps the standard
idiom and leaves the instrumented forwarder off the cmd/bd path.
- bazel: add //internal/storage/domain to the telemetry_test deps (make
bazel-sync); without it the telemetry pin's import fails strict deps.
Co-authored-by: dog <dog@ghosttrack.com>
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: dog <dog@ghosttrack.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(backends): registry Remote + optional OpenWith(ctx, dir, OpenOptions)
Slice S1: backends.Backend gains Remote bool and an optional
OpenWith(ctx, beadsDir, OpenOptions{Credential, HTTPClient, UserAgent}) so a
registered extension backend can honor a per-open credential instead of
dialing with a process-global client — the motivating case is one embedder
process serving many workspaces with distinct credentials. Open keeps
working unmodified for every existing backend: Backend.OpenWithOptions calls
OpenWith when present, otherwise falls back to Open and ignores
HTTPClient/UserAgent, but refuses (ErrCredentialWithoutOpenWith) rather than
silently dropping a non-nil Credential.
Public beads.OpenBestAvailableWith(ctx, beadsDir, opts) carries this through
the SDK surface (mirrored in beads_nocgo.go and aliased in backend/backend.go
and beads.go); OpenBestAvailable is now that call with a zero OpenOptions,
identical to its prior behavior for Dolt, embedded Dolt, and every registered
backend. The plain-Dolt path (no registered backend) applies the same
Credential refusal, since Dolt has no per-open credential seam either.
doltserver.ResolvePhysicalRoots now checks backends.IsRemote(cfg.GetBackend())
before every Dolt-mode branch, including the shared-server check (which reads
only env/config.yaml and never consults cfg) — without this ordering, a global
BEADS_DOLT_SHARED_SERVER=1 would hijack a remote-backend workspace into
reporting a bogus local Dolt root it will never open.
Tests: backends_test new file open_with_test.go covers OpenWithOptions
dispatch/back-compat/Credential refusal and Remote/IsRemote; root package
open_backend_selection_test.go adds a fake OpenWith registrant proving
dispatch and option pass-through through OpenBestAvailableWith, zero-options
back-compat for every path (registered w/ and w/o OpenWith, plain Dolt), and
the Credential-without-OpenWith refusal on both paths; doltserver
physical_root_test.go adds the registered-remote-backend case including the
shared-server-override ordering regression test. Verified under both cgo and
nocgo builds. Live-mutated each new guard (the Credential refusal, the
OpenWith dispatch, the ResolvePhysicalRoots remote-backend case, and the
plain-Dolt Credential refusal) one at a time and confirmed RED before
reverting to GREEN.
No HTTP client code added; that is a later slice.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fixup(backends): address Opus review findings on OpenWith (M1-M3, L1-L2)
- M1: frame cmd/bd store-open errors for remote backends as unreachable
server failures instead of Dolt-shaped "failed to open database"
advice (openStoreErrorMessage, backendNameForErrorFraming), with tests.
- M2: rewrite the OpenBestAvailable/OpenBestAvailableWith back-compat
subtest to assert fixed expected outcomes (error identity/message,
returned store behavior) now that the two functions are identical,
instead of comparing them to each other.
- M3: document and enforce the OpenWith contract: an implementation that
receives a non-nil Credential it cannot type-assert to its expected
type must refuse with the new ErrUnsupportedCredential sentinel,
verified with a fake registrant.
- L1: document that a nil OpenOptions.Credential means the backend's
default/ambient auth, and that multi-tenant embedders must pass a
non-nil Credential (RequireCredential deferred to S2).
- L2: fail closed on HTTPClient/UserAgent passed to a backend without
OpenWith, mirroring the existing Credential refusal, via new
ErrHTTPClientWithoutOpenWith/ErrUserAgentWithoutOpenWith sentinels.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* build(bazel): auto-sync BUILD files
Applied from the bazel-sync-patch artifact of https://github.com/gastownhall/beads/actions/runs/37195230844
(`make bazel-sync`: gazelle, tools/bazel/go_srcs.py, bazel mod tidy).
Only BUILD.bazel, MODULE.bazel and MODULE.bazel.lock are ever pushed; see
scripts/bazel-autofix-push.sh.
* fix(backends): keep the store-open error chain through the remote framing
Maintainer review fixes for the adopted PR (iteration 1).
openStoreErrorMessage returned a string, so ensureStoreActiveWithContext
rebuilt its error from text (%s) where base wrapped the open error with %w,
and the chain ended at the CLI's framing. Prime tells a store-open timeout
apart from a generic "storage unavailable" only through
errors.Is(err, context.DeadlineExceeded) on what ensureStoreActiveWithContext
returns (cmd/bd/prime.go), so the flattening silently downgraded that
diagnostic for every backend, Dolt included, not just the new Remote ones.
Replace the helper with openStoreError, which returns an error wrapping err
with %w on both arms. The message text is unchanged: "failed to open
database: <err>" for Dolt and any registered backend that is not Remote,
"failed to reach remote backend %q: <err>" for a Remote one. direct_mode.go
wraps the result with %w ahead of its Hint line; main.go keeps printing it
through HandleError("%v", ...), which only formats.
Tests:
- TestOpenStoreErrorFramesRemoteBackends (renamed from
TestOpenStoreErrorMessageFramesRemoteBackends) now also asserts errors.Is
on every arm, and the exact original text for the non-Remote arms.
- TestEnsureStoreActiveKeepsOpenErrorChain drives the real
ensureStoreActiveWithContext against a registered backend whose open
outlives its context, for a local and a Remote backend, and requires
errors.Is(err, context.DeadlineExceeded) plus the framing prefix and the
Hint line.
- TestFormatMemoriesForPrimeTimesOutOpeningRegisteredBackend is the
unstubbed twin of TestFormatMemoriesForPrimeTimesOutOpeningStore and
requires the timeout banner, not the "storage unavailable" one.
Measured at this head: turning direct_mode.go's outer %w into %v reddens
both chain-test rows and the prime test; turning the helper's %w into %v
reddens the framing test as well.
Non-gating cleanup in the same area:
- beads_cgo.go, beads_nocgo.go: OpenBestAvailableWith's doc and dispatch
comments said only a non-nil Credential is refused. The code also refuses
a non-nil HTTPClient and a non-empty UserAgent, each with its own
ErrXWithoutOpenWith sentinel.
- internal/doltserver/physical_root.go: the Mode doc lists "remote-backend",
and the RemoteBackend doc covers a registered Remote backend as well as a
Dolt server on a non-local host.
- open_backend_selection_test.go: the plain-Dolt refusal test is a table
over Credential, HTTPClient and UserAgent (renamed
TestOpenBestAvailableWithRefusesPerOpenOptionsOnPlainDolt). Disabling the
nocgo HTTPClient arm or the cgo UserAgent arm reddens only that row. The
zero-options test's comment had the delegation backwards and pointed at
beads.go; OpenBestAvailable delegates to OpenBestAvailableWith in
beads_cgo.go and beads_nocgo.go.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
* refactor(doltserver): share dolt's startup-output watcher with the plain server launcher
Move the ready-line / port-in-use watcher that the proxied DoltServer uses
(startupWatch, doltReadyLine, doltPortInUseTexts, logLevelEmitsReadyLine,
ErrPortInUse) into internal/doltserver as StartupWatch and friends, so the
plain server-mode Start can read the same signals. dbproxy/server already
imports internal/doltserver, so it now uses them from there; its
ErrPortInUse is the same error value. No behavior change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(doltserver): prove the auto-started dolt owns its port; move a taken ephemeral port
The plain server-mode Start (bd init --server, auto-start, bd dolt start)
had the same blind readiness check the managed-local proxied backend had
before #7184, plus a blind exit check:
- It picked an ephemeral port, closed the probe listener and launched dolt,
then slept 200ms and asked whether the child was still alive. dolt only
reaches its port check after its own startup, which under load takes
longer than that, so a lost port was never caught there. Worse, the child
had been Release()d unreaped, and a zombie still answers kill(pid, 0), so
an exit was invisible for the rest of the bd process.
- It then waited for any MySQL greeting on the port. If another process
took the port in between, either it was mute (a plain listener) and Start
ran out its ready timeout -- the direct-local-server auto-start timeout seen
under port churn -- or it was another dolt, and Start reported success
against a server it did not start.
Now each attempt launches the child with a goroutine that waits on (and
reaps) it, and awaitOwnedListener accepts a greeting only once the
listener is shown to be the child's: dolt's ready line in the child's
output when its log level emits it (debug), or else the listening socket
belonging to the child's process tree (Linux, via /proc/net/tcp and
/proc/<pid>/fd). The child's output is read from the server log past the
offset it started at, through the StartupWatch shared with dbproxy, so
"Port N already in use." (printed at log_level warning too) ends the
attempt at once as ErrPortInUse, and a child exit ends it as a failure.
Port policy follows #7184's contract: only a port bd chose itself moves.
An ephemeral port that is lost is retried on a fresh one (up to the
existing 10 attempts); an explicitly configured port (env, config.yaml,
metadata, dolt config) stays pinned and fails with ErrPortInUse and a
remedy. Nothing operator-owned is rewritten: the generated
dolt-server-config.yaml is bd's own state file and was already rendered
per attempt. Where ownership cannot be proven (non-Linux, quiet log
level) the greeting decides as before, but the child's exit and
port-in-use report still end the wait.
Tests: a fake dolt (this test binary, behind a PATH shim) that spends
700ms starting up and then binds like dolt does. A foreign greeter on the
port is not accepted (ErrPortInUse); the child's own listener is; a child
exit is reported promptly; and the real Start, handed a taken first
ephemeral port, comes up on a fresh one (fails before this change: Start
adopted the foreign port).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(doltserver): isolate user config in the DefaultConfig tests
Four DefaultConfig tests failed under -tags integration on a host whose
user config sets dolt.shared-server: true. The integration TestMain, unlike
the plain one, does not redirect HOME, so:
- TestDefaultConfigPrecedenceChain and TestDefaultConfigPortSource call
config.Initialize, which merged ~/.beads/config.yaml.
- TestDefaultConfigReturnsZeroForStandalone and
TestDefaultConfigPortFileTakesPrecedence read whatever config an earlier
test had loaded from the real HOME.
Shared mode then sent DefaultConfig to the shared server's state dir and
its port file ("port=3308 source=port_file, want 5002/config_yaml").
isolateUserConfig points HOME, USERPROFILE and XDG_CONFIG_HOME at an empty
dir, the way TestDefaultConfig_NonzeroPortAlwaysHasSource already does.
It also resets the loaded config before the test and again after it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(doltserver): auto-start review fixes: record the server at launch, sharper ownership, port policy by source
Follow-up to 0acb1041b, addressing review.
B1: write the PID and port files again right after each launch, as before
that commit, and remove them on every failure path (port conflict,
not-ready, remotesapi). Previously a bd interrupted during the readiness
wait left a dolt holding the database lock that nothing could find. The
next start, bd dolt stop and killall all saw nothing. Both files carry the
real port, so IsRunning never stops a starting server as "port unknown".
S1: a child gone from /proc is known not to own the port; it is no longer
"unknown", which would let a foreign greeting through. The child's log is
re-read on every check, not only after its exit has been observed, because
the reaper goroutine can lag the death.
S2: if no listener on the port is listed although one just answered, /proc
is incomplete (WSL1, some sandboxes, forwarding). That is now "unknown"
(fallback to the greeting), not "foreign". Also "unknown": a /proc that is
not this PID namespace's.
S3:
- bd's port-file port moves like an ephemeral one outside shared-server
mode, since bd chose it (GH#4052).
- Operator-configured ports and the shared-server port stay pinned.
- The pinned error now says where the port came from (env, config.yaml,
dolt config, metadata, --server-port, shared default, shared port file)
instead of always "configured explicitly".
S4: a killed child is waited for (up to 5s) before the next attempt or the
return, so it has released the database lock. Its process group is killed
too (unix), which reaches a dolt behind a non-exec wrapper.
S5: when /proc proves the listener belongs to another process, the wait
returns ErrPortInUse at once. It no longer sits out a slow child, which
could outlast the timeout and turn a movable port into a hard failure.
NITs:
- Debug-mode timeout names the missing ready line and the way out.
- The log tail restarts if the log is truncated under it.
- waitForReady is removed; its probe tests now drive awaitOwnedListener.
- Stale daemonization comment fixed in cmd/bd.
- CONFIG_PROC_CHILDREN caveat documented.
Tests:
- fake-/proc ownership cases: owned, foreign, child gone, no listener row,
unreadable fd table;
- /proc/net/tcp parsing;
- proven-foreign ends the wait at once;
- port-in-use in the log counts before the exit is seen;
- ready-line proof, with and without the line;
- Start records PID+port while waiting;
- Start removes them after a failed start;
- pinned env port: one launch, ErrPortInUse, source in the message;
- port-file port moves;
- remedy wording per source.
The Start tests now isolate the user config instead of skipping.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(doltserver): de-flake two startup tests under load
- TestStart_RecoversWhenEphemeralPortIsTaken: on Linux, /proc proves the
taken port foreign as soon as the greeting arrives, so the first child
can be killed before the fake records its launch. Assert two port
allocations and the final launch instead of the first launch.
- TestAwaitOwnedListener_ReadyLine: give the "no ready line" case 8s, so
the fake has time to start and greet on a loaded host.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
In shared-server mode every project's physical root is the one shared dolt
data dir, and bd init holds that dir's gate EXCLUSIVELY for its whole run
(~8s). It waited only exclusiveGateWait (5s) for it, so two concurrent
`bd init --shared-server` runs in different projects, or an init during
another project's long command, failed with "bd init refuses to run over
live bd activity".
acquireInitMutationGate now uses its own acquisition options:
- Wait: 30s by default, overridable with BEADS_INIT_GATE_TIMEOUT (Go
duration or bare seconds, same convention as BEADS_PRIME_TIMEOUT and
BEADS_FSCK_TIMEOUT); ctx cancellation still aborts the wait.
- One stderr notice ("waiting for another bd process on the shared
server (...)...") once the wait passes 2s, instead of immediately.
- Past the bound, the same refusal, now naming the budget and the knob.
Exclusivity is unchanged. The 5s exclusiveGateWait is also used by
backup restore, bootstrap, migrate and the backup lock; those keep it, so
the change is scoped to init via acquireExclusiveWorkspaceGatesWithOptions.
TestSharedServerConcurrent goes back to fully concurrent inits (manual runs
with many dirs raise BEADS_INIT_GATE_TIMEOUT to match). New unit tests: a
holder released after 6s lets init through with one notice; a holder past
the bound gives the clear ErrBusy error; cancellation; env parsing.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(routing): bind role detection to the -C target repo (re-port of #4242)
Role detection previously called routing.DetectUserRole(".") directly,
which resolves against the caller's CWD rather than the repo selected
via `bd -C <target>` (BEADS_DIR-driven). This meant auto-routing and
role-based behavior could silently apply the wrong repo's role when
invoked with -C.
Introduce activeRepoPathForRouting(), which prefers
beads.GetRepoContext().RepoRoot (the BEADS_DIR-bound target) and falls
back to the parent of beads.FindBeadsDir(), then to ".". Route role
detection in cmd/bd/create.go and cmd/bd/routing_read.go through the
new detectUserRoleForActiveRepo() helper instead of calling
routing.DetectUserRole(".") directly.
Faithful re-port of gastownhall/beads#4242 (osamu2001) onto current
main: determineAutoRoutedRepoPath's signature changed to
(string, routing.RoutingRule) since the PR was opened (89a4d6ed8 /
#4866), so the one-line call-site change re-applies inside the new
function body, and the new routing_read_test.go coverage destructures
both return values. All other ported content (routing_role.go,
context_binding_test.go, the create.go call site) is unchanged from
the original PR.
Co-authored-by: Osamu Okano <okano.osamu@gmail.com>
Agent-Signature: claude-fable-5-high on behalf of maphew
* test(routing): fix the sole CI failure in the re-ported #4242 test
TestActiveRepoPathForRoutingFallsBackToBeadsDirParent created its fake
project under this repo's tree, so beads.GetRepoContext() resolved a
real repo root from the caller's CWD and the FindBeadsDir fallback the
test claimed to cover was never exercised — an unreachable assertion
that CI reproduced as the PR's only failing test.
Rewrite it to target a directory that is genuinely outside any git
repo: targetDir now comes from t.TempDir() (its .beads/config.yaml
still written via writeTestConfigYAML), and the caller CWD is also
moved to a fresh t.TempDir() via t.Chdir() so GetRepoContext() can't
resolve through the CWD either. Both resolve under os.TempDir(), which
internal/beads/context.go's isPathInSafeBoundary explicitly admits, so
this stays safe under the existing boundary check.
This makes safeTempDirForContextTest (the manual git-repo-relative
temp dir helper the original test used to dodge the same problem)
dead code; delete it.
Co-authored-by: Osamu Okano <okano.osamu@gmail.com>
Agent-Signature: claude-fable-5-high on behalf of maphew
* fix(routing): a .beads/redirect must not move role detection to the storage root
Cross-vendor review of e8600e732 caught a regression the re-port would have
introduced for redirect users: with a .beads/redirect pointing at storage
outside any git repo, RepoContext.RepoRoot is the redirect target's parent,
so beads.role would be read from the storage location instead of the
workspace repo — silently bypassing contributor routing.
The two external-BeadsDir shapes now get their opposite answers explicitly:
an explicit BEADS_DIR selection (what bd -C plumbs) binds role detection to
the selected project (the GH#4242 fix), while a followed redirect keeps it
on the CWD workspace repo (pre-existing semantics — a redirect relocates
storage, not the project). Mutation-tested: with the guard removed, the new
test fails by resolving to the storage root.
Co-authored-by: Osamu Okano <okano.osamu@gmail.com>
Agent-Signature: claude-fable-5-high on behalf of maphew
* fix(routing): read BEADS_DIR selection provenance at startup, not the live env var
The self-review on this PR found a startup-path gap: rootCmd's
PersistentPreRunE calls prepareSelectedCommandContext for every command,
which sets BEADS_DIR to the resolved target — redirects included. By the
time role detection ran, activeRepoPathForRouting's os.Getenv("BEADS_DIR")
check was therefore always true, classifying a plain .beads/redirect as
explicit selection and binding beads.role to the storage root instead of
the workspace repo.
Capture whether BEADS_DIR was present in the environment at process start,
and treat selection as explicit only for that case or a -C flag. The new
TestActiveRepoPathForRoutingSurvivesStartupRebindAcrossRedirect goes
through the real startup rebind with a real redirect and fails on the
previous logic; the two tests that simulate a caller-exported BEADS_DIR
now pin their provenance explicitly.
Agent-Signature: claude-fable-5-high on behalf of maphew
* fix(routing): .env-provided BEADS_DIR is user selection, mark its provenance
Cross-vendor review of the previous commit caught a regression it would
have introduced: loadBeadsSelectionEnvFile intentionally lets a project's
.beads/.env route commands via BEADS_DIR, and that selection happens after
the process-start snapshot. Flip the provenance flag when the selector
loader sets BEADS_DIR, so .env routing keeps binding role detection to the
selected project. TestActiveRepoPathForRoutingHonorsEnvFileSelection pins
it end to end through loadSelectionEnvironment.
Agent-Signature: claude-fable-5-high on behalf of maphew
* test(routing): make the BeadsDir-parent fallback test order-robust on macOS
The macOS CI leg failed on /private/var vs /var: the test asserted a raw
string path while resolution can hand back the canonicalized spelling of
the same directory depending on which branch wins under test ordering.
Compare through EvalSymlinks like the sibling redirect tests, and pin
selection provenance in the two tests that had not declared theirs.
Agent-Signature: claude-fable-5-high on behalf of maphew
* ci: retrigger - dolt-install/download infra outage (curl 56/503) killed 4 jobs
Agent-Signature: claude-fable-5-high on behalf of maphew
* build(bazel): enumerate cmd/bd/routing_role.go in bd_lib srcs
The PR adds cmd/bd/routing_role.go, whose detectUserRoleForActiveRepo is
called from create.go and routing_read.go. cmd/bd/BUILD.bazel lists
go_library srcs explicitly, so the unenumerated new file broke the Bazel
library compile:
cmd/bd/create.go:303:21: undefined: detectUserRoleForActiveRepo
cmd/bd/routing_read.go:52:19: undefined: detectUserRoleForActiveRepo
Generated by `bazel run //:gazelle` (one srcs row, idempotent; no deps row
owed because the library already carries internal/beads and
internal/routing). Base parity at 89348699b0 was 336/336 non-test .go files
enumerated in cmd/bd, so the gap was PR-introduced, not pre-existing.
* fix(routing): bind role to the selected workspace across a .beads/redirect
Maintainer review fixup for the adopted PR (review iterations 1 to 3).
Iteration 1 addressed the one gating major plus both minors and both nits
from its review synthesis. Iteration 2 addressed the major, the minor and the
nit that the next synthesis raised against that fixup, and iteration 3
addresses the minor and the nit raised against iteration 2; see "Review
iteration 2" and "Review iteration 3" below.
The major: routing_role.go ordered its guard `explicitBeadsSelection() ||
!rc.IsRedirected`, but every beads-dir resolver follows a .beads/redirect before
that guard can run (ExplicitBeadsDir via FollowRedirect, FindBeadsDir, and -C's
own resolution). So an explicit selection of a REDIRECTED workspace arrived
already rewritten to the storage root, short-circuited the redirect doctrine the
PR had just written, and bound beads.role to wherever the DATA lives — the same
misroute GH#4242 reported, one resolution step further in. Worse, it was silent:
`git config --get beads.role` succeeds outside a repo by reading GLOBAL config,
and routing.DetectUserRole returns on that first success, so its own "beads.role
not configured" notice never fired and a contributor workspace could be routed
with the user's global role with no diagnostic on any stream.
The remedy has to be anchored per shape, because the two selection shapes carry
the pre-redirect directory in different places:
- `bd -C <dir>`: applyChangeDirSelection has already rewritten BEADS_DIR to the
resolved target, so only the -C argument still names the chosen project.
CWD-anchored GetRedirectInfo() cannot see this case at all — under -C the CWD
is some unrelated directory — so this arm asks GetRedirectInfoFrom(dir),
which is documented for exactly this case (GH#5509) and deliberately does not
consult BEADS_DIR.
- exported BEADS_DIR: here the CWD *is* the selected workspace, so the
CWD-anchored probe is the correct one. The selection is vacuous when it
merely names that workspace's own redirect, under both spellings of it:
BEADS_DIR=<workspace>/.beads and BEADS_DIR=<storage>/.beads both arrive as
the storage dir (the bd-wayc3 tooling shape), so both fall through to
rc.CWDRepoRoot.
An explicit selection of a genuinely different, non-redirected project still
wins — that is the GH#4242 fix itself, and a control test pins it.
Also in this commit:
- A role path that is not a git repository now warns instead of quietly
inheriting global beads.role (new beads.RepoRootFor answers both "what is
the repo root for this dir" and "is this a repo at all").
- A .env-provided BEADS_DIR records selection provenance on the broad loader
too, not only via loadBeadsSelectionEnvFile. That loader early-returns
whenever BEADS_DB or BD_DB is already exported, and loadBeadsEnvFile then
imports the same .env line, so one .env line meant target-role or CWD-role
depending on the caller's unrelated BEADS_DB export. Internal rebinds are
unaffected: the marking is conditional on BEADS_DIR having been unset, which
is what separates user selection from prepareSelectedCommandContext's
per-command rebind.
- The four-way role-path choice is logged via debug.Logf, since the downstream
"failed to detect user role" warning fires on none of those branches.
- The PR's new routing test neutralizes BEADS_ROUTING_MODE / BD_ROUTING_MODE,
which viper binds onto the routing.mode key and which reds the test on any
host that exports them.
- routing_role.go now cross-references RepoContext.Role(), the second,
known-divergent role oracle in internal/beads. No behavior change there.
Tests: the explicit x redirect cell was the one combination the PR's new tests
left empty. Both probe shapes land as tests, plus the `bd -C <redirected-ws>`
shape, a non-redirected -C control, the non-repo warning, and both provenance
polarities. Each new pin was verified to FAIL against the pre-fix code.
Review iteration 2:
- Major: the non-repo warning above ran inside detectUserRoleForActiveRepo,
which create.go and determineAutoRoutedRepoPath called before resolving the
routing config. Routing is off by default and only auto mode reads the
role, so in any non-git beads project every bd create/list/ready printed a
4-line warning about a role nothing used. The leak also broke six
TestParity* characterization tests at the iteration-1 head:
CreateHumanOutput, CreateOnOccupiedIDRefuses, CreateParentNotFoundExits1,
CreateMissingDepTargetIsFatal, CreateJSONErrorShape and
ReopenErrorExits1Silently. Detection now runs only when the fully resolved
config can use its answer: new RoutingConfig.UsesUserRole (auto mode, no
explicit override, a role-specific repo configured) gates the new
detectUserRoleForRouting, which both call sites invoke after building the
config, so the legacy contributor.auto_route=true fallback to auto counts
where a raw routing.mode check would miss it. Side effect: routing's own
GH#2950 "beads.role not configured" notice is also skipped when routing
cannot use the role, as docs/multi-agent/routing.md already promises when
it calls `routing.mode explicit` "disabling role detection entirely".
- Minor: for an exported BEADS_DIR, selectedWorkspaceRepoRoot called the
selection vacuous when the CWD-anchored GetRedirectInfo reported a redirect
to it. With no redirect in the CWD repo, GetRedirectInfo falls back to the
raw BEADS_DIR, so a FOREIGN redirected workspace vouched for its own
redirect and the CWD repo's role was bound. The check now also requires the
redirect to sit in the CWD repo's own .beads (RedirectInfo.LocalDir). A
foreign redirected selection falls through to its storage root, which is
the answer a live command already reaches after the pre-RunE rebind, so
unit and command behavior agree. Binding the foreign workspace itself would
need the raw startup BEADS_DIR, which nothing keeps; the routing_role.go
comment records that limit.
- Nit: the non-repo warning prints at most once per process. An ID lookup
falls back to auto-routing once per missing ID, and each fallback re-ran
detection.
- Test isolation: the PR makes role detection read the process-wide
beads.GetRepoContext() cache, a sync.Once. Three existing tests chdir
between temp repos without resetting it and so read beads.role from an
earlier test's deleted repo: TestResolveCloseTargets/
contributor_mixed_local_and_routed,
TestDetermineAutoRoutedRepoPath_ContributorToPlanning and
TestOpenRoutedReadStore_ContributorRouting fail in a broad cmd/bd run at
86b8abff3f and 8dbfc6c721 and pass at base 89348699b0. The failure is
order-dependent, and the tests skip without a Dolt test server. Each now
rebuilds the cache after its chdir, as does the MaintainerToPlanning
sibling, which has the same exposure.
Iteration-2 tests: a property test pins UsesUserRole to
DetermineTargetRepoWithRule (true exactly when the answer varies by role,
across unset/auto/explicit modes and every override and repo combination). A
table test covers routing unset, explicit mode, auto without a role repo,
auto, and legacy auto_route. Two more cover the foreign redirected BEADS_DIR
cell and repeated detection (the once-guard). Each pin was mutation-checked:
dropping the gate, gating on the raw mode, or dropping the LocalDir guard,
the once-guard, the role-repo clause or the override clause turns a test red.
Validated (iteration 1): gofmt, go build ./..., go vet ./cmd/bd/
./internal/beads/, focused go test over cmd/bd role/routing/envfile/context
tests and ./internal/beads/ ./internal/routing/, gazelle (0 srcs rows owed),
and bazel build //cmd/bd:bd_lib //internal/beads:beads.
Validated (iteration 2): gofmt, git diff --check, go build ./..., go vet
./cmd/bd/ ./internal/routing/ ./internal/beads/ with and without cgo,
golangci-lint v2.10.1 --new-from-rev=HEAD on cmd/bd and internal/routing (0
issues), go test ./internal/routing/ ./internal/beads/, and a broad cmd/bd
routing/role/redirect/context/Parity run. The only reds on this host,
TestInitRedirect/RedirectCreatesDBInTarget,
TestBareParentWorktreeCoreCommandsWithoutRedirect and
TestServeIssueRolesComeFromBeneathTheHookDecorator, fail the same way at base
89348699b0. No files were added and the only new import is stdlib, so no
BUILD.bazel change is owed.
Review iteration 3:
- Minor: the iteration-2 guard counted a redirect as the CWD workspace's
own only when it sat in the CWD git root's .beads (Dir(LocalDir) ==
rc.CWDRepoRoot), which equates the workspace with the git root. From a
workspace nested below its repo root (<repo>/sub/.beads/redirect), or
from a git worktree that inherits its main checkout's redirect,
exporting that workspace's own .beads therefore moved role detection
from the CWD repo to the storage root: the env-dependent inconsistency
the iteration-1 vacuous rule exists to remove. Dropping the guard would
not have fixed it. When the repo root's .beads holds no redirect,
GetRedirectInfo checks BEADS_DIR itself, and prepareSelectedCommandContext
has rebound BEADS_DIR to the storage .beads before RunE. After that
rebind GetRedirectInfo finds no redirect in either shape, so the
iteration-1 rule bound the storage root there too. New
beads.GetDiscoveredRedirectInfo is GetRedirectInfo without the
BEADS_DIR override: the redirect discovery finds from the CWD (the repo
root's .beads, then the worktree-local redirect, the main checkout's
.beads for a worktree, and the walk-up from the CWD), via
findDiscoveredLocalBeadsDir, the BEADS_DIR-free half of
findLocalBeadsDir. The exported-BEADS_DIR arm now calls a selection
vacuous exactly when that discovered redirect exists and targets the
selected storage. A foreign redirected selection still falls through to
its storage root, because discovery from the CWD finds no redirect or
one with a different target.
- Nit: the foreign-selection test's comment now says only the exported
arm pins the guard. The rebound storage .beads holds no redirect, so
the rebind arm only checks that both states of the variable agree.
Iteration-3 tests: nested-workspace and worktree-without-own-.beads cells,
each with BEADS_DIR unset, as exported, and as rebound before RunE. Against
the unchanged 07c7373dfb code the four set-BEADS_DIR cells fail and both
unset controls pass. A new test pins the target comparison: from a
redirected workspace, an exported BEADS_DIR naming a different,
non-redirected project still binds that project.
TestGetDiscoveredRedirectInfo pins the new API against GetRedirectInfo in
both directions (a nested redirect that BEADS_DIR masks, and a BEADS_DIR
redirect the CWD does not hold). Five mutants each turn a test red: probing
with GetRedirectInfo again (the iteration-1 rule, which fails both rebind
cells and the foreign test), dropping the target comparison, dropping the
worktree-fallback tier, letting discovery honor BEADS_DIR, and restoring the
git-root guard.
Validated (iteration 3): gofmt, git diff --check, go build ./..., go vet
./cmd/bd/ ./internal/beads/ ./internal/routing/, golangci-lint v2.10.1
--new-from-rev=HEAD on cmd/bd and internal/beads (0 issues), go test
./internal/beads/ ./internal/routing/, and a focused cmd/bd run over the
role, routing, redirect, envfile and context-binding tests against the
Dolt test server (47 passed, 0 failed, 0 skipped). No files were added,
so no BUILD.bazel change is owed.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Osamu Okano <okano.osamu@gmail.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* fix(dbproxy): prove the managed dolt owns its port; move a taken Beads-chosen port
The managed-local backend's dolt port comes from a bind-and-close
(proxy.PickFreePort) when bd writes the generated config. The dolt
sql-server binds it only later, after the proxy child has run dolt
config and init and booted the server. If another process takes the port
in that gap, dolt logs "Port N already in use." and exits. But
DoltServer.waitReady only dialed the port, so it accepted the other
process's listener as ready. The proxy then published proxy.pid, its
backend health check saw dolt gone, and it shut down. bd init's first
ping got "unexpected EOF" and every retry after that got "connection
refused". Under parallel tests this hit any test that starts its own
managed backend.
Readiness now requires proof that the process Start launched owns the
port:
- DoltServer sends the child's stdout/stderr through a watcher that
forwards to the server log. A dial counts only after dolt's own
"Server ready. Accepting connections." line has appeared on that
output. That line is info level, and every generated config uses
info. A config with a quieter log_level has no such signal and keeps
the dial-only check.
- A child that exits first is reported as the new server.ErrPortInUse
when its output said its port was taken.
Recovery: DoltServer.SetPortRepicker lets Start move the config to a
fresh port, re-read it, and relaunch, up to 5 ports. dolt config/init
run only on the first attempt. bd's repicker,
repickManagedProxiedServerPort, needs to tell a port Beads chose from
one an operator set, so generated configs now record the chosen port
on a "# beads-chosen-listener-port: N" line after the managed marker.
The repicker moves the port only when the file is Beads-generated,
carries that record, and its listener.port is still the recorded port.
Otherwise the port is treated as pinned and Start fails with
ErrPortInUse. That includes configs generated before this change. It
rewrites only listener.port and the record, through a yaml.Node so the
rest of the file is kept, and writes the file atomically.
db-proxy-child installs it for the local backend.
The proxy's waitForServerReady also re-checks Running after its dial.
Start has already proved ownership, and a running dolt holds its
listener, so only a backend that exited between the two checks could
let a dial reach another process.
Tests:
- server: a held port is not accepted as ready (ErrPortInUse; this
test fails on main), a repicker brings the server up on a new port
that the pid record and DSN both use, and a declining repicker ends
Start with ErrPortInUse.
- cmd/bd: the generated config records its port, a Beads-chosen port
moves while hand edits survive, and a hand-set port, a config
without the record, an operator config, and a stale in-use port are
all refused with the file left untouched.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(dbproxy): move a taken managed port via a runtime config, never config.yaml
This reworks cd00c5acb after review. That commit recovered from a taken
Beads-chosen port by rewriting the managed config.yaml. That broke the
file's own contract ("Never rewritten afterward; hand edits are
preserved", #4986), and #5024 had deferred that contract change to an
RFC.
dolt sql-server has no command-line way around the file: with --config,
-P/--port is silently ignored (checked against dolt 2.1.8 and 2.2.0, in
both argument orders). So on ErrPortInUse the proxy child now writes
proxy-child.runtime-config.yaml (server.RuntimeConfigFileName) in the
server root. That file is the operator config with only listener.port
moved to a free port. The child relaunches dolt from it and records the
effective port where runtime readers already look: the backend pid
record and the DoltServer's dial/DSN config. The runtime config is
removed when the server stops, when Start fails, and by the next Start.
config.yaml is never written.
- server.PortRepicker becomes server.PortConflictPolicy. It only decides
whether the port may move; the server does the move.
- bd's policy (managedPortConflictPolicy) allows a move when the file
carries the managed marker and either:
- has the port record and listener.port still equals it, or
- is byte-identical to the config bd generated before the record
existed, so existing unedited workspaces recover too.
- Everything else is pinned: operator configs, hand-set ports,
hand-edited legacy files, and configs with ${...} placeholders (a
runtime copy would put the expanded values on disk).
- The record line now says plainly that Beads runs on a free port
without editing the file, and that deleting the line or changing
listener.port pins the port. The record parser now requires the
digits to end at a space or line end and to be in 1..65535.
- ErrPortInUse messages say what to do: free port P, set listener.port
in <path> to a free port, or (for a generated file) delete it so
Beads regenerates it. The give-up message names the last port tried.
- A dolt that never logs the ready line is still not accepted. A
grace-period fallback would let a foreign listener through while dolt
is still starting. The timeout error now names the missing line, says
whether anything answered, and points at the escape hatch: at
log_level warning, readiness is dial-only.
- Port-conflict detection matches go-mysql-server's "Port host:port
already in use." and the Windows bind error, and requires the SQL port
in the kernel's bind error, so a metrics or MCP listener failure is
not taken for the SQL port.
- Spawn error paths reap with cmd.Wait(). cmd.WaitDelay is set, and a
comment notes that the backend's output is now a pipe into the proxy
child.
Tests:
- Output-watcher table tests: split, one-byte and CRLF writes, output
past the 4 KiB tail, the MCP ready line, port boundaries, the
go-mysql-server and Windows forms, another listener's bind error, the
unix-socket warning, and nil log.
- A real dolt at log_level warning starts through dial-only readiness.
- With a stand-in dolt (the test binary in fake mode, wired in
TestMain): Start gives up after maxStartPortAttempts, a missing ready
line is diagnosed, plus a positive control.
- With real dolt: a move keeps config.yaml byte-identical, runs from the
runtime config, and the runtime config is removed on Stop. A declining
policy and the no-policy remedy are covered.
- The bd policy's allow and pin cases.
- The managed-local lifecycle test's config/pid port check accepts the
runtime config.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(dbproxy): ask the port policy once, about the operator's port; copy raw config text
Re-review of the runtime-config rework found a regression. After the
first move, Start asked the PortConflictPolicy about the runtime port.
bd's policy re-reads config.yaml, whose listener.port is still the
operator's port, so it refused with "listener.port is A, not the in-use
port B". The "up to 5 ports" retry therefore never ran in production;
the fake-dolt test missed it because its policy always allowed.
Start now asks the policy once per Start, on the first conflict, about
the operator config's port. Ports Start picked itself are its own to move
again. Start also re-reads the operator config up front, so every Start
begins from that config's port.
The runtime config is now built from config.yaml's raw text
(servercfg.NewYamlConfig) instead of the env-interpolated
YamlConfigFromFile result. dolt interpolates the runtime file when it
reads it, so the old way expanded placeholders twice: "$$" escapes lost a
level and placeholder values landed on disk. The server reads the
runtime file back with interpolation for its own Dial/DSN view. Since
placeholders no longer expand on disk, bd's policy stops refusing
configs that contain them.
Tests:
- bd's real policy driving a real DoltServer with a stand-in dolt that
reports every port taken: Start makes five launches on five distinct
ports, starting with config.yaml's, then gives up. It is not refused
on the second move, and config.yaml stays unchanged.
- A frozen byte-for-byte literal of the config bd v1.3.0/v1.3.1
generates. The legacy render must equal it, and the policy must find
it eligible.
- The runtime config keeps placeholders and "$$" verbatim and is mode
0600, while the server dials the interpolated host.
- The give-up test asserts the policy is asked once, about the
operator's port.
- The missing-ready-line test timeout is raised to 30s for the slow
fake-dolt exec under race.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(dbproxy): classify a child that exits before its identity is captured
TestManagedPortConflictPolicy_ConsecutiveCollisions failed on the farm
with "capture child birth identity: procid: process is no longer
running", after 2 launches instead of 5. Its stand-in dolt reports
"Port N already in use." and exits immediately, and it exited before
Start captured its birth identity. Start treated that capture failure as
fatal, so an ErrPortInUse that Start could recover from became a hard
error. A real dolt that finds its port taken can exit just as fast, so
this race exists in the product, not only in the test.
Every spawn step before the child is handed to its supervising
goroutine (identity capture, root identity, pid record) now fails
through failSpawn. failSpawn kills and reaps the child; reaping also
drains its output into the watcher. The child's own exit then decides
the error:
- the child reported its port taken: ErrPortInUse, so the normal policy
and retry path runs;
- the child exited by itself for another reason: "exited (status N)
before startup completed";
- the child was alive and we killed it: the step's own error, as
before.
On Windows, a killed child reports an ordinary exit code, so there an
exit cannot be told from a kill. Only the port-in-use classification
applies there.
procid.Capture is reached through a package var so tests can make the
capture lose the race deterministically.
Tests, using a shell-script stand-in dolt that starts in milliseconds:
- a fast port-in-use exit that beats the capture is ErrPortInUse, and
with a policy it is retried up to the 5-port budget;
- a fast exit for another reason reports its status;
- a capture failure while the child is alive stays fatal and kills the
child;
- ten immediate port-in-use exits with the real capture are all
ErrPortInUse.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): run TestSharedServerConcurrent in the doltserver-cmd lane
TestSharedServerConcurrent was gated on BEADS_TEST_SHARED_SERVER=1, which
no CI job or Bazel target sets, so it skipped everywhere (the only
non-lane skip in //cmd/bd:bd_dolt_server_test). It predates the workspace
gate (#5093), and once enabled it failed immediately: in shared-server
mode every project's physical root is the one shared dolt dir, and bd init
holds that root's gate EXCLUSIVELY with a 5s wait, so concurrent inits of
different projects refuse each other ("bd init refuses to run over live bd
activity on this workspace"). That exclusivity is deliberate, and a single
init takes ~8s here, so the test now inits its projects one at a time; the
concurrent multi-writer workload phase, which is what the test exists for,
is unchanged.
- Also run when BEADS_TEST_SHARED_SERVER_CONCURRENT=1 (distinct from
BEADS_TEST_SHARED_SERVER, which scripts/test.sh also reads to start a
shared server).
- bd_dolt_server_test sets it with BEADS_TEST_SS_DIRS=2 and
BEADS_TEST_SS_CLIENTS=6: a bounded smoke (~50s, 3 writers per database)
against the lane's hermetic local dolt sql-server on an ephemeral port.
- Under BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 a server that cannot start
fails the test instead of skipping it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* build(bazel): size and shard //internal/storage/uow:uow_test for its configless run
uow_test timed out at the default medium 300s whenever it ran without a
lane config (`bazel test //internal/storage/uow:uow_test`, also on
origin/main). No CI lane runs it that way: --config=ci and
--config=integration set BEADS_TEST_SKIP=dolt, so its Dolt-backed tests
skip and the target takes 3-14s there (BEP of recent ci/integration
runs), and the full Dolt workload runs as uow_dolt_test (8 shards, slowest
~90s remotely on main) and uow_docker_test (4 shards, large).
Without a config nothing skips: every newTestUOWProvider test starts its
own dolt sql-server (~6-8s apiece) and the package needs ~7 min serially;
TestBatchApplyContract alone is ~1 min because BoundsTheItemCount applies
1000+1001 real items by design. That is the variants' workload, not a slow
test to fix, so give the base target the variants' shape: size = "large"
(900s) and shard_count = 4. Locally, on a host at load ~185, the shards
took 162-309s (unsharded it was killed at 300s); under --config=ci the
four shards still pass in seconds.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): reset cobra flags between in-process runs; keep them out of parallel tests
runBDInProcess and runBDInProcessAllowError execute the package-level
rootCmd tree again and again in one process, and cobra never resets a
flag between Execute calls: a value one invocation parsed (create's
--title, --labels, list's --status, ...) and its Changed bit stayed on the
FlagSet, so the next invocation saw it, and a slice flag that had been
set appended to the stale value instead of replacing it. With a Dolt test
server (the only setup in which these tests run) that failed about 20
TestCLI_* tests depending on suite order.
TestMain now snapshots every flag of the tree (snapshotCommandFlags,
after all init()s registered them, before any test runs) and both runners
put the tree back before and after each run (resetCommandFlags): the
pointee of each flag.Value is restored (for pflag's scalar types that is
the bound variable; for slice types it also clears the internal "changed"
bit, so the next Set replaces), slice contents via SliceValue.Replace,
and Changed=false. TestResetCommandFlagsRestoresEveryFlag sets every flag
of the real tree and checks the reset. The ad-hoc --title reset in
TestCLI_CreateRejectsEmptyTitle_ProxiedServerMode is no longer needed.
Seven TestCLI_Comment* tests called t.Parallel() around the runners.
inProcessMutex serializes the runners only against each other, so their
chdir, stdio swap, env and config re-initialization raced every other
parallel test (data races on config globals; TestCobraParallelPolicyGuard
failing to read its own source files after a concurrent chdir). They run
serially now, and the guard treats the two runners like rootCmd.Execute.
Also two stale TestCLI_Create* cases: DryRunWithRigPrefix exercised a
create --prefix flag that no longer exists, and the flag-like-title cases
passed "--help" or "--foo-bar" where cobra parses them as flags; they now
pass the title after "--", the only way it reaches create's own guard.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): fix the ADO round-trip and bulk-delete tests that rotted unseen
Both need the integration tag and a Dolt test server, which no CI lane
gave cmd/bd (BEADS_TEST_SKIP=dolt everywhere), so they failed unnoticed:
- TestADORoundTrip* stored ado.pat in the database. ado.pat is a secret
read only from config.yaml or AZURE_DEVOPS_PAT (config.IsYamlOnlyKey),
so the tracker found no PAT. The fixture sets AZURE_DEVOPS_PAT.
- TestBulkDeleteNoResurrection expected GetIssue to return (nil, nil) for
a deleted issue; the Dolt store reports storage.ErrNotFound.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): fix parity, completion and notion tests that only fail with a Dolt server
These are Dolt-gated (integration tag + test server), so no CI lane ran
them and they rotted:
- TestParityCreate*/TestParityReopenErrorExits1Silently: bd create
auto-routes via routing.DetectUserRole("."), which warns "beads.role
not configured (GH#2950)" on stderr when the working directory's git
config has no beads.role. The suite pins the configured case, so the
parity env now sets beads.role=maintainer in a test-owned global git
config ($XDG_CONFIG_HOME/git/config; the role lookup scrubs every
GIT_CONFIG_* variable, so those cannot be used).
- TestIssueIDCompletion: issueIDCompletion resolves a database path
before looking at the open store and returns nothing when there is
none; the test now sets dbPath to its store's path.
- TestIssueIDCompletion_UsesWorktreeFallbackWhenStoreNil and
TestGetNotionConfigReadsDBPathWhenStoreUnset: the code under test
reopens the store from metadata.json, which names a database but not
the per-test branch of the shared database that newTestStore uses, so
the reopened store saw none of the test's rows. They now use their own
database (newTestStoreIsolatedDB).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): fix stale doctor/e2e/autocommit/readonly Dolt-gated tests
These need the integration tag and a Dolt test server, which no CI lane
gave cmd/bd, so they rotted unseen:
- TestE2E_DoctorFixMetadataRoundtrip, TestE2E_MigrateDoltMetadata,
TestDoctorCheckHealthReportsVersionMismatchOnRepoLocalPort: bd init now
defaults to embedded mode, where `bd sql` and `bd dolt start` are
refused. Init with --server on a repo-local server of their own
(repoLocalServerEnv: the suite's shared-server port vars cleared, server
stopped at cleanup) and start it explicitly, since BEADS_TEST_MODE=1 never
auto-starts one. MigrateDoltMetadata's DELETE also needed `key` quoted.
- TestDoctor{Conventions,Pollution}MaxRows_EnvOnly_Exits2: bdRunRaw drops
every BEADS_* variable, so the subprocess hit dolt.New's test-database
firewall (exit 1) before the row cap; pass BEADS_TEST_SERVER=1.
- TestDoltAutoCommit_On_WritesAdvanceHead: the embedded engine keeps its
data under .beads/embeddeddolt, not .beads/dolt; findDoltRepoDir looks
in both.
- TestValidateCheck_AllClean: bd doctor validate runs five checks since
the cross-table duplicates check was added.
- TestConfigValidateReadOnlyIsHermetic: readonly commands take a shared
workspace gate, whose lock file (.beads/dolt.gate.lock) workspacegate
creates on first use by design; compare the .beads tree without gate
lock files.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): undo each in-process execution's env and storage-mode leaks
Every in-process run of the bd command tree (runBDInProcess and the many
tests that call rootCmd.Execute directly) leaves process state behind:
PersistentPreRun exports the selected workspace as BEADS_DIR, loads its
.beads/.env, and records the workspace's mode in serverMode /
proxiedServerMode. With a Dolt test server, later tests in the same shard
then resolved a deleted fixture ("no active beads workspace found",
"migration sidecar is missing"), ran subprocess bd against the wrong
workspace ("recorded as proxied-server in .beads/metadata.json"), or took
the proxied path in RunE-level tests ("proxied-server UOW provider not
initialized", a nil-UOW panic in reopenProxiedResolve that killed a shard).
TestMain now registers a cobra initializer/finalizer pair
(installExecuteIsolation) that snapshots the environment and the two mode
globals when an execution starts and restores them when it ends; the
runners' restoreEnvSnapshot shares the helper. TestDoltConfigEnvironmentOverrides
used os.Setenv + defer os.Unsetenv, which deleted the suite's
BEADS_DOLT_SERVER_PORT (the test server's port) for every later test; it
uses t.Setenv now.
Full integration-tagged cmd/bd suite against a hermetic dolt (16 shards):
18 order-dependent failures and the shard panic gone; the 27 remaining
failures all fail alone too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(init): keep --quiet quiet through the Claude/Codex/Cursor auto-setup
`bd init --quiet` ("Suppress output") still printed the project
integration installers' progress to stdout ("Installing Claude hooks for
this project...", "Claude Code integration installed", ...): the
installers write to os.Stdout unconditionally. Point stdout at the null
device around them while quiet; their failures keep going to stderr as
before. Found by TestInitCommand's quiet case, which asserts no output and
had not run in CI (Dolt-gated).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(init): bring the Dolt-gated init tests up to the current init contract
These tests need a Dolt test server, so no CI lane ran them and they
drifted from the product:
- Embedded is init's default mode, so the server-mode assertions
(.beads/dolt, opening the database on the test server, dolt_mode
"server" in metadata.json) now pass --server (TestInitCommand,
TestInitAlreadyInitialized, TestInitRedirect, TestInitBEADS_DIR,
TestInitDoltMetadata, TestInitDoltMetadataNoGit, TestInitDatabaseFlag's
metadata subtests). The in-process ones reset rootCmd's flags around
themselves so --server cannot leak into later in-process inits.
- Each server init gets its own --database: the suite shares one test
server, and a "test" database another test created belongs to another
project (init refuses: PROJECT IDENTITY MISMATCH).
- The marker tests seed a current-era version witness: the legacy-upgrade
guard refuses a non-empty .beads/dolt without one.
- The redirect test provisions the canonical target with config.yaml: bd
ignores a redirect to a directory with no project files (#4692).
- Shared-server inits get a free port of their own
(sharedServerTestEnv): the inherited BEADS_DOLT_SERVER_PORT is the
suite's test server, which a shared-server start refuses as another
project's, and the default shared port is 3308, a developer's live
server.
- --shared-server's config.yaml is now nested YAML (dolt: shared-server:
true); parse it instead of matching the old flat line.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): run the Dolt-gated tests that skipped on a bare dolt.New
setupTestDB (config, kv and Linear round-trip tests), setupGatedTestDB
(mol ready --gated) and the rename-prefix and bd sql tests opened stores
with dolt.New(&dolt.Config{Path: ...}): no server port, no
CreateIfMissing, so against a running test server they got "database ...
not found" and skipped as "Dolt server not available". They now use the
suite's newTestStore helpers (skip only when no test server runs), and
what that exposed is fixed test-side:
- TestCustomStatusConfig: custom_statuses is read back ORDER BY name;
look statuses up by name / expect name order.
- TestLinearRoundTripCoreFields, TestLinearPullMilestonesCreatesEpicHierarchy:
linear.api_key is a yaml-only secret (LINEAR_API_KEY), push now needs an
explicit linear.state_map, and batch push uses TeamLabels and
issueBatchCreate, which the mock server now answers.
- TestSqlCommand: bd sql refuses in the default embedded mode; set
serverMode for the server-backed store, and stop discarding RunE errors.
- TestE2E_AutoStartedRepoLocalServerPersistsAcrossCommands skipped on
this process's embedded mode although every bd it runs is a subprocess
on a --server workspace; gate on the dolt binary instead and stop the
auto-started server at cleanup.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): no fixed "unused" port, no swallowed JSON, no leaked front-door server
Three more things the Dolt-backed cmd/bd run exposed:
- TestTestServerConnection, TestSharedServerCfgNilHonorsSharedServer and
the two TestLegacyGuard* e2e tests pointed bd at 127.0.0.1:59999 as a
port nothing listens on. Any process on the host may hold it; a
listener that accepts and resets turns the expected "connection
refused" / "Dolt server unreachable" into another error. They take a
just-freed port from closedLoopbackPort (testutil.FindFreePort) now.
- TestDoltSetConfigJSONOutput and TestDoltSetConfigWithUpdateConfig
created .beads 0755, so bd's permissions warning landed in the JSON
under test and the tests skipped ("output not pure JSON") every run.
The fixture uses 0700, and non-JSON output fails instead of skipping.
- TestMigrateDoltModeFrontDoor's closing show/list auto-start a
repo-local server after the reverse migration; nothing stopped it, so
the suite's leak check failed (when the opt-in
BEADS_TEST_MIGRATION_FRONTDOOR suite runs). It stops it at cleanup.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* ci(bazel): advisory cmd/bd Dolt-server tier (bazel-cmd-dolt)
No CI lane ran cmd/bd's Dolt-gated tests (TestCLI_*, the init and
store-backed suites, the doctor/e2e tests): main.yml's integration shards,
nightly's Full Test Suite, and Bazel's --config=prcore/ci and
--config=integration all pass BEADS_TEST_SKIP=dolt, so cmd/bd's TestMain
never starts a test server and those tests skip; the proxied and embedded
tiers run only their manifests' tests. They rotted unseen.
//cmd/bd:bd_dolt_server_test (tag dolt-server-cmd) runs the whole
integration-tagged cmd/bd suite, the integration build's bd_test, against
a hermetic dolt sql-server: BEADS_TEST_DOLT_SERVER=local starts it from
the pinned dolt in the test wrapper's runfiles, and
BEADS_TEST_REQUIRE_DOLT_CONTAINER=1 fails the target instead of skipping
into a cached pass. No test selection: the Go binary shards itself over
every top-level test (32 shards), so each runs exactly once, and
check_testcases.py fails a shard that ran none. --config=doltserver-cmd
has exactly --config=integration's build flags, so the two lanes share
bd_test's compile; prcore/ci and integration exclude the tag.
bazel.yml's new bazel-cmd-dolt job runs it exactly where bazel-integration
runs (same if: remotely on the farm for same-repo PRs, fork-ro/fork-rw,
and locally with the read-only cache in mode cache for forks). It is
advisory: job-level continue-on-error keeps a failure out of the call's
aggregate (BAZEL), and pr.yml's ci-gate reads its result (BAZEL_CMD_DOLT)
but requires it only while the committed top-level flag
BAZEL_CMD_DOLT_REQUIRED is "true" (now "false"; flipping it is the one
change needed). bazel-gate.sh accepts its skip in modes skip and local.
Policy tests: a third lane category in TestBazelLaneIsGatedAlongsideLegacy
(bazelFlagGatedLanes: gate env wired, never statically required, added by
the run script exactly when the pinned flag is "true"), the gate
simulation over every mode with the flag off (advisory: nothing it
reports reddens the gate) and on (exactly a gated lane), the cache-mode
and execution-mode checks, the tag taxonomy and prcore/integration
exclusions, and TestBazelCmdDoltJob (job steps, timeouts, .bazelrc
config equal to integration's build with no dolt skip or test selection,
the target's dolt-server rules, and bd_test's env repeated).
Measured locally (all fixes in this series, 32 shards, 16 at a time on a
shared host): 3267 top-level tests, all shards pass, max shard 313s (one
5001-issue export test, 214s, sets it), mean 100s.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(init): hand the project installers a writer instead of swapping os.Stdout
The --quiet fix earlier in this series pointed the process-global
os.Stdout at the null device around the Claude/Codex/Cursor installers.
That works, but it mutates a global from inside a cobra Run: anything else
writing to stdout meanwhile (a goroutine, a future concurrent installer)
would vanish, and a concurrent read of os.Stdout is a data race.
The installers already write through env structs with stdout/stderr
fields. setup.ProjectInstallOutput carries the two writers, and
InstallClaudeProjectTo / InstallCodexProjectTo / InstallCursorProjectTo
use them (the old entry points keep the process streams). init passes
QuietProjectInstallOutput() under --quiet: progress discarded, error lines
still on stderr. The proxied-server init path (domain adapter
InstallClaudeProject now takes quiet) does the same, so its
"Installing Claude hooks..." is quiet too.
Consistent error policy under --quiet: errors still reach stderr. init's
own "Warning: failed to setup <installer>" lines were suppressed under
--quiet while the installers' "Error:" lines were not, and some installer
failures (Cursor rules) print nothing themselves; the warnings now print
whether or not quiet, like the installers' errors.
Coverage in required lanes: TestProjectInstallersReportToTheGivenOutput
(cmd/bd/setup) and TestEmbeddedInitA/basic, which now asserts that
`bd init --quiet` with agents enabled installs the Claude hooks and prints
none of the installers' progress (verified to fail with the quiet output
disabled).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(export): exercise the incremental-export fallback with a small threshold
TestTryIncrementalExport_ThresholdExceededFallsBack seeded
incrementalExportThreshold+1 = 5001 issues to cross the threshold. Batch
create is one transaction but still several statements per issue, so under
-race against the shared test server it took ~214 s, the longest test in
cmd/bd's Dolt-backed suite by far. The behaviour under test is only
"more changed issues than the threshold -> full export fallback".
incrementalExportThreshold becomes a var (same value), and the test, which
is not parallel, sets it to 20 and seeds 21 issues: 214 s -> 0.6 s.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): tighten the flag-reset self-test, guards and canaries
Review follow-ups:
- TestResetCommandFlagsRestoresEveryFlag no longer skips a flag it cannot
set: a flag type without a sample value, a Set error, or a non-pointer
Value (which resetCommandFlags could not restore) is an error, so a new
flag type cannot go untested. resetCommandFlags documents that it also
resets flag-bound package globals.
- TestCobraParallelPolicyGuard treats .ExecuteC/.ExecuteContext/
.ExecuteContextC like .Execute (the per-execution isolation writes the
mode globals; a parallel execution would race).
- TestConfigValidateReadOnlyIsHermetic ignores only the gate a readonly
command takes (.beads/dolt.gate.lock and its .info sidecar), not any
"*.gate.lock*" file, so a new unexpected gate still trips the canary.
- TestCLI_CreateRejectsFlagLikeTitles: a bare `bd create --foo-bar` must
fail and create no issue (bd-2c0's intent), next to the "--" cases.
- TestCustomStatusConfig cites why statuses come back in name order: the
normalized custom_statuses table (#2961, 8537d943b) has no ordinal and is
read ORDER BY name, like custom_types; the test predates it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* ci(bazel): run the cmd/bd Dolt-server tier in 16 shards
Each shard pays ~30-40 s of fixed cost (TestMain plus its own dolt
sql-server), so 32 shards spent roughly 40% of the lane's executor time on
setup and added 32 farm actions to every PR touching cmd/bd. With the
5001-issue export test cut to under a second, 16 shards measure (locally,
--nocache_test_results): max 186 s, mean 137 s, 2,187 executor-seconds
(vs ~2,800-3,200 at 32), all 3,267 top-level tests, every shard passing.
TestBazelCmdDoltJob pins the count; bazel.yml's timing comment is
restated (cache mode ~20-30 minutes).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(proxy): fail fast with a MySQL error when the external upstream is unreachable
A proxied-server command against a stopped external Dolt upstream stalled
~20-30s before failing with a bare "invalid connection". The local db proxy
stays up, so on a refused backend dial (or a front such as stunnel/socat
that accepts and closes because its own upstream is gone) it simply closed
the client connection. The MySQL driver reports that as invalid
connection / unexpected EOF, which the uow bootstrap ping (#6003) classifies
as a transient drop and retries with exponential backoff for its whole 30s
budget. Retrying cannot help: the proxy already proved the upstream at its
own startup, and the outage is the upstream's.
The proxy now answers such a connection itself with a MySQL ERR packet
(2003, HY000) in place of the server greeting, naming the upstream and the
cause, exactly as a real server refuses a connection before the handshake.
The driver surfaces it as a *mysql.MySQLError, which the bootstrap retry
already treats as permanent, so the command fails in ~0.1s with an
actionable message. Only shapes that prove the upstream is not serving
qualify: ECONNREFUSED/ENOENT/EHOSTUNREACH/ENETUNREACH on dial, or a backend
that reaches EOF having sent zero bytes (a MySQL server always speaks
first). A dial timeout or a drop after the greeting keeps the plain close
and the client's transient retry.
External backends only: a managed (local sidecar) backend is owned by the
proxy and its dial can be refused transiently while bd drives it (the
full proxied lane caught TestProxiedServerInitExplicitBeadsDirIsAuthoritative
hitting exactly that mid-init when this applied to every backend), so
managed backends keep the bare close and the client's bootstrap retry.
TestExternalProxyOutageAndRestoreReDialsTCPAndUnix asserted the old
silent close during an outage; it now asserts the ERR packet.
With the latency fixed, TestProxiedOutageReconnectAcceptanceMatrix is
renamed into the proxied discovery pattern as
TestProxiedServerOutageReconnectAcceptanceMatrix and placed in the Bazel
30-shard block by gen_proxied_shard_manifest.py's incremental --write
(shard 8). The frozen legacy 15-shard block is untouched; the test
hash-distributes there like every other test added since it was frozen.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(proxy,uow): retry the proxy's upstream-outage report for ~1s; hedge the zero-byte case
Review follow-up to the fail-fast change.
A zero-byte close from the upstream is not proof it is down: Dolt closes
queued connections without a byte when max_connections/back_log are full,
when a queued connection times out, and while it shuts down for a
restart; an L4 front does the same while its target is replaced. Its
report now says "closed the connection before the MySQL greeting (down,
restarting, or at its connection limit)" instead of "unreachable", and
the comment no longer claims proof.
Refusals and endpoint churn also lost #6003's retry entirely, so an
external Dolt restart or a Service with no ready endpoints failed a
command at once. The client now retries the proxy's report
(proxy.IsUpstreamOutageError: 2003 with the "beads db proxy: " prefix)
for upstreamOutageRetryWindow (1s) from the first time it sees it, with
the backoff clamped so the last attempt lands at the window's end; other
transient errors keep the 30s budget. A real outage still fails in about
a second, inside the acceptance test's 3s bound.
Also: the dial report drops Go call-site wrapping ("dial tcp H:P:
connection refused"), truncation keeps UTF-8 intact, the comment states
how the packet differs from a real server's pre-handshake ERR (keeps the
'#'+SQLSTATE marker for vitess; 2003 is a client code chosen on purpose),
a Stats counter for reported outages, and the isTransientPingError
paragraph is reflowed and corrected.
Tests: pingWithRetry retries the report inside the window and gives up
at its end without using the full budget; openDB against a front that
plays the proxy (its real packet) and comes back 300ms after the first
connection succeeds in one call, and fails in about the window when it
never does; NewProxyServer enables the report for external backends
only; the dial message carries no Go type names; rune-safe truncation.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(proxied): fail, not skip, socat-bridged subtests in the Bazel lane
The external-unix front-door matrix subtest and both outage/reconnect
matrix subtests bridge an external endpoint with socat and skipped when
it was missing, so they could stop running without anyone noticing (the
parent test still passes). requireSocat now fails them when
BEADS_TEST_REQUIRE_SOCAT=1, which //cmd/bd:bd_proxied_test sets (its
remote workers have socat; a recent main run's external-unix subtest
passed there). The legacy GitHub 15-shard jobs have no socat and leave
it unset, so the subtests keep skipping there. The check now runs before
the upstream Dolt server is started, so a skip no longer pays for one.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* ci(proxied): measured weight for the outage matrix; pin it to legacy shard 1
Give TestProxiedServerOutageReconnectAcceptanceMatrix a duration entry
(80s: local runs measured 55-79s alone, 60-70s in its shard, and review
68-109s under load) and re-place it with the generator's incremental
--write: it moves from 30/8 to 30/11, one line, nothing else moved. The
heaviest estimated shard is now 435s against a ~357s median; a repack
would even that out but moves most assignments, so it is left to a
separate CI-only change that refreshes all durations together.
Legacy 15-shard block: the test would hash onto shard 14, already ~13.5
of the 15 min timeout on main. It is pinned to shard 1 (~6.5 min in
recent main runs) under the block's reviewed-pin rule; it skips there
today (no socat), and the pin keeps shard 14 safe if that changes.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(delete): drop stale TestDeleteIssueUnsupportedStorage
The test asserted that deleteIssue returns "delete operation not supported
by this storage backend" when the global store is nil. That error came
from a type assertion to a deleter interface that a5da57e39 (Phase 7:
remove storage factory/memory backend/provider abstraction) removed:
store is now storage.DoltStorage, whose method set always includes
DeleteIssue, so there is no unsupported backend left to report. With the
assertion gone, the test's nil store is just a nil-interface method call
and panics at deleteIssue, killing the whole cmd/bd test binary.
The nil store is not reachable in production: deleteIssue's only caller
(bd doctor --check=pollution --clean) has already queried the store to
find the issues it deletes. So the test constructs an impossible state
for a removed behavior; delete it rather than reintroduce a dead branch.
No CI lane ran it: it needs the integration tag and a Dolt test server
(testDoltServerPort != 0), and every integration lane that builds
cmd/bd (main.yml integration cmd/bd shards, nightly Full Test Suite,
bazel --config=integration) sets BEADS_TEST_SKIP=dolt, while the
proxied/dolt-server lanes run only their TestProxiedServer*/
TestServerMode* manifests. It only ran in local integration runs with
Docker or a matching dolt.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): build the fallback bd by package path, independent of CWD
When BEADS_TEST_BD_BINARY is unset, buildEmbeddedBD and its sibling
helpers fall back to `go build -tags gms_pure_go -o X .`, which builds
whatever package is in the process's working directory. That is cmd/bd
only if the first caller of the sync.Once has not chdir'd into a fixture
and the test binary was started in cmd/bd. A precompiled test binary run
from the repo root (the pr-risk pattern) builds the root library package
instead: go writes a non-executable archive to X and the test dies with
"fork/exec .../bd: permission denied" (reproduced with TestEmbeddedCount).
Add goBuildBDCommand: the same non-race -tags gms_pure_go build CI
prebuilds BEADS_TEST_BD_BINARY with, naming
github.com/steveyegge/beads/cmd/bd explicitly and running in cmd/bd's
source directory, resolved at package init (this file's compiled-in path,
else the start-up working directory) before any test can chdir. Use it in
buildEmbeddedBD and the other copies of the pattern (cli_fast,
doctor_repair, explicit_db_nodb, init_permissions, scripttest,
shared_server, buildBDForInitTests); migrationFrontDoorBinary keeps its
untagged cgo build but gets the same package path and directory.
TestGoBuildBDCommandIsCWDIndependent checks it from a chdir'd temp dir
with go list (no link).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(cmd/bd): stop in-process bd from leaking BEADS_DIR into later tests
TestResolvedConfigRepoRoot's two CWD-discovery subtests ("uses local
workspace from subdirectory", "uses worktree fallback when local .beads
is absent") failed in full cmd/bd runs with "no active beads workspace
found" but passed alone. Cause: runBDInProcess / runBDInProcessAllowError
run rootCmd.Execute in the test process, and PersistentPreRun exports the
selected workspace with a raw os.Setenv("BEADS_DIR", ...) that nothing
restores. After any TestCLI_* test, BEADS_DIR still names that test's
since-deleted bd-cli-test-* fixture; FindBeadsDir honors an explicit
BEADS_DIR before walking from CWD, finds nothing there, and reports no
workspace. Minimal repro: -run '^(TestCLI_Ready|TestResolvedConfigRepoRoot)$'.
The leak also broke later TestCLI_* tests themselves: with
-run '^(TestCLI_.*|TestResolvedConfigRepoRoot)$' against a Dolt test
server, failures drop from 47 to 20 with this change and no new ones (the
remaining 20 are leftover cobra flag values between in-process runs, a
separate issue).
- runBDInProcess(AllowError): snapshot os.Environ() around Execute and
restore exactly the keys it changed (restoreEnvSnapshot).
- TestResolvedConfigRepoRoot: clear BEADS_DIR (t.Setenv) in the two
subtests that test CWD discovery, so neither a leak nor a developer's
exported BEADS_DIR decides them.
Not host-specific (HOME, global git config and ceilings play no part),
and CI never saw it: the TestCLI_* leakers need a Dolt test server, and
every CI lane that runs cmd/bd's integration tests sets
BEADS_TEST_SKIP=dolt, so they skip and BEADS_DIR is never set.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* test(delete): expect storage.ErrNotFound after delete in TestDeleteIssueWrapper
"successful issue deletion" asserted that GetIssue returns (nil, nil)
for a deleted issue; the Dolt store reports a missing issue as
storage.ErrNotFound, so the subtest failed with "GetIssue failed: not
found: issue test-xxx" whenever it ran. Like TestDeleteIssueUnsupportedStorage
it needs the integration tag and a Dolt test server, which no CI lane
provides to cmd/bd (BEADS_TEST_SKIP=dolt), so it rotted unseen.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TestSharedServerModeServeGlobalReportsTheServedDatabase was parked outside
the proxied discovery pattern because `bd serve --global` exited 1 on the
#5920 shared-store migration guard (v65 -> v69). The guard was right; the
test setup was wrong.
The workspace was a plain `bd init --server --server-port <test server>`
that only flipped BEADS_DOLT_SHARED_SERVER=1 afterwards. Shared-server
mode deliberately ignores the workspace's own dolt_server_port and
resolves the machine-wide shared server (BEADS_DOLT_SERVER_PORT, the
shared port file, ..., then the 3308 default), so every --global command
dialled 127.0.0.1:3308 rather than the hermetic test server. On CI nothing
listens there; on a developer machine running a real shared server, the
test read that server's own beads_global (created by an older bd at v65)
and serve asked to migrate it. beads_global was also never provisioned on
the test server, because only `bd init --shared-server` does that.
Set the workspace up the way an operator joins an externally-managed
shared server: `bd init --shared-server --external` (provisions
beads_global on the test server at the current schema) plus
BEADS_DOLT_SERVER_PORT naming that server. No product change: the guard
correctly refuses an un-consented migration of a shared database, and a
freshly created one (version 0) passes it.
Rename the test into the TestServerMode* discovery pattern and add it to
the Bazel 30-shard block via the generator's incremental --write. The
frozen legacy 15-shard block is untouched; the name hash-distributes there
(shard 12/15).
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TestProxiedServerSQLDatabaseFlag (and its sibling
TestProxiedServerMultiStatementSQL) flaked in the proxied-server tier with
bd init --proxied-server failed: exit status 1
[mysql] packets.go:58 unexpected EOF
Error: failed to open uow provider: uow: ping db: dial tcp ...: connection refused
Both called bdProxiedInit with no backend flags, so every run spawned a
managed-local dolt sql-server. Its port is picked bind-and-close
(proxy.PickFreePort) when bd init writes the managed config and bound by
dolt only after the proxy child runs dolt config/init and boots the
server. Under the parallel tier another process can bind that port in the
gap. dolt then logs "Port N already in use." and exits, but
DoltServer.waitReady and the proxy's waitForServerReady only dial the
port, so they accept the foreign listener and the proxy publishes
proxy.pid. Its 100ms backend health check then sees dolt gone and shuts
the proxy down: init's first ping gets EOF, and every retry for the
rest of the 30s budget gets connection refused.
These tests cover bd sql, not the managed-local lifecycle, so move them
to newSharedProxiedProject like most of the suite. The shared server's
startup (testutil.localDoltServer) waits for dolt's own ready line and
retries on a new port, so it does not have this race. The second
database name now comes from the project's unique database, because the
server is shared.
The product race in the managed-local backend (dial-only readiness plus a
bind-and-close port) is unchanged. The code already marks it as deferred
in PickFreePort.
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
TestProxiedServerShowWatch/deleted_issue_polls_stay_quiet flaked with
"stdout grew after the delete" (PR #7139 run 37146882037, shard 25/30).
exec.Cmd copies Stdout and Stderr through two independent goroutines
reading two independent OS pipes, so there is no happens-before
relationship between the stderr "Watching for changes..." banner and
the render's own trailing bytes landing in the stdout buffer.
proxiedRenderIssue's final line is an unconditional trailing
fmt.Println, written after dependency/comment lookups, so the first
render's tail can still be in flight on the stdout pipe after the
banner already confirms the render started; capturing a "no growth"
baseline right after the banner is racy.
Reproduced directly via Bazel (--runs_per_test=40..50,
--local_test_jobs up to 80): 2/40 and 2/50 failures, with diagnostics
confirming "after" was just the tail of the first render's trailing
DESCRIPTION/blank-line output.
Fix the test's synchronization instead of the product: ping
watchBannerWriter.renders on every write (not just banner increments)
and add waitForQuiet, which blocks until a stream has been idle for a
bounded window. The delete subtest now waits for stdout to go quiet
after the banner before taking its "before" baseline, so the first
render has fully landed before growth is measured. No product code
changed; the "no output growth after delete" property is unchanged.
Verified: 60/60 and 80/80 runs clean post-fix (0/140), versus the
pre-fix reproductions above.
Note: an independent upstream PR (#7141, bee/show-watch-stdout-race)
also fixes this race via a different os.Pipe-based approach; this
commit addresses it independently per this worktree's task scope.
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
* ci(bazel): embedded-Dolt tier 20/5 -> 40/14 duration-balanced shards (F1)
Give the Bazel-only bazel-embedded job its own duration-balanced manifest
blocks for //cmd/bd:bd_embedded_test (20 -> 40 shards) and
//internal/storage/embeddeddolt:embeddeddolt_embedded_test (5 -> 14
shards), decoupled from PR Risk's/main.yml's legacy frozen 20/5-shard
fork/push jobs, mirroring F2's bd_proxied_test precedent.
- Measured every TestEmbedded* / embeddeddolt test's wall time in
isolation; split 21 cmd-tier and 1 storage-tier single top-level test
over 180s into disjoint sub-tests (3 irreducible exceptions left:
TestEmbeddedUpdateConcurrent 475s, TestEmbeddedCloseConcurrent 308s,
TestLargeBatchApplyStatementCounts712_Embedded 261s).
- New scripts/ci/gen_embedded_{cmd,storage}_shard_manifest.py +
_embedded_shard_manifest_lib.py generate/check duration-balanced
manifest blocks (LPT packing, incremental --write/--repack, exact-once
--check), chosen at N=40/M=14 where the heaviest shard reaches the
irreducible-test floor.
- Fixed 18 stale legacy 20-shard cmd manifest entries (and 1 storage
entry) left over from earlier test splits, which would have hard-failed
every shard of PR Risk's real test-embedded-cmd jobs on their next run.
- New scripts/embedded_shard_count_test.go policy tests tie the
Bazel-only block's shard count to bazel.yml's check_shard_coverage.py
argument and catch generator staleness; generalized
TestBazelRetiredLanesCheckListedTestsRan's live-shard-count dispatch
from bd_proxied_test-only to a map covering both embedded targets;
removed TestBazelEmbeddedJobMirrorsEmbeddedTier's now-invalid
BUILD.bazel-shard-count-equals-PR-Risk-matrix assertion.
- Verified: go test ./scripts/..., bazel test //scripts:scripts_test,
actionlint, make ci-pr-policy, make bazel-sync-check all pass; full
local bazel test of both targets at 40/14 shards passes 2/2; mutation
testing confirms each new/changed policy test fails exactly when it
should.
See ~/beads-bazel-plan/f1/impl-report.md for full detail.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(embedded-dolt): skip 712-item statement-count assertion under -race (F1)
TestLargeBatchApplyStatementCounts712_Embedded genuinely costs ~260-300s
under -race (confirmed by solo re-measurement: 298.60s) -- 14014 real SQL
statement round-trips through the race-instrumented in-process Dolt engine,
not an artifact and not splittable (one indivisible ApplyBatchInTx
transaction). It was the storage tier's single-test floor for CI shard
packing.
Apply the exact precedent TestLargeBatchApplyWallClock_Embedded already set
for its 1000-item shape: skip this assertion under raceEnabled (the cost is
race-instrumentation overhead on the Dolt engine's own internal
goroutine/lock machinery, not this test's own logic) and extend nightly.yml's
"Embedded Dolt batch-apply suite (non-race)" step's -run regex so the full
pinned 14014-statement baseline still runs, non-race, every night. Verified
directly: under -race the assertion now skips in 0.00s; without -race it
still runs and asserts Total=14015 (within the existing +/-2 tolerance) in
36.76s.
Updates scripts/ci_workflow_test.go's
TestNightlyFullTestRunsEmbeddedDoltBatchApplySuite to match the extended
regex.
Storage tier's new single-test ceiling under the per-PR -race lane drops
from ~260.7s to 152.38s (TestBatchApplyContract).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* ci(bazel): correct cmd-tier long-pole durations, re-pack embedded manifolds (F1)
Investigated coordinator item 2 (single-test long poles): TestEmbeddedUpdateConcurrent
(recorded 475.39s) and TestEmbeddedCloseConcurrent (recorded 308.06s), plus
the two other >180s cmd-tier entries from the same capture
(TestEmbeddedInitA 196.94s, TestEmbeddedEpicCloseEligibleReason 192.47s).
Root cause: NOT host contention, NOT backoff/retry sleeps (bdRunWithFlockRetry
contributes negligibly), NOT race-instrumented-subprocess overhead alone.
These numbers were captured via `bazel --nohome_rc test --config=embedded`
with the then-current 20-shard legacy manifest (~10-11 tests/shard) and
`-test.parallel=4`. Go's t.Parallel() starts each parallel test's elapsed
clock when its function is invoked, before the Parallel() call blocks it
waiting for a free one-of-4 slot -- so a test queued behind several other
heavy shard-mates has that queueing wait baked into its own recorded
`--- PASS: TestX (Ys)` time. This is shard-composition-dependent scheduling
delay, not a cost intrinsic to the test.
Confirmed two ways in an isolated clone (not this worktree, per the
no-plain-go-test-from-a-beads-checkout rule):
- Solo (no rivals at all): 151.83s / 106.48s / 63.58s / 66.08s.
- All four together with the real -race -test.parallel=4 flags and exactly
4 tests requested (so nobody queues -- parallel slots == test count):
141.34s / 113.80s / 69.79s / 74.63s.
Both agree closely and both are far below the capture-time numbers.
F1's LPT packer already isolates the heaviest tests into shards with few or
no other heavy rivals (TestEmbeddedUpdateConcurrent lands alone in its own
40-shard-block shard), so under the new manifest these tests see little to
no queueing delay in real CI. None of the four needed splitting, parallel
subtests, or raceEnabled-scaled N: once correctly measured, none exceeds the
180s single-test guideline (new corrected weights: 155.0 / 115.0 / 72.0 /
77.0s). Corrected scripts/ci/embedded_cmd_test_durations.json accordingly
(with a doc-comment explaining the methodology and both confirmations) and
re-packed the 40-shard Bazel-only block (--repack --write); --check passes
(exact-once coverage of all 241 discovered tests). The frozen legacy 20-shard
block is untouched and independently re-verified exact-once by simulating
embedded-test-shard.sh across all 20 shards (241/241 tests, no
duplicates/misses/errors).
New cmd-tier single-test ceiling: 179.47s (TestEmbeddedCloseAlreadyClosed,
likely itself somewhat inflated by the same mechanism but already under the
180s line as recorded, so no action needed).
Also updates scripts/ci/embedded_storage_test_durations.json: the prior
commit's raceEnabled-skip for TestLargeBatchApplyStatementCounts712_Embedded
means it now costs ~0s in the per-PR -race lane bazel-embedded actually
packs for (not its real ~260-300s non-race cost, which nightly.yml still
exercises) -- weight set to 1.0 with a doc comment tying it to the skip in
large_batch_apply_measure_test.go. Re-packed the 14-shard Bazel-only block
accordingly; --check passes (exact-once coverage of all 387 discovered
tests, excluding TestMain/TestConformance per that file's existing
convention). The frozen legacy 5-shard block is untouched and independently
re-verified exact-once via embedded-storage-test-shard.sh simulation
(388/388 tests, no duplicates/misses/errors).
Verification: go test ./scripts/... (includes the nightly.yml policy test),
make ci-pr-policy, make bazel-sync-check, actionlint all pass. Real local
`bazel --nohome_rc test --config=embedded //cmd/bd:bd_embedded_test
//internal/storage/embeddeddolt:embeddeddolt_embedded_test`
(--local_test_jobs=8, both targets together, on a shared/noisy sandbox host)
passes both targets; per-shard wall time from each shard's test.xml: cmd/bd
max 218.9s (shard 23/40, min 20.6s), storage max 251.1s (shard 5/14, min
0.98s) -- down from the prior oversubscribed sweep's 783.41s / 351.94s and
well under the single-test-floor-based ~475s projection this slice started
from. Projected tier lane time (max of the two targets, real dedicated CI
runners should do at least this well): ~251s, under the 5-minute target.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* test(embedded): un-vacuous TestEmbeddedDepB edges, split epic-close test, trim concurrency stress N (F1 review)
Coordinator review follow-ups on the F1 embedded-Dolt resharding slice:
- TestEmbeddedDepB (one of TestEmbeddedDep's two CI-speed split halves) was
asserting its tree_* subtests against an edgeless graph, passing
vacuously; restores the same parent-child/blocks edges TestEmbeddedDepA
builds so those subtests exercise real multi-node traversal (review S2).
- TestEmbeddedEpicCloseEligibleReason split into
TestEmbeddedEpicCloseEligibleReasonFlag/...Output for CI shard balance,
matching the project's established single-concern split pattern.
- TestEmbeddedUpdateConcurrent/TestEmbeddedCloseConcurrent's
issuesPerWorker reduced 5->2: under real concurrent-shard-load
measurement these were genuine (not queueing-artifact) serialized-write
costs; 2 preserves every invariant the test checks (duplicate-ID
detection across all workers, one non-decreasing-list-count check per
worker) at a fraction of the serialized work.
- large712ShapeName: the 712-shape's race skip and its zero-match guard now
share one named constant instead of two independent literal shape-name
strings, so a future rename of the shape can't silently skip the pinned
statement-count assertion under race (review N2).
- Comment-only fixes (review N5) in files referencing test names since
renamed/split by this slice's earlier work: close_proxied_integration_test.go,
graph_apply_test.go, storage_class_proxied_integration_test.go,
tests/regression/discovery_test.go, plus doc-comment path cleanups (N1:
drop unverified ~/beads-bazel-plan paths/bead ids in favor of the
committed duration JSON files and engdocs/TESTING.md).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* ci(bazel): re-derive embedded-Dolt durations under concurrent load; cap cmd shards at Bazel's 50-shard limit (F1 round 2)
Coordinator review required re-deriving every per-test duration weight from
a single, consistent, CI-realistic measurement (all shards running
concurrently, -test.parallel=4, race-enabled) instead of the prior pass's
mix of crowded-shard captures and solo/4-together spot-corrections, and
required measuring per-shard wall time via BEP testAttemptDuration rather
than a shard's outer test.xml <testsuites time> (which can include a
different, already-finished shard-mate's setup/teardown).
- scripts/ci/embedded_cmd_test_durations.json (242 tests) and
scripts/ci/embedded_storage_test_durations.json (387 tests) rewritten in
full from one consistent sweep. Every entry is now a fresh measurement;
none is a carried-over capture-time value or an unverified estimate. Both
files' _comment blocks retract the earlier "queueing delay baked into a
test's own reported elapsed time" theory (testing.go's (*T).Parallel does
not add wait time to a blocked test's own clock) and document the real
methodology.
- Only one cmd-tier test remains over 200s (TestEmbeddedListFiltering,
239.70s), already under the ~240s ceiling; no further top-level splits
were needed this round.
- New finding: Bazel hard-caps shard_count at 50 per sh_test-like rule
("Having more than 50 shards is indicative of poor test organization";
a native analysis-time limit, not configurable). The previous 88-shard
plan for //cmd/bd:bd_embedded_test (chosen as the LPT-packed floor before
this limit was discovered) is reverted to 50, Bazel's real ceiling.
Repacking the fresh weights at 50 shards gives a heaviest shard of
409.6s -- above the single-test floor of 239.7s, because 50 bins is not
enough headroom over the suite's ~20145 measured test-seconds to flatten
every bin to that floor. This makes the <=5 min lane target unreachable
for the cmd tier via resharding alone within Bazel's native per-rule
limit; see ~/beads-bazel-plan/f1/impl-report.md section 3c for the full
writeup and the two remaining levers (suite-wide speedups or a
multi-Bazel-rule split), neither attempted in this slice.
- internal/storage/embeddeddolt gets 15 Bazel-only shards (unaffected by
the 50-shard cap): LPT-packed heaviest shard 225.3s, within target.
- cmd/bd/BUILD.bazel, internal/storage/embeddeddolt/BUILD.bazel,
.github/workflows/bazel.yml, engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md,
scripts/embedded_shard_count_test.go, scripts/pr_risk_bazel_coverage_test.go,
scripts/ci/gen_embedded_cmd_shard_manifest.py updated to the corrected
50/15 shard counts (and, for the generator, N3: --write without an
explicit total_shards now errors instead of silently regenerating the
frozen legacy 20-shard block).
- .github/scripts/embedded-{cmd,storage}-test-shards.txt: re-packed
Bazel-only blocks at 50/15; frozen legacy 20/5 blocks untouched except for
N5 fixes to stale entries left by this slice's earlier test splits
(TestShardScriptsListOnlyRealTests catches this class of bug; both
legacy blocks reconfirmed exact-once).
- .github/workflows/nightly.yml / scripts/ci_workflow_test.go (N4): the
embedded-dolt batch-apply nightly step now runs with `if: ${{
!cancelled() }}` and its own explicit `-timeout 20m`, independent of the
job-level timeout, with both halves now asserted by
TestNightlyFullTestRunsEmbeddedDoltBatchApplySuite.
Verified: gofmt -l clean, go vet ./scripts/... clean, go test ./scripts/...
green, both generators' --check pass at 50/15 (and legacy 20/5 remain
exact-once via the frozen-block invariant).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* test(ci): rename embedded manifest staleness tests out of the ^TestEmbedded skip
The allowlisted go-test leg runs with -skip ^TestEmbedded, so tests named
TestEmbedded*ShardManifestGeneratorNotStale never ran there and the leg
failed with "matched no test that ran".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
* ci(bazel): raise proxied-server tier from 15 to 30 shards (F2)
bazel.yml's bazel-proxied lane (//cmd/bd:bd_proxied_test, run only with
remote execution) was sharing PR Risk's legacy 15-shard, frozen
bd-init-cost-proxy manifest block, so its longest shard was the long
pole of the Bazel-only lanes. Give it its own 30-shard block in
.github/scripts/proxied-cmd-test-shards.txt, bin-packed
longest-processing-time-first by measured wall-time
(scripts/ci/proxied_test_durations.json, captured from two bazel-proxied
job failures' testlogs) instead of the bd-init count proxy, via
scripts/ci/gen_proxied_shard_manifest.py's new --weights=duration mode.
Coverage is proven equal to the full discovered test set by two
independent methods (sorted-name diff and an actual 30-shard invocation
of proxied-test-shard.sh in list-only mode), both exact matches with no
duplicates.
cmd/bd:bd_proxied_test's shard_count moves to 30; PR Risk's and
main.yml's own test-proxied-cmd jobs keep their 15-shard matrix and
frozen manifest block untouched, per D2's retirement design (the Bazel
lane only needs to run the same tests, not the same split). Updated the
two coupled policy tests (scripts/ci_workflow_test.go's
TestBazelDoltServerTiersMirrorPRRisk, scripts/pr_risk_bazel_coverage_test.go's
TestBazelRetiredLanesCheckListedTestsRan) to allow the Bazel target's
shard_count to differ from its legacy job's own matrix size, and
engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md / engdocs/TESTING.md to document
the split.
Verified: go test ./scripts/...; bazel --nohome_rc test
//scripts:scripts_test; actionlint on bazel.yml; make bazel-sync-check;
make ci-pr-policy; 3 representative shards (1, 15, 30 of 30) run
directly against Bazel-built race bd_test/bd_for_tests binaries and the
pinned dolt 2.2.0 release, all green, 55-81s wall time each (the
duration data's absolute seconds are from a contention-era sample and
run far faster here; the LPT balance itself, not the absolute SLA, is
the property that matters).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ci,bazel): close fork-PR gap in proxied 30-shard manifest validation (review B1/S1)
TestShardScriptsListOnlyRealTests only ran proxied-test-shard.sh at PR
Risk's legacy 15-shard matrix, never at the Bazel-only bazel-proxied
lane's 30-shard manifest block. bazel-proxied only runs in mode=remote
(skipped on fork PRs), so a fork PR could rename, duplicate, or corrupt
a TestProxiedServer*/TestServerMode* manifest entry in the 30-block and
merge green via go test ./scripts/... (which runs on every PR), only
breaking the required lane afterward on main and every same-repo PR.
Fix: the test now computes every shard total it must validate per
script (this job's own PR Risk matrix size, every distinct total found
in that script's own committed manifest, and - for proxied-test-shard.sh
- cmd/bd:bd_proxied_test's live shard_count from BUILD.bazel) and runs
the full per-shard validation loop at each one, relying on the script's
own duplicate/stale-name guards. It also sums each total's "manifest: N"
counts across all shards and fails if they sum to zero, catching a
silently-deleted block that would otherwise fall back to 100% hashing
undetected.
Also fold in S1: replace the independently hard-coded `30` overrides in
ci_workflow_test.go and pr_risk_bazel_coverage_test.go with
bazelProxiedShardCount(t), a new shared helper that reads
cmd/bd:bd_proxied_test's shard_count live from cmd/bd/BUILD.bazel. This
turns the check_shard_coverage.py argument comparison in
pr_risk_bazel_coverage_test.go into a genuine cross-file pin (BUILD.bazel
vs bazel.yml) instead of two literals that could drift together
unnoticed. ci_workflow_test.go's tiers loop no longer asserts
BUILD.bazel's shard_count against a value read from the same file
(tautological); it instead asserts pr-risk.yml's and main.yml's legacy
test-proxied-cmd matrices equal each other, restoring the pin S1 found
removed on this branch relative to base.
Verified against the reviewer's mutations (duplicate entry, bogus
entry, whole-block deletion, stale rename, matrix divergence, BUILD
shard_count drift, bazel.yml arg drift): each now fails go test
./scripts/..., where it previously passed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ci,bazel): add generator --write/--check and freeze legacy manifest block (review S3/N1/N4/N5)
gen_proxied_shard_manifest.py:
- Add --write (rewrite only the target total_shards block in place,
leaving every other block's header/body text untouched) and --check
(regenerate in memory and diff against the committed block, exiting
1 with the exact --write command needed if stale). Both operate via
new split_blocks()/write_block()/check_block() helpers that round-trip
the real manifest file losslessly.
- N1: fix the duration-weights header's false claim about the
fallback ratio.
- N5: warn on stderr when proxied_test_durations.json has duration
captures for tests that no longer exist in cmd/bd/*_test.go (renamed,
split, or deleted since the last capture).
proxied-cmd-test-shards.txt:
- N4: mark the legacy 15-shard block's header as frozen for
pr-risk.yml's/main.yml's legacy fork/push jobs: it is deliberately
not kept in sync with newly-added tests (those hash-fallback
instead), so regenerating it is not routine maintenance. Only the
header text changed; all 149 explicit assignment lines and the
"known blind spots" callouts are untouched (verified: a fresh
--write would pack all 164 currently-discovered tests explicitly,
silently changing which shard runs which test for this block, which
is exactly what "frozen" means to avoid).
- Regenerate the Bazel-only 30-shard block's header via
`gen_proxied_shard_manifest.py 30 --weights=duration --write` to
describe --write/--check instead of the old manual-copy-paste
instructions. proxied_test_durations.json has not changed yet (S2
is still in progress), so this run only touched header text; the 164
assignment lines are unchanged.
pr_risk_bazel_coverage_test.go:
- Add TestProxiedShardManifestGeneratorNotStale: runs
gen_proxied_shard_manifest.py 30 --weights=duration --check under
plain `go test` (skipped under `bazel test`, whose runfiles hold
neither the generator's sources nor cmd/bd) so a stale 30-block
(e.g. committed by hand, or left behind after adding tests without
regenerating) fails scripts-go-checks on every PR, including forks.
tools/bazel/equivalence_allowlist.txt: allowlist the new test's guarded
Bazel skip.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ci,bazel): rename 14 undiscovered proxied-gated tests; N2/N3/N6 doc fixes
cmd/bd/*_test.go: 14 tests call requireProxiedServerEnv/
requireSharedProxiedServer but their names did not match the shard
scripts' discovery regex ^Test(ProxiedServer|ServerMode), so no CI lane
ever set BEADS_TEST_PROXIED_SERVER=1 for them and they silently skipped
everywhere (pre-existing gap, not caused by F2; list was in
~/beads-bazel-plan/f2/review/undiscovered_gated.txt).
Fixed by renaming rather than widening discovery: 162 of the 164
already-discovered tests call one of the two gate functions in the first
few lines of their body, so name and gate already correlate almost
perfectly, but the 14 tests' names are each styled differently with no
single regex term that would cover all of them without a hand-maintained
list. Renaming lets the existing discovery mechanism, hash-fallback
behavior, and both shard-coverage policy tests pick them up with zero
other changes. Checked each of the 14 names for cross-references first;
each appeared only in its own file plus at most one doc-comment in a
sibling file, both updated alongside the rename. No collisions with
existing test names.
Discovery went from 164 to 178 tests. Regenerated the Bazel-only 30-shard
block (gen_proxied_shard_manifest.py 30 --weights=duration --write) to
pack the 14 new tests; this is the first --write this round to actually
change assignments, not just header text. The frozen legacy 15-shard
block (N4) was deliberately left alone: the 14 renamed tests now
hash-fallback into it, exactly like every other test added since it was
last generated.
cmd/bd/BUILD.bazel (N6): restore the bd_proxied_test comment sentence
bazel.yml's mirror comment kept but BUILD.bazel's had dropped: PR Risk
builds its bd-cmd-test with -race, as here; main.yml's test-proxied-cmd
twin uses build-artifacts' non-race bd-cmd-test, so this lane is the
stricter of the two.
.github/workflows/bazel.yml, .bazelrc (N2/N3): remove stale timing
language ("30 shards of ~5-10 minutes" / ".bazelrc's leftover "15 shards
of ~10 minutes") never reconciled with this task's own local
representative-shard measurements (55-81s/shard); replaced with the
concurrency argument (30 simultaneous dolt sql-servers don't fit a
GitHub-hosted runner regardless of any single shard's wall time). Also
removes the "within 5s of each other" balance claim (S2): the underlying
duration weights are contaminated by -test.parallel overlap in the
top-level <testsuite time> figures they were derived from; a corrected
re-measurement is in progress (separate commit once it lands).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ci,bazel): re-derive proxied duration weights without overlap double-counting (review S2)
scripts/ci/proxied_test_durations.json's 178 entries are now each a
clean, single-job (no concurrent heavy bazel/dolt job on the box),
-test.parallel=1 measurement: a fresh manifest-aligned 30-shard sweep's
own <testsuite time> per top-level test where errors="0" (including
failing-but-complete suites, whose elapsed time is still trustworthy),
plus, for the handful too slow to finish inside Bazel's default
per-target timeout, a `bazel run` leaf-subtest-only sum that never adds
a parallel group's own PASS/FAIL line on top of its already-overlapping
children's lines. An earlier pass at this data summed every PASS/FAIL
line indiscriminately, double-counting parallel subtest groups.
A first attempt at re-measuring the slow stragglers overlapped in
wall-clock time with a second, unrelated heavy sweep and came out 2-3x
inflated versus the same tests measured cleanly; that contaminated data
was discarded in favor of isolated re-runs. TestProxiedServerDep2
initially looked hung during its isolated re-run (15+ minutes with no
PASS/FAIL output and no CPU growth in the top-level test binary) but
was not: each of its subtests does real `bd init --proxied-server`
work in a short-lived child process, and Go buffers a parallel
subtest group's output until the group's last member finishes. Letting
it run to completion (2357.72s) rather than guessing avoided reporting
bad data.
seconds_per_init_fallback is recomputed as the weighted average
seconds-per-init across all 178 measured tests (sum of durations / sum
of inits), for use only when a brand-new test has no entry yet.
Re-packing the 30-shard manifest with this corrected data changes the
shard-balance picture: TestProxiedServerDep2 and TestProxiedServerClose
are each large enough, alone, to dominate their own shard (~2358s and
~1105s locally) while every other shard clusters around 741-876s. The
"within 5s" claim this replaces was never earned by the underlying
data; .github/workflows/bazel.yml now documents the real, uneven
spread and flags that the two outlier shards' local numbers already
exceed the job's 25m step timeout on their own merits (unverified
against RBE's actual per-shard throughput, since this job has only
ever run remote).
Verified: go vet ./scripts/..., go test ./scripts/... (includes the
manifest/coverage policy tests), actionlint, make bazel-sync-check,
make ci-pr-policy all pass. Exact-once coverage re-confirmed: 178
manifest assignments for 178 discovered tests, zero duplicates, zero
gaps.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(cmd/bd): apply re-review candidate fixes; revert 2 unready renames (R-B1)
Re-review found the prior round's 14 renames would turn the required
Bazel + legacy 15-shard lanes red once discovered:
- TestProxiedServerHistoryRemoteRefusalFrontDoorMatrix/external-unix and
TestProxiedServerOutageReconnectAcceptanceMatrix/external-unix-socket
built a dolt.sock path under t.TempDir(), which nests Bazel's hermetic
tmp-root plus the (64-byte-truncated) test name deep enough to exceed
sockaddr_un's 108-byte sun_path limit. Both now use a new shortSocketPath
helper (a short os.MkdirTemp("", "bds") directory) instead.
- runProxiedDeadline raced a deadline-watcher goroutine against
exec.Cmd.Start()/Run()'s write to cmd.Process, caught by -race. Replaced
with cmd.Cancel, which exec.CommandContext only invokes after Start, so
the read is ordered after Start's write.
With those two fixes applied, TestProxiedServerHistoryRemoteRefusalFrontDoorMatrix
passes outright. TestProxiedServerOutageReconnectAcceptanceMatrix's race is
fixed, but both its subtests still fail a real "exceeded 3s bound" assertion
against a stopped external upstream -- a genuine latency issue, not a test
bug -- so it is reverted back to its original name
(TestProxiedOutageReconnectAcceptanceMatrix) with a comment explaining why,
pending a bead against the underlying latency.
TestServerModeSharedServeGlobalReportsTheServedDatabase also reverted back
to TestSharedServerModeServeGlobalReportsTheServedDatabase: `bd serve
--global` refuses to auto-apply 4 pending schema migrations (v65->v69) to a
shared/proxied server database and exits 1 with a consent-required usage
message instead of starting, per the #5920 migration-consent guard. Also a
genuine product/test-fixture question, not fixed here; reverted with a
comment, pending a bead.
The other 12 of the original 14 renames are kept; all 12 verified passing
in both lanes (see commits that follow for the manifest update and full
verification).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ci,bazel): re-derive proxied weights from parallel=4 CI-identical sweep (R-S1)
The prior round's duration data (committed in 6be9605d9f) was captured at
-test.parallel=1 (serial). That fixed a real double-counting bug, but
serial timings don't model this lane, which always runs -test.parallel=4
(--config=doltserver-proxied's own setting). Re-review measured near-zero
correlation (r=0.08) between the serial-derived predicted shard load and
actual parallel=4 wall time -- e.g. TestProxiedServerRecomputeBlocked was
weighted 812s serially but measured 33s actual at parallel=4.
Replaced with a full fresh capture: `bazel --nohome_rc test
--config=doltserver-proxied //cmd/bd:bd_proxied_test` (local execution
only, the exact config bazel.yml's proxied-server tier uses), 30/30 shards
passing, 0 failures, 0 races. Every one of the 176 discovered tests'
top-level <testsuite time> was captured directly from this run's
bazel-testlogs test.xml files -- no leaf-summation workaround was needed
this time, since none of the 176 hit Bazel's per-target default timeout
running alongside the rest of its shard.
Re-ran `gen_proxied_shard_manifest.py 30 --weights=duration --repack
--write` with these corrected weights: a deliberate full reweight, not an
incremental add, since every weight changed. The new packing clusters all
30 shards within a few seconds of ~355-360s each (176 tests summing to
10712s / 30), a dramatic improvement over the serial data's wrongly
implied two-outlier-shard spread (TestProxiedServerDep2 alone at ~2358s,
TestProxiedServerClose alone at ~1105s -- both artifacts of serial
timing, not real per-shard cost). Updated bazel.yml's paragraph to report
this honestly instead of the prior, false "exceeds 25-minute timeout"
claim, which was itself downstream of the serial/parallel mismatch.
Verified: the 12 tests kept renamed in the previous commit, plus
TestProxiedServerHistoryRemoteRefusalFrontDoorMatrix's socket-path fix,
all pass under the new 30-shard Bazel manifest (this capture run) and
under the legacy 15-shard hash-fallback script (ran the 7 shards their
hash lands in: 2, 3, 4, 5, 8, 10, 11 -- all pass).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ci,bazel): incremental --write, --repack, name-coverage --check (R-S2)
The prior --check compared the committed 30-shard block byte-for-byte
against a fresh from-scratch LPT pack, and --write always did a full
repack. That meant any weight drift (even from proxied_test_durations.json
alone, with no test added/renamed/removed) failed --check, and two
unrelated PRs each adding one proxied test would both force a full
repack and conflict on unrelated shard lines -- re-review demonstrated
one new test moving 73 assignment lines under the old full-repack
behavior.
Redesigned:
- --check now verifies exact-once NAME coverage of the currently
discovered TestProxiedServer*/TestServerMode* set against the
committed block -- missing, stale, or duplicated names fail with an
actionable message -- but does NOT compare shard assignments, so a
weights-only change no longer forces --check to fail.
- --write is now incremental by default: every already-assigned test
keeps its current shard, stale (no longer discovered) names are
dropped, and only newly-discovered names are LPT-placed onto whichever
shard is currently lightest. A full from-scratch LPT pack now requires
the explicit --repack flag (used in the preceding commit for the
deliberate full reweight; ordinary new-test additions should use the
incremental default).
Mutation-tested directly (not just reviewed): verified --check correctly
flags a stale name as "stale/unknown" and a newly added test as "missing"
with the exact --write command to fix it; verified incremental --write
touches only the lines for the added/removed names; verified --repack
--write produces a materially different (full rebalance) diff from the
incremental default.
Updated TestProxiedShardManifestGeneratorNotStale's comment in
pr_risk_bazel_coverage_test.go to describe the new name-coverage-only
--check semantics (it previously described the old byte-identical-packing
behavior; the test's own assertion -- exit code only -- was already
correct and unaffected).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
* fix(lint): drop unparam findings in primeGitCmd and expandStep
primeGitCmd's error return was always nil (GH#4927 made every path
infallible but left the signature); drop it and update both call sites.
expandStep's depth parameter was always called with 0 from every caller;
recursion depth is tracked internally by expandStepWith via its own
depth+1 calls on children, so the parameter was dead. Hardcode the 0
start inside expandStep and drop the parameter.
Fixes golangci-lint unparam findings:
cmd/bd/prime.go:306:67: primeGitCmd - result 1 (error) is always nil
internal/formula/expand.go:197:49: expandStep - depth always receives 0
make ci-pr-lint is clean (native + windows/amd64 + darwin/arm64 non-CGO).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(dolt): give each TestBatchApplyContract subtest its own context
TestBatchApplyContract's subtests all shared one 90s context built once
in newDoltBatchApplyFixture. BoundsTheItemCount legitimately needs most
of that budget against the server-Dolt tier (ApplyBatchInTx's create
path calls ExecuteCreate once per item, ~5-8 round trips each, for all
1000 items at the MaxApplyBatchItems bound raised by #7051). Once
earlier subtests had spent part of the shared budget, BoundsTheItemCount
would blow the deadline and every subtest that ran after it in the same
parent would fail too with "context deadline exceeded", masking the
real failure behind unrelated red subtests (nightly run 37089445362,
shard 2/16: BoundsTheItemCount at 78.9s, deadline exceeded).
Give each t.Run its own fresh testContext(t) instead of sharing one,
mirroring openStoreWithOwnBudget's established rationale for the same
bug class (be-gvnsq). The store and its copy-on-write branch stay
shared across subtests, and subtests still run in sequence; only the
per-subtest deadline is decoupled. No production code changed: the
underlying per-item round-trip cost is genuine, documented, deliberate
behavior (see applyCreate's doc comment), and batching it safely would
be a larger, riskier change than this CI flake warrants.
Verified via bazel --nohome_rc test --config=doltserver-integration
//internal/storage/dolt:dolt_server_full_test --test_filter=TestBatchApplyContract
-t- --test_output=all: shard 2/16 (same shard as the original failure)
now passes, TestBatchApplyContract in 77.68s with BoundsTheItemCount at
66.08s.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(embeddeddolt): skip redundant 1000-item wall-clock case under -race
TestLargeBatchApplyWallClock_Embedded's 1000-item shape was taking
597-651s under --config=embedded (-race), inflated by race-instrumenting
the in-process Dolt engine's own internal goroutine/lock machinery on
every statement issueops.ApplyBatchInTx issues. The Dolt server (TCP)
tier doesn't pay this cost: its sql-server runs in a separate,
non-raced subprocess (dolt_race_off), but the embedded backend runs
Dolt entirely inside this test binary, so -race instruments all of it.
This pushed the embedded-storage CI lane's shard 5 over its 19-minute
per-shard test timeout (panic: test timed out after 19m0s).
The 1000-item case carries no pass/fail assertion on duration or count
(the test is explicitly a logging-only measurement, not a regression
gate), so skipping it under race removes no coverage. Real 1000-item
(issueops.MaxApplyBatchItems) correctness coverage is unaffected: it
still runs and is asserted by TestBatchApplyContract/BoundsTheItemCount
in this same package, under the same race lane.
Adds the established raceEnabled build-tag pair (see
internal/workapi and cmd/bd for the sibling idiom) to this package so
the skip can be conditioned on -race.
Verified via Bazel (--config=embedded, --nohome_rc):
TestLargeBatchApplyWallClock_Embedded: 651.23s -> 86.79s
(1000 now SKIPped; 356 still runs and passes)
Shard 5 of embeddeddolt_embedded_test: FAIL -> PASS
Not fixed in this commit: TestBatchApplyContract/BoundsTheItemCount's
embedded instantiation still takes ~903-945s under -race and leaves
shard 4 of embeddeddolt_embedded_test over its 19-minute budget. Unlike
the wall-clock test, that subtest carries real correctness assertions
via the shared backend/conformance.RunBatchApplyBoundsTheItemCount, and
shrinking it would require a cross-backend conformance-test design
decision (e.g. a per-fixture item-count override) that trades away real
MaxApplyBatchItems boundary coverage for one backend - judged out of
scope for an isolated test-only fix here. Flagging for a deliberate
follow-up rather than weakening the assertion to make it fast.
TestLargeBatchApplyStatementCounts_Embedded and the dolt-tier
TestLargeBatchApplyStatementCounts_Dolt were checked and left
untouched: neither includes the 1000-item shape, neither showed any
slowness or flakiness, and both pin exact statement-count regression
baselines that should not be disturbed without cause.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(cmd/bd): fence test-binary beads/git discovery against ancestor .beads
cmd/bd's test binary ambiently discovers its beads workspace the same way
production bd does: via internal/beads.FindBeadsDir's worktree-fallback and
ancestor-walk logic. When this package's checkout is itself a linked git
worktree (e.g. a sibling checkout like beads-bazel-y next to beads), the
first cached git-context call made anywhere in the test binary - before any
individual test has had a chance to chdir into its own isolated fixture -
permanently answers isWorktree=true/a real --git-common-dir for the rest of
the process. beads.FindBeadsDir then treats that as license to read (and
tests that don't isolate properly could write) the main checkout's shared
.beads database.
Confirmed via direct reproduction in a disposable scratch main+worktree pair
under /data/tmp (never /data/projects/beads): running a correctly-built `bd
--version` from the worktree checkout's cmd/bd directory resolves and warns
about the fake main checkout's .beads permissions, demonstrating the
fallback is reachable from plain ambient discovery, not just from a
contrived unit test.
internal/git.PinNoRepositoryForTesting seeds the process-wide git context
cache with a "not a git repository" sentinel as the first statement of
testMainInner, making the worktree-fallback vector inert by default. Tests
that need real git behavior for a fixture they control already call
git.ResetCaches/beads.ResetCaches after chdir'ing there (the existing
cmd/bd/git_test_helpers.go idiom), which overrides the pin for their own
scope - this is unchanged.
Separately, testMainInner now appends (never overwrites) a
BEADS_CEILING_DIRECTORIES entry for the package's own repo root, bounding
any literal ancestor-directory walk that starts at or under this checkout -
closing a second vector (an ancestor walk escaping past a nested worktree
root into a directory-with-.beads further up) that the pin alone doesn't
address. The existing pollution guard is extended to also watch the
worktree-fallback .beads directory (resolved via a direct, cache-independent
git shell-out) as a defense-in-depth detection backstop.
Verified via two full before/after `go test -tags "cgo integration" -v .`
runs of cmd/bd in a disposable linked-worktree scratch clone: identical
pass/fail sets before and after (no regressions), and zero filesystem
writes observed (inotify-monitored) in the scratch main checkout's .beads
in either run - the existing subprocess test helpers already discipline
themselves to set an explicit cmd.Dir/BEADS_DIR, so no currently-live test
was caught actively polluting the fallback directory in this repro. This
change is defense-in-depth against the mechanism itself (and against
regressions reintroducing it), rather than a fix for an empirically
isolated failing test in the current suite.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ci): make embedded-dolt and go:embed tests discoverable by their CI shards
embedded-test-shard.sh discovers cmd/bd's embedded-dolt tier by grepping
`^func TestEmbedded` out of cmd/bd/*_embedded_test.go — a filename-glob
match, not a package-wide one. 11 TestEmbedded* functions lived in files
that didn't match that glob (auto_import_upgrade_test.go,
dep_list_cross_db_test.go, and four files mixing TestEmbedded* with
unrelated TestProxiedServer*/TestServerMode*/TestWithFetchOneExtra_*
siblings: max_rows_test.go, store_factory_test.go,
purge_wisps_plane_integration_test.go, types_create_agreement_test.go).
They compiled and would run under a plain `go test`, but were invisible
to every CI lane that drives this tier off that discovery (the 20-shard
embedded cmd matrix), so they never ran in CI at all.
Fixed by relocating them into *_embedded_test.go files: a straight
`git mv` for the two files that were purely TestEmbedded* content, and a
function-level split for the four mixed files (moving just the
TestEmbedded* function itself; shared helpers/types stay put since
Go doesn't care which file in a package defines a symbol). The newly
discoverable tests aren't in embedded-cmd-test-shards.txt — consistent
with the ~55 pre-existing discovered-but-unlisted tests already in this
suite, they fall back to the manifest's documented hash(name)%shards
assignment. Verified via `BEADS_TEST_SHARD_LIST_ONLY=1` across all 20
shards: all 212 tests (201 + 11) are now listed exactly once, no shard
comes up empty. Also verified for real: built the cmd/bd test binary
and ran all 11 against a prebuilt bd binary (BEADS_TEST_BD_BINARY) from
the repo root, matching how CI invokes the prebuilt CMD_BINARY — all 11
pass.
Separately, 5 functions had a `TestEmbedded` prefix for an unrelated
reason — go:embed'd content (agents_test.go's AGENTS.md template tests,
schema_test.go's migration-source duplicate-version check) — and so were
being silently caught and skipped by the repo-wide `-skip '^TestEmbedded'`
pattern PR Core/main CI lanes use to exclude the Dolt-embedded tier from
./... runs. Renamed to a TestGoEmbed* prefix so they run where every
other unit test in their packages does; no other references to the old
names exist in the repo. Confirmed with `-skip '^TestEmbedded'` locally:
all 5 now run (previously would have been silently skipped).
Repo-wide grep for stray `^func TestEmbedded` outside cmd/bd,
internal/storage/embeddeddolt and internal/storage/dolt now returns only
internal/tracker's TestEmbeddedDoltExternalRefChangedAfterUsesHistoryFastPath,
which is genuinely about the Dolt-embedded backend and correctly named.
cmd/bd/BUILD.bazel regenerated via `bazel run //:gazelle` to reflect the
renames/new files; it also picked up internal/ceiling as a go_test dep,
a sync gap left over from test_repo_beads_guard_test.go's import in the
prior commit on this branch.
Verified: go build/vet (default, -tags cgo) clean; gofmt clean; go test
./scripts/...; bazel --nohome_rc test //scripts:scripts_test; bazel
--nohome_rc build //cmd/bd:bd_embedded_test; bazel --nohome_rc run
//:gazelle (cmd/bd/BUILD.bazel diff only); python3 tools/bazel/go_srcs.py
--check (make bazel-sync-check); make ci-pr-policy; make ci-pr-lint
(gofmt + golangci-lint native/windows/darwin, 0 issues). cmd/bd test
binary runs were built from cmd/bd (not the module root) and executed
with BEADS_TEST_BD_BINARY set to a binary built the same way, to avoid
buildEmbeddedBD's `go build -o X .` resolving "." against the wrong
package when invoked outside `go test`'s own working directory — not a
bug in this change, reproduced identically against an untouched,
already-correctly-named test (TestEmbeddedVersion). /data/projects/beads/.beads
checked before and after: no change beyond the pre-existing 166 untracked
.beads/formulas/*.toml files already present at session start.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(embeddeddolt): shrink BoundsTheItemCount's real apply under -race
TestBatchApplyContract/BoundsTheItemCount's embedded instantiation
measured 903-945s under -race (shard 4's single biggest long pole),
because the in-process cgo Dolt engine's own goroutine/lock machinery
runs inside the race-instrumented binary for a full 1000-item apply.
Every backend's ApplyBatch validates via the same storage.PlanApplyBatch
before opening any transaction, so the refusal half of this subtest is
already O(1) regardless of count, and the exact 1000/1001 boundary is
already pinned, for real and sub-millisecond, by
TestPlanApplyBatchAcceptsTheBoundary in internal/storage/batch_apply_test.go.
That leaves only "does this backend's own write body durably land N
accepted rows" as the expensive, backend-specific thing this subtest's
"at bound" half needs N real items for - and N does not need to be 1000
to prove that.
Split RunBatchApplyBoundsTheItemCount into a thin wrapper (unchanged,
still used by internal/storage/dolt and internal/storage/uow at the
full MaxApplyBatchItems) plus a new RunBatchApplyBoundsTheItemCountAtScale
taking an explicit atBoundItems. Embedded's subtest now applies 150 items
under -race (65.33s locally, down from 749.22s unmodified on the same
host) and the full 1000 otherwise, via the existing raceEnabled idiom.
internal/storage/dolt's non-race BoundsTheItemCount still covers the
shared inner write body at the full 1000-item count every PR. No CI lane
covers embedded's own post-commit wrapper at 1000 items anymore after
this change (the only non-race embeddeddolt build is compile-only and
never executed) - a known, reported, deliberate gap, documented in both
the updated large_batch_apply_measure_test.go comment and the task's
impl-report.md.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(git): make test-repository pin survive ResetCaches
PinNoRepositoryForTesting wrote its "no repository" sentinel into the
same gitCtx variable ResetCaches() unconditionally clears, so any test
fixture that calls ResetCaches() after the pin is set (runInDir's
cleanup, resetRepoCachesForTest, 25+ call sites) silently un-pins the
whole test binary for every later test. A reviewer's probe test proved
the bypass: GetRepoRoot() returned the real checkout path after a single
runInDir round-trip.
Replace it with PinNoRepositoryUnderForTesting(root), a separate,
directory-scoped pin checked live against os.Getwd() on every
getGitContext() call, before the gitCtxOnce/gitCtx one-shot cache is
touched at all. The pin survives ResetCaches() for any working directory
at-or-under the pinned root, while fixtures that chdir OUTSIDE that root
(the normal t.TempDir() pattern) still get real git detection.
Add TestPinNoRepositoryUnderForTestingSurvivesResetCaches, reproducing
the reviewer's exact repro and proving the fix: pins a real repo root,
confirms unpinned after chdir+ResetCaches outside the root, and confirms
STILL pinned after chdir+ResetCaches back inside the root (mimicking
runInDir's cleanup).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(cmd/bd): widen guard fallback coverage, document -C/doctor gap
Two review follow-ups on the test-repo .beads guard:
1. Honest scope documentation: FindBeadsDirFrom/ResolveBeadsDirForRepo's
-C/doctor paths shell out to git directly with the ceiling env var
stripped, so PinNoRepositoryUnderForTesting (see previous commit) does
not fence them. Document this residual gap explicitly rather than
implying full coverage; covering it would need those call sites to
consult the pin too, which is out of scope here.
2. The guard's fallback-.beads watch list only watched metadata.json and
skipped watching entirely when the main .beads directory was absent —
exactly the layout where the worktree fallback is actually in use.
Restructure to check the main and fallback directories independently,
add config.yaml/routes.jsonl to the flat watch list, and add a
recursive snapshot of dolt/ (snapshotDoltTree) so a real pollution
write anywhere under the fallback's Dolt-backed state is caught.
diffSnapshots is generalized to also report newly-appeared keys, since
a recursive tree snapshot can legitimately gain entries between
before/after in ways the old fixed-name flat list never could.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ci): pin MaxRows embedded tests off their shared race shard
TestEmbeddedMaxRowsNonListPaths and TestEmbeddedMaxRowsList both hashed
to embedded cmd shard 16, which measured 746s wall under -race
(605s + 214s) against a 19-20 minute budget on a 192-core host with
effectively unbounded test.parallel; CI's 4-way parallelism would be
worse. Neither test had ever run under race in CI before this branch
surfaced them to their own shards.
Both tests spawn many independent bd subprocesses per subtest
(bdInit + exec.Command), so their cost is dominated by subtest/subprocess
count rather than a single large-N parameter; buildEmbeddedBD also never
passes -race to the spawned bd binary, so there is no raceEnabled-style
"shrink N" lever analogous to BoundsTheItemCount's that would apply here
without just deleting coverage. Pin them to shards 11 and 13 instead,
the two lightest shards by current manifest+hash-fallback test count
(verified via BEADS_TEST_SHARD_LIST_ONLY=1, which lists shard
composition without executing any tests).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(embeddeddolt): correct coverage comments, range-check, document build tags
- large_batch_apply_measure_test.go's doc comment above
TestLargeBatchApplyWallClock_Embedded had three factual errors: the
150-item sibling subtest does not always run at 150 "race or not" (it's
1000 without -race); the 356-item shape is not "non-race only" (it runs
under race too, as the same comment's next line said); and the
server-Dolt full suite does not run on "every PR" (full_embedded in
.github/scripts/ci-embedded-tier.sh is unconditional on merge_group/push
but conditional on PRs, per pr-risk.yml's gating). Rewrote the comment to
be self-contained (no out-of-repo citation) and accurate, and reworded
the related t.Skip message. Fixed the same "every PR" overstatement in
batch_apply_contract_test.go's BoundsTheItemCount race-branch comment.
- Added a range-check to
conformance.RunBatchApplyBoundsTheItemCountAtScale: atBoundItems must be
1..publicops.MaxApplyBatchItems, since that's the production bound this
contract pins.
- Documented why race_detector_on_test.go/race_detector_off_test.go use
`cgo && race`/`cgo && !race` instead of the plain `race`/`!race` pair
used by internal/workapi and cmd/bd: every consumer of raceEnabled here
is itself cgo-gated, so the matching cgo tag keeps this file out of
non-cgo builds too, where it would otherwise compile with no consumer
and trip an unused-lint finding.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(dolt): give BoundsTheItemCount 3x timeout budget
The server-Dolt tier's BoundsTheItemCount subtest measured 66s against
the package's shared 90s testTimeout — a thin margin on a loaded CI
runner. Give it a dedicated 3x (270s) context.WithTimeout instead of
raising the shared testTimeout constant, since that constant also scales
every other subtest's 5*testTimeout cleanup bound package-wide; a local
override keeps the blast radius to the one expensive subtest.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* feat(ci): run embedded-Dolt batch-apply suite non-race in nightly
The nightly full-test job's main suite (go test -race ... ./...) never
sets BEADS_TEST_EMBEDDED_DOLT, so every skipUnlessEmbeddedDolt-gated test
in internal/storage/embeddeddolt — including TestBatchApplyContract and
the 1000-item case of TestLargeBatchApplyWallClock_Embedded — is skipped
on every CI lane, not just this one. Add a dedicated non-race step so a
real 1000-item apply through the embedded backend's own
version-commit-published-after-the-tx wrapper gets exercised somewhere:
non-race because the embedded engine's own goroutine/lock machinery runs
inside this test binary and the race detector dramatically inflates its
wall-clock (see race_detector_on_test.go), which would defeat the wall-
clock test's purpose and reintroduce the kind of shard-timeout pressure
the MaxRows shard-pin commit just worked around elsewhere.
Verified locally from a fresh /tmp clone (outside any .beads ancestor,
per this task's safety rules):
BEADS_TEST_EMBEDDED_DOLT=1 go test -tags gms_pure_go -run '^(TestBatchApplyContract|TestLargeBatchApplyWallClock_Embedded)$' ./internal/storage/embeddeddolt
PASS, 178.3s total (BoundsTheItemCount 81.06s, WallClock/1000 63.14s),
comfortably inside the job's 45-minute timeout.
Add TestNightlyFullTestRunsEmbeddedDoltBatchApplySuite to
scripts/ci_workflow_test.go, pinning the step's exact run command, its
BEADS_TEST_EMBEDDED_DOLT=1 env, that it runs after the main suite step,
and that it stays non-race.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(ci): allowlist the scripts tests that skip under Bazel, and check new ones before merge
nightly.yml's skip-parity check (equivalence.py --go-test-json) went red
on 2026-10-02 (run 36955306415): TestBazelGatedLanesNeverRetryFlakyTests
and TestCheckShardCoverageScript pass under go test and deliberately
t.Skip under Bazel (their inputs are not in //scripts:scripts_test's
runfiles), but had no `skip` allowlist entry. Step 2's
TestShardScriptsListOnlyRealTests and TestShardScriptNarrowingCheck, now
on main, have the same shape and would have turned the next nightly red.
Add the four entries, and TestBazelOnlySkipsAreAllowlisted: it parses
every _test.go file of the module and requires each top-level test whose
t.Skip is guarded by TEST_SRCDIR or bazeltest.IsBazel() (directly or
through a helper) to have an entry, so a new one fails under go test
before the merge instead of in the next nightly. It skips under Bazel
itself and is allowlisted too.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(test): keep cmd/bd's integration init out of the credential-command helper process
nightly.yml's Full Test Suite (go test -tags=integration ./...) failed
TestApplyInitGatewayCredentialAdoptsToken and ...FailsClosed on
2026-10-02 (run 36955306415): credentialcmd re-execs the test binary as
the credential helper, and cli_fast_test.go's integration-tagged init()
runs in that child before TestMain can dispatch it, tries `go build .`
from the helper's working directory and panics, so the helper exits 2.
Add credentialcmd.IsHelperProcess (Dispatch's two gates) and return from
that init early, as it already does for the worktree-remove helper.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* ci(bazel): overwrite fixed-name artifacts so "Re-run failed jobs" does not 409
A job re-run is the same workflow run, and upload-artifact v4+ refuses a
second artifact of the same name there (409 Conflict). bazel-test uploads
the bd package even after its tests fail, so re-running a failed Bazel /
test lane, the documented recovery for an eviction or a flake, failed on
the upload even when every test passed. Set overwrite: true on all eight
uploads in bazel.yml (the bd package, BUILD sync patch, every lane's test
logs) and policy-test it.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(test): keep skip-scan fixture functions out of line-based test discovery
The fixture source in bazel_skip_allowlist_test.go had top-level
`func TestXxx(t *testing.T)` lines, which equivalence.py (and the CI shard
scripts) count as tests of the scripts package; write them with a FUNC
placeholder and substitute at write time.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Post-merge review follow-up to #5614.
#5614 replaced the shell checker's three-way drift remedy with a bare
"Run: scripts/update-versions.sh <canonical>" in both the Go checker
(status 1) and bd preflight's Version sync output, and the release-tag
pre-push hook kept answering status 1 with "Fix with:
scripts/update-versions.sh <version>". update-versions.sh derives the old
version from cmd/bd/version.go and anchors its substitutions on it, so
with version.go already at the canonical version that re-run rewrites
only the .githooks markers and uv.lock and leaves any other drifted file
as it was.
Restore the remedy as versioncheck.Report.MismatchRemedy, shared by the
checker and preflight:
- one file drifted: edit it to the expected value
- several drifted: set version.go to the previous version, then replay
scripts/update-versions.sh <canonical>
- version.go is wrong: scripts/update-versions.sh <intended-version>
The hook's status-1 text now points at the checker output instead of
prescribing update-versions.sh; status 3 is unchanged. The text is sized
so one drifted file shows in full within preflight's 500-byte human
output, with the several-files case ahead of the version.go one.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* test(storage): measure ApplyBatchInTx SQL statement counts (B0)
Adds a driver.Connector-level counting/latency-injecting wrapper
(internal/storage/sqlcount) plus shared plan-request fixtures
(internal/storage/batchfixtures: mol-normalized 356/712-item shapes and a
40-item classic shape) and backend-specific pinning tests + benchmarks
(internal/storage/embeddeddolt, internal/storage/dolt) that measure the
ACTUAL number of SQL statements issueops.ApplyBatchInTx issues for each
shape, on both the embedded and Dolt (TCP) backends.
Measured totals (Prepare+Exec+Query+StmtExec+StmtQuery inside one
transaction): 356 items ~7008-7009, 712 items 14014-14015, 40 items 846,
identical on both backends (expected: statement issuance is driven by Go
application logic, not backend-specific SQL planning). Pinned with a small
(+/-2) tolerance to absorb an observed, host-contention-driven +/-1 Query
drift (Exec is deterministic on every run). This is the regression baseline
slice B2 (a later, lighter fast path) must demonstrably lower.
batchfixtures.UncappedPlan bypasses issueops.MaxApplyBatchItems so this
measurement does not depend on slice B1's cap raise.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* feat(httpapi,issueops): raise batchApply envelope to 1000 items with bounded large-apply handling
POST /v0/beads/issues:batchApply now accepts up to 1000 items (up from 100);
issueops.MaxApplyBatchItems moves accordingly and the request body cap rises
to 16 MiB. The whole plan still applies in exactly ONE transaction. A request
over 100 items runs under a separate, flat, operator-configured whole-run
budget (`bd serve --large-apply-ceiling`, 5 minutes by default) instead of
the ordinary 60s request deadline; a request at or under 100 items is
unaffected and keeps exactly the 60s deadline and 15s commit-retry ceiling it
always had.
Concurrency and shutdown are bounded, not just documented:
- Oversized requests serialize through a dedicated one-wide semaphore, and at
most one caller may wait for that semaphore at a time (a CAS-guarded single
waiter) — a burst of oversized requests is shed with 503 rather than
queuing and starving ordinary traffic behind the general semaphore.
- The run deadline is stamped only once the slot is actually acquired, not
at the time the request arrived.
- Graceful shutdown closes new admissions before computing its drain budget,
then waits out an in-flight large apply up to its own remaining deadline
(plus a few seconds' grace for the response to write); any large apply
still queued for the semaphore when shutdown begins is refused rather than
extending the drain further. A queued caller that disconnects gets a clean
503, never a misclassified context error. `bd serve`'s orchestrator stop
grace must be at least `--large-apply-ceiling` — see
engdocs/SERVE_RUNBOOK.md.
- ApplyBatch's commit-retry budget only extends past the ordinary 15s ceiling
on this explicit large-apply path (via a context marker), with headroom
reserved so the final retry attempt can't be killed mid-commit by the
context's own expiry.
A new `issues.batchApplyLarge` capability token on `GET /v0/beads/context`
lets a client learn whether a given server accepts the raised envelope.
Wall-clock measurement (embedded Dolt, whole-transaction build+commit) backs
the 5-minute ceiling default: 356 items ~12.6s (23.8x headroom), 1000 items
~57.5s (5.2x headroom).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(httpapi,serve): wire the large-apply retry budget; repair stale pins
Review fixes for the large batchApply envelope, on top of the test
repairs the PR needed against main.
The extended commit-retry budget was never switched on.
internal/storage/uow's retryTxBudget lets a large apply keep retrying a
commit-time conflict past the ordinary 15s ceiling only when its context
carries issueops.WithExtendedRetryBudget's marker, and the docs on both
sides say admitLargeApply sets it, but nothing did: the marker's only
callers were the uow tests, which mark their contexts by hand. A
1000-item apply that hit a conflict still gave up after 15s with most of
its 5-minute ceiling unused. admitLargeApply now marks the run context
it builds, and TestApplyBatchMarksOnlyALargeApplyForTheExtendedRetryBudget
pins the seam over HTTP: marked at 101 and 1000 items, unmarked at 100.
Removing the mark fails the 101 and 1000 cases; marking every request in
handleApplyBatch fails the 100 case.
Smaller fixes from the same review:
- `bd serve --large-apply-ceiling` repeated the 5m default as a literal
of its own, and since bd serve always passes a positive ceiling, that
literal, not httpapi's, was the default every deployment ran. Export
httpapi.DefaultLargeApplyCeiling, default the flag to it, and pin the
flag's 5m0s default in TestServeFlags.
- admitLargeApply's release cancels the run context before clearing
s.largeApplyDeadline, the order acquireLargeApply's doc states; it
cleared the deadline first.
- Drop the batchfixtures test's dead t.Skipf, which waited for the cap
to reach 1000, and correct a graph-counter comment that still cited
the 100-item cap and the TestServeFlags doc line that called the
no-argument server unchanged.
The PR raises issueops.MaxApplyBatchItems from 100 to 1000 and adds
`bd serve --large-apply-ceiling`, but two base-owned tests still pinned
the old surface and went red on every lane that runs them (Bazel / test,
Test (macos-latest)):
- TestServeFlags pins the exact `bd serve` flag list; add
large-apply-ceiling.
- TestPlanApplyBatchRefusesAnUnusableRequest/too_many_items built 101
items and expected "at most 100 items", a request the 1000 cap now
plans successfully. Size the over-cap request and its message from
issueops.MaxApplyBatchItems, as TestPlanApplyBatchAcceptsTheBoundary
already does for the other side of the cap; the cap's value stays
pinned by TestCapBatchApplyLargeTiesAllThreeLimits.
The PR's own TestLargeApplyBurstNeverStarvesSmallRequestsForSemTimeout
also went red in PR Core (-race, -p 4 on a 4-vCPU runner): all eight
small requests took 160-165ms against a 100ms bound. The stall it
guards against lasts semTimeout (5s), while a small request can still
queue briefly behind the refused large requests, each holding a general
sem slot while its body decodes. Bound it at a second, the "want well
under a second" its sibling TestLargeApplyQueueDoesNotStarveOrdinaryRequests
already uses. Pinned to four cores beside 24 busy loops, small requests
measured 183ms mean and 338ms max, and the 1s bound passed 80/80 runs;
with the one-waiter gate in acquireLargeApply disabled the test still
fails 3/3, on its 2s never-completed check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(uow): stop a doomed large-apply retry before ctx cuts it off
retryTxBudget sizes maxElapsed once at ApplyBatch entry, but says nothing
about how long an individual attempt takes. A slow first attempt (e.g.
157s of a large apply's commit) left little of the budget for a retry,
which then got killed mid-transaction by ctx's own deadline instead of
finishing and reporting its own outcome -- surfacing as
context.DeadlineExceeded (isUnavailable excludes it -> a generic 500)
instead of the exhausted-write-conflict result this loop already reports
correctly (-> 503 + Retry-After).
RunTxResultWithin now tracks the previous attempt's duration and, before
starting a new one, stops early with the last real serialization error
when time left on ctx is less than that duration plus a fixed headroom --
but only when publicops.HasExtendedRetryBudget(ctx) is set (the same
marker retryTxBudget itself checks). Applying the look-ahead
unconditionally regressed TestApplyBatchHonorsAnExtendedRetryBudgetFromContext's
unmarked case: ordinary requests have cheap attempts and are meant to run
until their own ctx deadline ends the loop, and the large-apply-sized 5s
headroom was tripping that for any short-ctx caller with a near-instant
failing attempt.
Adds TestRunTxResultWithin_SlowAttemptStopsBeforeADoomedRetry (a 1.2s
commit against a 2s marked ctx must stop after one attempt with its own
serialization error, never DeadlineExceeded, and never touch a second
unit of work) and its control, TestRunTxResultWithin_ShortAttemptStillRetries
(a 50ms attempt against the same shape must still retry and succeed).
Both mutation-checked against the look-ahead condition and its gate.
Also updates the stale "items accepts at most 100 entries" prose on the
applyBatch endpoint description (openapi.v0.yaml) to the large-envelope
wording already used elsewhere in the spec: 1000-item cap behind the
issues.batchApplyLarge capability, large-apply-ceiling deadline extension,
<=100 unaffected. dependencies:count's own "at most 100" lines are
unrelated and untouched.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ci,serve): fit the 1000-item cap's tests in the storage shard budget
Review fixes for the relaunched #7051, iteration 1.
Raising issueops.MaxApplyBatchItems from 100 to 1000 made the base-owned
TestBatchApplyContract take 604s under -race, against 97s at the old cap
(main run 35862663577). It hashed onto the legacy test-embedded-storage
shard 2/5, beside ~5m of other tests, and that shard hit its 15m budget
twice (PR Risk run 36807191489). PR Risk no longer runs the legacy tier
on same-repo PRs (#7071), but Main's push run and fork PRs still do, so
the merge would have carried the timeout to Main.
Raising the jobs' timeout-minutes alone would not fix it: the shard
script passes the binary its own -test.timeout=15m. So:
- embedded-storage-test-shard.sh passes -test.timeout=20m (and its go
test fallback -timeout 20m), as embedded-test-shard.sh does for
cmd/bd.
- test-embedded-storage in main.yml and pr-risk.yml: timeout-minutes 15
-> 25, the script's 20m plus setup.
- embeddeddolt_embedded_test appends -test.timeout=19m, as
bd_embedded_test does, so Go's timeout, which dumps every goroutine,
fires before rbe-west's 1200s action kill, which does not.
TestBazelEmbeddedJobMirrorsEmbeddedTier now checks the override on
both sharded targets instead of only cmd/bd's, and the PR Risk
coverage test pins the storage target's new args.
- embedded-storage-test-shards.txt places TestBatchApplyContract on
shard 4, which has ~3m of other tests, and the PR's two large-batch
tests, TestLargeBatchApplyStatementCounts_Embedded (247s) and
TestLargeBatchApplyWallClock_Embedded (261s), on shards 2 and 5. From
the PR run's per-test times, the heaviest shard projects to ~13m, down
from shard 2's 15m-plus.
Also correct the stop-grace guidance. For an in-flight large apply,
Serve's drain waits out the apply's remaining deadline plus drainGrace
(5s), so the orchestrator's stop grace must be at least
--large-apply-ceiling plus 5s, as Serve's own doc says. The runbook, the
flag help, the LargeApplyCeiling field doc and the CHANGELOG entry asked
for the ceiling alone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
The PAUSED warning, the `bd backup status` PAUSED line, CHANGELOG and
configuration.md told operators to switch to a fresh destination with
`bd backup init <new-path>`. That never ends the pause: backupDir()
reads only backup.git-repo, while `bd backup init` registers the
separate destination that manual `bd backup sync` pushes to, so
auto-backup keeps targeting the over-cap directory and stays paused.
Name the two levers that do end it: raise backup.size-cap-mb, or point
backup.git-repo at a different git repository. Also correct the
backup.git-repo row in configuration.md, which called it a repo URL
although backupDir() requires a local path containing .git (anything
else falls back to .beads/backup/), so the new advice is actionable.
TestPauseAutoBackupForSizeCap_RemediationAdvice and the status PAUSED
line now require backup.git-repo and reject `bd backup init`.
TestMaybeAutoBackup_RemediationLevers runs all three for real: raising
the cap and switching backup.git-repo each resume a sync, while
`bd backup init` leaves auto-backup paused.
Post-merge review follow-up to #6071.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
#5725 gave the cmd/bd init gateway credential fixtures a private helper
protocol. While it was queued, #5749 landed internal/testutil/credentialcmd
for the same production shell boundary, leaving two parallel
implementations: the same emit/exit-23/marker operations, the same exit-97
malformed sentinel and the same Windows .cmd trampoline. They had already
drifted. The private copy claims a process on an env var alone, with no
argv sentinel, and its command text is stable rather than unique per call,
although the production credential cache is keyed on that text.
Port cmd/bd onto the shared fixture, as internal/creds and
internal/storage/dolt already use it:
- TestMain claims helper processes with credentialcmd.Dispatch() before
any suite setup, and calls credentialcmd.Cleanup() after the suite.
- AdoptsToken, SkipsEmbeddedMode, FailsClosed and PresetWins build their
commands with credentialcmd.Emit/Exit23/Marker and check non-invocation
with credentialcmd.AssertMarkerAbsent. Their assertions are unchanged.
- The private protocol, its constants and
TestApplyInitGatewayCredentialHelperProtocol, which tested only that
protocol, are removed. credentialcmd's own TestProtocol covers the
shared one and already runs natively on Windows in pr.yml.
- The native driver's fixture list drops the removed test, and bd_test
gains the //internal/testutil/credentialcmd dep (gazelle agrees).
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix: make release-version checks shell-free (#5533)
Agent-Signature: codex-gpt-5-unknown-reasoning on behalf of Ewen Cuthiell
* fix(release): preserve checker status and explain gate failures (saa-cgh.16)
Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell
* docs: retain release-pinned CLI references (saa-cgh.16)
Preserve corrected live preflight help while generated references continue to match docs/cli-docs.pin v1.2.2. Fix the exact two-line hosted docs-policy failure without changing pin authority.
Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell
* fix(versioncheck): carry base's release gates into the Go checker
The base branch gained three release-metadata gates in scripts/check-versions.sh
after this PR's merge point (release: prep v1.3.0, b3ef65c854): the Copilot
plugin manifest, the four winres.json Windows PE version fields, and
manifest.xml's assemblyIdentity version. This PR replaces that shell body with
the Go authority, so adopting it as-written would have silently dropped all
three — each one guards a file whose bump is a sed anchored on the old value,
so a drifted copy no-ops and ships advertising the previous version.
Port them into internal/versioncheck so the shell-free checker enforces the
same set:
- source gains an optional expected() so a surface can derive its required
value; the Windows PE numeric fields must be purely numeric and so carry the
prerelease-stripped form, and manifest.xml carries the four-part form.
- readWinresVersionField reads the nested RT_VERSION resource path through the
existing duplicate-key-checked JSON helpers.
- readManifestAssemblyVersion anchors on line start, since the XML declaration
also carries a version attribute.
Also regenerate the Bazel BUILD files (make bazel-sync). cmd/bd/BUILD.bazel
enumerates srcs explicitly, so the PR's new preflight_versions.go was missing
from it and //cmd/bd:bd_lib failed to compile with `undefined:
runBeadsVersionSyncCheck`; gazelle adds that src, the //internal/versioncheck
dep edge, and BUILD files for the two new packages.
Known follow-up for review: the PR's TestRepositoryReleaseVersionsMatch and
TestPrePushHookOrdinaryPushWorksWithSystemBash read repository files directly,
so they need `data` runfiles to pass under `bazel test` (advisory lane only).
* fix(versioncheck): stop the release gate over-claiming docs coverage; distinguish --expect mismatch
Maintainer review fixup for iteration 1 (both findings minor, non-gating;
scorecard 915/850 approve with Required Changes: None).
Contract & Interface Fidelity (claude + codex): the success line claimed
"Version files and released-docs policy pass" while the checker reads no
documentation surface, and it replaced the shell predecessor's explicit
disclaimer that the docs release line and docs/cli-docs.pin are manual
release steps. Restore the base wording ("Version files in sync at: <v>")
plus the disclaimer, and update the three pins in main_test.go.
This also repairs a consumer neither review lane censused: the tracked
release runbook .beads/formulas/beads-release.formula.toml:475 instructs the
operator that the gate "must print `✓ Version files in sync at: <version>`
before you continue" — the renamed string had silently broken that
acceptance check. Grepping the new spelling finds nothing; the breakage only
shows up when grepping the old one.
Error Handling & Resilience (codex): --expect mismatch reused exit 1, so
.githooks/pre-push answered a tag/checkout mismatch with the version-drift
remedy ("Fix with: scripts/update-versions.sh <version>") — advice that
would rewrite every release surface to the wrong version. Give that case
status 3 and add the matching hook branch pointing at CONTRIBUTING's actual
rule. Only two --expect call sites exist: release.yml:45 (bare non-zero
check, unaffected) and this hook.
Verified at this head: check-versions.sh rc=0 (24 green rows, all three
ported base gates); exit taxonomy 0/2/3 as documented; go test
./internal/versioncheck/ ./scripts/check-versions/ PASS=65 FAIL=0 SKIP=0;
cmd/bd TestTrackedManagedHookSectionsMatchGenerator ok (hook edit sits above
the generator-managed markers); gofmt/vet clean. Both fixes proven
non-vacuous by mutating each back and requiring red.
Declined as out of cleanup scope, recorded for follow-up: making
TestRepositoryReleaseVersionsMatch fixture-based (redesigns the PR's own
test architecture and interacts with the deliberate untracked-discovery pin
at check_test.go:174; harm measured local-only) and declaring bazel data
runfiles (gate impact none — no BAZEL key in either CI_GATE_REQUIRED map at
this base; the remedy needs root filegroups that touch
scripts/bazel_policy_test.go invariants).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* test(versioncheck): declare the release-gate tests' repo inputs as Bazel data
Base commit e1b2e79484 (#6941) promoted the seven BAZEL* lanes into pr.yml's
CI_GATE_REQUIRED after this branch's merge point, so the two packages this PR
adds are now graded by a required check. Both reach real repository files
through a hand-rolled filepath.Join("..", ".."), which resolves outside the
runfiles tree, and `bazel test //...` failed on them:
TestRepositoryReleaseVersionsMatch
open ../../cmd/bd/version.go: no such file or directory
TestPrePushHookOrdinaryPushWorksWithSystemBash
runfiles .githooks/pre-push: No such file or directory
Resolve the root through internal/testutil/bazeltest.RepoRoot, the base's
helper for exactly this, which reduces to the previous behavior under plain
`go test`; and declare the inputs as data through a //:release_metadata_files
filegroup aggregating the surfaces versioncheck.releaseSources gates, the
canonical version it compares them against, the uv.lock pin and the tracked
hooks, exported from the packages that own them. The filegroup is hand-listed
because releaseSources is itself a closed list: a newly gated surface must be
added there too, and until it is the test fails under Bazel.
The shell entrypoint's exit-status subtests build the checker from source at
the repository root, which cannot work against a runfiles tree that has no
go.mod, so they skip under Bazel and keep running under `go test`. The guard
sits inside each subtest, not above the loop, so the ordinary-push assertion
still reports as run rather than hiding behind a skip.
Validation: `go test ./internal/versioncheck/ ./scripts/check-versions/` is
unchanged at 65 pass / 0 skip, with all three entrypoint subtests still
executing; both targets pass `bazel test --config=ci`; //scripts:scripts_test
(the tag-taxonomy and Bazel policy tests) passes; `bazel build //...` is clean
across 321 targets; `make bazel-sync` reports no drift and is idempotent.
* test(versioncheck): stop declaring the bazelignored npm manifest as Bazel data
The required `Bazel / test` lane failed on the refreshed head in fork-PR CI:
TestRepositoryReleaseVersionsMatch
npm package.json: open .../versioncheck_test.runfiles/_main/
npm-package/package.json: no such file or directory (expected 1.3.0)
npm-package/ is in .bazelignore (#6798), so Bazel never links it into the
execroot, and a local sandbox cannot stage npm-package/package.json even
though //:release_metadata_files named it and analysis accepted the label.
It resolved only under remote execution, where the client uploads the file
from the workspace. That is how the previous fixup's `bazel test
--config=ci` passed on a host whose bazelrc defaults to remote execution.
Fork PRs get no remote-execution secrets, so CI runs the test in
processwrapper-sandbox, where it fails.
Drop the entry from the filegroup. Under Bazel only, let
TestRepositoryReleaseVersionsMatch tolerate exactly that surface's absence:
the file must be missing, and every other gated surface, the uv.lock pin and
the hook markers must pass. The test logs the gap. This mirrors the base's
skipReleaseFormulaUnderBazel for the bazelignored .beads/. `go test`, which
sees the real checkout, still checks the npm manifest.
Validation: forcing local execution the way fork CI runs (`bazel test
--config=ci --nocache_test_results --remote_executor=
--strategy=TestRunner=processwrapper-sandbox`) reproduced the failure before
the change. After it, //internal/versioncheck:versioncheck_test,
//scripts/check-versions:check-versions_test and //scripts:scripts_test pass
(3 of 3 executed), and both release-gate targets also pass under remote
execution. Drifting a declared surface still fails the sandboxed run. The
tolerance was probed through TEST_SRCDIR and BEADS_TEST_REPO_ROOT: each of
these still fails:
- another drifted surface
- a present but mismatched npm manifest
- an unreadable canonical version
- plain `go test` with the manifest missing
`go test ./internal/versioncheck/ ./scripts/check-versions/`, golangci-lint
and `make bazel-sync-check` are clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* hooks: don't report foreign hooks as installed (GH#6084)
CheckGitHooks was calling getHookVersion and treating any nil-error
return as proof that beads installed the hook. getHookVersion returns
hookVersionInfo{} (IsBdHook=false) with a nil error when the file is
readable but contains no beads markers, so a foreign hook written by
another tool was falsely shown as installed in bd hooks list.
Fix: gate status.Installed=true on versionInfo.IsBdHook. The inner
Outdated check is unchanged in effect: it is now only reached when
IsBdHook is true (guaranteed by the new early-exit), so the
now-redundant IsBdHook guard in that condition is dropped.
Add TestCheckGitHooks_ForeignHookNotInstalled (regression for the bug)
and TestCheckGitHooks_BeadsHookIsInstalled (positive coverage for all
four recognised beads marker variants: section-marker, legacy-version,
shim, and inline).
* fix(hooks): count a bd hooks run integration as installed, not as bd-owned
Review fix for the findings filed on PR #6274 (GH#6084). Gating
HookStatus.Installed on IsBdHook also reclassified the integration beads itself
prescribes for external hook managers: a hook that calls `bd hooks run <hook>`
and carries no beads marker (GH#946). bd doctor has recognized that shape since
GH#946 via bdHooksRunPattern; cmd/bd's getHookVersion did not, so bd hooks list,
bd info and bd config drift disagreed with bd doctor about the same file, and
`bd config drift`'s documented exit code flipped from 0 to 1 for those users.
doctor.isBdHookContent is exported as doctor.IsBdHookContent and getHookVersion
now calls it, so a single classifier answers "is this a bd hook" for both
packages.
The classification is carried on a new hookVersionInfo.IsExternalIntegration
field, not on IsBdHook. IsBdHook is not only the display predicate: it is the
ownership predicate at three write sites, and setting it for a file bd never
wrote made bd destroy exactly the setup this branch exists to protect. Measured
on a scratch repo whose .git/hooks/pre-commit is `lefthook run pre-commit "$@"`
plus `bd hooks run pre-commit "$@"`, against the same tree with only
cmd/bd/hooks.go reverted:
reverted IsBdHook this commit
install: manager's own line survives yes no yes
install: pre-commit.backup written yes no yes
uninstall: hook file survives yes no yes
Both commands printed success and exited 0 in every arm, so the loss was silent
and, with no sidecar, unrecoverable. Mechanism: installHooksWithOptions
(hooks.go:1026) took the "legacy bd hook — replace entire file" arm instead of
the arm that writes the .backup sidecar and injects; uninstallHooks
(hooks.go:1438) os.Remove'd instead of reaching "not a bd hook at all — leave it
alone"; and isBdOwnedHookFile (hooks.go:913) returned true, so the tracked-file
write refusal in guardHookWritePath stopped refusing.
So ownership decisions keep asking IsBdHook, and only the two predicates that ask
"is this a working beads integration" widen: the CheckGitHooks installed gate,
and the runChainedHook recursion guard. The guard needs it — a <hook>.old that
delegates via `bd hooks run` re-enters bd, which chains to the same .old again;
it is skipped at this commit and at the previous one, and executed before either.
That is a recursion question, not an ownership question.
Reporting the shape as a shim is what keeps Outdated false. CheckGitHooks sets
Outdated when !IsShim && Version != Version, so an unversioned non-shim would be
reported outdated, `bd config drift` would still exit 1 — with a hooks.outdated
item instead of hooks.missing — and bd info would still say to run `bd hooks
install`, which would overwrite the manager's own hook. The behavior lives in the
bd binary the hook calls, so there is no hook template to re-install.
The read surface is unchanged from the previous commit and still measured on five
hooks, since CheckGitHooks iterates all five: the delegating shape reports
installed with `bd config drift` exiting 0, five genuinely foreign hooks report
not installed, and a GH#1120 inline hook is still outdated because bd wrote that
template.
Tests cover both consumer kinds. The previous commit pinned the read surface
only, which is why the write-path regression above left the suite green: the
existing install/uninstall fixtures use hook bodies with no `bd hooks run` line,
so they never took the changed branch. Adds a fixture that does, and with it an
install-backup case, a tracked-file refusal case and an uninstall-survival case.
All three fail if the classification moves back to IsBdHook, each on its own
assertion — missing .backup, nil refusal error, deleted file — while the two
read-surface tests stay green, so they pin the write surface specifically.
The recursion guard is pinned the same way. Its fixture comments the `bd hooks
run` line out: the classifier matches the call anywhere in the file, so the .old
still classifies as an external integration, but a guard that stops firing only
leaves a marker file behind instead of looping. Narrowing the guard back to
IsBdHook fails the delegating case, a guard that skips every .old fails the
plain case that must still run, and moving the classification back to IsBdHook
fails the fixture's own classification check.
Also narrows the CHANGELOG: it claimed bd hooks list, bd info, bd config drift
and bd doctor "cannot disagree about the same file", but doctor still splits
installed from missing by bare os.Stat (doctor/git.go:65) and uses the shared
predicate only for outdatedness, so the divergence is real and stays tracked
separately. And bd hooks list no longer prints the dangling `installed (shim )`
for a versionless integration — the rendered string only; HookStatus is
marshaled verbatim by --json.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* fix(init): name --recreate-missing in the refusal without a paste-ready command
The missing-server-database refusal added in #5791 ended with a complete
`bd init --recreate-missing --prefix <prefix>` line. ADR 0002 Invariant 4
keeps complete destructive invocations out of bd error output, and this
refusal also fires when the server merely could not be reached: a stopped
server, a wrong port and a wrong data dir all look the same from here, and
recreating in any of them strands the real data behind an empty database of
the same name. The line also echoed the raw --prefix flag value, so a run
without --prefix printed `--prefix ` with nothing after it.
The refusal now names the flag and points to `bd help init-safety`, which
keeps the full invocation behind the diagnosis it requires. The unused
prefix parameter stays as `_` so the guard call sites are unchanged.
Also:
- --force / --reinit-local flag help, `bd help init-safety` and the init
guard comment now say neither flag authorizes recreating a missing
server-mode database; the --recreate-missing stanza says to rule out a
stopped server or wrong port/data dir and restore first.
- bootstrap.go comments no longer describe #5791 as open and unmerged.
- TestInitGuardMissingServerDBMessage_RefusalTextNoEcho pins the wording
for both evidence arms, with and without a prefix.
- TestInitGuard_RecreateMissingE2ECreatesMissingServerDB runs the real
binary against a live server lacking the database: refused without the
flag, created with it. The unit tests flip initAllowRecreateMissing
directly, so nothing exercised the documented command end to end.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(recovery): init-missing-server-db covers both evidence arms and the flag limits
The init-missing-server-db section described only the project_id arm of the
guard. Under --reinit-local or --force a workspace that predates project_id
is also refused when its local Dolt data directory survives, and the refusal
then cites that directory instead of metadata.json. "What happened" now
covers both arms.
"Limits worth knowing" replaces the stale "fails open" bullet with a table
of which local state meets the refusal under bd init and under
--reinit-local / --force, and what --recreate-missing changes. The
init-force-refused section now says --force / --reinit-local bypass only the
local data-safety guard, not this refusal or the remote one, and step 3 says
why the refusal names --recreate-missing without printing the command
(ADR 0002 Invariant 4).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(adr): mark ADR 0004 Accepted now that #5791 has landed
ADR 0004 (the missing-database guard signal) still read "Proposed" after the
guards implementing it merged in #5791, and its Consequences said
checkExistingBeadsDataAt "does not change" although the same PR gave it the
Tier 1 probe ahead of project_id. Record the acceptance and say what the PR
already changed; DOC_INVENTORY.md follows the status.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(context): resolve from .beads when outside a git repository
`bd context` is documented to read directly from config files and work "in
degraded states", but it hard-failed with "cannot determine repository root:
not a git repository" whenever the working directory wasn't inside a git
repo — even with a valid, discoverable .beads/ present. Consumers that use
`bd context --json` as a health/identity probe got a false "unreachable" in
healthy non-git scopes (GH#4772).
When GetRepoContext returns the repo-root error, a boundary-checked .beads
directory has already been found and the only missing piece is the git repo
root. Fall back to the .beads parent as the repo root and continue, so
backend identity still resolves from config. Only this specific error
triggers the fallback; "no .beads directory found" and unsafe-location
errors still surface as before.
Adds an embedded regression subtest that removes .git from a workspace and
asserts `bd context --json` still resolves (backend/beads_dir populated, no
error). Verified end-to-end: reproduced the exact "cannot determine
repository root" error pre-fix; post-fix reports backend=dolt.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(context): select the no-git fallback by type, and cover both routes
Review follow-up on the GH#4772 fix.
The fallback was selected with strings.Contains(err.Error(), "cannot
determine repository root"). buildRepoContext's other failure — the
SEC-003 unsafe-location rejection — embeds the offending path verbatim
in its message, so the discriminator was controlled by the path being
rejected: a workspace whose path contained the probe phrase would take
the fallback and have its unsafe-location error cleared.
Replace it with a typed error. buildRepoContext now returns
*beads.NoRepoRootError, carrying the .beads directory that has already
cleared the found + safe-boundary checks — which is exactly what makes
recovering from this one failure safe, and removes the need to
re-derive it with a second FindBeadsDir call. The message text is
unchanged.
The recovery itself moves into beads.GetRepoContextAllowingNoGit, so
both `bd context` routes share it: the direct one in context_cmd.go and
the proxied one, whose provider (domain/fs contextRepositoryImpl
RepoContext + Role) propagated GetRepoContext's error unchanged and so
still failed outside git. Callers that actually run git commands keep
using GetRepoContext, so a missing repository stays an error where it
matters.
Tests:
- Discriminator regression: an unsafe-location error built with a
hostile path still matches the old substring test but does NOT
satisfy errors.As for *NoRepoRootError.
- GetRepoContextAllowingNoGit resolves a non-git workspace (BeadsDir,
RepoRoot = .beads parent, empty CWDRepoRoot) while GetRepoContext
still refuses.
- The embedded regression now decodes ContextInfo and asserts exact
beads_dir, repo_root, backend, bd_version and is_worktree instead of
probing for a key name (fields are not omitempty, so an empty or
wrong value passed before).
- Same assertions added for the proxied route.
- ngDir -> nonGitDir.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(context): report the redirect on the no-git path, and test the discriminator
Two blocking items.
B1. The synthesized context left IsRedirected at its zero value, so a
workspace reached via BEADS_DIR from a non-git working directory denied
being redirected, and Role() withheld the Contributor that
"BEADS_DIR implies contributor (external repo mode)" promises. That
contradicts the field's own contract two screens up in the same file,
and a probe sold as a health/identity check giving the wrong identity is
a worse failure than the error it replaced.
The normal path's answer is genuinely unavailable here:
isExternalBeadsDir compares git COMMON DIRS, and the CWD side of that
comparison cannot be computed without a repository — which is exactly
the state this branch serves. An explicitly-set BEADS_DIR is the only
evidence left, and it is the same signal FindBeadsDir's step 1 used to
choose the directory, so the fallback now mirrors that condition. A
.beads found by the working-directory walk still reports false.
IsWorktree stays false, with a comment saying why rather than by
omission.
B2. TestNoRepoRootError_DoesNotMatchUnsafeLocation never called the
selection. Asking errors.As about two hand-built values tests the
standard library, and passes whatever discriminator this package
actually uses — which the reviewer demonstrated by swapping the typed
check for the substring test the test is named after and watching it
stay green.
The selection is now recoverNoGit(rc, err), split out of
GetRepoContextAllowingNoGit, and the test drives it: the unsafe-location
error must come back out unchanged, and so must the no-.beads error and
a successful context. Under the reviewer's probe B it now fails, naming
the context the substring version wrongly recovered.
Nits, taken:
N1. NoRepoRootError's doc claimed the workspace "is not inside a git repo".
It means git could not tell us a root: GetMainRepoRoot bottoms out in
one `git rev-parse`, so a dangling gitfile, a dubious-ownership refusal
or git missing from PATH all arrive the same way. Recovery is equally
safe in all of them, but the command whose pitch is diagnostics in
degraded states should not swallow the fact — printContextText now
prints `cwd repo: git: unavailable` instead of nothing, which is the
text-output counterpart of the omitted JSON field.
N2. The comment on fs/context.go claimed there is no `git config beads.role`
to read outside a repo. `git config --get` reads global and system
config with no repository; I hit it by accident running the probe above,
where Role() returned "maintainer" from my own ~/.gitconfig. Comment
corrected — the behavior was fine.
N3. CHANGELOG [Unreleased] entry citing #4772, and a "Resolving Without Git"
section in engdocs/REPO_CONTEXT.md — the reference for this module,
which documented the boundary validation and the IsRedirected semantics
B1 bends but neither the new entry point nor the no-git case. It carries
the typed-selection rationale and a table of what the synthesized
context can and cannot know.
N4 (allocation) noted and left: correctness first, and two allocations on a
config-reading path is not worth a cache whose invalidation would be a new
thing to get wrong.
Reported-by: bee-ghosttrack
Agent-Signature: claude-code-opus-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(context): ask the caller's BEADS_DIR, not the one bd exported for itself
Round-2 blocker, and an embarrassing one: this is the same provenance bug I
fixed in #4795 an hour earlier, reintroduced one layer up.
beadsDirNamedByEnv read os.Getenv("BEADS_DIR") live. By the time
recoverNoGit runs, bd has already exported one: cmd/bd/context_cmd.go:75
calls prepareSelectedNoDBContext(selected) immediately before
GetRepoContextAllowingNoGit, and that ends in os.Setenv("BEADS_DIR", ...)
with whatever discovery just found. The proxied route arrives the same way
through the root pre-run. So on the no-git path EVERY walk-found workspace
reported itself as a redirect and claimed Contributor — the opposite of the
Round-1 bug, and worse, because it is the common case rather than the
unusual one. Reproduced against the built binary:
$ cd $T/proj/sub && env -u BEADS_DIR bd context --json
"is_redirected": true, "role": "contributor" ← no BEADS_DIR anywhere
internal/beads now takes the same package-init snapshot package main does,
for the same reason: provenance has to be captured before the process starts
overwriting the evidence. beadsDirNamedByCaller compares against that.
Two things worth recording while I was in there. First, a redirect FILE
cannot be missed by this branch: buildRepoContext checks GetRedirectInfo()
at step 3, and a redirect sends it down the isExternal branch that never
asks git for a root — so by construction the only redirect this code can be
looking at is a caller-named BEADS_DIR. That is now a comment rather than an
assumption. Second, the unit tests passed through the bug because they drive
recoverNoGit directly with an env they set themselves, which is exactly the
distinction that cannot be tested in process.
So the regression is end-to-end, on both routes, as asked:
- assertNonGitContext (shared by the embedded and proxied route tests) now
asserts is_redirected == false for the walk-found case. Reverting the fix:
"is_redirected should be false for a .beads found by the
working-directory walk".
- a new embedded subtest runs the binary from an unrelated directory with
BEADS_DIR supplied in the subprocess environment — the only place a
caller-supplied value is distinguishable from a bd-exported one — and
asserts is_redirected == true AND role == contributor.
N1: the `cwd repo: git: unavailable` line was unpinned (their probe P3
deleted the branch and every -run Context test stayed green).
TestPrintContextText_* now pins all three cases: empty CWD repo root reports
git unavailable, a matching one prints nothing, a differing one prints the
path and must NOT say unavailable. Deleting the branch now fails. Kept as an
in-process capture rather than another subprocess, since cmd/bd has no
runtime budget to spare (GH#6253).
N2: filed as GH#6560 — and my attribution on the PR thread was wrong. It is
not a legacy ~/.beads/config.yaml (I have none); it is BEADS_ACTOR in the
environment, which resolveConfiguredActor deliberately checks ahead of
config.yaml as the fix for GH#4645. `env -u BEADS_ACTOR` makes both tests
pass.
Reported-by: bee-ghosttrack
Agent-Signature: claude-code-opus-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* chore(bazel): enumerate the PR's two new test files in go_test srcs
Pre-review CI repair for PR #4792. The helper reads CI Readiness: pass, but
those nine green runs were created 2026-09-23 against the contributor head
961aa6239 -- before this branch was rebased onto 8269a88cb, an advance that
brings in the entire Bazel scaffold (.bazelrc, .bazelignore,
.github/actions/setup-bazel). So the green cohort predates the Bazel lanes
entirely and cannot certify them; the adopted head has never been seen by CI.
Both affected packages declare go_test srcs as an EXPLICIT list, not a glob, so
the PR's two added test files were invisible to bazel:
cmd/bd/BUILD.bazel + "context_text_test.go"
internal/beads/BUILD.bazel + "no_repo_root_test.go"
Base parity puts the obligation on this PR rather than on base: neither file
exists at the rebase base, so neither row could have been owed there.
The failure mode is a FAKE GREEN, not a red, which is why no check caught it.
Measured on //internal/beads:beads_test: with the row, bazel runs
TestGetRepoContextAllowingNoGit_RecoversOutsideGitRepo (rc=0). With the row
removed, the target still exits 0 -- and that test never runs. A silently
unexecuted regression test is exactly what this enumeration prevents.
Generated by the repository's own `make bazel-sync` (gazelle); the rows are
placed alphabetically, the diff is +1/-0 per file, and a second sync is a no-op.
* fix(context): root the no-git context at the .beads repo and decide redirects positionally
Maintainer review fixups for the two gating findings on the no-git recovery
path, plus the nearby non-gating cleanups.
Finding 1 (major) -- recoverNoGit rooted repo_root at filepath.Dir(BeadsDir),
but the failure that reaches it is the CWD's missing repository, not the
.beads's. A .beads that did live inside a repo therefore reported a
SUBDIRECTORY of that repo, so one workspace answered differently depending
only on where the caller stood. Root via repoRootForBeadsDir, which asks git
from the .beads side (needing no CWD repo) and already falls back to
filepath.Dir(beadsDir), so the documented no-git-anywhere answer is unchanged.
The conflated premise is corrected in the field comment and in
engdocs/REPO_CONTEXT.md.
Finding 2 (major) -- the provenance snapshot was captured at package init and
covered only BEADS_DIR, but bd has four caller-directed workspace channels:
--db, BEADS_DB/BD_DB and -C all resolve through selectedNoDBBeadsDir and end
in an os.Setenv("BEADS_DIR", ...) that runs after init, so the snapshot could
not see them and they reported is_redirected:false / role:maintainer outside
git. Decide externality POSITIONALLY instead: the resolved .beads is a
redirect iff discovery standing in the CWD would not have found it. This is
the reviewer's preferred arm -- it needs no environment inventory, so it
covers all four channels uniformly and stays correct as channels are added (a
further BEADS_DIR writer already exists in cmd/bd/doctor.go). It reuses
FindBeadsDirFrom, the same primitive -C itself resolves through, which reads
none of the routing variables and scrubs routing env from its git probe. The
package-init snapshot and its helper are removed. The boundary the review left
unspecified is settled deliberately: a store reachable only by being named is
a redirect, including one in a sibling directory of the CWD, because with no
repository for the CWD there is no enclosing scope that could make a sibling
local.
Finding 3 (minor) -- TestGetRepoContextAllowingNoGit_RecoversOutsideGitRepo
now scrubs BEADS_DIR, which takes priority at FindBeadsDir step 1. Measured:
three assertions fail under an ambient BEADS_DIR without the scrub and the
package is ok with it. The remedy's second part (stubbing the init snapshot)
is obsolete rather than skipped -- positional provenance reads no snapshot, so
there is nothing left to stub.
Findings 4 and 5 (nits) -- the beadsDirFromCaller / GH#4635 cross-reference
resolved to nothing at head or at base; it is gone along with the snapshot it
described. The CWDRepoRoot comment now states the value is known-empty because
the one cached git context its three readers share has already failed, which
is also a firmer justification for IsWorktree: false than "there is none".
Verification: both majors are pinned by new tests proven to red when the fix
is reverted, and measured end to end with a built binary from a non-git cwd --
BEADS_DIR, BEADS_DB, BD_DB, --db and -C all now report is_redirected:true /
role:contributor, while a walk-discoverable workspace correctly reports
false / maintainer. Contributor commits are preserved.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
#5677 made addToGitignore preserve a CRLF .gitignore by consuming
gitignore.AppendLineEnding, but it re-implemented the rest of the #6343
append policy inline: the final-line completion, including the rule that a
trailing CR is completed with a bare LF. That policy already lives in
gitignore.AppendLines, which the three other project-ignore writers call.
The two copies are byte-equivalent today, and only one of them is
discoverable when the policy changes.
Derive the appended bytes from AppendLines instead. Its contract leaves the
existing bytes unchanged, so everything past len(content) is exactly the
append, and writing only that suffix keeps the O_APPEND handle: the user's
.gitignore is still appended to, never truncated and rewritten. The write
also becomes a single Write call instead of a separator write followed by an
Fprintf.
No behavior change. The call-site tests pass unmodified, byte for byte. The
doc comment on TestAddToGitignoreCompletesUnterminatedCRLFLine is reworded
because it described the removed separator variable; the arm it pins, and
why only that test reaches it, are unchanged.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(epic): do not treat duplicate/wontfix closes as complete
GetEpicsEligibleForClosure counted any closed child as complete work.
An epic whose only child was closed as duplicate (or wontfix/superseded)
was flagged "complete-but-unclosed" and doctor suggested bd close — even
when the epic still had unfinished scope (GH#5026).
- Fetch close_reason with status; only completing closes count for eligibility
- IsNonCompletingClose for duplicate/wontfix/superseded/obsolete keywords
- Soften doctor/mol stale copy: review scope before closing
Fixes#5026
* fix(epic): word-boundary close-reason matching + conformance coverage (GH#5026)
Review follow-ups from maphew on #5138:
- IsNonCompletingClose now matches close_reason on word boundaries via a
precompiled regexp instead of raw strings.Contains. Bare "dup" is dropped
(redundant with duplicate/dupe, only added false positives on "dedup").
Bare "obsolete" is dropped in favor of "obsoleted" — "removed obsolete
migration shim" is completing work, not a redirect, and was silently
making such epics ineligible forever with no explanation.
- testAuditEpicsEligiblePartial (conformance, runs on every backend) gains
an ee-4 epic whose only child closes with reason "duplicate of ee-1",
asserting {Total:1 Closed:1 Eligible:false} — the dcr-tf2 regression from
#5026 end to end. Its doc comment now states the invariant this PR
actually enforces (Total == completing-closed), not the one it broke.
- cmd/bd/info.go and cmd/bd/doctor/maintenance.go no longer advertise the
retired "complete-but-unclosed" framing.
Generated CLI docs (docs/CLI_REFERENCE.md, docs/cli-reference/) are left
untouched: docs/cli-docs.pin freezes them to the released v1.1.0 tag, so
regenerating with the pinned build (matching CI's check-doc-flags job) is
a no-op regardless of source changes on this branch, and overriding the
pin pulls in ~100 files of unrelated accumulated drift. Verified via
scripts/check-doc-flags.sh against a CI-equivalent CGO_ENABLED=0 build.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015AfaSMkMRF5BTzuPNFnqHY
* fix(epic): match hyphenated wont-fix and curly-apostrophe won't fix (GH#5138)
Maintainer review on GH#5138 found the close-reason regexp missed two
forms of the already-handled wontfix keyword: a hyphen between "wont"
and "fix" (the ` ?` quantifier only tolerates a space, not a hyphen),
and "won't fix" written with the U+2019 typographic right single
quote instead of the ASCII apostrophe.
Extend the regex directly rather than normalizing the whole
close-reason string: `wont[- ]?fix` accepts a hyphen, a space, or
neither, and `won['\x{2019}]t fix` accepts either apostrophe form.
Scoping the hyphen tolerance to just this keyword pair (rather than
folding all hyphens to spaces) avoids the risk of turning unrelated
hyphenated prose into a false match.
Adds table cases for both forms plus a negative case confirming
ordinary hyphenated prose ("not-yet-planned") still doesn't match.
* style: gofmt maintenance.go after comment split the struct alignment
The GH#5026 wording comment inside the DoctorCheck literal splits gofmt's
alignment group, so Name/Status align independently of Message. CI's
"Check gofmt" caught this on the rebase; main's copy is clean, so the
violation is ours.
Whitespace only: `git diff -w` is empty.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(epic): compose wont-fix separators, sync epic_closeable classifier (GH#5138 review)
bee-ghosttrack's desk review on PR #5138 raised two asks:
1. The hyphen and curly-apostrophe fixes didn't compose: "won't-fix" and
"won't-fix" (curly quote) still matched as completing. The apostrophe
alternative in nonCompletingCloseRegexp required a literal space after
"fix"; give it the same [- ]? hyphen tolerance the plain "wont[- ]?fix"
alternative already had.
2. epic_closeable (internal/workapi/detail.go) computed closeable as raw
total==closed, disagreeing with issueops.GetEpicsEligibleForClosureInTx's
real classifier — an epic whose only child closed "duplicate of X" read
epic_closeable=true in `bd show --json`. Moved IsNonCompletingClose from
issueops into the leaf internal/types package (issueops already imports
workapi, so workapi importing issueops back would cycle) and had
applyEpicProgress apply the same classifier. That also surfaced a second
bug on the way: shallowDep, which every dependent row passes through
before applyEpicProgress ever sees it, was dropping CloseReason along
with the other free-form text fields — so the classifier was reading an
always-empty string. Fixed by keeping CloseReason (short, not a hub-scale
blob) in the shallow copy.
Regression test in workapi added and verified to fail without the
shallowDep fix and pass with it (both outputs recorded in review).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(epic): apply the eligibility classifier to bd show and doctor --deep (#5138 review)
Review iteration 1 (synthesis: request_changes, 1 major + 1 nit).
Major (Change Impact / Blast Radius) — two surfaces still computed epic
closeability from their own raw closed counts, so after this PR they
contradicted the eight sites that read the shared EpicStatus.EligibleForClose:
- cmd/bd/show_format.go: printEpicChildProgress gates only the
"— eligible for close" suffix on types.IsNonCompletingClose. The
closed/total figure stays raw, matching the deliberate raw ClosedChildren
convention pinned by the conformance test.
- cmd/bd/doctor/deep.go: checkEpicCompleteness routes through
issueops.GetEpicsEligibleForClosureInTx instead of its own SQL, so one
classifier remains and `bd doctor --deep` agrees with `bd doctor`'s Stale
Molecules check by construction. Side effects, both improvements: the local
LIMIT 20 is gone (the reported count is now exact), and the shared query's
isTableNotExistError tolerance replaces a LEFT JOIN that required the
optional wisps/wisp_dependencies tables unconditionally.
- cmd/bd/doctor.go: the --deep help text no longer says "all children closed".
Nit (Behavioral Correctness) — internal/types/non_completing_close.go spells
the keyword "not[- ]?planned", giving it the same per-keyword separator
tolerance the "wont fix" pair already had. The comment no longer rests the
space-only spelling on the "not-yet-planned" counterexample, which an
intervening word blocks under either spelling.
Bazel: gazelle had never been run for this PR's new files, so //internal/types
omitted non_completing_close.go and the Bazel build failed with
"internal/workapi/detail.go:275: undefined: types.IsNonCompletingClose".
`bazel run //:gazelle` adds those rows and the new cmd/bd test src.
Tests (each new pin mutation-proved: reverting the fix reds exactly the
intended case and nothing else):
- cmd/bd/show_format_test.go (new): first coverage for printEpicChildProgress;
asserts both halves — raw progress preserved, suffix gated.
- cmd/bd/doctor/deep_test.go: a duplicate-closed-child epic is not reported
ready to close and ships no `bd close` Fix line; the three pre-existing
cases pass unchanged.
- internal/types/non_completing_close_test.go: "not-planned"/"notplanned"
classify as non-completing; "not-yet-planned" still does not.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
* test(cli): scope workspace and Git caches together
Add resetRepoCachesForTest for serial fixtures that change directories.
Reset both successful and failed discoveries on entry and cleanup, and use
it in the three remaining beads-only context/serve reset sites.
Exercise non-repo to nested repository to non-repo discovery through both
cache owners. Preserve runInDir's callback lifetime and the two original
fixture repairs already owned by PR5747.
Fixes#6207
Reported-by: bee-ghosttrack
Bead: saa-cgh.92
Agent-Signature: unknown-model/unknown-reasoning
* test(cache): leave conventional helper filename available (saa-cgh.92)
Agent-Signature: unknown-model/unknown-reasoning on behalf of Ewen Cuthiell
* test(cli): apply review fixes — one reset invariant, gazelle-synced srcs
Maintainer review fixup for #6320 (iteration 1). Both minors from the review
synthesis; no blocker or major was filed.
Architectural Consistency (minor, both lanes): runInDir reset only the Git
cache, the inverse of the leak this PR fixes — a workspace context primed by an
earlier fixture survived its chdir. Extract the pair into resetRepoCaches() so
one definition owns the invariant, and route both resetRepoCachesForTest and
runInDir through it. Deviation from the synthesis's parenthetical "(or
resetRepoCachesForTest)": calling that helper inside runInDir would move the
exit reset from runInDir's own defer to a t.Cleanup at end of test, dropping
the before/after guarantee its doc comment states, so the shared closure is
extracted instead. The doc comment is updated to match the widened behaviour.
TestRunInDirScopesWorkspaceDiscovery pins both halves. Restoring the git-only
entry reset reds it at :94 ("no .beads directory found" — the finding's own
observable); restoring the git-only exit reset reds it at :110 with the leaked
context. In both arms the existing TestResetRepoCachesForTestScopesDiscovery
stays green, so the new test covers an uncovered site rather than duplicating
it.
Test Evidence Quality (minor, codex): the new test file was absent from the
gazelle-managed go_test srcs list, so bazel test never ran it. Ran make
bazel-sync (gazelle, go_srcs.py, mod tidy) rather than hand-editing. Its entire
output was three srcs lines: ours, plus two base-inherited absentees that
landed in this PR's own base commit. Only the line for the file this PR adds is
carried here, because shipping all three conflicts with origin/main. Measured,
not assumed: git merge-tree --write-tree against origin/main puts BUILD.bazel
in the conflict set with all three lines and merges it cleanly with one, while
the merged tree's bd_test srcs holds the same 648 entries — including all three
files — either way, since origin/main has already gazelle-synced the two
base-inherited ones. The one-line form is therefore what gazelle emits at the
merge target, and it leaves the base's own drift as found rather than fixing it
in this PR.
Validation: 32 tests covering all 22 package-main runInDir call sites pass
before and after with an identical name-level PASS set; the PR's four affected
tests plus the new pin are 5/5 anchored PASS; go vet, gofmt, git diff --check,
golangci-lint (0 issues) and go_srcs.py --check all clean.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* feat(label): add --prefix to bd label remove
bd list/bd ready already support --label-pattern/--label-regex for
finding issues by label shape. label remove had no equivalent for
stripping a whole label family in one call: callers had to fetch an
issue's labels themselves and issue one exact-match "bd label
remove" per matching label.
--prefix resolves the matching labels per issue (labelsWithPrefix, a
plain strings.HasPrefix filter over the labels already returned by
GetLabels) and removes them in a single transaction. Implemented for
both the embedded store path and the proxied-server (bd serve) path,
wisp-aware in the latter via workapi.GetIssueOrWisp — gc bd in Gas
Town runs proxied against a shared Dolt server, so an embedded-only
implementation would not have been usable there.
TDD: pure-function unit test (TestLabelsWithPrefix), plus embedded
and proxied CLI-level integration test cases mirroring the existing
label_remove_batch/add_list_remove conventions. Full existing
cmd/bd label suite re-run green (24/24 embedded subtests) for
regressions. The new proxied integration subtest could not be run
locally (this environment has no Docker, which the
testcontainers-go Dolt harness requires) but compiles clean under
go vet and golangci-lint and mirrors the existing, working
labelMutateProxied/runLabelListProxiedServer structure exactly.
Ref: ga-r8haw (gastownhall Gas Town city, Proposal 1).
* fix(label): address review feedback on --prefix (tense, arg validation, help text)
steveyegge's PR review (2026-08-08) asked for three small fixes before
merge, none of which the two subsequent rebases (2026-08-29, 2026-09-07)
touched:
1. Error-string tense: both label-remove failure paths (applyLabelEdit,
shared with label add; removeLabelsByPrefix) rendered "label
removed"/"added" on a FAILURE, claiming success on the very branch
that reports an error. Added labelOperationGerund() and used it on
both failure paths ("removing"/"adding"); the success-path constants
(labelOperationAdded/Removed, used by reportLabelEdit's JSON status
and human-readable verb) are untouched — they were already correct.
2. Reject --prefix combined with a label-shaped positional explicitly:
`bd label remove bd-1 stale-label --prefix x` used to hand ALL
positionals to resolveLabelIssueIDs, which (a) failed with a
confusing "could not resolve issue ID" error whose hint recommends
the exact comma-separated label syntax --prefix does not take, and
(b) left a live (if unlikely) risk that ResolvePartialID's fuzziness
could silently resolve a label-shaped string to an unrelated real
issue. Added resolveIssueIDsForPrefix, used only by the --prefix
branch of labelRemoveCmd's RunE, which fails with an explicit
"cannot combine --prefix with label arguments" instead.
3. Sharp-edge guard: per the reviewer's "at minimum" option, expanded
the --prefix flag help text to name the blast radius (a short
prefix can remove multiple unrelated label families in one
transaction) and point at `bd set-state` for state-dimension labels
(launch:, scalegate:), which --prefix bypasses without the
event-bead audit trail bd set-state provides.
TDD: new TestLabelOperationGerund (pure unit) and
label_remove_prefix_rejects_label_shaped_positional (embedded CLI
integration, mirrors the existing label_remove_prefix* subtests) —
both confirmed RED against the pre-fix code (temporarily reverted,
re-run, restored) before GREEN. Full cmd/bd label suite re-run green:
25/25 embedded subtests (24 pre-existing + 1 new), no regressions.
go vet + gofmt clean.
Ref: ga-r8haw (gastownhall Gas Town city, Proposal 1 — addresses the
2026-08-08 review verdict "MERGE AFTER FIXES (small ones)" on PR #5384).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* chore(bazel): add label_prefix_test.go to cmd/bd go_test srcs
cmd/bd/BUILD.bazel enumerates go_test srcs explicitly, so this PR's new
label_prefix_test.go was absent from the list. bazel.yml's "BUILD files in
sync" step runs `make bazel-sync` and exits 1 on any resulting drift
(.github/workflows/bazel.yml:382-406), and that job feeds pr.yml's
required CI_GATE_REQUIRED contexts (BAZEL, BAZEL_TEST, BAZEL_PURE, ...),
so the branch would red a required gate.
The bazel lane did not exist at the merge base the PR's green CI run was
built on, so no existing green covers it.
Generated with `make bazel-sync` (gazelle); re-running it is a no-op.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(label): report --prefix removals from the write result, not the pre-read set
Review fixes for the adopted PR. The gating finding is the reporting
contract on the new --prefix path.
MAJOR - removeLabelsByPrefix discarded the UpdateResult (`if _, uerr :=
lifecycle.Update(...)`) and then printed one `status: "removed"` row and one
`✓ Removed` line per entry in the pre-read snapshot, so it asserted label
removals that had not happened. That is the GH#5988 false-confirmation
defect base commit 0b9e644ba9 removed from the sibling path three commits
earlier, reintroduced on a new surface that never called the handler which
fixes it.
The path now builds a labelEditOutcome per issue from the returned
UpdateResult and reports through reportLabelEdit, the same handler the plain
path uses, so an edit that wrote nothing reports "unchanged" and the human
"was not on" line instead of a removal. Per-label attribution stays
best-effort on the same terms applyLabelEdit documents (the Get is outside
the write transaction); what is no longer possible is claiming a removal for
an edit that wrote nothing at all.
labelEditOutcome carries its own label set, because --prefix resolves a
different set per issue while applyLabelEdit repeats one caller-supplied
set. reportLabelEdit therefore reads outcome.labels and its shared `labels`
parameter is gone; it had one caller before this change and has two now.
resolveIssueIDsForPrefix collapses duplicate ids. Naming one issue twice
used to yield two "removed" rows per label deterministically - the grouping
map recorded the repeat once, but the report loops iterated the ungrouped
pairs - which is the arm that needed no concurrency to reproduce.
Minors from the same review:
- cmd/bd/label.go:159 passed the past-tense `operation` constant into an
error string, the anti-pattern this PR's own labelOperationGerund exists
to remove; the site is byte-identical at base, so the PR did not introduce
it, it shipped the remedy and applied it 13 lines below only.
- resolveIssueIDsForPrefix prefixed EVERY resolution failure with "cannot
combine --prefix with label arguments", blaming a lone typo'd id on an
argument mistake the caller did not make. The hint is speculative, so it
is now gated on len(issueIDs) > 1, matching resolveLabelIssueIDs' twin.
- The --prefix help text claimed a short prefix "removes every match in one
transaction", but a multi-issue call is one Update per issue and can land
some and fail others - the partial application applyLabelEdit documents.
Reworded to per-issue semantics, keeping the breadth caution. The same
overclaim was in this PR's own CHANGELOG entry and is reworded there too.
Tests: six subtests on TestEmbeddedLabel covering the surfaces that had no
guard - the --json row shape, the no-match empty array, two issues with
different matching sets, the duplicate-id arm, an already-removed re-run,
and the lone-bad-id message. The duplicate-id case is the pin for the
major: run against the pre-fix label.go it gets 4 rows for 2 labels. The
re-run case is not a pin. A re-run matches nothing and takes the no-match
branch before any write, so it passes against the pre-fix code too; the
"unchanged" report it cannot reach is covered through the shared handler
by the plain path's GH#5988 subtests.
Verified at this head: cmd/bd TestEmbeddedLabel 36/36 subtests and
TestProxiedServerLabel 22/22 PASS (BEADS_TEST_EMBEDDED_DOLT=1 and
BEADS_TEST_PROXIED_SERVER=1, ambient BEADS_* scrubbed), TestLabelsWithPrefix
5/5, TestLabelOperationGerund 3/3, 0 FAIL and 0 SKIP; the GH#5988
discovery-suite regression checks for the plain path
(TestDiscovery_LabelRemoveNonexistentSilentSuccess,
TestDiscovery_LabelAddDuplicateReportsAdded) PASS; build, vet and gofmt
clean; `make bazel-sync` produces no drift (no files added); and
scripts/check-doc-flags.sh passes, including the CLI docs freshness gate.
Measured complexity moved down where it changed: removeLabelsByPrefix
cyclomatic 16 to 12 and cognitive 21 to 16; reportLabelEdit is unchanged at
12 and 25.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
* fix(pour): reject --var names the proto cannot consume
An unrecognized --var name was dropped without comment. The failure that
surfaces is not a missing substitution but a missing step: a typo in an
optional var leaves its condition evaluating against an unset name, so
the conditional step is quietly never poured and the molecule looks like
it simply does not have that step.
checkPourVars now rejects names that no proto in the pour declares in
VarDefs or references as a {{handlebar}}, listing what is available.
Anything that could still affect the pour is accepted: a documentation
handlebar the formula never declared, and a var belonging to an --attach
proto rather than the root, both pass. Missing required vars are reported
first, unchanged, since the caller's hint is derived from them.
That hint is now only attached when a required var really is missing.
It interpolated missingVarHint unconditionally, so any other failure from
checkPourVars would have advised "--var =<value>".
* fix(wisp): reject --var names the proto cannot consume
bd mol wisp validates vars through checkRequiredVars rather than
checkPourVars, so the unknown-name rejection added for pour did not reach
it and a typo was still dropped without comment on the wisp path.
Route it through the same check. A wisp instantiates one proto with no
attachments, so the known set is that proto's declared vars plus the
handlebars it references.
The missing-var hint is now only attached when a var really is missing
here too, matching pour: otherwise any other failure from this check
advised "--var =<value>".
* fix(pour): count a var used only by a step condition as consumable
checkUnknownVars built its known set from the cooked subgraph, so it could
not see step conditions: formula.FilterStepsByCondition consumes them and
drops the steps carrying them BEFORE the cook, and nothing requires a
condition var to be declared in [vars]. An undeclared var that decides
which steps get poured therefore left no trace anywhere the check looked,
and a hard error turned a working pour into a failing one - exactly the
case the rule ("a name is rejected only when nothing in the pour could
consume it") means to accept.
TemplateSubgraph gains ConditionVars, recorded by
resolveAndCookFormulaWithVars immediately before the condition filter runs
- the last point at which those names are still visible. Collected
unconditionally, since they are a property of the formula rather than of
this pour's --var values, which is what makes the falsey case work: the
step is gone, and the var that removed it still counts. knownVarsAcross
adds them. A persisted proto loaded from the database leaves the field
empty, correctly: it has no formula behind it and its conditions were
resolved at cook time.
The reviewer's reproduction, against the pre-fix code:
Error: unknown variables: has_spike (available: story)
Regression coverage answers the fifth review point as well - that every
existing test called checkPourVars directly with a hand-built subgraph,
which is precisely why this was invisible.
TestBdMolPour_AcceptsAVarUsedOnlyByAStepCondition runs the CLI through the
real cook pipeline with has_spike both true and false (the falsey case
being the one that regresses if the collection ever moves after the
filter), plus a typo case proving the widened set does not disable the
check. Two unit cases cover the same pair.
The check does not disable itself: a typo in a condition var is still
reported, now with the condition var among the available names.
Non-blocking review points 3 and 4: pour's and wisp's --var flag help says
an unusable name is an error, and the CHANGELOG entry states the new
behavior and says plainly that `bd mol bond --var` and `bd mol seed --var`
remain out of scope - both go through formula.ValidateProvidedVars, which
only iterates declared vars and so never examines a provided name with no
VarDef.
On review point 2 (the interaction with #5758): no action needed either
way round. #5758 widens extractAllVariables itself, and knownVarsAcross
calls that same function, so a var referenced only from a step's
assignee/labels/metadata joins this known set automatically when #5758
lands, in whichever order the two merge.
Reported-by: bee-ghosttrack
Agent-Signature: claude-code-opus-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test(pour): exercise the real cook pipeline without spawning a binary
The end-to-end case spawned an embedded bd and ran three CLI invocations,
the most expensive shape of test in cmd/bd - and cmd/bd already runs 477s
of its 600s budget on the macos runner, so the addition timed the package
out.
The process boundary was not the point. What the unit tests could not see
was the ORDERING inside the cook pipeline, and
resolveAndCookFormulaWithVars takes its search paths as an argument, so
the real pipeline - control flow, expansions, FilterStepsByCondition, the
cook - runs directly against a formula in a temp dir. Same coverage in
0.01s instead of 32s.
It is also a sharper test than the CLI version was. It now asserts the
PREMISE of the falsey case (that the conditional step really is absent
from the cooked subgraph, so the case is testing the ordering rather than
passing for an unrelated reason), and that the typo error offers the
condition var among the available names, which is the actual user-visible
point of carrying those names into the known set.
Both reds confirmed, including the near-miss: with the known-set change
reverted all three cases fail, and with the collection moved to AFTER the
condition filter - the plausible fix, and the one the reviewer's suggested
call site would have produced - has_spike=true passes while has_spike=false
still fails:
--- FAIL: .../has_spike_false
pour rejected a var its own step condition consumes (has_spike=false):
unknown variables: has_spike (available: story)
Agent-Signature: claude-code-opus-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* docs(changelog): move this PR's entry under [Unreleased]
The 1.3.0 cut renamed the old [Unreleased] block, so the entry this branch
added there now merges cleanly into the released [1.3.0] section (#6643).
Agent-Signature: claude-code-opus-5-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* chore(bazel): enumerate the PR's new cmd/bd test files in go_test srcs
gazelle-generated. cmd/bd/BUILD.bazel lists go_test srcs explicitly, so the
two untagged test files this PR adds would not run under the advisory Bazel
lane added in #6881. Base parity at 6da2a4347 is exhaustive for untagged
tests (the only two unenumerated files are //go:build cgo && integration),
so the omission is PR-introduced rather than a pre-existing pattern.
Produced by make bazel-sync; no deps line was needed because go_test embeds
:bd_lib, which already depends on //internal/formula and //internal/types.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* fix(pour): read every substituted field into the unknown-var known set
Maintainer review fixup for the unknown-`--var` refusal. The refusal failed
CLOSED on a known set narrower than what the pour actually substitutes, so it
rejected names the clone demonstrably consumes.
- knownVarsAcross read the five prose fields only, missing a gate's await_id
and a gh:* gate's metadata.repo selector; a formula's `repo = "{{gate_repo}}"`
is stored literally on the proto and filled in at clone time, and nothing
mirrors that name into a scanned field. substitutedIssueFields now mirrors
cloneSubgraphInto's substitution set, and gateRepoSelector is factored out of
substituteMetadataRepo so the read and write sides of the selector cannot
disagree about which issues carry one.
- a proto loaded from the database has no formula behind it, so its [vars]
declarations are gone and a declared-but-unreferenced name cannot be told
apart from a typo. `VarDefs == nil` does not identify that case - a formula
declaring no [vars] is also nil, and that proto really does take none - so the
cook stamps DeclaredVarsKnown and the refusal stands down without it. That
covers every `bd cook --persist` proto and every --attach proto, which is
always DB-loaded.
- a handlebar living only inside a step the condition filter dropped left the
known set, so `--var deploy=false --var deploy_target=prod` failed while
deploy=true succeeded. ConditionVars becomes FormulaVarRefs and is collected
from the unfiltered steps' text and gate fields as well as their conditions,
making a name's validity a property of the formula rather than of another
var's value.
- a standalone `type = "expansion"` formula has no [[steps]]:
MaterializeExpansion builds them from its [[template]] before the cook,
substituting --var values into single-brace `{name}` placeholders, so a name
used only there was consumed and then refused as unknown.
formula.ExpansionVarRefs reports those names by running that same expansion
- expandStep now wraps expandStepWith - with a substitution that records
instead of replacing, so it covers exactly the fields the expansion fills in,
including a name that `{target.description}` pulls in from the formula's own
description. cook adds them to FormulaVarRefs ahead of the filter, and
without MaterializeExpansion's has-Steps skip: the filter can remove every
step, and then the template is materialized after all.
The hint-suppression branch was hand-copied to three sites and tested at none;
it is now handleVarErrorWithHint, pinned by a stderr assertion that an
unknown-var error prints no `Provide them with: --var =<value>`.
Tests: table cases for both gate fields and for `repo` on a non-gh gate staying
unsubstituted (the polarity that keeps the read side honest), for the DB-loaded
stand-down directly and via an --attach proto, and real-pipeline cases for the
dropped-step var, for vars only a dropped step's gate uses (await_id and a
gh:* repo), and for a template-only placeholder var, whose typo is still
refused with the real name offered. ExpansionVarRefs is pinned per substituted
field, per field the expansion drops (notes, condition), and for an expansion
formula that also has steps. Mutating each arm reds exactly the matching cases
and nothing else.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Julian Knutsen <agent@gascity.ai>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
* fix(config): unset a nested key in config.yaml instead of reporting a no-op
commentOutYamlKey matched only a flat "a.b:" line, so unsetting a key
written in nested form left the file untouched while bd printed
"Unset <key> (in config.yaml)" and the value stayed effective. The write
side does not have this limitation: SetYamlConfig routes dotted keys
through updateNestedYamlKey, and readUserGlobalYamlValue accepts either
shape, so bd could produce and read a nested key it could not remove. The
shipped config.yaml template documents the nested form in its commented
examples, which is the likeliest way a user acquires one.
Locate the leaf through the yaml node tree and comment out its source
line rather than re-marshalling, so the file's comments and layout
survive. A leaf whose value is not a scalar on the key's own line is
refused: commenting one line of a multi-line value would leave the file
unparseable. The flat form is still tried first and still wins when a
file somehow carries both.
* fix(config): do not comment out a yaml key whose value is the block below it
commentOutYamlKey matched any line opening with the key, so unsetting a
key that names a mapping commented out only that line and left the block
beneath it indented under nothing. The result does not parse, and the
next bd command in that workspace fails to read its config rather than
losing one setting.
Skip a match whose value is empty and whose following content line is
indented deeper: that line is the head of a block, not a setting. A key
with a genuinely empty value is still commented out, including at end of
file, where there is no following line to judge.
* fix(config): clear the config.yaml layer on unset of a database-backed key
bd config unset routes a key IsYamlOnlyKey does not claim to
UnsetSetting, which deletes the database row and nothing else. A key that
also appears in .beads/config.yaml therefore survived its own unset:
"Unset <key>" was printed, and bd config show still resolved the value
from config.yaml on the next read. types.custom and types.infra are the
keys this bites, since neither is yaml-only and both are read back out of
the file.
Clear the file layer too when the key is set there, and name the
locations that were actually cleared so the message can be trusted. The
JSON form gains the same location field the yaml-only branch already
emits. Removing the key from config.yaml comments the line out rather
than deleting it, so the file keeps documenting the setting.
Stacked on the nested-key fix: without it this path would report
config.yaml as cleared while a nested key stayed effective.
* style(config): fix the misspell lint on the new doc comment
golangci-lint's misspell linter fails the PR on "re-marshalling" in the
commentOutNestedYamlKey doc comment: the enforced spelling is
"marshaling". Comment-only change.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(config): report the unset location from the write, not a merged pre-check
Two blocking items from review.
1. The location guard read viper's resolved value, not the config.yaml
layer. config.GetYamlConfig is v.GetString on the merged viper, which
serves SetDefault values and AutomaticEnv, so every non-yaml-only key
with a non-empty default (no-hooks, no-db, json,
events-journal-retain-days, events-journal-auto-prune) looked present in
config.yaml even in a workspace with no config.yaml at all. That meant
bd printed "Unset <key> (in database, config.yaml)" over a file it never
touched - a more specific false claim than the message this PR set out
to remove - and, with no project config.yaml, failed the command with
"no .beads/config.yaml found" AFTER the database row was already gone,
where main printed "Unset <key>" and exited 0.
UnsetYamlConfig (and UnsetUserYamlConfig) now return whether the file
was actually changed, threading out the found/ok that
commentOutFlatYamlKey and commentOutNestedYamlKey already computed. A
missing project config.yaml, and a key not present in a shape that can
be safely commented, are both (false, nil) - "not in config.yaml" is an
answer, not a failure. The command clears the layer unconditionally and
derives the location from the result, so the string is a report of the
write rather than a guess made before it. That also settles the
non-blocking third point: a refusal path can no longer print "Unset ..."
over a no-op.
2. commentOutNestedYamlKey over-deleted a flow mapping. It accepted any
leaf whose key and scalar value shared a line, but in flow style the
leaf's line IS the parent's, so `unset dolt.mode` commented out
`dolt: {mode: server}` whole and took the entire mapping with it. On
main the flat regex never matched this, so the loss is new. The leaf now
has to start at the line's first non-space column.
Also from review: commentOutFlatYamlKey splits instead of scanning, so a
flat unset keeps the file's trailing newline like the nested and no-match
paths always did; and the "flat form wins when both are present" case says
why the nested copy survives, and what `changed` does and does not claim
when it does.
Regression coverage: four commentOutYamlKey cases (two flow-mapping, two
trailing-newline), a changed/content agreement assertion across the whole
table, and two embedded CLI subtests - one proving the location no longer
names config.yaml for a defaulted key that was never written there, one
proving an unset with no project config.yaml exits 0 and does not recreate
the file. All four reproduce red against the pre-fix code.
Reported-by: bee-ghosttrack
Agent-Signature: claude-code-opus-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(config): address #5760 review — top-level flat match, lists at the key's indent
Blockers from the re-review at d168df1841:
- The flat-key match accepted any indentation, so on the database-backed
path `bd config unset enabled` commented out a nested backup.enabled and
reported "in database, config.yaml". A flat key is a top-level key whose
name contains the dots, so it now matches only at the document's
top-level indentation, read from the first key line (yaml.v3 accepts a
document whose whole mapping is indented, which main's "preserve
indentation" case covers). The same change stops `mode` under
`dolt: mode: x: 1` from triggering a refusal that did not apply.
- A list at the key's own indentation (`types.custom:` then `- step`)
slipped past the refusal and left config.yaml unparseable. A `-` item at
the key's indentation now counts as the key's value.
Smaller:
- Only a comment, an anchor or a tag after the colon (`b: # note`,
`base: &b`) still leaves the value to the lines beneath, and is refused.
- Blank-line detection uses TrimSpace, so a CRLF blank line no longer ends
the value early.
- The message no longer calls a plain scalar on the next line "a mapping or
list".
Each has a case in TestUnsetRefusesShapesItCannotEdit or
TestCommentOutYamlKey, and undoing each fix fails its case.
Agent-Signature: claude-code-opus-5-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(config): refuse a single-segment block scalar; pin the tag and dedent branches (#5760 review)
- unsupportedUnsetShape returned early for single-segment keys, so
`notes: |` with an indented body plus `unset notes` commented the key and
orphaned the body, and the file stopped parsing. The database-backed
unset now reaches this path for every key, so single-segment keys are
checked too.
- New pins: a tag alone after the colon (`m: !!map`) leaves the value
below, and a dedent ends the value (`outer:` / ` k:` / `z: 1`, unset
outer.k, is commented). Undoing either branch fails its case.
- The database-path error no longer claims a row was unset.
UnsetSettingResult cannot say whether one existed.
Agent-Signature: claude-code-opus-5-5-unknown-reasoning on behalf of Harry Miller
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(config): restore CRLF normalization lost by the split-based unset rewrite
Base commentOutYamlKey scanned with bufio.Scanner, whose ScanLines drops a
trailing \r, so CRLF files came back LF-only. The PR switched to
strings.Split to preserve the file final newline, which carried every \r
through. Normalizing at entry keeps both properties: base own
TestCommentOutYamlKeyPreservesTheTrailingNewline now passes 9/9.
* fix(config): keep the no-config.yaml unset failure reportable for yaml-only keys
Base extracted the yaml-only unset into runConfigUnsetYamlOnly, which runs the
leaked-secret row cleanup independently of the YAML edit and folds the row's fate
into the returned error. This PR widened UnsetYamlConfig to (bool, error) and
swallowed the missing-config.yaml case as (false, nil) so its own new
database-backed call site would stop failing after the row was already gone.
Merging both turned base's report into a success, so
TestConfigUnsetCleansTheRowWhenTheYamlUnsetFails lost the error it asserts and
the leaked-credential rotation notice went to stdout instead of the error.
The two call sites need opposite answers, so report the case as a sentinel,
ErrNoProjectConfigYaml, and let each state its own contract. Resolution stays in
findProjectConfigYaml so neither caller re-derives it - a caller-side pre-check
is what produced the false "(in config.yaml)" claims this PR removes.
* fix(config): compare the unset against the normalized content, gate the hint
Maintainer review fixup for PR #5760 (adopt-pr iterations 1 and 2).
Iteration 1 addresses the synthesis Pre-Merge Checklist in full; iteration 2
takes both of its non-gating follow-ups.
New Finding 1 (major) — commentOutYamlKey rewrites CRLF to LF as its first
statement, but both public callers compared its result against the raw
os.ReadFile bytes. On any CRLF config.yaml those always differ, so the `changed`
bool meant "the bytes moved", not "the key was there": unsetting an ABSENT key
returned (true, nil), printed "Unset <key> (in config.yaml)" — the exact false
claim this PR exists to remove — rewrote the whole file to LF, and made the new
"was not set" branch unreachable on a supported platform. Both callers now
normalize once up front and compare like for like, so a no-op leaves the file
byte-identical. A real unset still normalizes to LF, which is base behavior; it
is pinned at the callee and, since iteration 2, through both callers. Note this
was introduced by the adopt lane's own CRLF-restoration repair (59463663e), not
by the contributor.
New Finding 1 test cell (required) — every change-report fixture in the package
was LF, so nothing in-tree could catch this. Added a CRLF absent-key cell for
BOTH callers asserting changed=false and byte-identity. Proven non-vacuous:
reverting one caller to the raw-byte compare reds that caller's subtest on both
assertions and leaves its sibling green.
New Finding 2 (minor) — printConfigSideEffects sat outside the if/else, so the
no-op branch printed "Backup config removed..." right after saying the key was
never set. All four side-effect keys are yaml-only by prefix, so 4/4 route
through the new branch. Gated on `changed`, which covers the --json arm too
since the hint goes to stderr and was never suppressed there.
New Finding 3 (minor) — the yaml-only --json payload rendered location as ""
both for an absent key and for an unpopulated field, with no way to tell them
apart; added a `changed` bool and pinned one --json cell per route.
New Finding 4 (nit) — the ErrNoProjectConfigYaml doc comment was written as a
caller census and was short by two. Re-censused: four non-test callers, taking
three different answers. Reworded to say so.
CHANGELOG: the honesty claim is no longer LF-only; recorded the no-op
byte-identity, the gated hint, and the new --json field.
Iteration 2, minor (test evidence) — the absent-key cell pins only the no-op
direction of the new compare. A caller that returned early whenever the
up-front normalization changed anything passed the whole package, and it turns
every unset on a CRLF config.yaml into a silent "<key> was not set" while the
key stays effective. Added TestUnsetOfAPresentKeyInACRLFFileReportsTheWrite for
both callers: changed=true, the key line commented out, and the file
LF-normalized. Proven non-vacuous: that early return in both callers reds only
this test, both subtests on both assertions; in one caller it reds only that
caller's subtest; and writing CRLF back reds only the file assertion. The rest
of the package stays green under each.
Iteration 2, nit (contract) — the CHANGELOG said `--json` carries a `changed`
boolean, but only the yaml-only route's payload does; the DB-backed route still
emits just key and location. Scoped the sentence to the yaml-only payload.
Validation (scrubbed env — ambient BEADS_* and BD_* variables fake reds here):
internal/config full package is 450 PASS / 0 FAIL; cmd/bd seam selector with
BEADS_TEST_EMBEDDED_DOLT=1 is 63 PASS / 0 FAIL / 2 SKIP over 65 runs, the two
skips being the cells that need a Dolt server. The new embedded cell executes
rather than skipping, and reverting the two config.go changes reds it on both
the payload and the hint assertions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
* Refuse reserved words and fuzzy id matches on bd comment writes
bd comment <id> [text...] treated its first argument as an id via the
same abbreviation-tolerant resolver used everywhere else, with no
protection against the id slot holding something that was never meant
to be an id. Two related failure modes came from that:
- "bd comment list <id>", a typo for "bd comments list" (or "bd
comments <id>"), silently ran with id="list" and text="<id>" instead
of erroring.
- If "list" (or any other stray first word) happened to be a
leading-prefix abbreviation of some unrelated issue's hash, the
resolver picked that issue and the comment landed there instead of
failing with "not found". This is exactly what happened in
production: 15+ automated sessions made the "bd comment list <id>"
typo over two days, and because "list" was a leading-prefix
abbreviation of an unrelated wisp's hash ("list3t0"), every one of
them wrote a garbage comment onto that wisp.
Fixes both, independently:
- checkCommentIDNotReservedWord rejects list/add/rm/delete as the id
argument before any resolution is attempted, mirroring the existing
"bd comments list" misplaced-subcommand guard.
- ResolvePartialIDExact (internal/utils) is an exact-match sibling of
ResolvePartialID: identical exact-ID and exact-hash matching
(including a wisp's hash with its "wisp-" infix stripped), but never
falls through to leading-prefix abbreviation matching. bd comment
now resolves through this via a new resolveAndGetIssueForMutationExact,
which keeps the existing cross-rig prefix-routing and contributor
auto-routing fallbacks intact (tightened to exact matching too) so
cross-repo comment writes by full id are unaffected.
Every other caller of the touched shared functions (ResolvePartialID,
resolveAndGetIssueForMutation, resolveViaPrefixRoutingWithAccess,
resolveViaAutoRouting) keeps its exact current behavior — the new exact
variants are additive, and existing call sites were updated to pass an
explicit "false" for the new parameter rather than changing behavior.
Testing: go build/go vet pass across the whole module. The new pure-Go
guard test and a hand-rolled in-memory PartialIDResolverStore test both
run and pass without Docker or a live Dolt server, and the latter
reproduces the original collision (ResolvePartialID) before asserting
the fix (ResolvePartialIDExact) in the same test, so the fixture is
proven to exercise the real failure mode rather than trivially passing.
The Dolt-container-backed table tests (mirroring the existing
TestResolvePartialID_Wisp / TestResolvePartialID suites) could not be
run locally (no Docker in this environment) — they compile and skip
cleanly the same way the pre-existing suite does, and will run for real
in CI.
* fix(ga-wpdum): address steveyegge's PR #5393 review items b/c/d
Review (2026-08-07, posted as a PR comment, not a formal GitHub review —
hence reviewDecision stayed empty) asked for four things before merge; (a)
rebase onto #5369 was already done (2026-09-07, see PR history). This
addresses the rest:
(c) MAJOR — comment writes require an exact id, but a REAL abbreviated id
was refused with "no issue found matching %q", which is false: the issue
exists, only the abbreviation was rejected. ResolvePartialIDExact now
distinguishes the two failure modes via a new sentinel,
ErrAbbreviatedIDNotAllowed, wrapped only when the input would have resolved
via leading-prefix abbreviation. bd comment's RunE checks errors.Is against
it and returns a truthful, actionable message pointing at `bd show <id>`
instead of claiming the issue is missing. Docs (hash-ids.md) and CHANGELOG
updated with the read/write carve-out this creates.
(b) MAJOR — investigated whether the proxied-server comment path needed the
same exact-match treatment. It doesn't: resolveCommentTargetProxied resolves
via workapi.GetIssueOrWisp with the raw id, which bottoms out in
issueSQLRepositoryImpl.Get's plain "WHERE id = ?" — SQL exact equality, with
no abbreviation-matching layer anywhere in that call chain (unlike the
embedded path's utils.ResolvePartialID). Comment writes over the proxied
server were already exact-id-only before this PR. Per the review's own
fallback ("extend exact matching to that path, or document/test the gap
explicitly"), added a regression test locking this in rather than leaving it
implicit.
(d) Added CLI-level (cobra-dispatch, in-process rootCmd.Execute) tests for:
- "rm"/"delete" reserved-word rejection, the two words the #5369-inherited
tests don't cover (only "list"/"add" have hand-written cases).
- The new (c) abbreviation-refusal message end-to-end, including a
same-abbreviation sanity check against `bd show` to prove it's a real,
resolvable abbreviation and not a fixture accident.
Plus a Docker-free fake-store test in internal/utils pinning
ErrAbbreviatedIDNotAllowed's distinguishability from a genuine not-found.
Fixed in the same pass, same class of defect as (c): checkCommentIDNotReservedWord's
message claimed every reserved word is a "misplaced bd comments subcommand" —
true for "list"/"add", false for "rm"/"delete" (no such subcommand exists;
bd has "delete" as a top-level command and "rm" as an alias elsewhere, e.g.
"dep rm"). Message now says "reserved word" generically, true for all four.
Testing: go vet (plain and -tags=integration) clean on cmd/bd and
internal/utils. go test ./internal/utils/... passes including the new
ErrAbbreviatedIDNotAllowed test. go test ./cmd/bd/. (non-integration tag)
passes including both reserved-word cases. The new CLI-level and
proxied-server integration tests need a Dolt test container (Docker) this
environment doesn't have — same limitation the original commit's own
Dolt-backed tests already disclosed; they compile clean under
-tags=integration and skip cleanly the same way the pre-existing suite does.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ga-wpdum): address bee-ghosttrack's R1 review (M1 + the flagged MINOR)
R1 (aec6de4ad, REQUEST-CHANGES) found that CHANGELOG.md and hash-ids.md
claim `bd comments add` is guarded against abbreviated ids and reserved
words exactly like `bd comment`, but the code never extended the guard
to the plural form — `commentsAddCmd` had no Args validator and resolved
through the abbreviation-tolerant `resolveAndGetIssueForMutation`. Per
the reviewer's preferred fix (option ii), extend the guard instead of
softening the docs:
- Add `validateCommentsAddArgs` (mirrors `comment`'s `validateCommentArgs`
minus the singular/plural-confusion special cases) and wire it as
`commentsAddCmd.Args`, so a reserved-word id is refused before either
dispatch branch.
- Switch the embedded-path resolution from `resolveAndGetIssueForMutation`
to `resolveAndGetIssueForMutationExact`, with the same
`errors.Is(ErrAbbreviatedIDNotAllowed)` truthful-message mapping
`comment` already has. (The proxied path already resolved exactly —
it shares `addCommentProxied`/`resolveCommentTargetProxied` with
`comment` — so this closes the embedded-path gap only.)
- Update the one pre-existing test that asserted the old, now-removed
behavior (`PartialIDWithCommentsAdd` expected a genuine abbreviation to
succeed) to assert the refusal instead, and add a CLI-level regression
test mirroring `TestCLI_CommentAbbreviatedIDRejectedWithTruthfulMessage`.
- Add `TestValidateCommentsAddArgs`, a pure Args-validator unit test
(no store/Docker needed) mirroring `TestValidateCommentArgs`.
Also treats the one MINOR the review flagged as an actual gap (not just
a suggestion): the wisp-branch abbrevOnly tracking in id_parser.go had no
test pinning it — P3 (making the wisp-branch abbrevOnly append a no-op)
went uncaught. Strengthened
TestResolvePartialIDExact_FakeStore_ReproducesReportedIncident's "list"
assertion from a bare `err != nil` to `errors.Is(err,
ErrAbbreviatedIDNotAllowed)`, which is exactly the incident's own shape
in the wisp branch.
CI (PR Core / wrapper timing) is failing on this branch, but independently
confirmed pre-existing and unrelated: `ci-pr-core.sh` runs `go test -race
./...` with no `-timeout` override, so cmd/bd (a large package under
-race) hits Go's default 10-minute per-package ceiling; same-hour green
runs on other PRs measured 11-13.5 min total job time, already at the
edge, and the actively-running test at the deadline
(TestWhereCommand_ReadsPrefixFromEmbeddedStore) is unrelated to this
diff. R1 independently measured the same thing (541.6s/387.0s on other
green runs vs. 600.9s here). Needs a green re-run, not a code fix.
Verified locally (no Docker in this environment, so the two integration-
tagged CLI tests above compile-check clean via `go vet -tags=integration,
gms_pure_go` but run as SKIP rather than PASS; will run for real in CI):
- go build ./...; go vet ./cmd/bd/ ./internal/utils/: clean
- go vet -tags=integration,gms_pure_go ./cmd/bd/: clean
- gofmt -l on all 4 changed/added files: clean
- go test ./internal/utils/... -run ResolvePartialID: PASS
- go test ./cmd/bd/. -run 'TestValidateCommentsAddArgs|TestValidateCommentArgs|TestCheckCommentIDNotReservedWord': PASS
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(ga-wpdum): address bee-ghosttrack's R2 review (dead-red fixture + cobra-dispatch wiring test)
R2 (a639234a0, CHANGES_REQUESTED): TestCLI_CommentsAddShortID/PartialIDWithCommentsAdd
was dead-red in its own setup — it only truncated the fixture hash to a
4-char abbreviation when len(hash) > 4, but fresh test DBs mint 3-char
hashes (min_hash_length unset), so shortID always equaled the full hash
and the t.Fatalf guard fired before any of the subtest's real assertions
ran. That meant mutation P-B (reverting comments.go's exact resolver back
to the abbreviation-tolerant one) went uncaught.
Fix: derive the abbreviation as a strict, one-character-shorter leading
prefix of the real hash (hash[:len(hash)-1]), the same derivation
comment_proxied_integration_test.go already uses — correct regardless of
fixture hash length, with a length>=2 guard instead of the old
always-true-in-practice one.
Also closes R2's recommended "NEW MINOR — the guard's wiring is
untested": comments_add_test.go drives validateCommentsAddArgs directly
(catches a gutted body, mutation P-C) but nothing exercised
commentsAddCmd's Args field through real cobra dispatch, so unwiring it
back to cobra.MinimumNArgs(1) left every test green (mutation P-D). Added
TestCLI_CommentsAddReservedWordRejectedThroughCobraDispatch, which runs
`bd comments add <reserved-word> ...` through actual rootCmd.Execute()
dispatch for all four reserved words and asserts the bystander issue
receives no comment.
Not touched, per R2: the carried-over m1 (cross-rig abbreviation error
message) — reviewer marked "Not a blocker" — and the CI race-default
timeout on cmd/bd, already diagnosed (R2 + prior PR comment) as
pre-existing infra flakiness needing a fresh run, not a code change.
Verified in this environment (no Docker/testcontainers available, same
disclosed limitation as prior rounds): gofmt clean; go vet -tags=integration
./cmd/bd/... clean (requires CGO_CPPFLAGS/CGO_LDFLAGS/PKG_CONFIG_PATH
pointed at the keg-only icu4c@78 install); go test -tags=integration
-run 'TestCLI_CommentsAddShortID|TestCLI_CommentsAddReservedWordRejectedThroughCobraDispatch'
./cmd/bd/ -v passes with all Dolt-backed subtests skipping cleanly
(Docker not available) rather than panicking — confirms both tests compile
and execute up to the container-availability skip. The actual fixture-hash
logic under test only runs where a Dolt container exists (CI); it has not
been exercised against a real container here.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* chore(bazel): enumerate the PR's 4 new test files in BUILD.bazel (adopt-pr rebase gate)
Base added cmd/bd/BUILD.bazel and internal/utils/BUILD.bazel enumerates
go_test srcs explicitly, so PR #5393's four new test files were unlisted.
Output of 'make bazel-sync' (gazelle + go_srcs.py + mod tidy), verbatim and
idempotent. Measured: the unrepaired //internal/utils:utils_test binary lists
0 of the PR's 5 TestResolvePartialIDExact* tests while still building green
(a fake green); repaired it lists 5/5.
* fix(review): surface a routed-tier abbreviation refusal on comment writes
Review-loop fixup for PR #5393 (iteration 1). The review approved with no
required changes; these are the non-gating minor plus one of the two nits,
taken because the minor is a user-visible false message on this PR's own
headline contract.
[minor] Contract & Interface Fidelity. resolveAndGetIssueForMutationExact
passes exact=true to all three tiers, so the cross-rig and auto-routed tiers
can mint utils.ErrAbbreviatedIDNotAllowed too -- and both wrappers propagate it
unwrapped (routed.go:303-305) -- but each routed error was bound inside an `if`
statement and discarded, and `return nil, err` returned the LOCAL error. The
consumers' errors.Is (comment.go:158, comments.go:238) was therefore
structurally unable to observe a routed-tier refusal, so `bd comment hr-8wn
"text"` printed `no issue found matching "hr-8wn"` for an issue a routed rig
demonstrably holds -- the exact falsehood the sentinel's own doc condemns, at
the caller that doc names (internal/utils/id_parser.go:33). Both tiers' errors
are now captured and the first abbreviation refusal is returned in preference to
the local not-found. The wrong write was already refused on every tier; only
the message contract was unmet.
The new pin cmd/bd/comment_routed_exact_test.go drives the real seam (local
town store + routed rig + routes.jsonl, mirroring
TestCheckBeadGateCrossRigPrefixRoute) in both directions, because either
assertion alone passes for the wrong reason: an abbreviation of a routed issue
must select the ROUTED refusal, and an id absent everywhere must stay a plain
not-found. Proven non-vacuous by mutation -- dropping only the selection reds
direction 1 with `no issue found matching "gt-abcdefg"`, the original symptom
verbatim, while direction 2 still passes.
[nit] Test Evidence Quality. The proxied regression test asserted only
strings.Contains(stdout+stderr, id), which passes identically on the false and
the truthful message and so locked the local/proxied message asymmetry in where
the suite could not see it. It now asserts the whole message (verified
empirically: `Error: issue pa-2u not found`) and empty stdout, matching the
exact-message norm of the sibling missing-ID subtest. The asymmetry itself is
deliberate and stays: the proxied route resolves through one exact
`WHERE id = ?` and cannot distinguish an abbreviation of a real issue from an
absent id without adding back the abbreviation probing this PR exists to remove
from write paths.
[nit] Release Safety -- DECLINED, measured. The prescribed `### Changed` bullet
belongs at the top of the first `### Changed` block in `## [Unreleased]` (base
CHANGELOG.md:383), and main has since inserted its own bullet at exactly that
anchor (`@@ -384,0 +492,16`, the #6111 entry). Adding it would mint a second
CHANGELOG add/add conflict for the finalize base-refresh on top of the
`### Fixed` re-conflict already predicted by the rebase gate -- not worth it for
an optional nit whose own text says "No code change".
cmd/bd/BUILD.bazel gains one srcs row for the new test file (via make
bazel-sync, a no-op on a second run) so bazel.yml's "BUILD files in sync" gate
stays clean.
Validation: go build ./... rc 0; go vet ./cmd/bd/ ./internal/utils/ rc 0; gofmt
clean; git diff --check clean; cmd/bd selectors 11/11 PASS including base's own
TestMatchPrefixRoute (the GH#5048 longest-prefix union guard) and
TestResolveCloseTargets (the abbreviation-tolerant sibling path);
TestProxiedServerComment 3/3 under BEADS_TEST_PROXIED_SERVER=1.
* test(utils): pin #6215's sentinel guard to the shared resolver (#5393 base refresh)
Rebasing this PR onto current main (e7138e93af -> a1ac9f4dcb, 27 commits) hit
two conflicts. Both are recorded in .gc/reviews/<root>/base-refresh-repair.md;
this commit carries the one piece of the repair that is not simply a replayed
contributor hunk.
The substantive conflict was internal/utils/id_parser.go against ab88b20517
(#6215, "refuse a bare jq/JS sentinel ... as an issue ID", which itself says
Refs #5393). Both sides ADD at the same point -- the diff3 ancestor section is
empty -- so nothing base-owned is rewritten, and the only question is WHERE
#6215's guard lands now that this PR splits the resolver into ResolvePartialID
(abbreviation-tolerant) and ResolvePartialIDExact (exact-only) over a shared
resolvePartialID.
It belongs in the shared body. #6215 put it in ResolvePartialID only because
that was then the repository's single ID-resolution entry point ("One guard
covers the direct, embedded and proxied-server paths uniformly"); this PR adds
a second. Its changelog entry on main states the guarantee directly -- "bd
update null, bd comment null and every other command that resolves an ID now
fail before any lookup, because the guard sits in the shared resolver" -- and
bd comment is precisely what this PR routes through the exact-only path. The
relocation costs no patch delta: the guard re-anchors as unchanged context
after the PR's insertion, so the content-line diff of (old base..old head) vs
(new base..new head) is empty, and the PR's stat is 16 files +1212/-31 before
and after.
Nothing covered that choice, which is why this test exists. #6215's own
id_parser_sentinel_test.go exercises only ResolvePartialID, so the naive
textual resolution -- guard left in the exported wrapper -- keeps every one of
its assertions green while a sentinel reaching the exact path degrades into
`id is a valid abbreviation, but exact-match resolution is required here:
"null" (matches [hq-null3t0])`: it names an unrelated decoy issue and tells
the caller to use the full id, when in truth their selector matched nothing.
Mutation-proved in both directions: with the guard moved into the wrapper
alone, #6215's two tests still PASS and this test FAILs; with the guard deleted
outright, #6215's refusal test and this one both FAIL (so neither is vacuous).
The over-refusal arm mirrors #6215's accepted-inputs test through the exact
path, so hq-null3t0 and the bare hash null3t0 must still resolve.
No new file, so no BUILD.bazel srcs row is owed. 61 PASS / 0 FAIL / 0 SKIP for
-run 'Sentinel|ResolvePartialID' against a real Dolt container.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
* fix(update): fence unforced --notes overwrites behind --force across all surfaces
bd update --notes silently replaced existing notes, destroying handoff
history. The contract now refuses an unforced overwrite of non-empty
notes with ErrNotesOverwrite (409 notes_overwrite_refused over HTTP,
force_notes_overwrite to override), enforced inside the mutation
transaction on both the dolt and uow backends, for single updates and
batch apply alike. CAS guards keep precedence: a stale
--if-assignee/--if-status still surfaces as the exit-13 mismatch, on
both backends, before the fence speaks.
CLI: --force and --if-assignee are no longer mutually exclusive (that
exclusion made overwriting under a guard impossible); both update
routes translate the fence's sentinel into the same actionable advice
(--force to overwrite, --append-notes to preserve history), and the
post---force warning is worded as an audit statement. The shipped
plugin skill docs and bd note help now prescribe --append-notes for
handoffs instead of the newly fenced bare --notes.
The fence is the single enforcement point: no client-side pre-read
copies of the rule. Conformance contracts, unit tests for
AuthorizeNotesOverwrite, and embedded/proxied/httpapi regression
coverage included.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MAFpn9pUw8WKMfymteZHbh
* fix(update): exempt explicit clears from the notes fence; share its predicate
CI surfaced three gaps in the fence's reach:
- Clearing notes (--notes "" / patch.notes: "") was refused, diverging
from every sibling text field's clear and from the backend behavior
contracts. The fence now targets only its actual footgun — replacing
non-empty notes with different non-empty content — via a single shared
predicate, issueops.NotesReplacement, used by both the contract's
AuthorizeNotesOverwrite and the CLI's warning path, so the two can no
longer drift. Prose updated to match everywhere the rule is stated
(ErrNotesOverwrite, ForceNotesOverwrite, OpenAPI spec + regenerated
types).
- The revision-CAS integration tests' incidental concurrent writes now
patch design instead of notes, so they no longer depend on notes-fence
semantics at all.
- The historical-upgrade harness deliberately replaces fixture notes and
asserts the new value; its two bd update --notes calls now pass
--force.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MAFpn9pUw8WKMfymteZHbh
* fix(update): address review — changelog BREAKING entry, problem.go doc block, close-policy-under-guard test
Review follow-ups on #5946 (bee-ghosttrack, MERGE-AFTER-FIXES):
- CHANGELOG: BREAKING entry under [Unreleased] ### Changed for the notes
fence on both wires (CLI exit 1, HTTP 409 notes_overwrite_refused), with
the --force / --append-notes migration line. It also names the two
deliberate edges: the explicit-clear exemption, and --force widening to
the close-policy half under --if-assignee now that the flag pair is legal.
- problem.go: CodeNotesOverwrite's comment had landed inside
CodeDependencyCycle's doc block; each const now sits under its own docs.
- assign_fence_embedded_test.go: pin the previously untested close-policy
half of --force under --if-assignee (refused unforced, authorized forced).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JyuQ6Tjv3D7tpNqeb2WDED
* test(update): align TestWarnNotesReplacement with the post-fence warning copy
The test landed on main after this branch was cut and pins the pre-fence
wording, where the warning fired on any unforced overwrite. Since the fence,
an unforced overwrite is refused outright and warnNotesReplacement fires only
after a forced one — the audit trail for a habitual --force — so the copy it
pins is now '--force replaced existing notes'.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JyuQ6Tjv3D7tpNqeb2WDED
* docs(import): record bd import's notes-fence exemption as by-design (GH#6190)
Import consults none of the per-field live-state fences — notes overwrite,
live-claim reassign, close policy — and that is the intended shape, not an
omission: its contract is wholesale row replacement, guarded by its own
staleness check (only strictly-newer rows rewrite local state, --allow-stale
is the single deliberate-overwrite opt-in) and reported field-by-field in
updated_issues. Named in AuthorizeNotesOverwrite's enforcement-boundary
comment and in bd import's help; the published CLI docs pick the help text
up at the next release pin bump.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JyuQ6Tjv3D7tpNqeb2WDED
* fix(update): refuse --notes "" and add --clear-notes; stop --notes help reading as additive
GH#6021: an empty --notes wiped the whole notes field at exit 0 behind the
same ✓ Updated receipt as a successful write — and the empty string is
exactly what a dead command substitution collapses to. The empty value is
now refused on both CLI routes (the accident and the deliberate clear are
the same bytes at the flag layer), and the deliberate clear gets its own
verb, --clear-notes, mutually exclusive with --notes/--append-notes. A verb
rather than the proposed --allow-empty-notes opt-in: what needs authorizing
is an intent, not an input path — --allow-empty-description unblocks
stdin/file plumbing, which notes does not have — and an opt-in passed
habitually would silently disarm the guard while a habitual --clear-notes
fails loudly. --force does not bypass the refusal; the fence's clear
exemption stands, so the verb alone authorizes the erase. The HTTP API is
unchanged: patch.notes "" still clears.
GH#6272: bd update --help called --notes "Additional notes" and the prime
text said "Add supplementary notes" — both read as appending, so agents
following the injected guidance faithfully clobbered prior context. The
update help now names the operation with the --append-notes contrast at the
point of use, the shared/create help is field-named like --description and
--design, and the prime line points at bd update --append-notes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JyuQ6Tjv3D7tpNqeb2WDED
* fix(bazel): enumerate the PR-new files in cmd/bd and issueops srcs
The base added cmd/bd/BUILD.bazel and internal/storage/issueops/BUILD.bazel
with EXPLICIT srcs lists after this branch was cut, so the three files this
PR adds were never enumerated:
cmd/bd/update_notes_guard.go (go_library bd_lib)
cmd/bd/update_notes_guard_test.go (go_test bd_test)
internal/storage/issueops/aggregate_authorize_notes_test.go (go_test)
The go_library omission is a hard build break, not a silent skip:
update.go:215,220 and update_input.go:106,111 are enumerated and call
validateNotesUpdate / clearNotesRequested, so //cmd/bd:bd_lib compiles the
callers without the callee. bazel.yml arms unconditionally for fork PRs
(head.repo.fork == true) and builds //cmd/bd:bd + //cmd/bd:bd_test, so this
reds the lane. make bazel-sync-check cannot see it -- go_srcs.py only
validates the glob-based go_srcs filegroup, never the rule srcs lists.
Generated by make bazel-sync (gazelle), not hand-edited, so the workflow's
own BUILD-files-in-sync drift step agrees byte-for-byte.
* fix(notes): name --clear-notes in bd note's rm guidance, correct the fence boundary comment, pin both request-shape rules
Takes all three non-gating minors from the review. No behavior change: two
prose fixes and two test cases.
1. cmd/bd/note.go's rm|remove|delete branch advised
`bd update <id> --notes "text" --force` under "To change or clear notes",
but clearing through --notes is exactly what this PR made impossible --
validateNotesUpdate refuses an empty value unconditionally and --force does
not reach it. The branch now names both verbs separately: --notes --force to
replace, --clear-notes to clear. The edit and update branches speak only of
replacing and were already correct, so they are untouched.
2. aggregate.go's enforcement-boundary comment claimed the UpdateIssueInTx
funnel's "one notes-replacing caller is bd edit". Under this PR's own
NotesReplacement predicate there are at least four more (bd note's
read-combine-write, bd defer --reason, bd rename and delete-tombstoning's
mechanical ID rewrites, bd compact's clears). The exemption is still sound --
every funnel writer derives its new value from the current notes -- so the
comment now names those CLASSES instead of a single caller, which is the
claim that is actually true and that a future fence auditor can check.
3. Both branches this PR adds to ValidateUpdateRequest were uncovered: the
batch apply leg reaches them here and nowhere else, while the single-issue
HTTP handler's own pre-check returns before storage. Added a sibling table
(the existing one varies only the patch; these two rules are properties of
the REQUEST) with a case each. Mutation-checked, disjoint: neutralizing the
force-without-notes branch reds only the first case, neutralizing the
notes+append branch reds only the second, and the pre-existing
canonical-fields table stays green under both.
Not an amend of 5ffcc9c16c: that commit's message states it was generated by
make bazel-sync and not hand-edited, so folding hand-written Go into it would
falsify the claim its own BUILD-files-in-sync argument rests on. No new files,
so the srcs lists it repaired stay correct.
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
* fix(externaldeps): guard explicit claims and batch closes
Preserve external capability policy across lifecycle updates and batch close/claim-next operations, including direct, embedded, and proxied paths. Follow up on upstream PR #4753 and issue #4769.
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of Denis Redozubov
* test(externaldeps): include embedded regression in CI discovery
* test(serve): preserve external close policy when peeling hooks
Replace the raw batch-closer identity assertion with a behavioral policy check, retaining the no-hooks assertion. Document full-workspace claim filtering and batch lookup cost.
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of Denis Redozubov
* test(externaldeps): align the mixed-batch pin with #6648's partial-failure exit
Maintainer fixup applied while adopting PR #6738.
`exerciseExternalMutationPolicy`'s `mixed_batch_and_claim_next` subtest asserted
that a partially-refused `bd close` batch keeps the CLI's zero exit status. That
was true at this PR's original base, but #6740 (Beads #6648) landed on main in
the meantime and made a partial batch close exit 1 with an
`N of M issues failed to close` summary. The two changes are independently
correct and merge without a textual conflict, so the stale expectation only
surfaces as a red `cmd/bd` shard after the rebase.
The PR's substance is unchanged: the externally blocked issue is still refused
with its blocker named, the eligible item still closes, and `--claim-next` still
claims. Only the exit-status expectation moves onto the current contract, and
the summary line is now pinned so the interaction between the two features stays
covered.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
* test(dolt): check version scope on the transaction owner
withWriteTx and withRetryTx delegate transaction creation to commitWriteTx after #6719. Point the existing completeness guard at that owner so it still checks BeginTx and the versioned-history scope together.
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of Denis Redozubov
* fix(ci): register external policy files and isolate server cleanup
Include all six new Go files in Bazel targets. Run the direct-server fixture before parallel proxied tests because its cleanup purges dropped databases across their shared server; observed initialization failures coincide with that cleanup.
Agent-Signature: codex-unknown-model-unknown-reasoning on behalf of Denis Redozubov
* fix(externaldeps): scope close-only batch policy and drop the claim --force hint
Review-loop fixup for PR #6738 (iteration 1). The review approved with no
blocker or major findings; this takes its three minors and its nit, all in
code this PR introduces. Each minor lands with a test that a mutation of the
covered code turns red.
[minor] A refused proxied claim suggested an override that cannot work. The
external claim guard ignores --force but shares ErrCloseBlocked with the close
policy, so on the proxied route `bd update <id> --claim` against an externally
blocked issue printed "(use --force to override)". proxiedUpdateFailure now
reports a refused claim as the generic update failure, as the direct route
always has. claim_is_atomic asserts the refusal never mentions --force;
restoring the unconditional hint fails it on the proxied lane.
[minor] A close-only batch demanded policy support for unrelated blockers.
Without ClaimNext the batch closer still passed the workspace's whole
externally blocked set to BatchCloserWithPolicy, so one external blocker
anywhere made a backend lacking PolicyBatchCloserSource (such as one
registered through internal/storage/backends) refuse to close unblocked
issues. The policy is now scoped to the batch items unless the batch claims
next work, which still needs every blocker for FilterClaim. CheckClose looks
up exact ids, so no refusal changes. The NewBatchClosePolicy doc now says when
the whole set is required. TestBatchCloserScopesPolicyWithoutClaim covers an
unrelated blocker, a blocked item, and a next claim against such a backend.
[minor] The policy's fallback target read had no pin.
TestExecuteCloseBatchWithPolicyDefersToTheTargetRead drives it through
sqlmock: a missing target keeps the backend's not-found, and a failing status
read reports that failure, never ErrCloseBlocked. Refusing the missing target
or swallowing the read error each fails it.
[nit] DoltStore and EmbeddedDoltStore BatchCloserWithPolicy return
ErrUnsupported on a nil receiver, as NewBatchCloser does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.local>
* fix(doctor): gate --fix when schema is skewed (GH#4993)
`bd doctor` printed `bd doctor --fix` for cosmetic warnings without
checking whether the DB schema is ahead of (or behind) the running
binary. Following that tip can resume/write migrations on shared state —
exactly what burned a fleet change-freeze.
- AssessSchemaFixGate compares schema_migrations to LatestVersion
- Refuse apply/dry-run when the database is ahead of the binary
- Sanitize Fix recommendations so tips do not steer into unsafe --fix
- Surface a schema fix-gate footer on doctor output
Fixes#4993
* fix(doctor): assess the schema fix gate before anything can write (GH#4993)
The gate shipped downstream of the hazard it guards, which produced three
separate-looking defects with one cause:
- Fix advice was sanitized inside printDiagnostics, the else branch of the
emitter chain, and by value over a []doctorCheck. --json, --agent and
--output therefore published advice the gate had ruled unsafe.
- The --check= handlers return before any gate exists, so --check=pollution
--clean and --check=validate --fix wrote with no gate consulted.
- runDiagnostics auto-migrates near its top while the gate was assessed at
print time, so a bare `bd doctor` applied pending migrations and then
warned about them.
Assess once in the RunE preamble, before any branch that can write, and
thread that verdict through. Sanitize once into result.Checks by index so
every emitter inherits it. Gate the --check= paths at the single branch
point via checkFlagWrites.
Also splits the overloaded Safe flag into RecommendFix / AllowDBFix /
AllowFSFix, since callers were asking three different questions of it, and
adds Determined / DBReachable so an unreadable schema version fails closed
while a genuinely absent database still permits filesystem repair. Fixes
follow from that: the --fix dry-run no longer refuses (it writes nothing),
filesystem-only repairs are no longer blocked by a schema hazard that cannot
affect them, and the dead `&& !g.Safe` conjunct and a leaked internal symbol
in operator-facing output are gone.
Tests move from asserting the predicate to asserting the wiring: a property
over the whole emitter set, the --check= enumeration, and a fail-closed case.
Verified against the original range-by-value bug, which they detect.
Reported by maphew.
* fix(doctor): gate DB fixes solely on AllowDBFix, not Reason == "" (GH#4993)
AssessSchemaFixGate's unreachable branch (openDoltDB failure) returns
AllowDBFix:false and Reason:"" — both zero values. doctor_fix.go's
`gate.AllowDBFix || gate.Reason == ""` in applyFixes and
`!gate.AllowDBFix && gate.Reason != ""` in previewFixes both treated
that empty Reason as "safe to fix", admitting database repairs (and
not even flagging them as blocked in a dry run) whenever the Dolt
server is stopped or unreachable — exactly the case this gate exists
to withhold.
Gate on AllowDBFix alone in both places. Enumerated every FixGate
literal in fix_gate.go (unreachable, undetermined, ahead, pending,
default/equal) against the new condition: only the unreachable case
changes (admitted -> withheld, the fix); undetermined/ahead/pending
stay withheld and the equal/default case stays admitted, so no
legitimate case is newly blocked.
Adds doctor_fix_gate_wiring_test.go coverage driving applyFixes and
previewFixes with an unreachable-shaped gate fixture, asserting no
database fix is applied or shown as unblocked.
* fix(doctor): correct comment typo labelled->labeled
The misspell linter flags 'labelled' (British spelling) in a comment
in previewFixes, failing the Lint / PR Lint (wrapper timing) / CI
Gate checks on PR #5145.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(doctor): guard --agent commands, test the gate assessor, keep recovery fixes (GH#4993)
- --agent: enrichers hardcode `bd doctor --fix` in their Commands and never
read the sanitized dc.Fix. EnrichForAgent now takes the FixGate and
sanitizes the finished Commands. TestNoAgentEnricherLeaksUnguardedFixCommand
runs over every registered enricher (doctor.AgentEnricherNames) plus an
unenriched name, with a non-vacuity check under a safe gate.
- AssessSchemaFixGate now has tests against a real Dolt server with a seeded
schema_migrations (ahead, pending, equal, empty/absent/unreadable table)
and unreachable cases, each guard verified by mutation.
- An unopenable database no longer withholds the recovery fixers that repair
it: FixGate.AllowsFix is the single admission policy; Corrupt Manifest,
Database Integrity, Dolt Format and Dolt Schema stay available when the DB
is unreachable, schema-writing fixes stay withheld whenever the gate blocks.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* chore(bazel): sync BUILD.bazel srcs/deps for the new doctor fix-gate files
The PR adds cmd/bd/doctor/fix_gate.go (which imports //schema), three
fix_gate*_test.go files in that package, and
cmd/bd/doctor_fix_gate_wiring_test.go. The rebase target added
cmd/bd/doctor/BUILD.bazel after this PR was opened, and it enumerates srcs
and deps exactly, so the merged tree left all five files unlisted and the
go_library missing //schema. Regenerated with `make bazel-sync`
(gazelle + tools/bazel/go_srcs.py + bazel mod tidy).
* fix(doctor): fail closed when the schema gate cannot open an existing database
Maintainer review fixes for the GH#4993 fix gate (adoption review of #5145).
The blocking defect: AssessSchemaFixGate conflated "there is no database" with
"I could not connect to one". Any openDoltDB error returned the no-hazard
unreachable shape, and the destructive `--check` refusal keyed on
gate.DBReachable, so in a server-mode repo whose server was merely stopped
`bd doctor --check=pollution --clean` skipped the refusal entirely, then the
handler's own factory open auto-started the server, applied the pending
migrations blind, and deleted rows. The identical command against the identical
schema was refused whenever the server happened to be running, so the guard was
conditional on incidental server liveness.
Split the two states. A failed connection is no longer evidence that there is
no database: when the configured database is still on disk the gate now reports
DBPresent with Determined=false, a Reason, and RecommendFix cleared, so the
refusal fires and printed advice stops steering at --fix for a schema version
it never read. The discriminator stats the path autoMigrateOnVersionBump
stats, os.Stat(cfg.DatabasePath(...)), and like it reads only ENOENT as absent,
so the gate and the auto-migrate agree about when a schema exists outside the
two deliberate departures described under the second review iteration below.
A repo with no database at all keeps the existing no-hazard shape.
DBPresent, not DBReachable, is now the hazard question, via
FixGate.BlocksDestructiveWrites(). Keeping DBReachable literal preserves the
recovery-fixer carve-out in AllowsFix unchanged: Corrupt Manifest and
Database Integrity stay available for a database that cannot be opened, which
is exactly the state they are the cure for, while a repair that opens the
migrating factory stays withheld.
Also from the review, all non-blocking:
- `--check=artifacts --clean` was refused under a blocked gate although the PR
itself classifies artifact cleanup filesystem-only, so the two planes
disagreed about one operation. The `--check` guard now routes through
FixGate.AllowsFix; pollution and validate have no filesystem-only
classification and stay refused.
- filesystemOnlyFixes omitted "Hooks Path" (a git-config unset) and
"Circuit Breaker" (stale marker files), so a blocked gate withheld them and
printed them as database fixes. Added both, plus "Database Config" (rewrites
metadata.json only and refuses Dolt outright). Audited the rest of
applyFixList's 42 dispatch names and recorded why the others stay guarded --
"Repo Fingerprint" writes through the store, so it is correctly withheld.
- applyFixes dropped a gate-withheld filesystem-only fix from both the fixable
and withheld lists, reporting nothing at all. Removed the qualifier and
relabelled the line "gated fix(es)", since the withheld set is whatever the
gate blocked.
- Corrected the gate's own ordering contract comment, which claimed assessment
happens "before anything that can write". The load-bearing guarantee is one
memoised verdict per invocation before any *gated* write, with the bd-jgxi
auto-migrate deliberately outside the gate's jurisdiction.
Tests: the fail-closed shape and its recovery/hazard admissions, the hazard
predicate across all six gate shapes, the `--check` refusal routing (including
that a read-only --check never probes the database), and the gate accessor's
laziness and memoisation. The review also asked for an assertion that the gate
is evaluated before autoMigrateOnVersionBump; that is declined deliberately,
because it would pin a contract the same review established is false -- the
auto-migrate precedes the gate by design. The lazy/memoised pins cover the part
of the contract that is real.
Validation: 29 focused fix-gate tests pass, and each of the four behavioural
changes was confirmed non-vacuous by mutating it and observing only its own
test fail. Full cmd/bd/doctor package is 387 pass / 7 fail, all 7 identical to
the same tests at the rebase base (ambient-env reds needing BEADS_TEST_SERVER
or a configured beads role). BUILD.bazel regenerated with gazelle; the new
cmd/bd test file runs under `bazel test //cmd/bd:bd_test`.
Second review iteration (one minor, non-gating): databaseExistsOnDisk's doc
called it the same probe autoMigrateOnVersionBump uses, but the two differed in
three arms. Each is now either aligned or a documented, pinned departure:
- Any stat error read as absent, where auto-migrate reads only ENOENT so. Now
only ENOENT reads as absent: a data directory that cannot be stat'ed for
another reason (ENOTDIR, EACCES) is unknown, and the gate fails closed.
- No metadata.json reads as absent, where auto-migrate falls back to
DefaultConfig. Kept deliberately and documented: the gate cannot connect
without metadata.json, so a fail-closed verdict could never be cleared by
starting a server, and SanitizeFixRecommendation would rewrite doctor's own
advice for this state (`bd doctor --fix` regenerating metadata.json, a
filesystem-only repair) into "Do NOT run 'bd doctor --fix'". The cost is one
unguarded state, left as follow-up: server mode selected by the environment
or config.yaml while metadata.json is missing, where a gated repair still
reaches the server's schema unmeasured.
- A proxied-server workspace was documented as reading absent because it
"keeps no local database", but it reads present whenever its data directory
is on disk, and the proxied root defaults to that same directory. Kept
fail-closed and corrected the doc. `bd doctor` is refused up front in
proxied-server mode (proxy.doctor.unsupported), so this arm only matters once
doctor gains a proxied route.
Also corrected the DBPresent field doc, which said only a repo with no database
at all is DBPresent:false.
Tests: the fail-closed test is now table-driven over a stopped server, a
proxied-server workspace, and a data directory whose stat fails with ENOTDIR
(skipped on Windows, where that error surfaces as path-not-found, which
os.IsNotExist matches). A new test pins the missing-metadata.json departure:
the no-hazard shape, RecommendFix kept, and Metadata Config admitted. Each arm
was confirmed non-vacuous by mutating it (a DefaultConfig fallback, an
any-error stat predicate, a proxied-mode early return) and observing only its
own test fail.
Not covered, and unchanged from main: an embedded-mode workspace keeps its
store under .beads/embeddeddolt, which this probe does not stat, so
`bd doctor --check=pollution --clean` there still gets the no-database verdict.
Validation (second iteration): git diff --check is clean; the 11 focused
doctor gate tests and the 13 cmd/bd gate-wiring tests pass.
databaseExistsOnDisk's only caller is AssessSchemaFixGate, whose only
production caller is doctor's newSchemaGate, so those suites cover every path
the predicate change reaches.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>