* fix(test): reap dolt sql-servers leaked by killed test runs
A `go test -timeout` panic skips every t.Cleanup and TestMain defer, so a
test run killed that way left its `dolt sql-server` running forever. Two
gaps kept anything from ever noticing:
1. On darwin the deleted-cwd signal could not fire. macOS lsof prints the
bare path of a working directory that has been unlinked — no
" (deleted)" suffix, unlike Linux's /proc/<pid>/cwd — so readDarwinCwd
always reported deleted=false and selectOrphanTestServerPIDs' orphan arm
was dead code on this platform. It now stats the path and treats ENOENT
(and only ENOENT) as deletion, via a pure parseDarwinCwd that takes the
stat function so the classification is unit-testable.
2. Nothing ever looked at a DEAD run's temp root again. Each suite swept
only its own root, after its own m.Run() — the one moment a killed run
never reaches. New in internal/doltserver: WriteSuiteOwnerMarker claims a
root with the owning PID, and SweepDeadSuiteRoots globs a suite's prefix
at the START of the next run and reaps only roots whose recorded owner is
gone. An unclaimed root and a root whose owner is alive (a parallel
package, a second `go test`) are both left exactly as they are, so this
keeps SweepOrphanedTestServers' contract: never a shared temp dir, never
another suite's live server. decideSuiteRoot holds that judgment alone
and is table-tested; the liveness probe is build-tagged darwin/linux with
an always-alive stub elsewhere, making the helper a no-op there.
Wired into the cmd/bd and internal/storage/dolt TestMains, plus a new
TestMain for internal/storage/uow — the package that produced the observed
orphan and had no suite lifecycle at all. It pins TMPDIR under a suite root
so every t.TempDir() is sweepable, and newTestUOWProvider's cleanup now
reads the backend pid file before proxy.Shutdown and fails the test if that
server is still alive five seconds later, so a leak is visible where it is
caused rather than inferred later from a sweep.
Each wired TestMain reports a non-empty post-run sweep loudly, and fails the
run on it only under BEADS_TEST_FAIL_ON_LEAK=1 — opt-in so one flaky test
cannot redden a package for everyone. No workflow sets it yet.
Tests: go test ./internal/doltserver/ -run 'Sweep|Orphan|Suite' -count=1;
go test ./internal/storage/uow/ -run TestUOWDependencyEditorContract -count=1
-timeout 10m (real dolt); go test ./cmd/bd/ -run 'TestMain|TestVersion'
-count=1 -timeout 5m; go build ./...; go vet over the three packages;
gofmt -l . clean; golangci-lint (gosec + misspell) clean over the touched
packages. Verified on a live box: the orphan with the deleted cwd was
reaped, while the production server, an unclaimed suite root's server, and
an unrelated dolt server were all left running.
Refs: wy-j2zc8q
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1sjyiTjodNqNqEzEFbKAE
* fix(test): bound the sweep to temp roots and verify before killing
Round 2 on the leaked-test-server sweep, addressing an adversarial review of
2d9d656b5. Every finding was about the same thing: the first pass reached
further than its own doc comments claimed.
1. selectOrphanTestServerPIDs' deleted-cwd arm was root-independent, and the
darwin fix had just brought it to life on macOS. A PRODUCTION server is
spawned with cmd.Dir = <workspace>/.beads/dolt, so a developer who moved
that workspace — or whose external volume unmounted — would have their
live server reaped by any test run on the box. The arm now also requires
the deleted path to have been under a temp root (tempDirRoots: os.TempDir
plus /tmp, each in both its literal and symlink-resolved form, which is
what makes macOS's /var/folders vs /private/var/folders pair match). This
was a live hazard on linux too.
2. SweepDeadSuiteRoots promised it only touched marker-owned dead roots, but
reached SweepOrphanedTestServers, whose deleted-cwd arm spans the whole
box — at suite START, with sibling packages mid-run. It now uses a new
strictly root-scoped entry point, sweepServersUnderRoots, with the shared
SIGTERM/SIGKILL loop factored out as reapServerPIDs on each platform. The
end-of-run sweep in the TestMains still uses the broad one, which finding
1 has now bounded to temp dirs.
3. The uow cleanup's exit check blind-killed a bare PID. The server is not
this process's child, so its PID is reusable, and proxy.Shutdown
deliberately REFUSES to signal a record it cannot verify — killing that
very PID defeated the protection. It now keeps the whole pidfile record,
runs only when Shutdown returned an error (success already kills and
confirms), and gates both the liveness check and the kill on
procid.Verify / procid.Open with the recorded birth token. Timeout raised
to 30s, since Shutdown's own budget is 5s + 2s.
4. os.RemoveAll deletes the marker early, so a partial failure left an
unclaimed root that no later run could ever touch. Removal now does a
chmod u+w walk first (mirroring cmd/bd's forceRemoveAll, which exists
because that root doubles as an isolated $HOME full of read-only module
cache entries), and on a still-failing removal it rewrites the marker with
the same dead PID so the next run retries.
5. internal/storage/dolt created its root and ran the sweep above the
isHelperSubprocess early return: eight concurrent helpers each swept and
each claimed a root that os.Exit then abandoned. Moved below it; a helper
inherits the parent's live BEADS_TEST_CIRCUIT_DIR through the BEADS_
allowlist in integration.FilterEnv.
6. SweepDeadSuiteRoots globs a world-writable directory, so a planted root
with a dead-PID marker could aim it at a tree of someone else's choosing.
It now requires the root's uid to be os.Getuid() (unix-only file, accept-
all stub elsewhere, where the sweep is inert anyway).
7. The symlink leg of the selection test skips instead of failing where
os.Symlink is unprivileged. 8. "favour" -> "favor".
Tests: go test ./internal/doltserver/ -run 'Sweep|Orphan|Suite|Darwin'
-count=1 -v (49 cases, incl. new ones for a moved production workspace, an
unmounted volume, the observed orphan in both macOS path forms, the
root-scoped selection, canonicalRoots, tempDirRoots, the marker-restore path
and the read-only-directory removal); gofmt -l . clean; go vet over
doltserver, uow, cmd/bd and storage/dolt; GOOS=windows and GOOS=linux go vet
./internal/doltserver/; golangci-lint clean over all four trees;
scripts/check-build-tags.sh clean; go build ./...; go test -c for uow,
cmd/bd and storage/dolt. The three live dolt sql-servers on the box were
untouched throughout.
Refs: wy-j2zc8q
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1sjyiTjodNqNqEzEFbKAE
* fix(test): isolate helper circuit state, re-verify late exits, bound TMPDIR
Round 3, from the verification pass on efb7a1c39 (PASS-WITH-NITS).
1. internal/storage/dolt: moving the suite root below the isHelperSubprocess
return also took the per-helper circuit-breaker directory with it, so all
eight of TestMultiProcessSchemaInit's helpers would have inherited the
parent's BEADS_TEST_CIRCUIT_DIR and read-modify-written ONE file keyed
host:port:db, concurrently — a fresh flake risk in the exact test the move
was meant to protect. The helper branch now makes its own temp directory
and overrides the variable, as it effectively did before. No sweep and no
owner marker for helpers: they start no server, and a helper that leaves
through os.Exit would only abandon a marked root.
2. internal/storage/uow: requireBackendExited could observe the server alive
and then have it exit before procid.Open/Kill, which report a plain
"does not match token" that IsProcessGone does not match — so a server
that stopped a few milliseconds late was reported as one that survived
Shutdown entirely. Both failure paths now re-verify once and stay silent
when the process is gone; only a verifiably-live process is a t.Errorf. A
record with no birth token now logs the skip instead of returning
silently, so it cannot pass for a clean check.
3. internal/doltserver: tempDirRoots now drops roots too broad to be evidence
of anything. TMPDIR is an ordinary environment variable, so os.TempDir()
can hand back "/" or a home directory, and either would put every
workspace on the box back inside the deleted-cwd arm. isCredibleTempRoot
rejects the filesystem root, a relative path, and any directory that is or
contains $HOME, while /tmp, /private/tmp and /var/folders/… survive.
4. The identical SIGTERM/SIGKILL loop in sweep_darwin.go and sweep_linux.go
is now one reapServerPIDs in sweep_reap_unix.go, taking the platform's
identity probe as an isServer validator. It sits in a darwin||linux file
rather than the portable sweep.go because the signaling is POSIX; the
selection logic that decides which pids reach it stays platform-agnostic
in sweep.go.
Tests: go test ./internal/doltserver/ -run 'Sweep|Orphan|Suite|Darwin|TempDir'
-count=1 (53 cases; new TestTempDirRootsRejectsOverbroadTMPDIR drives
TMPDIR=/ and TMPDIR=$HOME through the real os.TempDir, and
TestIsCredibleTempRoot tables the predicate); gofmt -l . clean; go vet over
doltserver, uow, storage/dolt and cmd/bd; GOOS=windows and GOOS=linux go vet
./internal/doltserver/; golangci-lint clean over all four trees;
scripts/check-build-tags.sh clean; go build ./...; go test -c for uow,
cmd/bd and storage/dolt.
Refs: wy-j2zc8q
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1sjyiTjodNqNqEzEFbKAE
* fix(sweep): keep /tmp credible when HOME is a sandbox under it (wy-j2zc8q)
PR core went red on every Linux runner: TestTempDirRootsBoundTheOrphanArm
and TestTempDirRootsRejectsOverbroadTMPDIR reported tempDirRoots() empty.
Cause: scripts/ci/lib/test-env.sh exports HOME under a mktemp -d root in
/tmp, and isCredibleTempRoot rejected any root that CONTAINS the home —
so /tmp itself was thrown out and the deleted-cwd arm silently disabled on
exactly the boxes whose killed runs it exists to clean up after. macOS
never showed it: the sandbox home lands under /var/folders, and the
hardcoded /tmp survived.
The carve-out: a home living inside the fixed /tmp fallback is a SANDBOX
home that anchors no workspaces, so a root that merely contains it stays
credible. A root that IS the home is still dropped whatever the home looks
like, and the sandbox test is judged against the hardcoded /tmp, never
os.TempDir(), so TMPDIR=/home with HOME=/home/runner still reads as a real
home under an overbroad root.
Tests: the overbroad-TMPDIR test now pins HOME to a real-shaped
non-temp path (the ambient one is the sandbox on CI, where "a workspace
under HOME" and "a path under /tmp" are the same path), plus two new
subtests for the sandbox shape and a sandbox row set in the predicate
table. Reproduced the red and the fix on Linux in docker with
HOME=/tmp/beads-test-env-abc/home; also green with HOME=/home/runner and
/root, and on macOS.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEmu5ZSFoappn7s9yUQ3aF
* fix(test): stop leaking daemonized shared-server dolt from test fixtures (wy-j2zc8q)
Every uow fixture that provisions a shared-server workspace now registers
ONE cleanup, verifiedShutdownCleanup, which stops the proxy and its
`dolt sql-server` and — when proxy.Shutdown reports an error — asserts the
recorded backend pid is actually gone (procid birth-token gated) instead of
printing a t.Logf line into a passing test. Nine copies of the silent idiom
are gone; an AST guard fails the package if a fixture provisions a workspace
without the cleanup, or calls proxy.Shutdown by hand.
A reaped server now FAILS the suite that leaked it (ApplyLeakPolicy), with
BEADS_TEST_ALLOW_LEAK=1 as the triage-only downgrade. The previous default
warned on stderr and exited 0, which is how all three recurrences rode green
suites and were rediscovered from a dev box's process table.
The dead-run root sweep (owner marker + SweepDeadSuiteRoots) is extended to
the remaining packages that pin a suite temp root and start servers:
cmd/bd/doctor (cgo + !cgo), cmd/bd/doctor/fix (cgo + !cgo), internal/beads.
* test(uow): guard pairs shutdownOnInterrupt with verifiedShutdownCleanup, exempts validation-error fixtures (wy-j2zc8q)
Salvaged from the executor's worktree after the quiet-hours stop: rules A/B/C
over *testing.T functions, non-vacuity counters per rule.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YWogqyZMByH2fYqUcafXvw
* fix(sweep): treat the per-user temp tree as a sandbox home root (wy-j2zc8q)
isSandboxHome whitelisted only /tmp, so on macOS a suite that pins HOME to a
t.TempDir() (cmd/bd/test_repo_beads_guard_test.go:128,
internal/beads/testmain_test.go:50) put HOME inside os.TempDir() itself
(/var/folders/xx/yy/T). isCredibleTempRoot then dropped os.TempDir() as "a
directory containing the user's home", tempDirRoots() collapsed to
[/tmp /private/tmp], and the deleted-cwd arm of SweepOrphanedTestServers was
inert on every Mac.
Judge sandbox-ness against a FIXED platform table (isUnderFixedTempRoots /
fixedTempRoots): /tmp everywhere, plus /var/folders on darwin,
canonicalRoots-expanded so /private/var/folders matches. TMPDIR still never
votes on its own credibility, so TMPDIR=/home with HOME=/home/runner keeps
reading as a real home under an overbroad root.
goos is a parameter, not a read of runtime.GOOS, so the darwin row is pinned
from Linux too.
Ran: go test -count=1 -run
'TestSandboxHomeUnderPerUserTempRoot|TestTempDirRoots|TestIsCredibleTempRoot|TestCanonicalRoots'
./internal/doltserver/ (ok); the pre-fix repro
HOME=$TMPDIR/fake-home-probe go test -run TestTempDirRootsBoundTheOrphanArm
now passes.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVJ7A7qWZYATyg2TsqggSA
* test(uow): exempt rule C by explicit name marker, not an error assertion (wy-j2zc8q)
The old rule-C exemption — "a function calling require.Error/ErrorContains
asserts the constructor rejected its arguments" — inferred intent from the
body, and TestNewExternalDoltServerUOWProvider_PreexistingDirtyDatabaseIsNotHealed
satisfied it by accident: it provisions a REAL external server, require.NoError
on the constructor, then asserts an error from a later query. Deleting BOTH
cleanup helpers from it left the guard green (mutation G).
Exempt only on an explicit, greppable name marker (_ValidationErrors), and
check the marker is not a lie: an exempted function must assert a rejection
(require.Error/ErrorContains) and must assert nothing succeeded (no
require.NoError/assert.NoError) — closing the rename-to-dodge path too. No
non-vacuity floor on the exemption count: if the marker stops matching, rule C
only gets stricter and the validation fixtures fail loudly.
Positive controls (both reverted):
- mutation G (drop both helpers from PreexistingDirty…) → FAIL:
"TestNewExternalDoltServerUOWProvider_PreexistingDirtyDatabaseIsNotHealed
provisions a shared-server workspace but never calls
verifiedShutdownCleanup(t, storeRootDir)"
- mutation G renamed to wear the marker → FAIL: "wears the
\"_ValidationErrors\" exemption but calls require.NoError/assert.NoError"
Ran: go test -count=1 ./internal/storage/uow/ -run
'TestEveryServerFixtureRegistersVerifiedCleanup' (ok; census: rule A paired 9,
rule C checked 8, exempted 2). go vet ./internal/storage/uow/ clean.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVJ7A7qWZYATyg2TsqggSA
* test(doctor): fail the doctor and fix suites on a swept leak (wy-j2zc8q)
ApplyLeakPolicy was wired into 4 of 7 TestMains; the three doctor-side suites
called SweepOrphanedTestServers and discarded its result, so a leaked dolt
sql-server there was reaped silently and the run still went green — the exact
blindness the policy exists to remove.
Four call sites across the three suites, in the pattern
cmd/bd/test_repo_beads_guard_test.go:52-54 and
internal/storage/uow/testmain_test.go:65-66 already use:
cmd/bd/doctor/testmain_nocgo_test.go -> "cmd/bd/doctor"
cmd/bd/doctor/dolt_e2e_test.go (cgo) -> "cmd/bd/doctor"
cmd/bd/doctor/fix/testmain_cgo_test.go -> "cmd/bd/doctor/fix"
cmd/bd/doctor/fix/testmain_nocgo_test.go -> "cmd/bd/doctor/fix"
Both build-tag variants compile.
Ran: go vet ./cmd/bd/doctor/... (0 issues); CGO_ENABLED=0 go vet
./cmd/bd/doctor/... (0 issues); go build ./... OK; go vet ./internal/doltserver/
./internal/storage/uow/ ./cmd/bd/doctor/... OK; gofmt -l internal cmd empty;
GOOS=linux go build ./... OK; GOOS=windows go build ./... OK.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BVJ7A7qWZYATyg2TsqggSA
* fix(sweep): pin darwin's fixed temp roots to their resolved forms (wy-j2zc8q)
fixedTempRoots("darwin") listed {"/tmp", "/var/folders"} and left the
/private/… forms to canonicalRoots' filepath.EvalSymlinks, which reads the
HOST filesystem: it adds them on a Mac and nothing at all on Linux. The
platform table is a claim ABOUT darwin that TestSandboxHomeUnderPerUserTempRoot
deliberately judges from any platform, so ubuntu CI saw
isUnderFixedTempRoots("/private/var/folders/…/fake-home", "darwin") = false.
Spell the resolved forms out in the table instead — "/private/tmp" and
"/private/var/folders" — so the answer is host-independent. canonicalRoots
dedups, so on a Mac they are exactly what it would have added anyway, and the
darwin lsof cwd form now matches from any judging platform. Linux rows are
unchanged.
The subtest is also given a direct assertion on the table's contents: the
isUnderFixedTempRoots rows alone cannot catch a dropped literal when they run
on a Mac (EvalSymlinks puts it back), so the mutation that started this would
have passed locally forever.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MPryBr9EE2Px9crZ4NrTT
* test(bd): move the darwin sweep guard onto the leak-fails-the-suite contract (wy-j2zc8q)
TestRunTestsAndSweepReapsOrphanedServer predates ApplyLeakPolicy (097757b3e,
wy-s4zdj) and asserted the OLD policy: a swept orphan still exits 0. With the
policy in place it fails on macOS CI with runTestsAndSweep() = 1, want 0 —
the test was pinning exactly the behavior this PR removes.
Restate it as the two-case contract it is now: the existing case expects 1
(a swept leak fails an otherwise-passing suite), and a sibling sets
doltserver.AllowLeakEnv to "1" and expects 0. Both still assert the fake
server was actually reaped; the fake-dolt shape and the reap wait are
unchanged.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MPryBr9EE2Px9crZ4NrTT
* fix(sweep): report the leaked server's working directory, not just its PID (wy-j2zc8q)
Both leak lines named PIDs only:
Info: swept 1 orphaned test dolt sql-server process(es): [21881]
FAIL: cmd/bd leaked 1 dolt sql-server process(es) [21881]; swept them.
By the time anyone reads that, 21881 has been dead for minutes and identifies
nothing — so a package with hundreds of tests reported a leak with no way to
find which fixture caused it. The sweep already knew the answer: every
candidate carries the cwd it was serving (serverCandidate.cwd), and a leaked
test server's cwd is the .beads/dolt under the suite's temp tree, which Go
names after the test that made it (<root>/TestSomeName1234/001).
Thread it through. selectCandidatePIDs/selectOrphanTestServerPIDs become
selectServers/selectOrphanTestServers returning a new exported SweptServer
{PID, Cwd}, reapServerPIDs becomes reapServers over the same type, and
SweepOrphanedTestServers and ApplyLeakPolicy carry it end to end — every
existing call site is a pass-through from the one to the other, so they are
unchanged. SweptServer.String renders "<pid> cwd=<dir>", which is what the
two stderr lines now print:
Info: swept 1 ... process(es): [21881 cwd=/tmp/TestFoo123/001/.beads/dolt]
Tests: the darwin ps/lsof selection path now asserts whole SweptServers
(cwd included) rather than PIDs; TestSweptServerNamesItsDirectory pins the
rendering; TestApplyLeakPolicyNamesTheLeakingDirectory captures stderr and
pins the cwd in both the FAIL and the downgraded Warning line; and
TestReapServersReportsTheLeakedDirectory pins the Info line against a real
reaped process. sweep_other.go (non-unix) keeps the same shape.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MPryBr9EE2Px9crZ4NrTT
* fix(test): stop the shared dolt sql-server three init fixtures daemonize (wy-j2zc8q)
The leak the new guard catches. `bd init` in shared-server mode takes the
shouldInitSharedGlobalDB branch (cmd/bd/init.go:1417) and calls
doltserver.Start(sharedDir), which DAEMONIZES — cmd.Process.Release(), no
Wait, cmd.Dir = <sharedDir>/dolt (doltserver.go:1443-1446). Three cmd/bd
fixtures run that as a subprocess with BEADS_DOLT_SHARED_SERVER=1 and never
stop it, so the server outlives the `bd` that started it, the test that ran
it and the suite whose temp HOME it is serving:
cmd/bd/dolt_worktree_remote_test.go:34 (--prefix remote-sync)
cmd/bd/init_test.go:2096 (--prefix bare-fallback)
cmd/bd/init_test.go:2318 (--prefix bare-core)
Evidence: a full local `go test ./cmd/bd/` left
`dolt sql-server --config <suite root>/.beads/shared-server/dolt-server-config.yaml`
running with cwd /private/var/folders/…/beads-bd-tests-1850365081/.beads/
shared-server/dolt and databases beads_global + remote_sync — the remote-sync
prefix names the fixture. All three resolve the SAME $HOME/.beads/shared-server,
so only the last starter leaves a survivor; the process table names one while
three carry the defect.
stopSharedServerCleanup (new cmd/bd/shared_server_cleanup_test.go) is the one
cleanup they now register, before the first subprocess so the t.Fatalf paths
are covered: record the pid from doltserver.IsRunning BEFORE stopping (a clean
Stop deletes the pid file), capture its procid birth token, doltserver.Stop,
then assert the recorded process actually left — t.Errorf and a force-kill if
it did not. Birth-token gated throughout: the server is not this process's
child, so its PID is reusable the moment it exits. Same shape as
verifiedShutdownCleanup in internal/storage/uow (35faf60e5).
Verified both ways on the same two tests:
before: FAIL: cmd/bd leaked 1 dolt sql-server process(es)
[4217 cwd=/private/var/folders/…/beads-bd-tests-1902359010/.beads/shared-server/dolt]
after: no Info/FAIL leak line, no sql-server left under any suite root
The three assertion failures in those tests (dolt_worktree_remote_test.go
sync.remote, init_test.go DoltMode server/embedded) reproduce identically with
and without this commit — pre-existing, untouched here.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MPryBr9EE2Px9crZ4NrTT
* fix(test): stop the shared and proxied servers the init-metrics fixture daemonizes (wy-j2zc8q)
The post-run sweep on 164661ce4c named a fourth leaker on both CI runners:
`bd-metrics-home-*/.beads/shared-server/dolt`, TestInitMetricsEmittedPerDoltMode's
shared_server_via_flag case. That fixture runs `bd init --shared-server` with
HOME set only in the subprocess env, so the daemonized shared server lives
under a tree the in-process stopSharedServerCleanup never looks at. The same
table's proxied_server_via_flag case leaves a proxy plus its backend server
under <repo>/.beads/dolt with proxy.pid / proxy-child.pid records that no
dolt-server.pid cleanup can see.
- stopDoltServerCleanup(t, beadsDir): the existing verified stop, now with
an explicit beads directory; stopSharedServerCleanup keeps its signature.
- stopProxiedServerCleanup(t, proxyRoot): proxy.Shutdown (the verified stop
`bd dolt stop` performs) when either record exists.
- runBdInitForMetrics registers both before the subprocess runs, and the
shared case now passes BEADS_DOLT_SERVER_PORT=<free port> so it actually
starts a server on a box whose 3308 is already taken instead of silently
skipping the path (the previously unused extraEnv field carries it).
Probe: with the two registrations commented out the sweep reports both
servers (`swept 2 ... bd-metrics-home-*/.beads/shared-server/dolt ...
bd-metrics-repo-*/.beads/dolt`); with them in place the package is ok.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXZ9wbaFUnzRWcMj7iBxmq
* fix(test): scope suite leak attribution and verify cleanup (bd-154w)
Maintainer fixup for PR #6441, review attempts 1, 2, and 3.
Wire dbproxy/server into the marked suite-root lifecycle and verify the
standard fixture's backend shutdown before its directory is removed.
Capture synthetic leak-policy stderr, share the suite-root guard helper,
and document the manual repro harness's unconditional Kill/Wait cleanup.
Use SweepSuiteTestServers for every failure-producing post-run sweep,
including CGO, non-CGO, and integration callers. It delegates to the
existing strict root selector so a clean suite cannot reap another live
suite's deleted-cwd leak or fail in its place. Keep abandoned-run cleanup
separate through owner-checked SweepDeadSuiteRoots, and deprecate the
legacy global sweep for TestMain use without deleting contributor tests.
Pin and mark the integration suite's temporary root to retain detection.
Add a Linux process regression proving clean B preserves A's deleted-cwd
server and passes, then A reaps its own server and fails. Retain dead-owner
cleanup coverage and guard both integration temporary-directory APIs.
Pin the storage, CLI, and internal/beads suite roots before fixtures run,
with guards for both temporary-directory APIs. Preserve the storage helper
subprocess early return and the original parent for abandoned-root cleanup.
A Linux subprocess regression exercises the real storage TestMain: an
owned deleted-cwd fixture fails its suite while a foreign process survives.
Keep the CLI sandbox HOME beside fixtures so ~/.beads cannot become a
fixture ancestor and interfere with worktree repository discovery.
Keep integration server data owned but allocate its Unix socket in a short,
private directory with explicit cleanup. Exercise a data path exceeding
the Unix socket path budget while retaining the real SQL round trip.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Agent-Signature: Codex-unknown-model-unknown-reasoning on behalf of Julian Knutsen
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Eddie the Engineer <julianknutsen@users.noreply.github.com>
Utility scripts for maintaining the beads project.
ci/
Repository-owned CI command wrappers. These scripts are the source of truth for
the target CI tiers; Make targets are aliases for local discoverability.
make ci-pr-core
make ci-pr-policy
make ci-pr-lint
make ci-package-mcp
make ci-package-npm
Each wrapper auto-detects the repository root, sources .buildflags when it
invokes Go in the default build mode, and records per-command timing through
scripts/ci/lib/timing.sh.
Broad Go test wrappers also source scripts/ci/lib/test-env.sh, which creates a
temporary HOME/XDG/Dolt root, isolates Git global/system config, clears runtime
Beads/Dolt environment variables, and sets BEADS_TEST_SKIP=dolt before tests
run. This keeps local make test and make ci-pr-core results comparable to
the fast PR-core contract even on shared agent hosts. Set
BEADS_TEST_ENV_RUN_DOLT=1 only when intentionally running the Dolt-dependent
tests through these broad wrappers, or BEADS_TEST_ENV_DISABLE=1 when debugging
against your real local configuration.
The broad Go wrappers also cap package and test parallelism to 4 by default
(GO_TEST_PKG_PARALLEL and GO_TEST_PARALLEL). This avoids turning high-core
shared hosts into a different test topology than GitHub Actions.
make ci-pr-policy includes scripts/check-testing-short.sh, which enforces
that testing.Short() is only used for runtime, stress, or large-fixture skips.
Use build tags, environment checks, or named wrappers for integration/e2e/API
boundaries.
make ci-package-mcp builds or consumes a bd binary, puts it on PATH as
bd, then runs locked MCP package uv sync, Ruff, mypy, pytest, and build
checks.
make ci-package-npm builds or consumes the native binary expected by
npm-package/bin/bd, runs the npm package test suite, and checks
npm pack --dry-run.
Set BEADS_TEST_BD_BINARY=/path/to/bd for MCP and npm package gates to reuse a
prebuilt candidate binary instead of rebuilding it inside the wrapper.
pr-preflight.sh
Read-only PR safety check for agents and maintainers.
# Before implementing or opening a related PR
./scripts/pr-preflight.sh --search "topic keywords" --repo gastownhall/beads
# Before changing, closing, or merging an existing PR
./scripts/pr-preflight.sh 123 --repo gastownhall/beads
It reports contributor/fork status, draft/review/merge/check state, risky diff
signals such as .beads/ changes or missing tests, and the required
contributor-protection next steps. It does not replace code review or local
validation.
Base-branch health is supplemented by a warn-only PR-gate sample: the last 60
completed pull_request-event runs, grouped per workflow. A single workflow
whose decisive runs (>= 5, across >= 3 distinct head branches) are all
failure-class is reported as a broken PR gate — the case where a job that
exists only in the PR workflow is red for every PR while the base branch shows
green. This detector never blocks (deliberately: automation classifies
unrecognized [block] lines as genuine merge blockers and would park merge
lanes on a false positive); it is skipped entirely while the base branch is
red.
gh-body-lint
Lint Markdown files before posting them with gh ... --body-file.
The lint catches literal \n sequences, which render poorly on GitHub, and
GH#123 references, which do not auto-link like #123 or owner/repo#123.
release.sh (⭐ The Easy Button)
One-command release from version bump to local installation.
Usage
# Full release (does everything)
./scripts/release.sh 0.9.3
# Preview what would happen
./scripts/release.sh 0.9.3 --dry-run
What It Does
This master script automates the entire release process:
✅ Stops running Dolt servers (avoids version conflicts)
✅ Runs tests and linting
✅ Bumps version in all files
✅ Commits and pushes version bump
✅ Creates and pushes git tag
✅ Verifies or opens the Homebrew core formula PR
✅ Upgrades local Homebrew installation
✅ Verifies everything works
After this script completes, your system is running the new version!
Examples
# Release version 0.9.3
./scripts/release.sh 0.9.3
# Preview a release (no changes made)
./scripts/release.sh 1.0.0 --dry-run
Prerequisites
Clean git working directory
All changes committed
golangci-lint installed
Homebrew installed (for local upgrade)
Push access to gastownhall/beads
Output
The script provides colorful, step-by-step progress output:
🟨 Yellow: Current step
🟩 Green: Step completed
🟥 Red: Errors
🟦 Blue: Section headers
What Happens Next
After the script finishes:
GitHub Actions builds binaries for all platforms (~5 minutes)
PyPI package is published automatically
Homebrew core formula is verified or tracked through its canonical PR
Users can brew upgrade beads to get the new version after Homebrew merges
GitHub Release is created with binaries and changelog
bump-version.sh
Bumps the version number across all beads components in a single command.
Usage
# Show usage
./scripts/bump-version.sh
# Update versions (shows diff, no commit)
./scripts/bump-version.sh 0.9.3
# Update versions and auto-commit
./scripts/bump-version.sh 0.9.3 --commit
What It Does
Updates version in all these files:
cmd/bd/version.go - bd CLI version constant
plugins/beads/.claude-plugin/plugin.json - Claude plugin version
plugins/beads/.codex-plugin/plugin.json - Codex plugin version
.claude-plugin/marketplace.json - Claude marketplace plugin version
integrations/beads-mcp/pyproject.toml - MCP server version
README.md - Alpha status version
PLUGIN.md - Version requirements
Features
Validates semantic versioning format (MAJOR.MINOR.PATCH)
Verifies all versions match after update
Shows git diff of changes
Auto-commits with standardized message (optional)
Cross-platform compatible (macOS and Linux)
Examples
# Bump to 0.9.3 and review changes
./scripts/bump-version.sh 0.9.3
# Review the diff, then manually commit# Bump to 1.0.0 and auto-commit
./scripts/bump-version.sh 1.0.0 --commit
git push origin main
Why This Script Exists
Previously, version bumps only updated cmd/bd/version.go, leaving other components out of sync. This script ensures all version numbers stay consistent across the project.
Safety
Checks for uncommitted changes before proceeding
Refuses to auto-commit if there are existing uncommitted changes
Validates version format before making any changes
Verifies all versions match after update
Shows diff for review before commit
sign-windows.sh
Signs Windows executables with an Authenticode certificate using osslsigncode.
Usage
# Sign a Windows executable
./scripts/sign-windows.sh path/to/bd.exe
# Environment variables required for signing:exportWINDOWS_SIGNING_CERT_PFX_BASE64="<base64-encoded-pfx>"exportWINDOWS_SIGNING_CERT_PASSWORD="<certificate-password>"
What It Does
This script is called automatically by GoReleaser during the release process:
Decodes the PFX certificate from base64
Signs the Windows executable using osslsigncode
Timestamps the signature using DigiCert's RFC3161 server
Replaces the original binary with the signed version
Verifies the signature was applied correctly
Prerequisites
osslsigncode installed (apt install osslsigncode or brew install osslsigncode)
The script prints a warning and exits successfully
GoReleaser continues without signing
The release proceeds with unsigned Windows binaries
This allows releases to work before a certificate is acquired.
Why This Script Exists
Windows code signing helps reduce antivirus false positives that affect Go binaries.
Kaspersky and other AV software commonly flag unsigned Go executables as potentially
malicious due to heuristic detection. See docs/reference/antivirus.md for details.
Future Scripts
Additional maintenance scripts may be added here as needed.