From fbd120daa20e05ac3c6c940b91d35427af6012c3 Mon Sep 17 00:00:00 2001 From: deacon Date: Thu, 3 Sep 2026 15:04:47 -0600 Subject: [PATCH 1/2] fix(create): report a failed commit instead of printing success MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `bd create --repo ` could print "✓ Created issue: " and exit 0 while the row existed only in the Dolt working set, because the commit error was discarded into debug.Logf and execution continued to the success print. FOUND BY A CENSUS OF EVERY CALL SITE, WHICH IS WHAT MAKES IT CONCLUSIVE. Of the 23 commitPendingIfEmbedded call sites in cmd/bd, 16 return the error -- update.go, tag.go, reclaim.go, ready.go, priority.go, note.go and others -- and create.go:646 was THE ONLY ONE THAT DISCARDED IT. That single outlier predicts the exact symptom that was observed downstream. A Gas Town patrol reported creating three beads on 2026-09-02 and none of them existed afterwards, while every issue the SAME session UPDATED survived. The split looked mysterious and is simply this: `bd update` surfaces a failed commit, `bd create` printed success over it. The evidence for "never persisted" rather than "persisted and was destroyed" is physical: gt-dolt-compact takes a `cp -a` byte copy of the store before each run, and the copy taken 6.5 hours after those creates contains none of the three, while the same copy contains the same session's updates. Compaction is also excluded -- that copy pre-dates any compaction of this store, and a history squash cannot drop rows since it preserves final table state. Now matches update.go: report it. The error names the ID and says the issue is in the working set only and can be persisted with `bd dolt commit`, because the caller can only recover what they are told about. Failing here rather than warning keeps this consistent with the other 16 sites instead of inventing a third behaviour. cmd/bd TestCreate suite passes. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01VxzPCaz7gDX8d9BmDdFrG5 --- cmd/bd/create.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cmd/bd/create.go b/cmd/bd/create.go index 64aeada9c..b9112eae6 100644 --- a/cmd/bd/create.go +++ b/cmd/bd/create.go @@ -626,7 +626,24 @@ var createCmd = &cobra.Command{ Command: "create", IssueIDs: []string{created.ID}, }); err != nil { - debug.Logf("warning: failed to commit routed repo: %v", err) + // A failed commit here USED TO be swallowed into debug.Logf, after + // which this function went on to print "✓ Created issue: " and + // return nil. The row exists only in the working set at that point, + // so the caller is told the issue was created and is given an ID + // that does not survive a working-set reset. + // + // That is not hypothetical. A Gas Town patrol reported creating + // three beads on 2026-09-02 and none of them existed afterwards; a + // byte copy of the store taken 6.5 hours later contained none of + // the three, while every issue the SAME session UPDATED was present + // in that same copy. The split is explained exactly here: of the 23 + // commitPendingIfEmbedded call sites, 16 return the error and this + // was the only one that discarded it. + // + // Report it the way `bd update` does. The issue may still be + // recoverable with `bd dolt commit`, which the caller can only do + // if they are told. + return HandleErrorRespectJSON("created %s but failed to commit it: %v\nThe issue exists in the working set only — run 'bd dolt commit' to persist it.", created.ID, err) } } From 312d0dd5a65be839314ae2c0f25995272bdde8a9 Mon Sep 17 00:00:00 2001 From: Eddie the Engineer Date: Fri, 16 Oct 2026 07:44:42 +0000 Subject: [PATCH 2/2] fix(create): warn, not fail, when a routed create's follow-up commit fails The follow-up Dolt commit a routed create runs in the target store only commits under dolt.auto-commit=on: maybeAutoCommitStore returns early in every other mode. In that mode issueOpsContext does not defer the version commit, so ops.Create has already committed the new issue before the flush runs, and a failure of that commit makes ops.Create return an error, so the create exits 1 before it reaches the flush. A failed flush therefore cannot leave the issue in the working set only. Failing the command at that point reports a durable create as an error, replaces the --json result with an error object, and skips the push to a remote target. Keep the fix for the swallowed error, but report it the way create's other follow-up commit does: a stderr warning that names the issue, the target repo and the error, and the create still succeeds. The flush moves into flushRoutedCreate, so a unit test pins the warning with an injected commit failure. The cross-repo embedded tests now assert that the created issues are in the target's HEAD commit and that its working set is clean. A routed bare create (no --parent, --deps or --waits-for) also ran the bare create's follow-up commit. setStore has made the target the command's store by then, so both commits ran on the same store, and one persistent commit failure printed two warnings, the first naming neither the issue nor the target. The bare create's commit now skips routed creates, so flushRoutedCreate is a routed create's only follow-up commit. The two gates differ only when dolt.auto-commit is unset. writesCommitNow treats an unset mode as on, so there too ops.Create has already committed the issue. Corrections to the message of "fix(create): report a failed commit instead of printing success": - The create does not fail on this error and prints no `bd dolt commit` hint. A failed follow-up commit is the warning described above. - "The row existed only in the Dolt working set" does not hold on this tree, for the reason in the first paragraph. This change therefore does not explain the 2026-09-02 report of three lost creates, and the cause of that loss is not established here. - cmd/bd has 19 production commitPendingIfEmbedded call sites, not 23. Of these, 17 return the error and the `bd create --file` path warns; this routed flush was the only one that discarded it. The counts are the same at c0d8da42de, the original commit's parent, and at b303d494df. Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen Co-Authored-By: Claude Opus 5.5 Co-authored-by: deacon --- CHANGELOG.md | 8 +++++ cmd/bd/create.go | 45 +++++++++++---------------- cmd/bd/create_embedded_test.go | 29 +++++++++++++++++ cmd/bd/dolt_autocommit_server_test.go | 32 +++++++++++++++++++ 4 files changed, 88 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5618ca17..cba3b27f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -524,6 +524,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- **A routed `bd create` reports a failed follow-up commit** (#6254). When + `--repo` or the `routing.*` settings send a create to another repository, + the follow-up Dolt commit in that repository wrote its error only to the + debug log. It now prints `Warning: created , but the follow-up Dolt + commit in failed: ` on stderr. The create still succeeds, + prints the issue and syncs a remote target, because that commit runs only + under `dolt.auto-commit=on`, where the create has already committed the new + issue. - **`bd gate list` works over a connected HTTP workspace** (S20). The workspace-wide listing built a raw `SearchIssues` filter, which the HTTP backend refuses, so gc's `renudge-stale-human-gates` order failed on every diff --git a/cmd/bd/create.go b/cmd/bd/create.go index b9112eae6..19b968b71 100644 --- a/cmd/bd/create.go +++ b/cmd/bd/create.go @@ -606,9 +606,11 @@ var createCmd = &cobra.Command{ created.Comments = nil edges := createDepEdges{parentID: parentID, specs: depSpecs, waitsFor: waitsForSpec} - if edges.empty() { + routed := repoPath != "." && targetStore != nil + if edges.empty() && !routed { // Bare create: preserve the embedded-mode follow-up Dolt commit. - // The deps path commits inside its transaction instead. + // The deps path commits inside its transaction instead, and a + // routed create's one follow-up commit is flushRoutedCreate. shouldCommit, err := shouldCommitCreatePostWrites(created, false) if err != nil { return HandleError("dolt auto-commit failed: %v", err) @@ -621,30 +623,8 @@ var createCmd = &cobra.Command{ } } - if repoPath != "." && targetStore != nil { - if err := commitPendingIfEmbedded(ctx, targetStore, currentActor(), doltAutoCommitParams{ - Command: "create", - IssueIDs: []string{created.ID}, - }); err != nil { - // A failed commit here USED TO be swallowed into debug.Logf, after - // which this function went on to print "✓ Created issue: " and - // return nil. The row exists only in the working set at that point, - // so the caller is told the issue was created and is given an ID - // that does not survive a working-set reset. - // - // That is not hypothetical. A Gas Town patrol reported creating - // three beads on 2026-09-02 and none of them existed afterwards; a - // byte copy of the store taken 6.5 hours later contained none of - // the three, while every issue the SAME session UPDATED was present - // in that same copy. The split is explained exactly here: of the 23 - // commitPendingIfEmbedded call sites, 16 return the error and this - // was the only one that discarded it. - // - // Report it the way `bd update` does. The issue may still be - // recoverable with `bd dolt commit`, which the caller can only do - // if they are told. - return HandleErrorRespectJSON("created %s but failed to commit it: %v\nThe issue exists in the working set only — run 'bd dolt commit' to persist it.", created.ID, err) - } + if routed { + flushRoutedCreate(ctx, targetStore, repoPath, created.ID) } if remoteCache != nil { @@ -924,6 +904,19 @@ func shouldCommitCreatePostWrites(_ *types.Issue, _ bool) (bool, error) { return embeddedWritesCommitNow() } +// flushRoutedCreate runs a routed create's follow-up Dolt commit in the target +// store. That commit runs only under dolt.auto-commit=on, where ops.Create has +// already committed the new row, so its failure cannot lose the issue: it is a +// warning that names the target, and the create still succeeds. +func flushRoutedCreate(ctx context.Context, target storage.DoltStorage, repoPath, id string) { + if err := commitPendingIfEmbedded(ctx, target, currentActor(), doltAutoCommitParams{ + Command: "create", + IssueIDs: []string{id}, + }); err != nil { + WarnError("created %s, but the follow-up Dolt commit in %s failed: %v", id, repoPath, err) + } +} + func createDepsAcceptedTypeList() string { names := []string{"blocked-by", "depends-on"} for _, depType := range types.WellKnownDependencyTypes() { diff --git a/cmd/bd/create_embedded_test.go b/cmd/bd/create_embedded_test.go index 43ed28a3a..44f320be1 100644 --- a/cmd/bd/create_embedded_test.go +++ b/cmd/bd/create_embedded_test.go @@ -159,6 +159,33 @@ func assertDepExists(t *testing.T, beadsDir, database, issueID, dependsOnID stri } } +// assertCommittedAtHead verifies via raw SQL that each issue is in the store's +// HEAD commit and that its working set holds no uncommitted change. +func assertCommittedAtHead(t *testing.T, beadsDir, database string, ids ...string) { + t.Helper() + db, cleanup, err := embeddeddolt.OpenSQL(t.Context(), filepath.Join(beadsDir, "embeddeddolt"), database, "main") + if err != nil { + t.Fatalf("OpenSQL: %v", err) + } + defer cleanup() + for _, id := range ids { + var count int + if err := db.QueryRowContext(t.Context(), "SELECT COUNT(*) FROM issues AS OF 'HEAD' WHERE id = ?", id).Scan(&count); err != nil { + t.Fatalf("count %s at HEAD: %v", id, err) + } + if count != 1 { + t.Errorf("issue %s at HEAD: count = %d, want 1", id, count) + } + } + var dirty string + if err := db.QueryRowContext(t.Context(), "SELECT COALESCE(GROUP_CONCAT(table_name), '') FROM dolt_status").Scan(&dirty); err != nil { + t.Fatalf("query dolt_status: %v", err) + } + if dirty != "" { + t.Errorf("uncommitted tables in the working set: %s", dirty) + } +} + func assertDepExistsWithType(t *testing.T, beadsDir, database, issueID, dependsOnID, expectedType string) { t.Helper() dataDir := filepath.Join(beadsDir, "embeddeddolt") @@ -990,6 +1017,7 @@ func TestEmbeddedCreateCrossRepo(t *testing.T) { // Verify issue exists in the TARGET store, not the source targetBeadsDir := filepath.Join(targetDir, ".beads") + assertCommittedAtHead(t, targetBeadsDir, "tgt", issue.ID) tgtStore := openStore(t, targetBeadsDir, "tgt") got, err := tgtStore.GetIssue(t.Context(), issue.ID) if err != nil { @@ -1044,6 +1072,7 @@ func TestEmbeddedCreateCrossRepoWithParent(t *testing.T) { // Verify parent-child dependency exists in the target store targetBeadsDir := filepath.Join(targetDir, ".beads") assertDepExists(t, targetBeadsDir, "tgt", child.ID, parent.ID) + assertCommittedAtHead(t, targetBeadsDir, "tgt", parent.ID, child.ID) } func TestEmbeddedCreateDryRunRepoDoesNotInitializeTarget(t *testing.T) { diff --git a/cmd/bd/dolt_autocommit_server_test.go b/cmd/bd/dolt_autocommit_server_test.go index 9476f5e46..ec55534c1 100644 --- a/cmd/bd/dolt_autocommit_server_test.go +++ b/cmd/bd/dolt_autocommit_server_test.go @@ -149,6 +149,38 @@ func TestCommitPendingIfEmbeddedPropagatesEmbeddedError(t *testing.T) { } } +func TestFlushRoutedCreateWarnsOnCommitFailure(t *testing.T) { + for _, tc := range []struct { + name string + err error + want string + }{ + {name: "commit succeeds", want: ""}, + { + name: "commit fails", + err: errors.New("commit failed"), + want: "Warning: created tgt-1, but the follow-up Dolt commit in ../planning failed: commit failed\n", + }, + } { + t.Run(tc.name, func(t *testing.T) { + saveStorageMode(t) + serverMode = false + proxiedServerMode = false + + fake := &fakeCommitPendingStore{err: tc.err} + got := captureStderr(t, func() { + flushRoutedCreate(context.Background(), fake, "../planning", "tgt-1") + }) + if fake.commitCalls != 1 { + t.Fatalf("Commit calls = %d, want 1", fake.commitCalls) + } + if got != tc.want { + t.Fatalf("stderr = %q, want %q", got, tc.want) + } + }) + } +} + func TestShouldCommitCreatePostWritesSkipsServerMode(t *testing.T) { saveStorageMode(t) serverMode = true