From 7cf4f7e6cd25c8b1ed3c95fdb0f974094067b274 Mon Sep 17 00:00:00 2001 From: Julian Knutsen Date: Sun, 9 Aug 2026 10:42:34 -0700 Subject: [PATCH] chore: retire a zombie test, drop a dead field, true up two leaf docs (#5492) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four small truth-restoration changes, none of which alter behavior. Retire TestImportWithDeletedParent (internal/beads/beads_integration_test.go). It asserts a "[RESURRECTED] placeholder parent" behavior that left with the JSONL sync layer: no implementation writes that marker anywhere at HEAD, so the assertions cannot pass on any backend. Verified live against a dolt sql-server with -tags=integration,gms_pure_go: unskipped, it dies at setup (dolt.New: database "testdb_..." not found) before reaching an assertion. The `encoding/json` import it was the only user of goes with it. Delete ImportOptions.OrphanHandling (cmd/bd/import_shared.go). No literal sets it and no path reads it — importIssuesCore hardcodes storage.OrphanAllow on the BatchCreateOptions it builds. The struct carries no tags and is never marshaled, and the historical `import.orphan_handling` config key is gone. Nothing else in the orphan-handling cascade is touched here; that removal is a published-surface decision and needs its own sign-off. Name ErrValidation in Claimer's leaf doc (issueops/claimer.go), in the same words the other sixteen roles use. All three implementations already answer it for an empty Actor or IssueID, and RunClaimerRefusesIncompleteRequestsAndAnAbsentIDWithoutTouchingState asserts it on all three legs; its SPEC GAP note recorded the doc's silence and is updated to match. State Commenter's history cost exactly (issueops/commenter.go): one durable comment records EXACTLY ONE entry, an ephemeral one records none. RunCommenterRecordsExactlyOneHistoryEntry was tightened from a range to an equality at one and RunCommenterCommentOnAWispLandsOnTheWispThread pins the ephemeral half at zero, both on all three legs, so the shipped contract was already stricter than the published prose. Co-authored-by: Review Sim --- backend/conformance/claimer_contract.go | 11 +- backend/conformance/commenter_contract.go | 34 +++--- cmd/bd/import_shared.go | 1 - internal/beads/beads_integration_test.go | 137 ---------------------- issueops/claimer.go | 3 +- issueops/commenter.go | 19 +-- 6 files changed, 34 insertions(+), 171 deletions(-) diff --git a/backend/conformance/claimer_contract.go b/backend/conformance/claimer_contract.go index b6af11681..e78236bf2 100644 --- a/backend/conformance/claimer_contract.go +++ b/backend/conformance/claimer_contract.go @@ -516,11 +516,12 @@ func RunClaimerRefusesAWispIDAsNotFound(t *testing.T, ctx context.Context, fixtu // claimable decoy seeded here is what makes that visible; it is checked // afterwards as a raw row, still open and still unassigned. // -// SPEC GAP. The leaf says these failures are "deterministic validation -// failures" and that they leave state alone, but it never names the sentinel -// they carry — every other role in this family says "match ErrValidation" in so -// many words. All three implementations answer ErrValidation, so the assertion -// records an observed three-way agreement that the doc has not yet ratified. +// THE SENTINEL IS THE LEAF'S OWN. Claimer's doc names ErrValidation for +// deterministic request-validation failures, in the same words every other +// role in this family uses, and all three implementations answer it — so the +// assertion pins published prose rather than an observed three-way agreement +// the doc had not yet ratified, which is what it recorded before the wording +// landed. // // The absent id is here for the same reason a wisp id is ErrNotFound: an id // that names nothing is not a conflict, and a caller that had to read the prose diff --git a/backend/conformance/commenter_contract.go b/backend/conformance/commenter_contract.go index 77c72a77d..412435c5f 100644 --- a/backend/conformance/commenter_contract.go +++ b/backend/conformance/commenter_contract.go @@ -368,10 +368,10 @@ func RunCommenterTakesTheClockWhenTheThreadIsBehindIt(t *testing.T, ctx context. // // The history assertion is an EQUALITY at ZERO, where the durable path's is an // equality at one: AddComment's ephemeral clause promises "NO durable history -// entry — none, not 'at most one'". A bound would let a regression that records -// exactly one entry pass on every backend, and that regression is the one that -// breaks federation — the wisp tables are dolt-ignored so ephemeral work never -// ships, and an entry naming a wisp thread ships. +// entry — none, not one". A bound would let a regression that records exactly +// one entry pass on every backend, and that regression is the one that breaks +// federation — the wisp tables are dolt-ignored so ephemeral work never ships, +// and an entry naming a wisp thread ships. // // The anchor here lives on exactly one plane, and every anchor a CALLER can // create does: no local write path reaches dual residency, which is why @@ -495,24 +495,22 @@ func RunCommenterDoesNotResolvePrefixes(t *testing.T, ctx context.Context, fixtu } // RunCommenterRecordsExactlyOneHistoryEntry pins Commenter.AddComment's "ONE -// atomic mutation, with at most one history entry" at the number every wiring -// actually records: a durable comment costs EXACTLY one entry. +// atomic mutation, with EXACTLY ONE history entry": a durable comment costs +// exactly one entry. // -// The case is deliberately stricter than the leaf's bound, because the bound -// cannot fail in the direction that matters. "after <= before+1" holds whether -// the entry was written or not, so a body that quietly stopped committing -// keeps it green — and that is not hypothetical. The deleter role stopped -// versioning embedded deletes, the identically-shaped range in its contract -// absorbed it, and what noticed months later was a sibling-write test outside -// the contract suite (e9acfac6e). +// EXACTLY ONE, NOT AT MOST ONE. The leaf carried a bound until this case's +// number was ratified into it, and a bound cannot fail in the direction that +// matters: "after <= before+1" holds whether the entry was written or not, so +// a body that quietly stopped committing keeps it green — and that is not +// hypothetical. The deleter role stopped versioning embedded deletes, the +// identically-shaped range in its contract absorbed it, and what noticed months +// later was a sibling-write test outside the contract suite (e9acfac6e). // -// EXACTLY ONE IS MEASURED, NOT DEMANDED: all three wirings already record one +// EXACTLY ONE WAS MEASURED, NOT DEMANDED: all three wirings already record one // entry for a durable comment — the server-backed store inside its write // transaction, the embedded store on a second connection after the SQL commit, -// the unit-of-work provider from the message it hands RunTxResult — so this -// tightens the assertion and asks no backend to change. Ratifying the leaf's -// own wording to match is the owner's call; until then this case is the -// stricter of the two statements, and the honest one. +// the unit-of-work provider from the message it hands RunTxResult — so neither +// this assertion nor the wording it ratified asked any backend to change. // // What the strictness buys a caller: a comment row no entry carries is a row // `bd dolt push` does not ship. The thread then reads back locally and exists diff --git a/cmd/bd/import_shared.go b/cmd/bd/import_shared.go index 347b43b62..68f669053 100644 --- a/cmd/bd/import_shared.go +++ b/cmd/bd/import_shared.go @@ -54,7 +54,6 @@ type ImportOptions struct { Strict bool RenameOnImport bool ClearDuplicateExternalRefs bool - OrphanHandling string DeletionIDs []string SkipPrefixValidation bool ProtectLocalExportIDs map[string]time.Time diff --git a/internal/beads/beads_integration_test.go b/internal/beads/beads_integration_test.go index 853b272c1..fe25a8bc0 100644 --- a/internal/beads/beads_integration_test.go +++ b/internal/beads/beads_integration_test.go @@ -5,7 +5,6 @@ package beads_test import ( "context" - "encoding/json" "os" "path/filepath" "testing" @@ -444,139 +443,3 @@ func TestRoundTripIssue(t *testing.T) { h.assertEqual(original.IssueType, retrieved.IssueType, "IssueType") h.assertEqual(original.Assignee, retrieved.Assignee, "Assignee") } - -// TestImportWithDeletedParent verifies parent resurrection during import -// This tests the fix for bd-d19a (import failure on missing parent issues) -func TestImportWithDeletedParent(t *testing.T) { - if !hasDoltTestPort() { - t.Skip("skipping: Dolt test container not available") - } - tmpDir, err := os.MkdirTemp("", "beads-test-*") - if err != nil { - t.Fatalf("Failed to create temp dir: %v", err) - } - defer os.RemoveAll(tmpDir) - - beadsDir := filepath.Join(tmpDir, ".beads") - dbPath := filepath.Join(beadsDir, "beads.db") - jsonlPath := filepath.Join(beadsDir, "issues.jsonl") - - // Create .beads directory - if err := os.MkdirAll(beadsDir, 0755); err != nil { - t.Fatalf("Failed to create .beads dir: %v", err) - } - - // Phase 1: Create parent and child in JSONL (simulating historical git state) - ctx := context.Background() - - parent := types.Issue{ - ID: "bd-parent", - Title: "Parent Epic", - Description: "Original parent description", - Status: types.StatusOpen, - Priority: 1, - IssueType: types.TypeEpic, - CreatedAt: time.Now(), - UpdatedAt: time.Now(), - } - - child := types.Issue{ - ID: "bd-parent.1", - Title: "Child Task", - Status: types.StatusOpen, - Priority: 1, - IssueType: types.TypeTask, - CreatedAt: time.Now(), - UpdatedAt: time.Now(), - } - - // Write both to JSONL (parent exists in git history) - file, err := os.Create(jsonlPath) - if err != nil { - t.Fatalf("Failed to create JSONL: %v", err) - } - encoder := json.NewEncoder(file) - if err := encoder.Encode(parent); err != nil { - file.Close() - t.Fatalf("Failed to encode parent: %v", err) - } - if err := encoder.Encode(child); err != nil { - file.Close() - t.Fatalf("Failed to encode child: %v", err) - } - file.Close() - - // Phase 2: Create fresh database and import only the child - // (simulating scenario where parent was deleted) - store, err := dolt.New(ctx, &dolt.Config{Path: filepath.Dir(dbPath)}) - if err != nil { - t.Fatalf("dolt.New failed: %v", err) - } - defer store.Close() - - if err := store.SetConfig(ctx, "issue_prefix", "bd"); err != nil { - t.Fatalf("Failed to set issue_prefix: %v", err) - } - - // Manually create only the child (parent missing) - childToImport := &types.Issue{ - ID: "bd-parent.1", - Title: "Child Task", - Status: types.StatusOpen, - Priority: 1, - IssueType: types.TypeTask, - CreatedAt: time.Now(), - UpdatedAt: time.Now(), - } - - // This should trigger parent resurrection from JSONL - if err := store.CreateIssue(ctx, childToImport, "test"); err != nil { - t.Fatalf("Failed to create child (resurrection should have prevented error): %v", err) - } - - // Phase 3: Verify results - - // Verify child was created successfully - retrievedChild, err := store.GetIssue(ctx, "bd-parent.1") - if err != nil { - t.Fatalf("Failed to retrieve child: %v", err) - } - if retrievedChild == nil { - t.Fatal("Child was not created") - } - if retrievedChild.Title != "Child Task" { - t.Errorf("Expected child title 'Child Task', got %s", retrievedChild.Title) - } - - // Verify parent was resurrected as a closed placeholder - retrievedParent, err := store.GetIssue(ctx, "bd-parent") - if err != nil { - t.Fatalf("Failed to retrieve parent: %v", err) - } - if retrievedParent == nil { - t.Fatal("Parent was not resurrected") - } - if retrievedParent.Status != types.StatusClosed { - t.Errorf("Expected parent status=closed, got %s", retrievedParent.Status) - } - if retrievedParent.Priority != 4 { - t.Errorf("Expected parent priority=4 (lowest), got %d", retrievedParent.Priority) - } - if retrievedParent.Title != "Parent Epic" { - t.Errorf("Expected original title preserved, got %s", retrievedParent.Title) - } - if retrievedParent.Description == "" { - t.Error("Expected resurrected parent description to be set") - } - if retrievedParent.ClosedAt == nil { - t.Error("Expected resurrected parent to have ClosedAt set") - } - - // Verify description contains resurrection marker - if len(retrievedParent.Description) < 13 || retrievedParent.Description[:13] != "[RESURRECTED]" { - t.Errorf("Expected [RESURRECTED] prefix in description, got: %s", retrievedParent.Description) - } - - t.Logf("Parent %s successfully resurrected as closed placeholder", "bd-parent") - t.Logf("Child %s created successfully with resurrected parent", "bd-parent.1") -} diff --git a/issueops/claimer.go b/issueops/claimer.go index a0faecccd..27b495218 100644 --- a/issueops/claimer.go +++ b/issueops/claimer.go @@ -36,7 +36,8 @@ type ClaimResult struct { // Lifecycle and Reader, reached by its own accessor; a new capability gets a // new role interface and its own accessor, so never append a method here. // -// Implementations never mutate caller-owned request values. Result values are +// Implementations never mutate caller-owned request values. Deterministic +// request-validation failures match ErrValidation. Result values are // unspecified when error is non-nil. type Claimer interface { // Claim validates and commits the complete request as one atomic diff --git a/issueops/commenter.go b/issueops/commenter.go index ffbc8e183..dd38a9b87 100644 --- a/issueops/commenter.go +++ b/issueops/commenter.go @@ -65,17 +65,18 @@ type AddCommentResult struct { // attempt-local clones. Deterministic request-validation failures match // ErrValidation and leave persistent state unchanged. type Commenter interface { - // AddComment appends one comment as ONE atomic mutation, with at most one - // history entry. A blank Text is ErrValidation, and so is an empty - // IssueID; a NON-EMPTY id that names neither an issue nor a wisp is - // ErrNotFound. Refusals use the same typed vocabulary Lifecycle returns, - // so a caller classifies them with errors.Is rather than by reading prose. + // AddComment appends one comment as ONE atomic mutation, with EXACTLY ONE + // history entry — a comment is one act, and not none. A blank Text is + // ErrValidation, and so is an empty IssueID; a NON-EMPTY id that names + // neither an issue nor a wisp is ErrNotFound. Refusals use the same typed + // vocabulary Lifecycle returns, so a caller classifies them with errors.Is + // rather than by reading prose. // // A comment on an EPHEMERAL row records NO durable history entry — none, - // not "at most one". Ephemeral rows are not versioned, and the wisp tables - // are dolt-ignored precisely so ephemeral work never ships, so a history - // entry naming a wisp thread would be the sync artifact ignoring those - // tables exists to prevent. The comment itself lands on the ephemeral + // not one. Ephemeral rows are not versioned, and the wisp tables are + // dolt-ignored precisely so ephemeral work never ships, so a history entry + // naming a wisp thread would be the sync artifact ignoring those tables + // exists to prevent. The comment itself lands on the ephemeral // thread and reads back from it; only the durable trace is absent, so a // caller reconstructing threads from durable history alone will not see // it.