Commit graph

70 commits

Author SHA1 Message Date
gascity-eddie[bot]
4df395698b
fix(bazel): the root go_srcs glob skips Bazel's convenience symlinks, so //cmd/bd tests cache (#7714)
The root //:go_srcs filegroup is glob(["**/*.go"]), and a glob follows the
checkout's bazel-bin/bazel-out/bazel-testlogs/bazel-beads symlinks into the
output tree. CI's test step is the first build in a fresh checkout, so it never
sees them, but in any checkout that has built before every test that reads
//:go_srcs (bd_test, bd_embedded_test, bd_embedded_part2_test,
bd_dolt_server_test, bd_proxied_test, bd_managed_local_test) gains the output
base's .go files: their inputs differ on every run, they are never cached, and
loading grows with the output tree.

Measured on main 2563f021ed with the symlinks present, `bazel test
//cmd/bd:bd_test --config=ci --test_filter='^TestResolveCommitHash$'` twice:
both runs executed all 16 shards remotely, and the analysed graph grew from
20,773 to 56,941 configured targets (14 s, then 25 s). With this change the
second run is `(cached)` in 3.6 s. In agent worktrees the glob had reached
433,026 output-tree files, a cached re-run took 36 s to load against ~3 s
without them, and 135 of 202 blocking test minutes of the factory's beads
seats went to these six targets (formula-overhead audit 4; bead ga-ylpbsy.24).

tools/bazel/go_srcs.py gives the root block exclude = ["bazel-*/**"] (the
same pattern ROOT_REPO_FILES_EXCLUDE already uses for //:repo_files); only
the root BUILD.bazel changes. CI's action keys do not change: its checkout has
no such files. scripts/bazel_policy_test.go's
TestBazelRootGoSrcsSkipsConvenienceSymlinks fails without the exclude.

Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 23:30:10 +00:00
Julian Knutsen
8988340994
ci(embedded): run every BEADS_TEST_EMBEDDED_DOLT-gated cmd/bd test in the embedded lane (#7708)
* test(cmd/bd): repair the embedded-gated tests that rotted while no lane ran them

These tests skip unless BEADS_TEST_EMBEDDED_DOLT=1 but no CI lane selected
them, so they rotted unseen. Running them shows:

- TestEventsTailFollowReportsTruncationOnTheStream raced on a plain
  bytes.Buffer that os/exec's copy goroutine writes while the test polls it.
  Use the package's syncBuffer.
- TestCorruptMetadataDiagnosticsRunAndDataFailsLoud still asserted that
  doctor and init run on a corrupt metadata.json. #4857 deliberately made
  every workspace command refuse instead (pinned for doctor by
  TestDoctorRejectsCorruptMetadataBeforeSharedServerChecks). Rewrite it to
  the shipped contract as TestEmbeddedCorruptMetadataFailsLoudUntilRestored:
  version warns, doctor/list/init refuse naming the file without touching
  it, and restoring the file brings the data back.
- dolt_remote_origin_guard_embedded_test.go was tagged
  `embeddeddolt && cgo`, a tag no lane sets, so it never compiled in CI
  (gazelle left it out of bd_test srcs). Retag it `cgo`, as #4153 did for
  its dolt_local_only sibling, and add it to srcs. Drop its four bd doctor
  git-origin tests: bd doctor runs no checks on an embedded workspace
  (GH#3794), so two could never pass and two passed vacuously on empty
  output. Rename the surviving tests into the TestEmbedded* prefix.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(embedded): run every BEADS_TEST_EMBEDDED_DOLT-gated cmd/bd test in the embedded lane

The embedded-Dolt cmd lane selected tests with
grep '^func TestEmbedded' cmd/bd/*_embedded_test.go, and only its two
Bazel targets set BEADS_TEST_EMBEDDED_DOLT. A test that skips without the
variable but missed the name prefix or the file suffix skipped in every
lane and reported green: 92 of them, including #7203's --if-revision CLI
coverage (TestIfRevisionMatchAndMismatch, TestReassignFenceCLI, ...).

- embedded-test-shard.sh and gen_embedded_cmd_shard_manifest.py select
  TestEmbedded* by name across cmd/bd/*_test.go, as proxied-test-shard.sh
  does, leaving authors one rule.
- Rename the gated tests into the TestEmbedded* prefix
  (TestDoctorEmbedded<X> -> TestEmbeddedDoctor<X>) and update every
  reference.
- Place the new names with gen_embedded_cmd_shard_manifest.py 100
  --weights=duration --write (incremental).
- Add TestEmbeddedGatedTestsRunInTheEmbeddedLane: it walks cmd/bd's tests
  for any that reach os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" and fails
  if a shard of the lane never lists one. The proxied guard's helpers now
  take the variable and the script; a fixture test pins the walk.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 22:02:22 +00:00
Julian Knutsen
d28f56cd46
perf(startup): initialize packages on four Ps, not every CPU (#7701)
* perf(startup): initialize packages on four Ps, not every CPU

bd links several thousand packages whose init functions allocate about
20 MB before main runs, which triggers four or five garbage collections.
Each one starts mark workers and stops the world across every P, and on a
large host that costs more than the collection itself: on a 192-CPU machine
`bd version` spent about 20 of its 110 ms there, paid again by every bd
process a script or an orchestrator starts.

internal/initprocs lowers GOMAXPROCS to 4 for the duration of package
initialization. It imports only runtime and syscall, so it initializes
ahead of the heavy packages, and main hands GOMAXPROCS back first thing:
to the GOMAXPROCS environment value when one is set, else to the runtime
default, which keeps tracking the CPU limit.

cmd/bd's TestMain does the same hand-back, since tests never run main, and
resets the -test.parallel default testing derived from the capped count.

Measured on that host (40 runs each, `bd version`): p50 103 -> 86 ms.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(initprocs): tell an explicit GOMAXPROCS hand-back from the runtime default

Review follow-up. TestDoneHonorsAnExplicitGOMAXPROCS swaps the two runtime
calls for recorders and pins that Done restores the exact value when
GOMAXPROCS is set and calls SetDefaultGOMAXPROCS when it is not; the earlier
test only saw the resulting count, which is the same either way on a host
whose default equals the saved value.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of gascity-agent
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-19 17:15:54 +00:00
Julian Knutsen
05fffb1e11
test(storage): versioned-history flag-off differential and statement pins (#6132, #6135) (#7681)
* test(domain/db): pin the statements the history-off upsert Insert issues

The participation_generation write fence (#6943) gave domain/db Insert's
upsert path (CreateOnly unset: the quick, todo, gate and batch proxied
servers' create) an existence probe ahead of the upsert, skipped while
versioned history is off. Pin that skip with a sqlmock statement-sequence
test: with history off, the upsert into issues and into wisps issues
exactly the three statements the pre-stack code (4a67d0d028) issues --
the upsert, the created event's same-content scan and its insert -- and
nothing else.

The mock is reached through internal/storage/sqlcount, and the pin also
requires exactly three statements to reach the driver. sqlmock alone
answers an unscripted statement with an error and fails only if the
caller returns it, so a best-effort read whose error Insert dropped would
pass its checks; the count catches it. The history-on run of the same
script is the control: the probe (and the mint after it) must make the
pin refuse it, which shows the script is exhaustive and that Insert reads
the transaction's scope.

Passes on 4a67d0d028 and on main; main issues no extra read with history
off. Before-parity pin P2 (Insert half) from the fork gap analysis, for
gastownhall/beads#6132 / #6135.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(issueops): pin the statements the history-off defer-wake sweep issues

Port the fork's sqlmock pin of WakeExpiredDefersInTx with versioned
history off (donnabox/codex/preview3-source-catchup-46aa 11c74cb575):
a one-row sweep issues exactly the expired-row SELECT, the UPDATE, the
event's same-content SELECT and INSERT, and the empty wisps pass, so any
read added before or after waking a row while history is off fails the
pin. It passes on main unchanged and guards the fork's wake-skip change,
which checks each expired row against the mint before waking it and must
keep that check free with history off.

Adapted for main: the doc no longer describes the fork's pre-wake check
as existing; a history-on run of the same script is added as the control
(the mint's read must make the pin refuse it), so the pin cannot pass
vacuously; and the mock is reached through internal/storage/sqlcount, so
the pin also requires exactly five statements to reach the driver. That
catches a read whose error the sweep swallowed, which sqlmock alone does
not see. Passes on 4a67d0d028 and on main. Before-parity pin P2 (wake
half), for gastownhall/beads#6132 / #6135.

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(storage): versioned-history flag-off differential against pre-stack goldens

gastownhall/beads#6132 and #6135 require a differential test proving that
with versioned history off (the default) storage behaves byte-identically
to before the feature. Existing coverage stops short of that:
TestDualWriteContractFlagOff only counts version rows, the
participation-generation contracts check one column, and createbatchequiv
runs its batch with history on over a column subset.

Add internal/storage/historyoffequiv. Each leg (embedded Dolt, Dolt
server, unit of work) runs one scripted mutation set through its own
front doors on a store whose history was never turned on:

- on the issues plane, every write role: creates, batch create, apply
  batch, updates, the no-op update, reparent, dependency add/remove,
  comments, claim/heartbeat/release, lease reclaim, metadata CAS,
  close/reopen, batch close with a refused item, defer and wake, delete;
- the persistence moves in both directions;
- on the wisps plane, the roles again: create, update and the no-op
  update, dependency add/remove, comment, metadata CAS, close/reopen,
  apply batch, batch close, release, defer and wake (the sweep's wisps
  pass), delete, a forced close of a no-history wisp, and the refusals
  the lease roles' contracts give a wisp (Claim, Heartbeat; Reclaim finds
  nothing);
- each leg's own surface: the store legs' DoltStorage methods (import
  upsert, promotion, RunInTransaction, ...) and the uow leg's
  CreateOnly-unset domain upsert and importer.

Neither reclaim sweep finds an expired lease, since no role can age one.
The harness then dumps every column of every base table, plus the
scenario's Dolt commit messages and the final dolt_status, and compares
per-table SHA-256 digests with goldens recorded by running the same
harness against origin/main 4a67d0d028, the commit before the stack
(#6943, #6661, #6664).

The only tolerated differences are listed in schemaAdditions: the stack's
new columns (issues/wisps.participation_generation,
issue_versions.removed_restriction) must be NULL in every row and are
then left out of the digest; its new table (epoch_minted_addresses) must
be empty; its own migration bookkeeping rows (0070-0072, ignored/0028)
may each be there once. Recording and checking apply that rule the same
way, so a golden re-recorded from main is byte-identical to the
pre-stack one (verified on all three legs). The package doc says how the
goldens are kept: a later migration whose schema flag-off leaves
untouched adds its own schemaAdditions entry; a deliberate flag-off
change, a scenario change or an engine rendering change re-records them
and shows the dump diff. Wall-clock instants, wall-clock-derived ids and
random tokens are masked by explicit, documented rules found by diffing
two runs; instants the scenario supplies stay verbatim, so a write that
starts overwriting one still shows.

All three legs pass on main. Before-parity pin P1 from the fork gap
analysis; the new embedded test is placed in the 40-shard storage block.

Agent-Signature: claude-code-claude-opus-5-5-unknown-reasoning on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Jim Wordelman <jim@wordelman.name>
2026-10-19 03:47:00 +00:00
Jim Wordelman
9c6f6e15cd
bd versions + a config switch for versioned history — the minimum cut that makes versioned beads usable (#6138) (#6661)
* test(conformance): author R7.1 as-of-read conformance contract

Adds a new Phase 0 conformance contract for R7.1 (as-of reads,
gastownhall/beads#6136, design doc #5898 rev 9) -- no fixture existed for
this anywhere in backend/conformance/, so this is authored from scratch,
not un-skipped.

AsOfReadFixture supplies three hooks: Resolve (the read under test),
MintAt (seeds a version at a controlled accept-time), and
MakeUnanswerable (arranges a Gone/Unknown refusal independently of
RetentionFixture/EpochFixture's own removal machinery, since R7.1's
refusal is a sibling contract to R17/R20, not a dependent of them).

Five Run* functions cover the bead's five required-coverage points
verbatim:
- selector accepts either an instant or a version address, and both name
  the same answer when they resolve to the same version;
- resolution returns the latest version at-or-before T, with a version
  accepted after T strictly excluded even when close by;
- a served result reports the exact address it served;
- an unanswerable read refuses as a typed Gone*/Unknown outcome with a
  reason, and never substitutes a neighboring version, the nearest
  surviving version, or current state -- asserted directly by requiring
  Address == "" on every refusal;
- local completeness only (TC3): a lineage minted into one of two stores
  resolves there and refuses Unknown (FR-06) on the store that never
  received it, asserting nothing about agreement between the two.

The file's doc comment states the Memory-plane-consumer-policy non-goal
explicitly (closed-before-T boundary, sibling exclusion, supersession
exclusion are consumer policy per #5877, not part of this primitive) so
the gap reads as deliberate scope, not an oversight.

Wired onto all three storage legs (dolt, embeddeddolt, uow) with
unconditional "not implemented" stubs rather than partial-real hooks, so
every case fails via MintAt on its first fixture call -- deterministic
RED with no risk of an accidental pass, per the precedent set by
be-x5jqd.1. Sentinel error messages reference be-x5jqd.5, the
implementation child this suite is written ahead of.

TestEveryLegWiresEveryRoleContract requires zero waivers: all 5 new
entrypoints are fully wired (not nil) on all three legs.

Branch cut from the rebased be-2h167 head (5fdfb92fe5).

Verified via go build ./..., go vet ./..., gofmt -l, and go test -tags
cgo across all three legs: all 5 new subtests (8 counting the 4-way
Gone/Unknown table) FAIL for the documented reason,
TestEveryLegWiresEveryRoleContract passes cleanly on all three legs, and
TestVersionedHistoryPhase0RunsInFullSkipMode is unaffected.

Bead: be-x5jqd.2

* fix(history): refuse metadata integers binary64 cannot hold exactly (refs be-wdlod, #6358 follow-up)

canonicalDurableState canonicalizes numbers per RFC 8785 (JCS), which
renders every number as an IEEE-754 binary64 double regardless of
magnitude. An integer-valued metadata literal past 2^53-1 therefore
rounds to a DIFFERENT VALUE on the way into durable_state -- not a
formatting change, a value change -- which can collapse two distinct
issue states onto one durable_state and therefore one content token.

refuseUnrepresentableIntegers is the fix: an admission gate, one layer
above the JCS step, that parses each JSON number literal exactly with
math/big (never float64 -- float64 rounding is the exact thing being
guarded against) and refuses whenever the literal's VALUE, not its
spelling, is an integer whose magnitude exceeds 2^53-1. Value-not-form
matters because the first cut of this gate skipped any literal
containing '.', 'e', or 'E' outright, reasoning that non-integer forms
round-trip losslessly -- true for genuinely fractional literals, but
not for an integer VALUE spelled in decimal or exponential form: QA
found that 9007199254740993.0 and 9.007199254740993e15 walked straight
past that first gate and canonicalized to the same colliding target as
the bare literal. The predicate now inspects the value via
big.Rat.SetString/.IsInt, so all three spellings are refused alike.

1e300 is refused too, no notation carve-out: it denotes the integer
10^300, and binary64 spacing near that magnitude is roughly 2^248 --
vastly wider than the collision window at the 2^53 boundary this gate
exists to close. Admitting that spelling while refusing 9007199254740993
would be the same defect with a bigger window (mayor's ruling, citing
this collision-window argument as decisive). Non-integer values stay
admissible past the bound (1.5e300 is fine): ES6 shortest-round-trip
formatting is a bijection on doubles, so two non-integer literals
collide only if they already denoted the same double before this gate
ever ran, and a fractional literal never carried a promise of exact
decimal storage the way an integer -- an id, a count, a timestamp --
carries a promise of exactness that silent rounding would corrupt.

jcsCanonicalize is canonicalDurableState's RFC 8785 step pulled out on
its own, below the gate rather than behind it, because refusing 1e300
puts the admission policy at odds with one of this store's own spec-
conformance fixtures: testdata/jcs/input/values.json, one of the 10
official RFC 8785 vectors shipped verbatim from the spec's reference
suite (not authored here), itself contains 1E30. RFC 8785 conformance
is a claim about the canonicalizer, not about this store's admission
policy, so TestCanonicalDurableStateIsJCS now runs all 10 shipped
vectors -- values.json included, still asserting 1E30 folds to 1e+30
per spec -- through the ungated jcsCanonicalize, while its two local ad
hoc cases keep exercising the full gated canonicalDurableState, since
neither conflicts and both are more faithful to production traffic that
way. The gate's own refusal of that magnitude is pinned separately, on
its own terms, in version_history_integer_admission_test.go.

Severity is MINOR, not MAJOR: Dolt's JSON column type already
renormalizes metadata to float64 on every read regardless of this gate
(measured on dolt 2.2.3: 9007199254740993 reads back as
9007199254740992, 1e300 as 1e+300), which converges two distinct
in-memory states to one stored state before any version row is minted.
The collision this gate closes is therefore unreachable through normal
bd update traffic on this backend; it stays real for off-path writes --
bd sql, a hand-written JSONL import, or a TEXT-column backend -- which
is why this landed as a follow-up rather than gating Phase 2 itself.

Verified clean: a full module compile; static analysis over the
storage tree; the complete issueops package suite (260 subtests); the
schema package suite; and the broader storage tree, apart from one
dolt-package test that fails identically against the pre-this-diff
baseline (a Dolt server port collision with a concurrent session's
process on this host) -- confirmed pre-existing and environmental, not
caused by this change.

* feat(issueops): implement R7.1 as-of read's store-layer primitive (be-x5jqd.5)

Turns backend/conformance/versioned_read_contract.go (authored RED in
6aefdce60, gastownhall/beads#5898 rev 9, #6136) towards GREEN. This
commit lands the shared production seam; wiring the three per-leg
fixtures (dolt, embeddeddolt, uow) onto it is a follow-up commit.

asof_read.go (new): AsOfReadInTx resolves an AsOfSelector (an instant
or a previously-served version address) to one issue_versions row --
the latest version accepted at or before T, everything later strictly
excluded -- and reports either its state and address, or a typed
refusal (gone-retention/gone-erasure/gone-reorganization/unknown) with
a reason. storeID is accepted only for signature parity with the
fixture hook shape (Design D: the conformance suite's own ad hoc
dispatch string selects among per-leg isolated test stores; issue_versions
carries no store_id column, matching CurrentEpochInTx's precedent).
AsOfRestriction is string-backed, unlike R20's int-backed
EpochRestriction, because it round-trips directly through the new
removed_restriction column with a plain cast.

Migration 0069 adds issue_versions.removed_restriction VARCHAR(30),
nullable (NULL = live, never a stored value). Sits alongside removed_at/
removed_reason (migration 0067, virgin until this slice); AsOfReadInTx
only READS all three -- a future R17 is the real writer via hold/remove/
erase primitives, no collision. Guarded PREPARE + CLI direct-DDL
override + schema_test.go hygiene entries, all modeled on 0068's
pattern; TestLatestVersionIncludesMigration0068 is superseded per the
one-pin-at-a-time convention.

version_history.go: splits RecordVersionInTx into a versionedHistoryEnabled-
gated wrapper and a new exported RecordVersionAtInTx, both delegating to
a shared recordVersionAtInTx(..., at time.Time) body. RecordVersionAtInTx
is test-support only -- ungated, caller-chosen timestamp -- so an as-of-
read fixture's MintAt hook can mint version rows dated in the past
without flipping a store's history-enabled flag. No behavior change for
existing RecordVersionInTx callers.

The new/moved code shifted which function each completeness guard sees
as the enclosing write site, so all three needed updating, not bypassing:
- row_lock_guard_test.go's funcNameExemptions key moves from
  RecordVersionInTx to recordVersionAtInTx (the write's new actual
  enclosing function), reasoning extended to cover both callers.
- journal_completeness_test.go's beadDMLExemptions and
  version_completeness_test.go's versionExemptions each gain a
  RecordVersionAtInTx entry mirroring RecordVersionInTx's own (test-
  support twin, no production caller, no mutation of its own to
  journal/mint beyond the seam itself).

Also fixed a latent test-helper gotcha found while writing the 0069
Dolt-CLI test: queryDoltCSV trims the whole `dolt sql -r csv` output
before parsing, so a row whose ONLY selected column is NULL renders as
a bare blank line that strings.TrimSpace silently swallows when it's
the trailing line, collapsing "one row, NULL value" into "zero rows".
Fixed by selecting a non-NULL anchor column (issue_id) alongside the
column under test.

Verification performed: full module compile and static analysis, gofmt
clean; the complete internal/storage/schema suite with the real-Dolt-CLI
lane enabled; and the complete internal/storage/issueops suite,
including every completeness/row-lock structural guard -- all clean.

* feat(issueops): wire dolt, embeddeddolt, and uow onto R7.1 as-of read (be-x5jqd.5)

Turns backend/conformance/versioned_read_contract.go fully GREEN
(authored RED in 6aefdce60, gastownhall/beads#5898 rev 9, #6136): this
follows up on 4da98a9a8's shared production seam by wiring all three
storage legs' AsOfReadFixture (Resolve/MintAt/MakeUnanswerable) onto
issueops.AsOfReadInTx, per that commit's own stated plan.

Each leg's asOfReadHarness is Design D's dispatch table: the
conformance suite invents storeID strings to select among N isolated
stores, and isolating them is entirely the harness's job --
AsOfReadInTx itself stays storeID-oblivious. The three legs differ
only in how they get that isolation cheaply:
  - dolt: one shared testcontainer, N randomly-named databases
  - embeddeddolt: N fully independent on-disk databases
  - uow: one shared dolt sql-server subprocess (NewDoltServerUOWProvider's
    adoption semantics collapse repeat calls against the same root dir
    onto the same process), N randomly-named databases

All three harnesses are Fatalf/Skip-free below their own
TestAsOfReadContract body: AsOfReadFixture's hooks carry no *testing.T
of their own and run from inside t.Run subtest closures (sometimes
nested two deep), where FailNow/SkipNow would panic with "subtest may
have called FailNow on a parent test". Failures instead flow back as a
plain error into conformance.RunAsOfReadXXX, which Fatalfs correctly
on the subtest's own goroutine.

Two small companion fixes surfaced while wiring the legs on:

  - issueops.asOfVersionAddress -> AsOfVersionAddress (exported): each
    leg's MintAt needs to build the exact token its own
    RecordVersionAtInTx write will resolve against, from a different
    package than issueops.

  - recordVersionAtInTx now truncates `at` to whole seconds before
    writing it to issue_versions.change_at (DATETIME, migration 0067).
    Measured on dolt 2.2.3: the column ROUNDS a sub-second value rather
    than truncating it, so a change_at of 13:32:04.77 lands at 13:32:05
    -- strictly later than the instant it was meant to record. That
    breaks resolveAsOfRevisionInTx's "at or before T" comparison
    (asof_read.go) for any T between the true instant and the rounded-
    up one. This is a production correctness fix, not test-only:
    RecordVersionInTx hits the identical hazard on every real
    time.Now().UTC() call whose nanosecond component rounds up.

Verification performed:
  - uow: TestAsOfReadContract green standalone (5 subtests, 4 nested
    restriction variants) and the full uow package green in isolation
    (673s, includes pre-existing TestReleaserContract and everything
    else). A `go test ./internal/storage/...` full-tree sweep flagged
    uow FAIL via a 600s hang inside TestReleaserContract's migration
    lock -- traced to cross-package parallel resource contention from
    running the whole storage tree's dolt-sql-server-spinning suites
    concurrently, not a regression: the same test is clean when the
    package runs alone.
  - embeddeddolt: TestAsOfReadContract green (22.89s, all subtests and
    all 4 restriction variants).
  - dolt: skipped on this host -- no Docker for the leg's testcontainer,
    the same pre-existing skipIfNoDolt gate the whole dolt package
    already runs under, unrelated to this change.
  - TestEveryLegWiresEveryRoleContract and
    TestEveryContractImporterInTheStorageTreeIsRegistered both pass for
    all three legs.
  - gofmt clean; whole-module build and vet clean.

Bead: be-x5jqd.5

* feat(versions): bd versions + a config switch for versioned history (refs be-hs42e.6.2)

Versioned history has been buildable but not usable: migrations 0067+ create
issue_versions, and the Phase 2 writer fills it, but SetVersionedHistoryEnabled
was a Go method nothing in cmd/bd ever called. There was no supported way for a
person to turn the feature on, and no way at all to read it back without raw
Dolt SQL. This adds the switch and a reader.

- versioned-history.enabled (env BD_VERSIONED_HISTORY_ENABLED), default off,
  applied at the top of wireStorageDecorators. It MUST run on the raw store:
  the capability is a type assertion and no decorator forwards it, so applying
  it after a wrap would silently leave history off while the config said it was
  on. TestVersionedHistoryConfigAppliesToTheRawStore pins the ordering, and
  fails rather than skips if a decorator ever starts forwarding.

- storage.VersionLister + issueops.ListVersionsInTx over issue_versions, on the
  dolt and embeddeddolt legs. A narrow capability rather than a Storage method,
  following ExternalRefHistoryQuerier: a backend that cannot know must be able
  to say so instead of answering "none".

- bd versions <id>, with three distinguishable outcomes rather than two. Off,
  unsupported, and empty are different answers with different fixes; an empty
  list is a claim about the bead, and returning it for the other two would be a
  wrong answer rather than an empty one. The four removal restrictions render
  as four sentences, and unknown (no lineage knowledge here) is not gone.

- REV is printed as a local ordinal with a footer saying so. It is deliberately
  NOT presented as a citable address: AsOfVersionAddress mints over the ordinal,
  two clones can both hold revision 8 of the same bead, and the durable
  version_id primary key has not landed. An address printed now would break
  every citation once it does.

- bd version <id> now points at bd versions <id> instead of printing bd's own
  build and looking like the bead has no history. Bare bd version is unchanged.

No migration: 0067/0068/0069 already carry every column this reads.

Verified on a scratch store: create + 2 updates + close with the flag on lists
4 attributed versions; with the flag off, 0 rows in issue_versions and the
command refuses naming the key.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(versions): emit local_revision, not revision, in --json (bee's #5898 consumer read)

types.Issue already ships `json:"revision"` (types.go:1206) and it is the
row-lock CAS token — an unrelated value, and a string where this one is an
int64. Emitting "revision" from the versions payload would put two meanings
and two types on one key in the place machines read: the `bd version`
collision again, with worse consequences, since a script that learned one
shape gets the other and cannot tell.

local_revision also carries the non-citability with the value rather than
only in a footer no script parses, and needs no rename when version_id lands
beside it.

Raised by @bee-ghosttrack's consumer read on #5898, who reported a couple of
hundred script files parsing `bd … --json` — this is the part of the surface
they would actually touch. Pinned by
TestVersionsJSONDoesNotCollideWithIssueRevision.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(versions): make the advertised switch actually switch it on (#6661 review)

@bee-ghosttrack's blocking finding: the help text and the off-refusal both
told the user to run `bd config set versioned-history.enabled true`, and that
command did not turn the feature on. The key is not yaml-only, so `bd config
set` routed it to the workspace DATABASE; both readers called config.GetBool,
which is viper (yaml + env) only. The user ran exactly what they were told,
was told it was set, and recording stayed off — configured on, actually off,
one layer up from the decorator-ordering hazard this command already guards.

Takes bee's option (b): read the switch from the store's own config, where
`bd config set` already writes it. That also makes recording a property of
the STORE rather than of whoever is calling, which is what closes finding 2 —
two clients of one sql-server can no longer disagree about whether a write is
recorded.

The two planes are OR'd rather than ranked. The hazard is a write that fails
to record, never one that records when it needn't, so either saying yes is
enough and neither can silently switch the other off. BD_VERSIONED_HISTORY_ENABLED
still works for a one-off run. A store with no settings plane (proxied, no-db)
falls back to viper instead of failing the command.

Also from that review:

- finding 3: the read no longer refuses just because recording is off. A store
  that recorded for a month and was switched off HAS versions; refusing made a
  claim about the store from a fact about this invocation's config, which
  VersionLister's own doc says are independent. Rows are listed either way,
  with a note when recording is currently off; refuse-with-remedy only when
  off AND empty.
- finding 4: an unresolved id with no versions is "no such bead", not "none
  yet". Falling through on an unresolved id stays right — a deleted bead can
  still have versions — but only until the answer is empty.
- finding 5: the ordering test's escape hatch is t.Fatal, not t.Skip; a skip
  returned before the assertion that actually guards the ordering. The
  storage_chain.go doc cited a test name that never existed. version_lister.go
  promised a list of compile-time assertions that was not there; the
  assertions now exist in each leg's own package, where they can compile.
- `versioned-history.` is a recognized config prefix, so the set no longer
  prints "not a recognized config key" immediately before confirming the set.

Test: TestVersionedHistorySwitchRoundTrip_Embedded drives the real
`bd config set` through to a real `bd versions` against a real store, with
BD_VERSIONED_HISTORY_ENABLED cleared so a pass proves the store setting
carried it alone. This is the round trip bee asked for, and it is the only
shape that could have caught the original defect — a fake-backed unit test
cannot see a disagreement between two real planes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* docs(versions): name what the OR'd switch planes cost (#6661 review)

@bee-ghosttrack, round 2: with the two planes OR'd rather than ranked, the
consequence worth naming is that once the store setting says on,
BD_VERSIONED_HISTORY_ENABLED=0 cannot countermand it for a single run. The
help now says so, and says where to turn it off instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(versions): gate the wiring store read on the capability, not a recover (#6661 review)

@bee-ghosttrack's round-3 blocking finding. wireStorageDecorators reads the
versioned-history switch off the raw store on every bd invocation, and did so
before anything established that the store could use the answer. cmd/bd's own
fakeProbingDoltStore embeds a nil storage.DoltStorage, so the promoted
WorkspaceConfig SIGSEGV'd at wiring time -- and a panic takes the whole test
binary down, which is why one unguarded read showed up as two red CI steps
(Test (macos-latest), PR Core (wrapper timing)) rather than one failed test.

Takes the fix bee prescribed: assert storage.VersionedHistoryConfigurer first
and read the store plane only when the store could act on the answer.

The previous round fixed this with a recover plus a WorkspaceConfig on the
fake, and left a comment arguing that no capability assertion could work. That
argument was wrong, and wrong in a specific way worth recording: it reasoned
about asserting WorkspaceConfig, which IS declared on storage.DoltStorage and
so matches every store including the nil-embedding fake. bee proposed
asserting VersionedHistoryConfigurer, which is a different interface --
SetVersionedHistoryEnabled is NOT part of DoltStorage, so the fake does not
promote it and does not satisfy it. The comment rebutted a fix that had not
been proposed. It now states what is actually true.

So the fake goes back to byte-identical with the pushed head: the wiring fix
fixes that test without touching it, as bee said it would, and the fake keeps
the "only the methods below may be called" constraint its own doc asserts.

The recover stays, as a backstop rather than the guard. It covers what the
assertion does not: versionedHistoryEnabled is also called from `bd versions`,
where the read is the point and no capability gate precedes it, and a store
that DOES implement the capability can still have a half-built settings plane.

The viper plane is still read first and unconditionally, so a set-but-unsupported
store still reaches applyVersionedHistoryConfig and still gets its warning. Only
the store-plane read is gated. The one case that loses a warning is a store whose
own settings plane says true but which lacks the capability -- and `bd config
set` could not have written that plane on such a store to begin with.

Tests, split so each layer fails for its own reason:

- TestWireStorageDecoratorsSkipsTheStoreReadForANonConfigurer asserts calls == 0,
  not merely that it survived. "It survived" is what the recover delivers too,
  which is how this regressed the first time.
- TestWireStorageDecoratorsSurvivesAStoreThatCannotAnswer keeps the recover's
  case, now on a store that IS a configurer so the guard lets it through.
- TestVersionedHistoryEnabledForWiringReadsTheStoreWhenItCanRecord pins that the
  guard did not stop reading the plane finding 1 existed to start reading.

Mutation-verified both ways: removing the guard fails the first test on
calls=1/want=0 while everything still "passes" by surviving; removing the
recover leaves the first test green and fails only the second.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(versions): name the embedded round-trip so CI selects it (#6661 review)

@bee-ghosttrack's round-3 finding 2. The round-trip test that proves the two
config planes agree ran only on the author's machine.

.github/scripts/embedded-test-shard.sh discovers what to run with
`grep -rh '^func TestEmbedded' cmd/bd/*_embedded_test.go` and validates
manifest entries against ^TestEmbedded[A-Za-z0-9_]+$.
TestVersionedHistorySwitchRoundTrip_Embedded matched neither, so the only
lane that sets BEADS_TEST_EMBEDDED_DOLT=1 for cmd/bd never selected it; the
generic Test jobs run without that env, where the test's own guard skipped it.
Skipped and passed look alike from outside, which is what made it invisible.

Renaming is the whole fix -- a test absent from the shard manifest still gets
a shard from the fallback distribution. Verified by running the script's own
selector over the tree and confirming the new name is discovered.

The rationale is now a comment on the test, because the old name reads more
naturally and nothing else in the file explains why the prefix is load-bearing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(versions): drop the dead fixture, name the empty arm (#6661 review)

@bee-ghosttrack's round-3 finding 3. TestVersionsRefusesWhenFlagOff built a
backend holding one recorded version, handed it to nothing, and ended in
`_ = backend`.

The fixture was load-bearing for the assertion the test was named after --
that the read was refused BEFORE the backend was consulted. Finding 3 removed
that behaviour on purpose, so the assertion went with it; the fixture stayed
behind, unused, under a name still promising the old contract.

Renamed to TestVersionsOffAndEmptyRefusesWithRemedy for what it actually pins,
moved beside TestVersionsOffButRecordedStillLists so the two read as the pair
they are -- recording off decides the FOOTER, never whether to read; off with
rows lists them, off and empty is the one case that refuses -- and the dead
fixture is gone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(proxy): give bd versions a capability row, a typed refusal (#6661)

main's proxied-server capability registry (#6582) requires every command
path to carry a row, and TestProxyCapabilityRegistryCoversCommandTree
fails for `bd versions`, which this PR adds.

It is refused, reason unimplemented, rather than permitted. It is a pure
read (issueops.ListVersionsInTx in one read transaction), so nothing
about it is unsafe on a shared backend and "design" would be wrong. But
it reaches the backend only through the optional storage.VersionLister,
which the dolt and embedded stores implement and the uow provider does
not. Permitting it would open the proxied provider in the root pre-run
(starting the proxy and dolt) and then fail untyped at
errVersionsUnsupported. The row refuses with proxy.versions.unsupported
before any side effect, and its tracking names the missing piece: a
VersionLister over the proxied uow provider (tracker #6132).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(uow): register verified shutdown cleanup in TestAsOfReadContract (#6661)

main's TestEveryServerFixtureRegistersVerifiedCleanup (#6441) requires
every server fixture to use verifiedShutdownCleanup(t, storeRootDir)
instead of calling proxy.Shutdown directly, so a shutdown that refuses
cannot leave a live dolt sql-server behind a green run. TestAsOfReadContract
still had its own proxy.Shutdown cleanup that only logged the error.

The cleanup is registered at the same point, so the LIFO ordering the
harness relies on (every provider closed before the shared server stops)
is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* style(schema): gofmt cli_migrations.go after the 0070 renumber

The rebase onto upstream's 0069_widen_issue_versions_datetime_precision
(#6675) joined its const and the renumbered 0070 comment without the
separating blank line, which make fmt-check rejects.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(history): stop flooring change_at now that 0069 widened it (refs be-hs42e.10)

recordVersionAtInTx carried `at = at.Truncate(time.Second)`. That was correct
while 0067's plain DATETIME was in force: Dolt's datetime(0) does not truncate
sub-second input, it ROUNDS half-up, so a change_at could be stored strictly
LATER than the instant it recorded and break AsOfReadInTx's "latest version
accepted at or before T". Flooring first left nothing to round.

Migration 0069 widened change_at and removed_at to DATETIME(6), which removes
the rounding entirely and makes the floor actively harmful — it threw away the
microseconds the widening exists to keep. Two versions minted in the same
second collapsed onto one stored value and stopped being distinguishable by
change_at, which defeats --at, the only PORTABLE selector the read surface
offers while revision stays a per-store ordinal and no durable version address
has shipped.

This was measured, not inferred. On a store carrying both the widening and the
floor, four versions minted inside one second all read back 15:40:38.000000:
the column could hold microseconds and the writer refused to supply them. Two
correct fixes cancelling each other, and only the second one was visible.

removed_at needs no matching change: MarkLatestVersionRemovedInTx already
passes time.Now().UTC() straight through and was never floored. Audited rather
than assumed.

Pinned by TestRecordVersionKeepsSubSecondChangeAt (embeddeddolt), which mints
two versions 500ms apart inside one second and asserts both that the
fractional part survives and that the two differ. Verified it FAILS with the
floor restored — reporting exactly the 11:04:07.000000 collapse — and passes
without it, so it is a real guard rather than a test that passes either way.
The column's own half of the contract stays pinned by
TestMigration0069ChangeAtSurvivesSubSecondPrecisionThroughDoltCLI.

Also drops this branch's own tx-minting guard commit, which upstream landed
independently as #6833.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(feat): red — Activate versioned history in every store and provider factory, each store reading its own #6661 switch (stacked on #6661) (refs be-qxq70)

Tests first, all failing on the right reasons at fb6e219d6a (#6661's head):
- D1: on real embedded stores a routed update, a routed close and
  `bd create --repo` into a rig whose OWN row is on each gain 0
  issue_versions rows, want 1; the control (a write inside the rig) gains 1.
- D3: BD_VERSIONED_HISTORY_ENABLED=1 records into no routed store, and =0 is
  shown not to switch off a store whose row is on.
- D4: TestEveryStoreConstructionActivatesVersionedHistory flags all 9 store and
  provider factories, and its mutation probe reports "probed 0 of 9".
- wiring: wireStorageDecorators still reads the store's row (1 read) and
  switches it on; activation belongs to the factories.
- internal/versionedhistory (does not exist yet) and the doctor repair opener:
  the resolver, the provider read (K1), the error-vs-absent diagnostics and the
  shared-activation requirement.

* feat: green — Activate versioned history in every store and provider factory, each store reading its own #6661 switch (stacked on #6661) (refs be-qxq70)

Stacked on #6661 (fb6e219d6a). #6661's plane and approved commits are
unchanged: the switch stays a row of the store's own config table, OR'd with
viper, and `bd config set versioned-history.enabled true` still writes that
row and not config.yaml.

The defect: applyVersionedHistoryConfig ran only from wireStorageDecorators, so
the one store a command opens for its own workspace was activated and every
store built by newDoltStoreFromConfig (prefix-routed update/close, `bd create
--repo`, the direct-mode open) was not. With the switch on they recorded no
issue_versions row while the command reported success.

- Activation moves to where a store or unit-of-work provider is constructed
  (the store_factory.go/_nocgo.go twins, uow_factory.go's two provider
  constructors, the personal-migration planning store, and bd doctor's repair
  opener), on the raw store, before anything can wrap it. wireStorageDecorators
  no longer activates, so each store's row is read once per open.
- One resolver, in internal/versionedhistory, reachable from doctor/fix which
  cannot import package main. #6661's semantics are preserved: one key
  spelling, viper first, then the capability check, then the row read, with
  the recover backstop. The behavior-preserving refactor of #6661's
  versioned_history_switch.go / storage_chain.go is the only edit to files
  #6661 introduced; the resolver tests moved with the code, assertions
  unchanged.
- K1: a provider has no DoltStorage, so its row is read through a unit of work
  (NewUOW + ConfigUseCase().GetConfig) at construction: a pooled connection,
  one SELECT, rolled back. The constructors have already run initSchema, so
  this starts no server and creates nothing. It does not fall back to viper
  alone.
- A row read that errors resolves to off but is reported under BD_DEBUG; an
  absent row stays silent.
- Docs (configuration.md), a CHANGELOG entry, and a hint at `bd config set ...
  true` time that the setting replicates and is single-writer only.

The bazel-sync run also wanted unrelated BUILD entries for files that already
exist at #6661's head (versions.go, versioned_read_contract.go, ...); they are
not part of this change and are left out.

* test(feat): green — a served mutation records from the provider's own row, on a real server (refs be-qxq70)

K1 is the one place the resolver cannot ask a DoltStorage: `bd serve` against a
server-mode workspace writes through a unit-of-work provider, so its flag is
read through NewUOW + ConfigUseCase().GetConfig at construction. The fakes in
internal/versionedhistory prove the read; this proves it WORKS against a real
Dolt server at that moment (pool open, database selected, schema migrated).

Two server-mode workspaces on the shared test container: the one whose own row
says on records a served HTTP mutation (+1 issue_versions row), the one with no
row records none.

Measured both ways: passes with the provider activation in place, and fails
("added 0 issue_versions row(s), want 1") with it deleted from both provider
constructors in uow_factory.go.

Proxied lane only (BEADS_TEST_PROXIED_SERVER=1 BEADS_TEST_ENV_RUN_DOLT=1
TESTCONTAINERS_RYUK_DISABLED=true), like TestServeActivatesTheEventsJournal, so
it skips in a plain make test.

* test(feat): red — #6661 review round, small items: findings 2, 4, 5, 6 and 8

Tests for the small findings in the second review round on #6661.

- 2: `bd versions` must decide "recording" from the store's own setting.
  BD_VERSIONED_HISTORY_ENABLED=1 with the store's row unset and nothing
  recorded must refuse, not answer "none yet"; the help text must not offer
  the variable as a per-run switch for a read.
- 4: `bd versions --json` is one object, {"versions": [...], "recording":
  bool}, with [] rather than null when nothing is recorded.
- 5: AsOfReadInTx reports any stored removed_restriction outside its four
  values, "live" included, as unknown.
- 6: the 0070 header spells the restriction vocabulary with the underscore
  spellings the code stores and compares.
- 8: `bd version <arg>` exits 1 and points at `bd versions <arg>`. This one
  pins behaviour the branch already has, so it passes at red; it was shown
  to fail with the guard removed.

Item 7 is a comment-only fix and has no test.

* feat: green — #6661 review round, small items: findings 2, 4, 5, 6 and 7

- 2: `bd versions` reports the store's own setting. It read the environment
  and config.yaml as well, so BD_VERSIONED_HISTORY_ENABLED=1 made a store that
  never recorded answer "No versions recorded yet" instead of refusing with
  the remedy. It only reads, so those planes cannot make the store record.
  The "for one run" hint is dropped from the help and the refusal, since it
  could only ever produce the wrong answer.
- 4: `bd versions --json` is always {"versions": [...], "recording": bool},
  with [] rather than null when nothing is recorded. Previously a bare array,
  or null, and no recording flag.
- 5: AsOfReadInTx reports a stored removed_restriction outside its four
  values, "live" included, as unknown instead of passing it through.
- 6: the 0070 header and its test use the underscore spellings the code
  stores and compares. 0070 is unreleased, and this changes its content hash.
- 7: comment only. DATETIME(6) still rounds to the microsecond; the comment
  said 0069 removed the rounding entirely.

* test(fix): red — #6661 number admission: fractions past the bound, exponent cost, pre-enable scan

Tests for the review round on the number-admission gate, written before the change:

- a fraction whose nearest double is at or past 2^53 is refused (9007199254740993.5,
  9007199254740994.5, 9007199254740991.5), and the gate is closed under its own
  canonicalization, checked as a property over a corpus
- classification depends on magnitude, not on the size of an exponent: 1e100000000 and
  -1e400 are refusals, 1e-100000000 and 1e-400 are admitted, and allocation does not grow
  with the exponent
- the sentinel's text names the I-JSON exact-integer range
- CheckMetadataVersionable agrees with the mint, and FindUnversionableMetadata finds what
  the mint would refuse and skips what it never versions
- bd config set versioned-history.enabled true refuses, writing nothing, over rows the mint
  would refuse, and false never scans

Guards that pass before and after by design: the verdict on every literal as the store
returns it, the mint's refusal writing nothing, and, on the server and embedded legs, the
store-level property that no two literals reading back as different numbers share a canonical
form. Those store tests also log what each Dolt holds for a number outside the range when
history is off, and pin that a later write to such a row is refused once history is on.

* fix: green — #6661 number admission: the nearest-double rule, ParseFloat classification, a pre-enable scan at the switch

The admission gate now refuses a JSON number literal if and only if the binary64 nearest to it
has magnitude above 2^53-1, or it overflows, whatever the literal's spelling:

- a fraction that rounds to or past 2^53 (9007199254740993.5, 9007199254740994.5,
  9007199254740991.5) is refused, so the gate is closed under its own canonicalization
- literals are classified with strconv.ParseFloat, linear in their length, so 1e1000000 no
  longer builds a million-digit integer inside the writer's transaction; an overflow is the
  sentinel and a magnitude too small for binary64 is admitted; math/big is gone
- the sentinel reads "number is outside the I-JSON exact-integer range (magnitude above
  2^53-1)"; ErrIntegerNotRepresentable keeps its name, with a comment saying why
- ordinary fractions such as 0.1 stay admitted; no verdict on a value the store hands back
  changes

The header now says what the mint's refusal is: an integrity backstop inside the writer's
transaction, not an admission policy for metadata.

bd config set versioned-history.enabled true now checks the store first. It reads every issue
the mint would version, runs the mint's own function over each one's metadata
(issueops.CheckMetadataVersionable, through issueops.FindUnversionableMetadata), and refuses,
writing nothing, while any is refused, printing the count, the ids and the fix. There is no
override; setting it false never scans. The environment and config.yaml planes do not pass
through the command and rely on the refusal at write time.

Also: docs and a CHANGELOG entry, and comments in the existing admission tests that described
the old rule.

* test(fix): keep the exponent-cost allocation test stable under the race detector

TestNumberAdmissionAllocationsDoNotGrowWithTheExponent compared two
independently averaged allocation counts with a strict >. Under -race
sync.Pool drops one Put in four at random, and the refusal's fmt.Errorf
takes its printer from a pool, so a call now and then allocates one more
than it would. The test failed on most runs of `go test -race -short`, the
flag set of the required lane, and never without -race.

That noise only ever adds allocations, so compare the fewest allocations
over many single-call samples instead. The comparison stays strict, and it
still fails on the exact big.Rat gate this test exists to keep out (49
allocations for 1e1000000 against 36 for 1e400). The doc comment no longer
claims the count is deterministic under -race.

* test(fix): red — set-many skips the pre-enable scan; pin what the scan reads

bd config set-many versioned-history.enabled=true switches versioned history
on with no pre-enable scan: only bd config set makes it. With a row holding a
number outside the I-JSON exact-integer range the setting is turned on and the
next write to that row fails. The new embedded test drives the real verb over
such a row and expects the whole batch to be refused, writing nothing.

The scan's own embedded test only used open issues, so deleting AllFlag or
IncludeAllTypes, or replacing the unlimited Limit, left it green. It now adds a
closed, a pinned and a gate offender, and a second test imports more rows than
one default page and expects every one of them counted.

* fix: green — bd config set-many runs the pre-enable scan for versioned-history.enabled

bd config set refuses to turn versioned history on while an issue holds
metadata a version could not record. bd config set-many writes the same
setting through a validation loop of its own and made no such check, so it
switched history on over a row whose next write then failed. It now runs the
same check for that one key inside its validation loop, before any pair of
the batch is written, so a refusal stores nothing. The check reads through
the accessor it already used on both routes: the store the command has
opened on the direct route, the provider on the proxied one.

* chore: strip internal tracker ids from the comments and tests across #6661's range

Comment and test-text changes only; no behaviour changes. Across every commit from the
merge-base with upstream main to here, the comments and tests named internal tracker ids
(one bead id in eleven comments and in one test failure message, an example id in the
`bd version` guard's comment, and an internal decision's attribution in the huge-exponent
admission test). They now cite gastownhall/beads#5898 and #6136 only, which is what a reader
of the public branch can follow.

The 0070 migration's header comment is one of the edits. That migration is new on this branch
(it does not exist on upstream main), so the change is not an edit to a shipped migration, but
it does change the file's content hash; the schema tests that compute hashes are self-consistent.

Text that already exists on upstream main is left as it is, even where it mentions an id: this
commit does not rewrite lines the range did not add.

* chore(bazel): bazel-sync (gazelle) for the #6661 range

* fix(bazel): give fix_test the store.go its activation guard parses

TestVersionedHistoryDoctorRepairOpenerUsesTheSharedActivation parses
store.go from its working directory. `go test` runs in the package
directory, so the file is there. A Bazel test only sees its declared
runfiles, so the test failed with

    parse store.go: open store.go: no such file or directory

in //cmd/bd/doctor/fix:fix_test (--config=ci) and in shard 1 of
//cmd/bd/doctor/fix:fix_dolt_test (--config=doltserver), which runs the
same binary through data = [":fix_test"].

Declare store.go as data on fix_test.

* test(fix): red — the pre-enable scan must check the whole issue, as the mint does

bd config set versioned-history.enabled true runs a check over every issue
before it turns history on. The check looked at each issue's metadata alone,
while the mint canonicalizes the whole issue. A gate's timeout is a
time.Duration that a version holds as nanoseconds, so a gate whose timeout is
past 2^53-1 ns (about 104.25 days) holds a number outside the I-JSON
exact-integer range: the mint refuses every write to it, the scan never
looked, and the switch could be turned on over it.

- The agreement test's domain widens from metadata documents to whole issues:
  the metadata corpus, plus timeouts at 2500h (admitted), 2600h, 8760h and
  -2600h (refused), exactly 2^53-1 ns (admitted) and 2^53 ns (refused).
- The scan test covers a gate over 105 days and expects the verdict to name
  the field, "timeout".
- The mint-level refusal test covers the same gate and expects the refusal to
  name the field as well as the literal, for a number in metadata too.
- An end-to-end test on the direct route and one on the proxied route create
  gates with bd gate create --timeout, expect the enable to refuse and name
  them, and expect the issues the scan names to be exactly the issues whose
  next write the mint refuses.
- Three guards keep the scan's lite read from hiding a number: every column it
  leaves out is a string or a list of strings, nothing the mint adds and the
  scan does not load can hold a number, and no exported check over part of an
  issue exists beside the one the mint runs. Each guard is also run against
  shapes it must refuse, so it cannot pass by finding nothing.

The new symbols (CheckIssueVersionable, FindUnversionable and the Field of
UnversionableIssue) do not exist yet, so the issueops tests do not build.

* fix: green — the pre-enable scan runs the mint's own check over the whole issue

The check behind bd config set versioned-history.enabled true looked at each
issue's metadata alone. The mint canonicalizes the whole issue, and a gate's
timeout, a time.Duration held as nanoseconds, is a number outside the I-JSON
exact-integer range once it is past 2^53-1 ns (about 104.25 days). The mint
refuses every write to such a gate, the scan cleared the switch over it, and
the first write after that failed.

CheckIssueVersionable is now exactly canonicalDurableState's refusal over the
whole issue, and FindUnversionable runs it over every issue the mint would
version. It replaces FindUnversionableMetadata, and CheckMetadataVersionable
is gone, so no check over part of an issue is exported beside the one the mint
runs. A refusal names the top-level field it found the value in ("metadata",
"timeout") as well as the literal, on the mint and on the scan; the field is
located only after a refusal, so a write that is admitted still reads the
document once. A gate timeout above 2^53-1 ns is unrecordable by policy: it is
refused at the write, named by field and documented, not re-encoded.

The refusal at the switch gives the fix for each field. For a number in
metadata that is bd update --metadata or --unset-metadata, which works with
history on or off because a version is recorded from the state after the write.
For a gate timeout, which bd update cannot change, it is removing the gate with
bd delete, or setting the timeout_ns column with bd sql while history is off;
bd sql needs a server-backed store, and the text says so. It also says the
check runs once, now: a writer that does not record (an older bd, bd sql, a
pull from a clone that had history off) can add such a row afterwards, and the
first write to it then fails with the same refusal. Making the check and the
write of the setting one transaction would narrow that window, not close it.

Corrected in the comments, the docs and the changelog as well: an import is not
a path that skips the mint, since it goes through the same batch create; and
Dolt's JSON column collapses duplicate keys when it stores a document, so on a
Dolt store neither the scan nor the mint can see one, and the duplicate-key
refusal is a defence for a backend that keeps them.

* test(fix): red — the listing must answer as the as-of read does; the SDK opens must be accounted for

Three review findings on the versioned-history change and one wording fix,
tests first.

- A removed version's restriction. AsOfReadInTx answers a stored value outside
  the four-value vocabulary (a NULL or empty column, "live", a hyphenated or
  arbitrary string) as unknown, but ListVersionsInTx hands the column back as
  stored, for every row, and the label bd versions prints passes such a string
  through. A table test runs the listing and the as-of read on the same stored
  value, for a version that was removed and one that was not, and expects the
  same answer, and none for a version that was never removed. The label gets
  the same out-of-vocabulary values and is expected to render what unknown
  renders.
- The SDK's store opens. The shared construction guard now scans the repository
  root as well, so the Go SDK's five opens (Open, OpenFromConfig and OpenGated,
  and OpenBestAvailable in each build-tag twin) are noticed. Nothing accounts
  for them yet, so both guards fail on exactly those five sites.
- A bytes bound beside the allocation-count bound on the number admission
  gate. A classifier that builds the number it is asked about makes one
  allocation whatever the exponent, so the count bound passes it, and the bytes
  grow. The fewest bytes one call allocates for a literal with a huge exponent
  must be no more than for a small one plus a margin. It passes today, because
  the gate never builds the number; it fails for a gate that does.
- The refusal at the switch names the gate remedy as bd delete <id> --force,
  says that without --force bd only previews, and says that removing the gate
  unblocks anything it was blocking. The embedded and proxied end-to-end tests
  expect all three.

* fix: green — the listing answers as the as-of read does; the SDK opens are accounted for

Three review findings on the versioned-history change and one wording fix.

A removed version's restriction. A stored removed_restriction is a free string,
and only the four values of the vocabulary are answers. The as-of read already
reported anything else (a NULL or empty column, "live", a hyphenated or
arbitrary string) as unknown, but the listing handed the column back as stored,
for every row, and the label bd versions prints passed it through.
NormalizeRemovedRestriction is now the one place that decision is made.
AsOfReadInTx calls it; ListVersionsInTx calls it for a version that was removed
and gives a version that was not removed no restriction; and restrictionLabel
renders through it. The listing, its JSON and the label now say what the as-of
read says for the same row.

The SDK's store opens. The Go SDK's five opens (Open, OpenFromConfig and
OpenGated, and OpenBestAvailable in each build-tag twin) apply neither per-store
switch, the events journal's or versioned history's, and they still do not.
Applying them would change the library's behavior for every embedder, so that
is a separate change; this one declares the boundary. The shared construction
guard now accounts for the five with one exemption reason that is true of both
switches, so a new SDK open is noticed rather than missed, and its staleness
check keeps the exemptions honest. The docs gain one bullet saying that writers
built on the SDK do not apply the switch.

The bytes bound on the number admission gate needs no production change: the
gate never builds the number, which is what the bound pins.

The refusal at the switch now names the gate remedy as bd delete <id> --force,
says that without --force bd only previews, and says that removing the gate
also unblocks anything it was blocking. The docs line says the same. For a gate
that blocks an issue, bd delete without --force prints a preview and exits 1,
and with --force the gate is removed and what it blocked is ready again.

* test(bazel): declare the root package's Go source as data for //cmd/bd:bd_test

The shared store-construction scan now reads the repository root, where the Go
SDK's opens live, but //cmd/bd:bd_test declared none of the root package's
source. Under bazel test the scan therefore saw an empty directory, reported
the five SDK exemptions as no longer matching a store construction site, and
failed the events-journal guard, while go test, which sees the whole checkout,
passed.

List the root in tools/bazel/go_srcs.py so the generator emits its managed
go_srcs filegroup there, and add that filegroup to bd_test's data. The new
block is the generator's own output and nothing else changes.

* ci: list the switch scan's proxied gate-timeout test in the 30-shard manifest

Upstream main (#7129) moved the proxied-server tier to 30 duration-balanced
shards, and TestProxiedShardManifestGeneratorNotStale requires every
TestProxiedServer*/TestServerMode* test exactly once in that block. This
branch adds TestProxiedServerVersionedHistorySwitchRefusesAnUnrecordableGateTimeout
(cmd/bd/versioned_history_switch_scan_proxied_integration_test.go), so the
block needs its line. Written by the generator itself:
python3 scripts/ci/gen_proxied_shard_manifest.py 30 --weights=duration --write
(one line, shard 8); --check exits 0 afterwards.

Rebase note (maintainer): regenerated on current main, whose proxied-server
tier uses 34 shards; the generator's incremental output
(gen_proxied_shard_manifest.py 34 --weights=duration --write) placed this
test at shard 6 of the 34-shard block.

* ci: list the PR's embedded versioned-history tests in the embedded shard manifests

#7156 made the embedded-Dolt tier's shard manifests exact-once (50 cmd
shards, 15 storage shards), so every embedded test must be listed. This PR
adds five embedded cmd tests and three embedded storage tests; this commit is
exactly what the generators write for them:

  python3 scripts/ci/gen_embedded_cmd_shard_manifest.py 50 --weights=duration --write
  python3 scripts/ci/gen_embedded_storage_shard_manifest.py 15 --weights=duration --write

Incremental: 8 lines added, none moved.

Rebase note (maintainer): regenerated on current main, whose embedded
manifests use 100 cmd shards and 40 storage shards; the generator's
incremental output placed these tests at cmd shards 55
(TestEmbeddedVersionedHistorySwitchScansEveryRowNotOnePage), 56
(...SwitchRoundTrip), 57 (...SwitchRefusesUnversionableMetadata), 58
(...SwitchRefusesAnUnrecordableGateTimeout) and 59
(...SetManyRefusesUnversionableMetadata) of the 100-shard block, and at
storage shards 5 (TestRecordVersionKeepsSubSecondChangeAt), 6
(TestVersionedHistoryKeepsNumbersTheStoreDistinguishesApart) and 23
(TestAsOfReadContract) of the 40-shard block.

* test: exempt OpenBestAvailableWith, where #7188 moved the SDK's store construction

Upstream #7188 split beads.OpenBestAvailable: it now delegates to the new
OpenBestAvailableWith, which builds the store. This PR's two construction
guards (TestEveryStoreConstructionActivatesTheEventsJournal and
TestEveryStoreConstructionActivatesVersionedHistory) share one exemption
list keyed by function, so after merging main they flagged
OpenBestAvailableWith as an unexempted construction site and reported the
OpenBestAvailable entries as stale. The two build-tag twins' keys now name
OpenBestAvailableWith. The reason is unchanged: it is the SDK's library
surface for embedders, and no code in the bd binary calls it. gofmt
realigned the three neighbouring entries.

* chore(schema): renumber removed_restriction to 0071 after #6943's 0070

Migrations are numbered by landing order. #6943 (participation_generation,
the versioned-history write fence) lands first and owns main-plane 0070 and
ignored/0028, so this PR's removed_restriction migration moves to the next
free slot, 0071. The rename is done here, as one maintainer commit, rather
than inside the replayed commits, so the history shows exactly what changed
relative to the PR as reviewed; the intermediate commits of the rebase carry
a duplicate 0070 and are not expected to build.

- migrations/0070_add_removed_restriction.{up,down}.sql become 0071_*, with
  their header comments updated (the SQL itself is unchanged). Neither file
  exists on main or on #6943, so this is not an edit to a shipped migration.
- cli_migrations.go: the CLI-bundle override is keyed to the new file name
  and renamed cliMigration0071AddRemovedRestriction, and its const now sits
  after 0070's.
- migration_0070_add_removed_restriction_test.go becomes
  migration_0071_add_removed_restriction_test.go; its tests and messages say
  0071, and it now owns the one LatestVersion pin (71).
  TestLatestVersionIncludesMigration0070 in #6943's participation_generation
  test is superseded by it and replaced by the usual pointer comment, and
  0069's pointer comment now names the 0070 file that superseded it.
- schema_test.go hygiene comments, BUILD.bazel embedsrcs/srcs, and the
  asof_read.go comment that cited the migration number.

Checked: go test ./internal/storage/schema/... (with the dolt CLI lane,
including TestAllMigrationsSQLAppliesThroughDoltCLIAndRecordsLatestVersion)
and scripts/check-migration-hygiene.sh against origin/main and against
#6943's tip.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(versions): reconcile #6661's tests and docs with #6943's write fence

#6943's write fence (design §16.2b) makes an update-shaped write to a legacy
record -- one whose participation_generation is NULL because it was created
while versioned history was off -- a skip, not a refusal: the fence returns
before the snapshot is canonicalized, so nothing is versioned and the mint's
admission gate never runs. Several of #6661's tests seed rows with history
off and then expect a later write to them to be versioned or refused, and
several comments say every later write to an offending row fails. On a tree
that carries both PRs those tests fail and those comments are wrong.

This ports, without changing their substance, the fence-integration commits
Jim Wordelman wrote for the donnabox integration fork, where both PRs were
already folded together:

- eff898db80 / 5d2e5a2ac4 (issueops, dolt, embeddeddolt): the mocked mint
  sequence scripts the fence's participation_generation read; the number
  fidelity test splits phase 2 into 2a (a legacy row is written, not
  versioned, not refused, stays NULL) and 2b (a participating row is
  refused and left untouched); TestRecordVersionInTxSkipsALegacyRowBefore-
  TheAdmissionGate pins the fence's order against the gate.
- e0ad9d1e3c / 1528022dfa (cmd/bd): the switch round trip and the routing/env
  end-to-end tests build the rows they expect a version for after the setting
  is on, and assert that the pre-setting seeds gain nothing.
- 18b9015bf5 (cmd/bd): the embedded and proxied gate-timeout scan tests assert
  the whole scan-vs-mint truth table (legacy offenders are named by the scan
  but not refused by the mint; participating offenders are both).
- 5929ebd50c / 8ce872be03 (comments, CHANGELOG, configuration reference): the
  mint's refusal binds rows that participate in history; the pre-enable scan
  cannot see participation, so it over-approximates in the safe direction.

Left out on purpose: the fork's mintSkipsRow helper and defer-wake sweep
change, and its bd doctor "Versionable Issues" check and the docs that point
at it; none of those are part of #6661 or #6943.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Jim Wordelman <jim@wordelman.name>

* test(versions): adapt #6661's guards to what main changed under it

Three test-side adjustments for code that landed on main after #6661's last
merge of it; no production code changes.

- internal/storage/leg_contract_wiring_test.go: main gained an HTTP storage
  leg, and TestEveryLegWiresEveryRoleContract requires every leg to name or
  waive every role contract. The five R7.1 as-of read contracts this PR adds
  are a storage capability the HTTP client does not serve (internal/httpclient
  answers AsOf with an explicit unsupported error, and the wire has no
  instant/address selector or gone/unknown refusal), so they are waived on
  the http leg with that reason, as the donnabox integration fork does.
- cmd/bd/versioned_history_construction_test.go: main split
  newDoltStoreFromConfig into two thin wrappers over openDoltStoreFromConfig,
  which is where the activation defer now lives (this rebase's resolution of
  the activation commit), so the factory guard keys on that body.
- cmd/bd/versioned_history_serve_e2e_test.go: main's
  TestProxiedGatedTestsRunInTheProxiedLane requires a test that skips unless
  BEADS_TEST_PROXIED_SERVER=1 to be one the proxied lane selects, so
  TestVersionedHistoryServeActivatesTheProviderFromItsOwnRow becomes
  TestProxiedServerVersionedHistoryServeActivatesTheProviderFromItsOwnRow,
  and the 34-shard proxied manifest gains its line (written by
  gen_proxied_shard_manifest.py 34 --weights=duration --write, incremental;
  --check passes).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* chore(bazel): emit go_srcs.py's managed blocks for internal/versionedhistory

Main's tools/bazel/go_srcs.py now manages a repo_files filegroup block in
every package BUILD file, lists those filegroups in the root BUILD.bazel's
aggregates, and lists every go_library in tools/bazel's release_cross_build
target. internal/versionedhistory is a package this PR adds, so after the
rebase those managed blocks were stale and TestBazelGoSrcsBlocksCurrent
(go test ./scripts/...) failed. This is the generator's own output
(python3 tools/bazel/go_srcs.py) and nothing else; --check passes
afterwards.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(versions): don't publish change_agent in bd versions --json

`bd versions <id> --json` prints storage.IssueVersion as-is, so every JSON
tag on that struct is part of a public contract. Provenance V2
(gastownhall/beads#7510, as ruled by the maintainer) removes the ad hoc
agent field in favour of an actor chain; shipping a "change_agent" key now
would make a public contract out of a field that is on its way out.

IssueVersion.ChangeAgent is now tagged json:"-". Nothing else changes: the
issue_versions.change_agent column (migration 0067) stays, ListVersionsInTx
still reads it, change_actor and change_message are still published, and
the human listing never showed the agent. No doc or golden named the key.

TestVersionsJSONDoesNotPublishChangeAgent pins the absence with a non-empty
value, so an omitempty-style regression would still fail, and pins that
change_actor and change_message are still there.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(issueops): pin what the unfenced test-support mint does on #6943's new paths

#6943's two fixes to the shared mint body -- (a) no issues row means no
mint and no error, and (b) a create-shaped call on a new issues-table row
flagged no-history stamps participation_generation without minting -- were
written for its two kinds. This PR's shared body has a third,
mintUnfenced, behind RecordVersionAtInTx (the R7.1 as-of fixtures'
controlled-timestamp mint). The rebase resolution decided what (a) and (b)
mean for it; this pins that decision:

- (a) applies. It is the plane rule (FR-8: the table that holds the row
  decides its plane), not the fence, and the unfenced kind already honoured
  the flag-based form of the same rule (IsWisp). Without it, an unfenced
  mint for an unflagged wisps-table row would insert a version row that no
  issues row points at. The shared body's issues-table read now runs for
  all three kinds; only the update kind acts on the value it reads.
- (b) does not apply. The unfenced mint never declares participation, so a
  flagged row returns right after the snapshot, as before: no read, no
  stamp.
- The fence still does not apply: a legacy row is minted, and the closing
  UPDATE advances current_revision alone.

TestRecordVersionAtInTxKeepsThePlaneRuleButNotTheFence scripts each of
those three sequences exactly with sqlmock.
TestTestSupportMintsStayOutsideTheShapeSplit places RecordVersionAtInTx
outside #6943's create / dual-shape / update classification explicitly (it
is the seam's exempt twin, not a mutation entry point or mint site): it must
be in none of the shape lists, stay in versionExemptions, and reach neither
RecordVersionForCreateInTx (it never stamps) nor RecordVersionInTx (whose
gate and fence would stop the as-of fixtures minting history-off rows). The
row-lock guard's exemption comment for recordVersionAtInTx already names the
stamp-only UPDATE: #6943's own wording of it (all three UPDATE issues
statements) was carried into that exemption when the as-of read commit was
replayed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(storage): say exactly why the as-of read contracts stay waived on http

#6943 now runs most of its participation-generation contracts over the
served wire (internal/httpclient/served_participation_generation_test.go):
their subject is a create or an update, which the client can send, and the
fixture reads the reference store's raw columns. This checked whether the
five R7.1 as-of read contracts can be wired the same way. They cannot,
cheaply or otherwise, without a new wire operation:

- their subject is the read itself (AsOfReadFixture.Resolve), and R7.1's
  read, issueops.AsOfReadInTx, is reached by no publicops role and served
  by no wire operation;
- the wire carries neither selector (an instant or a served version
  address) nor the gone/unknown refusal the read answers with;
- the client's only point-in-time read, DoltStorage.AsOf, is a Dolt
  commit-ref read, not R7.1, and is on the client's D8 unsupported
  allowlist.

Binding Resolve to the reference store behind the served env would pass,
but as a property of that store, which the store legs already pin, never
of the client. So the waiver stays; its comment and reason string now say
the above instead of the earlier shorthand ("HTTP AsOf is explicitly
unsupported"), which conflated the client's commit-ref AsOf with R7.1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(versions): describe what the write fence does to beads that predate recording

With #6943's write fence (design §16.2b) a bead that existed before
versioned history was turned on (participation_generation NULL) is legacy:
an update-shaped write to it is skipped, so it is never versioned however
often it is edited. Several user-facing strings from #6661 still described
the behaviour before the fence, and an independent review reproduced each
with a built bd (a legacy bead edited twice after enabling still lists no
versions; a legacy bead the switch refuses over is written without refusal
under BD_VERSIONED_HISTORY_ENABLED=1). Text only; no behaviour changes.

- bd versions help: only beads created while recording is on are versioned;
  a bead that already existed is legacy and editing it records nothing; no
  backfill. (Was: "a bead edited yesterday shows nothing until it is
  edited again".)
- bd versions empty listing: drops "yet" and says why the list is empty -- a
  bead created while recording is on always has its create version, so an
  empty list means the bead predates recording (or was made by a writer
  that was not recording), or is no-history or a wisp. The line still
  starts "No versions recorded for <id>", which the switch round-trip test
  pins.
- bd versions with recording off: only beads created after it is turned on
  are versioned.
- bd config set versioned-history.enabled true refusal: Jim's scan stays as
  conservative as he made it -- it cannot see participation, and a legacy
  row can still be minted create-shaped if it re-enters the issues plane --
  but the text now says a listed issue's writes are refused only if it
  participates (created while history was on, or entered the issues plane
  while it was on), and that legacy issues are listed because the check
  cannot tell. The closing line says the same of a value a non-recording
  writer adds later.
- docs/reference/configuration.md: the section opener says every accepted
  change to an issue created while history is on is snapshotted, and that a
  pre-existing issue is legacy; the "participates" parenthetical drops "or
  written" (a write never stamps participation; only a create-shaped mint
  does) and names entering the issues plane, matching the refusal text.

CHANGELOG already says "if it participates in history" and is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(versions): keep updated_at across update-shaped version mints

The update-shaped mint ended with UPDATE issues SET current_revision = ?
WHERE id = ?. current_revision always changes there, so the column's
ON UPDATE CURRENT_TIMESTAMP clause fired: with versioned history on, every
label, dependency or import write moved issues.updated_at to the session's
wall clock (local time, read back as UTC). An import with
RejectStaleUpserts then stored the wall clock instead of the source's
updated_at, and the source's next genuine edit was rejected as stale. The
statement now assigns updated_at to itself, the rule #4298, blocked_state.go's
mark/unmark templates and the create-shaped mint statements already follow,
so history on leaves updated_at exactly where history off does. It is the
one statement every production update-shaped mint ends with.

Tests:
- TestEmbeddedMintLeavesUpdatedAtWhereHistoryOffDoes (embeddeddolt) ages a
  bead, adds and removes a label and a dependency, and runs two
  RejectStaleUpserts imports, with history off first as the control. With
  the fix reverted, history on fails all six arms (updated_at reads the
  wall clock, and the later source edit is rejected as stale); history off
  passes either way.
- RunParticipationGenerationFlagOffSkipsUpdateOnParticipatingRecord, wired
  on the dolt, embeddeddolt, uow and http legs: a record created with the
  flag on and updated with it off mints nothing and keeps its
  current_revision. Every other flag-off case uses a legacy record, which
  the fence stops first, so with RecordVersionInTx's gate removed this is
  the only case that fails, on all four legs. That gate is the single entry
  for every production update-shaped mint, so the one update arm covers
  label and close writes too.
- The sqlmock pin of the statement (version_history_preenable_scan_test.go)
  and the journal-completeness exemption comment follow the new SQL.
- The createbatchequiv issues_updated_at goldens of small, depadd,
  import458 and import458-reject-stale are re-recorded. They pinned the
  wall-clock bump, so each row minted a second time (eq-n2; eq-db1 and
  eq-dl; eq-b3 and eq-b250) had dropped out of the compared set; CI's
  embedded and server legs both printed the new digests. Recorded on
  embedded Dolt, the fix-reverted tree reproduces every committed golden
  byte for byte, HEAD moves only these four digests, and its rows equal
  the history-off rows in every scenario. GoldenDirEnv's comment lists it
  as the goldens' third deliberate change.
- The new embedded test has its line in the storage shard manifest
  (gen_embedded_storage_shard_manifest.py 40 --weights=duration --write),
  so TestStorageEmbeddedShardManifestGeneratorNotStale stays green. It sits
  after TestEmbeddedEveryAcceptedLifecycleMutationMintsOneVersion rather
  than at the end of the file, where #7646 appends its own test, so the two
  PRs still merge without a conflict in that file.

Docs:
- CHANGELOG: the feature's two entries under ### Fixed described fixes to a
  switch no released bd has. One ### Added entry replaces them, covering
  bd versions, the versioned-history.enabled switch and its per-store
  semantics, the pre-enable check, the single-writer caveat, migration 0071
  and the bd version <arg> refusal.
- The bd versions help, its recording-off refusal and empty-listing note,
  and the opening paragraph of the configuration doc's Versioned Issue
  History section now state the rule the pre-enable refusal prints: a bead
  participates if it was created, or entered the issues plane (a wisp
  promoted or made persistent), while recording was on.

bd version: the "did you mean bd versions" refusal now runs after the
command's metrics event is created, like the other in-RunE argument
refusals, so a mistyped bd version <id> is counted as a version invocation
instead of going uncounted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen

---------

Co-authored-by: Jim Wordelman <mayor@quad341.uk>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <338826946+gascity-eddie[bot]@users.noreply.github.com>
2026-10-18 17:28:16 +00:00
gascity-eddie[bot]
8d2b4152f7
fix: commit server-mode config and memory writes (GH#4078, carries #4383) (follow-up to #7299) (#7608)
* feat(storage): add CommitConfigOnly — scoped config-table commit (GH#4078)

Generic Commit() excludes the config table by design (GH#2455) and
CommitWithConfig stages everything via '-Am' — neither can commit an
intentional config write without sweeping concurrent operations' dirty
tables in server mode. CommitConfigOnly stages ONLY config (via the
existing doltAddAndCommit helper) and commits it.

- VersionControl interface method with GH#4078/GH#2455 rationale
- DoltStore: scoped DOLT_ADD('config') + DOLT_COMMIT
- EmbeddedDoltStore: aliases Commit — single-process, so '-Am' cannot
  sweep concurrent work (same rationale as its CommitWithConfig alias)
- Tests against a real dolt-sql-server container: scoped commit lands,
  concurrent dirty issues row survives uncommitted, and generic
  Commit()'s config exclusion is pinned as a regression guard

(cherry picked from commit 61ba8f05c9)
Carry note: rebased onto b1bee123b. The two version_control.go conflicts
were additive (upstream added CommitMergeResolution/CommitAll in the same
spot); resolved by keeping both sides, no change to this commit's code.

* feat(storage): CommitConfigUserKVOnly — screen memory commits to kv.* rows (GH#4078)

Carry reconciliation for the #4383 review: CommitConfigOnly stages the whole
config table, so a memory write's commit in server mode could sweep a
concurrent writer's half-applied internal key (issue_prefix above all), the
row-level form of the GH#2455 hazard. The review asked for #4412's kv.*
screen at the remember/forget sites.

CommitConfigUserKVOnly applies that screen before the scoped commit: if any
dirty config row is outside kv.*, it commits nothing and names the keys,
pointing at `bd dolt commit` (CommitAll), the same remedy the pre-pull
refusal gives. User kv.* rows already dirty are committed with the memory,
as the pre-pull auto-commit would. The screen query moves out of
assertDirtyConfigUserKVOnly into dirtyInternalConfigKeys so both paths share
it; the pre-pull refusal text is unchanged. Embedded aliases Commit, as its
CommitConfigOnly does.

Also softens the CommitConfigOnly interface doc (review nit): embedded mode
commits the whole working set, not only config.

Tests (server container): user kv.* rows commit; a dirty internal key is
refused with HEAD and the working set untouched.

* fix(storage): stage config's lookup-table projections with CommitConfigOnly (GH#4078)

Carry reconciliation for a change on main since #4383 was written:
SetConfig now writes status.custom into custom_statuses and types.custom into
custom_types in the same transaction as the config row (SyncConfigTables),
and reads of those sets are table-first. CommitConfigOnly staged config
alone, so `bd config set status.custom ...` in server mode would commit the
row and leave its projection dirty: HEAD would carry the new string with the
old lookup set, the split the projection exists to prevent. The
transactional SetConfig already marks the synced table dirty for this reason.

CommitConfigOnly now stages config plus issueops.ConfigProjectionTables(),
a list kept next to SyncConfigTables. Clean tables stage nothing, and the
projections are written only from config, so no other kind of work is
swept. CommitConfigUserKVOnly keeps staging config alone: memory rows have
no projection.

Test (server container): status.custom and types.custom writes leave
config, custom_statuses and custom_types all clean after CommitConfigOnly.

* fix(cli): commit config writes in server mode — remember/forget/config set (GH#4078)

In server mode nothing ever commits config-table writes: maybeAutoCommit
skips SQL-server modes entirely, and the explicit flush commands call
Commit(), which excludes config (GH#2455) and silently no-ops on a
config-only working set. Every bd remember / bd config set then strands
the working set dirty and the next 'bd dolt pull' fails with 'cannot
merge with uncommitted changes' until a manual raw-SQL flush.

commitConfigWrite commits the config table immediately after an
intentional config write, scoped via CommitConfigOnly so concurrent
operations' dirty tables are never swept. Server modes only — embedded
'-Am' auto-commit and the unflagged-writes sweep already cover config.
This restores the v1.0.1 always-commit behavior from PR #3052 that the
unified-PostRun refactor regressed.

Wired sites: bd remember, bd forget, bd config set, bd config unset,
bd config set-many (one commit for the whole batch). Commit failures
surface loudly per each site's error convention.

(cherry picked from commit 64f77a1963)
Carry note: rebased onto b1bee123b. config set/unset now write through the
WorkspaceConfig role and remember/forget through the memoryops role, so the
conflict resolution re-anchors each commitConfigWrite call right after that
site's noteDirectConfigWrite/noteDirectMemoryWrite (set-many: after its
direct-route store.SetConfig loop) and uses each RunE's current error
convention (return HandleError / HandleErrorRespectJSON instead of os.Exit).
No change to commitConfigWrite or its tests in this commit.

* fix(cli): reconcile commitConfigWrite with current main (GH#4078)

Carry reconciliation on top of the cherry-picked commit, for two things
that changed on main since #4383 was written:

- Proxied route: proxied mode never opens a store, and its WorkspaceConfig
  and memory roles commit each write inside their own unit of work
  (noteDirectConfigWrite / noteDirectMemoryWrite say so). commitConfigWrite
  now returns early on usesProxiedServer() instead of relying on the nil
  store, and the proxied test asserts the no-op.
- dolt.auto-commit: bd-4wamg made batch/off real deferral in server mode,
  and #5830 made `bd dolt commit` commit config (CommitAll). A config write
  under batch/off now defers with every other server-mode write instead of
  committing regardless; mode on (the default) commits as before. This
  matches embedded mode, where the PersistentPostRun auto-commit honors the
  same setting.

The doc comment drops the stale "-Am auto-commit and unflagged-writes
sweep" wording and says why rename-prefix and migrate are not wired.

* fix(cli): commit remember/forget through the kv.*-screened variant (GH#4078)

Carry reconciliation for the #4383 review: bd remember and bd forget write
user kv.* data, so their server-mode commit now goes through
CommitConfigUserKVOnly via a new commitMemoryWrite helper. A dirty internal
config key from another writer is refused with the keys named and the
`bd dolt commit` remedy, instead of being swept into the memory's commit.
bd config set/unset/set-many keep CommitConfigOnly: the operator is writing
config deliberately there, the same trust level as `bd dolt commit`.

commitConfigWrite and commitMemoryWrite share one guard path
(commitConfigTable), so both no-op on embedded, proxied, and batch/off.

* docs: changelog entries for the GH#4078 config-commit fixes

Server-mode config writes (bd remember/forget, config set/unset/set-many)
now commit immediately via the scoped CommitConfigOnly, and the explicit
'bd dolt commit'/'bd vc commit' are config-inclusive and truthful.

(cherry picked from commit c412b96b96)
Carry note: rebased onto b1bee123b. The hunk's old context now sits in a
released section, so it is moved under [Unreleased] > Fixed. The second
entry (bd dolt commit / bd vc commit) is dropped: that fix landed separately
as #5830 (CommitAll) and is already in the changelog.

* docs(changelog): update the GH#4078 entry for the carried fix

Rewords the cherry-picked entry for what the fix does on today's main:
batch/off defer config writes like every other server-mode write, the
commit stages config's lookup-table projections, remember/forget are
screened to kv.*, and #4412's pre-pull commit now absorbs dirty kv.* rows,
so the pull-side symptom is a refusal on internal keys rather than the
merge error. Drops the #2455 link, which does not resolve in this repo
(the number is a source-comment reference).

* test(cli): pin server-mode config writes leave no config dirt (GH#4078)

User-level regression test for the carried fix, on the direct SQL-server
route against the suite's Dolt server: bd remember, bd config set
(status.custom), bd config set-many (types.custom + status.custom), bd
config unset and bd forget must each leave config, custom_statuses and
custom_types clean in dolt_status. A final step dirties an internal config
key out of band and checks that bd remember refuses, names the key, and
leaves config dirty for bd dolt commit.

On b1bee123b (without the fix) it fails at its first step:
  after bd remember --key gh4078 server-mode memory: config left
  uncommitted in the working set (GH#4078)
With memory writes routed through the unscreened commit, it fails at the
last step: bd remember committed over a dirty internal config key.

* docs(cli): say why config writes skip the kv.* screen (GH#4078)

commitConfigWrite stages every dirty config row, while commitMemoryWrite
refuses internal keys. Record the reason in the code, not only in the
commit history: bd config set/unset/set-many are deliberate config
writes, the same trust level as bd dolt commit.

* build(bazel): list the GH#4078 test files in BUILD srcs

The rows the Bazel / test job's 'BUILD files in sync' check printed at ec27abd1d. Without them the Bazel tiers never run config_commit_write_test.go, config_commit_server_integration_test.go or commit_config_test.go, and the server-Dolt storage tier fails its shard check for the six storage tests.

* fix(storage): say the kv.* write is already saved when the screen refuses (GH#4078)

When CommitConfigUserKVOnly refuses, the memory row's SQL transaction has already committed, so exit 1 read as 'not stored'. The refusal now says the write is in the working set and that bd dolt commit publishes it with those keys.

* fix(httpclient): add the scoped config commits to the no-op commit family

The PR adds CommitConfigOnly and CommitConfigUserKVOnly to
storage.VersionControl. Since the PR's merge base, main added
internal/httpclient, whose Store asserts storage.DoltStorage, so the
tree merged with main did not build (*Store does not implement
storage.DoltStorage: missing method CommitConfigOnly).

Add both methods to httpclient's commit family as no-ops, for that
family's D3 reason: a write over this client is durable once the server
answers, so there is nothing to flush, and refusing would fail a command
whose write already landed. Regenerate unsupported_gen.go: only its
trailer count moves (201 -> 203 methods), because both methods are
hand-written rather than stubbed. Extend the two tests that pin the
family by name, TestCommitFamilyIsNoOp and
TestCommitFamilyIsNotOnTheUnsupportedMap, to cover both methods.

Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Eddie the Engineer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: sms <114885497+seanmartinsmith@users.noreply.github.com>

* fix(config): screen the staged set, warn on refused memory commits (GH#4078)

Review fixes for the adopted PR, iterations 1 and 2.

CommitConfigUserKVOnly screened the working set on one pooled
connection and staged config on another, so an internal key written in
between (issue_prefix above all) was committed with a memory: the
GH#2455 hazard the screen exists to refuse. The screen, DOLT_ADD and
DOLT_COMMIT now share one pinned connection (stageAndCommit), and the
screen runs twice: on the working set before DOLT_ADD, and on what
DOLT_ADD actually staged after it, because sessions on one branch share
the working set. A refusal after staging unstages config again with
DOLT_RESET, so the refused rows are not left staged for the next commit
on the branch. Two residuals are documented at the code: another commit
path's own DOLT_ADD of config landing between the second screen and
DOLT_COMMIT is absorbed, as for every scoped commit, and the table-wide
reset can unstage such a commit's config staging. The refusal is now a
*storage.ConfigCommitRefusedError carrying the keys.

The two config-table commits also stop widening their staging list
with the versioned-history tables: a config write mints no version
rows, and that list's issues table swept concurrent issue work into a
config or memory commit.

bd remember and bd forget exited 1 after their write had landed
whenever a non-kv.* config key was dirty, including keys bd's own
unwired writers leave, such as the issue_prefix of bd rename-prefix.
They now warn on stderr with the keys named and exit 0, as v1.0.1
(#3052) did on a failed memory commit. Under --json they add
committed: false, commit_error and dirty_config_keys, only when the
commit did not happen, so a committed write's payload keeps its shape.
The CHANGELOG entry now says so instead of claiming that the refusal
restores the v1.0.1 behavior.

bd config unset of a yaml-only secret key deleted the credential row an
older bd had stored, but never committed the delete, so HEAD, which
bd dolt push publishes, kept the credential while --json reported
database_row_removed. The delete is now committed like any other config
write. A failed commit is a warning, and database_commit_failed under
--json, because the delete and the YAML unset both landed.

A commit error the store marks storage.ErrCommitIndeterminate, such as
a connection lost during DOLT_COMMIT, may have landed, so neither
surface reports it as a definite non-commit any more. --json adds
commit_indeterminate (remember, forget) or
database_commit_indeterminate (the secret-row unset) beside
committed: false and database_commit_failed, which stay, so a consumer
that reads only those is still told to commit; the secret-row warning
and the note a failed YAML unset carries say the removal may not be
committed and point at bd dolt commit.

commitConfigWrite's doc now says why a failed commit fails the config
verbs while the memory verbs only warn, and names bd kv set/clear and
the kv.memory rows bd import writes as config writes it does not wire
yet. CommitWithConfig's interface doc drops bd config set, which on
the SQL-server route now commits through CommitConfigOnly, and points a
command committing only its own config write at the scoped commits.

Tests: a live-store test writes an internal key between the screen and
DOLT_ADD and requires a refusal that moves no HEAD and leaves nothing
staged; a sqlmock test pins the refusal SQL, including a failed
unstage; a versioned-history-on test requires a dirty issues table to
stay dirty through both scoped commits; cmd/bd fakes pin the
warn-and-succeed contract, the JSON fields, the secret-row commit, and
the indeterminate qualifiers in both payloads and both texts; and the
server E2E gains a secret-row step plus a bd rename-prefix step ahead
of bd remember and bd forget.

Pre-approval CI repair: tools/nogo/unvalidated_integration_tests.txt
now lists the PR's integration-tagged
cmd/bd/config_commit_server_integration_test.go. Since #7486 no nogo
lane analyzes integration-tagged test files, and
TestUnvalidatedIntegrationTestsFileIsExact requires the list to name
every one of them, so the new file failed //scripts:nogo_integration_scan_test
in the Bazel test and integration lanes.

Left for follow-ups, both pre-existing and not changed here: the
review's projection minor (config delete paths do not reconcile
custom_statuses/custom_types), and committing bd kv set/clear and
bd import's kv.memory rows on the SQL-server route.

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: sms <114885497+seanmartinsmith@users.noreply.github.com>

---------

Co-authored-by: Aaron Lippold <lippold@gmail.com>
Co-authored-by: sms <114885497+seanmartinsmith@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
2026-10-16 13:48:30 +00:00
Julian Knutsen
e0a32676ff
test(bazel): pin dolt-int's moved cmd-dolt args/env + omitted-status BEP case (#7536)
PR #7535 review nits (bee-ghosttrack, julianknutsen):

- The -test.timeout=19m arg and BEADS_TEST_REQUIRE_EXCLUDE_PERMISSION env
  var moved off --config=doltserver-cmd onto cmd/bd:bd_dolt_server_test and
  tests/regression:regression_test directly. Nothing pinned either line
  once it lived on the target instead of in .bazelrc, so TestBazelDoltIntCmdDoltTimeoutAndEnvPinned
  now fails if either is dropped or altered on either target.
- classify_tier_results.py already fails closed on a BEP testResult whose
  "status" field is omitted (proto3's NO_STATUS encoding), but no test
  exercised that path through read_test_statuses()/classify() -- only
  tier_result() with a pre-built status set. Add coverage for the real
  shape (an event whose testResult body has no "status" key at all).

Verified against rv7535's mutate.py: E5, E6 and G4 now CAUGHT (previously
SURVIVED on main); the other 38 mutants are unaffected.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-13 09:54:41 +00:00
Julian Knutsen
873162dafa
ci(bazel): dolt-int gates server-storage + cmd-dolt in mode remote (item 5 A2) (#7535)
* ci(bazel): dolt-int gates the server-storage and cmd-dolt tiers in mode remote (item 5 A2)

In mode remote, folds bazel-server-storage (--config=doltserver-integration)
and bazel-cmd-dolt (--config=doltserver-cmd) into one bazel-dolt-int job
(--config=dolt-int), following the dolt-race pattern from #7514. The
members have different gating categories (server-storage plain-gated,
cmd-dolt flag-gated/advisory), so the union carries continue-on-error: true
and a bespoke --label-scoped Shard balance step. All other modes keep the
two lanes running unchanged. Action keys are byte-identical between the
member configs and the union (17 + 46 = 63 TestRunner actions), so cached
results carry over either direction and a revert is a safe rollback.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): dolt-int per-tier results, integration gating, key-parity wording (review)

Coordinator review of #7535 found three must-fixes: integration:"off" was
ignored in remote mode (the union's members already honor it); job-level
continue-on-error made a server-storage-only failure read success on
push/nightly/dispatch, where main stays red; and the PR's key-parity claim
overstated byte-identical actionKeys when only the remote action digest
(not the local actionKey) is unaffected by moving --test_env/--test_arg
onto the targets' own env/args.

Fixes:
- bazel-dolt-int's if now adds `&& inputs.integration != 'off'`, matching
  the members (#7491's review); bazelLaneRunModes and
  TestBazelDoltIntArmsExactlyOnePerMode cover the "off" case.
- Job-level continue-on-error removed; only the `bazel test` step carries
  it, and a new always() "Classify tier results" step
  (tools/bazel/classify_tier_results.py, with its own unit tests and a Go
  wrapper) computes server_storage_result/cmd_dolt_result from the BEP and
  decides job.status per-tier. Confirmed with bazel-gate.sh/ci-gate.sh on
  synthetic empty-output inputs that a dead job still fails the gate.
- Corrected the local-actionKey-vs-remote-digest wording in .bazelrc,
  bazel.yml's job comment and CI_REQUIRED_CHECK_TOPOLOGY.md.
- Should-fix: test step 23->25 / job 58 minutes with reasoning; --label
  coverage added to shard_budget_test.py; stale lane comment fixed in
  tests/regression/BUILD.bazel:46; TestBazelDoltIntSoleRunIsInTheUnion's
  docstring corrected (members bake sole-run's line in directly, never via
  --config=sole-run).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): fail-closed classify, per-tier check_testcases, pinned argv (review)

Final review round for PR #7535 (maintainer-city-c3, bee-ghosttrack,
julianknutsen):

- classify_tier_results.py now fails every tier shut (exit 1) on a
  non-PASSED label outside every --tier list, so a newly tagged target
  added without updating the step's --tier args cannot silently read as
  success (must-fix 1). Its --tier/--check label sets are policy-tied to
  the BUILD files' own tag sets by a new
  TestBazelDoltIntTierLabelsMatchTheTags.
- A missing or non-integer --rc (a timed-out or cancelled test step)
  takes the same fail-everything-shut branch instead of crashing argparse
  with no outputs written (bee-ghosttrack's should-fix 2).
- check_testcases.py gained a repeatable --label flag, and bazel.yml's
  shared "Every target and shard ran tests" step is split into check-ss
  and check-cd, each continue-on-error and folded into its own tier via
  classify's new --check NAME=OUTCOME, so a zero-testcase cmd-dolt shard
  no longer reddens the job on push/nightly (must-fix 2).
- classify's run: argv is now pinned by exact equality
  (bazelDoltIntClassifyRun), and every flag except --tier/--check is
  --StoreOnce; a repeated --tier/--check name or an unrecognized flag is
  now a hard parser error (must-fix 3).
- "Upload test logs" now also fires on steps.test.outcome == 'failure',
  not just failure() (must-fix 4).
- shard_budget.py --label now fails closed (::error, exit 1) on a label
  with no executed shard in the BEP at all, instead of silently reporting
  "no sharded test target executed two or more shards" (should-fix 3,
  carried across both review rounds).
- Updated engdocs/TESTING.md, CI_REQUIRED_CHECK_TOPOLOGY.md, .bazelrc and
  scripts/bazel_dolt_int_test.go/ci_workflow_test.go comments for the
  nits: stale "Advisory (continue-on-error: true)" wording, the
  bazelUnionHasFlagGatedMember comment's stale claim about bazel-dolt-int,
  "byte-identical" without specifying remote action digest vs. local
  actionKey, and "is unset" vs. ci-gate.sh's actual "was skipped" branch
  for an empty union output.

Verified: python3 -I on all four tools/bazel/*_test.py (classify 29,
check_testcases 7, shard_budget 19) green; GOTOOLCHAIN=go1.26.7 go test
./scripts/... green; bazel --nohome_rc test //scripts:scripts_test
--config=ci green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): shard_budget --label fail-closed only on a truly unknown label

The previous commit's fail-closed --label check compared against
read_shard_durations, which only records executed (non-cached) shards, so
a target whose every shard was a cache hit this run had zero entries and
was wrongly treated the same as a --label typo. This was not caught by
the new tests (none exercised an all-cached target) and broke this PR's
own dolt-int CI run: bazel-dolt-int's Shard balance step went red on
//internal/storage/dolt:dolt_server_full_test with "no executed shard for
it", even though that target was correctly, fully cache-hit.

Fix: a new read_tested_labels() reads every label with any testResult
event (cached or executed), and --label's fail-closed check now tests
against that set instead of read_shard_durations. A fully-cached target
still legitimately reports "nothing to judge" through evaluate(); only a
label absent from the BEP altogether is now an error. Added the missing
test row (every shard cached) that would have caught this before push.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(bazel): pin bazel-dolt-int's Upload test logs if-condition

A full 42-mutation re-run for PR #7535's second review round found that
nothing pinned this job's own "Upload test logs" if-condition (must-fix 4):
the other lanes' upload-logs steps are each pinned, but bazel-dolt-int's
(unlike dolt-race, a brand-new job) had no equivalent assertion, so a future
accidental revert to the old failure()-only condition would go uncaught.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-13 09:17:54 +00:00
Julian Knutsen
38c0f24adb
ci: F5 S2 Variant A — nogo ownership for the integration configuration group (#7486)
* ci: F5 S2 Variant A nogo ownership for the integration configuration group

No full Bazel lane validates the integration / doltserver-integration /
doltserver-cmd configurations anymore (all three now pass
--norun_validations). Instead bazel-integration gains a narrow "Nogo:
integration library files" step that keeps full nogo (vet + golangci-lint)
on the configuration's one non-test library package,
//internal/testutil/integration, via
`bazel build --config=integration --@rules_go//go/config:race --keep_going
--output_groups=nogo_fix -- //internal/testutil/integration:integration`.

This accepts a scoped coverage loss (f5-spec.md §3/§5 S2, Variant A): the 56
integration-tagged _test.go files (listed in
tools/nogo/unvalidated_integration_tests.txt, derived from source by the new
T4 test) no longer get a vet pass in any lane, since golangci-lint already
skips all _test.go files repo-wide (.golangci.yml's run.tests: false) and no
lane builds those test binaries with validations on. Verified directly with
real `bazel build` runs: a planted vet finding in the library package still
fails the new step; the same finding in an integration-tagged _test.go file
no longer fails anything; a planted finding in a plain race-configuration
library still fails bazel-test; and GoCompilePkg action keys for the
integration configuration are identical with and without
--norun_validations (it is a build-request option, not a configuration
flag, so no farm cache invalidation).

scripts/nogo_lint_policy_test.go: the nogoConfigurations table gains a
"integ" row with an ownerIsNogoOnlyStep flag and a dedicated
checkNogoOnlyStepRow, generalizing T1/T2/T5/T6 to cover an owner that is a
narrow build step rather than a full lane; adds T4
(TestNogoIntegrationStepCoversItsConfiguration), which derives the step's
expected target set from source via go/build's own tag matching instead of
a hardcoded list.

Also fixes four should-fix items from julianknutsen's review of #7482:
1. expandBazelrcConfig now follows `common:` lines and --config= tokens
   anywhere on a line, not just a first-position `build:`/`test:` one.
2. TestNogoRaceOwnerBuildsEverything now expands every config the owner job
   can reach (including shell-variable-gated ones like sole-run), not just
   the statically-named "ci".
3. The package-gate check now compares full key-flag fingerprints instead
   of substring-matching --@rules_go//go/config:race / --norun_validations.
4. tools/bazel/nogo_ownership.py now fails loudly (exit 2) when both the
   owner's and non-owners' action-key sets are empty, instead of reporting
   a vacuous pass.

Each fix has new mutation-test coverage in TestNogoPolicyRejectsMutations
(should-fixes 1-3) or nogo_ownership_test.py (should-fix 4).

engdocs/LINTING.md and engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md updated to
remove the stale "integration still validates in all three lanes" claim and
document the Variant A trade-off.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(ci): make T4's source scan work under Bazel, not just plain go test

scripts:scripts_test only declares //:repo_other_files as data (every
tracked file but Go and Markdown source, by design: a Go-only change
should not re-run the CI/workflow policy tests). TestNogoIntegrationStep
CoversItsConfiguration's source scan needs every non-test .go file, so
under `bazel test //scripts:scripts_test` its runfiles tree had none and
the scan always came back empty.

Fixes:
- scripts/BUILD.bazel: add //:repo_go_srcs to scripts_test's data, with a
  comment explaining why (this is the one test in the target that needs it).
- integrationOnlyLibraryPackages: use bazelPolicyRoot(t) + repoFiles(t, ...)
  (the existing Bazel-safe, runfiles-aware file listing other policy tests
  in this package already use) instead of sourceRepoRoot(t) +
  filepath.WalkDir, which only sees what //scripts's own go_test target
  declares.

Verified with real `bazel test --config=integration --@rules_go//go/config:race`
and `--config=ci --@rules_go//go/config:race` runs of //scripts:scripts_test
(both pass); CI caught the original gap (PR #7486's first push failed
Bazel / integration and Bazel / test with exactly this).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): address independent review + bee-ghosttrack findings on F5 S2 Variant A

Independent review of #7486, must-fixes 1-7: pipefail on the nogo-only
step's tee pipeline; exact source-scan equality check for
tools/nogo/unvalidated_integration_tests.txt; expandBazelrcConfig
follows common:-lines and non-first-position --config= tokens in both
the Go policy test and nogo_ownership.py; mirrored
nogo_ownership.py should-fix guarding against a non-owner action-key
query silently matching nothing.

Cost fix: split T4/T6's whole-repo .go source scan into its own
go_test target (//scripts:nogo_integration_scan_test) so a Go-only
change no longer re-runs all of scripts_test; extracted the shared
bazelInvocations and ciWorkflow helpers into helper-only files so
both targets can depend on them without violating the
one-target-per-test-file partition rule.

bee-ghosttrack review: checkNogoOnlyStepRow's own fingerprint now
excludes test:-sourced .bazelrc lines pulled in via --config=X
(buildOrCommonLines), since the nogo-only step is a `bazel build`
invocation that never reads a test: line; added mutation s2i
reproducing the gap this closes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(nogo): pin integration nogo-only step's target, fingerprint its lane, add behavioral test

Addresses the remaining should-fixes from the independent review of #7486:

1. TestNogoIntegrationStepScriptFailsWithoutMaskingBazelsExitCode
   (scripts/nogo_integration_step_script_test.go) extracts the real
   "Nogo: integration library files" step script from bazel.yml and runs it
   under plain `bash -e` (GitHub's actual run: semantics, no pipefail added)
   against a stub bazel, closing the gap a text-only pin can't: it catches
   rc=0 before `exit "$rc"`, `|| :`/`|| true` on the tee pipeline, or a
   missing/negated `set -o pipefail`, regardless of how the mutation is
   spelled.

2. The nogo-only step's target set is now pinned by exact go_library
   label, not just package: nogo_integration_scan_test.go derives the
   label(s) from source + BUILD.bazel and nogo_lint_policy_test.go pins
   them literally (its own go_test target has no //:repo_go_srcs). Both
   reject a `-//` exclusion pattern outright.

3. checkNonOwnerCommandLineAddsNoKeyFlag is now also applied to the
   integ row's owner's own full lane: under Variant A that lane validates
   nothing, so it is effectively a non-owner for this check's purpose, and
   must not override a key-affecting flag on its command line either.

4. Latent items: TestNoUnconditionalValidationOff now also scans
   .github/actions/setup-bazel/write-bazelrc.sh for run_validations (every
   line it emits lacks a :config suffix, so any occurrence would turn
   validation off everywhere with no owner lane to catch it).
   tools/bazel/nogo_ownership.py's docstring is corrected: it had said S2
   was simply "out of scope," which is now stale since S2 has its own
   validating lane (the nogo-only step, checked statically); the script's
   dynamic aquery-based cross-check remains S1-only because S2's owner has
   no non-owner test lane building the same configuration to compare
   actions against.

Skipped (not cheap / not reachable):
- bazel-server-storage's `if:` not modeling an "integration" input: no such
  input exists to model; the gate is RBE-enabled-only by design, and
  resolving this requires understanding pr.yml's broader gating semantics,
  not a textual fix.
- defaults.run.shell parsing: bazel.yml has no `defaults:` block today
  (confirmed by grep), so there is nothing to parse; the gap is latent only
  for a future change, not a live bug.
- race-off scan's future-wrong-fix edge case: the review itself
  characterizes this as not reachable with today's file set.

New mutation cases s2j/s2k/s2l in TestNogoPolicyRejectsMutations cover
items 2 and 3. All mutation-verifications performed by hand-editing the
real files, confirming FAIL, and reverting via Edit (never git
stash/checkout).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-10 23:19:16 +00:00
Julian Knutsen
76d5bf61ef
ci: harden F5 S1 nogo ownership checks (follow-up to #7479) (#7482)
* test(nogo): reject F5 S1 ownership mutations the policy tests missed

Follow-up to #7479's independent review.

- nogoKeyFlags parses whole tokens instead of a prefix regex, so
  --@rules_go//go/config:race=false on a non-owner no longer fingerprints
  as the owner's race build (1f).
- The owner's run_validations check expands every --config its bazel
  commands select (including BAZEL_SOLE_RUN/BAZEL_FRESH) recursively, so
  e.g. `test:sole-run --config=doltserver` is caught (1e).
- T3 scans every argument of the owner's `bazel test`, including
  backslash-continued lines, for negative target patterns (1g).
- T1 pairs each non-owner job with the --config its own bazel command
  selects instead of by list index (2).
- TestNogoPolicyRejectsMutations feeds T1/T3/T5/T6 each mutation 1a-1g
  and 2 and requires a rejection.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(bazel): nogo_ownership.py compares nogo actions by action key

Owner and non-owner nogo coverage was compared by target label, which
treats one label compiled in two configurations as covered. Compare
RunNogo and ValidateNogo actions by Bazel action key instead. Non-owner
universes drop manual-tagged tests (bazel test //... never builds them)
and add //cmd/bd:bd_for_tests, the package gates' target. The
fingerprint mirrors nogoKeyFlags' whole-token parsing.

nogo_ownership_test.py covers this with a fake bazel.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(ci): correct nogo lane-sharing and one-required-lane claims

- CI_REQUIRED_CHECK_TOPOLOGY.md: only the nogoConfigurations rows
  (race, pure, js/wasm) validate in exactly one required lane; the
  integration configuration still validates in its three required lanes
  until F5 S2.
- .bazelrc: --norun_validations lanes share compile, link and nogo
  actions with `test`, not test PASS results (each lane's test actions
  have their own env and args). Comment only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 19:54:13 +00:00
Julian Knutsen
b8e6ba1791
fix(bazel): one nogo-validating lane per race configuration (F5 S1) (#7479)
* fix(bazel): one nogo-validating lane per race configuration (F5 S1)

The race configuration (--@rules_go//go/config:race) is built by five
lanes that duplicate the same RunNogo/ValidateNogo work: bazel-test
(--config=ci), bazel-embedded, bazel-doltserver, bazel-proxied, and
the advisory bazel-dolt-race shadow, plus the package-mcp/package-npm
gates' explicit race build. --norun_validations is a build-request
option, not a configuration flag (proven here by aquery: GoCompilePkg/
GoLink/RunNogo/ValidateNogo action keys are byte-identical with and
without it), so passing it on every lane but bazel-test removes the
duplicate work without touching a single action key or dropping any
lint coverage: bazel-test's --config=ci already validates every file
any of the others compiles.

scripts/nogo_lint_policy_test.go replaces the old blanket
"--norun_validations never appears in .bazelrc" check with
TestNogoConfigurationsHaveOneValidatingLane (T1: one owner per
configuration fingerprint), TestNogoOwnersAreRequired (T2: the owner
is a required CI Gate check whose `if:` covers every non-owner's),
TestNogoRaceOwnerBuildsEverything (T3: the owner builds //... whole,
no exclusions) and TestNoUnconditionalValidationOff (T5: nothing else
may disable validation). tools/bazel/nogo_ownership.py (make
nogo-ownership) is a dynamic, advisory aquery cross-check of the same
property, run on demand rather than from inside a Bazel action.

Verified locally: aquery shows identical action keys for the affected
lanes with/without --norun_validations; a planted printf-format vet
finding in internal/idgen/hash.go failed the owner build and passed
the non-owner build (then reverted, never committed);
scripts/bazel_dolt_race_shadow_test.go and the full //scripts suite
stay green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): close S1 nogo-ownership review gaps (allowlist, owner pin, real aquery)

Addresses maintainer-city-c3's review of #7479:

1. T6 TestRunValidationsOnlyOnAllowlistedLines replaces the coverage gap
   left when main's blanket run_validations ban was dropped: only the four
   race-group non-owners' "test:<cfg> --norun_validations" lines in
   .bazelrc, and the two package-gate bazel-build steps in bazel.yml, are
   permitted. A later test:integration/doltserver-cmd --norun_validations
   (out of T1's table, S2) now fails here instead of landing silently.
   Verified by mutation: adding test:integration --norun_validations fails
   the new test; reverting passes.

3. TestNogoRaceOwnerBuildsEverything (T3) now also pins that the race
   owner's "bazel test //... --config=ci" step has no step-level if: or
   continue-on-error, and that its job has none either. Verified by
   mutation: adding if: ${{ always() }} to that step fails; reverting
   passes.

2. tools/bazel/nogo_ownership.py's aquery comparison was querying the
   identical mnemonic("RunNogo", //...) for the owner and every non-owner,
   so `missing` could never be non-empty. It now derives each non-owner's
   actual built target set the way --build_tests_only + --test_tag_filters
   does: the deps closure of tests(//...) filtered to targets carrying one
   of the lane's tags, read exactly from `query --output=xml` (not attr()'s
   substring regex match, which would wrongly fold "dolt-server-proxied"
   and "dolt-server-cmd" into a "dolt-server" filter). Confirmed against a
   real (offline, --nohome_rc) bazel run: reports OK at head, and reports
   100+ missing targets when the owner's query is artificially narrowed to
   a subpackage -- it can now actually fail.

Also: refreshed a stale .bazelrc comment claiming nogo runs beside every
lane's compile, which S1 made untrue for race-group non-owners.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-10 18:05:17 +00:00
Julian Knutsen
a945619b5e
fix(bazel): re-vendor the BEP test-timing clamp from gascity (extractor 1.1.1) (#7477)
#7374 re-vendored gascity's signed-duration fix for exec-log spawns, but
build_tests() still kept the sign of BEP testResult timings. rbe-west
scheduler/worker clock skew makes a remotely executed test report
queueTime -1 ms (-24 ms at worst), and the collector rejected the whole
artifact on tests[].results[].queue_ms: about 19% of beads artifacts,
holding 52% of beads' CI worker time.

Byte copy of gascity 2ddde0d94be15d95086cc2bcb169303ea1243456: clamp
duration_ms and every timingBreakdown child with _clamp_duration_ms.
Updates the two sha256 pins; testdata/ci_analytics is unchanged.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 16:20:37 +00:00
Julian Knutsen
8dbbe78e9a
feat(backend/http): public HTTP backend door, OSS registration, and bd connect (S6) (#7288)
* feat(backend/http): add the public HTTP backend door, cmd/bd registration, and bd connect

internal/httpclient (S1-S5) had no production caller for the per-open
backends.OpenOptions.Credential seam and no way for a workspace to actually
select it. This slice (S6) closes both gaps in OSS's own idiom, without
carrying over anything from bd-enterprise's gateway/box-login/storage-profile
machinery:

- backend/http (bdhttp) is the public, out-of-tree extension door: Register
  adds "http" to the backend registry and installs its transport, Open/
  Handshake dial a server directly with no workspace on disk, and the
  registered OpenWith hook threads a per-call credential through
  beads.OpenBestAvailableWith for a multi-tenant embedder.
- internal/httpclient/open_with.go is the backends.Backend.OpenWith hook
  itself: a fresh dial per open (opts.Credential/HTTPClient/UserAgent),
  distinct from the process-wide registered dialer Open/OpenReadOnly use.
- cmd/bd/http_backend.go registers the backend for the OSS binary, so a
  workspace whose metadata.json names "http" opens through the ordinary
  OpenBestAvailable path; any other unregistered backend name still refuses.
- cmd/bd/connect.go adds the minimal `bd connect <url>` command: a handshake
  that must succeed before anything is written, a per-user activation
  sidecar (.beads/http_target.json, never git-tracked), a plaintext-to-
  non-loopback refusal without --allow-plaintext, and a backend-switch
  refusal without --force. No credential is ever accepted on the command
  line or written to disk.
- cmd/bd/doctor/gitignore.go requires the new http_target.json /
  http_local_metadata.json sidecars be git-ignored, the same way the
  proxied-server client info already is.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(storage): keep external-dependency blocking over http unless the server enforces it

bd ready / bd close / claim hard-failed against the new http backend with
"GetAllDependencyRecords not supported by the http backend": cmd/bd's
storage chain wraps every opened store in the externaldeps policy
decorator, which needs either the narrow ExternalDependencyQueryStore
interface or the broad GetAllDependencyRecords fallback to resolve
blocking state, and the http client implemented neither.

The decorator now stays on for a remote store. It is skipped only when the
server's handshake advertises policy.external_dependencies (the server
enforces the policy before answering). Without that capability the client
resolves blocking itself from the listing and chunked dependency reads, so
an issue with an unresolvable external: dependency stays out of bd ready
exactly as it does on a local backend; it is never silently skipped
(DESIGN 3.6). Server-side enforcement is slice S10.

storage.RemoteBackendStore marks a DoltStorage that is a pure network
client of a remote bd serve; the http backend's Store satisfies it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(cmd/bd): suppress the CreatedBy stamp on create against a remote backend

bd create failed against the http backend with "Issue.CreatedBy: ... is not
expressible on the v0 wire": the http client's create role deliberately
refuses any POPULATED CreatedBy/CreatedAt (the creation stamp belongs to the
server's own journal entry, not a value the caller supplies), but
cmd/bd/create.go unconditionally stamped getActorWithGit() onto every
created issue regardless of backend. The refusal only fires on a non-zero
field, so suppressing the stamp for a registered remote backend is wire-
compatible by construction, not a workaround.

Add isRemoteBackendWorkspace()/creationActorStamp() to backend_support.go,
reusing the existing resolveCommandBeadsDir(dbPath) +
backendNameForErrorFraming(beadsDir) + backends.IsRemote(name) pattern
already used elsewhere in that file, and use creationActorStamp() at both
create.go call sites (the dry-run preview and the real create).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(backend/http): add an embedder linkage test over public packages only

Prove the one promise S6 makes to an out-of-tree embedder (gc is the
motivating case): importing nothing but github.com/steveyegge/beads,
.../backend, and .../backend/http is enough to register the http backend,
open a workspace through it with a per-call credential
(beads.OpenBestAvailableWith), and read through the role-accessor surface
(IssueReader().Ready) against a stand-in server — with no internal/...
import in the test file, which is itself the thing under test.

Written fresh for OSS beads S6; no bd-enterprise source copied.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs: document the HTTP backend, bd connect, and the public backend/http door

Add a README section with bd connect usage, the credential ladder, and the
plaintext/force refusals, plus a CHANGELOG entry for the new cmd/bd
registration, bd connect command, and the public backend/http package.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): address bee-ghosttrack review on #7288 (connect --clear restore, persisted --allow-plaintext)

Closes the CHANGES_REQUESTED items on the HTTP backend door PR:

- Must-fix: `bd connect --force` over a workspace with its own local
  (dolt) identity now has writes succeed instead of tripping "workspace
  identity mismatch detected" — validateWorkspaceIdentity (cmd/bd/main.go)
  and the sidecar (internal/httpclient/metadata.go) now compare against
  the http backend's own pinned project id. New e2e regression test
  TestE2E_ForceConnectWritesSucceedDespiteDifferingLocalProjectID
  (backend/http/e2e_cli_test.go), confirmed to fail without the fix.

- Should-fix 1: `bd connect --clear` now restores metadata.json's
  backend selection to whatever it was before this workspace connected,
  instead of leaving it pinned to "http" with no sidecar to dial.
  Target.PreviousBackend (internal/httpclient/target.go) is recorded by
  Attach (backend/http/attach.go) and round-tripped through the sidecar;
  connect.go reads it back on --clear. New tests in
  backend/http/attach_test.go and internal/httpclient/target_test.go.

- Should-fix 2: `bd connect --allow-plaintext` is now remembered in the
  sidecar (Target.AllowInsecureCredential), scoped to the target it was
  granted for, so every later ordinary command's dial honors the grant
  without also needing BEADS_HTTP_ALLOW_INSECURE=1 set
  (internal/httpclient/dial.go). Fixed BearerProvider.warnInsecure's
  wording (internal/httpclient/credential.go), which used to assert a
  token was being sent immediately above a refusal saying the opposite.
  New test TestDialWithWiresTargetAllowInsecureCredentialThroughToTheGuard.

- Should-fix 3: README no longer claims HTTP mode works "exactly as
  with a local database" — it lists what round-trips and points at the
  divergence ledger (engdocs/design/http-divergence-ledger.md) for what
  differs.

- Verified, no code change needed: Attach already handles an existing
  metadata.json project_id coherently (only cfg.Backend is touched); bd
  show's isNotFoundErr already matches a http 404 (issueops.ErrNotFound
  is storage.ErrNotFound, the same sentinel a local miss uses), so it
  reads as "not found" rather than an unsupported-operation error.

- Doc fix: guardInsecureCredential's doc comment and refusal message
  were stale against should-fix 2's own change — they named only
  DialOptions.AllowInsecureCredential and the env var as ways to get
  past the guard, not the newly-persisted target.AllowInsecureCredential
  or `bd connect --allow-plaintext` itself.

Gates run clean on this branch: go build/vet, go test over
internal/httpclient, backend/http (including the full e2e suite under
BEADS_TEST_EMBEDDED_DOLT=1) and cmd/bd, make api-check, make
ci-pr-lint, make bazel-sync-check, bazel run //:gazelle -- -mode=diff,
and internal/storage's TestEveryLegWiresEveryRoleContract.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(backend/http): give the e2e server the BatchGetter role #7248 added to the required set

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: exact http ready totals, connect capability row, doc corrections

Ready totals over http (review major). externaldeps drops externally
blocked rows client-side for a store that cannot express ExcludeIDs
(today httpclient.Store). dropBlockedIssuesWithCounts compacted the
fetched rows in place (`kept := rows[:0]`), and
readyWorkWithCountsAndTotal then re-scanned `rows` to count the blocked
rows it had dropped. By then the compaction had overwritten them, so
whenever a blocked row came back ahead of a kept one the re-scan
undercounted the drops: `bd ready --json`'s total and text-mode `bd
ready`'s count (CountReadyWork) overstated ready work against any server
that does not advertise policy.external_dependencies. Both drop helpers
now copy into a fresh slice, and dropBlockedIssuesWithCounts reports how
many rows it dropped, so nothing re-scans `rows`.

fakeStore gains an excludeIDsUnsupported switch that, like
httpclient.Store, refuses any ExcludeIDs. The new
TestReadyTotalsWhenStoreCannotExpressExcludeIDs puts the blocked issue
first and checks the page and total for an unlimited filter, a Limit
whose bumped window holds the whole set, and one the set outgrows, then
CountReadyWork. TestServedReadyExcludesUnsatisfiedExternalDependencyWithoutServerCapability
now also checks the total and count against a real in-process bd serve.
Against the previous decorator the unit test's unlimited case reports
total and count 3 beside a 2-row page, and the served test 2 beside a
1-row page.

Review minors, all wording:
- `bd connect --clear` pointed at `bd config set backend dolt`, which
  writes the database's config table rather than metadata.json and, in
  the state that prints the advice (metadata.json says http, sidecar
  gone), fails the pre-open identity check. It now says to reconnect, or
  to set "backend" in metadata.json.
- CHANGELOG described the superseded skip-at-wrap design; it now
  describes the always-wrap decorator with its capability probe and
  client-side drop.
- RemoteBackendStore's docs no longer name a consumer; nothing in-tree
  checks it.
- creationActorStamp's comment pointed at backend/http/lifecycle.go; the
  refusal lives in internal/httpclient/lifecycle.go.

Capability row. TestProxyCapabilityRegistryCoversCommandTree fails at
60b7128204: the command tree walk finds `connect`, which this PR adds,
with no row in cmd/bd/capability_registry.go ("1 command(s) have no
proxied-server capability row: connect"). The test predates the PR
(#6582 is an ancestor of its base) and passes at the base dabf20ef07.

connect opts out of store init (skipStoreAnnotation) and never reaches
the store factory, so it belongs in proxyPermittedPaths beside init and
setup. The row is runtime-neutral: validateProxyRegistryBeforeProvider
returns nil both for a permitted row and for a path with no row, so
this only records the policy decision the coverage test asks for.

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>

* docs(httpclient): regenerate the divergence ledger doc after the S5 rebase

The rebase onto feat/http-client-batch-apply's rebased head (S3/S4 merged to
main) left the ledger doc's summary line at a conflict-resolution placeholder
count. Regenerate it from internal/httpclient/encode.Ledger() so
TestDivergenceLedgerDocMatchesLedger passes against the merged ledger.go.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(backend/http): host-scope S6's test BEADS_HTTP_TOKEN values

Rebasing onto feat/http-client-batch-apply's rebased head pulled in main's
#7247 review-fix round, which made BEADS_HTTP_TOKEN/BEADS_HTTP_TOKEN_COMMAND
host-scoped (host[:port]=value, scopedEnvValue/parseScopedEnv in
internal/httpclient/credential.go) after S6's own tests were written against
the unscoped form. Five S6 tests across backend/http/open_test.go,
backend/http/register_test.go and
internal/httpclient/insecure_credential_guard_test.go set a bare token and
now hit the new ladder's "an unscoped token would be used for whatever
server..." refusal. Scope each to the test server's actual host
(127.0.0.1 for the httptest.Server-backed recording servers,
nonLoopbackTestHost for the insecure-credential-guard integration tests)
so they exercise the same ladder rung as before.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* build(bazel): resync go_srcs/repo_files for the new backend/http and test/embedder packages

make bazel-sync-check failed after the rebase: tools/bazel/go_srcs.py's
managed repo_files filegroups for backend/http and test/embedder (new in
this slice) hadn't been generated, and the root BUILD.bazel / tools/bazel's
release_cross_build target list hadn't picked up the new package either.
Regenerate with `python3 tools/bazel/go_srcs.py`; `bazel run //:gazelle --
-mode=diff` reports no further drift.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(cmd/bd): route swarm's create paths through creationActorStamp after main's currentActor change

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: police http's served roles, refuse close --claim-next, exact totals

External-dependency policy over http (review blocker). cmd/bd wraps
every store, http included, in the externaldeps decorator, and its role
accessors rebuilt each role over legacy methods httpclient.Store refuses
(SearchIssuesWithCounts, GetDependencyTree, ClaimReadyIssue, IsBlocked,
GetDependencyRecordsForIssues, BatchCloserWithPolicy). Over http `bd
list`, `bd dep tree`, `bd ready --claim` and a policed `bd close`
therefore exited 1, even in a workspace with no external dependency.
Over a store that reports storage.RemoteBackendStore, each accessor now
starts from the inner store's served role and layers the policy around
it (remote_roles.go):

- IssueReader serves List and Get from the served reader; Ready and a
  ready-flagged List go through the policy reader.
- IssueClaimer refuses an externally blocked claim before the served
  one.
- ReadyClaimer uses the served claim-next while no issue, closed ones
  included, holds an unsatisfied external ref. Otherwise it claims down
  the policy's filtered ready page through the served Claimer, because
  claimNext cannot exclude ids.
- BlockingAnnotator and TreeWalker merge external blockers into, or add
  external leaves to, the served answer. They read only the named
  issues' edges through the served EdgeReader, 100 anchors per call.
- BatchCloser refuses externally blocked open items and sends the rest
  to the served closer as one request. --force keeps the base path, and
  a next claim is refused whole (below).

RemoteBackendStore now only chooses this composition. Whether the policy
runs is still ServerEnforcesExternalDependencyPolicy's answer (design
3.6), and the storage and httpclient docs say so. remote_roles_test.go
drives each role over a store that refuses the legacy methods.
TestServedRolesKeepTheExternalDependencyPolicy runs every role over a
real http server. TestE2E_BDOverHTTP adds `bd list` (JSON, text and
--deps), `bd dep tree`, `bd ready`, `bd list --ready`, `bd ready
--claim`, a refused `bd close --claim-next`, and a refused then forced
close of an externally blocked issue. At the fixup before the
composition, the role tests then written (bar one pin of the next-claim
refusal, since replaced) and the e2e's list, dep tree, claim and close
steps of that round were red.

Close with a next claim over http (review major). batchCloseIssues has
no member for a next claim, so httpclient refuses any ClaimNext before
the dial (ledger W-CloseBatchRequest.ClaimNext). Over http `bd close
--claim-next` therefore always exited 1 and closed nothing. With an
external ref anywhere in the workspace (a closed holder or --force
included) the decorator's base path failed first, with an opaque
`BatchCloserWithPolicy` unsupported. remoteBatchCloser now refuses a
next claim whole, before it reads or closes anything, and the error
says nothing closed: close without --claim-next, then run `bd ready
--claim`. A request that is invalid on every backend is still
ErrValidation first, and a server that enforces the policy itself gets
the request unchanged.

Composing close-then-claim was not taken. The role closes and claims in
one transaction and answers with an error or with outcomes, never both,
so a claim that failed after the closes committed could not report
them; httpclient refuses the same request for that reason. A CLI-level
close then claim that can report a partial result is the follow-up.
The review also suggested leaving closed holders out of the blocking
state. They stay in, as on every backend: a closed issue is never a
claim candidate, so they change no claim, and leaving them out would
cost a status read per holder because the wire has no batch read.

TestRemoteBatchCloserRefusesANextClaim covers an open holder, a closed
one, none, --force, and a server that enforces the policy; with the
previous remote_roles.go the first four are red.
TestRemoteBatchCloserValidatesANextClaimFirst keeps ErrValidation ahead
of the refusal. Dropping the filter check, or loading the blocking
state before refusing, is each caught. TestE2E_BDOverHTTP runs `bd
close --claim-next` while the holder is open and again after it is
closed; with the previous remote_roles.go both steps are red and print
`operation "BatchCloserWithPolicy" not supported`. Ledger F-close no
longer says --claim-next is served, and no longer names a
renderEscapedHTTPRefusal that does not exist. L14 says the decorator's
claim leg applies while any issue, closed or not, holds an unsatisfied
ref. The README and CHANGELOG mention the refusal, and the decorator's
IsBlocked, IsBlockedBatch and CloseIssueChecked say they refuse over a
store that serves its roles.

Ready totals with external blockers (review majors, both rounds).
CountReadyWork asks for Limit=0, and readyWorkWithCountsAndTotal took
any Limit<=0 to mean "the window held the whole ready set". Over http a
zero limit never reaches the wire: the server answers with its default
page (workapi.DefaultReadyLimit, 100 rows) while the bridge reports the
full total, so past 100 ready issues text-mode `bd ready` kept counting
externally blocked issues beyond the first page. Exactness is now judged
from the rows that came back (total <= len(rows)). A window that holds
only part of the set no longer subtracts every externally blocked id in
the workspace either: that set includes closed issues and ones the
filter excludes, none of them in the total, so the count came out low.
It refetches the filtered ready set, ids only, and subtracts the blocked
rows in it; the old bound is left as the fallback for a refetch that
comes back truncated too.

fakeStore gains the bridge's shape: a defaultPage for a zero Limit,
with GetReadyWorkWithCountsAndTotal still totalling the whole set.
TestReadyTotalsWhenAnUnlimitedFetchComesBackAsOnePage (a blocked issue
past the first page) and
TestReadyTotalsIgnoreExternallyBlockedIssuesOutsideTheReadySet (a
blocked issue outside the ready set) have served counterparts,
TestServedReadyCountExcludesAnExternallyBlockedIssuePastTheDefaultPage
and TestServedReadyTotalIgnoresAnExternallyBlockedIssueOutsideTheFilter
(an assignee filter). The first pair is red on the Limit<=0
condition, the second on the subtract-every-blocked-id branch.

Docs: ledger L8 now says which decorator paths take the chunked
GetAllDependencyRecords scan and which read only named edges, and L14
records the decorator's composed claim leg; http-divergence-ledger.md
is regenerated. The README names the verified commands, and the README
and CHANGELOG say how cross-repo dependencies behave over http.

Minors from the reviews:

- Drop creationActorStamp/isRemoteBackendWorkspace and restore the base
  stamps at all 11 sites. The arm guarded a refusal the http create
  role does not make: since #7247 (actorStampedCreateMember) it accepts
  a CreatedBy naming the actor. Because the arm keyed on the CWD
  workspace, a create routed from an http workspace into a local one
  (--repo) stored an empty created_by. TestE2E_BDOverHTTP checks
  created_by for a direct and a routed create; the routed check is red
  with the arm restored. The CHANGELOG sentence describing the arm goes
  with it.
- bdhttp.Attach decides a reconnect from the raw metadata.json backend.
  GetBackend() reads an unregistered "http" as the dolt default, so in
  an embedder that never called Register a reconnect recorded dolt as
  the backend --clear restores. The reconnect test now seeds postgres
  (TestAttachOnAReconnectKeepsTheEarlierPreviousBackend) and is red
  with the old check.
- README, CHANGELOG and `bd connect --help` document the host-scoped
  BEADS_HTTP_TOKEN=host[:port]=<token> form (and _COMMAND), and say why
  a bare value is refused.
- bdhttp.Attach also gitignores http_local_metadata.json, the per-user
  file the store writes on first use, so an embedder activating through
  Attach alone gets the coverage `bd connect` already had.
  TestAttachGitignoresBothPerUserFiles pins it.
- ServerSnapshot.WireRevision's doc names the handshake's actual check
  instead of a comparison `bd connect` never makes.

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>

* test(backend/http): give the e2e server the LeaseReclaimer role #7412 added to the required set

main's #7412 made LeaseReclaimer part of httpapi's required role set and
updated main's own binders, but backend/http's e2eServeConfig predates it,
so every TestE2E_* that binds the in-process server failed with
"httpapi: no database source". Same shape as e63f7da36a for BatchGetter.

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

* fix(externaldeps): lead the --claim-next refusal with the wire fact; pin the L14 leg and connect --clear

Review i4 minors/nits on the stranded fixup, carried as a separate commit:

- remoteBatchCloser's --claim-next refusal now says the served batch close
  cannot carry a next claim (the real cause), rather than blaming
  externally blocked work a workspace may not have. The test asserts the
  reason, that nothing closed, and the remedy.
- GetDependencyTree's doc says a served store refuses its reads and that
  bd dep tree goes through remoteTreeWalker.
- README no longer gives `bd ready --claim` local semantics everywhere; it
  names when ledger row L14's two-step claim applies.
- TestE2E_BDOverHTTP claims once more after the external-ref holder is
  closed, pinning L14's composed leg (a mutant whose composed leg claims
  nothing turns only that step red).
- New TestE2E_ConnectClearRestoresThePreviousBackend: --clear restores
  the prior dolt backend with its identity intact, removes the sidecar,
  and a second --clear changes nothing.

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

* test(backend/http): run the served e2e under bazel

//backend/http:http_test declared no bd binary, so under bazel the e2e
files (bazeltest.PrebuiltBD) failed on BEADS_TEST_BD_BINARY with
BEADS_HTTP_TEST_REQUIRED=1 and only "passed" by skipping otherwise. It now
takes //cmd/bd:bd_for_tests (visibility added), size large / timeout long:
the served cases run 4-5 minutes on the farm under BEADS_TEST_EMBEDDED_DOLT=1.

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

* test(backend/http): run the e2e tier in the embedded lane as http_served_test

The previous commit gives //backend/http:http_test the bd binary, but no
lane sets BEADS_TEST_EMBEDDED_DOLT for it, so its TestE2E_* cases still
skipped in CI. http_served_test runs the same test binary through
//tools/bazel:go_test_variant.sh with BEADS_TEST_EMBEDDED_DOLT=1 and
BEADS_HTTP_TEST_REQUIRED=1 (a skip fails it). It is tagged embedded, so
the --config=embedded lane runs it and prcore/ci keep their current
shape, the same split as //internal/httpclient:httpclient_served_test.
Under plain --config=embedded all 8 TestE2E_* cases run, none skipped.

TestBazelRetiredLanesCannotBeNarrowed pins every embedded-lane target's
args and env; the new target is added to that pin list.

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

* fix(externaldeps): cap the ready rows kept, not the bumped http window

An http store cannot carry ExcludeIDs on listReadyWork, so readyExclusion
fetches the unfiltered ready set, widened by len(blocked) under a limit,
and drops the externally blocked rows client-side. The http ready bridge
enforced MaxRows on the rows it fetched rather than the rows kept. So
`bd ready --limit N --max-rows N` exited 2 whenever more than N issues
were ready and any workspace issue held an unsatisfied external blocker
(a closed one counts), even with no blocked row in the window, and a
blocked row in the page counted against the cap although the caller
never sees it. Locally neither can happen: issueops enforces the cap on
the filtered page it delivers, after the Limit trim
(finishReadyWorkWithCounts).

The client-side path now takes MaxRows off the inner query and enforces
the caller's cap on the rows it keeps, after the trim, in all three
listings. The inner query keeps the cap whenever nothing is dropped
client-side. MaxRows never rode the wire, so the fetch is the size it
was; refetchedReadyTotal already clears the cap on its own over-fetch.

TestServedReadyMaxRowsCountsTheRowsKept runs the decorator over a served
http store holding three free issues and one externally blocked one: a
cap equal to the limit, a cap under a wider limit, an unlimited listing,
and a kept page wider than the cap, which must still return
ErrTooManyRows with the caller's cap and source. Each case runs through
GetReadyWork, GetReadyWorkWithCounts and GetReadyWorkWithCountsAndTotal.
Leaving the cap on the inner query fails the first three cases in all
three methods, dropping the re-applied cap fails the fourth, and
enforcing it before the Limit trim fails the first.

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>
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.com>
2026-10-10 07:19:18 +00:00
Julian Knutsen
b3cdbf9e46
ci(rbe): auto-PR a worker-env pin sync when gascity main re-pins (mc-gv9fk) (#7455)
rbe-west's pool workers advertise gastownhall/gascity main's worker-env
pin; when gascity re-pins (a Go/dolt/OS bump, e.g. #7387) beads' copy
falls out of step and every remote-execution run stops in bazel.yml's
preflight until a human notices and copies the fix by hand (#7419 took
~100 minutes). This adds a scheduled workflow (every 15 minutes, plus
workflow_dispatch) that runs tools/rbe/worker-env-sync against gascity
main, and on a real mismatch (exit 1) copies the manifest and pin with
the new tools/rbe/worker-env-sync-copy, opens/updates a PR on a fixed
branch with status/needs-review-auto, and arms auto-merge.

GitHub never runs checks on a PR a plain GITHUB_TOKEN opens, so this
needs a GitHub App token -- but gastownhall-autofix (contents:write on
this repo) cannot open or label a PR. Two Apps split the two write
roles instead: gastownhall-autofix mints push-token (contents:write
only) and does the git push of bot/worker-env-sync via plain git;
gascity-autofix (pull-requests:write only) mints pr-token and does
everything PR-shaped -- create/update, the label, and arming
auto-merge -- via gh. peter-evans/create-pull-request takes one token
for the whole flow, so it can't honor this split; plain git and gh
replace it. Every ${{ }} is resolved into a step's env: first, never
written inside a run: script.

Both Apps' id/private-key secrets live in the same autofix environment,
gated by its deployment-branch policy to main; schedule and
workflow_dispatch are never fork events, so neither key is ever
readable by a fork.

Needs admin setup: the gascity-autofix App (id 5259233) installed on
gastownhall/beads (and gascity) with pull-requests:write and metadata
read, and its GASCITY_AUTOFIX_APP_ID / GASCITY_AUTOFIX_APP_PRIVATE_KEY
secrets added to the autofix environment alongside the existing
AUTOFIX_APP_ID / AUTOFIX_APP_PRIVATE_KEY.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-10 05:58:24 +00:00
Julian Knutsen
f53010a23b
ci(bazel): remote repo contents cache: main-push seed, lane readers, nightly verify (#7453)
Port gascity's remote repo contents cache wiring (gascity #7467, #7478) to
bazel.yml, gated on the repository variable RBE_REPO_CONTENTS_CACHE
(unset/off: nothing; seed: rrc-seed on push to main; canary: + bazel-test
reads; on: + every test lane reads). Mode remote only.

- rbe job: an rrc step turns the variable into the rrc output.
- Readers: the eight test lanes append startup
  --experimental_remote_repo_contents_cache and common
  --loading_phase_threads=64 to .bazelrc.local before Set up Bazel.
- rrc-seed (push to main, id-token: write): a 30-minute
  rbe-rrc-writer-beads certificate from rbe-west's mint
  (.github/scripts/rrc-writer-credential.sh), then every lane's command
  (.github/scripts/rrc-lane-commands.txt) with --nobuild, --remote_cache
  only and --remote_upload_local_results (.github/scripts/rrc-run-lanes.sh).
- rrc-verify (schedule/dispatch, issues: write): cold fetch of every lane
  and tools/bazel/rrc_verify.py against the cache; a mismatch opens an
  rrc-verify issue.
- pr.yml, nightly.yml and bazel-farm.yml grant id-token: write and
  issues: write on their bazel.yml call (startup_failure otherwise);
  TestBazelWorkflowCallersGrantEveryRequestedPermission guards it.

rrc-writer-credential.sh, rrc_verify.py and rrc_verify_test.py are byte
copies of gascity's, pinned by sha256.

Refs ga-vnycm2.29.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-10 02:50:26 +00:00
Bee
ff4f46e137
fix(bazel): go_test_pinned_shard.sh runs under bash 3.2 (macOS Main red since #7413) (#7423)
The pinned-shard wrapper kept a `declare -A shard_of` map whose only use was
the "pinned twice" check. Apple's /bin/bash is 3.2, which has no associative
arrays, so on the main workflow's macOS Test job scripts/pinned_shards_test.go
(which runs the wrapper through the host `bash`) failed every sharded case
with `declare: -A: invalid option` (exit 2). The job has been red on every
main push since #7413 landed (runs 37890739870, 37900573128, 37902968742);
the Bazel lanes run the wrapper on Linux bash 5 and never saw it.

The check is now a membership test on the "|"-joined `all` string, which the
manifest's name pattern (^Test[A-Za-z0-9_]*$) keeps free of "|". Nothing
else changes: the pinned-twice refusal still fires
(TestPinnedShardWrapperRejectsBadManifests/test_pinned_twice).

Verified: go test -run TestPinnedShard ./scripts with PATH limited to
/usr/bin:/bin (bash 3.2.57): 5 PASS; the whole ./scripts package under
bash 5.3: ok; shellcheck -s bash and `/bin/bash -n` clean.

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 02:00:02 +00:00
Julian Knutsen
0d865460b1
ci(bazel): split the slow embedded cmd tests and run the cmd block as 2x50 shards (#7438)
//cmd/bd:bd_embedded_test was the embedded lane's floor: at Bazel's 50-shard
cap per rule, each shard's wall time was its slowest top-level test, and
~40 tests ran 65-130s on rbe-west.

- 34 slow TestEmbedded* functions are split into 89 smaller top-level
  functions. Subtests and table cases are moved verbatim: no assertion,
  flag or data changes, the same t.Run set per file, the same skip guard and
  t.Parallel. Subtests that read state earlier ones left stay together, in
  order; each new function repeats the shared setup it needs.
- The manifest's cmd/bd block is now 100 shards, run by two targets:
  bd_embedded_test (shards 1-50) and the new bd_embedded_part2_test
  (51-100), through go_test_manifest_shard.sh --shard-offset/--shard-total.
  check_shard_coverage.py takes SHARDS@OFFSET/TOTAL and fails unless the
  targets' ranges tile the block exactly once, so every test runs in exactly
  one shard of one target; the policy tests read both rules' ranges from
  cmd/bd/BUILD.bazel.
- Durations re-measured on rbe-west with the split tests and repacked. The
  frozen legacy 20-shard block drops the renamed names (no workflow reads
  it; new names hash-distribute as before).

Not split: the *Concurrent stress tests (their bd subprocesses queue on the
workspace's single writer lock: TestEmbeddedUpdateConcurrent is ~100
serialized bd commands), TestEmbeddedPurgeWispsPlaneRetention (one stateful
sequence), and the MaxRowsList* tests (setup is 21 sequential creates every
subtest reads).

rbe-west, both targets, --nocache_test_results: slowest shard 138-163s ->
109s (TestEmbeddedUpdateConcurrent alone; every other shard <=86s), median
80-84s -> 40s, shard-seconds 4.1-4.4k -> 4.2k, critical path 213-306s ->
113s.

Bead: ga-vnycm2.17

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 20:30:52 +00:00
Julian Knutsen
a13272b024
ci(bazel): serve gazelle's go_repository tools from the repository cache (#7417)
* ci(bazel): serve gazelle's go_repository tools from the repository cache

Every bazel.yml lane starts from a fresh output base, and before any go_deps
repository can be fetched gazelle compiles fetch_repo and gazelle with
`go build` in @bazel_gazelle_go_repository_tools: 18-24 s of every 2 vCPU
lane's loading phase (the top ci-analytics repo_fetch entry in the
embedded, proxied, cmd-dolt and test lanes).

tools/bazel/go_repository_tools.bzl replaces that repository (override_repo
on gazelle's non_module_deps extension). The build is reproducible, so the
three binaries are pinned by sha256 per gazelle release, Go SDK and host.
The rule asks the repository cache for the pinned digests first (Bazel
re-hashes every hit, so a restored runner cache can only yield the pinned
bytes); on a miss it builds exactly as gazelle does, inside env -i, and
stores a matching build in the repository cache. An unpinned or stale
combination still builds from source and prints the digests to pin.
scripts/bazel_go_repository_tools_test.go keeps the pins in step with
MODULE.bazel's gazelle and go_sdk versions. The runner cache key already
includes MODULE.bazel, so the first push to main after this saves them.

Analysis-only (--nobuild) per lane on Blacksmith 2 vCPU, main vs this change
with a seeded runner cache (ga-vnycm2.8): test 54.0 -> 38.3 s, embedded
53.6 -> 31.1 s, integration 49.6 -> 35.2 s, doltserver 48.5 -> 33.0 s,
proxied 46.6 -> 31.6 s, server-storage 33.5 -> 17.3 s, cmd-dolt 50.3 -> 33.0 s.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): pin gazelle's go_repository tools for Go 1.26.9 too

Ready for the next go_sdk bump (gascity#7387 moves to 1.26.9 for the
2026-10-08 advisories): the same binaries keep coming from the repository
cache instead of failing the pin test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 07:57:01 +00:00
Julian Knutsen
ce582394fe
build(rbe): re-pin worker-env to gascity's go1.26.9 worker host (#7411)
gastownhall/gascity bumps Go to 1.26.9 for the 2026-10-08 stdlib
advisories (GO-2026-6599..6617). The shared rbe-west pool workers install
the Go named in gascity main's go.mod, so once that merges they advertise
a new worker-env. This is the byte-for-byte copy of gascity's
tools/rbe/worker-env.txt and its pin (tools/rbe/worker-env-sync); merge it
together with the gascity change or beads' remote actions stop scheduling.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 07:38:56 +00:00
Julian Knutsen
5a5b7cfd66
ci(bazel): pin the slowest cmd/bd Dolt-server tests to their own shards (#7413)
* ci(bazel): pin the slowest cmd/bd Dolt-server tests to their own shards

The cmd-dolt lane's wall time when its tests re-run is the bd_test race
compile plus its slowest shard. rules_go shards round-robin by test index,
so whichever shard drew TestSharedServerConcurrent and the TestInit*
family ran 117-170s while the median shard ran ~55s.

tools/bazel/go_test_pinned_shard.sh runs a go_test binary with the tests a
committed manifest pins (measured >= 5s, bin-packed longest-first by
tools/bazel/pin_shards.py) in shards of their own, and every other test in
the binary's own round-robin shards with the pinned set skipped, so each
test still runs exactly once and new tests need no manifest edit.
bd_dolt_server_test goes from 16 to 32 shards (16 pinned + 16 round-robin),
regression_test from 8 to 16 (10 + 6; its go_test becomes the manual
regression_suite binary behind an sh_test of the old name).

Pinning exposed a pre-existing order dependence: TestCLI_Import failed
whenever it was the binary's first test, because runBDInProcess reused the
workspace discovery an earlier in-process execution cached and `bd init` in
a fresh directory resolved the previous one's .beads. The in-process
runners now reset beads/git discovery caches per execution.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): pin cmd/bd Dolt-server shards from two measured runs; regression in 14 shards

The bd manifest now takes each test's slowest of the 16- and 32-shard runs
(pin_shards.py over both), and regression_test drops to 10 pinned + 4
round-robin shards: its unpinned tests total ~128s, so 6 round-robin
shards were mostly fixed cost.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(scripts): place the pinned-shard tests by what they read (#7414 split)

The manifest-name scan reads every cmd/bd and tests/regression _test.go
file, so it moves to go_test_sources_test (with tests/regression's
manifest); the wrapper, generator and wiring checks stay in scripts_test.
Shared helpers live in a helpers-only file both targets compile, and
repoFiles takes #7414's minimum-file count.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 05:50:09 +00:00
Julian Knutsen
d90823480a
ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files (#7414)
* ci(bazel): split //scripts:scripts_test by what it reads; partition //:repo_files

//scripts:scripts_test declared //:repo_files (the whole checkout), so every
PR re-ran it, and it took ~181s on rbe-west. Most of that (60-79s) was
TestBazelGatedLanesNeverRetryFlakyTests line-regexping the --run_under
wrapper's pinned dolt binary (tools/bazel/hermetic_bin/dolt, in every
test's runfiles); it now skips binary files, as git grep -I does.

tools/bazel/go_srcs.py's per-package repo_files block now partitions each
package's files into repo_go_srcs, repo_go_test_srcs, repo_doc_files and
repo_other_files, aggregated at the root; //:repo_files is their union
(same 4679 files). The //scripts tests are split into go_test targets by
what they read (traced per test with strace over a runfiles-shaped tree):

  scripts_test          CI/Bazel policy: //:repo_other_files (+1 Go file)
  shell_scripts_test    script fixtures: //scripts files, a few root files
  go_test_sources_test  _test.go scans: //:repo_go_test_srcs + shard files
  go_sources_test       check-testing-short.sh: every .go file
  tracked_files_test    every tracked file: //:repo_files

Shared helpers move to helpers-only files; TestScriptsTestTargetsPartition-
TheTests fails on a test file in no target or in two. //test/docsync and
the //scripts/repochecks slices declare partitions or single files instead
of //:repo_files where they can.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): skip only the non-checkout hermetic_bin dir in the flaky-retry walk

Skipping every binary file also stopped scanning tracked binaries (images,
.binpb fixtures). Skip just tools/bazel/hermetic_bin, the --run_under
wrapper's runfiles directory, which is not in the checkout, so the walk's
coverage of tracked files is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-09 05:13:07 +00:00
Julian Knutsen
6d21d337ad
feat(httpclient): OSS HTTP client store and roles + a served http conformance leg (contributed from bd-enterprise under MIT) (#7247)
* feat(httpclient): lift the HTTP client store and roles from bd-enterprise (MIT contribution)

Contributed by gascity from bd-enterprise (github.com/gascity/bd-enterprise,
internal/enterprise/httpstore @ 49d1df2f6) to OSS beads under the MIT
license, with the owner's explicit approval. Every lifted file carries a
provenance header naming its source path.

Lifted into internal/httpclient: the Store (DoltStorage over the wire), the
dial/register glue, the read roles (reader, querier, counters, edges,
relations, graph, tree, cycles, stats, config, memories, journal), the write
roles (lifecycle, claimer, releaser, deleter, dependency editor, metadata
CAS, commenter, batch closer/creator/applier, ready claimer, sweeper), and
their tests. The store transport seam (WireClient/WireDialer) and the
store-dependent tests deferred from the S2 lift are restored here.

Not lifted: the hosted gateway (httpgw/gwauth), box-login, storage profiles
and gasworks. dial.go only mentions the gateway in comments.

This commit is the mechanical lift and does NOT build yet. It references
enterprise-only APIs absent from OSS: issueops.ReadyLister,
journalops.Watcher, storage.ServerEnforcedPolicy, the
NonCommitGraphBackend/RemoteWorkspaceBackend markers, DoltStorage
differences, and BatchCloseRequest.claim_next. The following commits
reconcile it with OSS (S3/S4/S5).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(httpclient): reconcile the bd-enterprise lift's compile-time API surface against OSS

The mechanical lift (02a9dad17) carried several bd-enterprise-only shapes
that do not exist in OSS beads:

- ReadyLister, journalops.Watcher/StreamWire, and ServerEnforcedPolicy have
  no OSS wire counterpart; drop the role, its served/journal-watch tests,
  and the policy enforcement path entirely rather than leave dead code that
  cannot compile against OSS's apigen types.
- claim_hook_gate_test.go exercised a hook surface OSS does not publish.
- recordingWire/fakeWire no longer embed a StreamWire double now that no
  read role can reach a watch stream; testTarget's two conflicting
  package-scope declarations (store_test.go and helpers_test.go) are split
  apart as pinnedProjectTarget vs. the generic helper.
- unsupported_gen.go is regenerated from scratch against OSS's actual
  storage.DoltStorage via a new, from-scratch reflection-based generator
  (internal/storage/unsupportedgen) rather than hand-copied from
  bd-enterprise's generated output; completeness_test.go's
  legitimatelyUnsupported map grows the handful of OSS-only or
  previously-missed methods (AddRemoteWithRef, RenameLabel, etc.) this
  regeneration surfaces.
- write_ledger_test.go and the divergence ledger doc gain the
  force_notes_overwrite and claim pending rows OSS's apigen.UpdateRequest
  and SweepRequest actually carry, and drop the Remaining/LiveDependent
  assertions SweepResult/SweepSkips have no wire member to ever populate.

go build ./... and go vet ./... are clean after this change. No behavior
beyond the removed surfaces changes here; read-role and write-role
reconciliation land in follow-up commits.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): stop sending listIssues a reverse/sort vocabulary OSS does not publish

The bd-enterprise lift's sortedPage pushdown assumed GET /v0/beads/issues
(listIssues) shared the same sort vocabulary and a reverse parameter with
GET /v0/beads/issues:query (handleQueryIssues) -- a different operation.
OSS's openapi.v0.yaml publishes listIssues a CLOSED two-value `sort` enum
(created, priority; deliberately smaller than the nine values :query
takes) and no `reverse` parameter at all. Sending either would earn an
unknown-parameter or invalid_value refusal from the real server, not a
silently-wrong answer -- which is why this only surfaces against a served
backend, not a Go-side unit test of the request builder.

Add listSortPushdownEligible to gate the pushdown fast path to the two
keyset orders listIssues can actually page, unconditionally refusing any
reversed request (listIssues has no parameter that names a reversed
direction, so a reversed request of any order walks and sorts
client-side). Drop the unconditional `reverse` send from sortedPage.

served_list_test.go's three affected cases encoded the wrong,
enterprise-only wire shape (expecting reverse=false on the fallback path,
expecting a reversed order to push down with sort+reverse, and expecting a
Go-side/SQL-side mix in listIssues' sort enum); corrected to match OSS's
actual, provable wire contract rather than left red. list_sort_test.go's
publishedParamEnum helper now reads the OpenAPI document via the
go:embed'd spec.OpenAPIV0() accessor instead of a relative os.ReadFile, so
it no longer depends on the test's working directory (this also fixes the
same test failing under Bazel's sandbox, which does not expose arbitrary
relative-path files).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): reconcile write-role tests against OSS's BatchClose/Update shapes

OSS's apigen.BatchCloseRequest and BatchCloseResponse publish no
claim_next/claimed_next member at all (ledger row
W-CloseBatchRequest.ClaimNext) -- bd-enterprise's claim-folded-into-close
shape has no OSS wire counterpart. Replace the three tests that exercised
decoding a served claim (TestBatchCloseRefusesAServedClaimCarryingNoIssue,
TestBatchCloseRefusesAServedClaimTheRequestNeverEarned,
TestBatchCloseKeepsTheClaimItEarned) with
TestBatchCloseRefusesClaimNextUnconditionally, which pins the actual OSS
behavior: a CloseBatchRequest naming ClaimNext refuses before any dial, on
both the unserved and served legs, regardless of what a server would
otherwise answer. Drop the now-dead "claim-next" case and helper claim
variable from TestBatchCloseServesTheSingleItemShapeAndRefusesTheRest.

Also:
- Add the ForceNotesOverwrite case to
  TestUpdateRefusesEveryMemberTheWireExcludes's hand-maintained member
  map -- a ledgered-pending UpdateRequest member (see
  W-UpdateRequest.ForceNotesOverwrite) the lift's test left uncovered.
- Remove write_roles_test.go's duplicate `ptr[T]` generic helper, which
  redeclared the one already in helpers_test.go and never compiled.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(conformance): pin post-write RowVersion propagation across Update/Close/Reopen

types.Issue.RowVersion is json:"-", so an implementation that forgot to
populate it on the way back from storage would still compile and still
pass every existing content assertion in lifecycle_close_reopen_contract.go
-- none of them read RowVersion. Add
RunLifecycleResultsCarryThePostWriteRowVersion, which chains each write's
result token into the next write's ExpectedVersion (Update -> Close ->
Reopen) with no intervening read, so a dropped or stale token fails closed
on the next write's optimistic-concurrency guard rather than passing
silently.

Register it in role_bundle_cases.go's roleContractCases dispatch table at
its declaration-order position -- TestRoleContractCasesCoverEveryContractCase
was failing because the function existed with no dispatcher entry.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* chore(bazel): sync BUILD files via gazelle for the S3 reconciliation

bazel run //:gazelle after the compile/read-role/write-role reconciliation
commits:

- internal/httpclient/BUILD.bazel: regenerate srcs/deps for the files
  added, removed and newly imported above (drops the deleted
  policy/journal-watch/readylister files, adds the spec dep for
  list_sort_test.go's embedded OpenAPI read). Manually add
  `data = glob(["*.go"])` to the go_test rule, matching the idiom already
  used by //internal/httpclient/encode: completeness_test.go and
  divergence_citation_gate_test.go read their own package's .go sources at
  runtime (a regex scan of unsupported_gen.go and an AST walk of the
  package directory), and Bazel's go_test sandbox only copies in files a
  rule declares as `data` -- `srcs` are compiled away, not left readable.
  A `# keep` directive protects the attribute across future gazelle runs
  (confirmed gazelle does not manage `data` on this rule).
- internal/storage/BUILD.bazel,
  internal/storage/unsupportedgen/BUILD.bazel: pick up the new
  from-scratch unsupportedgen generator package.

bazel test //internal/httpclient/... //backend/conformance/... now passes
all 4 targets (previously 4 of the package's tests failed only under
Bazel's sandbox: TestInterfaceCompleteness,
TestTheCountGroupVocabularyMatchesTheSharedOne,
TestFlaglessListSortIsTheSameOrderNamed,
TestDivergenceParkCitationsResolveToLiveLedgerRows).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(conformance): close two pre-existing leg-wiring gaps found while registering http

- RunLifecycleResultsCarryThePostWriteRowVersion (added in 536561124) was
  never wired into dolt/embeddeddolt/uow's own lifecycle_close_reopen test
  tables, only into the http leg's. TestEveryLegWiresEveryRoleContract
  catches this once a fourth leg forces the test to actually run again;
  wire the missing t.Run into all three.
- The three StatsReporter "suppressed rows" cases (GateIssues/TemplateIssues
  breakdown) were never added to served_graph_aux_test.go even though the
  wire already carries both fields end-to-end (types.Statistics is shared
  verbatim by apigen.StatsResponse and the client's decode). Wire them; all
  three pass over HTTP with no server or client change needed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* feat(conformance): register the http leg in the role-contract lock

Registers "http" (wiringRoot internal/httpclient) in contractLegRegistry.
The served-surface harness (served_harness_test.go + 16 served_*_test.go
files) already wired 495 of 576 role-contract entrypoints from the
bd-enterprise lift; this change:

- Waives the 3 RunCycleDetectorIncludeTracks* cases: issueops.
  DetectCyclesRequest.IncludeTracks has no plumbing on either side of the
  wire today (cycles.go always calls DetectCycles with a zero-value
  request; the client's DetectCycles ignores its request parameter). No
  slice through S13 adds one, so the waiver says a new slice is needed
  rather than pointing at an existing one.
- Sets adoptionCeiling: 75 for the remaining, not-yet-wired write-role and
  internal-plumbing entrypoints (lifecycle writes, DependencyEditor,
  MetadataCAS, Lease, Sweeper, VersionReconciler, Bootstrapper/
  InitVerifier, cross-record invariants) that S4 and later write slices
  pick up and ratchet down.
- Adds //internal/httpclient:go_srcs to storage_test's data: the leg's
  wiring root lives outside internal/storage, and the Bazel sandbox has no
  other reason to materialize those sources for a test that reads them at
  runtime.

TestEveryLegWiresEveryRoleContract, TestEveryRoleMethodHasAContractCase,
and RunUnsupportedContract (already wired pre-lift in
internal/httpclient/completeness_test.go) all pass for the http leg.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): close review's HIGH 2-5 gaps and reconcile their test doubles

HIGH 2 (BatchCloser), HIGH 3 (created_by stamping, absent-parent 404/400,
force_notes_overwrite carriage) and HIGH 4 (CapabilityError now unwraps to a
typed *storage.ErrUnsupported with Capability) were implemented in prior
commits on this branch; this change finishes HIGH 5 and the verification the
review asked for:

- role_reader.go's Reader.Get and bridge.go's raw GetIssue both now stitch
  Revision back onto Issue.RowVersion via parseRevision, so a guarded write
  built off either read carries the row's real token instead of a decoded
  zero. Both are pinned by round-trip served tests that guard a write with
  the read's token and require a stale-token replay to refuse.
- Fixed create_test.go's stale assertion that created_by must stay empty
  (contradicted the HIGH 3 stamping fix it predated).
- Fixed recordingWire's canned IssueDetails{} response (roles_test.go): it
  omitted Revision, which is a required field on every getIssue response
  per the OpenAPI spec, and the HIGH 5 stitch now reads it unconditionally.
- Synced internal/httpclient/wire/BUILD.bazel via gazelle: handshake_test.go's
  new internal/storage import had no corresponding dep.
- gofmt'd write_roles_test.go's stubWire struct tags.

Verified: served HTTP conformance tier (BEADS_TEST_EMBEDDED_DOLT=1
BEADS_HTTP_TEST_REQUIRED=1 go test ./internal/httpclient/, -timeout=40m)
600 PASS / 0 FAIL / 72 SKIP (all ledgered known-divergence waivers). One
TLS-handshake-timing test failed in that run and passed 3/3 in isolation
(unrelated file, pre-existing flake under machine load, not reproducible).
Also green: default go test (minus the pre-existing, unrelated
TestEngdocsAndRootMarkdownLinks doc-link drift and the environmental
internal/storage/uow dolt-server-spawn hang), bazel build/test for the
touched packages, make api-check, and gofmt/vet.

Live-mutated and reverted 3 guards to confirm their tests are load-bearing:
role_reader.go's RowVersion stitch, bridge.go's RowVersion stitch, and
lifecycle.go's force_notes_overwrite wiring.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* feat(ci): add served HTTP conformance as Tier 3 of the conformance gate

The served tier (internal/httpclient's served_*_test.go corpus) never ran
in CI, so HIGH 2-5's regressions (and any future ones) would merge
undetected. Add it as Tier 3 of scripts/conformance.sh, the existing
required entrypoint conformance.yml already runs on every PR/push/merge_group
(not a new workflow, not wired through ci-gate.sh's aggregation -- this
repo's convention for this gate is a single standalone job):

  CGO_ENABLED=1 BEADS_TEST_EMBEDDED_DOLT=1 BEADS_HTTP_TEST_REQUIRED=1 \
    go test -timeout=40m ./internal/httpclient/

Left unsharded: Tier 1 and Tier 2 are themselves single unsharded
invocations, and Tier 3 is one Go package, not a multi-package corpus the
repo's existing package-sharding scripts apply to. No Bazel-lane addition:
bazel-coverage's embedded/dolt_server outputs only ever substitute for
main.yml/pr-risk.yml jobs, never for conformance.yml's own job, so there is
no existing Bazel-lane relationship for this gate to extend.

Bumped the job's timeout-minutes 45 -> 100 (30m + 10m + 40m budgeted
sub-timeouts plus checkout/setup-go overhead) and updated the three policy
tests that pin this script/workflow byte-for-byte
(TestConformanceScriptUsesExplicitTimeoutBudgets,
TestConformanceScriptPropagatesGoTestFailures,
TestConformanceWorkflowHasOuterTimeoutBudget), re-included
internal/httpclient/** in both path filters (push and pull_request, kept
identical) since served_*_test.go files are the suite itself and would
otherwise be excluded by the shared !**_test.go negation, and documented the
new filter entry in ci_f7c_advisory_test.go's own-entries map.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): root-cause and fix the Happy-Eyeballs TLS flake in store_dependent_test.go

TestTransportForSucceedsWithEnvCAFile (and 3 Handshake-based siblings that
assert on a successful dial through a configured CA: SidecarCAFile,
CAFileEnvAgreeingWithSidecarSucceeds, DialWithNilTransportHTTPClientGetsCAInjectedOnACopy)
flaked once with "tls: first record does not look like a TLS handshake".

Root cause: our code, same class S2 already fixed for TransportFor's direct
callers (forceIPv4Loopback in ca_test.go/ca_wrong_ca_test.go). Every server
these tests dial is addressed by hostname "localhost" (ca.startServer
rewrites it there deliberately, so SNI is actually sent), which Go's
default dialer races a tcp6 dial to ::1:<port> against the real tcp4 dial to
127.0.0.1:<port> for (RFC 6555). An unrelated local process already bound to
a colliding ephemeral port on ::1 can occasionally win that race before the
real dial completes, and the client speaks TLS to that unrelated process
instead -- the misleading handshake error, not a real hang or a product bug.

These four tests go through Handshake with DialOptions{} (HTTPClient left
nil deliberately, since that is itself the nil-HTTPClient branch of DialWith
under test), so they never get a *http.Transport back to mutate the way
forceIPv4Loopback's existing callers do. Fixed via warmIPv4OnlyCATransport:
pre-build the target's CA-scoped transport through the same public
TransportFor the product code itself calls (so it lands in the exact
(path, content)-keyed cache transportForFile's cache hit returns), force
tcp4-only on that cached pointer, and let Handshake's own DialWith run
unchanged -- same branch under test, same cached transport, no sleeps, no
retries. Verified with -race -count=50 on all four: 200/200 pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): refuse DetectCycles(IncludeTracks=true) instead of silently ignoring it

roles_graph.go's httpCycleDetector.DetectCycles took its request as `_`,
forwarding nothing: a caller asking for the widened (tracks-following) walk
silently got the narrower default walk back with no error. listDependencyCycles
has no include_tracks wire parameter at all, so there is no way to honor the
field — only to refuse it loudly or drop it silently. Switch to the typed,
ledger-cited refusal (encode.RefusedError via refuse(), citing new row
"L-cycles-tracks") that CountEdges' own wire bound already uses, add the
ledger row and its Op, regenerate the auto-generated ledger doc, and pin the
behavior with a unit test (no served-tier case needed: the refusal is
pre-dial by design, same reasoning as the existing edge-count bound pin).

Also fix leg_contract_wiring_test.go's cycleTracksWireGapWaiverReason, which
had gone stale: it described the http leg as silently forwarding nothing for
this field, which was true before this change and is not after. The waiver
itself (the three RunCycleDetectorIncludeTracks* contract cases stay unwired
for the http leg) is unaffected — they were never wired, and still are not —
only the reason text needed updating to describe a typed refusal instead of a
silent ignore.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(storage): name the http leg's permanent contract gaps instead of budgeting them

The http leg's role-contract adoption ceiling (internal/storage/contract_leg_registry_test.go)
sat at a flat 75, with a prose "adopting" note that bundled every skip into
one vague bucket — including MetadataCAS, which is in fact fully wired (0
missing cases), a false claim left over from an earlier wiring pass.

Twenty-six of the 75 skips are not S4-and-later work at all: they are
PERMANENT gaps that no future slice closes, because the contract itself has
no publicops role for an HTTP client to route through:

  - Importer (4 cases): uow is Importer's one accessor, same precedent the
    dolt and embeddeddolt legs already carry (importerOneAccessorWaiverReason).
  - RetentionFixture/EpochFixture (15 cases) and CrossRecordInvariantFixture
    (7 cases): both fixtures carry raw storage hooks (Resolve, Erase, Mint,
    CurrentEpoch, GuardedWrite, EnforceCrossRecordInvariant, ...) with no
    publicops field at all. dolt, embeddeddolt and uow wire these because
    they ARE the storage engine this address/epoch/retention and
    cross-record transaction bookkeeping belongs to; the http leg is a
    remote client with none of its own to report. There is no wire surface
    for this to ever route through short of a new role being designed from
    scratch — a new slice, not a missing test line.

These 26 are now named, reasoned waivers in unwiredContractEntrypoints
(two new reason constants: retentionEpochNoRoleWaiverReason and
crossRecordInvariantNoRoleWaiverReason), and the ceiling drops from 75 to 49
to match. The "adopting" note is rewritten to correctly name every remaining
category under budget (lifecycle writes, DependencyEditor, DualWrite,
Sweeper, VersionReconciler, Bootstrapper/InitVerifier, ExpectedRevision/
Refusal) and to drop the false MetadataCAS claim.

Also documents, at conformanceEntrypointsWiredBy, why a leg wiring a
conformance.RunX reference with every hook left nil would read as "adopted"
by this lock's static source grep while actually running as a skip —
matching the loophole internal/httpclient's divergence_citation_gate_test.go
already closes for skipKnownDivergence call sites. No leg currently does
this (verified by inspection); the note sets the review expectation for
future wiring rather than papering over the gap with no record of the policy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(licensing): scrub internal program/org naming and a leaked private ID from OSS-visible text

MEDIUM 8 of the S3 ship review: remove licensing-hygiene leaks found by a
read-only repo-wide survey, while leaving every legitimate "Contributed by
gascity from bd-enterprise ... to OSS beads under the MIT license." provenance
header and every genuine public gascity/gastownhall self-reference (the real
OSS org, beads.gascity.com docs domain, RBE infra) untouched:

- Delete release-gates/ga-7psli2-3-1-baseline-cmd-bd-fix-gate.md: the only
  file in release-gates/ keyed by a private `ga-` tracker ID instead of the
  directory's established public `be-` convention (30 other files), and the
  only one leaking internal filesystem paths (/home/jaword/...,
  gc-management/.gc/artifacts) and internal routing terms (mayor/mpr,
  "deployer session"). Not referenced from anywhere else in the tree.
- .golangci.yml: drop two private `ga-2ltro.12`/`ga-26w10` history citations
  used as nolint-comment justifications; reworded to the same explanatory
  content without naming a private tracker ID.
- Reword 19 "gc native-program" occurrences (14 files, comments and one
  design doc) to drop the internal program name while keeping the "S3
  reconciliation (2026-10)" dating they were attached to.
- cmd/bd/if_revision.go, if_revision_test.go, update.go,
  update_proxied_server.go: drop literal citations of gascity's private
  bdstore_conditional.go classifier (including a test function name,
  TestIfRevisionEnvelopeGascityContract -> ...DownstreamContract) while
  keeping the substantive explanation of why this envelope's shape is
  load-bearing for a downstream consumer.
- internal/httpclient/lifecycle.go: drop a citation of gascity's private
  internal/beads/bdstore.go.
- internal/httpclient/dial.go: drop the internal/enterprise/httpgw package
  path, keeping "a gateway dialer outside this repo".
- internal/httpclient/register.go: reword away from naming "the enterprise
  distribution" while keeping the build-tag-opt-in behavior it documents.

Verified: go build ./..., go vet ./internal/httpclient/... ./cmd/bd/...,
go test ./internal/httpclient/... and ./cmd/bd/... -run TestIfRevision all
pass; TestDivergenceLedgerDocMatchesLedger still passes (ledger.go and its
doc were edited in lockstep). gofmt -l reports no diffs on any touched file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient/wire): correct the CapExternalDependencies doc's implied false claim

MEDIUM 9 of the S3 ship review. The old comment on CapExternalDependencies
said this client "has no external-dependency policy layer to gate" and that
"OSS publishes no storage.ExternalDependencyQueryStore-backed client policy
... to compose" immediately after naming bd-enterprise's removed policy.go --
easily misread as "OSS has no external-dependency decorator at all." It does:
internal/storage/externaldeps's decorator is unconditional (no build tag) and
is wired into every local storage chain by cmd/bd/storage_chain.go.

Reworded to say precisely what is and is not true: the decorator exists and
runs for local backends; what this http client lacks is a client-side
composition of that decorator around a remote store, which is moot anyway
because a server advertising this capability already applies the policy
itself before answering. (Rolled in the same "gc native-program" wording
removal from the MEDIUM 8 commit, since both edits touch this comment block.)

A second claim from the same review item -- that OSS is said somewhere not to
serve events:watch -- could not be located despite an exhaustive repo-wide
search (this file, engdocs/, docs/reference/events-journal.md,
SERVE_RUNBOOK.md, the divergence ledger, CHANGELOG.md, and a dedicated
read-only research pass). internal/httpapi/events_watch.go,
routes.go's events.watch route entry, and internal/httpclient/wire/stream.go
all confirm OSS serves it unconditionally (gated only per-workspace by the
events journal setting, not by build/distribution). No corresponding false
claim exists in this worktree to fix; noting this rather than editing
something that already reads correctly.

Verified: go build ./internal/httpclient/..., go vet, go test
./internal/httpclient/wire/... pass. gofmt -l clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(unsupportedgen): add a freshness check for the generated shell

LOW item from the S3 ship review: internal/storage/unsupportedgen had no
tests of its own, so the generator could drift from the checked-in
internal/httpclient/unsupported_gen.go (a storage.DoltStorage interface
change, or a hand-written method added/removed on Store) with nothing to
catch it short of a human noticing the diff. TestInterfaceCompleteness
(completeness_test.go) already pins which methods belong in the shell by
name, but not whether the checked-in bytes match what the generator would
produce today.

TestGeneratedShellIsFresh runs the same scan-then-generate pipeline main()
runs for the registered DoltStorage/httpclient/Store consumer and diffs the
result against the checked-in file -- mirrors the existing
TestDivergenceLedgerDocMatchesLedger pattern in
internal/httpclient/encode/ledger_render_test.go. Added
TestScanHandWrittenMethodsExcludesOwnOutput alongside it to pin the
correctness property the freshness check depends on (scanning must not see
the generator's own prior output as hand-written).

BUILD.bazel: added the go_test rule by hand (gazelle cannot infer the
cross-package `data` dependency a relative-path os.ReadFile needs under the
Bazel sandbox) with data = ["//internal/httpclient:go_srcs"], following the
existing cross-package data pattern in
internal/httpclient/encode/BUILD.bazel. Placed go_test before the
go_srcs.py-managed filegroup block, which `make bazel-sync-check` requires.
Verified: `bazel run //:gazelle` leaves the rule untouched, `bazel test
//internal/storage/unsupportedgen:unsupportedgen_test` passes, `make
bazel-sync-check` is clean, go build/vet/test ./... all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient/encode): scrub a private tracker-ID cluster from the shipped divergence-ledger doc

Follow-up to the MEDIUM 8 licensing scrub: internal/httpclient/encode's
ledger_render.go header and ledger.go's comments/pinnedElsewhere constant/two
Why strings cited "ga-b8ddd.12/.19/.23/.30" by name. These feed directly into
engdocs/design/http-divergence-ledger.md -- a shipped, generated OSS design
doc, the most visible surface this private ID cluster reached (Fork A's
MEDIUM 8 survey found ~40 occurrences of "ga-b8ddd" across the httpclient
package; this commit addresses the subset inside package encode that is
checked-in prose/doc text, not test-fixture or assertion values). Reworded to
keep the same substantive explanation (what closed, what's still deferred,
which dual run resolved L17) without naming the private ID.

The remaining ~30 occurrences of "ga-b8ddd" outside package encode
(offrole.go, metadata.go, store.go, roles_test.go, wire/*_test.go,
served_*_test.go) are left for a follow-up pass: scrubbing them individually
needs the same per-file verification this commit did, and is a larger,
separate blast radius than was practical in this pass.

Regenerated engdocs/design/http-divergence-ledger.md via
`go test ./internal/httpclient/encode -run TestDivergenceLedgerDocMatchesLedger
-update-ledger-doc`; diff confirmed only the ga-b8ddd text changed. go build
./..., go vet ./internal/httpclient/..., and go test ./internal/httpclient/...
all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(httpclient): drop a private host reference from a test comment

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* revert(licensing): keep the scrub to the contributed client code

The previous scrub also edited upstream files this PR doesn't otherwise
touch (.golangci.yml, cmd/bd --if-revision files from #7203) and deleted an
upstream release-gate record. Restore them; the provenance scrub applies only
to the code contributed from bd-enterprise.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat(httpclient): wire S8 count-scope fields on the client

Encode ParentID/NoParent/ExcludeTypes/ExcludeStatus onto countIssues
(table.go + encode.go), add issues.count.scope to the client capability
table (wire/handshake.go, wire/vocabulary_test.go), and refuse locally
before dialing when the server hasn't advertised the token and any scope
field is set (counter.go's refuseUnservedScope), returning a typed
*storage.ErrUnsupported{Capability:"issues.count.scope"} rather than
dropping fields or taking a guaranteed-400 round trip.

Adds encoding-parity coverage (counts_test.go), a masked-token skew test
proving the pre-dial refusal and zero dials (counts_test.go), roundtrip
and skew-table fixes for the newly-encoded fields (encode/roundtrip_test.go,
encode/skew.go), and wires S8's nine shared Counter conformance cases into
the served http leg (served_counter_test.go), including AddDependency so
the wisp/compose cases run instead of skipping. List stays nil on this
fixture since listTable() has pre-existing, unrelated permanent refusals
for ListRequest.NoParent/ExcludeTypes, so the three *MatchesListCardinality
cases skip here by design.

internal/storage's TestEveryLegWiresEveryRoleContract/http ceiling check
remains red (53 skipped vs ceiling 49) after this change, but strictly
improved: before this change the inherited baseline was 62 skipped (13
over ceiling), all nine of S8's new entrypoints unwired. This change wires
all nine, closing exactly that gap; the remaining 4-over are named
RunBootstrapper*/RunDependencyEditor* cases unrelated to count-scope,
pre-existing debt from other already-merged slices whose ceiling was
never bumped for them. Left the ceiling constant alone rather than
raising it to paper over debt this change doesn't own.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(storage): close the http leg's role-contract ceiling regression

TestEveryLegWiresEveryRoleContract/http went red after the rebase (62
skipped, 13 past its ceiling of 49) before any work in this session; the
prior commit closed 9 of those (S8's Counter cases). The remaining 4-over
were RunBootstrapper* (9 entries) and RunDependencyEditor* (2 entries),
both newly-merged contracts this leg had never classified.

RunBootstrapper*: internal/httpclient/accessors.go already names
Bootstrapper PERMANENTLY UNSERVABLE over http (bd init resolves its
substrate identity entirely client-side, before any server exists to
dial) — add a new named waiver, bootstrapperPermanentlyUnservableWaiverReason,
covering all nine entrypoints. VersionReconciler and InitVerifier are
named permanently unservable by the same accessors.go comment but are
left under the ceiling for their own reviewed change, out of scope here.

RunDependencyEditor*: the OSS server already serves add/remove and the
http leg already wires nearly all of DependencyEditor's contract. The two
missing cases (SameTypeReAddWithChangedMetadataMintsOneVersion,
SameTypeReAddWithIdenticalMetadataIsANoOp) only needed
SetVersionedHistoryEnabled wired onto the fixture, the same way
SetJournalEnabled already is — wired it for real; both pass served.

With Bootstrapper waived and DependencyEditor fully wired, the leg's
unwaived-missing count drops from 53 to 42, so adoptionCeiling moves
from 49 to 42 to keep the ratchet exact, with the adopting prose updated
to match.

TestEveryLegWiresEveryRoleContract is green. Served tier (real, CGO +
embedded dolt): 611 PASS, 0 FAIL, 72 SKIP (up from 609). bazel build/test
and make api-check pass for the touched targets.

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/37307836753
(`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(conformance): pass -tags gms_pure_go to Tier 3's served httpclient run

scripts/conformance.sh:61 ran a bare `go test -timeout=40m ./internal/httpclient/`
for Tier 3 (served HTTP client/role conformance), which `make ci-pr-policy`'s
build-tag policy check refuses ("bare go test without -tags=gms_pure_go").
Pass the same -tags Tier 1 already does, and update
TestConformanceScriptUsesExplicitTimeoutBudgets' pinned argv to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(bazel): give //internal/httpclient:httpclient_test room to run

The package takes ~350s under --config=ci (BEADS_TEST_SKIP=dolt, no
BEADS_TEST_EMBEDDED_DOLT) — mostly wall-clock wait on the CA tests'
dialer/keep-alive timeouts, not CPU — but the go_test had no size/timeout
override, so it inherited the medium default's 300s and timed out
intermittently under Bazel (and took "Go test equivalence" down with it).
Set size = "large", timeout = "long", matching
//internal/storage/embeddeddolt's go_test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): fix data race in caContextHandler test helper

TestTransportForRaisesMaxIdleConnsPerHostForBursts drives caContextHandler
with 8 concurrent requests; handler() wrote requestSeen/host/sni from every
server goroutine with no synchronization, and the other nine callers (all
single-request) never exercised the race. go test -race reproduced it as
3x DATA RACE across repeated runs.

Guard the fields with a mutex and expose them only through accessor methods
(sawRequest/seenHost/seenSNI), updating every call site in
store_dependent_test.go accordingly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(unsupportedgen): canonicalize reflect-visible stdlib aliases

TestGeneratedShellIsFresh fails on Go >= 1.27: encoding/json.RawMessage
became an alias of encoding/json/jsontext.Value, and reflect only ever sees
an alias's underlying type, so formatType rendered
storage.DoltStorage.MergeMetadata's signature with the new, non-portable
name even though the signature itself did not change. A contributor on
1.27 following the freshness test's own advice ("go generate
./internal/httpclient") would commit a shell that does not compile on the
1.26.7 SDK this repo pins.

Add reflectAliasCanonical, a table mapping a reflect-visible alias target
back to the name a human wrote in source, consulted by namedType. Add an
entry here for any future stdlib alias this generator's output needs to
stay stable across.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): claimOnlyUpdate propagates the claim's RowVersion

bridge.go's GetIssue already stitches details.Revision onto
hydrated.RowVersion when claimOnlyUpdate rehydrates labels/CreatedBy onto
the claim response, but the claim response itself (issueops.Claimer's
bare-row contract) carries no revision at all, and the copy-back only
touched Labels and CreatedBy. So Lifecycle.Update({Actor, IssueID, Claim:
true}) — `bd update X --claim` — handed back Issue.RowVersion == 0 over
http where the local leg returns the real token, and feeding that into the
next write's ExpectedVersion got a spurious mismatch instead of none.

Copy RowVersion back too. Extend
RunLifecycleResultsCarryThePostWriteRowVersion (shared lifecycle/close/reopen
conformance contract) with a claim-shaped first link in the chain: claim,
then guard the next write with the claim result's own token, proving the
claim-only path populates the real version rather than a nonzero constant.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): stitch RowVersion on SearchIssues' exact-id fast path

resolve.go's getIssuesByExactID decodes the same IssueDetails shape
bridge.go's GetIssue does, but never parsed details.Revision the way
GetIssue's own stitch does, so SearchIssues(ctx, "<exact id>") answered
RowVersion 0 — a one-line gap: Issue.RowVersion is json:"-", so the decode
left it at zero, and only the explicit parseRevision stitch recovers it from
the response's own Revision string member.

Add TestSearchIssuesExactIDPopulatesRowVersionForAGuardedWrite, pinning the
same guarded-write round trip TestBridgeGetIssuePopulatesRowVersionForAGuardedWrite
already pins for the plain GetIssue path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): route every write role's refusals through inexpressible

Review finding 7: write-side refusals were not uniformly *ErrUnsupported.
Read roles already wrap encoder refusals through Store.inexpressible, which
reaches both encode.RefusedError and encode.CapabilityError; the write side's
refuse() returned a bare *encode.RefusedError instead, so a caller doing
errors.As(err, &unsupported) caught the count-scope refusal but missed
Sweeper.Sweep(Limit), DetectCycles(IncludeTracks), ReadyClaimer.ClaimNext,
BatchApplier.ApplyBatch, BatchCloser.CloseBatch, Deleter.Delete,
DependencyEditor.AddDependencies, and BatchCreator.CreateBatch.

Give InexpressibleError a detail field that preserves the original error's
composite text (an "items[%d]..." or "Issue.%s:" prefix a deeper encoder
helper already adds) instead of collapsing the message to the bare ledger
row text, and wrap every remaining write role's exported method in a single
named-return defer calling store.inexpressible, matching the pattern
lifecycle.go's Create/Update/Reopen already use.

Add TestWriteRoleRefusalsMatchTheReadShape, pinning three write-side
refusals (Sweeper.Sweep Limit, CycleDetector.DetectCycles IncludeTracks,
ReadyClaimer.ClaimNext) now classify via errors.As(*storage.ErrUnsupported)
the same way a read-side refusal does.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(cmd/bd): stop spelling out Status: StatusOpen on a markdown batch create

Review nit 8: batchcreator.go's refuseUnwirableIssue refuses a populated
Status (apigen.BatchCreateItem has no wire slot for it), and
buildMarkdownBatchRequest always set Status: types.StatusOpen explicitly, so
`bd create --file` refused on every call against an http-backed store.

PreparePublicCreateRequest already defaults an empty Status to StatusOpen on
every backend, including the http client store's own server, so the explicit
assignment here was never a different outcome - only a populated member the
wire can't carry. Leave it unset; the created issue is identical on every
backend, and the http leg's role-level accounting for why Status and
CreatedBy are excluded from its allowlists is documented on
batchCreateCarriedIssueMembers (internal/httpclient/batchcreator.go).

CreatedBy is left as-is: that member genuinely has no wire slot AND the
server does not yet stamp it from Actor (a gap already tracked in this PR's
Follow-ups), so its refusal is correct, not a bug to route around.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(httpapi): correct create.go's CreatedBy comment to caller-asserted

Review nit 8: the comment claimed CreatedBy is stamped from the
"authenticated actor," but actor is parsed straight from the request body
(s.bodyActor) and never authenticated - exactly as this file's own doc
comment states a few lines above. Reword to "caller-asserted actor" and
cross-reference that doc comment so the two stay consistent. No behavior
change: the stamp itself and its test coverage were already correct.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): raise MaxIdleConnsPerHost for a supplied client's nil Transport

Review nit 8: DialWith's doc comment promises the raised MaxIdleConnsPerHost
ceiling on every dial, "whether or not a CA is configured," but the
opts.HTTPClient.Transport == nil arm only injected a transport when the
target's CA was configured (resolved.configured()). A caller-supplied
*http.Client with a nil Transport and no CA fell through untouched, so it
defaulted to http.DefaultTransport's own ceiling of 2 at request time instead
- silently exempting this one shape from the doc's promise and forcing a
fresh TLS handshake on most of a concurrent burst even once the pool is warm.

Route this arm through the same dialTransport helper the opts.HTTPClient ==
nil arm above already uses (the CA-scoped transport when a CA is configured,
the shared baseline otherwise), injected onto a copy so the caller's own
*http.Client fields (Timeout, CheckRedirect, Jar) stay untouched.

Add TestDialWithSuppliedClientNilTransportNoCARaisesMaxIdleConnsPerHost: an
end-to-end burst through wire.Client.Do, traced with httptrace, asserting the
connection pool settles into reuse at a burst size the default ceiling of 2
cannot sustain.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(httpclient): stop citing nonexistent design docs from new source files

Review nit 8: several comments added by this lift cited
engdocs/design/http-client-backend.md, "D8 row N", and beads-design/slices.json
- none of which exist in this repository (the design lived in the
bd-enterprise-internal source this code was lifted from).

Point each citation at what actually ships in-repo instead:
engdocs/design/http-divergence-ledger.md (the generated, human-readable
rendering of the divergence ledger in encode/ledger.go) for the D7/D8/D9
discipline citations in encode.go, ledger.go, bijection_test.go,
write_ledger_test.go, wire/credential.go and store.go's package doc; and a
direct description of the wire-gap it records, rather than a slices.json
scope reference, in leg_contract_wiring_test.go's cycle-tracks waiver
rationale. Regenerate http-divergence-ledger.md from ledger_render.go (which
had the same stale citation) via
`go test ./internal/httpclient/encode -run TestDivergenceLedgerDocMatchesLedger -update-ledger-doc`
so the shipped doc and its generator agree.

No behavior change; comment and generated-doc text only.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* feat(httpclient): implement issueops.BatchGetter for the HTTP client leg

The rebase onto origin/main (item 9 of PR #7247's review) brought in
upstream #7248's new issueops.BatchGetter role on storage.DoltStorage,
breaking the HTTP client leg's interface satisfaction. This wires it up
as a read role (no actor, no version guard, writes nothing — dialed as
a POST only because MaxGetManyIDs ids cannot ride a GET query string),
mirroring Counter/Querier rather than the WriteWire-wrapped roles.

- wire/paths.go: add PathIssuesBatchGet ("/v0/beads/issues:batchGet").
- batchgetter.go: httpBatchGetter.GetMany dials the server and stitches
  each resolved issue's RowVersion from apigen.BatchGetIssue.Revision
  (the role's only wire spelling of the row token, since RowVersion is
  json:"-"). checkGetManyIDs pre-validates the cap and blank-id rules,
  in the same order internal/storage/issueops.ValidateGetManyRequest
  applies them, because batch_get.go's failBatchGetErr collapses every
  validation failure into one generic, code-less InvalidArgument the
  client could never decode back into *issueops.TooManyIDsError.
- accessors.go: add the BatchGetter() accessor (26th wire-backed role).
- unsupported_gen.go: regenerated, dropping the now-implemented stub.
- completeness_test.go: move BatchGetter into wireBackedAccessors and
  bump the asserted accessor-matrix total from 28 to 29.
- served_test.go / served_harness_test.go: both package-local "by hand"
  httpapi.Config builders (serveRoles, serveConfig) now wire
  cfg.BatchGetter, fixing ~56 served-tier tests that broke once
  BatchGetter joined httpapi.Listen's required role set.
- served_batch_getter_test.go: wire the HTTP leg into all 14
  backend/conformance.RunBatchGetterXxx cases, following
  served_graph_counter_test.go's pattern. This surfaced a real bug:
  GetMany built Missing via append([]string(nil), body.Missing...),
  which stays nil when the server reports no misses, violating the
  role's "Missing is never nil on success" contract — fixed to build
  via make([]string, len(body.Missing)) + copy.

Verified: go build/vet clean; internal/httpclient suite green
(including the embedded-dolt served tier); TestEveryLegWiresEveryRoleContract
holds the http leg's adoption ceiling at exactly 42 with no change needed;
TestInterfaceCompleteness and TestAccessorMatrixMatchesDesign pass.

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/37450731721
(`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.

* test(httpclient): lock contextServer.seen against concurrent handler goroutines

TestDialWithSuppliedClientNilTransportNoCARaisesMaxIdleConnsPerHost drives
the stub with bursts of 8 concurrent requests; the handler appended to
seen without a lock. Readers only look at seen after their requests return.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* build(bazel): sync go_srcs managed blocks for unsupportedgen after the main merge

The PR adds internal/storage/unsupportedgen on a base that predates #7320,
which gave every Bazel package a managed repo_files filegroup. On the merge,
`python3 tools/bazel/go_srcs.py --check` (TestBazelGoSrcsBlocksCurrent) found
3 stale blocks: the package's own repo_files block, its entry in the root
BUILD.bazel repo_files list, and its entry in tools/bazel/BUILD.bazel.
`make bazel-sync` regenerated exactly those; gazelle changed nothing else.

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(httpclient): refuse DepAddItem.HasSpawner and ThreadID on applyBatch after the main merge

Main's #7209 gave issueops.DepAddItem two members, HasSpawner and
ThreadID, and a conformance case, RunBatchApplyStampsSpawnerIDOnlyWhenNamed.
ApplyDepAddItem on the v0 wire publishes source, target, type and
metadata only, so on the merge the http leg dropped both silently and
two of the PR's gates went red:

- TestEveryWireExcludedWriteMemberCarriesALedgerRow: the reflective
  census found two wire-excluded DepAddItem members with no ledger row.
- TestEveryLegWiresEveryRoleContract/http: the new case left the leg
  at 43 unwired cases against its exact ceiling of 42.

applyDepAddItemBody now refuses each member where the role would store
something the wire cannot say, under two new KindRefuse rows,
W-DepAddItem.HasSpawner and W-DepAddItem.ThreadID. The spawner flag
refuses only on a waits-for edge, because the role ignores it on every
other type and stores the same row either way. The ledger doc is
regenerated (264 rows).

The served tier wires the new case as a park on W-DepAddItem.HasSpawner,
owned by the family's existing bead, which brings the http leg back to
its ceiling. With the skip removed the case fails on the client's
refusal; with the refusal also removed it fails on the drop the row
names: spawner_id "" where the role stamps the resolved target.

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(httpclient): address #7247 relaunch review iteration 1

Review iteration 1 of the relaunched adoption raised six majors. This
commit fixes all six. Five are the majors the first adoption's
iteration 1 raised. Its fixup, 696803f250 (tag
adopt-pr/bd-f5illd/stranded-fixup-696803f250), fixed them but never
reached the branch. That fix is ported here onto the contributor's
current head, with its reasoning unchanged; the sixth is new.

Creates refused what the CLI sends. Every `bd create` carries
CreatedBy, a workspace whose config.yaml names a prefix also carries
IDPrefix, and the client refused both.
- The server stamps created_by from the actor on all three create
  shapes: batch_create.go and batch_apply.go now match create.go.
- The client sends a CreatedBy that names the actor and refuses any
  other value, which the server's stamp would silently replace.
  createIssue and the apply create item share
  refuseUnwirableIssueMembers.
- IDPrefix refuses only where the role would act on it: an explicit,
  unforced id.
- `bd create --file` stays refused over http. Dropping its Status was
  safe but not enough: the batch create still refuses its Provenance
  and Owner. The markdown.go and batchcreator.go comments that called
  it servable now say so.

keysetFilter ignored AfterPriority. It now compares priority first,
mirroring sqlbuild's KeysetPriorityCreatedAtIDPredicate, and a new
served case resumes a priority keyset position. AfterID or AfterPriority
without AfterCreatedAt no longer reads as a zero-instant position that
discarded every row (the AfterID minor).

Claim with a patch was refused on a false ledger claim. `claim`,
`force_assignee_transfer` and `force_close_policy` now ride updateBody
like `force_notes_overwrite`, so a claim with a patch or a version guard
is one updateIssue call. A claim ALONE sent to a server that predates
the member (#6890) falls back to claimIssue. The three ledger rows are
retired, and the served cases parked on them now run.

OpenReadOnly returns a writable store. It stays writable, as a
documented exception: backends.Backend.OpenReadOnly also serves the
root pre-run's classified reads, and `bd ready --claim` writes through
that store. The exception is named in the backends.Backend contract,
the store_factory invariant and the store doc, and
TestReadOnlyOpenServesTheClaimBdReadyMakes pins it. An OpenNonMutating
backend hook is the follow-up.

Security surface.
- http_target.json is in the doctor gitignore template and its required
  patterns.
- BEADS_HTTP_TOKEN and BEADS_HTTP_TOKEN_COMMAND are host-scoped with
  BEADS_HTTP_CA_FILE's "host[:port]=value" syntax. A value scoped to
  another server falls through to the next rung, and a command scoped
  elsewhere never runs.
- LoadTarget and SaveTarget refuse a url that carries userinfo, and
  Target.String drops userinfo.

The served Tier 3 had no CI home. The new target
//internal/httpclient:httpclient_served_test is an `embedded`-tagged
sh_test. It reruns httpclient_test's binary through
tools/bazel/go_test_variant.sh with the script's
BEADS_TEST_EMBEDDED_DOLT=1 and BEADS_HTTP_TEST_REQUIRED=1, in 24 shards
on the embedded lane's race build. bazel.yml's bazel-embedded job
already runs `bazel test //... --config=embedded`, so no workflow
changes.
- -test.timeout=19m, not the script's 40m: Go's own timeout then fires,
  and dumps every goroutine, before the action's 1200s limit.
- TestBazelRetiredLanesCannotBeNarrowed pins its args and env. The new
  TestConformanceServedTierRunsUnderBazel ties the script's Tier 3
  switches to the rule.
- The new untagged TestServedTierIsLinkedWhenRequired fails a required
  run built without cgo, which drops every served file (the sentinel
  minor).
- A first 12-shard run found two test defects; both are fixed.
  TestServedBatchApplyBoundsTheItemCount's 1000-item apply outlasts the
  client's 60s per-request timeout under -race, so a
  race_detector_{on,off}_test.go pair scales its "at bound" half to 150
  there, as embeddeddolt's TestBatchApplyContract does. And
  TestTheCompositionCatchesAWrongParameter's dropped-filter case leaned
  on rows earlier tests had seeded: run alone, or first in its shard,
  it failed. It now seeds its own row outside the scope.
- conformance.sh, its script test and
  engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md name the target.

Deviations from the review's suggested fixes:
- A bare BEADS_HTTP_TOKEN(_COMMAND) fails closed rather than falling
  back, and the error does not echo the value: a bare token split at an
  "=" would put token text into the pattern half. Dropping the bare
  syntax is safe today: the backend has no Register call site and no
  docs/ page names the variables.
- Target.String drops userinfo instead of using url.URL.Redacted, which
  masks only the password, so a token used as the username would print.
- The pre-#6890 claimIssue fallback leaves RowVersion unset instead of
  borrowing the follow-up read's token. That read is a second snapshot,
  so its token could postdate a write this claim never saw and arm a
  guard that should miss; a guard built from the unset token fails
  closed. Against a current server the claim rides updateIssue, whose
  `revision` is stitched as for any update.

Also fixed: the nit about the completeness failure message, which now
says to regenerate the shell, and the offrole.go tombstone comment that
named a skip list which no longer exists. Left for follow-up (all
latent, since httpclient.Register has no production caller): vocabOnce
latching a failed fetch, snapshot holding s.mu across the handshake
dial, unchunked graph anchors, private tracker IDs in park owners, and
the bounded journal limit above 10000.

Validation:
- git diff --check; gofmt -l; go vet over internal/httpclient/... and
  scripts
- go test -tags gms_pure_go over internal/httpapi/...,
  internal/httpclient/..., internal/storage/backends/... and
  backend/conformance/...; the doctor gitignore tests; the cmd/bd
  events-journal construction guard; ./scripts
- bazel test --config=embedded
  //internal/httpclient:httpclient_served_test on the lane's remote
  executors: 24 shards, 702 top-level tests, 632 pass, 70 skip (69
  ledgered KNOWN DIVERGENCE, plus
  TestCAFileHygieneRefusesGroupWritableFile, which finds no
  supplementary group on the executor), 0 fail, 0 data races; slowest
  shard 283s. tools/bazel/check_testcases.py --bep passes.
- each of the 702 tests run alone (go test -run '^Name$', without
  -race): 0 fail
- the whole tier under go test without -race, with the script's
  switches and -timeout=40m, before the two test fixes: 633 pass, 69
  skip, 0 fail
- removing BEADS_HTTP_TEST_REQUIRED from the rule fails both policy
  tests
- bazel test --config=ci over //internal/httpclient/...,
  //internal/httpapi/..., //scripts/..., //test/docsync/...,
  //internal/storage/backends/..., //backend/conformance/... and
  //cmd/bd/doctor/...: 32 tests pass
- make ci-pr-lint: nogo native plus windows/darwin, 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>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <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>
2026-10-08 12:01:09 +00:00
Julian Knutsen
143c418148
ci(bazel): cut per-lane fixed cost — LLVM .tar.zst slice, release cross-compile lane, no protoc build (#7379)
* ci(bazel): fetch the LLVM toolchain as a 149 MB slice; re-key the runner cache

Port of gascity #7279. @llvm_dist_linux_x86_64 downloaded the 1.94 GB
LLVM-22.1.8-Linux-X64.tar.xz and ran a single-threaded `tar -xJf` over
11 GiB to keep a 688 MB slice. That took 94-147 s in every Bazel lane,
and every cgo, race and stdlib action waits on it.

- llvm_dist.bzl gains `sliced`: download_and_extract of a members-only
  .tar.zst, plus a missing-member check. The xz path stays.
- MODULE.bazel pins the toolchain-llvm-22.1.8-slice-1 asset by sha256
  (de614777...6bec5). The URL is gascity's release asset for now; the
  list form leaves room for a beads mirror of the same bytes.
- tools/cc_toolchain/repack_llvm.sh and llvm_members.txt rebuild the slice
  from the pinned upstream release.
- Runner cache v4, keyed on MODULE.bazel too. MODULE.bazel.lock does not
  record llvm_dist, so the v3 key never changed and kept restoring the
  2.9 GB entry that holds the xz archive.
- bazel_hermetic_cc_test: a sliced llvm_dist may only download from a
  gastownhall/beads or gastownhall/gascity release, and its members must
  equal llvm_members.txt.

Verified locally:
- Every file in the extracted slice (2009 entries: types, modes,
  symlink targets, sha256) is identical to the xz extraction.
- aquery action keys are identical, base vs head, at the same workspace
  path: 7565/7565 over deps(//cmd/bd:bd_for_tests) and 7146/7146 over
  the race deps(//internal/storage/embeddeddolt:embeddeddolt_test).
- Extraction time: 178 s (xz) vs 1.9 s (zstd).

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): run the release cross-compile as its own lane

After the LLVM slice, bazel-pure is the longest cached Bazel lane (about
170 s). Its "Cross-compile every release target" step takes 54-58 s of
that (78.9k configured targets, 25k cache-hit lookups) and shares no
analysis with the pure invocations, because release_cross is a split
transition.

The step moves, unchanged, into a new job, bazel-release-cross ("release
cross-compile"). The job uses bazel-pure's runner, `needs: rbe` and skip
rule, so it runs in every mode except skip. It reports job.status like
every lane: the workflow_call output is bazel-release-cross, and pr.yml's
CI Gate requires it as BAZEL_RELEASE_CROSS. bazel-gate.sh skips it only in
mode skip, as it does BAZEL_PURE. Merge groups use the same pr.yml gate.
Push and dispatch runs gate nothing. Existing gate ids are unchanged.

The policy test now pins the step to bazel-release-cross, requires the new
gate id, and rejects any other job that runs the script (no double runs).
The new job is listed as having no CI analytics step. It captured no BEP as
a bazel-pure step either, and the analytics steps are unchanged. Docs:
LINTING.md, TESTING.md, CI_REQUIRED_CHECK_TOPOLOGY.md.

Expected: bazel-pure about 110 s on cached runs; the new lane about 85 s,
in parallel. Cost: one more 2-vCPU Blacksmith runner per run.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* build(bazel): stop building protoc for protoc-gen-validate

github.com/envoyproxy/protoc-gen-validate ships validate/validate.pb.go,
but its own validate/BUILD makes the Go library a go_proto_library. So
every lane built protoc from source just to regenerate that file. The
module reaches the graph only through grpc xds and the cloud SDKs.

A gazelle_override now regenerates the module's BUILD files with
`gazelle:proto disable`. It sets build_file_generation = "on" and adds
`gazelle:build_file_name BUILD.bazel`, so gazelle writes BUILD.bazel
(which Bazel prefers) instead of keeping the upstream BUILD. The proto
directive alone changes nothing, because the upstream BUILD files win.
validate is now a plain go_library over validate.pb.go.

Measured locally with aquery:
- //... minus the manual release_cross target: base has 2096 CppCompile,
  612 CppArchive, 314 CppLink and 1 GoProtocGen action; head has 0.
- cquery somepath(//..., @protobuf//:protoc): base goes through
  grpc xds -> envoy core/v3 -> validate_go_proto -> protoc; head is
  empty.
- deps(//cmd/bd:bd_for_tests): 7565 actions become 3077. The race
  deps(//internal/storage/embeddeddolt:embeddeddolt_test): 7146 become
  2658.

MODULE.bazel.lock does not change. The v4 runner cache key includes
MODULE.bazel, so it still moves. Expect one cold compile of the Go
packages above validate on the first run after merge.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* build(bazel): bazel mod tidy formatting

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 03:13:34 +00:00
Julian Knutsen
233d151b37
ci(pr): cut the Windows PR preflight leg's fixed costs (slice W) (#7378)
PR preflight process (windows-latest) is a CI Gate input and, after the
Bazel fixed-cost work, the merge-group critical path (ends at +247..+303s).
Step timings from merge group 37710264475 and seven same-repo PR runs:
45-115s setup (setup-go, then module and build cache tar extraction),
33-71s "Exercise the real Bash process boundary", 27-58s ./cmd/bd test
compile+link, 5-9s each for three more go test relinks.

- scripts/pr_preflight_test.go: the ~29 pr-preflight.sh runs (about 1.5s
  each under Git Bash on Windows, 42.8s total in the merge group) now run
  as parallel subtests. Each run already had its own temp dir, call log
  and env; the one test that t.Setenv's stays serial. Linux: 4.8s -> 0.8s.
- pr.yml: the hook-timeout step and the bd build fallback step become one
  go test of ./cmd/bd, saving a package re-hash and test-binary relink
  (5-9s on Windows for a sub-second test). Policy tests and the allowlist
  and topology docs follow the step name.
- warm-non-race-cache.sh: on Windows also compile the three CGO_ENABLED=0
  credential-fixture test packages the Windows-only fixture step runs, so
  main.yml's test-windows seeder covers them.

No step, test or gate input is dropped; the job id, name, matrix and
runner are unchanged.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 02:42:27 +00:00
Julian Knutsen
dff41b4bb8
fix(bazel): re-vendor signed-duration decode fix from gascity (#7374)
gascity commit 9865cc045aee1391dbcc7eac99339c26e3a5ce71 fixed a
production bug: negative protobuf durations in the compact exec log
were decoded as unsigned, so the collector rejected roughly 22% of
artifacts on remote_queue_ms. Re-vendor the extractor and its unit
test byte-identical from that commit and update the sha256 pins in
ci_analytics_extract_test.go accordingly. testdata/ci_analytics/ is
untouched by the fix; its tree-hash pin is re-verified unchanged
against gascity's tree.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-08 01:05:38 +00:00
Julian Knutsen
886ebb375a
ci(rbe): fail remote runs fast on a stale worker-env pin; nightly opens an issue (#7373)
rbe-west's pool workers run gascity main's tools/rbe/worker-env and
advertise its pin; the schedulers match //platforms:rbe_worker's pin
exactly. When gascity re-pins and beads' copy falls behind, every remote
action queues until the lanes time out, and the only check ran nightly
with no notification (review finding S1).

- bazel.yml's rbe job: after decide, only when the lanes execute remotely
  (enabled: modes remote, fork-ro, fork-rw; merge groups are remote), a
  sparse checkout of tools/rbe and platforms and tools/rbe/worker-env-sync
  main. Out of step fails the job, so every lane skips and pr.yml's gate is
  red within a minute, with the diff and the pin to commit in the summary.
  No fallback to mode cache: pr.yml's ci-gate requires a remote run
  (BAZEL_REMOTE), so it would be just as red, only slower. gascity
  unreachable warns and proceeds. The steps set no output; the job's
  outputs stay decide's.
- worker-env-sync: exit 1 only for out of step, exit 2 (warning) when it
  cannot compare (ERR trap; curl timeouts), WORKER_ENV_SYNC_REPORT copies
  the markdown report.
- nightly.yml: top-level permissions contents: read; rbe-worker-env-sync
  gets issues: write and, on exit 1, tools/rbe/worker-env-sync-issue opens
  a ci/infra issue with the report or updates the open one (body + comment
  linking the run). GITHUB_TOKEN is in that one step.
- Policy tests: TestBazelRBEWorkerEnvPreflight (shape + the step's script
  run in step / out of step / unreachable), TestNightlyWorkerEnvSyncOpensIssue
  (permissions, token scope, rc output, issue create/update via a stub gh),
  TestRBEWorkerEnvSync (exit codes, report); rbe job step and checkout
  counts updated.

Agent-Signature: claude-code-claude-opus-5-5-medium on behalf of Julian Knutsen

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 00:55:02 +00:00
Julian Knutsen
b4831e7250
ci(bazel): go_test_offline runs on the fork tier, where actions are already offline (#7359)
bd_managed_local_test (#7326) fails on every fork PR's proxied lane:
the rbe-west fork tier forbids nested namespaces, so unshare exits with
ENOSPC, but that tier already runs every action loopback only. When
unshare is unavailable, run the binary directly after the same outbound
probe proves the network is absent; a host with network and no
namespaces still fails.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 10:04:40 +00:00
Julian Knutsen
57e86a2f0d
ci(bazel): add CI analytics extraction to all lanes (S3) (#7356)
tools/bazel/ci_analytics_extract.py turns a lane's BEP file, compact
execution log and JSON profile into a redacted ci-analytics-summary
(timing, per-mnemonic cache classes, cold actions, test results,
repo-fetch time): only validated labels, mnemonics, enums and numbers
leave the runner, never an endpoint, cert/key path, env value, token
or hostname. Every lane's "CI analytics summary" step runs the
extractor and uploads its output as ci-analytics-<lane>-<run_attempt>
(7-day retention); CHECK_RUN_ID uses the real job.check_run_id
context (requires actionlint >= 1.7.8), and both the summary and
upload steps are continue-on-error, the summary capped at
timeout-minutes: 3, and both gated on !cancelled() (not always(),
which also runs after a workflow cancellation).

The extractor, its 62-case unittest file, and testdata/ci_analytics/
(the real/* Bazel 9.2.0 fixtures, poisoned-bep.json, mismatch.bep.jsonl
and regen.sh) are vendored byte-identical from gascity's
ci/analytics-extractor slice (final squashed commit
00161373bc7bbfcef8d6a05ac5ce70409fc7f2ac), which is canonical for this
pair the same way tools/rbe/cache-zstd-probe.sh is a byte copy.
Fixtures are regenerated under env -i with every BEP field stripped
unless it's on an explicit allowlist, and the compact exec log is
committed decompressed (*.binpb) rather than as a zstd frame, so
nothing opaque reaches version control.

scripts/ci_analytics_extract_test.go is the thin Go wrapper:
TestCIAnalyticsExtractorIsPinnedToGascity pins both vendored files'
sha256 so local drift is caught, and TestCIAnalyticsExtractUnitTests
runs gascity's unittest file in place. scripts/ci_analytics_workflow_test.go's
TestCIAnalyticsStepsAreSafeAndBounded mirrors gascity's pin test,
adapted to beads' 8 separately-named lane jobs: continue-on-error,
timeout-minutes bounds, no raw ${{ }} expression in run:, !cancelled()
required in if:, correct per-lane upload artifact name/path, and
CHECK_RUN_ID == ${{ job.check_run_id }}, for every lane.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-07 09:07:24 +00:00
Julian Knutsen
8d7d7fef16
build(rbe): adopt gascity's toolchain-only worker-env pin; check the copy nightly (#7346)
gascity now builds the worker-env manifest from the worker's toolchain,
not the image's patch revisions. The manifest records the arch, the OS
release, Go and dolt, and the upstream releases of the libraries and
tools actions reach (major.minor; git and yq at their major). The Debian
epochs and Ubuntu revisions are gone, so the Blacksmith image's routine
security updates no longer move the hash. That is what stranded every
remote action on 2026-10-07: coreutils 9.4-3ubuntu6.1 -> 6.2 and libc6
2.39-0ubuntu8.6 -> 8.8 forced re-pins (gascity #7266, beads #7338).

- tools/rbe/worker-env.txt: byte-identical copy of gascity's new
  manifest. platforms/BUILD.bazel pins its sha256,
  sha256:6be1381cf08e7fd66684cfce6f26aca57de2561e722c505d1f2f578e9fdeafa7.
  The manifest now also measures python3, curl, openssl, unzip and yq,
  which //scripts:scripts_test runs from the executor.
- scripts/rbe_worker_env_test.go: the manifest must be a rendering of
  gascity's tools/rbe/worker-env (sorted; one arch, dolt, go, os and yq
  line; packages at most major.minor, installed). A copy of an older
  gascity manifest with dpkg revisions, a hand edit or a truncated copy
  fails here.
- tools/rbe/worker-env-sync, run by nightly.yml: compares the manifest
  and the pin with gascity's main byte for byte. If they differ, it
  prints the diff and the pin to commit, and fails.

Merge this together with the gascity change. Pool workers run gascity
main's provisioning, so they serve the new hash only once that change
lands, and beads' actions on any other pin queue. This supersedes #7338
(the old-format re-pin). The new key misses the cache once.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 23:18:24 -07:00
Julian Knutsen
d652def9db
build(rbe): re-pin worker-env to the updated Blacksmith ubuntu-24.04 image (#7338)
Blacksmith's runner image picked up Ubuntu security updates around
2026-10-07 02:28Z (coreutils 9.4-3ubuntu6.2, git 2.55.0, libc6 2.39-0ubuntu8.8,
sed, tar, util-linux). Pool workers now measure
worker-env=sha256:b2c8be1f53ba4c2f1603b1d65f31e0d4c7ddd498110b9928eda37f193c7eb674
while actions requested sha256:f4d6d0460877…, and rbe-west's oss and oss-fork
schedulers match worker-env exactly, so no action could run (pools idle,
queues growing, every pool run failing the env check). Re-pin to the
measured manifest, copied verbatim from the pool worker's report; gascity
and beads carry byte-identical copies.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 22:58:06 -07:00
Julian Knutsen
a4509deb2d
ci(bazel): nogo replaces go vet and golangci-lint (ga-96smfk.18) (#7341)
* ci(bazel): nogo replaces go vet and golangci-lint (ga-96smfk.18)

Lint and vet now run as nogo inside the Bazel build, so they gate wherever
the Bazel lanes execute (rbe-west), and the golangci-lint and go vet jobs
leave pr.yml and main.yml.

- //tools/nogo (own go.mod, joined to beads' for go_deps only through
  gazelle.go.work): go test's vet checks (cmd/go's defaultVetFlags, the set
  scripts/ci/go-test-vet.sh ran) plus the eight linters .golangci.yml
  enables, each a wrapper over the library version golangci-lint v2.10.1
  uses (depguard, errcheck, forbidigo, gosec, misspell, sloglint, unconvert,
  unparam).
- .golangci.yml stays the single lint policy: Bazel embeds it and
  tools/nogo/internal/golangci applies it as golangci-lint does (enabled
  set, settings, run.tests: false as library-unit-only analysis, lax
  generated-file detection, path/path-except/text exclusion rules), with
  strict decoding so an unimplemented key fails the build.
- gascity's rules_go //nolint-range patch and x/tools ctrlflow patch,
  byte-identical.
- Windows/darwin: cross-configured, not a golangci leg. The pure lane's
  release cross-compile (//tools/bazel:release_cross, every library and
  binary for all eight release platforms, cgo off) runs nogo on every
  compile, a superset of golangci-lint's windows and darwin legs.
  scripts/pr-lint (make ci-pr-lint, bd preflight) runs `bazel build
  --config=nogo //...` plus release_cross for windows_amd64,darwin_arm64.
  release_cross skips tools/nogo, a separate Go module `go build ./...`
  never compiled.
- pr.yml: scripts-go-checks (vet) and pr-lint-wrapper (x3) are gone, with
  their ci-gate entries; main.yml: pr-lint-wrapper (x6) and go-vet-cache.
  scripts/ci/go-test-vet.sh and install-golangci-lint.sh are deleted.
- pre-commit hook and .pre-commit-config.yaml run `make lint-changed
  LINT_CHANGED_SCOPE=staged` (nogo over the staged packages); Makefile adds
  lint, vet and lint-changed. pr-lint.sh no longer runs gofmt
  (//scripts/repochecks:fmt_test owns it; ga-96smfk.41).
- internal/testutil/integration: five gosec findings in integration-tagged
  library files golangci-lint never built, now linted by the integration
  lanes, carry reasoned //nolint directives.

Parity: with the exclusion rules removed, golangci-lint and nogo report the
same 3,916 findings natively and 3,859 each for windows and darwin (file,
line, linter, text); with .golangci.yml as committed both report none.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): equivalence.py leaves nested Go modules' tests out of go test's set

tools/nogo is its own Go module, so `go test ./...` in the root never runs
its tests; Bazel's unit lane does. Its packages are neither expected nor
extra.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 05:17:22 +00:00
Julian Knutsen
ce661175ff
ci(bazel): retire the docker A/B variants and pr.yml's container jobs (#7340)
The dolt-server lane (--config=doltserver) has been the only pre-merge run
of the Dolt-backed domain, uow, tracker, doctor/fix and protocol suites
since BAZEL_COVERS_FORKS went "true": bazel-coverage reports pr_lanes=true
for every pull_request and merge_group, so pr.yml's test-domain-uow and
contract-corpus never run. An A/B run of every requires-docker target
against its dolt-server twin on the same commit shows identical test sets
and statuses (2683 testcases) except TestDoltServerFingerprint/container,
the container half of the fingerprint, which needs docker by design.

Delete the six requires-docker sh_tests, test:docker in .bazelrc, the
requires-docker tag from the taxonomy and lane filters, bazel.yml's
dolt-lane dispatch input and image pull, and pr.yml's test-domain-uow and
contract-corpus jobs with their ci-gate wiring. The testcontainers backend
in internal/testutil stays: it is plain go test's default. pull-dolt-image.sh
stays for pr-risk.yml's legacy tiers. No required check changes: the
rulesets require only CI Gate / Required and PR Risk Gate / Required.

Refs ga-96smfk.21

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 04:13:24 +00:00
Julian Knutsen
3f1c6038f0
ci: warn-only shard-balance budget for bazel-server-storage (#7339)
rbe-ci-cost-latency-study.md recommendation 4: this tier's last shard
has trailed the rest by 4.3-4.5 min in 2 of 8 runs. tools/bazel/shard_budget.py
reads the job's BEP file and prints ::warning when a sharded target's
slowest shard exceeds max(150s, 2x median); --fail-on-imbalance (not
wired in yet) switches that to ::error and a nonzero exit once the
budget has run clean for a while.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-07 04:05:33 +00:00
Julian Knutsen
5e73670866
ci(bazel): cross-compile every release target with Bazel, retire the go build job (#7332)
pr.yml's check-release-target-cross-compilation ran `CGO_ENABLED=0
GOOS/GOARCH go build -tags gms_pure_go ./...` for the eight release targets
on two GitHub/Blacksmith runners. It is now a step of bazel.yml's pure-Go
lane (BAZEL_PURE, already required by ci-gate):
scripts/ci/bazel-release-cross-compile.sh builds //tools/bazel:release_cross
once, remotely, with --//tools/bazel:release_platforms set from
scripts/ci/release-targets.txt (still the single source of truth, pinned to
.goreleaser.yml). release_cross's split transition configures every
go_library/go_binary for each rules_go platform with cgo off, so all eight
platforms build in parallel in one invocation.

- tools/bazel/release_cross.bzl: the split-transition rule and the
  string-list flag.
- tools/bazel/go_srcs.py (make bazel-sync, checked by bazel-sync-check and
  TestBazelGoSrcsBlocksCurrent) keeps the release_cross target list; the
  script checks with bazel query that every Bazel package holding Go
  targets is reached before it builds.
- //tools/bazel:pure_bd_has_no_cgo_only_deps: Bazel compiles gozstd's pure
  stubs where `go build` rejects them, so the pure bd of every platform
  must not link gozstd.
- //internal/storage/embeddeddolt/cmd:cmd (cgo-only main, skipped by
  `go build ./...` under CGO_ENABLED=0) is tagged cgo-only and incompatible
  with pure builds.
- A failed build is re-run per platform (cache hits) to name each failing
  GOOS/GOARCH.

Same cgo-off coverage boundary as the retired job. Refs ga-96smfk.20.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 03:18:37 +00:00
Julian Knutsen
7e0adfd353
ci(bazel): run the historical-upgrade corpus under Bazel; retire migration-test.yml (#7330)
* chore(migration-test): extend the release catalog through v1.3.1

The catalog stopped at v1.1.2 (the v1.2 upgrade census). The migration
corpus already upgrades from v1.2.2, and the Bazel targets that replace
migration-test.yml and cross-version-smoke.yml take their pinned release
binaries from the catalog (@bd_releases), so it has to cover the releases
since. Regenerated with `catalog generate` after raising maximumVersion to
v1.3.1: five new stable versions (v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.3.1;
three with a linux/amd64 asset) and five new proxy prereleases; no existing
entry, drift record or repository-only exclusion changed. The count
constants and the identity digest are updated to match, and the README now
says how to add a release.

Refs: ga-96smfk.19

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): run the historical-upgrade corpus under Bazel; retire migration-test.yml

migration-test.yml ran scripts/migration-test/run.sh --version <release> for
14 reviewed releases in 3 shards on GitHub runners: it downloaded each
release archive, built v0.9.1 from source with Go 1.25 through the module
proxy, installed libicu74 and the dolt 2.1.8 runtime, all over the network.

//tests/migration now has one target per corpus release
(historical_upgrade_<release>_test) plus legacy_bridge_test, all hermetic:
- Published releases come from @bd_releases (the release catalog's
  sha256-verified assets) through a per-target directory
  (HISTORICAL_RELEASE_DIR); lib/binary.sh uses it instead of downloading and
  still checks each binary's self-reported version.
- v0.9.1 is //tests/migration:bd_source_tag, the same `go mod download` +
  `go build -trimpath` with CGO and Go 1.25.0, run offline as a build
  action: the module files come from tests/migration/source_tag_modules.json
  through a file:// GOPROXY tree (tools/bazel/go_module_proxy.bzl), the
  release's own zip is the catalog's source_zip, and go checks every
  dependency against the release's go.sum (SOURCE_TAG_SQLITE_BIN).
- The external Dolt runtime is @dolt_test_runtime_linux_amd64 (dolt.bzl's
  dolt_release gains a version attribute; 2.1.8 is pinned to versions.sh's
  digest), passed as DOLT_BIN to the server-Dolt and wisp-plane releases.
- The workers already provide jq, python3, sqlite3 and libicu74.

The targets are untagged, so bazel-test runs them remotely on every PR,
merge group and push; result caching replaces the path filter. Every
release also passed inside a loopback-only network namespace.
scripts/migration_corpus_bazel_test.go keeps the BUILD lists equal to
versions.sh's corpus, the catalog digests equal to STRICT_RELEASE_SHA256,
the source-tag lock equal to the catalog's source_zip, and the Dolt runtime
pin equal to versions.sh's. migration-test.yml and the policy tests that
pinned its shards, caches, apt step and runner are removed.

Refs: ga-96smfk.19

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): run the historical-upgrade targets in the PR-core lane only

The integration lane runs every untagged target too, and its
check_testcases.py requires Go testcases, which a shell test's test.xml does
not list. A new pr-core-only tag keeps //tests/migration out of
--config=integration (bazelIntegrationExcludedTags adds it), so the corpus
runs once, in bazel-test, against the release-shaped bd_for_tests (no
integration tag). build_source_tag.sh carries the build-tags opt-out: it
builds a historical release with that release's own go.mod, which predates
gms_pure_go.

Refs: ga-96smfk.19

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 02:16:11 +00:00
Julian Knutsen
9a91f0629e
ci(bazel): run the differential regression suite under Bazel; retire regression.yml (#7324)
regression.yml ran `go test -tags=regression ./tests/regression/...` on a
GitHub runner: it built the candidate with `go build`, downloaded the v0.49.6
baseline release over the network, and pulled the dolt-sql-server image.
None of that works on rbe-west workers (no network for fork lanes, no docker).

- tools/bazel/bd_releases.bzl: a module extension that reads
  scripts/migration-test/release-catalog.json and declares one repository per
  catalog release with a linux_amd64 asset digest (bd_release_<version>,
  verified against the catalog's sha256), behind the @bd_releases hub
  (@bd_releases//:<version>, plus versions.bzl). Adding a release is a
  catalog change only; nothing downloads until a test declares one.
- //tests/regression:regression_test: the suite's files build under
  `regression || integration`, so gazelle generates the target. It runs the
  injected non-race bd_for_tests (BEADS_TEST_BD_BINARY) against
  @bd_releases//:v0.49.6 (BD_REGRESSION_BASELINE_BIN), both over a hermetic
  dolt sql-server (BEADS_TEST_DOLT_SERVER=local, required), in 8 shards.
  TestMain checks the baseline reports BASELINE_VERSION, so the label and the
  file cannot drift. Tagged dolt-server-cmd: bazel.yml's bazel-cmd-dolt lane,
  which pr.yml's gate requires, runs it remotely; test result caching stands
  in for the old path detector.
- A plain `go test -tags=integration ./...` (nightly) compiles the files but
  skips the suite; only -tags=regression (make test-regression) or Bazel
  runs it.
- regression.yml, main.yml's warm-up compile for it and the policy tests that
  pinned its jobs are removed.

Refs: ga-96smfk.19

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 01:41:12 +00:00
Julian Knutsen
b1fe68e63a
ci(bazel): run pr.yml's repository guards as Bazel tests (#7329)
fast-checks, PR Policy, and the Linux leg of check-doc-freshness-platforms
ran repository guards on GitHub runners. They now run as Bazel tests in
bazel.yml's `test` lane (remote, cached), each over only the files it reads:

- tools/bazel/repo_subset.bzl picks a narrow, path-selected slice of
  //:repo_files at analysis time. scripts/repochecks/run_check.sh copies that
  slice into a throwaway git checkout and runs the unchanged guard there.
- //scripts/repochecks: build_tags, workflow_tags, go_install_guidance,
  winget_portable_alias, migration_hygiene (checks A and B),
  fmt (registered SDK gofmt), doc_freshness, workapi_frontend_boundary,
  types_gen_drift (`make api-check` drift, oapi-codegen from go.mod).
- //scripts:doc_freshness_required_test (integration lane, -required-suite)
  and //scripts/gitattributespolicy:gitattributespolicy_required_host_test
  cover the Linux doc-freshness leg.
- check-versions stays covered by //internal/versioncheck:versioncheck_test.
  check-testing-short stays covered by //scripts:scripts_test.

pr-policy-wrapper is deleted. fast-checks keeps only the two checks that
need the PR base: migration hygiene's delta half (MIGRATION_HYGIENE_SCOPE=
delta) and the .beads diff. check-doc-flags stays, because it builds bd from
the pinned release tag. The example Go modules leave .bazelignore so gofmt
and the grep guards see them. check_testcases.py now accepts --not-go
//pkg:all.

Refs: ga-96smfk.20

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 00:59:18 +00:00
Julian Knutsen
c292964571
ci(bazel): run the managed-local proxied lifecycle lane under Bazel; retire proxied-local-smoke.yml (#7326)
proxied-local-smoke.yml built bd and the cmd/bd test binary on a GitHub
runner, installed the pinned dolt, and ran `-test.run ^TestManagedLocalProxied`
under `sudo unshare --net` with only loopback up, to prove the managed-local
lifecycle (bd -> loopback proxy -> dolt sql-server) needs no outbound network.

//cmd/bd:bd_managed_local_test runs the same tests (BEADS_TEST_PROXIED_LOCAL=1,
BEADS_TEST_SKIP=dolt, the non-race bd_for_tests as the bd under test, the
pinned dolt from the test wrapper's PATH) through tools/bazel/go_test_offline.sh,
which enters an unprivileged user + network namespace with only loopback up
and fails if outbound network is reachable: the job's netns, without sudo,
on the rbe-west workers. Tagged dolt-server-proxied, so bazel.yml's
bazel-proxied lane (remote-only, required by pr.yml's gate) runs it; test
result caching replaces the workflow's path filter. The job's "tests are
compiled in" assertion becomes scripts/managed_local_lane_test.go, which
evaluates cmd/bd's build constraints for a linux cgo build and requires each
of the 17 pinned tests.

The target joins the pinned retired-lane targets in
TestBazelRetiredLanesCannotBeNarrowed. proxied-local-smoke.yml and the policy
tests that pinned its job and its dolt version are removed (the Bazel dolt
pin is already enforced against install-dolt.sh).

Refs: ga-96smfk.19

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 00:59:14 +00:00
Julian Knutsen
cb0dcbecf2
ci(bazel): hermetic LLVM C toolchain and pinned rbe_worker exec platform (#7325)
beads' MODULE.bazel registered no C toolchain, so -race and cgo builds used
the autodetected local_config_cc of the machine that ran analysis. From a
client with lld installed (cherry) every remote cgo/-race link failed with
"collect2: fatal error: cannot find 'ld'" (the workers have no lld), and the
host gcc path, lld availability and gcc-version inputs keyed every Go action
to the client machine.

Port gastownhall/gascity's design:
- toolchains_llvm 1.11.0 with a pinned LLVM 22.1.8 slice
  (third_party/cc_toolchain/llvm_dist.bzl) and a sysroot of sha256-pinned
  Ubuntu 24.04 debs (deb_sysroot.bzl), without ICU (ICU policy);
  stock toolchains_llvm LLVM on other hosts.
- .bazelrc: BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 so nothing falls back to the
  host compiler.
- //platforms:rbe_worker, selected unconditionally, whose worker-env exec
  property is the sha256 of tools/rbe/worker-env.txt (a copy of the shared
  rbe-west OSS pool's manifest, owned by gascity), so the worker host is in
  every action key.
- scripts/bazel_hermetic_cc_test.go and scripts/rbe_worker_env_test.go guard
  both.

Refs: ga-96smfk.20

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 00:59:11 +00:00
Julian Knutsen
0500fc6f40
ci(bazel): run the scripts and source-walking tests remotely; retire their go test legs (#7320)
//scripts:scripts_test and //scripts/check-versions:check-versions_test
drop their host-tools/no-remote-exec/no-remote-cache tags and run on the
rbe-west workers like every other target (the worker image ships bash, git,
python3, jq, yq, curl, openssl, unzip and coreutils; a missing tool fails the
test under Bazel rather than skipping it). Go comes in hermetically as the
registered SDK; check-versions.sh's `go build` is stood in for by the
Bazel-built checker.

The tests that walked the source checkout now get it as data:
tools/bazel/go_srcs.py keeps a managed `repo_files` filegroup in every
package and aggregates them into //:repo_files (exactly the tracked files
Bazel can see; make bazel-sync-check fails on a package without one).
scripts_test and docsync_test take it instead of hand-listed filegroups,
and every TEST_SRCDIR/IsBazel skip and go-test-only block in them is gone.
The release formula under .bazelignore'd .beads/ comes in through a
@beads_formulas local repository; npm-package/ and .claude/ are visible to
Bazel again (only their node_modules/worktrees stay ignored), so the npm
manifest release check and the AGENTS.md skill links run under Bazel too.
TestZZStdioNotLeaked falls back to TestMain's pre-run streams instead of
skipping in a shard without its baseline.

tools/bazel/equivalence_allowlist.txt shrinks from 20 skip entries to the
two cmd/bd tests of plain go test's own bd build fallback, which Bazel never
takes; pr-preflight-platforms now runs them on Linux, macOS and Windows. The
scripts-go-checks scripts-test and allowlisted legs, their scripts
(scripts-go-test.sh, allowlisted-go-tests.sh, run_allowlisted_go_tests.py)
and main.yml's --compile-only warm for them are removed. The vet leg stays
(ga-96smfk.18).

Refs: ga-96smfk.16

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 22:20:16 +00:00
Julian Knutsen
6d7fecaa3e
feat(httpclient): OSS HTTP client wire/encode layers (contributed from bd-enterprise under MIT) (#7210)
* 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(httpclient): lift the HTTP client wire/encode layers from bd-enterprise (MIT contribution)

Contributed by gascity from bd-enterprise (github.com/gascity/bd-enterprise,
internal/enterprise/httpstore @ 49d1df2f6) to OSS beads under the MIT
license, with the owner's explicit approval. Every lifted file carries a
provenance header naming its source path.

Lifted into internal/httpclient:
- wire/    the HTTP transport, lazy handshake, project-identity stamping,
           problem-code decoding, retry behaviour and the capability vocabulary
- encode/  request/response encoders for the role operations
- credential*.go, ca*.go, target*.go   the bearer credential ladder,
           host-scoped CA trust and the http_target.json sidecar

Not lifted (stays enterprise-only): the hosted gateway (httpgw/gwauth),
box-login, storage profiles and gasworks.

Deferred to later slices (kept aside, not in this tree): the store transport
seam (WireClient/WireDialer/process-wide dialer, which goes to S3 with
dial.go), the enterprise-only BatchCloseRequest.claim_next encoder
(ClaimNextBody; the OSS server has no claim_next on batch close), and the
tests that need the store/dial layer.

This commit is the mechanical lift: import paths rewritten, package renamed,
two compile gaps removed. The production code builds. Known follow-up in the
next commit: reconcile the client's vocabularies and encoder tables with the
OSS spec (e.g. the OSS problem code notes_overwrite_refused, policy/sort
differences), restore the test helpers the lifted tests need, and wire in the
S0 wire_revision handling and S1 OpenOptions credentials.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(httpclient): compile the lifted client and reconcile with the OSS wire

The lift in ab11cb1f8 carried relative test paths and vocabulary tables
from bd-enterprise's internal/enterprise/httpstore (4 directories below
repo root) into internal/httpclient (3 below), and several tables
described enterprise-only server behavior OSS does not serve. Reconcile:

- Add testTarget test helper (written fresh) so internal/httpclient
  compiles and its tests pass.
- Fix four relative paths off by one "../" from the package relocation
  (skew_test.go, ledger_render_test.go, bijection_test.go x2).
- skew_test.go: importsHTTPClient now matches internal/httpclient instead
  of the retired internal/enterprise/httpstore path; the cmd/bd sweep no
  longer hard-fails when it legitimately finds zero matching files (cmd/bd
  does not import this client yet - that's S3's wiring).
- encode/table.go, encode/ledger_fields.go: removed a Reserved "reverse"
  entry and a refused ExcludeIDs field claimed for listIssues/ReadyRequest;
  OSS's listIssues never accepts "reverse" (confirmed against
  internal/httpapi/reads.go and routes.go's CapIssuesListSort, which gates
  `sort` only) and issueops.ReadyRequest carries no ExcludeIDs member in
  OSS. Each removal is documented in place.
- encode/table.go, encode/encode.go, encode/roundtrip_test.go: countIssues
  publishes has_metadata_key and include_ephemeral that CountRequest
  carries and the table/encoder/round-trip corpus all silently dropped;
  mapped and wired through.
- encode/ledger.go: ~70 ledger rows cited enterprise store-conformance and
  cmd/bd subprocess-parity tests (dual-run reader, claim races, flag-mode
  refusals) that don't exist in this package and belong to S3's store/dial
  seam and cmd/bd wiring. Re-pinned to a documented TODO(S3) sentinel
  (pinnedByS3Conformance) rather than deleted, per the ledger's own
  well-formedness discipline.
- wire/handshake.go, wire/vocabulary_test.go: added CapBatchApplyLarge
  (issues.batchApplyLarge) alongside the server's behaviorCapabilities.
- wire/problem.go: mapped the notes_overwrite_refused problem code to
  issueops.ErrNotesOverwrite.

internal/httpclient/... is fully green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* feat(httpclient): wire-revision handshake gate and batch cap from capability

S0 integration (task #2): Client.Handshake now reads ContextResponse's
wire_revision/min_client_wire_revision and refuses with a typed
*WireRevisionSkewError before any post-handshake call when the server's wire
shape falls outside [ClientMinWireRevision, ClientWireRevision] -- mirroring
DESIGN.txt sec 4's "Client rule". A decoded 0 is treated as "the server
omitted the member" per the permanently-retired-values rule, never as a value
needing refusal. The client now also stamps Bd-Wire-Revision on every request
(client.go's stampRequest), and problem.go gained the per-request mirror:
*WireRevisionUnsupportedError, decoded from the reason:"wire_revision_unsupported"
extension members, for the case where the SERVER refuses this client's
declared revision as too old. Both error types are deliberately distinct --
one is this client declining after reading a 200, the other is the server
refusing a request outright -- and neither branches on bd_version (only
assigns it into error text), so TestNoFeatureBranchesOnBdVersionOrSchemaVersion
stays green.

Also added legacyRevisionFields/decodeRevisionToken to problem.go: a
precondition_failed refusal's expected_version/actual_version, typed *string
on the generated Problem, now tolerates a pre-#6053 server sending either as a
bare JSON integer rather than the decimal string every server since has used,
recovering the field the primary decode silently drops rather than losing it.

Batch cap (task #3): ApplyBatch reads the handshake snapshot on every call and
enforces 100 items unless the server advertises issues.batchApplyLarge, in
which case the ceiling is issueops.MaxApplyBatchItems (1000) -- never a bare
compiled constant. A plan over the applicable cap refuses before the dial: via
the existing *CapabilityError machinery when advertising the capability would
help (D7 case 2), or via a new *BatchTooLargeError (unwraps to
issueops.ErrValidation) when it would not. BatchTooLargeError lives in
handshake.go rather than beside ApplyBatch because every exported method in
writes.go is swept by TestEveryOperationMethodRoutesThroughTheSharedDispatch as
an operation-dispatch method.

All three internal/httpclient/... packages build and `go test` passes with
TMPDIR=/data/projects/.scratch/s2t BEADS_TEST_SKIP=dolt.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* feat(httpclient): REQUIRE-mode credential resolution bridge to backends.Credential

Task #4: adds the knob internal/storage/backends/backends.go's OpenOptions.Credential
doc explicitly deferred ("S1 does not add a RequireCredential knob to enforce
the multi-tenant rule mechanically -- that is deferred to S2").

ProvidedCredential wraps an embedder-supplied wire.CredentialProvider (via its
httpclient alias) as a backends.Credential, so a multi-tenant embedder (for
example gc, Gas City: one process serving many workspaces) can carry a
per-workspace credential through backends.OpenOptions without the backends
package needing to know this package's CredentialProvider shape.

ResolveCredential(opts, base, require) is the bridge itself:
  - nil Credential, require=false: NewBearerProvider(base), the existing
    single-tenant ambient bearer ladder (unchanged).
  - nil Credential, require=true: ErrCredentialRequired -- the multi-tenant
    fail-closed case backends.go's doc names: a missing per-workspace
    credential must be a loud refusal, not a silent fall-through to
    process-global ambient env that cannot tell one tenant's workspace from
    another's.
  - a ProvidedCredential with a non-nil Provider: returned directly,
    regardless of require.
  - a ProvidedCredential with a nil Provider, or any other
    backends.Credential this package does not recognise: refused -- the
    former as ErrCredentialRequired (a present-but-empty wrapper must not
    look like "a credential was supplied"), the latter wrapping
    backends.ErrUnsupportedCredential per the OpenWith contract
    internal/storage/backends/open_with_test.go already pins
    (TestBackendOpenWithRefusesUnsupportedCredentialType).

No bd-enterprise source was copied for this file; it is new code written
against the OSS backends.go contract and the existing BearerProvider/
CredentialProvider types already lifted into this package. Live-mutated all
three guards (the require branch, the ProvidedCredential type assertion, and
the nil-Provider check) and confirmed each produces a RED test before
reverting.

go build/vet/gofmt clean; `go test ./internal/httpclient/...` passes with
TMPDIR=/data/projects/.scratch/s2t BEADS_TEST_SKIP=dolt.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(httpclient): S2 task #6 wire-revision/legacy-decode coverage, fix legacyRevisionFields bug

Add httptest coverage for the two wire-revision mechanisms task #2 added
(commit 7ff68b29d8):

- handshake_wire_revision_test.go: the client-initiated skew gate
  (checkWireRevision/WireRevisionSkewError) and the per-request
  Bd-Wire-Revision header stamp. Live-mutated both switch arms in
  checkWireRevision and the stamped header value; confirmed RED, reverted.

- problem_wire_revision_test.go: the server-initiated
  wire_revision_unsupported refusal (reason-before-code dispatch priority)
  and the legacy-integer revision-token fallback.

Writing the legacy-decode tests surfaced a real bug in legacyRevisionFields:
its presence guard treated any non-nil *string field as "already decoded,"
but encoding/json's indirect() pre-allocates a pointer to "" for a *string
field before discovering a type mismatch (e.g. a bare JSON integer). A
type-mismatched expected_version/actual_version therefore arrived as a
non-nil pointer to the empty string, not nil -- exactly the one case the
fallback exists to recover, and exactly the case the old guard skipped.
Fixed by adding revisionNeedsFallback(p) (nil-or-empty), used in place of
the bare nil checks. No legitimate server response uses a literal
empty-string revision token, so this changes no other behavior.
Live-mutated the fixed guard back to the old nil-only checks; confirmed RED
on both recovery tests, reverted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(httpclient): S2 task #6 ApplyBatch item-cap coverage

Add writes_batch_cap_test.go: httptest coverage for ApplyBatch's
capability-gated item ceiling (task #3), separate from the generic
two-speed "is issues.batchApply routed at all" gate writes_twospeed_test.go
already covers.

Cases: at-or-under the 100-item floor succeeds without the capability;
over the floor without issues.batchApplyLarge refuses with a
*CapabilityError before any dial past the handshake; the capability raises
the ceiling to issueops.MaxApplyBatchItems (1000), both at the new ceiling
and strictly between the old floor and it; over the absolute ceiling
refuses with *BatchTooLargeError regardless of the capability, also
without dialing the batch-apply endpoint.

Live-mutated all three guards in ApplyBatch (the limit computation, the
n > limit check, and the capability-vs-absolute-ceiling branch); confirmed
each produces a distinct RED, reverted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(httpclient): S2 task #6 live TLS coverage for wrong-CA refusal

Add ca_wrong_ca_test.go: an end-to-end httptest TLS dial proving
TransportFor's configured CA pool is actually enforced at the wire, not
just recorded on the transport struct. ca_test.go already proves the
latter (TestTransportForReplacesRootPoolNotExtends, via
x509.CertPool.Equal) and proves the RIGHT CA dials successfully
(TestTransportForFileRotationClosesSupersededIdleConnections's live GETs);
neither exercises a server whose leaf a DIFFERENT CA signed.

TestTransportForWrongCARefusesTheTLSHandshake dials a server through a
transport built from an unrelated CA file and asserts the handshake fails
with x509.UnknownAuthorityError. TestTransportForRightCASucceedsOverTLS is
the positive control, using the same (newly-exercised) ca.startServer
helper that was defined but had no caller before this test -- without it,
a mutation that drops RootCAs entirely (falling back to the system pool)
would still pass the wrong-CA test for the wrong reason; the positive
control catches that case. Live-mutated transportForFile to drop RootCAs;
confirmed the positive control goes RED, reverted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* build(bazel): gazelle BUILD files for the lifted httpclient package tree

Task #7: bazel run //:gazelle, now that internal/httpclient and its
encode/wire subpackages exist in the OSS tree (ab11cb1f8) and have gained
this S2 slice's new files. No existing BUILD.bazel files changed; these
three packages previously had none.

Note for S3: bazel test //internal/httpclient/... fails on tests that read
sibling source trees by relative path at runtime
(TestLedgerRowsAreWellFormed, TestEveryEncoderTableParameterIsPublished,
TestDivergenceLedgerDocMatchesLedger in encode, and
TestNoFeatureBranchesOnBdVersionOrSchemaVersion,
TestEveryOperationMethodRoutesThroughTheSharedDispatch,
TestEveryOperationMethodIsCoveredByTheTwoSpeedTable in wire) -- paths like
../../../cmd/bd and ../../httpapi/spec/openapi.v0.yaml resolve under `go
test`'s working directory but not Bazel's sandbox, which gazelle cannot
infer `data` attributes for. Pre-existing in code from task #1/#2, not
introduced by this commit; `go test ./internal/httpclient/...`,
`go vet ./...`, `gofmt -l .`, `golangci-lint run ./internal/httpclient/...`,
and `make api-check` are all clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient/wire): tolerate bare-integer revision on success-path responses

Review HIGH #2: against a fake pre-#6053 server (one whose ContextResponse
omits wire_revision), CloseIssue and its revision-bearing siblings
(ApplyBatch, ReleaseIssue, ReopenIssue, UpdateIssue) failed with an untyped
`json: cannot unmarshal number ... revision of type string`. S0's
string-or-number tolerance (problem.go's legacyRevisionFields) only covered
the problem+json error path, never the success path.

Adds revision_tolerance.go: a pre-unmarshal rewrite that walks a response
body and turns a bare JSON number at a "revision" key into its exact decimal
string, scoped to the five apigen response types that carry the member and
gated on the handshake having seen no wire_revision at all. Left
apigen/types.gen.go and the OpenAPI spec untouched (both are
regenerate-and-diff gated by `make api-check`), rather than introducing a
custom Revision JSON type through codegen, to keep the fix's blast radius to
the wire package's own reader.

Updates ClientMinWireRevision's doc comment (handshake.go) to describe
tolerance on both halves of the wire instead of overclaiming the error-path
fix alone covered it. Adds revision_tolerance_test.go: a read (ListReadyWork)
and a guarded write (CloseIssue with ExpectedVersion) against a fake
pre-#6053 server, plus a modern-server control proving the rewrite never
fires when wire_revision is present. Mutation-tested: disabling the rewrite
reproduces the exact untyped UnmarshalTypeError the review reported.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* build(bazel): sandbox internal/httpclient's source-reading tests (Bazel gate green)

Review HIGH #1: the Bazel lane was red because three tests under
internal/httpclient read sibling/cross-package files by relative OS path at
runtime, which bazel test's sandbox does not materialize without an explicit
`data` dependency.

- internal/httpclient/encode/BUILD.bazel: encode_test gets
  data = ["//cmd/bd:go_srcs", "//internal/httpapi/spec:openapi.v0.yaml",
  "//:engdocs/design/http-divergence-ledger.md"] + glob(["*.go"]), covering
  bijection_test.go's cmd/bd scan and ledger_render_test.go's golden-doc read.
- internal/httpclient/wire/BUILD.bazel: wire_test gets
  data = ["//cmd/bd:go_srcs", "//internal/httpclient:go_srcs"] + glob(["*.go"]),
  covering skew_test.go's AST sweep of both trees.
- internal/httpclient/BUILD.bazel gains a go_srcs filegroup via `make
  bazel-sync` (tools/bazel/go_srcs.py): added "internal/httpclient" to the
  script's managed PACKAGES list rather than hand-writing the block.
- internal/httpapi/spec/BUILD.bazel and the root BUILD.bazel gain
  exports_files for openapi.v0.yaml and engdocs/design/http-divergence-ledger.md,
  scoped to //internal/httpclient/encode:__pkg__.
- bijection_test.go's loadPublishedParameters now reads the wire contract
  through spec.OpenAPIV0() (the package's existing go:embed) instead of a
  relative os.ReadFile path, per review suggestion -- the embed makes the
  parameter set reachable without a `data` dependency on the YAML at all; the
  openapi.v0.yaml data entry above stays as defense in depth for any other
  reader the package gains.

Ran via `bazel run //:gazelle` then `python3 tools/bazel/go_srcs.py`
(bazel-sync-check passes). `bazel test //internal/httpclient/...` is fully
green: 3/3 test targets pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(httpclient): scrub private/enterprise infra references from code and docs

Review MEDIUM #3. Provenance headers ("Contributed by gascity from
bd-enterprise...") stay by design -- this removes references to private
infrastructure and unported internals from comment bodies and generated docs:

- wire/doc.go: dropped the internal/enterprise/hostedbeads and
  internal/enterprise/storageprofile build-tag comparison (neither exists in
  this OSS tree) and the dangling citation of the never-written
  engdocs/design/http-client-backend.md, replacing both with an accurate
  description of this package's own build-tag-free status and a pointer to
  the divergence ledger that does exist.
- credential.go: CredentialProvider's doc no longer names gwauth/DPoP/gateway
  auto-detection by their private spelling; describes the interface generically.
- ca.go: dropped "cherry-to-AWS RTT" (generalized to "a typical cross-region
  RTT") and the cmd/bd/enterprise_connect.go file reference (generalized to
  "a `bd connect --ca-file X`-style command").
- ca_permissions_unix.go / ca_permissions_unix_test.go: ~/.config/gascity and
  /etc/gascity example paths replaced with ~/.config/bd and /etc/bd.
- encode/skew_test.go: beads.corp replaced with bd.example.invalid.
- encode/ledger_render.go + ledger_render_test.go: the generated-doc preamble
  and regenerate-hint strings now name internal/httpclient/encode (this
  package) instead of internal/enterprise/httpstore/encode; regenerated
  engdocs/design/http-divergence-ledger.md via `go test
  ./internal/httpclient/encode -run TestDivergenceLedgerDocMatchesLedger
  -update-ledger-doc` rather than hand-editing it.

Final grep for enterprise/cherry/gascity/corp/gwauth under internal/httpclient
and engdocs turns up only: provenance headers (kept deliberately), this
session's own "no bd-enterprise source copied" disclaimers, and a handful of
generic "enterprise-tagged"/"enterprise server" references describing a
build-tag or commercial-tier server concept in the abstract -- none name a
private host, path, or credential.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(httpclient): review LOW items -- S3 TODO, env-driven CA test, lockstep doc

Review LOW #4-#6:

- wire/skew_test.go: TODO(S3) on the branch where the cmd/bd AST sweep is
  vacuous (no store/dial wiring yet), naming the slice that closes it.
- ca_wrong_ca_test.go: TestTransportForWrongCAViaEnvRefusesTheTLSHandshake,
  the BEADS_HTTP_CA_FILE env-driven sibling of the existing direct-CAFile
  wrong-CA test -- same live-TLS refusal, resolved through resolveCAFile's
  host-scoped env syntax instead of Target.CAFile.
- vocabulary_test.go: expanded the ClientWireRevision/CurrentWireRevision
  comment to explain why this repo holds them in strict lockstep (client and
  server ship from the same commit) rather than merely <=, distinguishing it
  from the real cross-version compatibility ClientMinWireRevision exists for.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient/wire): re-review HIGH-a/b -- cover IssueDetails, stop recursing into metadata

HIGH-a: the legacy-revision set was missing apigen.IssueDetails (GET
/v0/beads/issues/{id}'s body, an alias for types.IssueDetails that a grep for
"type ... struct" never sees). getIssue is a baseline op that can dispatch
with no cached handshake at all, so serverPredatesRevisionStrings now treats
"no snapshot" the same as "WireRevision == 0" instead of only the latter.
revisionBearingResponse's set is now pinned exhaustively against
internal/httpapi/wireshape/testdata/golden.json -- the same committed digest
TestWireShapeDigest guards -- by a new test
(TestRevisionBearingResponseCoversEveryWireShapeSchemaWithARevisionMember), so
a future schema gaining a `revision` member can't silently miss coverage
again. New coverage: both "with" and "without" a prior handshake for getIssue,
and an explicit items[].revision test for ApplyBatchResponse.

HIGH-b: the previous fix recursed into every nested object looking for a
bare-number "revision" key, which reached caller-owned blobs like
CloseIssueResponse.issue.metadata -- real user data shaped like
{"revision":3} came back silently coerced to a string, on every server the
broadened gate above now also covers. tolerateLegacyRevisionNumbers no longer
recurses at all: it rewrites only the body's own top-level "revision", and,
for *apigen.ApplyBatchResponse specifically, each item's top-level
"revision" in the top-level "items" array. New
TestCloseIssueLegacyRewriteNeverTouchesIssueMetadata proves a metadata
document with "revision" keys at three nesting depths round-trips
byte-for-byte unchanged.

Mutation-tested both guards by hand (not committed): dropping the
IssueDetails case turns TestRevisionBearingResponseCoversEveryWireShapeSchemaWithARevisionMember
and both getIssue tests red with the exact missing-coverage/decode-failure
messages; reinstating a fully recursive rewrite turns
TestCloseIssueLegacyRewriteNeverTouchesIssueMetadata red, showing the
metadata's revision keys silently rewritten at all three depths. Both
reverted clean before this commit.

internal/httpapi/wireshape/BUILD.bazel and internal/httpclient/wire/BUILD.bazel
export/declare testdata/golden.json as data for wire_test's new exhaustiveness
test.

Verified: go test ./internal/httpclient/... (ok, one pre-existing unrelated
flake in ca_wrong_ca_test.go confirmed not reproducible across 8 reruns),
golangci-lint run ./internal/httpclient/... (0 issues), make api-check (no
apigen drift), bazel test //internal/httpclient/... //internal/httpapi/wireshape/...
(5/5 PASSED).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): stop the wrong-CA TLS tests racing Happy Eyeballs

Root cause: startServer rewrites its httptest TLS server's URL to the
hostname "localhost" so SNI is actually sent, but the server itself only
binds 127.0.0.1. net/http's default dialer does RFC 6555 Happy Eyeballs
for a hostname with more than one address family, racing a tcp6 dial to
::1:<port> against the real tcp4 dial. On this host, many unrelated
processes (JVM tooling) are bound to high ::1 ports, so the tcp6 race
occasionally "won" against a listener that had nothing to do with the
test, and the client spoke TLS to it instead -- surfacing as "tls: first
record does not look like a TLS handshake" rather than the expected
x509.UnknownAuthorityError. Confirmed via ss -tlnp captured at the moment
of failure (a java process holding the exact port raced) and via an
immediate manual redial to 127.0.0.1 on that port succeeding against the
real, still-live test server.

Fix: forceIPv4Loopback (new shared helper in ca_test.go) rewrites the
returned *http.Transport's DialContext to dial tcp4 only. SNI and the
request Host are unaffected, since crypto/tls and net/http derive both
from the URL, never from which address family carried the bytes. Wired
into every TLS fixture test in the package (ca_wrong_ca_test.go's three
tests, and ca_test.go's rotation test) -- grepped the rest of the repo
for the same "rewrite to localhost for SNI" pattern and found no other
occurrences.

Also fixed a latent bug this surfaced: TestTransportForWrongCAViaEnvRefusesTheTLSHandshake
called TransportFor(Target{}) with a nil BaseURL, so caHostMatches always
returned false and the CAFileEnv path was never actually exercised --
the nil RoundTripper was silently masked by http.Client's fallback to
http.DefaultTransport, which also failed to verify (via system roots)
for an unrelated reason. Now passes Target{BaseURL: u} so the test
exercises the host-scoped env-resolution path it documents.

go test -race -count=50 -run WrongCA: 8/8 clean. Whole package
go test -race -count=20: clean, twice. bazel test, golangci-lint,
make api-check: all green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(httpclient): repair CI-red tests and apply review fixes (adopt-pr #7210)

Three defects on the contributor head, none of them present on the base:

- test/docsync's TestEngdocsAndRootMarkdownLinks fails: the generated
  divergence-ledger doc links http-client-backend.md, an architecture
  spec this repository does not carry. Name it in a code span instead,
  in ledgerDocPreamble, and regenerate the doc (-update-ledger-doc).

- TestCAFileHygieneRefusesGroupWritableFile fails under umask 022:
  os.WriteFile's 0o660 passes through the umask, so the file lands 0640,
  is never group-writable, and TransportForFile accepts it. Chmod it
  explicitly. Its acceptance twin had the same gap on its file (only the
  explicitly chmodded directory reached the user-private-group
  exception), so chmod that file too: a mutant that drops the exception
  for files alone passed the old test under umask 022 and fails the new
  one.

- That acceptance twin calls the unix-only isUserPrivateGroup from
  ca_test.go, which carries no build constraint, so the package's tests
  do not compile for GOOS=windows. Move it, otherwise verbatim, into
  ca_permissions_unix_test.go beside the other isUserPrivateGroup tests.

Review fixes (iteration 1):

- Encode dispatched through nine case arms of op/shape conjunctions
  (cyclomatic 24). Switch on an (op, shape) struct key instead, and move
  the getIssue and search-bridge arms into encodeGetIssue and
  encodeSearch. The arms are disjoint, so dispatch and every error string
  are unchanged. Cyclomatic 24 -> 10.

- EventStream.Next kept four accumulators and the per-field switch in
  one loop (cognitive 27). Gather the accumulators into sseEvent and
  fold each field line, per-event cap included, in applyField. Next
  cognitive 27 -> 12; applyField is 11/11.

- The CA hygiene walk joined a relative symlink target onto the textual
  containing directory, so with a/link -> ../b/c and b/c/x -> ../y it
  resolved a/y where the kernel opens b/y: a valid CA was refused, or a
  hygienic file at a/y was checked and read instead. readLinkTarget joins
  onto the directory's EvalSymlinks path, taken after that directory's
  own ancestors passed the hop-by-hop check. The regression test plants
  a decoy at a/y; a lexical-join mutant reads it and fails.

- SaveTarget wrote a relative CAFile that every later LoadTarget
  refuses. Both now go through checkCAFileAbsolute, so SaveTarget refuses
  first, with LoadTarget's own message, and writes nothing.

- Document the cached transport TransportFor and TransportForFile return
  as shared and read-only.

Review fixes (iteration 2):

- The walk still dropped a ".." inside a symlink target textually:
  filepath.Join cleans a relative target, and an absolute target's
  ancestors come from filepath.Dir, while the kernel takes that ".."
  from wherever the component before it really leads. Both reviews
  rated the relative leaf as a wrong-file read, and it is one: with
  x/d -> ../e/s, x/L -> d/../y read a decoy at x/y where the kernel
  opens e/y. The other three shapes are hygiene bypasses: an absolute
  leaf target x/d/../y, and an ancestor link to d/../dir or x/d/../dir
  with the CA at x/L/y, each read a file in a world-writable e that the
  walk never checked. readLinkTarget now refuses a target with a ".."
  after any other component, relative or absolute; a leading run of
  ".." is still taken from the directory's physical path. The test pins
  all four shapes behind a control that refuses e/y named directly, and
  a table pins hasInteriorDotDot's boundary. Mutants that drop the
  refusal, limit it to relative targets, refuse every "..", or count
  "." as a component each fail.

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>
2026-10-05 02:58:34 -07:00
Julian Knutsen
0773e6334e
docs(agents): contributor-only agent instructions and documented-issue intake (#7223)
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>
2026-10-05 08:43:53 +00:00
Julian Knutsen
cdda0dffa5
test(cmd/bd): drop dead unsupported-storage test, CWD-independent bd fallback build, stop BEADS_DIR leaking between in-process runs (#7171)
* 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>
2026-10-03 23:44:37 -07:00
Julian Knutsen
1137aeb70d
ci(bazel): embedded-Dolt tier 20/5 → 50/15 duration-balanced Bazel shards (F1) (#7156)
* 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>
2026-10-03 21:30:03 -07:00
Julian Knutsen
84ce244857
ci: same-repo Linux/Windows PR jobs on Blacksmith with main-seeded warm build caches (F7b) (#7155)
* ci: move same-repo PR Linux/Windows/macOS legs to Blacksmith, shard preflight (F7b)

PR-path jobs for same-repo PRs/merge_group now run on Blacksmith instead
of GitHub-hosted runners, following F4/F7a's ternary-expression and
restore-only-cache patterns; forks/Dependabot are unaffected:

- scripts-go-checks, pr-lint-wrapper: same-repo Blacksmith 4vcpu Linux.
- check-doc-freshness-platforms, pr-preflight-platforms: restructured
  from a top-level matrix.os list to an include:-only "matrix marker"
  shape (runner: same-repo-linux/-windows/-macos) so each host can
  resolve an independent same-repo Blacksmith selection via one chained
  ternary runs-on expression.
- Six standalone Windows jobs (test-windows-liveness,
  worktree-remove-windows, test-windows-small,
  test-windows-liveness-prebuilt, worktree-remove-windows-prebuilt,
  windows-make-shell) move to same-repo Blacksmith Windows
  (blacksmith-{2,4}vcpu-windows-2025, public beta). CGO/mingw-w64 and
  Chocolatey preinstall are unconfirmed on that image; both risks are
  flagged with one-line rollback instructions at the call sites.
- pr-preflight-platforms' Windows leg is split into two shards (common
  steps on shard 1, the three Windows-only heavy steps on shard 2) to
  shorten its critical path; shard 2 downloads Go modules directly
  instead of sharing shard 1's runner/cache.

main.yml gains cache savers for the newly same-repo-Blacksmith PR
consumers, since Blacksmith and GitHub-hosted runners cannot see each
other's actions/cache entries even for identical keys:

- blacksmith-go-build-cache warms the Blacksmith-selection race/non-race
  GOCACHEs scripts-go-checks and pr-preflight-platforms/check-doc-
  freshness-platforms' ubuntu legs need, push-to-main only. Its non-race
  leg shares scripts/ci/warm-non-race-cache.sh with build-artifacts, and
  compiles tools/bazel/run_allowlisted_go_tests.py's allowlisted
  packages via its new --compile-only flag, so the two paths and the
  warm-up can never drift from what they actually run.
- pr-lint-wrapper, go-vet-cache, test-windows gain a venue: [blacksmith,
  github] matrix leg to seed both runner selections pr.yml's
  same-repo-Blacksmith-or-fork-hosted consumers can land on.

Updates the policy-test suite (ci_workflow_test.go,
ci_blacksmith_runner_test.go, pr_lanes_bazel_coverage_test.go) to cover
the new runner selections, matrix-marker shape, shard gating, and cache
topology, including a dedicated inventory/writer check for
blacksmith-go-build-cache.

Deferred follow-up (not done here): sharding check-doc-freshness-
platforms and the standalone Windows jobs, and moving/sharding macOS
legs beyond what check-doc-freshness-platforms'/pr-preflight-platforms'
matrix-marker form already covers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(ci): F7b review response -- msys2/Blacksmith-saver guards, macOS stays hosted (B1/B2/S3)

Addresses ~/beads-bazel-plan/f7b/review.md's two cache-safety blockers and
one follow-up gap found after F7b moved same-repo PR Linux/Windows/macOS
legs onto Blacksmith and added push-to-main Blacksmith cache seeders:

- B1: windows-make-shell's msys2/setup-msys2 step caches its installed
  packages by default, which implicitly SAVED a GitHub Actions cache entry
  from a same-repo PR the moment it ran on a Blacksmith runner (confirmed
  via a real cache-list entry from a refs/pull/.../merge ref). Disabled with
  a fail-closed `cache: ${{ runner.environment == 'github-hosted' }}`, and
  generalized the sweep (TestBlacksmithReachablePRJobsDisableDefaultCachingActions)
  to cover any default-caching setup-* action on a Blacksmith-reachable job,
  not just this one.

- B2: blacksmith-go-build-cache, pr-lint-wrapper, go-vet-cache and
  test-windows (main.yml) had no (or an incomplete) same-repo push-to-main
  guard, so a same-repo fork with push access to its own main could run --
  and save a cache entry from -- a paid Blacksmith job. Added the exact
  push-to-main/same-repo `if:` F7c's own blacksmith-setup-go-cache already
  uses, pinned by TestBlacksmithSaverJobsGuardedAgainstPullRequest.

- S3: the macOS leg of pr-preflight-platforms/check-doc-freshness-platforms
  resolved to Blacksmith for same-repo PRs; Blacksmith bills macOS at
  roughly 20x its Linux/Windows rate and no push-to-main Blacksmith-macOS
  saver exists, so that leg would pay the premium for a guaranteed cold
  cache. macOS now stays unconditionally on GitHub-hosted macos-latest.

Also pins S7 (blacksmith-go-build-cache/go-vet-cache/test-windows's cache
keys are bounded by go.sum+UTC-day, not github.sha) and S6/S8 (their
20-minute timeouts), both already in place but previously unpinned, and
replaces run_allowlisted_go_tests.py's fragile GO_TEST_FLAGS[-2:] slice with
an explicit BUILD_FLAGS constant (N1).

Re-ran the reviewer's 15 mutations (~/beads-bazel-plan/f7b/review/mutate.py):
all now killed or structurally moot (the Windows preflight shard split this
review asked to revert-unless-helpful was reverted, in an earlier commit on
this branch, removing the vulnerability surface 6 of them targeted).

scripts/BUILD.bazel: add the new ci_f7b_review_test.go to scripts_test's
srcs -- bazel test caught it missing (file existed on disk but was not
compiled into the Bazel-built test binary).

Verification: go vet/test/build, gofmt, bazel --nohome_rc test
//scripts:scripts_test, actionlint -shellcheck, shellcheck, make
ci-pr-policy, make bazel-sync-check all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(ci): drop local review-doc path from comment

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>
2026-10-03 17:58:31 -07:00
Julian Knutsen
6e9a15507e
ci(bazel): proxied-server tier 15 → 30 duration-balanced shards; un-hide 12 proxied tests (F2) (#7129)
* 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>
2026-10-03 09:36:05 -07:00
Julian Knutsen
0588af25d1
ci: retire pr.yml's legacy PR Core, build, pure-Go, domain+uow and contract jobs where the gated Bazel lanes run them (D2 step 3) (#7097)
* ci: retire pr.yml's legacy PR Core, build, pure-Go, domain+uow and contract jobs where the gated Bazel lanes run them (D2 step 3)

On same-repo, non-Dependabot pull_requests while the committed
BAZEL_RETIRES_LEGACY_PR_LANES flag is "true" (bazel-coverage's new
pr_lanes output; the job stays identical in pr.yml and pr-risk.yml),
pr.yml's build-artifacts, pr-core-wrapper, check-cmd-bd-puregeo-tests,
test-domain-uow and contract-corpus stand down. ci-gate accepts those
skips only then, and BAZEL_PR_LANES_RETIRED requires the same run's
Bazel test, pure-Go/js-wasm and dolt-server lanes to have run remotely
and passed. Revert: commit the flag "false" in both workflows.

What the retired jobs did besides their tests keeps running on every PR:
- the package gates take bazel-ci-build-artifacts (bazel-test's bd, same
  layout) where build-artifacts stands down;
- the Dolt server fingerprint moves to its own required job;
- the Go tests Bazel does not run or skips (equivalence allowlist) run
  under go test in pr-preflight-platforms' Linux leg, each required to
  pass (tools/bazel/run_allowlisted_go_tests.py).

In mode remote the three lanes' bazel test invocations add
--config=sole-run (no cached test results, no whole-invocation retry on
remote cache eviction), as steps 1 and 2 do for their lanes.

Policy tests: decision matrix and named cases extended to the third
flag, gate simulation for the pr.yml tier, artifact consumers, pinned
lane steps and rc lines, a repo-wide narrowing scan of BUILD rules and
.bzl files, and the allowlisted-test runner.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(ci): record the retired pr.yml PR Core, build, pure-Go, domain+uow and contract jobs in the check topology

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(ci): only pr.yml's workflow env sets a BAZEL_RETIRES_* flag, and only the decision step reads one

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(pr): keep go test ./scripts/..., go test's vet and the Bazel-skipped tests on every PR (D2 step 3 review F1, F1b, F3, L2)

Review of D2 step 3: retiring PR Core removed the only required pre-merge
`go test` of the scripts packages, whose policy tests (the D2 guards
among them) check part or all of their rules under go test only, and
go test's implicit vet for every package (rules_go's go_test runs none).

New required job scripts-go-checks (SCRIPTS_GO_CHECKS), on every PR, in
PR Core's environment (dolt, git and dolt identity, test-env):
- scripts/ci/scripts-go-test.sh: `go test ./scripts/...` with PR Core's
  flags;
- scripts/ci/go-test-vet.sh: `go vet` with cmd/go's defaultVetFlags over
  ./..., policy-tested equal to the running toolchain's list;
- scripts/ci/allowlisted-go-tests.sh, moved here from
  pr-preflight-platforms.

TestBazelOnlySkipsAreAllowlisted also requires every test that runs part
of its checks under go test only (a Bazel-guarded return/continue, or a
go-test-only block that reports failures) to live under ./scripts, the
only packages go test still runs on every PR; and step 3's
TestRunAllowlistedGoTestsScript gets its allowlist entry.

Package gates on a covered PR whose Bazel call did not run remotely (the
farm switch off) now fail in their own step naming
BAZEL_PR_LANES_RETIRED instead of on a missing artifact (L2).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(ci): record scripts-go-checks, the skip-allowlist check and the re-run-safe uploads for D2 step 3

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>
2026-10-02 06:08:52 -07:00
Julian Knutsen
fe6bd6301f
ci: fix red nightly (Bazel-skip allowlist, credential helper init); rerun-safe Bazel artifacts (#7096)
* 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>
2026-10-02 05:42:05 -07:00
Julian Knutsen
3789dde785
ci: retire PR Risk's legacy proxied and server-Dolt tiers where the gated Bazel lanes run them (D2 step 2) (#7094)
* ci: retire PR Risk's legacy proxied and server-Dolt tiers where the gated Bazel lanes run them (D2 step 2)

On same-repo, non-Dependabot pull_requests, PR Risk's test-proxied-cmd (15),
test-server-storage and test-server-storage-full (16) jobs stand down while
the committed BAZEL_RETIRES_LEGACY_DOLT_SERVER_TIERS flag is "true" (in both
pr.yml and pr-risk.yml, policy-tested equal); pr.yml's gated Bazel
proxied-server and server-Dolt storage lanes are then the tiers' only
pre-merge run. build-embedded, whose embedded-test-binaries artifact feeds
exactly the six retired legacy test jobs, stands down where both D2 steps
apply.

Generalizes step 1 instead of copying it:
- bazel-embedded-coverage becomes bazel-coverage (identical in both
  workflows): one decision step, outputs embedded and dolt_server, each
  flag && pull_request && !fork && actor != dependabot[bot]; gate id
  BAZEL_COVERAGE.
- PR Risk's gate accepts the retired jobs' skips only when their output is
  true, and BUILD_EMBEDDED's only when both are.
- pr.yml's gate adds BAZEL_DOLT_SERVER_RETIRED: red when dolt_server is true
  and the mode is not remote or BAZEL_PROXIED / BAZEL_SERVER_STORAGE is not
  success (shared helper with BAZEL_EMBEDDED_RETIRED).
- Lane hardening as for embedded: --nocache_test_results for
  doltserver-proxied and doltserver-integration, the flaky-target query,
  check_shard_coverage.py (proxied 15 shards; server full suite 16 shards
  plus --whole conformance), pinned test steps, rc lines and target
  args/env; the shard listings now run concurrently (the server script
  forks per test).
- Policy tests generalized over the retired tiers: decision equivalence
  with bazel.yml's mode across two runs, both gates simulated, flag
  equality, artifact consumers, real shard scripts in list-only mode.

Revert: commit BAZEL_RETIRES_LEGACY_DOLT_SERVER_TIERS: "false" in both
workflows.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(ci): record the retired legacy proxied and server-Dolt tiers in the check topology

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): no whole-invocation retry on remote cache eviction in the retired tiers' lanes

Review F1 (D2 step 2): Bazel 9 re-runs a whole `bazel test` invocation
(--experimental_remote_cache_eviction_retries, default 5) when an input was
evicted from the remote cache, and that exit code outranks a test
failure. With --nocache_test_results every test runs again and only the
retry is reported, so a flaky failure in the embedded, proxied or
server-storage lane (each now its tier's only pre-merge run) could turn
green. Set the retries to 0 in test:embedded, test:doltserver-proxied and
test:doltserver-integration (not remote-exec, which must stay key-neutral),
pin the lines, forbid any other line or the setup-bazel action from
setting the count, and correct the topology doc, which claimed the retry
never re-runs a failed test.

Reproduced against a local HTTP cache emptied mid-build: with the default
the build hit "Lost inputs", retried and exited 0; with 0 it failed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(ci): pin how the retired lanes' shard scripts run their tests

Review F2 (D2 step 2): the narrowing scan covered tools/bazel and the
setup-bazel action but not the four .github/scripts/*-test-shard.sh
scripts the sharded targets execute, so appending -test.short to an exec
line or exporting BEADS_TEST_SKIP there passed the policy tests (and
check_shard_coverage.py only rejects a shard that is entirely skipped).
Pin each script's prebuilt-binary and go test fallback commands exactly
and its RUN_REGEX construction, and forbid anything else in the scripts
from running tests or selecting, skipping or switching them. The scripts
themselves are unchanged (the legacy jobs run them too); a self-test
checks that six narrowing edits are rejected.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(ci): simulate a non-true coverage decision per retired tier

Review F3 (D2 step 2): the "decision succeeded but its output is not
exactly 'true'" gate scenarios set both bazel-coverage outputs bad at
once, so the embedded ids reddened the gate whatever the dolt_server rule
said, and weakening PR Risk's gate to `!= "false"` for one tier passed.
Run them per tier, with the other output a valid "false" and only that
tier's job skipped, and isolate build-embedded's both-true rule the same
way. Failed or cancelled decisions keep the all-skipped scenarios.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(ci): list Bazel tier coverage and the proxied/server-Dolt checks as not directly required

Review F4 (D2 step 2): the topology doc still named the renamed
`Bazel embedded coverage` job, and its list of check names not to require
directly lacked the proxied and server-Dolt test jobs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(ci): skip the real shard-script listing test on bash < 4

The CI shard scripts use associative arrays and only run on Linux runners;
macOS's /bin/bash 3.2 can't execute them.

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>
2026-10-02 02:20:30 -07:00
Julian Knutsen
46e670abbf
ci: retire PR Risk's legacy embedded tier where the gated Bazel lane runs it (D2 step 1) (#7071)
* ci(pr-risk): stand down legacy embedded tier where the gated Bazel lane runs it

D2 step 1. A new bazel-embedded-coverage job decides, from the same
expressions as bazel.yml's rbe job, whether pr.yml's Bazel call takes
execution mode remote on a same-repo pull_request (RBE_WEST_WORKERS on,
executor secret present, not a fork). Only then do test-embedded-storage,
test-embedded-conformance and test-embedded-cmd (27 jobs) skip, and PR
Risk's gate accepts those skips only then; a failed or missing decision is
red. Forks, Dependabot, secret-less runs, the farm switch unset and
merge_group keep the legacy tier. build-embedded keeps running: its
artifact feeds the proxied and server Dolt jobs.

The decision job reads no repository code and the secret only as an
emptiness test. scripts/pr_risk_bazel_coverage_test.go runs both actual
decision scripts over every event/var/secret/fork combination and requires
covered <=> (pull_request && Bazel mode remote), pins the shared env
expressions, checks pr.yml still requires BAZEL_EMBEDDED and shares PR
Risk's triggers, and simulates PR Risk's gate over every tier/decision.

Revert: unset RBE_WEST_WORKERS.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(ci): record the retired legacy embedded tier in the check topology

Who keeps the legacy tier, how the decision and gate work, the drift
guard, the residual cross-run race, the conformance.yml duplicate, and
how to revert (unset RBE_WEST_WORKERS).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(pr-risk): retire the embedded tier by committed flag; pr.yml gate fails closed

Review F1. PR Risk's coverage decision read the mutable RBE_WEST_WORKERS
variable in a different run from pr.yml's rbe job, so unsetting it and
re-running one workflow could leave both required checks green with
neither the legacy tier nor the Bazel lane having run the tier.

- Both workflows now commit BAZEL_RETIRES_LEGACY_EMBEDDED (policy-tested
  equal) and run the identical bazel-embedded-coverage job:
  covered = flag && pull_request && !fork && executor secret present.
  RBE_WEST_WORKERS is no longer read by PR Risk at all.
- pr.yml's ci-gate requires the job's result (BAZEL_EMBEDDED_COVERAGE)
  and BAZEL_EMBEDDED_RETIRED, which is red when covered but the Bazel
  embedded lane did not run remotely and pass (mode skip included).
- Revert is a commit of the flag to "false" in both workflows; in-flight
  PRs pick it up on their next push. The kill-switch runbook now flips
  the flag first.

Tests run both decision steps, bazel.yml's rbe step and pr.yml's real
gate step over every event/var/secret/fork/flag combination, with the
variable differing between the two runs, and require no double-green
without the tier.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): never cache embedded-tier test results

Review F2. Since D2 step 1 the Bazel embedded lane is the tier's only
pre-merge run on same-repo PRs, so a cached PASS (stale, or a poisoned
entry in the shared farm action cache) or a cached run that never
re-exercises an intermittent -race finding would stand in for the legacy
jobs' -test.count=1 run. test:embedded now sets --nocache_test_results,
and the policy test requires it and forbids any other rc line that turns
test result caching back on.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(ci): forbid flaky-test retries in the gated Bazel lanes

Review F3. Adding --flaky_test_attempts to a lane's config or
flaky = True to a lane target passed every policy test, and would hide
a flaky failure the legacy jobs (which ran each test once) would have
reported; since D2 step 1 nothing else runs the embedded tier on
same-repo PRs. TestBazelGatedLanesNeverRetryFlakyTests rejects
flaky_test_attempts and runs_per_test_detects_flakes in .bazelrc,
.github (workflows, setup-bazel's generated rc) and tools/bazel, and
flaky = True in every BUILD file and .bzl macro.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(ci): pin the Bazel embedded lane's command line and config

Review F4. An extra --test_arg=-test.short/-test.skip on bazel.yml's
`bazel test //... --config=embedded` line, or a test:embedded
--test_filter in .bazelrc, narrowed the tier while every policy test
passed (check_testcases only rejects a shard with zero tests). Since D2
step 1 this lane is the tier's only pre-merge run on same-repo PRs, so:

- bazel-embedded's test step must be exactly the pinned script;
- the --config=embedded lines must be exactly the pinned list, in order;
- no unconfigured common/build/test line, and nothing setup-bazel's
  generated rc writes, may select or narrow tests (test_filter,
  test_arg, -test.short/run/skip, tag/size/lang/timeout filters).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* build(bazel): add the D2 policy tests to scripts_test

scripts/pr_risk_bazel_coverage_test.go was missing from
//scripts:scripts_test's srcs, so `bazel test //scripts:scripts_test`
(and the BUILD-sync check) did not see it. The repository-walking
flaky-retry test skips under Bazel, whose runfiles hold no other
package's BUILD files.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): check every listed embedded test ran in its Bazel shard

Review F5. The shard scripts discover tests from source with grep, but
each Bazel test binary holds only its target's srcs, so a discovered test
the binary lacks matches nothing in the shard's -test.run selector and
passes silently (check_testcases.py only rejects a shard with no tests).

tools/bazel/check_shard_coverage.py runs each shard script in list-only
mode (BEADS_TEST_SHARD_LIST_ONLY=1) and requires every Bazel shard's
test.xml to hold exactly the listed top-level tests: missing, extra,
wrong-shard, shard-count mismatch, missing test.xml and a failing script
are errors. bazel-embedded runs it after the tier for
//cmd/bd:bd_embedded_test (20) and embeddeddolt_embedded_test (5); the
policy test pins the suites to pr-risk.yml's jobs and shard counts, and
a fixture test exercises the script.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(ci): correct the D2 enforcement, re-run and merge-queue claims

Review F6.
- The beads-only ruleset enforces both gates on main only; release/**
  PRs run them but merging does not wait for them, before and after D2.
- There is no merge queue and strict is off: merge_group runs are not a
  pre-merge safety net for the retired tier.
- Spell out "Re-run all/failed jobs" semantics under the committed flag,
  the remaining secret-deletion window, and that the revert needs a new
  push to in-flight PRs.
- Record the lane hardening the retirement relies on (no result caching,
  no retries, pinned selection, per-shard coverage check).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(ci): drop TestMain from the embedded shard-coverage check

Re-review G1 (blocking). embedded-storage-test-shard.sh discovers tests
with `grep '^func Test'`, which also lists TestMain(m *testing.M)
(internal/storage/embeddeddolt/test_fixture_test.go). It is never a
<testcase>, so check_shard_coverage.py reported it missing on every real
remote run, turning bazel-embedded and CI Gate red on every same-repo PR.

The checker now drops NOT_TESTS = {TestMain}. The shard scripts are left
unchanged so the legacy jobs' -test.run selection stays byte-for-byte the
same (dropping TestMain there would be harmless to shard assignment,
which hashes per name, but would touch the legacy CI scripts this step
does not otherwise change).

TestEmbeddedShardScriptsListOnlyRealTests runs both real shard scripts
in list-only mode for every shard and requires each listed name to be a
`func Name(t *testing.T)` in the package, or in NOT_TESTS (which may hold
only TestMain, and only if it is not a test). The fixture shard script
now lists TestMain too, so the filter itself is exercised.

Verified on a real remote run (`bazel test //... --config=embedded
--config=remote-exec`, 4/4 targets, 27 test.xml, 582 top-level tests,
348 s uncached): check_testcases.py and check_shard_coverage.py both
pass (199 cmd + 381 storage tests); the previous checker failed on
TestMain.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(pr-risk): decide embedded coverage by actor, not by the executor secret

Re-review G2. covered still read secrets.RBE_WEST_EXECUTOR, which an admin
can delete between PR Risk's run and a re-run of pr.yml: PR Risk stayed
green with the legacy tier skipped, while the re-run computed covered =
false, took mode local and passed with no embedded lane.

Both workflows' bazel-embedded-coverage now decide
covered = flag && pull_request && !fork && github.actor != dependabot[bot]
and read no secret or variable at all (PR Risk now reads no secret).
Dependabot (no Actions secrets) keeps the legacy tier; github.actor,
unlike triggering_actor, survives a re-run by someone else. A same-repo
PR without the secret is covered, so pr.yml's gate goes red (mode local)
instead of passing.

The two-run test matrix now varies the secret as well as RBE_WEST_WORKERS
between PR Risk's and pr.yml's runs, adds the actor to the facts, and
names the missing-secret case (red). Docs updated: the residual is gone,
the cost of failing closed is recorded.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(ci): close the remaining ways to narrow the Bazel embedded lane

Re-review G3. Skip-inducing edits outside the pinned --config=embedded
lines and command line still passed every policy test (reviewer
survivors m1, m2, m5, m6, m9, m10, m11), and the runtime checks counted
skipped testcases as run.

TestBazelEmbeddedLaneCannotBeNarrowed now rejects:
- any .bazelrc line of a config the lane uses (unconfigured, embedded,
  remote-exec from setup-bazel's rc, and any config they reference) that
  filters, narrows, re-runs or re-routes tests (test_filter, test_arg,
  -test.*, *_filters, test_env=BEADS_TEST*/GO_TEST*/TESTBRIDGE*,
  --config=, cache_test_results, run_under other than test_env, flaky,
  runs_per_test, sharding strategy);
- any import other than the two gitignored try-imports, and any
  committed rc file besides .bazelrc (try-import would load it in CI);
- -test.short/run/skip/list, BEADS_TEST_SKIP, BEADS_TEST_EMBEDDED_DOLT,
  TESTBRIDGE_TEST_ONLY and similar in tools/bazel/*.sh (test_env.sh,
  go_test_manifest_shard.sh, ...) and anywhere in the setup-bazel action,
  and any --config= there but remote-exec;
- any change to the set of embedded-tagged targets or their args/env.

At run time check_shard_coverage.py fails a shard whose top-level tests
were all skipped, and its new --whole option applies the same check to
the unsharded conformance core/audit targets (added to bazel-embedded's
step). The real remote run still passes (no shard is all-skipped today;
one cmd shard has 1 of 9 tests skipped).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* ci(bazel): ask Bazel for flaky test targets before the embedded tier

Re-review G4. The F3 grep wanted a literal `flaky = True`, so
`flaky = _RETRY` (or a macro default) slipped through (reviewer m3).

- bazel-embedded runs `bazel query 'attr(flaky, 1, tests(//...))'` after
  setup-bazel and before the tier, and fails on any result (loading only;
  about 0.2 s warm). Verified locally: with `_RETRY = True` /
  `flaky = _RETRY` on embeddeddolt_embedded_test the query lists it.
- The policy grep now rejects any `flaky =` whose value is not a literal
  False or 0, and TestBazelEmbeddedQueriesFlakyTargets pins the step.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(ci): cover the zero-testcase shard in check_shard_coverage

Re-review G5. Skipping the "listed but did not run" report when a shard's
test.xml has no top-level tests survived the fixture test (reviewer m7);
check_testcases.py catches that shard at run time, but the coverage
check should not depend on it. Two fixture cases: a shard with no
testcases, and one with only a subtest.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* docs(ci): record the G1-G5 embedded-lane hardening in the topology doc

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>
2026-10-01 02:03:46 -07:00