Commit graph

47 commits

Author SHA1 Message Date
Jim Wordelman
a690b0a8c4
fix(metrics): stop failing the reap test on a transient zombie (#6262)
* fix(metrics): stop failing the reap test on a transient zombie

startDetached (spawn.go) reaps asynchronously via `go func() { cmd.Wait() }()`,
which is correct: GH#5900's fix already reaps every child, just not
synchronously. Between a child's exit and that goroutine's waitpid, `ps`
briefly reports it as STAT=Z -- the normal kernel process-table lag, not
a leak.

The test's in-loop check faulted the instant it saw "Z" in ps output, so it
was failing on the transient window itself rather than on a child that
actually stays a zombie. Measured on clean main under 32 busy loops (40
probe runs): zombie observed 12/40, never-reaped 0/40, window 5.0-23.4ms --
wider than the loop's own 20ms poll spacing, so the false positive was
guaranteed to land sometimes. Reproduced at ~14% (13/90 failures) building
`go test -c ./internal/metrics` and running under nproc busy loops, matching
the exact failure text seen in CI.

Remove the in-loop check and stop binding its now-unused `st`. The
post-loop 3s-deadline assertion already covers the real regression: a
child that STAYS a zombie keeps `alive` true, so the loop spins to the
deadline and fails there instead. Verified that path still works by
temporarily swapping startDetached's Wait goroutine for the old
`cmd.Process.Release()` (pre-GH#5900) reap -- the test fails 3/3 with
"still present after 3s" -- then reverting.

Before: 13/90 failures under load. After: 0/90.

Agent-Signature: claude-code-claude-sonnet-5-unknown-reasoning on behalf of Jim Wordelman

* docs(release-gates): PASS 7/7 — be-3vzut (transient zombie flake in TestStartDetachedReapsExitedChild)

Independently re-verified review bead be-5gizx's evidence for the fix
built in be-kh65q (root-caused by investigator bead be-heifp's PR #6147
triage): full-suite make test re-run at the deploy SHA (6348 PASS/0
FAIL/2104 SKIP, all SKIPs pre-existing Dolt/embedded/proxied opt-in
gates), diff-owned test independently isolated and confirmed PASS,
regression-catch re-verified (3/3 fail on reintroduced bug, 0/90 under
load after fix vs 13/90 before), gofmt/vet clean, 0 divergence from
origin/main. Criterion 7 (ancestry scope) carries a bounded mayor
waiver (gm-wisp-9mtr84) — see the gate file for full reasoning.

Agent-Signature: claude-code-claude-sonnet-5-unknown-reasoning on behalf of Jim Wordelman

* docs(release-gates): record opened PR #6262 for be-3vzut

Agent-Signature: claude-code-claude-sonnet-5-unknown-reasoning on behalf of Jim Wordelman

* docs(metrics): reword reap-test doc comment to persistence framing

The function doc comment still asserted the absolute invariant this PR
repudiates -- "startDetached must reap it so `ps` never reports STAT Z
under this process" -- which contradicted the new in-loop comment and
invited a future maintainer to re-add the removed in-loop Z fatal,
reintroducing the flake. Reword to the persistence framing already used
by startDetached's own doc comment (spawn.go:210-211, "never left as Z
under this process") and state explicitly that a transient Z is the
normal reaped-child path.

Comment-only; no behavior change. Review fix for the sole actionable
finding in the #6262 review synthesis (minor, claude+gemini).

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

---------

Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 18:16:35 -07:00
Jim Wordelman
2bb1e20de0
Phase 1: additive schema + migration slot claim for versioned beads (#6134) (#6304)
* test(feat): red — Phase 1: additive schema + migration slot claim - gastownhall/beads#6134 (refs be-hs42e.2)

Failing tests for the versioned-beads Phase 1 schema (issue_versions,
store_epoch, issues.current_revision), written before the migration file
exists so MigrationSQL("0067_add_versioned_beads_schema.up.sql") and
LatestVersion()==67 both fail RED. Confirmed via
`go test ./internal/storage/schema/...` (pipefail set — the molecule's own
`$TEST_CMD | tee` template misreports success without it, since `tee`'s
exit code masks a failing pipeline stage).

* feat: green — Phase 1: additive schema + migration slot claim - gastownhall/beads#6134 (refs be-hs42e.2)

Adds migration 0067: issue_versions (per-issue version log), store_epoch
(store-global epoch singleton, empty until a later phase seeds it), and
issues.current_revision (BIGINT NOT NULL DEFAULT 1). Purely additive, no
DML/backfill, no PREPARE/EXECUTE wrapper (ADD/DROP COLUMN vanishes under
the CLI-bundle path on a pre-2.3 Dolt CLI — see cli_prepared_ddl.go).

Also corrects two wrong assumptions baked into the RED-step test:
- down.sql files are not part of the //go:embed'd FS (only
  migrations/*.up.sql is), so MigrationSQL() can never read one for any
  migration; switched to os.ReadFile, matching
  TestMigration0035HandlesLegacyWispDependenciesShape's existing precedent.
- a plain TEXT column reports information_schema.columns.column_type as
  "text" in this Dolt version, not "longtext" as assumed.

* test(feat): red — Review: Phase 1: additive schema + migration slot claim - gastownhall/beads#6134 (refs be-xrl84)

* feat: green — Review: Phase 1: additive schema + migration slot claim - gastownhall/beads#6134 (refs be-xrl84)

* docs(release-gates): PASS 7/7 — be-dy66n

Phase 1: additive schema + migration slot claim - gastownhall/beads#6134
(deploy bead be-4ka6t). 4 pre-existing, non-diff-owned failure/finding
classes encountered and attributed to their tracker beads (be-9ogs6,
be-irise, be-w4qbu, be-a0dxu) with clause-3 proof; zero diff-owned
failures. PR: gastownhall/beads#6304.

* fix(schema): 0067 mirrors current_revision onto wisps and guards its own raw-SQL replay (refs be-yi9vu, be-hs42e.2)

Both maintainer rulings on gastownhall/beads#6304.

1. current_revision on both planes. wisps gains
   `current_revision BIGINT NOT NULL DEFAULT 1`, identical to issues.
   The semantic asymmetry is kept and written down instead of hidden:
   nothing in Phase 1, 2 or 3 reads or writes the wisps column —
   versioning is an issues-plane contract. What it satisfies is a SHAPE
   obligation. The two planes share column-list-shaped code paths, and
   TestSchemaParityIssuesVsWisps enforces strict column-name parity with
   no exemption list; wisps.row_lock (0054 + ignored/0013) is the
   precedent for a column carried on both planes and meaningful on one.

   wisps is dolt-ignored, so the main-plane ALTER never runs on a fresh
   clone. Ships with the ignored-series twin ignored/0026, per check D of
   scripts/check-migration-hygiene.sh (precedent ignored/0020 for 0060,
   whose absence is how wisps.storage_class missed every fresh clone).

2. Raw-SQL idempotence for the ADD COLUMNs, and the Go-side guard
   removed as redundant. internal/storage/dolt/pr4107_corruption_test.go
   replays the frozen .up.sql bytes from 0046 onward straight through the
   driver onto an already-migrated store, so nothing in
   internal/storage/schema is in that path: every migration >= 0046 has
   to be idempotent as raw SQL on its own, and execMigration0067Body
   could never have covered it. schema.go is back at origin/main.

   The guard is now an INFORMATION_SCHEMA-probed PREPARE per plane, the
   0060/0066 shape. Dolt accepts no unprepared conditional DDL that would
   do the same job — ADD COLUMN IF NOT EXISTS, DROP COLUMN IF EXISTS and
   a top-level IF are all parse errors, and a stored procedure's body
   needs a client-side DELIMITER that the CLI batch path requires and the
   Go driver rejects, so one frozen file cannot satisfy both.

   A PREPARE'd ADD COLUMN vanishes on the pre-2.3 CLI bundle path
   (dolthub/dolt#11345), so it gets the same direct-DDL override
   0060/0065/0066 use: cliMigration0067AddVersionedBeadsSchema, listed in
   cliSubstituteAssumesWispTables because its wisps ALTER is unguarded.

New TestMigration0067ReplaysIdempotentlyAsRawSQLThroughPR4107Harness
proves it through that harness rather than a hand-written double-apply:
runMigrationSQLFilesFrom(..., "../schema/migrations", 46) twice, asserting
the columns stay single, a seeded current_revision survives (a
drop-and-re-add would pass a mere existence check while resetting rows),
and the tables are not recreated.

* review: pin 0067's wisps table-exists sub-guard and scope the rollback hazard

Maintainer review fixes for #6304 (Phase 1 versioned-beads schema). All three
are non-gating findings from the review synthesis; the scorecard approved with
no required changes.

- migration_0067_versioned_beads_test.go: pin the wisps arm's table-exists
  sub-guard. It was neither executed nor string-pinned by any test — the
  full-chain test seeds bounded at v46 and 0047's repair recreates wisps
  before 0067's frozen text runs, so the arm never fires against an absent
  wisps table anywhere in the suite. The pin is on the INFORMATION_SCHEMA
  .TABLES probe rather than the suggested "TABLE_NAME = 'wisps'" literal:
  that literal also matches the adjacent COLUMNS probe, so it stays green
  after the sub-guard is dropped. Verified counterfactually — with the
  table-exists arm removed, the TABLES pins fail and the literal still
  matches.

- 0067_*.down.sql: the header claimed the pre-2.3 PREPARE hazard "never
  reaches this file" because only migrations/*.up.sql is embedded. True of
  the bundle, but a rollback file's consumer is a manual operator, and
  `dolt sql -f` on a pre-2.3 CLI reports success while dropping both tables
  and silently keeping both current_revision columns (dolthub/dolt#11345).
  Scope the claim to the bundle and steer manual rollback to a server
  connection or dolt >= 2.3. The Phase-1 "not a data-loss concern" sentence
  is accurate and is left alone; Phase 2 (#6135) revisits it. Same scoping
  applied to the identical claim in the test's down-side comment.

- initschema_0067_versioned_beads_replay_test.go: the doc comment cited
  TestPR4107Migration0067ReplaysIdempotentlyAsRawSQL, which does not exist.
  Corrected to TestMigration0067ReplaysIdempotentlyAsRawSQLThroughPR4107Harness.

Comment/test-only; no migration semantics change.

---------

Co-authored-by: quad341 <quad341@users.noreply.github.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
2026-09-08 12:47:10 -07:00
Jim Wordelman
14fc79ab4e
docs(release-gates): annotate be-tqwx gate record with be-mv0ww correction note (be-mv0ww.2) (#5890)
* docs: green — Annotate be-tqwx release-gate record with be-mv0ww correction note (do not rewrite verdict) (refs be-mv0ww.2)

* chore: retrigger CI on be-pyt0d gate (be-y9rxv)

PR Policy (wrapper timing) and Upgrade smoke (v1.2.2-rc.1 -> candidate)
failed at ~21:20:3xZ due to a transient proxy.golang.org outage during the
module-fetch phase (stream error: stream ID NNN; INTERNAL_ERROR), not a
defect in the reviewed diff -- root-caused by beads/investigator, see
be-y9rxv. No source changes; empty commit to get a clean CI run on the
same content.
2026-09-02 18:04:11 -07:00
Jim Wordelman
069241019d
fix(dolt): purge dropped databases in bench-store cleanup, with a regression gate (#5792)
* fix(dolt): be-pq5 PURGE dropped databases after DROP

dropBenchDB now calls CALL DOLT_PURGE_DROPPED_DATABASES() after the DROP
so .dolt_dropped_databases/ does not grow across bench samples — fixes
the ~5.6 GB /tmp leak the mayor flagged on the be-s9d bench rerun.

bd dolt clean-databases adds 'benchdb_' to the prefix list and issues a
batched PURGE after the drop loop so the operator-facing cleanup actually
reclaims disk (the gm city has 9.3 GB of dropped DBs that this CLI was
unable to remove).

setupBenchStore / dropBenchDB now accept testing.TB so the new regression
test (TestBenchDBPurgeDoesNotLeak) can drive them from a *testing.T
context. The test counts entries in .dolt_dropped_databases/ via
BEADS_TEST_EXTERNAL_DOLT_DATA_DIR — Dolt 1.86 exposes no SQL view for
the dropped-databases list, so the only signal is the on-disk dir.
Self-skips when the env var is unset.

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

* fix(dolt): be-pq5 PURGE dropped databases (production code, follow-up)

Re-commits the dropBenchDB PURGE call and the bd dolt clean-databases
prefix + post-loop PURGE that 343ed3a6 dropped during pre-commit
gofmt/golangci-lint hook re-staging. Test file already landed in the
prior commit; this brings the production fix in.

See 343ed3a6 for the full be-pq5 description.

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

* test(feat): red — Review: Extract PURGE dropped-database theme onto clean branch off origin/main (refs be-eh6)

Redesign TestBenchDBPurgeDoesNotLeak to run under plain `go test` with no
external server, no BEADS_TEST_EXTERNAL_DOLT_DATA_DIR, and no -short
self-skip, per reviewer round-2 exit_contract option (b): source the
dropped-databases dir from the TestMain-managed shared container directly.

Builds a store against testServerPort (mirroring create_guard_test.go's
idiom) instead of setupBenchStore, since setupBenchStore's
BEADS_BENCH_DOLT_PORT gate (be-cfm3z) is a deliberate firewall never set
in CI. Discovers/counts .dolt_dropped_databases/ via a new
testutil.DoltContainerExec accessor (not yet implemented — this is RED).

RED: build fails on undefined testutil.DoltContainerExec.

* feat: green — Review: Extract PURGE dropped-database theme onto clean branch off origin/main (refs be-eh6)

Add testutil.DoltContainerExec, a minimal accessor wrapping
doltSingletonSrv.container.Exec (the same testcontainers.Container
already reached into by DoltContainerCrashed/DoltContainerCrashError).
This is a deliberate, narrow scope expansion beyond the exit_contract's
two named files: the TestMain-managed Dolt server is a Docker
testcontainer with no host-visible data dir, so exec is the only way to
reach .dolt_dropped_databases/ without reintroducing an external-server
dependency. Matching Windows no-op stub added alongside the package's
existing stubs.

Delete the orphaned uniqueBenchDBName() (dolt_benchmark_test.go): zero
callers anywhere in the repo, fully superseded by benchDatabaseName()
which every real call site already uses. Wiring it into a call site
instead would be change without a motivating bug.

GREEN: go build/vet/gofmt clean repo-wide. Scoped package suite
(-race -short, matching CI's documented command) has zero new failures;
the one pre-existing failure (TestWispSeesCustomTypeRegisteredInTransaction,
ambient port 28231 in use by another project's dolt server) is the known
be-j8e environmental class with zero file overlap against this diff.

Caveat: this sandbox has no Docker daemon access (not in the docker
group; declined to sudo/escalate around a restriction that appears
deliberate), so TestBenchDBPurgeDoesNotLeak itself skips locally via
skipIfNoServer — consistent with every other container-backed test in
this package in this environment, and with the prior round's own
verification note. The Exec-based path is verified by static review and
by mirroring already-proven patterns (create_guard_test.go's direct-
Config-against-testServerPort idiom; DoltContainerCrashed/CrashError's
precedent for reaching into doltSingletonSrv.container); real
confirmation will come from CI, which has Docker.

* deploy(be-vc1m): record real CI PASS for criterion 3

Rebased deploy/be-vc1m-gate onto current origin/main (unblocked by
be-z3iuv landing the PUSH_REMOTE fix) and re-ran CI. The new
test-server-storage-full job (from PR #5836) gave a real, positive,
unambiguous PASS for TestBenchDBPurgeDoesNotLeak on real Docker infra
(shard 4/16, job 96860162658, run 32510110772) -- the exact evidence
class mayor's round-42 ruling required. All 7 gate criteria now PASS.

Bead remains on hold:mayor / human pending mayor's own sign-off --
this commit records the result, it does not lift the hold.

* fix(testutil): demultiplex Docker exec output in DoltContainerExec

Review finding 2. container.Exec returns the raw hijacked Docker stream
unless tcexec.Multiplexed() is passed, so io.ReadAll glued the 8-byte
stdcopy frame header onto every payload. Measured before the fix:

    DoltContainerExec(ctx, []string{"echo", "hello"})
    -> "\x01\x00\x00\x00\x00\x00\x00\x06hello\n"

Any caller that fed the result back into the container — the purge test
feeds it a path read out of find(1) — failed with "invalid argument" on
a prefix it could not see. Finding 1 was masking this one.

* fix(test): stop -xdev hiding the dropped-databases dir from the purge probe

Review finding 1, the blocking one: the test could not fail.

The Dolt image declares VOLUME /var/lib/dolt, so the data dir is a
separate mount from /. Verified in a live container:

    stat -c "%d %n" / /var/lib/dolt   ->  84 /
                                          37 /var/lib/dolt

    # with the directory demonstrably present:
    find / -xdev -maxdepth 6 -type d -name .dolt_dropped_databases  ->  (nothing)
    find /       -maxdepth 6 -type d -name .dolt_dropped_databases  ->  /var/lib/dolt/.dolt_dropped_databases

find -xdev stops at that mount boundary, so findDroppedDatabasesDir
always returned "", the count was always 0, and `post > baseline` was
always `0 > 0`. The comment claiming the data dir was on the root
filesystem had it exactly backwards.

Prune /proc, /sys and /dev explicitly — the reason -xdev was reached for
— instead of stopping at the first mount boundary.

* test(dolt): fail if the bench DROP silently didn't happen

Review finding 3. dropBenchDB only Logf's when its DROP fails, so a
failed drop was also a green run — and it leaks the live database into
the shared container rather than into the dropped-databases dir the
assertion counts, so the test would pass for the wrong reason while
making the leak worse.

Assert absence from SHOW DATABASES after each cycle, via an admin
connection that is not bound to the database being dropped.

* test(dolt): run the purge regression on its own Dolt container

Review finding 4. Five rapid CREATE/DROP cycles were being run against
the container every other test in the package shares. Six sites in this
same package refuse to DROP for exactly that reason
(create_guard_test.go:101 "rapid DROP DATABASE crashes the Dolt test
container"; also cross_project_test.go:107,272, dolt_test.go:242,
schema_skew_test.go:91, store_unit_test.go:49) — so a crash here would
take out unrelated tests, not just this one.

The counting was racy too: both .dolt_dropped_databases and
DOLT_PURGE_DROPPED_DATABASES are server-global, so baseline/post raced
whichever test held the other testSem slot (cap 2) in both directions —
a race that only became reachable once finding 1 was fixed and the
counts stopped being identically zero.

Add StartIsolatedDoltContainerHandle, which returns the per-test
container together with a demultiplexed Exec, and move the test onto it.
Unlike StartIsolatedDoltContainer it does not touch BEADS_DOLT_PORT /
BEADS_DOLT_SERVER_PORT, which are process-wide and would perturb the
sibling tests sharing this process; the existing helper keeps that
behavior for its existing callers.

DoltContainerExec is retired — it was introduced by this branch for this
test, which no longer uses it. Windows stubs follow, with the unused
parameters named `_` (review nit).

Side effect: the test now takes ~21s wall instead of the 108-174s the
reviewer measured, since it no longer contends for the shared container.

* test(dolt): add a positive control so the probe can never go blind again

Findings 1 and 6, hardened. Finding 1 was not really "a wrong find flag"
— it was that a broken probe is indistinguishable from a clean run. The
assertion is `post > baseline`, so anything that makes the probe report
0 for ever makes the test pass vacuously, and nothing in the test
notices.

Before asserting there is no leak, prove a leak would be visible: drop a
throwaway database WITHOUT purging, require the count to rise, then
purge and require it to fall back. If the probe is blind the control
fails immediately and says so, instead of the test passing for free.

Verified by re-introducing the -xdev bug on top of this commit:

    control: dropping "beads_test_purge_control" without PURGE left the
    dropped-databases count at 0 (baseline 0); the probe cannot observe a
    leak, so this test could not fail and proves nothing about dropBenchDB
    --- FAIL: TestBenchDBPurgeDoesNotLeak (2.03s)

* docs(release-gate): retract criterion 3's PASS as evidence and record what replaced it

Review finding 6. The criterion-3 PASS recorded in this gate is a real
CI result that distinguishes nothing: given the -xdev probe bug, the
test read identically whether PURGE worked or was deleted outright.

Record the retraction rather than editing the history out, and state the
standard it missed — mayor's round-42 ruling that "a SKIP is not a PASS"
has a sibling: a PASS that cannot fail is not evidence either. The
24.90s runtime was cited at the time as proof the test was not a stub;
it was real work with an inert measurement wrapped around it.

Criterion 3 now rests on a demonstrated red/green plus an in-band
positive control, so it no longer depends on a hand-run experiment.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-08-24 14:05:03 -07:00
Jim Wordelman
893e42cdaa
perf(export): incremental auto-export via dolt_diff (#5806)
* perf(export): incremental auto-export via dolt_diff

Every bd command that mutates state triggers maybeAutoExport, which
re-serializes every non-infra, non-template issue plus its relational
data to issues.jsonl. On a mature repo with 46k beads (99.5% closed),
that full sweep takes ~110s per trigger and blocks the foreground bd
call, making commands like `bd list` and downstream callers appear to
hang for minutes.

This patches the export in place instead of rewriting from scratch:

- New DiffStore capability interface (internal/storage/diff_store.go)
  returning upserted/removed issue IDs between two Dolt commit hashes.
- DoltStore.ChangedIssueIDs implementation using dolt_diff() unioned
  across issues/labels/dependencies/comments tables. Issue-table removals
  flow to Removed; everything else flows to Upserted. Commit refs are
  validated and inlined since dolt_diff() does not accept prepared
  statement bind params.
- tryIncrementalExport loads the existing issues.jsonl into an
  insertion-ordered map, fetches fresh JSON only for upserted IDs via
  GetIssuesByIDs + the existing bulk loaders, drops removed IDs, and
  atomically renames the result over the old file.
- Falls back to full exportToFile on: no prior commit, missing file,
  store does not implement DiffStore, dolt_diff errors, or the changed
  set exceeds incrementalExportThreshold (5000).
- Full-export paths that run longer than 3s now print an actionable
  stderr warning with the three mitigation levers (bd purge --force,
  export.interval, export.auto).
- saveExportAutoState now writes to a tmp file and renames. The
  previous os.WriteFile leaves a brief O_TRUNC window where a
  concurrent reader sees an empty file, silently parses it as a zero
  exportAutoState, and treats the next run as "no prior commit" - which
  then forces a full export on a repo that would otherwise be
  incremental-eligible.

Safety: upserted IDs that GetIssuesByIDs does not return are NOT dropped
from the export. Treating a fetch miss as a delete is destructive: any
transient fetch hiccup would wipe otherwise-valid records. Real
deletions arrive via changed.Removed from the issues-table diff; only
explicit template/infra filter rejections take items out of the export.

Measured on a 46k-bead repo: 1m48s (full) -> 228ms (incremental with
~5 changed beads). Roughly 470x on the common steady-state path.

Tests (cmd/bd/export_auto_test.go, 8 cases):
- orderedIssueLines insertion-order + in-place replace semantics.
- loadExistingIssueLines parses issues, skips memories, handles
  malformed lines and missing files.
- ChangedIssueIDs detects row modifications, label-only changes, and
  true issue-row deletions with the correct Upserted/Removed split.
- tryIncrementalExport patches changed issues in place, drops deletions,
  drops issues flipped to template between runs, and falls back on
  missing file and threshold breach.

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

* fix(test): stop dolt test-store hang on fallback per-test-DB path (be-fgd)

Root cause: context.Background() in cmd/bd/test_helpers_test.go's
per-test-DB fallback path had no deadline, so a slow (not stuck) full
v0->v65 migration replay could block indefinitely once the shared-schema
fast path fell back. Goroutine dump confirmed the block site: a per-test
dolt.New() sitting in mysqlConn.readWithTimeout/net.Read.

Two-part fix:
- Make the shared-DB fast path succeed reliably instead of always
  falling back: initCmdBDSharedSchema now sets
  schema.SetForceAllowRemoteMigrate(true) around its dolt.New() so the
  v52->v65 migration applies against the ephemeral per-run test
  container (the #4259 remote-migrate gate exists to protect persistent
  remotes, which doesn't apply here).
- Bound the rare/backstop fallback path itself: testStoreOpenTimeout is
  calibrated from a real isolated measurement (219.62s for one full
  migration replay, forced via a temporary diagnostic hook and reverted)
  rather than guessed, giving ~37% margin over that observed duration.

Refs be-hka, be-fgd.

* test(export): red — bulk-seed pool read timeout plumbing (refs be-uoat)

TestNewTestStoreWithReadTimeout_AppliesConfiguredTimeout and the
timeout-aware setupIncrementalExportTestWithReadTimeout wrapper
reference newTestStoreWithPrefixAndReadTimeout, which does not exist
yet (cmd/bd fails to vet/build: "undefined:
newTestStoreWithPrefixAndReadTimeout"). This expresses the be-uoat
round-2 gate's acceptance criterion: the bulk-seed helper used by
TestTryIncrementalExport_ThresholdExceededFallsBack needs a
caller-configurable Config.PoolReadTimeout so it stops flaking under
host contention on the shared-branch MaxOpenConns=1 connection,
without changing the pool timeout for any other test.

* fix(test): green — thread configurable PoolReadTimeout into shared-branch test store helpers (refs be-uoat)

Add newTestStoreSharedBranchWithReadTimeout and
newTestStoreWithPrefixAndReadTimeout, siblings of the existing
newTestStoreSharedBranch / newTestStoreWithPrefix that additionally
thread a caller-supplied dolt.Config.PoolReadTimeout through both the
shared-branch fast path and the per-test-DB fallback.

cmd/bd now vets and builds clean; TestTryIncrementalExport_ThresholdExceededFallsBack
and TestNewTestStoreWithReadTimeout_AppliesConfiguredTimeout both run
(PASS/SKIP per Dolt test-server availability, no compile error).

Existing callers are untouched — newTestStore/newTestStoreWithPrefix
still default to defaultPoolReadTimeout (10s) via internal/storage/dolt.
This only affects the one bulk-seed helper that opts in.

* fix(test): green — assert on returned error instead of subtest propagation in PoolReadTimeout plumbing test (refs be-8wnq)

TestNewTestStoreWithReadTimeout_AppliesConfiguredTimeout's 'unreasonably
short timeout fails fast' case wrapped its expected-to-fail store creation
in t.Run and checked the returned bool. Go's testing package unconditionally
propagates a failed subtest to the parent test and process exit code, so
that pattern could never report an overall PASS even when the PoolReadTimeout
plumbing was working correctly.

Add tryNewTestStoreWithReadTimeout, the dolt.New portion of
newTestStoreWithPrefixAndReadTimeout with the error returned directly
instead of calling t.Fatal. The test now asserts on that error value with
no subtest wrapper for the expected-to-fail branch.

* docs(release-gate): PASS — incremental auto-export via dolt_diff, round 4 (be-y1jo)

Deploy gate re-evaluation for be-hka's incremental auto-export feature,
round 2 of deploy (be-y1jo, superseding be-uoat's criterion-3 FAIL).

Round 3 (be-8wnq) root-caused be-uoat's flake to the pool's 10s default
read timeout colliding with a 5001-row bulk seed under host contention,
and fixed it by threading a configurable PoolReadTimeout (5m for this
one bulk-seed path) through the shared test-store helpers -- soaked 3/3
PASS. Round 4 (be-unlq, commit fc5caadcf) fixed a separate, deterministic
test-logic defect (Go subtest failure unconditionally propagating to the
parent) that round 3 found in the new plumbing-proof test.

Independently re-verified rather than trusted: all 8 diff-owned tests
green against a real Dolt container, including 3 fresh runs of the
previously-flaky test (43.9-45.5s each, zero failures -- 6/6 real-
container passes post-fix combined with round 3's soak). Build/vet/
gofmt clean. Policy lane's one failure independently confirmed
pre-existing and diff-unrelated (.githooks/commit-msg, byte-identical
to origin/main). Ancestry-scope check's single stray-commit flag
independently confirmed a benign artifact of the extraction workflow
(the flagged commit predates be-hka; its 4 files are a strict subset
of the approved 7-file scope).

refs be-y1jo, be-hka, be-uoat, be-8wnq, be-unlq

* test(feat): red — Fix PR #5806 review: incremental auto-export never fires (state hash is not a commit) + memory/owner/format contract breaks (refs be-shbed)

* fix: green — Fix PR #5806 review: incremental auto-export never fires (state hash is not a commit) + memory/owner/format contract breaks (refs be-shbed)

* fix: green — missingJSONLIssueIDsInStore no longer blocks incremental export on proven deletions (refs be-nti0e)

Round 2 fix for bee-ghosttrack's CHANGES_REQUESTED on PR #5806.
TestMaybeAutoExport_SecondRunTakesIncrementalPath_ServerMode regressed
because missingJSONLIssueIDsInStore treated any JSONL-only issue id as
corruption -- including ids a legitimate `bd delete` removed between
exports -- permanently wedging tryIncrementalExport's fast path in
server mode.

missingJSONLIssueIDsInStore now takes the last successful export's diff
anchor (state.LastDiffAnchor) and, for whatever candidates remain after
the existing ephemeral/template/infra-type filtering, asks
ChangedIssueIDs (dolt_diff over issues/labels/dependencies/comments)
whether each was actually removed since that anchor. Proven deletions
are excluded from the missing set; anything not provably deleted still
falls back to the original conservative refusal. No anchor (cold start)
falls through unchanged, same as before this check existed.

Also fixes cmd/bd/export_auto_missing_store_test.go's call site for the
new 3-arg signature, and renames export_auto_test.go's idSet helper to
idSetFromIDs to resolve a rebase collision with PR #5822's own idSet in
stale_embedded_test.go.

refs be-nti0e

* test(export): assert the incremental path ran, not just that a diff was reached (refs be-re1zl)

PR #5806 round-5 review, finding 1. Deleting e2e-b makes it an orphan-guard
candidate, so the guard's own ChangedIssueIDs call satisfies a bare
`changedIssueIDsCalls < 1` check even when tryIncrementalExport falls back to
a full export -- the test passed while proving nothing about the path it is
named for.

Use both oracles the reviewer verified against a real server: an exact call
count of 2 (orphan-guard deletion probe + incremental diff), and
LastDirtyIDs == {e2e-a}, which maybeAutoExport explicitly nils on the
full-export fallback.

* fix(export): require the diff anchor to be on HEAD's history before trusting a removal (refs be-re1zl)

PR #5806 round-5 review, finding 2: "removed since anchor" is not the same
claim as "deleted by bd delete". dolt_diff(anchor, WORKING) reports a row as
removed whenever it is absent at WORKING, which is equally true when the
history moved out from under the anchor -- a CALL DOLT_RESET('--hard', ...),
a branch checkout, or any other data-dir rewind on a shared server. The orphan
guard honoured that as proof of deletion, so auto-export silently dropped a
live record from issues.jsonl: exactly the #4988 corruption class the guard
exists to prevent.

Gate the deletion proof on the anchor still being reachable from HEAD
(CommitExists queries dolt_log, i.e. HEAD's forward history). Fails closed --
a store that cannot answer, or an error while asking, keeps refusing, which is
the conservative pre-existing behaviour.

TestMaybeAutoExport_HistoryRewindDoesNotProveDeletion reproduces the reviewer's
repro (export, create rw-x, export, DOLT_RESET --hard back to the baseline,
export) and fails without this change.

Also records the residual the reviewer noted: an unresolvable anchor (after a
history squash or GC) plus a pending delete is a permanent wedge, tracked by
 #5896.

* docs(changelog): scope incremental export and the delete guard to server mode (refs be-re1zl)

PR #5806 round-5 review, finding 3 and note (b).

- Add the orphan-guard change as its own user-visible entry, including how
  narrow the deletion proof deliberately is.
- State that both the incremental path and the guard are server/DiffStore-mode
  only: EmbeddedDoltStore implements neither DiffStore nor StateHasher, so in
  embedded mode every cycle is still a full export and bd delete still wedges
  auto-export there -- #5896 stays open for it.
- Add the anchor-never-advances caveat: with auto-commit off and nothing
  committing, the diff range grows until the 5000-id threshold sends every
  export back to a full rewrite.
- Stop claiming the memory-record handling "matches full-export behavior
  exactly". It deliberately does not: the full path refuses to overwrite a
  JSONL containing memory lines, the incremental path preserves them verbatim
  and proceeds. Preserving is the better behaviour; say so instead.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-08-22 06:49:19 -07:00
Jim Wordelman
072f0f8799
Fix: CLI/runtime schema parity oracle ignored-column handling + pool-heal cherry-pick (be-krza3) (#5878)
* fix(dolt): make schema parity oracle deterministic and ignored-column-aware (be-0v3l)

TestCLIBundleMatchesRuntimeCommittedSchema failed for two independent
reasons. Cause 1 (a random snapshot category reading as empty on a
freshly migrated store) was fixed in be-itm5. This addresses Cause 2,
the remaining stable failure: leases.granted_node is added by the
ignored migration stream (migrations/ignored/0016_add_lease_granted_node.up.sql),
so it exists in the runtime schema but never in the CLI bundle, and the
oracle's exclusions were all table-level -- none could exclude a single
column on an otherwise main-stream table.

- Iterate committedSchemaSnapshotQueries() in sorted key order in both
  snapshot helpers, instead of ranging over the map directly, removing
  the run-to-run variation in which query hits the DB first.
- Exclude leases.granted_node from the columns query, and extend the
  comment to state that the ignored stream owns both whole tables and
  individual columns on main-stream tables.

Verified live (podman-backed Dolt, DOCKER_HOST=unix:///run/user/1000/podman/podman.sock):
unmodified test fails deterministically 2/2 on the single granted_node
diff (genuine RED, no code change needed to observe it); fixed test
passes 6/6 consecutive -count=1 runs (GREEN).

Agent-Signature: claude-code-claude-sonnet-5-unknown-reasoning on behalf of Jim Wordelman

* test(feat): red — Fix: first read after a migrating store open fails with table-not-found and never self-heals (refs be-itm5)

* feat: green — Fix: first read after a migrating store open fails with table-not-found and never self-heals (refs be-itm5)

* docs(release-gates): be-krza3 gate PASS 7/7 — schema parity oracle + pool-heal cherry-pick

Deploy bead be-krza3, review be-8xjjg (PASS round 2), build be-pouv5.
Commit e0c39aa25b7429ddfc88ca085b78f038b80bf87a rebased onto origin/main
tip d38ac728b (0 conflicts). Pushed to headfork per rig precedent —
origin push disabled, and attempt_bounded_self_rebase's internal push
is still hardcoded to origin (be-z3iuv, unfixed as of this gate despite
a mail claiming otherwise).
2026-08-20 06:35:53 -07:00
Jim Wordelman
6deca80cf2
fix(dolt): remove dead decoy-listener test code, use retry-safe schema init under 10-way contention (#5880)
* feat: green — Fix: multiprocess tests INSERT without issues.description and report OK on zero writes; dolt init has no identity (refs be-kafb)

* test(feat): red — Review: Fix: multiprocess tests INSERT without issues.description and report OK on zero writes; dolt init has no identity (refs be-yzowm)

* feat: green — Review: Fix: multiprocess tests INSERT without issues.description and report OK on zero writes; dolt init has no identity (refs be-yzowm)

* fix(dolt): remove dead decoy-listener test code, use retry-safe schema init under 10-way contention

Round-2 review (be-4oah9) found two blocking issues in
TestMultiProcessSchemaInit_DoltVerify:

1. The "hermetic regression test" decoy listener set
   BEADS_DOLT_SERVER_PORT to its own port, then immediately cleared it
   to "" on the next line before doltserver.Start ran — so the decoy
   was never actually exercised. Removed the dead block; kept the
   actual fix (clearing the ambient env var before Start) with a
   comment describing why it's needed instead of a non-functional
   simulation of it.

2. TestMultiProcessSchemaInit_DoltVerify failed reproducibly on a
   migration-lock-timeout distinct from round 1's port collision.
   Root cause: the test's 10 concurrent goroutines called the raw,
   single-attempt initSchemaOnDB instead of initSchemaOnDBWithRetry —
   the wrapper real bd processes use via store.go's initSchema
   specifically so contended GET_LOCK attempts converge instead of
   one unlucky waiter failing outright. Sibling file
   initschema_concurrent_test.go already uses the retry variant for
   the same kind of contention scenario.

Verified: TestMultiProcessSchemaInit_DoltVerify PASS x3 (incl. once
with ambient BEADS_DOLT_SERVER_PORT set, matching the reviewer's
environment), plus TestMultiProcessSchemaInit,
TestHelperMultiStore, TestMultiStoreConcurrent_{InProcess,Subprocess,
CloseIsolation} all PASS. gofmt/go vet clean.

refs be-4oah9, be-yzowm

* deploy: release gate PASS for be-u8ldr (multiprocess dolt schema-init retry)

Gate evaluated against e2a7bbb90b (reviewed,
be-4oah9 round 3 PASS). All 7 criteria PASS: clean merge vs origin/main,
review PASS present, three-part acceptance criteria met, tests independently
re-run (7 PASS / 0 FAIL / 0 SKIP incl. adversarial ambient-port condition),
policy/lint lane clean, zero open HIGH findings, clean tree, single theme.

refs be-u8ldr, be-4oah9, be-yzowm, be-kafb

* deploy: correct gate criterion-7 evidence to cite full cumulative PR diff

The prior commit's criterion-7 line cited only the round-3 commit's
single-file stat. The actual PR diff (origin/main...e2a7bbb90b) spans
both files touched across the feature's full 4-commit lineage. Verdict
is unchanged (still single-theme PASS); this corrects the evidence
citation to match what actually ships.
2026-08-20 06:31:01 -07:00
Jim Wordelman
735dfc7edb
fix(dolt): hermetic peer-branch naming in TestMergeRecomputesIsBlocked (#5879)
* fix(dolt): green — Blocked-recompute guard fails against real Dolt server (5 tests: repair/dirty-detect/merge) (refs be-mge0b)

TestMergeRecomputesIsBlocked hardcoded a fixed peer-branch name ("bmpeer"),
which is not collision-safe in this shared, leak-prone real-server test
environment: leaked Dolt containers (be-5kkk6, compounded by Ryuk being
disabled under rootless podman) persist their anonymous storage volumes, and
a later container creation can end up attached to a volume carrying stale
state from an earlier run of this same test, including a pre-existing
"bmpeer" branch. Derive the peer branch name from the test's own
already-unique isolation branch instead, and clean it up in t.Cleanup.

* chore: release gate PASS(6/7)+criterion3-pending for be-km2kg (real CI requested)

Deploy source 3e1a002a3 (rebase-recovered from reviewed 160deb601,
blocked_merge_test.go byte-identical). Criteria 0,1,2,3b,4,5,6,7 PASS.
Criterion 3: diff-owned TestMergeRecomputesIsBlocked SKIPs locally due to
independently-reproduced host Docker/containerd corruption
(docker-containerd-content-store-corrupted-2026-08-20) -- not self-graded
per mayor's explicit round-42 ruling on be-vc1m (gm-wisp-5vw1ga: a SKIP is
not a PASS, no waiver). PR #5836 (merged) fixed the CI-lane gap that
originally caused this on be-vc1m; verified this PR's diff triggers
full_embedded=true and server-storage-test-shard.sh reaches this exact
test, so opening this PR should produce a real CI result to finalize
criterion 3.

refs be-km2kg
2026-08-20 06:13:40 -07:00
Jim Wordelman
42483de468
fix: TestMain teardown was dead code after os.Exit — 101 dolt containers leaked over 6 days (#5876)
* test(feat): red — Three TestMains defer TerminateDoltContainer then os.Exit in the same function — teardown is dead code, 101 dolt containers leaked over 6 days and exhausted swap (refs be-5kkk6)

* fix(feat): green — Three TestMains defer TerminateDoltContainer then os.Exit in the same function — teardown is dead code, 101 dolt containers leaked over 6 days and exhausted swap (refs be-5kkk6)

* chore(release-gates): add be-r3ysh gate evaluation (PASS 7/7)

refs be-r3ysh, be-43oyc, be-5kkk6
2026-08-20 06:06:32 -07:00
Jim Wordelman
349e4b029f
fix(dolt): explicit ServerPort must outrank ambient BEADS_DOLT_SERVER_PORT env var (#5835)
* test(feat): red — Fix: explicit Config.ServerPort must outrank ambient BEADS_DOLT_SERVER_PORT env var (refs be-wf9a.1)

* feat: green — Fix: explicit Config.ServerPort must outrank ambient BEADS_DOLT_SERVER_PORT env var (refs be-wf9a.1)

* test(dolt): red — applyResolvedConfig must propagate ServerPortSource (refs be-9tju)

Four new subtests on TestApplyResolvedConfig pin down the reviewer's
security blocker: applyResolvedConfig (open.go:250-255) copies only
doltserver.DefaultConfig(beadsDir).Port into cfg.ServerPort, never
.PortSource/.PortSharedServer. Chained through applyConfigDefaults,
this mislabels any port-file-resolved port as PortSourceCallerExplicit
(the PortSourceUnset guard at store.go:1429 can't tell the difference),
which in turn makes the legacy BEADS_DOLT_PORT env-var override at
store.go:1439 a no-op — a regression of the hq-27t bug class.

Currently failing (RED), for the traced reasons:
- "propagates ServerPortSource...": ServerPortSource stays "" instead
  of "port_file".
- "chained through applyConfigDefaults...never mislabeled": comes out
  "caller_explicit" instead of "port_file".
- "legacy BEADS_DOLT_PORT redirects...": ServerPort stays the
  port-file value (14567) instead of following the env override
  (43211).

A fourth subtest ("genuinely caller-explicit ServerPort still
outranks ambient env") already passes today — it chains through the
same real applyResolvedConfig -> applyConfigDefaults integration path
that the reviewer flagged as uncovered (the existing
TestApplyConfigDefaults_* tests bypass applyResolvedConfig entirely
via a bare &Config{}), locking in that be-wf9a.1's original
caller-explicit-wins intent survives the upcoming fix.

* fix(dolt): green — propagate ServerPortSource so legacy port-env override isn't silently skipped (refs be-9tju)

Two-part fix for the request-changes security blocker on this branch:

1. internal/storage/dolt/open.go applyResolvedConfig: when ServerPort
   resolves via doltserver.DefaultConfig(beadsDir)'s fallback chain
   (env > port file > config.yaml > metadata), propagate the resolved
   .PortSource and .PortSharedServer alongside .Port — mirroring the
   pattern store.go's own fallback block already uses. Previously only
   .Port was copied, leaving ServerPortSource at its zero value
   (PortSourceUnset) even when the port came from an ambient/stored
   resolution like the port file.

2. internal/storage/dolt/store.go applyConfigDefaults: widen the legacy
   BEADS_DOLT_PORT / BEADS_DOLT_SERVER_PORT env-override gate from
   `cfg.ServerPort == 0` to `cfg.ServerPort == 0 ||
   !cfg.ServerPortSource.IsAuthoritative()`. Part 1 alone isn't
   sufficient: the gate only ever checked whether ServerPort was zero,
   independent of whether its source was actually caller-authoritative.

Without both parts, applyConfigDefaults's PortSourceUnset check
(`if cfg.ServerPort != 0 && cfg.ServerPortSource == PortSourceUnset {
cfg.ServerPortSource = PortSourceCallerExplicit }`) mislabeled a
port-file-resolved port as caller-explicit, which then made the legacy
env override a silent no-op for any normal (non-init) bd command
against an already-initialized project — a regression of the hq-27t
bug class, exactly as reported in be-9tju's rejection notes.

A genuinely caller-explicit ServerPort (e.g. bd init --server-port)
still outranks the ambient env var: applyResolvedConfig only stamps
PortSourceCallerExplicit when the caller preset ServerPort before the
call, and IsAuthoritative() is true for that source — covered by the
new "genuinely caller-explicit ... still outranks ambient env" subtest
committed in the RED step (4f4de51618).

Targeted test: go test ./internal/storage/dolt/... -run
TestApplyResolvedConfig -v — all 10 subtests (6 original + 4 new) pass.

Full suite: bash scripts/ci/pr-core.sh succeeded in 345s, zero FAILs,
including both packages that timed out on the prior rejected run
(cmd/bd 288.243s ok, internal/storage/embeddeddolt 255.521s ok) and
both packages this diff touches (internal/doltserver 5.045s ok,
internal/storage/dolt 9.520s ok). Log: /tmp/tdd-green-pr-core.log.

* docs(release-gates): record be-gd3v gate PASS (ServerPort precedence fix)

All 7 criteria clear: review PASS, tests green (-race, 0 skips),
lint clean, no blocking findings, clean tree, clean fast-forward off
origin/main, single theme. PR gastownhall/beads#5835 opened.

* fix(doltserver): stamp a PortSource on the shared-server default port

Review point 1 (blocking), part 1 of 2.

DefaultConfig filled in DefaultSharedServerPort (3308) when shared-server
mode is on and no source resolved a port, but left PortSource unset. That
made a bd-chosen port indistinguishable from a caller assertion: any site
copying DefaultConfig(...).Port into dolt.Config.ServerPort hands
applyConfigDefaults a nonzero port with PortSourceUnset, and the
"nonzero + unset => caller_explicit" inference (be-wf9a.1) stamps it
authoritative.

Add PortSourceSharedServerDefault -- deliberately NOT authoritative, since
bd picked it on the user's behalf exactly like the port file -- and record
it on that fill. TestDefaultConfig_NonzeroPortAlwaysHasSource pins the
invariant the inference depends on: DefaultConfig never returns a nonzero
Port with PortSourceUnset. Verified red before the fix (Port=3308 with
PortSourceUnset), green after.

Propagation at the remaining unthreaded call sites follows in part 2.

* fix(cmd/bd): propagate PortSource at the remaining unthreaded config sites

Review point 1 (blocking), part 2 of 2.

applyConfigDefaults infers "the caller explicitly asserted this port" from
"ServerPort nonzero, ServerPortSource unset" (be-wf9a.1). Round 2 closed
that gap in applyResolvedConfig, but four twin sites still copied
doltserver.DefaultConfig(dir).Port into a hand-built dolt.Config without
the source, so every port bd resolved for itself arrived labeled
authoritative:

  - cmd/bd/main.go resolveDoltServerConnection -- the primary CLI
    store-open path, and the connection `bd serve` builds
    (cmd/bd/uow_factory.go). Its own comment said it mirrors
    applyResolvedConfig; the mirror had gone out of sync.
  - cmd/bd/init.go initPort -- resolves from the env var, the port file,
    or the shared-server default 3308. None of the three is a caller
    assertion.
  - cmd/bd/init.go initGlobalDatabaseConfig -- copied ServerPort forward
    without its source.
  - cmd/bd/doctor/federation.go doltServerConfig.

Consequences, both user-visible: the legacy BEADS_DOLT_PORT override
became a silent no-op on the main CLI path while still working on the
library open path -- the two open paths disagreed on precedence -- and a
stale .beads/dolt-server.port after a crashed server made auto-start
hard-fail with "bd will not silently use a different port than the one you
configured" when the user had configured nothing (GH#4052).

Centralize rather than repeat the three-line copy a fifth time:
dolt.ApplyResolvedServerPort(beadsDir, cfg) resolves port, source and
shared-server flag together, and applyResolvedConfig now uses it too.
init.go keeps its own hand-rolled chain (it deliberately consults only
project-local sources, GH#2336) and tracks the source alongside; `bd init
--server-port` stamps PortSourceCallerExplicit itself, replacing rather
than inheriting the resolved source.

The shared-server default also sets ServerPortSharedServer, mirroring
DefaultConfig: if the shared server is down and auto-start brings up a
repo-local one, that is a different database, so newServerMode still fails
closed -- now with the accurate message instead of one blaming the user's
config.

Tests: TestApplyResolvedServerPort (+ chained through applyConfigDefaults)
and TestResolveDoltServerConnectionPropagatesPortSource assert the source
travels and, directly, that IsAuthoritative() is false for both port-file
and shared-default ports -- that predicate is what both consumers branch
on. Verified red before the fix (ServerPortSource = "" on the CLI path),
green after.

* docs(changelog): record the ServerPort precedence changes

Review point 2. Two deliberate user-visible precedence flips shipped
without a CHANGELOG entry: caller-explicit ServerPort now beats the ambient
port env vars, and the legacy BEADS_DOLT_PORT spelling no longer overrides
a port resolved from config.yaml, Dolt's listener.port, or metadata.json.
Both are intentional, so both are documented, with the migration for the
one workspace shape that changes behavior.

Also notes the GH#4052 failure that goes away with them -- a stale
.beads/dolt-server.port no longer makes auto-start refuse to start over a
port the user never configured -- since that is user-visible too.

Placed at the top of Unreleased/Changed rather than the end: main has been
appending after the existing entry, so inserting before it leaves that
block as common context and the two hunks merge without conflict.

* docs(release-gates): note the be-gd3v gate describes 2dbcbd7f2, not the head

Review point 3 (nit). The gate recorded headRefOid = 2dbcbd7f2 with "no
drift", but the commit adding the gate document was itself the first to
move the head past that SHA, so the claim contradicted itself the moment it
landed. Qualify the line as a snapshot and add a Post-gate history section
listing what has landed since -- including this review round, whose code
changes the criteria walk does not cover.

Corrected by annotation rather than by editing the verdict: the PASS is
still accurate about the SHA it examined.
2026-08-20 05:43:57 -07:00
Jim Wordelman
ac8086429e
fix(cmd/bd): label created_by as 'Created by:' instead of 'Owner:' (#5800)
* test(bd): red — bd show text view labels created_by as 'Owner:' while --json 'owner' is a different field with a different value (refs be-ss66)

* fix(cmd/bd): label created_by as 'Created by:' instead of 'Owner:'

The text view rendered issue.CreatedBy under an "Owner:" label, but a
distinct Owner field (a git author email) also exists on types.Issue
with a different value. Relabel to avoid conflating the two.

be-ss66

* docs(release-gates): add be-3b4e gate record — PASS

bd show text view labels created_by as "Owner:" while --json exposes a
distinct owner field. Review be-r0za passed; independently re-verified
diff-owned test, full-suite + isolated + origin/main-baseline test runs,
and the ci-pr-policy lane. Found and losslessly corrected an unrelated
automated commit that had landed on this deploy branch.

Agent-Signature: claude-code-claude-sonnet-5-unknown-reasoning on behalf of Jim Wordelman

* docs(changelog): record the created_by label change under [Unreleased]

Review ask on PR #5800: this changes a label every `bd show` reader sees,
and the repo logs smaller output changes than this.

refs be-ss66, be-xm0ly

* docs(release-gates): note the be-3b4e gate describes 092947695, not the head

The gate's branch-integrity section claimed the branch held "exactly the two
reviewed commits over origin/main". The review round for PR #5800 added a
CHANGELOG entry and a main merge, so that line no longer describes the head.

Corrected by annotation rather than by editing the verdict: the PASS is still
accurate about the SHA it examined, and no post-gate commit touches
production code.

refs be-xm0ly

---------

Co-authored-by: Jim Wordelman <james@wordelman.name>
2026-08-20 05:31:58 -07:00
Jim Wordelman
5941096915
Fix: check-testing-short.sh flags comments and misnames the offending function (round 2) (#5809)
* test(feat): red — Fix: check-testing-short.sh flags comments and misnames the offending function (refs be-0v13)

* feat: green — Fix: check-testing-short.sh flags comments and misnames the offending function (refs be-0v13)

Skip comment-only mentions of testing.Short() before the allowlist
check: read the exact matched line and treat a line whose first
non-whitespace characters are // as non-offending. Existing
func-attribution logic already reports "unknown" for a hit above the
first func in a file, so no change was needed there.

Also fixes two test-fixture bugs found while confirming RED: the RED
test file's own source contained the literal substring testing.Short()
(now built via string concatenation into a shortCall const so the
checker doesn't flag this file when it scans the real repo tree), and
single-file temp-dir fixtures omitted the grep filename prefix
(now every fixture dir gets a companion .go file so find+grep always
sees 2+ filenames, matching real repo-root invocations).

* test(scripts): red — check-testing-short.sh must not attribute a hit between two functions to the preceding one (refs be-r56j)

* fix(scripts): green — resolve testing.Short() hits to the containing function, not the nearest preceding one (refs be-r56j)

* chore: release gate PASS for be-053u-check-testing-short-round2

* ci: retrigger — unrelated Ryuk reaper flake in storage/uow/tracker job

The "Test (storage domain + uow)" job failed on an infrastructure flake
unrelated to this PR's diff. That job runs three package trees in one
go test invocation (.github/workflows/pr.yml:676), so Go runs their test
binaries in parallel and each starts its own Dolt testcontainer. The
binaries share a single testcontainers Ryuk reaper; in this run the
internal/tracker binary reused a sibling's reaper and its handshake was
reset:

  23:12:21 Reaper obtained from Docker for this test session 6a74346c
  23:12:21 Reaper handshake failed: read ack: ... connection reset by peer

With no live connection holding the session open, Ryuk reaped the
session's containers. The tracker package's Dolt container went down
mid-suite and every subsequent store-backed test failed with
"connection refused" on 127.0.0.1:32772.

This is be-2on, root-caused on a different PR (#5339) with the identical
signature. The durable fix is PR #5770 (disable Ryuk on the Dolt
testcontainer steps), which is open and awaiting upstream merge.

This PR touches only scripts/check-testing-short.sh, its test, and a
release-gate record — nothing in internal/tracker or the Dolt path.
Empty commit to re-trigger CI.
2026-08-19 21:01:15 -07:00
Jim Wordelman
28d65c1329
fix(httpapi): remove flaky race in TestSemaphoreShedsLoadInsteadOfQueueingForever (#5808)
* test(httpapi): red — slow-release acquire must tolerate more than a hair-trigger window

TestSemaphoreShedsLoadInsteadOfQueueingForever's final section shares its
semTimeout (20ms) with the shed-check above it, so the "eventually succeeds"
path only had ~15ms of margin over its 5ms release delay. Bump the delay to
25ms to deterministically prove the current margin is too tight: a release
that beats a merely-adequate window must still succeed. This fails today by
construction, not by chance (refs be-qczn).

* fix(httpapi): green — slow-release acquire must tolerate more than a hair-trigger window

Widen semTimeout to 2s for the "eventually succeeds" section only, leaving
the shed-check above untouched at 20ms. The two assertions were sharing one
field: the shed check needs a short deterministic timeout to stay fast, and
the slow-release check needs enough margin that a loaded runner overshooting
a short sleep can't turn a real success into a spurious ErrBusy. This is not
a blanket bump of the 20ms constant — the busy-path assertion keeps its
original tight window; only the section that was actually racing gets more
room (refs be-qczn).

Verified: go test -count=200, and -count=200 pinned to a single contended
core (GOMAXPROCS=1, 6 competing busy loops) — both clean.

* chore(release-gate): PASS record for flaky semaphore test fix (be-u8o4)

Deployer gate evaluation for be-f80c/be-u8o4: all 7 criteria PASS,
independently re-verified rather than trusted from review evidence alone.
2026-08-19 21:01:10 -07:00
Jim Wordelman
571ab8afe6
fix(cmd/bd): restore os.Stdout via deferred idempotent restore so capture helpers survive t.Fatal (#5803)
* test(feat): red — cmd/bd capture helpers leak os.Stdout on t.Fatal (refs be-leuf)

Add TestCaptureCycleStdoutRestoresOnFatal (dep_cycles_test.go) and the
package-wide TestZZStdioNotLeaked guard (zz_stdio_leak_guard_test.go).
Both express the be-gh02 acceptance criteria before any fix: a capture
helper that restores os.Stdout/os.Stderr on the happy path only leaks
the global when its callback exits via runtime.Goexit (t.Fatal/panic).

RED confirmed: TestCaptureCycleStdoutRestoresOnFatal fails with
"captureCycleStdout leaked os.Stdout after a Goexit"; go vet clean;
0 broken-pipe collateral (the new test restores os.Stdout itself
before failing, so it doesn't poison later tests).

* fix(feat): green — cmd/bd capture helpers leak os.Stdout on t.Fatal (refs be-leuf)

Move every bare stdio-restore in cmd/bd's capture helpers into a defer
registered immediately after assignment, so a callback that exits via
runtime.Goexit (t.Fatal) or panic can no longer leave os.Stdout/os.Stderr
pointed at an orphaned pipe.

- captureCycleStdout (dep_cycles_test.go): restore moved into a defer,
  drain moved to a goroutine so a >64KiB write can't deadlock.
- Both inline os.Stderr captures in dep_cycles_test.go: deferred.
- captureStdout/captureStderr (test_helpers_pure_test.go): deferred,
  stdioMutex discipline unchanged.
- TestCaptureCycleStdoutRestoresOnFatal: drives the leaking callback via
  a goroutine + runtime.Goexit so the suite stays fully green (the fix
  spec's stated alternative to the failing-subtest shape).
- 19-site mechanical sweep across 11 more files: same bare-restore ->
  defer transform, no other restructuring, per spec item 6.

GREEN confirmed: go vet ./cmd/bd/... clean. go test -v -count=1
./cmd/bd/... via scripts/test.sh (beads_test_env_enter,
BEADS_TEST_SKIP=dolt) — EXIT_CODE=0, 0 'broken pipe' occurrences (was
3), 0 FAIL lines, all packages ok. TestRunSyncCommandExitCodeMapping
passes (all 3 subtests), TestZZStdioNotLeaked passes,
TestCaptureCycleStdoutRestoresOnFatal passes. The two dep-cycles tests
(TestDepCyclesNamesTheMembersItCannotDescribe,
TestDepCyclesSaysNothingIsWrongForACleanWorkspace) also pass in this
run — their arming precondition is order/environment-dependent per the
fix spec, so this is not required and does not indicate the fix works
only by coincidentally fixing them; the decoupling is structural.

* docs(release-gates): add be-sr7a gate record — PASS

Review be-1kxq passed; independently re-verified diff-owned tests
(TestCaptureCycleStdoutRestoresOnFatal, TestZZStdioNotLeaked,
TestRunSyncCommandExitCodeMapping) and full ./cmd/bd/... suite
(2389 PASS, 0 FAIL, 0 broken pipe/EPIPE occurrences), plus the
ci-pr-policy lane. .githooks/commit-msg false-failure root-caused
as a local gc-rig worktree shim (same finding as be-3b4e) and
remediated reversibly rather than waived.
2026-08-19 21:01:06 -07:00
Jim Wordelman
7e6641adba
fix: hermeticInitEnv strips metrics guards, racing detached send-metrics child against t.TempDir cleanup (#5797)
* test(bd): red — Fix: hermeticInitEnv strips the metrics guards, letting the detached send-metrics child race t.TempDir cleanup (refs be-xxwt)

* feat: green — Fix: hermeticInitEnv strips the metrics guards, letting the detached send-metrics child race t.TempDir cleanup (refs be-xxwt)

* release-gate: PASS — hermeticInitEnv metrics-guard race fix (be-358n)
2026-08-19 20:41:15 -07:00
Jim Wordelman
30f30ca95b
ci: PR-CI lane runs the full internal/storage/dolt suite against a live Dolt server (#5836)
* test(ci): red — gastownhall/beads: no PR-CI lane runs TestBenchDBPurgeDoesNotLeak against a live Dolt server (checkDolt SKIP) (refs be-aiy5)

* feat(ci): green — gastownhall/beads: no PR-CI lane runs TestBenchDBPurgeDoesNotLeak against a live Dolt server (checkDolt SKIP) (refs be-aiy5)

Add test-server-storage-full as a sibling job to test-server-storage in
pr-risk.yml. build-embedded already compiles every top-level test in
internal/storage/dolt into one binary (embedded-test-binaries); the
existing job only ever runs -test.run '^TestConformance$' against it.
The new job reuses that same artifact and live-server setup with no new
build step, and runs everything else via -test.skip '^TestConformance$'
so previously-stranded tests (TestCreateGuard_*, federation/concurrent
suites, and diff-owned tests such as TestBenchDBPurgeDoesNotLeak on PR
#5792) get a real PASS/FAIL instead of a silent SKIP. Sets
BEADS_TEST_ENV_RUN_DOLT=1 so federation_test.go's own live-server check
fails loudly rather than skipping if this job's setup ever regresses.
Wired into ci-gate: added to needs, CI_GATE_REQUIRED, and the
tier-gated skipped_ok fallback (mirrors test-server-storage's existing
treatment in each).

Also updates two pre-existing meta-tests over pr-risk.yml that pinned
exact snapshots of the file this job necessarily changes:
scripts/ci_capability_selector_test.go's ci-gate authority snapshot,
and scripts/pull_dolt_image_test.go's retry-helper call count
(pr-risk.yml: 2 -> 3, the new job's own Dolt-image-pull step).

* chore: release gate PASS for be-pp7e (PR-CI lane for TestBenchDBPurgeDoesNotLeak)

Deploy gate record for be-pp7e, gating be-aiy5's PR-CI lane addition
(runs TestBenchDBPurgeDoesNotLeak against a live Dolt server instead of
letting checkDolt SKIP it). Review: be-w90n, verdict pass. All 7 gate
criteria PASS; two pre-existing/unrelated failures encountered during
evaluation (be-jy56, be-vf95) were attributed and excluded from the
verdict.

* test(ci): red — shard test-server-storage-full across 16 matrix jobs (refs be-yy25)

TestPRRiskGateReachesFullServerDoltStorageSuite now asserts
pr-risk.yml's test-server-storage-full job is a fail-fast:false matrix
over shard 1..16, with the Test step invoking
server-storage-test-shard.sh, instead of pinning the old single-job
unsharded command. Fails against the current workflow, which still
runs all 1126 tests unsharded in one 15m job (be-extn).

* feat(ci): green — shard test-server-storage-full across 16 matrix jobs (refs be-yy25)

Adds .github/scripts/server-storage-test-shard.sh (mirrors
embedded-storage-test-shard.sh: discovers internal/storage/dolt/*_test.go,
excludes TestConformance, manifest-plus-hash-fallback shard assignment) and
its shard manifest .github/scripts/server-storage-test-shards.txt, pinning
TestCloudAuthCLIRouting (~9.5m) alone on shard 1 and spreading the other
known 10-20s-heavy tests across the rest.

pr-risk.yml's test-server-storage-full job becomes a fail-fast:false matrix
over shard 1..16, Test step now runs server-storage-test-shard.sh instead of
the old unsharded single-job command that died at 256/1126 tests after
15m28s with zero failures (job 95616282508).

Documents the new lane in engdocs/CI_REQUIRED_CHECK_TOPOLOGY.md alongside the
existing embedded matrix description.

TestPRRiskGateReachesFullServerDoltStorageSuite now passes. Offline shard
partition verified disjoint and complete across all 1125 discovered tests
(BEADS_TEST_SHARD_LIST_ONLY=1 for i=1..16). (be-extn)

* test(feat): red — Fix: sharded lane runs prebuilt test binary from repo root, breaking ../schema/migrations and ../issueops (6 tests) (refs be-gepv)

* feat: green — Fix: sharded lane runs prebuilt test binary from repo root, breaking ../schema/migrations and ../issueops (6 tests) (refs be-gepv)

* chore: release gate PASS for be-23f3

Extends deploy/be-pp7e-gate (PR gastownhall/beads#5836) with be-gepv's
fix rather than cutting a fresh isolated branch: be-gepv's own bead
text and be-extn's precedent both establish this fix belongs on the
already-open PR. All 7 gate criteria PASS; two repo-wide lint/policy
failures attributed to already-tracked pre-existing issues (be-vf95,
be-jy56), confirmed untouched by this PR lineage.

be-gepv, be-6yo1, be-23f3

* fix(dolt): federation test isolation + panic (be-3c78s)

TestFederationDatabaseIsolation and TestFederationVersionControlAPIs are
federation-prototype tests that predate the suite's shared-server,
branch-per-test isolation architecture (setupTestStore/StartTestBranch)
and were never updated to account for it.

- setupFederationStore hardcoded Database: "beads" for both towns. New()
  always connects in server mode against one shared Dolt server for the
  whole test binary (TestMain), so Path alone doesn't isolate two stores
  — Database does. Both towns silently shared one database, so Alpha
  could read Beta's issues and vice versa. Give each town its own
  database (beads_test_federation_<prefix>, matching the beads_test AD-01
  cleanup-firewall prefix).

- TestFederationDatabaseIsolation's not-found assertions assumed GetIssue
  returns (nil, nil) on a miss. It never does — issueops.GetIssueInTx
  always returns a wrapped storage.ErrNotFound. Switched to
  errors.Is(err, storage.ErrNotFound).

- TestFederationVersionControlAPIs hardcoded Checkout(ctx, "main") to
  return to its "starting" branch, but setupTestStore already checks out
  a private branch (test-<name>-<hex>) — "main" is a branch shared by
  every parallel test in the binary and never has vc-001. That mismatch
  is what produced the nil-pointer panic (GetIssue's error was discarded
  via `_`, and the resulting nil issue was dereferenced). Capture the
  real starting branch via CurrentBranch() right after setupTestStore()
  and check both previously-discarded GetIssue errors before
  dereferencing.

Neither bug is a production security issue: New(), Checkout(), and
GetIssue() all behave exactly as specified. Both bugs are confined to
this prototype test file's own setup/assertions, which hadn't caught up
to the isolation model the rest of the suite already uses correctly.

Verified via `go build`/`go vet`/`go test -c` (all clean) and running the
compiled binary, which now reaches and cleanly SKIPs both tests (no
Docker locally) instead of the previous isolation failure / panic
surfacing at compile-adjacent runtime. Full GREEN confirmation is via
CI, which has a working Dolt/Docker environment.

Refs be-3c78s

* chore: release gate PASS for be-42tlj
2026-08-19 20:39:38 -07:00
Jim Wordelman
537d00b265
fix(dolt): pin recompute connections to the store's actual branch (#5848)
* test(dolt): red — branch-invariant regression test for recompute connections (refs be-b0am)

Adds TestPinStoreBranch_ReproducesStoreActiveBranch, asserting directly that
a fresh long-timeout connection must be pinned to the store's real
active_branch() rather than defaulting away from it. Fails to compile today:
pinStoreBranch does not exist yet. GREEN step will factor the branch
reproduction already performed by withReadTxLongTimeout into this shared
helper and wire it into recomputeAllBlocked and recomputeBlockedTx.

* fix(dolt): green — pin recompute connections to the store's real branch (refs be-b0am)

recomputeAllBlocked and recomputeBlockedTx each opened a fresh long-timeout
connection and began a transaction on it directly, with zero branch
reproduction. Dolt branch checkout is per-connection session state, so the
fresh connection silently defaulted to the database's default branch
instead of whatever branch the store's pooled session (s.db) was actually
checked out to — a full recompute or a post-merge recompute would then
repair the wrong branch and commit there, exit 0, while the branch the
caller actually cares about kept its stale is_blocked flags.

withReadTxLongTimeout already reproduced the branch correctly (query
active_branch() on s.db, CALL DOLT_CHECKOUT on the fresh connection, falling
back to s.branch only if the query fails). Factored that into a new
pinStoreBranch helper, shared by all three call sites, and gave the two
recompute functions the same single-physical-connection pinning federation.go's
filteredPushToPeer already uses (SetMaxIdleConns(0) + db.Conn(ctx)) so the
checkout and the BeginTx that follows it cannot land on different pooled
connections.

recomputeAllBlockedWithDB/recomputeBlockedTxWithDB now take a small
txBeginner interface (just BeginTx) instead of a concrete *sql.DB, satisfied
by both *sql.DB and *sql.Conn — settlement_commit_boundary_test.go's sqlmock
unit tests keep passing a *sql.DB unchanged.

Audited every other fresh-connection call site (execWithLongTimeout,
execWithLongTimeoutNoTx, pullWithAutoResolveUnchecked, federation.go's
filteredPushToPeer): three are safe by construction (target branch/ref
passed explicitly, not inherited from checkout). pullWithAutoResolveUnchecked
has the same latent hazard on its federation.go:126 peer-pull route (no
branch arg to CALL DOLT_PULL) — out of scope here (needs its own regression
test for a merge landing on the wrong branch), filed as be-5ybd.

Tests: TestRecomputeAllBlocked_{RefusesDirtyIssues,RefusesDirtyDependencies,
AllowsDirtyWisps,RepairsAndCommitsWhenClean}, TestMergeRecomputesIsBlocked,
TestPinStoreBranch_ReproducesStoreActiveBranch (new, be-b0am's direct
branch-invariant regression test) all pass against a real Dolt container.
gofmt and go vet clean.

* chore(deploy): release gate record for be-a8g61

* fix(dolt): correct the pull-path branch audit — all three callers share the hazard

The annotation on pullWithAutoResolveUnchecked claimed store.go's two callers
were safe because they pass s.branch to CALL DOLT_PULL(...). That is wrong:
DOLT_PULL's second positional arg names the remote ref to merge FROM
(doDoltPull binds it to remoteRefName), while the merge target is always the
session's current working branch (CWBHeadRef) — on this fresh
openLongTimeoutConn connection, the database's default branch.

So both store.go callers pin only the source and still merge into the default
branch, federation.go's single-arg route derives source and target from it, and
the GH#3144 DOLT_MERGE(trackingRef) fallback merges into it as well.

Widens the tracked follow-up (be-5ybd) from federation-only to all three call
sites, and records the correct fix (pinStoreBranch before BeginTx) — the bead's
previous suggestion of passing a branch argument would not have moved the merge
target.

Refs be-5ybd.

* docs(dolt): say why the fetch half of the exec audit is safe, not just that it is

The execWithLongTimeout annotation justified both callers with one reason --
"passes its target branch/ref explicitly as a query arg". That is true of
CALL DOLT_PUSH(?, ?), which names the refspec, but not of CALL DOLT_FETCH(?),
which passes only the remote and so has no ref argument to point at.

Fetch is still safe, for a different reason: with no refspec argument dolt
resolves the remote's configured fetch specs (ParseRefSpecs falls through to
GetRefSpecs, which reads remote.FetchSpecs), so the refs come from remote
config rather than session state, and the resulting RemoteRefSpecs write
remote-tracking refs only -- never the working branch.

Naming both reasons keeps the annotation checkable: a later reader can verify
each caller against the reason given for it instead of against a claim that
only holds for one of them.

* docs(dolt): record that pinStoreBranch's active_branch() read assumes a single-conn pool

pinStoreBranch reads the store's live branch with SELECT active_branch() on
s.db, but branch checkout is per-connection session state and s.db is a pool.
Checkout() leases one connection, runs DOLT_CHECKOUT on it and hands it back,
so only that physical connection carries the new branch. The pool defaults to
10 (BEADS_DOLT_MAX_CONNS / dolt.max-conns override it), so on a genuinely
multi-connection pool the read can be answered by a sibling connection still
sitting on the branch it was opened with.

That is not a live defect: the paths relying on this pin run effectively
single-connection, because server-mode stores are pinned to MaxOpenConns=1
for the same session-scoped-branch reason (iter_issues.go). But it is
reliable in practice, not by construction, and the s.branch fallback does not
cover it -- that only fires when the query errors, not when it succeeds with
another connection's answer.

Documented rather than fixed: making it true by construction means taking the
read on a connection the caller already holds, which changes the helper's
signature and its three call sites, and belongs with the pull-path work in
be-5ybd rather than in this bead's regression cycle.
2026-08-19 12:44:06 -07:00
Jim Wordelman
0b2ac312e0
fix(schema): probe cursor table existence before selecting from it (be-bv7x) (#5847)
* test(dolt): red — Fix: failing schema_migrations probe poisons the pooled Dolt session, so the first query after bd init can 404 the whole catalog (refs be-bv7x)

* fix(schema): green — probe cursor table existence before selecting from it (refs be-bv7x)

A Dolt sql-server session that issues a failing statement stays pinned to
its pre-statement catalog snapshot. migrationSource.currentVersion ran a
bare SELECT against the cursor table before it necessarily existed, so on
a fresh database the pooled connection that hit the missing-table error
stayed poisoned for the rest of its life in the pool -- tables created by
migrations afterwards, on other connections, remained invisible to it.

Probe existence first with a query that always succeeds
(information_schema.tables), and only run the original SELECT once the
table is known to exist. The original error-handling path is unchanged
and still covers races.

* docs(release-gate): PASS — schema_migrations pool-poison fix (be-tqwx)

All 7 gate criteria pass on e71d405784.
Review be-43sq PASS; 9/9 tests independently re-verified against a real
Dolt container; gofmt/vet/build clean; single-theme 2-file diff.

refs be-tqwx, be-bv7x, be-43sq

* test(schema,uow): green — repair 37 sqlmock expectations for the be-bv7x cursor probe (refs be-1jha0, be-bv7x)

migrationSource.currentVersion (PR #5847 / be-bv7x) now issues an
information_schema existence probe before every cursor-table read. Prepend
expectCursorProbe to each ordered sqlmock expectation across 9 test files in
internal/storage/schema and internal/storage/uow so the mocks match the new
call sequence. Two tests that previously simulated a missing cursor table via
WillReturnError on the version read now use expectCursorProbe(..., false)
instead, since the probe short-circuits currentVersion to (0, nil) before the
old error-injection point is ever reached. No production code changed — the
probe logic itself is correct; only the stale test expectations were wrong.

Also appends a post-hoc annotation to the be-tqwx release gate (per mayor
ruling) explaining why this gate's criterion 3 could not have caught a
caller-side break outside its diff scope; the durable template fix is tracked
separately as be-mv0ww. Criterion 3's original verdict is left unchanged.

* docs(release-gate): PASS — be-z2ffj deploy-gate evaluation (be-z2ffj, be-pubk9)

Appends the be-z2ffj deploy-gate record to the existing be-tqwx gate
file, following this lineage's established append-only convention.
All 7 criteria PASS; criterion 3's one CI failure (internal/tracker)
attributed to the documented pre-existing Ryuk-reaper testcontainer
flake (be-lrkh), not diff-caused — full 4-point evidence chain in the
new section. Reconciled with the already-open PR #5847 rather than
cutting a duplicate branch/PR, per live repo state overriding the
bead's generic prose (deploy/be-tqwx-gate is not a shared worktree
branch; see reconciliation section).

refs be-z2ffj, be-pubk9, be-1jha0
2026-08-19 09:02:47 -07:00
Jim Wordelman
94fc33990b
fix(testutil): stop dolt test suites from silently opening the ambient shared server (#5837)
* test(feat): red — Fix: dolt test suites open stores on the ambient shared Dolt server, not their testcontainer (refs be-33se)

* feat: green — Fix: dolt test suites open stores on the ambient shared Dolt server, not their testcontainer (refs be-33se)

* chore: release gate PASS for dolt-testcontainer-ambient-port
2026-08-19 08:54:06 -07:00
Jim Wordelman
4274815c6c
Fix E2BIG when runDoltSQL passes large schema SQL as a single argv (#5846)
* test(dolt): red — Fix: runDoltSQL passes 134KB of schema SQL in one argv, past Linux MAX_ARG_STRLEN (E2BIG) - 10 dolt tests red (refs be-go6d)

* feat(dolt): green — Fix: runDoltSQL passes 134KB of schema SQL in one argv, past Linux MAX_ARG_STRLEN (E2BIG) - 10 dolt tests red (refs be-go6d)

* test(dolt): wire TestRunDoltSQLHandlesLargeScript into the default lane (refs be-wq49)

Reviewer follow-up on be-go6d (runDoltSQL argv E2BIG fix): the regression
test proving it lived in git_remote_test.go under //go:build integration,
gated by skipIfNoDolt — which checks for the shared containerized Dolt SQL
server (testServerPort). That test never touches the server, only the
local dolt CLI, so the gate was wrong and the test only ever ran on the
non-blocking nightly cron, never in the PR-gating/merge-gating lane.

Extract TestRunDoltSQLHandlesLargeScript + its runDoltSQL helper into a
new file, dolt_sql_large_script_test.go, with no tag and gated on
testutil.RequireDoltBinary(t) instead. Remove the originals from
git_remote_test.go (kept as a same-package call site — setupGitRemote
still calls runDoltSQL) to avoid duplicate symbols when both files
compile together under -tags=integration.

No production code changes: runDoltSQL's fix was already proven correct
in be-go6d's own tdd_red/tdd_green (cc407e186/fceb1c69a). This closes the
CI-wiring gap only.

Verified: test absent from the default lane before (mechanically-verified
red state via a targeted -run + -v check), present and passing after;
default and integration-tagged compiles both stay duplicate-symbol free;
full ./internal/storage/dolt/... default-lane suite still green with no
regression.

* test(feat): red — Fix: runDoltSQL passes 134KB of schema SQL in one argv, past Linux MAX_ARG_STRLEN (E2BIG) - 10 dolt tests red (refs be-wq49)

TestRunDoltSQLHandlesLargeScript now calls testutil.RequireDoltCLIOnly,
which does not exist yet. This fails the build (RED), proving the test
is not currently gated correctly.

Root cause: RequireDoltBinary conflates "needs containerized
dolt-sql-server" with "needs local dolt CLI only" by honoring
BEADS_TEST_SKIP=dolt before checking for the CLI binary. That env var
is unconditionally set by scripts/ci/lib/test-env.sh's
beads_test_env_enter(), so this test silently SKIPs instead of
running PASS/FAIL in the required pr-core-wrapper CI job — even
though it has no containerized-server dependency.

* feat: green — Fix: runDoltSQL passes 134KB of schema SQL in one argv, past Linux MAX_ARG_STRLEN (E2BIG) - 10 dolt tests red (refs be-wq49)

Add RequireDoltCLIOnly, which checks for the dolt CLI binary but does
NOT honor BEADS_TEST_SKIP=dolt. Extract the shared binary-presence
check into requireDoltBinaryPresent so RequireDoltBinary's existing
behavior (skip on BEADS_TEST_SKIP=dolt, fail under GITHUB_ACTIONS if
missing) is unchanged for its other 20 call sites.

TestRunDoltSQLHandlesLargeScript now gates on RequireDoltCLIOnly
instead of RequireDoltBinary, so it actually runs PASS/FAIL in the
required pr-core-wrapper CI job instead of silently SKIPping — it has
no dependency on the shared containerized dolt-sql-server that
BEADS_TEST_SKIP=dolt exists to exclude.

Verified under bash (matching scripts/ci/pr-core.sh's real shebang
and trap semantics — sourcing test-env.sh into an interactive zsh
session instead triggers zsh's function-local EXIT-trap behavior,
which tears the hermetic env down early; not a bug in the script):

  source .buildflags && source scripts/ci/lib/test-env.sh && \
    beads_test_env_enter && \
    go test -run ^TestRunDoltSQLHandlesLargeScript$ -v ./internal/storage/dolt/...

  --- PASS: TestRunDoltSQLHandlesLargeScript (1.03s)

* release-gate: PASS record for runDoltSQL E2BIG fix (deploy/be-al8j-gate)
2026-08-19 08:51:07 -07:00
Jim Wordelman
19e239d41f
Speed up TestCloudAuthCLIRouting by sharing one Dolt store across cases (#5841)
* test(dolt): red — TestCloudAuthCLIRouting wall-clock regression guard (refs be-4wy3)

Add a 90s wall-clock assertion to TestCloudAuthCLIRouting. Currently
FAILS: the test creates one Dolt database per case (16 total), each
slower than the last as server load grows, pushing wall time past 6
minutes in this run (118-460s+ observed across runs) for a test that
only exercises a pure routing predicate. The GREEN step will
restructure to a single shared store keyed by distinct remote names.

* feat: green — TestCloudAuthCLIRouting single shared store (refs be-4wy3)

Restructure TestCloudAuthCLIRouting to open one Dolt database and give
each case its own remote name (origin_0..origin_15) instead of
creating a fresh database per case. shouldUseCLIForCloudAuth's routing
decision is keyed purely by remote name, so distinct names are enough
to keep the 16 cases isolated within a single store.

TestCloudAuthCLIRouting: 118-460s -> 6.58s in this env. Wall-clock
regression guard (90s threshold, added in the RED commit) now passes.

TestCloudAuthCLIRoutingStructural's two live-server subtests keep
per-subtest fresh stores — their preconditions (no remote configured;
a SQL remote with no local CLI remote yet materialized) aren't
shareable — now documented with a comment explaining why.

No production code changed.

* chore(release): gate record for be-39ss (TestCloudAuthCLIRouting shared-store speedup)

Release gate PASS for the be-4wy3 build (reviewed as be-yxlr): restructures
TestCloudAuthCLIRouting to share one Dolt store across its 16 cases instead
of one store per case, cutting wall time from ~566s to ~6s. Test-only change,
no production code touched.
2026-08-19 08:50:39 -07:00
Julian Knutsen
7505e173f2
chore(release): forward-port v1.2.2 to main (version record, retracts, recovery guide, gate record) (#5782) 2026-08-14 21:45:02 -07:00
Jim Wordelman
02c1d516e2
Fix: wisp delete never cascades to auxiliary tables (orphan row leak) (#5343)
* test(feat): red — Fix: wisp delete never cascades to wisp_labels/wisp_events — 3.03M orphan rows on the city store (refs be-zdqyl)

* feat: green — Fix: wisp delete never cascades to wisp_labels/wisp_events — 3.03M orphan rows on the city store (refs be-zdqyl)

* test(feat): red — Fix: wisp delete never cascades to wisp_labels/wisp_events — 3.03M orphan rows on the city store (refs be-wnuyt)

* chore: release gate PASS for wisp-delete-cascade
2026-08-07 05:42:09 -07:00
Jim Wordelman
9973e96289
fix(test): viper singleton state leak across cmd/bd test runs (#5194)
snapshotBootstrapEnv restores via t.Cleanup (first-registered = last-run, so the snapshot has the final word over later t.Setenv cleanups); pin BEADS_DIR in initConfigForTest/ensureCleanGlobalState; clear BD_BACKUP_ENABLED/BEADS_BACKUP_ENABLED at TestMain; stop the test-only config walk at the module root.

Fixes quad341/be-yjp4z.
2026-07-31 12:48:55 -07:00
Jim Wordelman
f7e3fdad3f
fix(bench): stop dolt benchmarks from leaking test databases onto shared servers (#5029)
* test(feat): red — Fix: Dolt benchmark leaks beads_test_bench_* DBs onto shared prod server (firewall only guards port 3307) (refs be-cfm3z)

Pure-logic regression tests for benchDoltServerPort (not yet implemented,
intentionally RED via compile failure): benchmarks must never resolve
their server port from ambient BEADS_DOLT_SERVER_PORT/BEADS_DOLT_PORT,
since gc agent shells set those to point at a shared production Dolt
server. Tests are network-free by design so RED verification cannot
itself touch the real server.

* feat: green — Fix: Dolt benchmark leaks beads_test_bench_* DBs onto shared prod server (firewall only guards port 3307) (refs be-cfm3z)

setupBenchStore and BenchmarkBootstrapEmbedded no longer resolve their
server port from ambient BEADS_DOLT_SERVER_PORT/BEADS_DOLT_PORT (gc agent
shells set these to point at a shared production Dolt server). Both now:

- scrub the inherited env vars via b.Setenv
- require explicit opt-in via BEADS_BENCH_DOLT_PORT, skipping otherwise
- set BEADS_TEST_MODE=1 and BEADS_TEST_SERVER=1 as backstops
- drop their benchmark database in cleanup via dropBenchDatabase

Verified: full benchmark suite (49 benchmarks/sub-cases) skips cleanly
under default env with zero network I/O; go test/vet green with no new
failures vs preflight baseline.

* docs(release-gates): add gate record for be-cfm3z dolt-bench leak fix

Gate PASS (7/7) for be-k4hyk, deploying be-cfm3z's dolt benchmark
prod-DB-leak fix (reviewed PASS). Independently re-verified all
criteria including a from-scratch test run that surfaced and resolved
a test-environment methodology question (raw go test vs the repo's
hermetic scripts/test.sh wrapper).
2026-07-25 15:40:54 -07:00
Jim Wordelman
3567bf1260
test(cmd/bd): clear baseline gate blockers (#4345)
* test(cmd/bd): fix baseline make-test blockers

Four CGO failures (TestAutoExport*, TestInitNonInteractive*): the pre-built
../../bd binary was compiled with CGO_ENABLED=0 and cannot run embedded Dolt.
Add isCGOBuild() — reads 'go version -m <path>' to detect a statically-linked
binary — and skip it in buildBDForInitTests, falling through to a fresh build.

TestCommitBeadsConfigSkipsGitHooks: TestIgnoreSchemaSkewFlagPropagatesEnvVar
calls rootCmd.PersistentPreRun which sets BEADS_DIR via prepareSelectedCommandContext
without cleanup. savePersistentPreRunState snapshotted globals but not env vars,
so BEADS_DIR leaked across tests and pointed the subsequent commit to the wrong
repo. Add t.Setenv tracking for BEADS_DIR/BEADS_DB/BD_DB to savePersistentPreRunState.

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

* chore: release gate PASS for ga-7psli2.3.1

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-24 01:52:38 -07:00
Jim Wordelman
a9a48d6e36
test(cli,storage): BEADS_MAX_ROWS behavioral + opt-out gate tests (be-x42v) (#4160)
* feat(storage): be-x42v.1 BEADS_MAX_ROWS defensive cap foundation

Add IssueFilter.MaxRows + IssueFilter.MaxRowsSource and a typed
issueops.ErrTooManyRows error. searchTableInTx routes its LIMIT through
EffectiveSearchLimit (LIMIT MaxRows+1 when MaxRows>0, with Limit
preserved otherwise); SearchIssuesInTx checks EnforceMaxRowsCap after
the issues+wisps merge so the cap reflects the count returned to the
caller. Both helpers are exported so future PG-backend support can
reuse the same logic.

Default MaxRows=0 disables the cap and is byte-identical to today at
every existing call site. Limit semantics are unchanged: Limit=0 still
means unlimited at the contract level.

PG backend is not on origin/main yet; PG cap support is a follow-up
when the postgres backend merges. Validator's per-backend bead exercises
the issueops path via Dolt/embedded fixtures.

Refs: be-x42v (designer §3/§6.2), be-jp5s (architecture D1/R-03).

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

* feat(cli): be-x42v.2 wire --max-rows / BEADS_MAX_ROWS on CLI surface

Adds cmd/bd/max_rows.go with three helpers: addMaxRowsFlag registers
--max-rows int with the designer's spec help text, resolveMaxRows
picks flag > env > 0 (negative flag → exit 1, bad env → warn-and-ignore),
and handleMaxRowsError pattern-matches *issueops.ErrTooManyRows to
emit the two-line stderr message and exit 2 with stdout empty.

The flag is wired on bd list, bd ready, bd dep tree, bd find-duplicates,
and bd graph (designer §4). The env-only resolveMaxRowsEnvOnly variant
is wired on bd lint and the SearchIssues paths inside bd doctor
(conventions + pollution checks). bd cleanup, bd gc, bd export,
bd export --auto, bd migrate-issues, and bd jira explicitly set
MaxRows=0 / MaxRowsSource="" in code so a misconfigured env can't
abort a data-integrity sweep partway through.

bd ready needed storage-layer support too: WorkFilter gains MaxRows +
MaxRowsSource and GetReadyWorkInTx routes its LIMIT through
EffectiveSearchLimit and enforces the cap via EnforceMaxRowsCap on
the row count returned to the caller. bd dep tree applies the cap at
the CLI layer on the TreeNode count since the tree walk doesn't go
through IssueFilter.

bd config show gains a standalone-env collector so BEADS_MAX_ROWS
shows up alongside BEADS_DIR etc. when set. The Viper-managed env
detection skips it because BEADS_MAX_ROWS isn't bound to a config key.

Adds a CONTRIBUTING.md section documenting the opt-out rule for new
IssueFilter sites that aren't on designer §4's wired-up list, with a
pointer to the validator's opt-out test gates (be-x42v.4).

Smoke-tested against the rig database (298 issues):
- bd list --max-rows 5 → exit 2, "--max-rows=5"
- BEADS_MAX_ROWS=5 bd list → exit 2, "BEADS_MAX_ROWS=5"
- BEADS_MAX_ROWS=banana bd list --limit 3 → warn + exit 0
- BEADS_MAX_ROWS=5 bd list --max-rows 0 --limit 3 → exit 0
- bd list --max-rows -1 → exit 1, "must be non-negative"
- bd ready --max-rows 5 → exit 2 (storage layer fires)
- bd dep tree be-jp5s --max-rows 1 → exit 2 (CLI-layer count)
- bd find-duplicates --max-rows 5 → exit 2
- bd graph --all --max-rows 5 → exit 2
- BEADS_MAX_ROWS=5 bd lint → exit 2 (env-only)
- BEADS_MAX_ROWS=5 bd export → exit 0, 299 lines (opt-out)
- BEADS_MAX_ROWS=10 bd config show → lists BEADS_MAX_ROWS

The 10 CLI behavioral test scenarios for bd list are owned by
be-x42v.3 (validator). Coverage for the non-list paths, the env-only
doctor family, and config show is filed as be-u8z9 (needs-tests,
routed to validator).

Refs: be-x42v (designer §2-§5), be-x42v.1 (foundation).

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

* chore: release gate PASS for be-x42v.1 + be-x42v.2 (BEADS_MAX_ROWS)

Documents PASS evaluation across the six gate criteria for the
storage foundation (be-x42v.1, 3900c1bdc) and the CLI wiring
(be-x42v.2, dea537c56) shipping together. Review verdicts: be-xf0o
(foundation) and be-2p12 (CLI), both PASS from Opus 4.7 reviewer.

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

* docs: regenerate CLI reference for --max-rows flag

* docs: revert federation to pure-go stub in CLI_REFERENCE.md

CI's check-doc-flags freshness check runs generate-cli-docs.sh with
CGO_ENABLED=0. The previous regeneration used a CGO binary, expanding
the federation section with subcommands. Revert to the requires-CGO
stub that the pure-go binary produces.

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

* docs: revert website federation.md pages to pure-go stub (be-x42v)

Three website cli-reference/federation.md files still had CGO-enabled
content after CLI_REFERENCE.md was reverted. This commit brings them
into sync with the pure-go stub, resolving the Check doc flags freshness
CI failure on PR #3908.

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

* test(cli): be-u8z9 BEADS_MAX_ROWS non-list command paths + config show

Locks down the manually-verified behavior shipped in be-x42v.2 across the
CLI surface beyond `bd list`.

cmd/bd/max_rows_test.go (new):
  - ReadyMaxRows_FlagOverCap_Exits2  - bd ready --max-rows N → exit 2
  - ReadyMaxRows_EnvOverCap_Exits2   - BEADS_MAX_ROWS=N bd ready → exit 2
  - DepTreeMaxRows_TreeNodes_Exits2  - tree-node count cap in dep tree
  - FindDuplicatesMaxRows_Exits2     - find-duplicates --max-rows N
  - GraphAllMaxRows_Exits2           - graph --all --max-rows N
  - LintMaxRows_EnvOnly_Exits2       - bd lint with BEADS_MAX_ROWS=N
  - LintMaxRows_NoFlagAccepted       - cobra rejects --max-rows on lint
  - ConfigShow_ListsBeadsMaxRows     - bd config show surfaces the env var
  - ConventionsMaxRows_EnvOnly       - skipped (bd doctor needs server mode,
                                       follow-up filed as be-pc8c)
  - PollutionMaxRows_EnvOnly         - skipped (same reason)

cmd/bd/ready_max_rows_test.go (new):
  - TestGetReadyWork_MaxRowsSuite — exercises WorkFilter.MaxRows in
    GetReadyWork (under cap / over cap / zero disabled / with Limit
    matrix), via newTestStore. Companion to the SearchIssues parity
    work in be-x42v.3.

Refs: be-u8z9 (this bead), be-x42v.2 (builder), be-pc8c (follow-up).

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

* test(cli,storage): be-x42v.3 BEADS_MAX_ROWS bd list scenarios + backend parity

Covers the 10 CLI scenarios from designer §6.1 against `bd list` and the
5 storage scenarios from designer §6.2 against both Dolt-server and
embedded backends.

cmd/bd/max_rows_test.go (extended):
  TestEmbeddedMaxRowsList — 10 subtests on a shared 21-issue rig:
    - Disabled_NoEnv             (baseline, no cap)
    - Flag_UnderCap              (--max-rows 100 over 21 rows → success)
    - Flag_OverCap               (--max-rows 5 → exit 2, source attribution, empty stdout)
    - Env_OverCap                (BEADS_MAX_ROWS=5 → exit 2, env source)
    - Flag_OverridesEnv          (env=5 flag=100 → success)
    - Flag_Zero_OverridesEnv     (env=5 --max-rows 0 → success, explicit disable)
    - BadEnv_LogsAndIgnores      (env=banana → warning + normal output, exit 0)
    - Negative_FlagRejected      (--max-rows -1 → "must be non-negative", exit 1)
    - LimitSet_CapTighter        (--limit 100 --max-rows 5 → exit 2)
    - LimitSet_CapLooser         (--limit 5 --max-rows 100 → 5 rows, exit 0)

internal/storage/embeddeddolt/search_max_rows_test.go (new):
  TestSearchIssues_MaxRows_{NotExceeded,Exceeded,Zero_NoCap,WithLimit}
  Exercises SearchIssues end-to-end against the embedded backend on a
  6-row fixture, including the four-quadrant (Limit, MaxRows) matrix.

internal/storage/dolt/search_max_rows_test.go (new):
  Identical scenarios against the dolt-server backend. Per-backend
  parity is implicit: both SearchIssues entry points wrap
  issueops.SearchIssuesInTx, so cap behavior is shared by construction.
  Same fixture + same assertions ensures divergence cannot ship silently.

PG backend coverage is deferred until the postgres-backend branch lands
(per PR #3908 description and parent designer notes).

Refs: be-x42v.3 (this bead), be-x42v.2 (builder), be-u8z9 (sibling validator for non-list paths).

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

* test(cli): be-x42v.4 opt-out gate tests for data-integrity commands

Add filterCapturingStore spy and four MaxRows=0 gate tests asserting
that bd export, bd export --auto, bd jira sync, and bd migrate-issues
always construct IssueFilter with MaxRows=0 / MaxRowsSource="" per
designer §4.1 opt-out rule. A BEADS_MAX_ROWS env var on these paths
would corrupt backups, sync state, or migration runs mid-flight.

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

* test(cli): be-x42v.4 add TestExport_BypassesBeadsMaxRows behavioral gate

End-to-end belt-and-suspenders test (designer §6.4): sets BEADS_MAX_ROWS=1,
seeds 5 task issues, runs runExport, and asserts 5 JSONL lines in the output.
Completes the be-x42v.4 acceptance criteria for the bypass behavioral test
alongside the filter-spy gate already committed.

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

* test(cli): be-pc8c server-mode BEADS_MAX_ROWS gate for bd doctor --check={conventions,pollution}

TestDoctorConventionsMaxRows_EnvOnly_Exits2 and TestDoctorPollutionMaxRows_EnvOnly_Exits2
cover the two subtests that were skipped in max_rows_test.go because bd doctor refuses
to run in embedded mode (doctor.go:188). Both tests seed 6 open issues against the
Dolt test server with BEADS_MAX_ROWS=3, assert exit 2, and confirm BEADS_MAX_ROWS=3
in the combined output.

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

* fix(search): enforce MaxRows cap when wisps table is empty

SearchIssuesInTx skipped EnforceMaxRowsCap on the common empty-wisps
path: when filter.Ephemeral is nil/false and the wisps table is empty,
the early `return results, nil` returned before the post-merge cap check.
The issues-only result set (LIMIT cap+1) could exceed MaxRows yet never
trip ErrTooManyRows. Enforce the cap before the early return.

Fixes TestSearchIssues_MaxRows_Exceeded_ReturnsErrTooManyRows and
TestSearchIssues_MaxRows_WithLimit (internal/storage/embeddeddolt).

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

* fix(rebase): re-home BEADS_MAX_ROWS enforcement onto post-rebase seams

Fixes gaps exposed by rebasing PR #4160 onto current upstream/main,
found by actually running the PR's own gate tests rather than just
resolving textual conflicts:

- internal/storage/issueops/search.go: the Q2 perf-escape-hatch
  SkipWisps early return (added by main's search perf work, landed
  after this PR's original design) skipped EnforceMaxRowsCap entirely.
  bd list sets SkipWisps=true by default, so `bd list --max-rows N`
  silently ignored the cap. Enforce the cap on that return path too,
  mirroring the existing empty-wisps-table fix alongside it.

- internal/storage/issueops/search_counts.go: SearchIssuesWithCountsInTx
  (the `--json` query path, already present at the PR's merge-base but
  never wired for MaxRows by the original be-x42v.1/.2 commits) neither
  sized its SQL LIMIT off the cap nor enforced it on the merged result.
  Thread filter.MaxRows through EffectiveSearchLimit for the query LIMIT
  and check EnforceMaxRowsCap in the shared finishSearchIssuesWithCounts
  terminal helper (now returns an error), which every exit path already
  routed through. Fixes be-x42v.3's TestEmbeddedMaxRowsList/Flag_OverCap
  (`bd list --json --max-rows 5`), which failed after the rebase.

- cmd/bd/jira_max_rows_gate_test.go,
  cmd/bd/migrate_issues_max_rows_gate_test.go: seed INSERTs predate
  migration 0049 (LONGTEXT NOT NULL on issues.description/design/
  acceptance_criteria/notes, no default) that landed on main after
  this branch's merge-base. Provide empty-string values for the
  now-required columns.

Not fixed (separate, pre-existing gap; no gate test in this PR
exercises it): GetReadyWorkWithCountsInTx (`bd ready --json` /
`bd list --ready --json`) also doesn't thread MaxRows. Left alone to
keep this rebase to conflict resolution rather than expanding scope;
worth a follow-up bead.

Agent-Signature: claude-sonnet-medium on behalf of maphew

* fix(review): address adjudicated cross-vendor review follow-up (be-x42v.4)

Works the MUST-FIX / SHOULD-FIX list from the adjudicated claude-opus +
codex-gpt-5.6-sol review on the rebase (25e35cc3e), landing coverage gaps
the vendors found in the feature's own promise rather than the rebase
mechanics.

MUST-FIX:

1. internal/storage/issueops/claim.go: ClaimReadyIssueInTx forwarded the
   caller's MaxRows/MaxRowsSource into its internal unbounded
   GetReadyWorkInTx scan, so a rig-wide cap (e.g. BEADS_MAX_ROWS=100 with
   150 ready issues) hard-failed a claim that only ever consumes one row.
   Bound the internal scan via Limit instead, then clear the cap fields.

2. cmd/bd/ready.go, internal/storage/issueops/ready_work_counts.go:
   GetReadyWorkWithCountsInTx (ready --json / list --ready --json) never
   enforced MaxRows at all — a pre-existing gap in the original PR (the
   function predates this branch's merge-base), not something the rebase
   introduced. Threaded EffectiveSearchLimit into its query LIMIT and added
   EnforceMaxRowsCap via a new finishReadyWorkWithCounts terminal helper,
   mirroring finishSearchIssuesWithCounts. Wired handleMaxRowsError on the
   bd ready --json error branch.

3. cmd/bd/max_rows.go + list/ready/graph/dep/find-duplicates: proxied-server
   mode silently ignored the cap (the proxied repository doesn't thread
   MaxRows through the UOW pipeline). Added rejectMaxRowsUnderProxiedServer,
   called on every command that registers --max-rows before it diverts to
   its *ProxiedServer path — an explicit --max-rows or BEADS_MAX_ROWS now
   errors out under --proxied-server instead of no-oping.

4. cmd/bd/list.go: `--limit N --max-rows N` errored instead of truncating.
   withFetchOneExtra unconditionally bumped Limit to N+1 for its own
   >N-matches truncation-hint probe, which then crossed EffectiveSearchLimit's
   `limit > maxRows` branch and tripped the cap on the probe row alone, even
   though the delivered set is always trimmed back to N. withFetchOneExtra
   now skips the bump when MaxRows is active and no looser than Limit;
   >N-matches semantics for limit<maxRows are unaffected.

5. cmd/bd/list.go: `bd list --watch` swallowed the initial-query cap error
   (logged to stderr, returned void, exited 0). watchIssues now returns the
   initial-query error instead of handling it itself; runListCore routes it
   through handleMaxRowsError for exit-code-2 semantics. Mid-poll refresh
   failures still just log and continue (interactive command, not a reason
   to kill the watch loop).

6. cmd/bd/max_rows.go + every call site: handleMaxRowsError and the
   --max-rows usage-error path in resolveMaxRows called os.Exit directly
   from deep inside RunE, bypassing both the command's own metrics defer
   and main()'s post-ExecuteC metrics.CloseAndFlush(). Converted both to
   return errors: resolveMaxRows now returns (int, string, error) and
   handleMaxRowsError returns error, both following the exact &exitError{Code:
   N}-via-RunE precedent already used elsewhere in this package (e.g.
   list_input.go's skip-labels-conflict check, HandleErrorRespectJSON).
   doctor_conventions.go's runConventionsLint (called from a "()
   []doctorCheck" advisory-checks aggregator with no error channel) needed
   its own (([]doctorCheck, error) signature to propagate the one non-advisory
   failure mode; every other call site was already RunE-adjacent.

SHOULD-FIX (both mechanical, done):

7. cmd/bd/graph.go: `bd graph <issue>` (no --all) never resolved the cap.
   loadGraphSubgraph is a BFS over per-ID GetDependents/GetDependencies
   lookups with no IssueFilter to thread MaxRows through, so — mirroring
   dep tree — the cap is now checked post-hoc against the final
   connected-component node count. Documented both graph's per-status
   (--all) and post-hoc (single-issue) cap semantics, and dep tree's
   post-hoc semantics, in their flag help text.

8. internal/storage/issueops/ready_work.go: getReadyWispsInTx's unbounded
   (Limit<=0) branch queried and hydrated the *entire* wisps table before
   the post-merge cap check in GetReadyWorkInTx ever ran, defeating the
   "circuit breaker against pathological queries" purpose for
   --include-ephemeral. readyWorkWispIssueFilter now propagates
   MaxRows/MaxRowsSource so EffectiveSearchLimit bounds that query to
   cap+1 up front.

Tests added: TestClaimReadyIssue_MaxRows_LargePoolUnderLowCap (1),
ReadyMaxRowsJSON_FlagOverCap_Exits2 + ListReadyMaxRowsJSON_FlagOverCap_Exits2
(2), reject_max_rows_flag + reject_max_rows_env + allow_max_rows_zero under
TestProxiedServerList (3), LimitEqualsCap_TruncatesNotErrors +
LimitEqualsCap_JSON_TruncatesNotErrors (4), Watch_FlagOverCap_Exits2 (5),
GraphSingleIssueMaxRows_NodeCount_Exits2 + _UnderCap_NoError (7),
ReadyIncludeEphemeralMaxRows_FlagOverCap_Exits2 (8).

Verified: go build/vet clean; full MaxRows-named + FilterHasZeroMaxRows +
BypassesBeadsMaxRows sweep passes in both dolt-server and
BEADS_TEST_EMBEDDED_DOLT=1 modes (one dolt-testcontainer flake observed and
confirmed non-reproducing on retry, consistent with prior sessions);
TestProxiedServerList passes with BEADS_TEST_PROXIED_SERVER=1.

Agent-Signature: claude-sonnet-medium on behalf of maphew

* fix(review): address round-2 delta review regressions (be-x42v.4 round 3)

opus verified all eight round-2 items as implemented, but codex found three
regressions those fixes introduced, confirmed on adjudication. Common
thread: enforce the cap on the DELIVERED result, not on fetched/merged
intermediates, and don't let the safety rejection block one-row operations.

1. cmd/bd/ready.go: proxied `bd ready --claim` was rejected by
   rejectMaxRowsUnderProxiedServer before it could dispatch to
   runReadyProxiedClaim, even though --claim always delivers exactly one
   row and the direct-path fix (claim.go, round 2) already exempts claim
   from cap enforcement for that exact reason. Moved the claimReady flag
   parse before the proxied branch and exempt --claim from the rejection;
   bulk (non-claim) proxied `bd ready` still rejects an active cap. Added
   claim_succeeds_under_env_max_rows_cap plus
   reject_bulk_ready_under_max_rows_{flag,env} to
   ready_proxied_integration_test.go.

2. internal/storage/issueops/ready_work_counts.go: with --include-ephemeral,
   GetReadyWorkWithCountsInTx's issues and wisps queries are each
   independently bounded by EffectiveSearchLimit(filter.Limit,
   filter.MaxRows), so the merged pre-trim slice can hold up to ~2x that
   per-table bound even when filter.Limit <= filter.MaxRows (e.g. limit=2,
   cap=3, 2 rows/table -> merged 4 -> false "too many rows" even though the
   delivered page, trimmed to 2, is well within the cap). Reordered
   finishReadyWorkWithCounts to trim to Limit before checking the cap,
   mirroring GetReadyWorkInTx's non-counts path (mergeReadyWisps already
   trims before its caller's EnforceMaxRowsCap runs). Verified this
   reproduces "4 found, --max-rows=3 exceeded" on the pre-fix code and is
   fixed after. Added ReadyIncludeEphemeralMaxRowsJSON_MergedUnderLimit_NoError.

3. cmd/bd/list.go: round-2's fix for `--limit N --max-rows N` (skip the
   withFetchOneExtra probe-row bump entirely when Limit>=MaxRows) stopped
   the false cap error but also stopped fetching the extra row, so
   len(results) could never exceed effectiveLimit and the GH#3212
   truncation notice silently stopped firing — a partial result started
   presenting as complete. Restored the probe-row fetch (Limit still bumps
   to N+1) and instead bump MaxRows to N+1 in lockstep, but only in the
   exact Limit==MaxRows case: this keeps the probe row inside the
   (temporarily N+1) cap so EnforceMaxRowsCap doesn't trip on it, while the
   CLI's own len(results)>effectiveLimit check still sees the extra row and
   correctly reports truncated=true. Tighter-cap (Limit>MaxRows) and
   looser-cap (Limit<MaxRows) cases are unaffected — MaxRows is left
   unbumped there, so a genuine violation still reports the true cap value.
   printTruncationHint's text is gated on ui.IsStderrTerminal() and
   unconditionally suppressed for this subprocess test harness's piped
   stderr (matches the existing limit_truncation_hint subtest's documented
   constraint), so the fix is verified via 4 new unit tests asserting
   withFetchOneExtra's exact bump values directly
   (TestWithFetchOneExtra_LimitEqualsCap_BumpsBothForTruncationProbe et al.)
   rather than the unobservable hint text; extended
   LimitEqualsCap_TruncatesNotErrors's comment to document this and point
   to the unit tests.

Opus nits:

4. internal/storage/issueops/claim.go: bounding the claim scan at
   Limit=MaxRows (round 2) meant a BEADS_MAX_ROWS=1 rig would only attempt
   the single top-of-queue ready row and return "nothing to claim" if it
   was transiently unclaimable (e.g. a race with another agent), even with
   plenty of other ready work available. Restored the unbounded scan
   (Limit=0); the breaker's job is to bound delivered payloads, and a
   claim's payload is always exactly one row regardless of scan size.

5. cmd/bd/find_duplicates.go: replaced the inlined proxied-server rejection
   check with a call to rejectMaxRowsUnderProxiedServer so the message
   can't drift from the other 4 commands that use it.

Verified: go build/vet clean; full MaxRows-named + FilterHasZeroMaxRows +
BypassesBeadsMaxRows + WithFetchOneExtra sweep passes in both dolt-server
and BEADS_TEST_EMBEDDED_DOLT=1 modes; TestProxiedServerList +
TestProxiedServerReady (full suites, ~200s) pass with
BEADS_TEST_PROXIED_SERVER=1; broader TestList|TestWatch|TestGraph|
TestDepTree|TestReady|TestClaim|TestFindDuplicates sweep clean except the
same pre-existing unrelated ICU-header build failure noted in the round-2
commit (confirmed via stash-based control test to reproduce identically
without this round's changes).

Agent-Signature: claude-sonnet-medium on behalf of maphew

* fix(review): address round-3 delta review items (be-x42v.4 round 4)

Converging: four small items adjudicated from round-3 delta reviews.

1. internal/storage/issueops/search.go, search_counts.go: round 3's
   trim-before-cap fix landed in finishReadyWorkWithCounts but not on the
   sibling bd list search paths. `bd list --include-infra --limit 2
   --max-rows 5` (3 durable + 3 wisps) exited 2 in both output modes even
   though the delivered page is 2 rows, since --include-infra disables the
   default SkipWisps escape hatch so the wisps merge actually runs.
   Reproduced live: "6 found, --max-rows=5 exceeded" on the pre-fix code.
   Mirrored the ready remedy: trim to filter.Limit (guarded by Limit>0)
   before EnforceMaxRowsCap in searchInTx's four exit points (added a
   trimToSearchLimit helper) and in finishSearchIssuesWithCounts (swapped
   the cap/trim order). Fixed search_counts.go's doc comment, which still
   asserted the old cap-before-trim rationale and directly contradicted
   ready_work_counts.go's. Single-source results are unaffected (a lone
   query never exceeds Limit when Limit>0, so the trim there is a no-op);
   Limit=0 and genuine Limit>MaxRows overage still error. Added
   IncludeInfraMergedUnderLimit_NoError (both bd list output modes) to
   TestEmbeddedMaxRowsList.

2. cmd/bd/ready.go: the round-3 fix that exempts proxied `ready --claim`
   from rejectMaxRowsUnderProxiedServer also skipped resolveMaxRows
   entirely for that branch, so `--max-rows -1` was silently accepted
   under proxied claim (every other command, direct or proxied, rejects
   it with exit 1). Still call resolveMaxRows in the claim-exempt branch
   for its validation side effect, ignoring the resolved cap for the
   claim itself. Reproduced live (claim succeeded instead of failing) on
   the pre-fix code. Added claim_rejects_invalid_max_rows_flag to
   ready_proxied_integration_test.go.

3. cmd/bd/find_duplicates.go, cmd/bd/max_rows.go: find-duplicates resolved
   --max-rows twice under proxied mode (once to build its filter, again
   inside rejectMaxRowsUnderProxiedServer), doubling the malformed-env
   stderr warning. Split rejectMaxRowsUnderProxiedServer into itself plus
   a new rejectResolvedMaxRowsUnderProxiedServer(maxRows int) that takes
   an already-resolved value; find_duplicates.go now calls the latter with
   its existing resolved maxRows instead of re-resolving.

4. internal/storage/issueops/claim.go: added a comment sentence noting the
   unbounded-scan trade-off per the adjudication note — parity with
   pre-PR main and correctness-first (preserves claim's existing
   fairness/ordering across the ready set); a bounded, paged scan is a
   deliberate follow-up, not folded in here.

Verified: go build/vet clean; full MaxRows-named + FilterHasZeroMaxRows +
BypassesBeadsMaxRows + WithFetchOneExtra sweep passes in both dolt-server
and BEADS_TEST_EMBEDDED_DOLT=1 modes (including the two new regression
tests); full TestProxiedServerReady suite (~211s) passes with
BEADS_TEST_PROXIED_SERVER=1; internal/storage/issueops unit tests pass;
broader TestList|TestWatch|TestGraph|TestDepTree|TestReady|TestClaim|
TestFindDuplicates sweep clean except the same pre-existing unrelated
ICU-header build failure noted in prior rounds. Both new regression tests
(item 1 and item 2) reproduce the reported failure on the pre-fix code via
git-stash and pass after.

Agent-Signature: claude-sonnet-medium on behalf of maphew

* fix(review): sort merged issues+wisps before trim in searchInTx (be-x42v.4 round 5)

codex P1, confirmed live: searchInTx's merge branch concatenates two
independently ORDER BY'd legs (`results = append(filtered,
wispResults...)`), and round-4's trimToSearchLimit then sliced that
UNSORTED concatenation. With Limit=N and durable rows alone filling N, a
higher-ranked wisp (per filter.SortBy/SortDesc) was silently dropped from
the page — before round 4 the CLI received the full merged set and its own
sort-then-trim produced correct page membership; round 4 moved a naive
prefix-trim into storage ahead of any global re-sort.

Fix: added a `less func(a, b T, sortBy string, sortDesc bool) bool` field
to searchProjection[T], populated for issueProjection via sqlbuild.Less
(the existing Go-side mirror of the SQL ORDER BY, already used correctly
by search_counts.go's sortSearchIssuesWithCounts). searchInTx's merge
branch now re-sorts the concatenation via a new sortMergedResults helper
before trimToSearchLimit runs, mirroring how finishSearchIssuesWithCounts
already orders before its own trim. idProjection (bare-ID search, no
sortable payload) leaves less nil — sortMergedResults no-ops in that case;
documented why this is safe today (no current caller combines Limit>0 with
a merged, non-SkipWisps ID-only search — see id_parser.go, which always
passes Limit=0) and where to look if that changes. The other three
trimToSearchLimit call sites in searchInTx are single-source (already
SQL-ordered), so they don't need this.

Checked the two round-3/round-4-cited "mirror" precedents per the
adjudication note, since this bug's shape (unsorted-concat-then-trim) could
plausibly recur there: GetReadyWorkInTx's mergeReadyWisps already calls
sortReadyIssues(kept, filter.SortPolicy) before its own Limit trim, and
GetReadyWorkWithCountsInTx / SearchIssuesWithCountsInTx both already sort
(sortIssuesWithCountsByPolicy / sortSearchIssuesWithCounts) before their
finish* trim-then-cap helpers. All three were already globally ordered
before trimming; only searchInTx had the bug.

Added IncludeInfraMerged_WispOutranksDurable_InDeliveredPage to
TestEmbeddedMaxRowsList: 3 durable P2 issues + 1 wisp at P0 (outranks under
the default priority-ASC sort), --limit 1 in both bd list output modes —
asserts the P0 wisp is the delivered row, not an arbitrary P2 durable row.
Reproduces exactly against 77227aa67 (the durable row is returned instead
of the wisp) and passes after the fix.

Verified: go build/vet clean; full MaxRows-named + FilterHasZeroMaxRows +
BypassesBeadsMaxRows + WithFetchOneExtra + Search sweep passes in both
dolt-server and BEADS_TEST_EMBEDDED_DOLT=1 modes (including the new
regression test); internal/storage/issueops unit tests pass.

Agent-Signature: claude-sonnet-medium on behalf of matt wilkie

* docs: remove --max-rows lines from pinned-generator CLI docs (be-x42v.4 CI fix)

CI's "Check doc flags freshness" job compares docs/CLI_REFERENCE.md and
docs/cli-reference/*.md against bd built from the pin in
docs/cli-docs.pin (v1.1.0), which predates --max-rows/BEADS_MAX_ROWS —
the same pinned-doc-generator trap that hit PRs 3920 and 4022 in this
sweep. Any doc lines this PR added for the new flag are flagged stale
against that older pinned build, and the failure cascades into "PR
Policy (wrapper timing)" via make ci-pr-policy.

Applied CI's own generated fix verbatim (downloaded the
cli-docs-freshness-patch artifact from the failing job
https://github.com/gastownhall/beads/actions/runs/30067827283/job/89403539322,
git apply --check passed cleanly, applied as-is — no manual edits).
Removes the six --max-rows generated-doc lines (bd list, bd ready, bd dep
tree, bd find-duplicates, bd graph — CLI_REFERENCE.md and the matching
cli-reference/*.md) plus the incidental column-width realignment in the
bd graph flag tables that removing the widest flag name triggers.

The flag help strings themselves (cmd/bd/max_rows.go's addMaxRowsFlag)
are untouched — those are the source of truth for docs generation and
will regenerate correctly once docs/cli-docs.pin advances past this
PR's merge. This is a pinned-generator artifact of the CI pipeline, not
a statement that the flag is undocumented.

Agent-Signature: claude-sonnet-medium on behalf of maphew

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-24 01:40:36 -07:00
Jim Wordelman
50003b803b
feat(storage): refuse test DBs on production dolt servers (AD-01) (#3632)
* feat(storage): be-c5p AD-01 isProductionPort + DB-name firewall

Generalize the BEADS_TEST_MODE production-port guard so deployments
on non-3307 ports (BEADS_PRODUCTION_PORT env, BeadsDir/dolt-server.port
file) are also caught, and add a defense-in-depth database-name
firewall that refuses test-named DBs on any server unless the operator
opts into the dedicated test-server lane via BEADS_TEST_SERVER=1.

Both defenses honor BEADS_TEST_SERVER=1 as the single opt-in for
test-server connections, so each test harness flips one env var rather
than each layer reasoning about test/prod independently. Adds benchdb_
to testDatabasePrefixes (per-bench scratch DBs from cmd/bd/dolt.go)
and updates the doc-block to call out the two sibling prefix lists
that need to converge under be-avn.

Test harnesses across cmd/bd, internal/storage/dolt, internal/molecules,
internal/tracker, internal/utils, doctor, doctor/fix, protocol,
regression, and the root suite now set BEADS_TEST_SERVER=1 alongside
BEADS_TEST_MODE=1 in TestMain. The cross-rig integration test that
filters BEADS_* env on subprocess Cmd.Env adds it back explicitly.

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

* chore: release gate PASS for be-c5p-firewall (be-m1u/47dcc380)

* fix(test): adapt store_unit_test.go for BEADS_DOLT_SERVER_PORT (rebase compat)

Tests that exercise applyConfigDefaults now clear BEADS_DOLT_SERVER_PORT (added
to main after this branch was cut) so the legacy BEADS_DOLT_PORT path runs as
intended. Without this, a GC-city environment with BEADS_DOLT_SERVER_PORT set
causes the tests to resolve an unexpected port.

* fix(dolt): stop BEADS_TEST_SERVER=1 from suppressing DefaultSQLPort detection

Restructure productionPortReasons so Rule 1 (cfg.ServerPort ==
DefaultSQLPort) is evaluated unconditionally; BEADS_TEST_SERVER=1 now only
suppresses the BEADS_PRODUCTION_PORT and dolt-server.port heuristics (Rules
2 and 3). isProductionPort loses its independent whole-function bypass and
becomes a thin wrapper. Update doc comments on both functions and the
buildTestModeProductionPortPanic fix list (which no longer lists
BEADS_TEST_SERVER=1 as a fix when port 3307 is the matched reason) to match.
Add TestApplyConfigDefaults_TestModeBlocksProdPort_EvenWithTestServerOptIn
asserting port 3307 is still refused with the opt-in set.

Also: drop a redundant explicit db.Close() in openServerConnection's
firewall-refusal path (already covered by the connReady defer), and fix two
comments that referenced a non-existent uniqueBenchDBName, pointing them at
the real generator (cmd/bd/template_test.go newTemplateBenchmarkStore) with
the correct benchdb_ name format.

Agent-Signature: claude-sonnet-medium on behalf of matt wilkie

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-24 01:28:51 -07:00
Jim Wordelman
ae48b0a090
perf(dolt): eliminate 12s slow path on bd commands when .local_version is stale (#3710)
* perf(dolt): be-1he eliminate 12s `dolt remote -v` against multi-db server roots

Three layers of defense for the bd 12s slow-path bug:

- Layer 1: migrateServerRootRemotes skips when rootDir/.dolt/repo_state.json
  is missing. Multi-database server roots have only sql-server.info; running
  `dolt remote -v` there takes ~12s to fail.
- Layer 2: ListCLIRemotes wraps the dolt subprocess in a 2s context timeout.
  Backstops Layer 1 against any future variant of the broken-parent-dir case.
- Layer 3: autoMigrateOnVersionBump does a read-only probe of bd_version
  before opening writeable. Read-only stores skip syncCLIRemotesToSQL, so a
  stale .local_version (e.g. from a multi-binary install) no longer triggers
  the slow path on every command.

End-user impact pre-fix: gc mail inbox 60-80s, gc status 30s+ hangs.

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

* chore: release gate PASS for be-1he (3-layer slow-path fix)

* docs(repro): add be-1he slow-path repro script (be-vxngmn)

Adds scripts/repro-be-1he-slow-path/repro.sh + REPRO.md demonstrating
the 12-second `dolt remote -v` slow path on multi-DB server roots.

Satisfies coffeegoddd's review request: "We need a beads-only repro of
this to prove its a bug."

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

* docs(cli): regenerate CLI reference after slow-path fix rebase

Output of ./scripts/generate-cli-docs.sh ./bd and ./scripts/generate-llms-full.sh.

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

* docs(cli): regenerate CLI reference + llms-full with pure-go bd

The previous regen (0aeb5934e) was built with a CGO-enabled bd, which
includes the CGO-only `bd federation` subcommands. CI builds the docs
binary with CGO_ENABLED=0 (scripts/ci/pr-policy.sh build_docs_binary),
so check-doc-flags rejected the extra federation subcommand pages.

Regenerated docs/CLI_REFERENCE.md, the federation cli-reference pages
(live + versioned 1.0.0/1.0.4/1.0.5), and website/static/llms-full.txt
with a CGO_ENABLED=0 binary. check-doc-flags + check-doc-freshness now
pass locally under LC_ALL=C.

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

* docs(release-gate): correct be-1he layer description to match shipped diff

The PR body and this gate doc both described a "Layer 1" repo_state.json
sentinel in internal/storage/dolt/federation.go, but the actual diff never
touched that file - only cmd/bd/version_tracking.go (Layer 3) and
internal/storage/doltutil/remotes.go (Layer 2) are changed. Correct the
gate doc's commit table, acceptance-criteria row, and follow-up/out-of-scope
notes to describe only what ships. No code or test changes; Layer 2 and
Layer 3 remain independently verified as still-needed on current main
(ListCLIRemotes has no timeout, no equivalent sentinel exists).

Agent-Signature: claude-sonnet-medium on behalf of maphew

* fix(dolt): scope ListCLIRemotes timeout, fix repro.sh, purge Layer 1 narrative

Addresses the cross-vendor review's four should-fixes plus the comment nit
(gastownhall/beads#3710 review, 2026-07-24):

1. ListCLIRemotes' 2s cap could turn a slow-but-valid dolt remote -v into
   "remote absent": FindCLIRemote folds any error (including a timeout) into
   "", and EnsureCLIRemote then blind-adds on that signal, which hard-fails
   if the remote actually exists. Chose the "scope the cap" fix over
   "propagate DeadlineExceeded distinctly": it's fully contained inside
   ListCLIRemotes (no changes needed at the three call sites - remotes.go:192
   ensure-path, store.go:1958 URL match via hasMatchingCLIRemote, and
   doctor/federation.go:127, which already treats errors distinctly from "no
   remotes"), whereas threading a sentinel error type through FindCLIRemote's
   string-returning signature and its callers touches more surface for the
   same outcome. ListCLIRemotes now stats dbPath/.dolt/repo_state.json: 2s
   cap when absent (the known broken multi-DB server-root case - there's
   never a real answer coming from there), 30s cap otherwise (a real repo's
   `dolt remote -v` is ~130ms even loaded, so 30s only bites a genuinely hung
   subprocess). Added TestListCLIRemotesTimeout covering both branches,
   following the t.TempDir() pattern already used in
   persisted_remotes_test.go.

2. repro.sh's baseline `dolt remote -v` ran in the invocation directory, not
   $SERVER_ROOT, so the central "slow" measurement never exercised the
   constructed broken root. Fixed to `(cd "$SERVER_ROOT" && dolt remote -v
   2>&1) || true`, matching the correct subshell pattern already used later
   in the script. Also relabeled the "PARTIAL FIX ... Layer 2 timeout capped
   it" branch: the 2s cap lives in bd's Go code, not dolt, and this script
   calls the raw dolt binary directly - it's never capped. Relabeled to
   describe the underlying dolt slowness the script demonstrates instead of
   implying bd's timeout is in play here.

3. `dolt init --quiet` isn't supported by dolt 2.2.x and set -e killed the
   script before it reached the summary. Redirected output instead
   (`dolt init >/dev/null 2>&1`). Ran repro.sh end-to-end locally (dolt
   2.2.0): completes with exit 0, and the fixed subshell now shows real
   timing/output from inside $SERVER_ROOT.

4. Purged the unshipped "Layer 1" (federation.go sentinel) narrative from
   repro.sh and REPRO.md - same reconciliation already done for the release
   gate doc and PR body. Both files now describe only the two layers that
   ship (remotes.go timeout, version_tracking.go read-only probe), with a
   short note that an earlier draft described a Layer 1 that never landed.

5. cmd/bd/version_tracking.go:195-197 comment cited syncCLIRemotesToSQL,
   which doesn't exist anywhere in the tree, and overstated the read-only
   probe's benefit. On current main the writeable-open gate reads remotes
   via doltutil.PersistedRemotes (a fast on-disk repo_state.json probe, no
   dolt subprocess), so the probe saves an initSchema round-trip, not a 12s
   hang. Corrected.

Agent-Signature: claude-sonnet-medium on behalf of maphew

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-24 00:53:06 -07:00
Jim Wordelman
bc9d854ebb
feat(stats): --no-blocked flag skips blocked-count computation; fix Blocked:0 red render (be-nnqp, be-4b63) (#4022)
* feat(stats): add --no-blocked flag; fix Blocked:0 red render (be-nnqp, be-4b63)

- types.go: BlockedIssues int → *int (nil when --no-blocked skips computation)
- storage: add FastStatisticsStore interface + GetStatisticsNoBlocked to DoltStorage;
  implement in DoltStore and EmbeddedDoltStore (ScanIssueCountsInTx only, no blocked traversal)
- status.go: --no-blocked flag (no short alias), BlockedCountSkipped bool in StatusOutput;
  fast path calls GetStatisticsNoBlocked; human output renders "(skipped)" in muted style
- be-4b63: Blocked:0 now renders plain text; only Blocked:N>0 uses RenderFail (red)
- nil-guard BlockedIssues callers: getAssignedStatistics, status_test.go, queries_test.go,
  examples/library-usage/main.go

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

* docs(cli): regen CLI reference for `bd status --no-blocked`

Regenerates docs/CLI_REFERENCE.md and the website CLI reference pages
(`website/docs/cli-reference/status.md` and the version-1.0.0 / 1.0.4
snapshots) from the live `bd help` output so the doc-flags freshness
check passes.

Picks up the new `--no-blocked` flag, the updated `--no-activity`
description ("Skip git activity summary"), and the matching example
lines added in ddf53438c.

Fixes the CI "Check doc flags freshness" failure on PR #4022.

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

* chore: release gate PASS for be-nnqp+be-4b63 (bd stats --no-blocked)

* fix(stats): ReadyIssues *int, data-derived skip render, proxied-server warning

Address the adjudicated cross-vendor review on PR #4022:

- internal/types.Statistics.ReadyIssues is now *int, mirroring BlockedIssues:
  nil when --no-blocked skips the computation (readiness needs the blocked
  set), populated by all three backends' full GetStatistics, by
  issueops.GetStatisticsInTx, and by buildAssignedStats. Left nil only in
  the *NoBlocked fast-path variants. JSON now emits `"ready_issues": null`
  instead of a fake 0 a CI consumer could misread as "nothing ready".
- renderStatus derives "(skipped)" rendering from the data itself
  (stats.BlockedIssues/ReadyIssues == nil) instead of the noBlocked flag,
  fixing the --assigned + --no-blocked contradiction where fully-recomputed
  stats were mislabeled as skipped. The noBlocked parameter is gone from
  renderStatus entirely; both call sites (status.go, status_proxied_server.go)
  simplified accordingly.
- Proxied-server mode now prints a one-line stderr warning when --no-blocked
  is passed but not honored, instead of silently discarding the flag; the
  flag's help string documents the limitation.

Agent-Signature: claude-sonnet-medium on behalf of maphew

* test(stats): cover GetStatisticsNoBlocked nil semantics and renderStatus skip branch

- internal/storage/dolt: new TestGetStatisticsNoBlocked_LeavesBlockedAndReadyNil
  asserts the --no-blocked fast path leaves BlockedIssues/ReadyIssues nil
  while the full GetStatistics path on the same store populates both.
- cmd/bd: new TestGetStatisticsNoBlocked (storage-level, same assertion via
  the CLI-facing store handle), TestRenderStatus_SkipJSONEmitsNullNotZero
  (asserts blocked_count_skipped:true plus literal `"blocked_issues": null`
  / `"ready_issues": null` in the JSON envelope),
  TestRenderStatus_SkipHumanRendersSkippedNotZero (asserts the "(skipped)"
  human branch renders for both fields), and
  TestRenderStatus_AssignedIgnoresSkipEvenWithNoBlockedFlag (guards the
  --assigned + --no-blocked fix: fully-populated stats never render
  "(skipped)").
- Update existing statistics assertions in
  internal/storage/conformance/audit_search-counts-stats.go,
  internal/storage/dolt/queries_test.go, and
  internal/storage/domain/db/ready_helpers*_test.go for
  ReadyIssues's int -> *int change.

Agent-Signature: claude-sonnet-medium on behalf of maphew

* docs(cli): drop --no-blocked doc lines from CLI_REFERENCE.md/status.md (pinned-generator policy)

CI's "Check doc flags freshness" job builds bd from the release pin in
docs/cli-docs.pin (currently v1.1.0) to regenerate docs/CLI_REFERENCE.md
and docs/cli-reference/status.md, not from this branch's HEAD. v1.1.0
predates --no-blocked entirely, so the pinned generator's output omits
every --no-blocked reference (use case bullet, both example lines, the
flag description) and also reverts the --no-activity flag description
wording, flagging both files as stale relative to it. Same trap PR #3920
hit for --mem-profile.

Applied the exact patch CI generated and uploaded as the
cli-docs-freshness-patch artifact on the failing job
(run 30063539327 / job 89390739992) verbatim to both files; the lines
will reappear automatically once the pin advances past a release that
includes --no-blocked.

Agent-Signature: claude-sonnet-medium on behalf of maphew

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-23 23:52:39 -07:00
matt wilkie
187ba85f3c
chore: remove agent-rig workflow artifacts (release-gates/, private plan docs) (#4632)
The release-gates/ directory (16 files) and two docs/plans/ files
(schema-skew-guard.md, reference-aware-prune.md) are internal artifacts
from a contributor's personal multi-agent development rig: release-gate
checklists and PM handoff plans referencing bead IDs (be-*) from a
private tracker that does not exist in this repo. They arrived as
passengers on otherwise-valuable contribution PRs between April and
July 2026 and have no readers here - the user-facing documentation for
those features landed in --help text and README via the same PRs.

Removing them keeps the tree free of files that reference untraceable
issue IDs and confuse both human readers and coding agents that treat
docs/plans/ as authoritative. Content remains available in git history.

Agent-Signature: claude-fable-5-high on behalf of matt wilkie
2026-07-07 09:54:01 -07:00
Jim Wordelman
64d67e0976
chore(dolt): converge bd dolt clean-databases prefix list with firewall (#3618)
Converge the cleanup-side `staleDatabasePrefixes` list in `bd dolt clean-databases` with the firewall-side `testDatabasePrefixes` from be-c5p, so both prefix lists are textually identical and `benchdb_` / `beads_test` are no longer leaked by cleanup.

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Agent-Signature: claude-fable-5-high on behalf of matt wilkie
2026-07-07 07:49:32 -07:00
Jim Wordelman
3e10077dc5
feat(preflight): implement --fix mode for vendorHash and version sync (#4054)
* feat(preflight): implement --fix mode for vendorHash and version sync

- Add fixNixHash(): uses sentinel-hash trick with nix build to compute
  and write the correct vendorHash into default.nix when go.sum has
  uncommitted changes; prints clear error if nix not in PATH
- Add fixVersionSync(): syncs cmd/bd/version.go to match default.nix
  version field (default.nix is source of truth)
- Add runFixes(): wires both to --fix flag with human-readable and
  --json output modes
- Remove outdated 'not yet implemented / bd-lfak.3-5' stub
- Preserve original file permissions on all writes

Closes be-xra8, be-roho

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

* docs: sync CLI_REFERENCE.md --fix help text with live CLI (be-xra8, be-roho)

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

* docs(preflight): regenerate website CLI reference for --fix flag (be-laor)

Update website/docs and both versioned_docs variants to reflect --fix
flag description change from 'not yet implemented' to 'vendorHash, version sync'.

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

* chore: release gate PASS for be-xra8+be-roho (bd preflight --fix mode)

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-06 22:33:29 -07:00
Jim Wordelman
e802fa0c4e
docs: add CONTRIBUTING_PR_GUIDELINES.md (codify reviewer expectations for contributors) (#3913)
* docs: add CONTRIBUTING_PR_GUIDELINES.md (codify reviewer expectations for contributors)

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

* chore: release gate PASS for be-z33z (CONTRIBUTING_PR_GUIDELINES docs)

Docs-only PR #3913. Review be-z33z PASS. CI 18/18 non-skipped SUCCESS.

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

* chore: retrigger CI (unrelated audit flake on prior run)

Prior run failed only on internal/audit::TestAppend_ConcurrentWritersUniqueIDs,
a birthday-paradox flake in 32-bit newID() — see be-5uxe for the source fix.
This commit is intentionally empty to retrigger CI on this docs-only PR.

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-06 22:12:29 -07:00
Jim Wordelman
51951ff854
fix(test): bump listenWait 2s→10s to fix flaky TestProxy_IdleTimeout_Fires (#3987)
* fix(test): be-0x7ztf — bump listenWait 2s→10s to fix flaky TestProxy_IdleTimeout_Fires

Proxy startup (net.Listen + server.Start + waitForServerReady) can exceed 2s
under heavy CI load. 10s comfortably covers worst-case scheduling while staying
well under go test's 10-minute per-package timeout.

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

* chore: release gate PASS for be-0x7ztf (proxy listenWait fix)

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-06 22:00:09 -07:00
Jim Wordelman
3cbe5f8876
test(cmd/bd): auto-opt-out of repo config in initConfigForTest helper (#3904)
* test(cmd/bd): be-3lch auto-opt-out of repo config in initConfigForTest helper

The helper now sets BEADS_TEST_IGNORE_REPO_CONFIG=1 as its first
statement, so tests calling initConfigForTest no longer silently
inherit the dogfooded .beads/config.yaml. This was the foot-gun
behind be-hple (TestWhereCommand_ReadsPrefixFromEmbeddedStore).

Design (be-3lch / be-lspm audit): all 7 callers verified safe.
types.custom is read from store, not viper; other dogfood values
(dolt.auto-start, gc.*, export.auto, no-push) are not read from
viper by any audited caller.

Deviation from architect's design: the design called for a lockstep
edit in both test_helpers_test.go and test_helpers_pure_test.go,
but be-5t00 (commit b589f9b63) already removed the cgo duplicate.
The helper now lives in test_helpers_pure_test.go only — single
edit is sufficient.

Audit gate (criterion #4): TestWhereCommand_UsesConfigPrefixFromSelectedDB
still PASSES.

Cleanup breadcrumb: where_cgo_test.go:20 now has a redundant
explicit t.Setenv("BEADS_TEST_IGNORE_REPO_CONFIG", "1") that can be
removed in a separate hygiene PR (do NOT bundle — preserves bisect
signal for the original be-hple failure).

Refs: be-3lch, be-lspm, be-hple, be-sm6v

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

* chore: release gate PASS for be-3lch (helper-level repo-config opt-out)

Cherry-picks 6858f98fc onto a fresh branch off origin/main and records
PASS verdict for all 6 gate criteria. Zero new test regressions vs
baseline. Architect criteria all met (helper-level t.Setenv, doc
comment update, audit-gate test passes).

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

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-06 21:57:55 -07:00
Jim Wordelman
f1db5a9fa5
fix(close): refuse silent close on actor/assignee mismatch (#3734)
* fix(close): be-035 refuse silent close on actor/assignee mismatch

bd close now requires the actor to match the bead's assignee (or have
--force) before persisting. Without this, an actor whose claim was
overwritten by a concurrent re-claim could call bd close, see "✓ Closed"
on stdout, and leave the bead open in the store — silent data loss.

The storage UPDATE was already id-only with proper rowcount checking,
so this is purely a CLI-layer authority guard implemented as a new
validation.AssigneeMatches validator wired into validateIssueClosable.

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

* chore: release gate PASS for be-07y (be-035 close authority guard)

Cherry-pick of 7a925e304 onto a clean branch off origin/main. Verified
delta byte-identical to reviewed commit. All four be-035 acceptance
criteria covered; reviewer-recorded PASS verdict in bead notes; tests
pass on the touched surfaces (TestAssigneeMatches 6/6, TestEmbeddedClose
35/35 incl. four new authority-guard cases, TestEmbeddedCloseConcurrent).
Three full-suite flakes observed are pre-existing baseline (reproduce
on plain origin/main).

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

* test(count): close alice-assigned fixture with --force under be-035 guard

TestEmbeddedCount's setup created a fixture assigned to alice and closed it
as the test actor ("Test"). With this PR's be-035 close-authority guard, that
cross-actor close is now correctly refused (exit 1), failing the test setup at
count_embedded_test.go:84.

The fixture must remain assigned to alice for the --assignee alice count
assertion below (expects >=3), so close it with --force rather than dropping
the assignee. Fixes the Test (Embedded Dolt Cmd 5/20) shard.

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

* docs(validation): note identity-by-string semantics of AssigneeMatches

Addresses review question: two principals sharing one actor name both pass
the check, because the actor string is compared verbatim and bd has no
identity layer. Document this as intentional — the guard removes silent
cross-actor closes without adding new identity guarantees.

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

* fix(close): update proxied-server call site for validateIssueClosable actor param

Maintainer branch-update for #3734: upstream added cmd/bd/close_proxied_server.go
after this PR's base; align its call with the PR's widened signature.

Agent-Signature: claude-fable-5-high on behalf of matt wilkie

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-05 23:51:45 -07:00
Jim Wordelman
c4e51986b0
feat(prune): reference-aware bd prune skips closed beads cited by open beads (be-jewoem, be-u2mw2x) (#4023)
* pm: decompose be-zej8mz → 3 builder beads for reference-aware prune

Child beads:
- be-jewoem: core implementation in cmd/bd/purge.go
- be-u2mw2x: --help and README docs update
- be-0wt833: bench asserting <5s on 10K-open-bead fixture (blocked on core)

Plan at docs/plans/reference-aware-prune.md.

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

* feat(prune): reference-aware bd prune skips closed beads cited by open beads (be-jewoem, be-u2mw2x)

Implements be-5sn FR-01 through FR-06:

- buildReferencedSet scans description/notes/comments of every non-closed
  bead for literal candidate IDs using word-boundary regexp alternation.
  Uses Statuses filter (not ExcludeStatus) to avoid the PG coverage gap
  (be-jdeief guardrail per be-5sn §15).

- runPurgeOrPrune filters referenced beads after pinned-filtering when
  scope.cmdName == "prune" && !scope.ignoreReferences.

- All 4 human output paths updated: preview, dry-run, force, nothing-to-do.
  referenced_skipped/referenced_count always in prune JSON; absent in purge.
  referenced_ids_sample omitted when 0 (per be-zej8mz §5).

- --ignore-references flag registered in pruneCmd.Flags() only; purge
  init() unchanged so bd purge --ignore-references gives "unknown flag".

- pruneCmd.Long gains reference-protection paragraph per be-zej8mz §3.

- README.md adds Maintenance section documenting prune, purge, and the
  reference-aware skip with --ignore-references escape hatch.

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

* test(prune): NFR-02 bench test for buildReferencedSet on 10K-bead fixture (be-0wt833)

TestPruneLargeFixture generates 10K open beads × ~5KB bodies + 100 closed
candidates with 20 seeded references; asserts buildReferencedSet completes
<5s and returns exactly the seeded IDs.

Passes in ~1.2s on a standard dev machine. Skips under -short.

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

* docs(prune): regen CLI reference + release gate PASS (be-jewoem)

Regenerate CLI docs with CGO_ENABLED=0 -tags gms_pure_go binary built
from PR HEAD. Adds --ignore-references flag to prune command docs in
CLI_REFERENCE.md and three website prune.md pages.

Gate evaluation: all 6 criteria PASS (AC-6 integration tests deferred
to be-zkzw per reviewer).

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

* feat(contributor): bd-umbf contributor namespace isolation (Children 1-3)

Child 1 (be-c7696f): Auto-configure contributor routing in bd init
when upstream remote is detected. Non-interactive, idempotent — skips if
routing.contributor is already set. Creates ~/.beads-planning, sets
routing.mode=auto, routing.contributor, sync.remote=upstream, and pins
git beads.role=contributor.

Child 2 (be-9d2b67): bd export --exclude-owner flag and config-driven
export.exclude_owners / export.exclude_owner config. Filters issues by
created_by before writing JSONL. --verbose emits filtered count.

Child 3 (be-3c5a0f): New bd migrate-personal command. Finds project DB
issues whose created_by matches the current git identity, prompts for
confirmation, then moves them to the planning repo (routing.contributor),
copying labels, dependencies, and comments atomically.

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

* fix(init): match autoConfigureForkContributor output to be-0ccf34 design spec

Three variants were missing; the one present used wrong symbol (✓ instead of ▶).

Happy path: ▶ header, upstream URL echoed, three ✓ action lines, opt-out hint last.
Opt-out path (--role=maintainer on a fork): ⚠ with explanation and recovery hint.
Re-init path (routing already configured): ⚠ with existing path and reconfigure hint.
Non-interactive/quiet: silent (unchanged).

Pass roleFlag through to autoConfigureForkContributor so the opt-out variant fires
when --role=maintainer is given explicitly on a fork.

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

* fix(contributor): separate insert/delete phases in migrate-personal; suppress nonInteractive output

migrate-personal now copies all issues to planning DB first, then
deletes them from project DB in a single transaction via DeleteIssues.
A mid-loop failure before the delete phase leaves no issues deleted,
making re-runs safe.

Also pass quiet || nonInteractive to autoConfigureForkContributor so
bd init --non-interactive does not emit fork-detection output.

Fixes B4 and the nonInteractive gap from be-72b53f review.

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

* docs(prune): regen CLI reference — add bd migrate-personal, update bd export flags

Regenerated from bd 1.0.4 dev (9ed33b68d) with CGO_ENABLED=0 -tags gms_pure_go.
Fixes B1: bd migrate-personal was missing from docs/CLI_REFERENCE.md and
all website cli-reference pages.

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

* docs(gate): update be-jewoem release gate to cover bd-umbf scope

Expands gate scope from be-jewoem/be-u2mw2x only to include bd-umbf
Children 1-3 commits added to the branch. Documents blocker resolution
status (B1/B2/B4 resolved, B3 pending validator), updates CI results to
latest all-green run 26009209774, and marks overall gate ON HOLD pending
validator tests.

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

* docs(gate): update be-jewoem gate — PR description refreshed, B3 dependency chain clarified (2026-05-19)

* test(contributor): be-f9a104 — bd-umbf export+migrate-personal tests

6 tests for bd-umbf Children 2-3 per be-f9a104 scope:

cmd/bd/export_exclude_owner_test.go (be-9d2b67):
- TestExportExcludeOwner_flag: --exclude-owner=alice filters alice's issues
- TestExportExcludeOwner_config: export.exclude_owners config drives filter
- TestExportExcludeOwner_verbose: --verbose reports filtered count

cmd/bd/migrate_personal_test.go (be-3c5a0f):
- TestMigratePersonal_noopWhenEmpty: no matching issues → 0/success
- TestMigratePersonal_movesIssues: personal issues moved to planning repo
- TestMigratePersonal_abortOnNoConfirm: EOF stdin → abort, issues stay

All gate on BEADS_TEST_EMBEDDED_DOLT=1. Fork-detection init tests
covered by be-de99a6 (tests/be-de99a6-fork-detect) per PM scope.

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

* fix(test): be-36oa — skip TestMigratePersonal_movesIssues on Dolt unavailable

Broaden the skip condition in TestMigratePersonal_movesIssues to also skip
when the planning dir's Dolt server is unavailable (BEADS_DOLT_AUTO_START=0
leaves port=0, causing dolt.New() to fail). Adds "dolt", "cannot connect",
and "server" to the skip-trigger strings alongside the existing routing
and actor-mismatch conditions.

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

* test(init): be-de99a6 — fork-detection UX output format tests

4 embedded tests for autoConfigureForkContributor output per be-de99a6:

- TestBdInit_ForkAutoContributor: upstream remote → 'Fork detected' in output,
  routing.mode=auto set
- TestBdInit_ForkAutoContributor_Idempotent: second init run → routing.mode
  still 'auto' (no double-write)
- TestBdInit_ForkAutoContributor_MaintainerFlag: --role=maintainer → routing.mode
  NOT set to auto
- TestBdInit_ForkAutoContributor_NonInteractive: --quiet → no '▶' block, but
  routing still configured

All gate on BEADS_TEST_EMBEDDED_DOLT=1. Uses initForkRepo helper to
add upstream remote for fork detection.

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

* fix(bd-umbf): be-jewoem B3 — fix yaml/DB store mismatch in export owner-filter and fork routing

Two real bugs found while landing the B3 validator tests:

1. buildOwnerExcludeSet (export.go) was only reading export.exclude_owners
   from the database. The export.* prefix is yaml-only (config.yaml), so
   config set via 'bd config set export.exclude_owners' was invisible to the
   filter. Now reads yaml first, falls back to database.

2. autoConfigureForkContributor (init_contributor.go) was writing
   routing.mode, routing.contributor, and sync.remote via store.SetConfig
   (database). Those keys carry the routing.*/sync.* prefixes which are
   yaml-only. Reading back via 'bd config get routing.mode' always returned
   empty. Now uses config.SetYamlConfig for these keys; idempotency check
   updated to read from yaml too.

Also: update TestBdInit_ForkAutoContributor to verify routing config state
rather than output text (suppressed in non-TTY test environments); remove
temporary debug_fork_test.go; mark B3 RESOLVED in release gate.

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

* fix(lint): drop unused ctx+store params from autoConfigureForkContributor

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

* chore: release gate PASS for bd-3852 (orphaned children doctor check)

* fix(rebase): update second autoConfigureForkContributor call to 2-arg signature

Later commits in this branch dropped ctx and store params from
autoConfigureForkContributor. The second call site added by be787e4b5
still used the old 4-arg form; update to match the final 2-arg form.

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

* fix(rebase): drop #4028-superseded fork-detect; take main init.go/init_contributor.go (be-15y28)

PR #4028 landed autoConfigureForkContributor on main. PR #4023 had its own
version of init.go and init_contributor.go plus a fork_detect_embedded_test.go
that collided with TestEmbeddedInit/fork_auto_contributor, causing CI to fail.

Take origin/main's init.go and init_contributor.go verbatim; remove
fork_detect_embedded_test.go. The unique features — reference-aware prune,
export --exclude-owner, bd migrate-personal — are untouched.

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

* fix(prune): scan active custom statuses in reference-aware skip

buildReferencedSet scanned only the built-in non-closed statuses, so a closed bead cited by a bead in an active *custom* status (status.custom) was unprotected and could be deleted by 'bd prune --pattern ... --force'. Now include every configured custom status whose category != done (via GetCustomStatusesDetailed); the read is required, not best-effort, so a destructive prune never silently under-scans. Adds TestPrune_protectsBeadCitedByCustomStatusBead. Addresses maphew's review of PR #4023 (be-e2nb).

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

* fix(export): apply export.exclude_owners to auto-export

The export.exclude_owners safety net was applied only by manual 'bd export'; the git-committed auto-export (.beads/issues.jsonl) did not filter, so contributor/personal issues could still leak into git history and PRs. exportToFile now applies the same owner filter (config-sourced owners). Adds TestAutoExportExcludeOwner_config. Addresses maphew's review of PR #4023 (be-e2nb).

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

* fix(migrate-personal): all-or-error copy preserving comments before delete

migrate-personal copied labels/deps/comments best-effort (warnings) and used event-style AddComment, then deleted the source -- so a partial copy could silently drop comments and dependencies while reporting success. Make the copy all-or-error in two passes (create all issue rows, then copy relations so same-prefix intra-set deps resolve), roll back the planning-DB rows and abort before touching the project DB on any failure, and copy comments via ImportIssueComment (structured row + original timestamp). Adds TestCopyIssueRelations_preservesCommentWithTimestamp and TestMigratePersonal_preservesComments. Addresses maphew's review of PR #4023 (be-e2nb).

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

* fix(ci): register TestPruneLargeFixture in check-testing-short allowlist

Large-fixture bench introduced in this PR was blocked by pr-policy.

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

* fix(docs): restore version-1.0.5 migrate-personal CLI reference

The 2026-06-03 main merge (72a2a2521) pulled in main's wholesale website
doc regeneration, which dropped
website/versioned_docs/version-1.0.5/cli-reference/migrate-personal.md
(migrate-personal is new in this PR and absent on main). check-doc-flags'
generate-cli-docs.sh --check then failed: the live bd emits the command but
the 1.0.5 snapshot lacked the page, turning Build Artifacts, PR Policy,
Check doc flags freshness, and the CI Gate rollup red.

Regenerated with scripts/generate-cli-docs.sh ./bd — only this file
changed (index.md and llms-full.txt already reference the command).
Verified the full pr-policy sequence passes locally: build-tags,
go-install-guidance, versions, doc-flags (incl. llms-full), doc-freshness,
testing-short, and the jsonl guard.

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

* docs(gate): finalize be-jewoem gate — re-review PASS, CI green 2026-06-04

Re-review PASS confirmed (gm-wisp-765hi, 2026-05-22, commit 9cfe6206f).
Post-review CI/docs commits (merge, CI allowlist, version-1.0.5 docs)
are non-behavioral. CI run 26924427657: 51/51 checks SUCCESS.
PR #4023 mergeStateStatus: CLEAN. Gate: definitive PASS.

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

* fix(docs): true up CLI reference after upstream rebase

Mechanical doc-conflict resolution during the rebase onto upstream/main
(cb33b566a) picked a stale --include-infra description and live
top-level command count. Re-run scripts/generate-cli-docs.sh to
resync docs/CLI_REFERENCE.md and website/docs/cli-reference/* with the
post-rebase bd binary; scripts/check-doc-flags.sh passes clean.

Agent-Signature: claude-fable-5-high on behalf of matt wilkie

* test(export): teach fakeStateHashStore GetConfig for auto-export owner-exclude path (fixes PR Core panic)

buildOwnerExcludeSet reads export.exclude_owners / export.exclude_owner
from the store as a database fallback after the YAML-only lookup. The
fake store used by the auto-export tests embeds a nil storage.DoltStorage
and never implemented GetConfig, so any exercised auto-export path
(TestMaybeAutoExportExportsOnStateHashChange et al.) panicked on the
embedded nil interface. Add a GetConfig stub returning ("", nil), the
same pattern used by other embedded-nil-interface fakes in this package
(captureOptsStore, mockRefStore).

Agent-Signature: claude-code-sonnet-5-medium on behalf of matt wilkie

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-05 15:57:27 -07:00
Jim Wordelman
5b6b494407
schema: print migration name to stderr on apply (human UX only) (#3914)
* schema: print migration name to stderr when running (human UX only)

When bd opens a repo and schema migrations run, users watching the
terminal see no output and cannot tell whether the CLI is hung or
working. Print one line per migration to stderr so a human knows
progress is happening.

    migrating schema: 0033_add_date_indexes.up.sql

This is intentionally narrow: no spinner, no timing, no progress bar.
It is NOT a fix for orchestrator timeouts — orchestrators should increase
their timeout budgets independently if they are killing long-running
migrations.

The stderr writer is package-level and overridable in tests.

Closes be-drsfc2

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

* fix(schema): pass migrationSource to runMigrations, not just mainSource

The extracted runMigrations helper hardcoded mainSource for its file list
and cursor table. When ignoredSource.migrate() was called it fell through
to runMigrations, which re-iterated main migration files and left
ignored_schema_migrations empty — so wisp tables (created by ignored
migrations) never existed after bd open.

Symptoms: TestSchemaAfterInit, TestGetNextChildID/wisp_parent_*,
TestCreateIssues/wisp_*, TestAddDependency/mixed_table_cycle_wisp_endpoints
all failed because the wisp tables were never created.

Repro before fix:
  BEADS_TEST_EMBEDDED_DOLT=1 go test -tags gms_pure_go -run TestSchemaAfterInit \
      ./internal/storage/embeddeddolt/...
  → schema_test.go:44: reading max ignored_schema_migrations version:
    sql: no rows in result set

Fix: thread migrationSource through runMigrations so it operates on the
source it was given. Added a regression test that proves the two sources
emit different counts.

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

* schema: suppress migration progress when stderr is not a TTY

The PR's intent is "human UX only" — a progress line so an interactive
user can tell that bd is working during a 25-75s migration. When bd's
stderr is captured by a test harness, CI step, or shell pipeline, the
same lines pollute machine-parsed output. Several test helpers using
exec.CombinedOutput fail to parse the merged stream as JSON
(see bd-embedded-test-json-stderr-leak).

Default stderr to io.Discard when os.Stderr is not a terminal. The
package-level stderr remains overridable so existing tests
(TestRunMigrationsStderrOutput) still capture output deterministically.

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

* chore: release gate PASS for be-soq0 (fix/be-drsfc2-migration-progress)

Deploy bead: be-soq0. All 7 criteria PASS. 62+ schema tests green locally.
CI Gate Required: PASS (both runs, PR #3914). Terminal-gated stderr feature.

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

* test(schema): bound PR#3914's mockDB-based runMigrations tests below v53

Rebase fixup for #3914 onto upstream/main. TestRunMigrationsStderrOutput
and TestRunMigrationsUsesProvidedSource run mainSource's migrations with
upTo=0 (latest) against the bare mockDB stub, whose QueryRowContext
panics unconditionally. Main added migration 0053's preMigrationRepair
(5589e3f6d, 80ba331a6) since this PR branched, which issues real
INFORMATION_SCHEMA probes when it reaches that version - already covered
by TestPreMigrationRepairScopedToMain0053 and friends. Bound both tests'
mainSource run to upTo=52 so they keep exercising the stderr line and
source-threading behavior they were written for, without also needing
to fake the unrelated repair path.

Agent-Signature: claude-fable-5-high on behalf of matt wilkie

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-07-05 15:35:02 -07:00
Jim Wordelman
fae194f6e3
test(dolt): add TestNoPushSkipsDoltPush for push guard coverage (#4323)
* feat(no-push): guard dolt push/pull and strip push from rendered templates

- bd dolt push/pull skip silently (exit 0) when no-push: true in config
- RenderOpts gains NoPush bool; !HasRemote || NoPush strips bd dolt push
- NoPush propagated through AgentsFileParams, fs_adapters, init, setup/agents, init_proxied_server

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

* fix(no-push): anchor stripDoltPushReferences to prevent 4-space indent false match

Without the newline anchor, ReplaceAll matched any line containing "   bd
dolt push\n" as a substring — including 4-space indented code blocks that
happen to share the prefix. Pad body with newlines so the match is anchored
to the start of the line.

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

* fix(no-push): remove pull guard from bd dolt pull (be-ve2x6)

no-push means "do not publish local state to the remote"; it must not
prevent receiving remote updates. The guard at dolt.go:330 made
bd dolt pull return success without contacting the remote when
no-push: true, leaving contributor clones stale.

Remove the pull guard. Add TestNoPushDoesNotSkipDoltPull to prevent
reintroduction: injects a minimal fake store and asserts Pull() is
called even under no-push: true.

Push guard (dolt.go:257) and template stripping (render.go:217)
are unchanged — both are correct behavior per maphew's review of #4212.

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

* test(dolt): add TestNoPushSkipsDoltPush for push guard coverage (be-i9e2)

Direct unit test for the no-push guard at cmd/bd/dolt.go:247-249.
Asserts Push() is not called and output contains "skipping push"
when BD_NO_PUSH=true. Mirrors TestNoPushDoesNotSkipDoltPull pattern.

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

* chore: release gate PASS for be-i9e2 (no-push dolt push test)

* test(dolt): fix minimalPullStore for current main (ListRemotes drift)

Rebasing #4323 onto current main surfaced a latent defect hidden by cached
green checks: main now routes bd dolt pull failure handling through
isConfirmedNoRemote, which calls st.ListRemotes during error classification
(cmd/bd/dolt.go). minimalPullStore embeds a nil storage.DoltStorage and
overrode only Pull, so TestNoPushDoesNotSkipDoltPull nil-panicked once merged
into current main.

Add a ListRemotes that reports no remotes, keeping the simulated pull failure
on the benign no-remote path (clean exit) so the test still proves the no-push
guard does not short-circuit bd dolt pull. Same fix quad341 applied on #4212.

Verified against current main: TestNoPushSkipsDoltPush, TestNoPushDoesNotSkipDoltPull,
TestIsConfirmedNoRemote, TestDoltPushPullCommitNeedStore all pass.

Agent-Signature: claude-opus-4-8-high on behalf of maphew

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-06-20 13:23:40 -07:00
Jim Wordelman
0da7f51f3b
fix(init): initialize planning Dolt schema in fork auto-config (be-wqt8) (#4290)
* fix(init): initialize planning Dolt schema in fork auto-config (be-wqt8)

autoConfigureForkContributor creates ~/.beads-planning/.beads but never
ran schema init, causing "Dolt server unreachable" when any command
(e.g. bd migrate-personal) opened the planning store immediately after
bd init on a fork.

Fix (approach a): call newDoltStoreFromConfig on the fresh planning
.beads dir right after creating it. In CGO/embedded builds this
initialises the schema via initSchema so the store is ready for first
use. In no-CGO/server-mode builds the call is a no-op (returns
nocgoEmbeddedErrMsg); those builds initialise on first use once a Dolt
server is running.

Also extends the idempotency guard to cover YAML-configured contributor
setups, not just the DB config key (secondary acceptance criterion).

Regression test: fork_auto_contributor now asserts that the
embeddeddolt data dir exists after bd init, proving initSchema ran.

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

* chore: release gate PASS for be-wqt8-planning-init

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-05 14:13:34 -07:00
Jim Wordelman
7941e00cac chore: release gate PASS for be-l9q (bd list --skip-labels AD-02) 2026-05-25 16:26:19 -07:00
Jim Wordelman
82020c42f1
feat(init): auto-configure contributor routing on fork detect (be-7daa14) (#4028)
* feat(init): auto-configure contributor routing on fork detect (be-7daa14)

Adds autoConfigureForkContributor to init_contributor.go and wires it
into bd init after the fork-exclude block. Three output variants:

  happy path  — ▶ Fork detected block with ✓ lines and opt-out hint
  opt-out     — ⚠ message when --role=maintainer is set on a fork
  re-init     — ⚠ message when routing.contributor already configured

CI/quiet mode produces no output. Non-interactive, idempotent.

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

* fix(init): suppress autoConfigureForkContributor output in non-interactive mode

Pass quiet || nonInteractive to autoConfigureForkContributor so CI and
scripted bd init --non-interactive runs do not emit fork-detection output.

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

* chore: release gate PASS for be-7daa14 (feat(init): auto-configure contributor routing)

* test(init): cover fork auto contributor routing

Add an embedded init regression test for PR 4028's fork auto-routing path and update the release-gate evidence after rebasing onto current main.

PR: https://github.com/gastownhall/beads/pull/4028

_codex-gpt-5.5-high on behalf of matt wilkie_

* fix(init): run fork auto routing before store close

Keep the PR 4028 fork contributor setup on an open store so routing config writes persist and are included in the initial commit.

_codex-gpt-5.5-high on behalf of matt wilkie_

* docs(gate): describe PR 4028 maintainer merge

Update the release gate to reflect that PR 4028 is maintained on the original contributor branch instead of through a replacement PR history.

_codex-gpt-5.5-high on behalf of matt wilkie_

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: matt wilkie <maphew@gmail.com>
2026-05-23 11:01:38 -07:00
Jim Wordelman
cfcc957995
feat(show): count-only JSON details with opt-in streamed payloads
Summary:
- Make default `bd show --json` emit relationship/comment counts without materializing dependents and comments.
- Add `--include-dependents` and `--include-comments` for callers that need full streamed payloads.
- Add Count* storage APIs and iterator APIs across Dolt, embedded Dolt, telemetry, and test stubs.
- Keep count and dependent-iterator semantics aligned with existing relationship APIs by including `wisp_dependencies`.

Verification:
- Full PR CI green at 3e036880f.
- go test -tags gms_pure_go ./cmd/bd -run 'TestShallowDependentsForJSON|TestIssueDetailsCountOnlyJSON' -count=1

Refs #4010.
Addresses be-ijck6q.

_codex-gpt-5.5-medium on behalf of matt wilkie_

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 16:54:15 -07:00
Jim Wordelman
008508f5c9
test: prevent Cobra command flag cache races (#4011)
* test: prevent Cobra command flag cache races

* chore: release gate PASS for be-psutr9 (cobra/pflag race-fix)

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

* docs(gate): update be-psutr9 gate — re-review PASS (be-mouz), fix stale file list

Re-review be-mouz confirmed PASS on current HEAD 1b5536624. Correct files
changed: stdio_race_guard_test.go + test_helpers_pure_test.go only (earlier
version listed notion_test.go/stale_test.go which are no longer in the diff).

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

* fix: address PR review findings (bd-wrntbm)

---------

Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 20:57:03 -07:00
Jim Wordelman
42a2772fe4
refactor(ui): extract markdown rendering to internal/uimd package (#4009)
* refactor(ui): extract markdown rendering to internal/uimd package

Move RenderMarkdown out of internal/ui into a new internal/uimd package
so callers that don't need markdown don't pay the ~4.6 MB chroma/glamour
init cost on every bd subprocess.

Update callers: cmd/bd/show.go, show_display.go, show_children.go,
comments.go.

Closes be-ow4w54

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

* chore: release gate PASS for be-ow4w54 (uimd markdown extract)

* docs: narrow uimd release gate scope (bd-wisp-msz5y1)

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Julian Knutsen <julianknutsen@users.noreply.github.com>
2026-05-17 15:05:25 -07:00
Jim Wordelman
331bc3aed2
perf(storage): amortize per-ID wisp routing via WispIDSetInTx (#3453)
* perf(storage): amortize per-ID wisp routing via WispIDSetInTx

Implements D2 build per ADR be-nu4 §4.D2 (bead be-nu4.2.1).

Add WispIDSetInTx helper that returns the set of currently-active
wisp IDs, consistent for the tx's lifetime under Dolt MVCC. The hot
batch-routing paths (GetLabelsForIssuesInTx, GetIssuesByIDsInTx)
gain a trailing wispSet parameter; callers that pass nil trigger a
single internal SELECT id FROM wisps rather than the N-per-ID
IsActiveWispInTx loop the helpers previously ran.

IsActiveWispInTx is retained unchanged for single-ID callers
(AddLabelInTx etc.) per the ADR audit note.

Mixed-ID routing is the sacred invariant (ADR §11.5); covered by a
new hard-gate test TestWispIDSetInTx_HardGate that exercises both
refactored helpers with a permanent issue and an active wisp in the
same input slice. Pure-fn unit coverage (partitionByWispSet) runs
without a testcontainer.

Adds BenchmarkGetLabelsForIssues_Mixed and
BenchmarkGetIssuesByIDs_Mixed at 1K / 10K / 50K with 25% wisp share.

Note for reviewer: two additional per-ID hot loops share the same
pattern (GetDependencyRecordsForIssuesInTx,
GetBlockingInfoForIssuesInTx in dependency_queries.go) and would
benefit from the same treatment. Left alone here to respect ADR
scope; flagged for a follow-up bead.

Dolt testcontainer runs flaky on this worktree (Docker 29.4 + ryuk
0.13.0). TESTCONTAINERS_RYUK_DISABLED=true works when infra
cooperates; unit-level coverage (TestPartitionByWispSet) runs
container-free and is green.

Refs: be-nu4.2.1, be-nu4

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

* chore: release gate PASS for be-eqw

* fix(storage): scope WispIDSetInTx to input IDs

Reviewer maphew on #3453 flagged that the new default helper builds
the active wisp set with an unscoped SELECT id FROM wisps for
nil-set callers. That turns a small hydration batch (N IDs) into a
full scan of the wisps table (W rows), which is worse than the
pre-PR per-ID IsActiveWispInTx path for small N against large W.

Scope the helper query to the input IDs so cost becomes O(N·log W)
+ 1 round-trip — strictly better than both the old per-ID path and
the current unscoped path.

Signature change: WispIDSetInTx now takes ids []string. Both
internal call sites (GetIssuesByIDsInTx, GetLabelsForIssuesInTx)
pass their input IDs through; all 13 existing nil-set callers
continue to pass nil and get a scoped internal build. Doc updated
on the wispSet parameter to reflect "set scoped to cover these
IDs."

Note: committed with --no-verify (authorized) because release/be-eqw
inherits a pre-existing pre-commit hook blocker — sanitizeDBName is
only defined in the cgo-tagged store_factory.go and the hook runs the
linter under CGO_ENABLED=0. be-4lf (on main) deletes the duplicate
extraction file; once release/be-eqw rebases onto main post-merge the
hook passes naturally. Green-field build/vet/gofmt and all wisp
routing tests were run locally before committing.

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

* test(storage): be-rgm WispIDSetInTx scoped path + small-N bench

be-3l2 fills the codecov gap on PR #3453 flagged by maphew:
WispIDSetInTx scope-to-input-IDs (14 missing lines on
wisp_routing.go, 0% on dependencies.go/labels.go hydration paths).

New tests in internal/storage/dolt/wisp_set_scoped_test.go:
- TestWispIDSetInTx_Scoped_ReturnsOnlyInputIDs — "lock the fix"
  regression: seeds 5 wisps, passes 1 ID, asserts the other 4
  are NOT in the set. Reverting to `SELECT id FROM wisps` fails this.
- TestWispIDSetInTx_Scoped_AcrossBatchBoundary — 250 wisps (past
  queryBatchSize=200) all pass through the batched IN-clause loop.
- TestWispIDSetInTx_Scoped_UnknownIDsReturnEmpty — unknown IDs
  return empty set; a bait wisp outside the input must not leak.
- TestGetLabelsForIssuesInTx_SmallInputLargeWispTable — end-to-end
  hydration with nil wispSet against 20 noise wisps; exercises the
  dependencies.go/labels.go callers that pass input IDs through.
- TestGetIssuesByIDsInTx_SmallInputLargeWispTable — same shape for
  issue hydration.

New benches in internal/storage/dolt/dolt_benchmark_test.go:
- BenchmarkGetLabelsForIssues_SmallNLargeW_10_5K / _10_10K / _100_5K
- BenchmarkGetIssuesByIDs_SmallNLargeW_10_5K / _10_10K / _100_5K
These measure the maphew regression shape: small input batch
against a large wisps table. Local 10_5K: ~2.6 ms/op, confirming
the scoped N·log(W) path wins cleanly over the pre-be-rgm
full-scan path (existing Mixed10K is ~1.35 s/op for the full
hydration, but that loads 10K not 10).

Note: committed with --no-verify (authorized). release/be-eqw
inherits a pre-existing pre-commit hook blocker — golangci-lint
on the hook is built with go1.25 while go.mod targets 1.26.2,
so the lint step errors before seeing the diff. Green-field
go vet, go build, and all five new tests pass locally against
an isolated Dolt test container.

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

---------

Co-authored-by: Jim Wordelman <jim@wordelman.name>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 13:39:42 -07:00