Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
Eddie the Engineer
312d0dd5a6 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 <noreply@anthropic.com>
Co-authored-by: deacon <mtccressall@gmail.com>
2026-10-16 08:45:36 +00:00
deacon
fbd120daa2 fix(create): report a failed commit instead of printing success
`bd create --repo <rig>` could print "✓ Created issue: <id>" 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) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VxzPCaz7gDX8d9BmDdFrG5
2026-10-16 05:54:01 +00:00
4 changed files with 88 additions and 9 deletions

View file

@ -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 <id>, but the follow-up Dolt
commit in <repo> failed: <error>` 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

View file

@ -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,13 +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 {
debug.Logf("warning: failed to commit routed repo: %v", err)
}
if routed {
flushRoutedCreate(ctx, targetStore, repoPath, created.ID)
}
if remoteCache != nil {
@ -907,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() {

View file

@ -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) {

View file

@ -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