diff --git a/.github/scripts/proxied-cmd-test-shards.txt b/.github/scripts/proxied-cmd-test-shards.txt index 92b21b1d4..ac576ae45 100644 --- a/.github/scripts/proxied-cmd-test-shards.txt +++ b/.github/scripts/proxied-cmd-test-shards.txt @@ -256,6 +256,7 @@ 30 1 TestProxiedServerSQLStatementRouting 30 1 TestProxiedServerServeLifecycle +30 2 TestProxiedServerCloseBeadGate 30 2 TestProxiedServerDelete 30 2 TestProxiedServerDeleteForceOrphans 30 2 TestProxiedServerIfRevisionGuardAssign diff --git a/CHANGELOG.md b/CHANGELOG.md index 51577f7ec..3e6aa83e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -462,6 +462,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 installed/missing check still only tests for file existence and is tracked separately. +- **`bd close` verifies a bead gate in proxied-server mode.** The close + pre-check built its bead-gate lookup on the local store, which the + proxied-server route never opens, so closing a bead gate there refused with + `no local store available` even after the awaited bead had closed, while + `bd gate check` resolved the same gate. The close pre-check now reads the + awaited bead through the same fresh-read path `bd gate check` uses on that + route; the direct and embedded routes are unchanged + ([#5861](https://github.com/gastownhall/beads/issues/5861) item 1). + - **`bd doctor` no longer flags a `.local_version` that starts with `v`.** The canonical spelling of a Go module version — and the string a build stamped from a Go pseudo-version reports and writes into `.local_version` itself — diff --git a/cmd/bd/close.go b/cmd/bd/close.go index e49aed1c7..9e4f14ab0 100644 --- a/cmd/bd/close.go +++ b/cmd/bd/close.go @@ -695,7 +695,7 @@ func checkGateSatisfaction(issue *types.Issue) error { case issue.AwaitType == "timer": resolved, escalated, reason, err = checkTimer(issue, time.Now()) case issue.AwaitType == "bead": - resolved, reason, err = checkBeadGate(rootCtx, routedBeadGateGetter{localStore: store}, issue.AwaitID) + resolved, reason, err = checkBeadGate(rootCtx, closeBeadGateGetter(), issue.AwaitID) if err != nil { // Unlike the gh:* and timer arms above, a bead gate whose store // cannot be read stays closed: the close would need that same @@ -725,6 +725,20 @@ func checkGateSatisfaction(issue *types.Issue) error { return fmt.Errorf("gate condition not satisfied: %s (use --force to override)", reason) } +// closeBeadGateGetter picks the bead-gate lookup the current route can serve. +// The proxied-server route never opens the local store (the root pre-run +// short-circuits to uowProvider), so a store-backed getter there refused every +// bead gate with "no local store available" even when the awaited bead was +// closed (#5861); that route now reads through the same fresh-read getter +// `bd gate check` uses. The direct and embedded routes keep the store-backed +// local -> prefix-route lookup. +func closeBeadGateGetter() issueGetter { + if usesProxiedServer() { + return proxiedFreshReadGetter{} + } + return routedBeadGateGetter{localStore: store} +} + // autoCloseCompletedMolecule checks if closing a step completed an auto-closing // parent molecule, and if so, closes the molecule root. Ordinary epics remain // open when all children finish so they can become explicitly close-eligible diff --git a/cmd/bd/close_gate_test.go b/cmd/bd/close_gate_test.go index 458640b19..0cfc91900 100644 --- a/cmd/bd/close_gate_test.go +++ b/cmd/bd/close_gate_test.go @@ -241,3 +241,21 @@ func TestCheckGateSatisfaction_BeadGateUnreadableStoreRefuses(t *testing.T) { } } } + +// The close pre-check reads a bead gate's target through the route that can +// serve it: the proxied route has no local store, so it must not build a +// store-backed getter there (#5861). +func TestCloseBeadGateGetter_RouteSelection(t *testing.T) { + oldMode := proxiedServerMode + t.Cleanup(func() { proxiedServerMode = oldMode }) + + proxiedServerMode = true + if _, ok := closeBeadGateGetter().(proxiedFreshReadGetter); !ok { + t.Errorf("proxied-server mode: got %T, want proxiedFreshReadGetter", closeBeadGateGetter()) + } + + proxiedServerMode = false + if _, ok := closeBeadGateGetter().(routedBeadGateGetter); !ok { + t.Errorf("direct mode: got %T, want routedBeadGateGetter", closeBeadGateGetter()) + } +} diff --git a/cmd/bd/close_proxied_integration_test.go b/cmd/bd/close_proxied_integration_test.go index 3dc53d349..8017e593a 100644 --- a/cmd/bd/close_proxied_integration_test.go +++ b/cmd/bd/close_proxied_integration_test.go @@ -987,3 +987,71 @@ func TestProxiedServerCloseConcurrent(t *testing.T) { t.Errorf("open issues remain after concurrent close: %d", openCount) } } + +// bd close on a bead gate evaluates the awaited bead through the proxied read +// path. Before #5861 item 1 was fixed this route refused every bead gate with +// "no local store available", closed target or not, while bd gate check +// resolved the same gate. +func TestProxiedServerCloseBeadGate(t *testing.T) { + requireSharedProxiedServer(t) + t.Parallel() + bd := buildEmbeddedBD(t) + + createBeadGate := func(t *testing.T, p proxiedProject) (gateID string, awaited *types.Issue) { + t.Helper() + parked := bdProxiedCreate(t, bd, p.dir, "Parked bead") + awaited = bdProxiedCreate(t, bd, p.dir, "Awaited bead") + out, stderr, err := bdProxiedRunBuffers(t, bd, p.dir, + "gate", "create", "--type=bead", "--blocks", parked.ID, "--await-id", awaited.ID, "--reason", "waiting on "+awaited.ID) + if err != nil { + t.Fatalf("bead gate create failed: %v\nstderr:\n%s", err, stderr) + } + return parseCreatedGateID(t, out), awaited + } + + t.Run("awaited_open_refuses_with_its_status", func(t *testing.T) { + t.Parallel() + p := newSharedProxiedProject(t, bd, "cbgo") + gateID, awaited := createBeadGate(t, p) + + out := bdProxiedCloseFail(t, bd, p.dir, gateID) + if strings.Contains(out, "no local store available") { + t.Errorf("close read the gate through a store-less getter:\n%s", out) + } + if !strings.Contains(out, "gate condition not satisfied") || !strings.Contains(out, "bead "+awaited.ID+" is open") { + t.Errorf("expected the awaited bead's status in the refusal, got:\n%s", out) + } + db := openProxiedDB(t, p) + if got := readStatus(t, db, gateID); got != types.StatusOpen { + t.Errorf("refused gate should stay open, got %q", got) + } + }) + + t.Run("awaited_closed_closes", func(t *testing.T) { + t.Parallel() + p := newSharedProxiedProject(t, bd, "cbgc") + gateID, awaited := createBeadGate(t, p) + + bdProxiedClose(t, bd, p.dir, awaited.ID) + bdProxiedClose(t, bd, p.dir, gateID, "-r", "awaited bead closed") + db := openProxiedDB(t, p) + if got := readStatus(t, db, gateID); got != types.StatusClosed { + t.Errorf("gate should close once its awaited bead is closed, got %q", got) + } + if got := readCloseReason(t, db, gateID); got != "awaited bead closed" { + t.Errorf("close_reason: got %q, want %q", got, "awaited bead closed") + } + }) + + t.Run("force_skips_the_check", func(t *testing.T) { + t.Parallel() + p := newSharedProxiedProject(t, bd, "cbgf") + gateID, _ := createBeadGate(t, p) + + bdProxiedClose(t, bd, p.dir, gateID, "--force") + db := openProxiedDB(t, p) + if got := readStatus(t, db, gateID); got != types.StatusClosed { + t.Errorf("--force should close the gate regardless, got %q", got) + } + }) +} diff --git a/docs/reference/troubleshooting.md b/docs/reference/troubleshooting.md index ae2d37120..78e26267c 100644 --- a/docs/reference/troubleshooting.md +++ b/docs/reference/troubleshooting.md @@ -423,27 +423,6 @@ don't know", not "this is definitely broken". A genuinely missing or broken `dolt` binary (not found, not executable, or the probe itself fails/times out) is a hard error, not a warning. -### Proxied-server mode: closing a bead gate fails with "no local store available" - -``` -gate condition not satisfied: bead gate "bd-a1b2": no local store available (use --force to override) -``` - -`bd close` on a bead gate refuses this way in proxied-server mode even when -the awaited bead is closed. Proxied-server commands run against a shared -`dolt sql-server` and never open a local store, so the close path has -nothing to read the awaited bead's status from. - -`bd gate check` does evaluate bead gates in proxied-server mode, and closes -the ones whose target has closed: - -```bash -bd gate check --type=bead # closes bead gates whose awaited bead is closed -bd close --force # or close without verifying the condition -``` - -Tracked in [#5861](https://github.com/gastownhall/beads/issues/5861). - ### Prefix routing: "proxy server store needs to be uow provider" A lookup routed through the orchestrator's `routes.jsonl` prefix routes diff --git a/docs/workflows/gates.md b/docs/workflows/gates.md index 36c032a04..97dd71dff 100644 --- a/docs/workflows/gates.md +++ b/docs/workflows/gates.md @@ -54,18 +54,13 @@ repository. ### Known limitations: multi-rig and proxied-server topologies Bead gates and prefix routing (`routes.jsonl`) do not work in every -topology. Three limitations to expect, all tracked in +topology. Two limitations to expect, both tracked in [#5861](https://github.com/gastownhall/beads/issues/5861): - **Cross-rig bead gates never resolve on their own.** A `:` await value reports `cannot be checked (multi-rig routing removed)` and stays pending regardless of the awaited bead's status. Close it with `bd gate resolve`. -- **`bd close` cannot verify a bead gate in the experimental proxied-server - mode.** Proxied-server commands never open a local store, so closing the - gate refuses with `no local store available` even when the awaited bead is - closed. Run `bd gate check`, which evaluates bead gates in proxied-server - mode and closes the satisfied ones, or `bd close --force`. - **Prefix routing cannot open a proxied-server target rig.** A routed lookup into a rig that is itself in proxied-server mode fails with `proxy server store needs to be uow provider`, so an all-proxied