From 6deca80cf273873d91251861eef1cd7ce4f35e5c Mon Sep 17 00:00:00 2001 From: Jim Wordelman Date: Thu, 20 Aug 2026 06:31:01 -0700 Subject: [PATCH] fix(dolt): remove dead decoy-listener test code, use retry-safe schema init under 10-way contention (#5880) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 e2a7bbb90bcd1077bd785236a4915c899ed059d8 (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. --- .../dolt/initschema_multiprocess_test.go | 22 ++++++++-- .../dolt/multistore_multiprocess_test.go | 9 +++- .../be-u8ldr-multiprocess-schema-init-gate.md | 41 +++++++++++++++++++ 3 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 release-gates/be-u8ldr-multiprocess-schema-init-gate.md diff --git a/internal/storage/dolt/initschema_multiprocess_test.go b/internal/storage/dolt/initschema_multiprocess_test.go index 7a276a2bf..1a3fbfc04 100644 --- a/internal/storage/dolt/initschema_multiprocess_test.go +++ b/internal/storage/dolt/initschema_multiprocess_test.go @@ -215,7 +215,7 @@ func TestMultiProcessSchemaInit_DoltVerify(t *testing.T) { t.Fatalf("mkdir dolt: %v", err) } - initCmd := exec.Command(doltPath, "init") + initCmd := exec.Command(doltPath, "init", "--name", "test", "--email", "test@example.com") initCmd.Dir = doltDir initCmd.Env = append(os.Environ(), "HOME="+tmpDir, "DOLT_ROOT_PATH="+tmpDir) if out, err := initCmd.CombinedOutput(); err != nil { @@ -226,6 +226,17 @@ func TestMultiProcessSchemaInit_DoltVerify(t *testing.T) { t.Setenv("BEADS_DOLT_SHARED_SERVER", "0") t.Setenv("BEADS_DOLT_AUTO_START", "1") + // Regression coverage for a round-1 review finding: BEADS_DOLT_SERVER_PORT + // is the top-priority, authoritative port source (see portSources in + // internal/doltserver/doltserver.go) — an ambient value left by an + // unrelated process on a shared host pointed doltserver.Start at that + // process's port, and Start correctly refused to steal it, failing this + // test for a reason unrelated to schema init. This test manages its own + // throwaway server, so it isolates itself from ambient port config the + // same way it already isolates BEADS_DOLT_SHARED_SERVER/ + // BEADS_DOLT_AUTO_START above. + t.Setenv("BEADS_DOLT_SERVER_PORT", "") + state, err := doltserver.Start(beadsDir) if err != nil { t.Fatalf("Start: %v", err) @@ -270,7 +281,12 @@ func TestMultiProcessSchemaInit_DoltVerify(t *testing.T) { defer db.Close() db.SetMaxOpenConns(2) <-ready - _, err = initSchemaOnDB(egCtx, db) + // initSchemaOnDBWithRetry, not the raw initSchemaOnDB: real bd + // processes racing for the migration lock go through this same + // retry wrapper (store.go's initSchema), which exists precisely so + // contended GET_LOCK attempts converge instead of one unlucky + // waiter failing outright. + _, err = initSchemaOnDBWithRetry(egCtx, db) return err }) } @@ -293,7 +309,7 @@ func TestMultiProcessSchemaInit_DoltVerify(t *testing.T) { dbDir = doltDir } - verifyCmd := exec.Command(doltPath, "verify") + verifyCmd := exec.Command(doltPath, "fsck") verifyCmd.Dir = dbDir verifyCmd.Env = append(os.Environ(), "HOME="+tmpDir, "DOLT_ROOT_PATH="+tmpDir) verifyOut, verifyErr := verifyCmd.CombinedOutput() diff --git a/internal/storage/dolt/multistore_multiprocess_test.go b/internal/storage/dolt/multistore_multiprocess_test.go index 7332f2620..d1be8a86e 100644 --- a/internal/storage/dolt/multistore_multiprocess_test.go +++ b/internal/storage/dolt/multistore_multiprocess_test.go @@ -79,7 +79,7 @@ func TestHelperMultiStore(t *testing.T) { var inserted bool for retry := 0; retry < 5; retry++ { _, err := db.ExecContext(ctx, - "INSERT INTO issues (id, title, status, priority, issue_type, created_at, updated_at) VALUES (?, ?, 'open', 2, 'task', NOW(6), NOW(6))", + "INSERT INTO issues (id, title, description, design, acceptance_criteria, notes, status, priority, issue_type, created_at, updated_at) VALUES (?, ?, '', '', '', '', 'open', 2, 'task', NOW(6), NOW(6))", issueID, title, ) if err == nil { @@ -106,6 +106,11 @@ func TestHelperMultiStore(t *testing.T) { os.Exit(1) } + if created != numOps || count != created { + fmt.Fprintf(os.Stderr, "FAIL proc=%s created=%d verified=%d numOps=%d\n", procID, created, count, numOps) + os.Exit(1) + } + fmt.Fprintf(os.Stdout, "OK proc=%s created=%d verified=%d\n", procID, created, count) } @@ -174,7 +179,7 @@ func TestMultiStoreConcurrent_InProcess(t *testing.T) { id := fmt.Sprintf("ms-%d-%d", idx, op) title := fmt.Sprintf("Multi-store issue %d-%d", idx, op) _, err := db.ExecContext(egCtx, - "INSERT INTO issues (id, title, status, priority, issue_type, created_at, updated_at) VALUES (?, ?, 'open', 2, 'task', NOW(6), NOW(6))", + "INSERT INTO issues (id, title, description, design, acceptance_criteria, notes, status, priority, issue_type, created_at, updated_at) VALUES (?, ?, '', '', '', '', 'open', 2, 'task', NOW(6), NOW(6))", id, title, ) if err != nil { diff --git a/release-gates/be-u8ldr-multiprocess-schema-init-gate.md b/release-gates/be-u8ldr-multiprocess-schema-init-gate.md new file mode 100644 index 000000000..c3854b4d6 --- /dev/null +++ b/release-gates/be-u8ldr-multiprocess-schema-init-gate.md @@ -0,0 +1,41 @@ +# Release gate — be-u8ldr (multiprocess dolt schema-init retry + test isolation fix) + +**Date:** 2026-08-20 +**Deployer:** beads/deployer +**Bead (deploy):** be-u8ldr — needs-deploy: Fix: multiprocess tests INSERT without issues.description an (from:be-4oah9) +**Source bead (build):** be-kafb — tdd_green fa825dcbd6a9cf389c42e5ab3b5a5b2f58aafcf9 +**Review bead (round 1):** be-yzowm — closed, request-changes → superseded by round 2/3 rework +**Review bead (round 2/3):** be-4oah9 — closed, close_reason "pass", `verdict: PASS`, `review_round: 3` +**Source commit:** `e2a7bbb90bcd1077bd785236a4915c899ed059d8` — "fix(dolt): remove dead decoy-listener test code, use retry-safe schema init under 10-way contention" (refs be-4oah9, be-yzowm, be-kafb) +**Provenance branch:** `builder/be-kafb` — provenance only, not a push target (shared builder branch) +**Deploy branch (isolated, cut from source commit above):** `deploy/be-u8ldr-gate` +**Base:** `origin/main` @ `d38ac728b581c8595fae36344ecca68830c7f3b5` ("fix(httpapi): make beads_dir and repo_root optional in ContextResponse (#5757)") +**Merge-base:** `ed382cbdb89cf7ba42b020e4927575dbf27e102e` +**Merge-tree simulation:** `git merge-tree --write-tree origin/main e2a7bbb90b` → tree `90320eb53df70b48ab8014c0ae231e673d0991ba`, exit 0, **zero conflict markers** +**Ancestry scope check:** `assert_deploy_ancestry_scope origin/main e2a7bbb90b be-u8ldr be-4oah9 be-yzowm be-kafb` → exit 0 (both commits between merge-base and source commit cite an accepted bead id; no `.claude/**` paths touched) + +## Pre-flight: already merged/PR'd? + +`DEPLOY_MODE=remote` (origin and fork both resolve to github.com URLs). No PR URL recorded in be-u8ldr. Checked `gh api repos/gastownhall/beads/commits/e2a7bbb90bcd1077bd785236a4915c899ed059d8/pulls` → `[]` (no PR exists for this SHA). Checked `git merge-base --is-ancestor e2a7bbb90b origin/main` → not an ancestor (not already merged). Clean to proceed with the normal flow. + +## Verdict: PASS + +## Criteria walk + +| # | Criterion | Result | Evidence | +|---|-----------|--------|----------| +| 6 | Branch diverges cleanly from main | PASS | `git merge-tree --write-tree origin/main e2a7bbb90b` succeeds, single merged tree, no conflicts. Source commit is 28 commits behind current `origin/main`, but none of those 28 touch `internal/storage/dolt/initschema_multiprocess_test.go` (`git log --oneline SHA..origin/main -- ` → empty). No self-rebase needed. | +| 1 | Review PASS present | PASS | be-4oah9 closed by beads/reviewer, close_reason "pass". Round-3 notes: `style_findings` all clean (gofmt/build/vet×2), `security_findings` — diff is a pure subset of round-1's already-walked 9-point OWASP review, zero new attack surface, no go.mod/go.sum change. `verdict: PASS`, `review_round: 3`. | +| 2 | Acceptance criteria met | PASS | Original three-part bug (title: "INSERT without issues.description and report OK on zero writes; dolt init has no identity"): (a) `issues.description/design/acceptance_criteria/notes` are `TEXT NOT NULL` with no default — INSERT now includes them (verified against `internal/storage/schema/migrations/0001_create_issues.up.sql` in be-yzowm round 1); (b) write-count mismatch now `os.Exit(1)`s instead of silently reporting OK (confirmed independently by round-2 reviewer); (c) `dolt init --name/--email` fix verified against baseline failure "empty ident name not allowed" (be-yzowm round 1). All three fixed and untouched by this round's diff — round 3 closes the sole remaining gap, the diff-owned test's own susceptibility to ambient dolt-server port/lock state. | +| 3 | Tests pass (documented CI-equivalent command, real counts) | PASS | **Independently re-run by this deployer** (not just trusting reviewer's report) at the exact source commit, disposable scratch worktree, `DOCKER_HOST=unix:///run/user/1000/podman/podman.sock TESTCONTAINERS_RYUK_DISABLED=true go test -race -tags=integration,gms_pure_go -timeout=200s -count=1 -v -run '' ./internal/storage/dolt/...`. `TestMultiProcessSchemaInit_DoltVerify`: PASS×2 (clean env 8.95s; ambient `BEADS_DOLT_SERVER_PORT=28231` set, replicating round-1/round-2's adversarial condition, 8.33s). Adjacent regression suite (`TestMultiProcessSchemaInit`, `TestHelperMultiStore`, `TestMultiStoreConcurrent_{InProcess,Subprocess,CloseIsolation}`): PASS×5. **Totals: 7 PASS / 0 FAIL / 0 SKIP** across both runs. `gofmt -l`, `go build ./...`, `go vet -tags=integration,gms_pure_go ./internal/storage/dolt/...`: all clean, exit 0. | +| 3a | Pre-existing-failure attribution | N/A | Not invoked — zero failures observed, nothing to attribute. | +| 3b | Policy/lint lane | PASS | `make ci-pr-policy` at source commit: exit 0. Doc-freshness, testing.Short() boundaries, workapi frontend boundary, `.beads/issues.jsonl` diff check, and openapi spec gate (incl. `go test ./internal/httpapi/...`) all reported PASS/succeeded; zero FAIL/ERROR lines in the full log. | +| 4 | No HIGH-severity findings open | PASS | Both round-2 BLOCKING findings (dead decoy-listener test code; migration-lock-timeout FAIL) were root-caused and fixed in round 3, independently re-verified structurally correct by the round-3 reviewer (not just trusted from builder's claim). `waiver_ref: none needed`. `bd dep tree be-u8ldr` / `bd dep tree be-4oah9`: no open child/dependent beads. | +| 5 | Feature branch / working tree clean | PASS | `git status --short` at the deployer worktree checked out to the source commit: empty (clean). | +| 7 | Single feature theme | PASS | Full PR diff `git diff --stat origin/main...e2a7bbb90b`: 2 files (`internal/storage/dolt/initschema_multiprocess_test.go`, `internal/storage/dolt/multistore_multiprocess_test.go`), 26 insertions(+), 5 deletions(-), across 4 commits (fa825dcbd tdd-green, dfdfa0440/d7233eb38 round-2 red/green rework, e2a7bbb90 round-3 fix). One coherent theme throughout: the bug title's own three symptoms (INSERT missing NOT NULL columns, zero-writes-reported-OK, dolt-init-missing-identity) plus the round-2/3 hardening of the diff-owned test's own reliability under ambient dolt-server state. No scope creep, no unrelated files. | + +## Hand-off + +- `DEPLOY_MODE=remote`. Push target: **`headfork`** (`https://github.com/quad341/beads-sec003-contrib.git`) — **not** `origin` (`gastownhall/beads`; push disabled, fetch-only) and **not** `builder/be-kafb` (provenance only, a shared builder branch other beads may still commit to). `fork` (`quad341/beads.git`) is stale post-rename; `headfork`/`prhead` are the current remotes for this contributor rig. +- PR: cross-repo `quad341-sec003-contrib:deploy/be-u8ldr-gate` → `gastownhall:main`. Run `gc beads-contributor pre-pr-check` before opening and clear every `[BLOCK]`. +- **gastownhall/beads is upstream-only for this rig** (contributor relationship, not maintainer). Per role instructions, job ends at opening the PR: do not merge, approve, or dismiss reviews there; never run `maintainer-pr-review`/mpr against it. Record the gate result + PR URL, close the bead, stand down.