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.