fix(mol): clear root Ephemeral on bd mol squash (#3696)
* fix(mol): clear root Ephemeral on bd mol squash
bd mol squash auto-closes a wisp molecule's root but did not clear its
Ephemeral flag, contrary to the wisp lifecycle help text ("Squash: bd
mol squash <id> (clears Ephemeral flag, promotes to persistent)").
The closed-but-still-ephemeral root row remained in the wisps table, so
auto-export queries (Ephemeral=true) re-emitted it as a duplicate JSONL
row on every export cycle, accumulating noise indefinitely.
Within the squash transaction, after closing the root, also call
tx.UpdateIssue to set wisp=false. This mirrors what the bd update
<id> --persistent workaround does today and matches the natural
"squash absorbs the molecule into a digest" mental model.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* test(mol): add embedded-dolt regression for squash root Ephemeral
The standalone-Dolt regression test in mol_test.go skips in the
Embedded Dolt CI tier, leaving the squash fix's lines uncovered
(Codecov 0% on the patch).
Add a parallel test using embeddeddolt.New so the fix is exercised
in the default CI matrix.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
218349937c
commit
229f214fbb
3 changed files with 154 additions and 0 deletions
|
|
@ -282,6 +282,10 @@ func squashMolecule(ctx context.Context, s storage.DoltStorage, root *types.Issu
|
|||
if err := tx.CloseIssue(ctx, root.ID, reason, actorName, ""); err != nil {
|
||||
return fmt.Errorf("failed to close wisp root %s: %w", root.ID, err)
|
||||
}
|
||||
// Clear ephemeral so the closed root stops being re-emitted by every wisp-table export cycle.
|
||||
if err := tx.UpdateIssue(ctx, root.ID, map[string]interface{}{"wisp": false}, actorName); err != nil {
|
||||
return fmt.Errorf("failed to clear ephemeral flag on root %s: %w", root.ID, err)
|
||||
}
|
||||
result.WispSquash = true
|
||||
}
|
||||
|
||||
|
|
|
|||
83
cmd/bd/mol_squash_embedded_test.go
Normal file
83
cmd/bd/mol_squash_embedded_test.go
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
//go:build cgo
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/steveyegge/beads/internal/storage/embeddeddolt"
|
||||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
// TestEmbeddedSquashWispMoleculeClearsRootEphemeral mirrors
|
||||
// TestSquashWispMoleculeClearsRootEphemeral but runs against the embedded
|
||||
// Dolt backend used by CI. Without this, the standalone-Dolt regression test
|
||||
// skips in the Embedded Dolt CI tier and the fix's lines stay uncovered.
|
||||
func TestEmbeddedSquashWispMoleculeClearsRootEphemeral(t *testing.T) {
|
||||
if os.Getenv("BEADS_TEST_EMBEDDED_DOLT") != "1" {
|
||||
t.Skip("set BEADS_TEST_EMBEDDED_DOLT=1 to run embedded dolt integration tests")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
beadsDir := t.TempDir()
|
||||
|
||||
s, err := embeddeddolt.Open(ctx, beadsDir, "moltest", "main")
|
||||
if err != nil {
|
||||
t.Fatalf("embeddeddolt.Open: %v", err)
|
||||
}
|
||||
defer s.Close()
|
||||
|
||||
if err := s.SetConfig(ctx, "issue_prefix", "test"); err != nil {
|
||||
t.Fatalf("SetConfig: %v", err)
|
||||
}
|
||||
|
||||
root := &types.Issue{
|
||||
Title: "Wisp Molecule Root",
|
||||
Status: types.StatusOpen,
|
||||
Priority: 1,
|
||||
IssueType: types.TypeEpic,
|
||||
Ephemeral: true,
|
||||
}
|
||||
if err := s.CreateIssue(ctx, root, "test"); err != nil {
|
||||
t.Fatalf("CreateIssue root: %v", err)
|
||||
}
|
||||
|
||||
child := &types.Issue{
|
||||
Title: "Wisp Step",
|
||||
Status: types.StatusClosed,
|
||||
Priority: 2,
|
||||
IssueType: types.TypeTask,
|
||||
Ephemeral: true,
|
||||
}
|
||||
if err := s.CreateIssue(ctx, child, "test"); err != nil {
|
||||
t.Fatalf("CreateIssue child: %v", err)
|
||||
}
|
||||
if err := s.AddDependency(ctx, &types.Dependency{
|
||||
IssueID: child.ID,
|
||||
DependsOnID: root.ID,
|
||||
Type: types.DepParentChild,
|
||||
}, "test"); err != nil {
|
||||
t.Fatalf("AddDependency: %v", err)
|
||||
}
|
||||
|
||||
result, err := squashMolecule(ctx, s, root, []*types.Issue{child}, false, "", "test")
|
||||
if err != nil {
|
||||
t.Fatalf("squashMolecule: %v", err)
|
||||
}
|
||||
if !result.WispSquash {
|
||||
t.Error("expected WispSquash=true for ephemeral root")
|
||||
}
|
||||
|
||||
closed, err := s.GetIssue(ctx, root.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("GetIssue root after squash: %v", err)
|
||||
}
|
||||
if closed.Status != types.StatusClosed {
|
||||
t.Errorf("root status = %v, want closed", closed.Status)
|
||||
}
|
||||
if closed.Ephemeral {
|
||||
t.Error("root Ephemeral should be false after squash; closed wisp roots otherwise leak as duplicate JSONL rows on every export cycle")
|
||||
}
|
||||
}
|
||||
|
|
@ -746,6 +746,73 @@ func TestSquashMoleculeWithAgentSummary(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestSquashWispMoleculeClearsRootEphemeral verifies that squashing a wisp
|
||||
// molecule (root with Ephemeral=true) clears the root's Ephemeral flag in
|
||||
// addition to auto-closing it. Without this, auto-export keeps re-emitting
|
||||
// the closed root as ephemeral=true on every export cycle, accumulating
|
||||
// duplicate JSONL rows.
|
||||
func TestSquashWispMoleculeClearsRootEphemeral(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
dbPath := t.TempDir() + "/test.db"
|
||||
s, err := dolt.New(ctx, &dolt.Config{Path: dbPath})
|
||||
if err != nil {
|
||||
t.Skipf("skipping: Dolt server not available: %v", err)
|
||||
}
|
||||
defer s.Close()
|
||||
if err := s.SetConfig(ctx, "issue_prefix", "test"); err != nil {
|
||||
t.Fatalf("Failed to set config: %v", err)
|
||||
}
|
||||
|
||||
// Wisp molecule: root is ephemeral too (created via `bd mol wisp`).
|
||||
root := &types.Issue{
|
||||
Title: "Wisp Molecule Root",
|
||||
Status: types.StatusOpen,
|
||||
Priority: 1,
|
||||
IssueType: types.TypeEpic,
|
||||
Ephemeral: true,
|
||||
}
|
||||
if err := s.CreateIssue(ctx, root, "test"); err != nil {
|
||||
t.Fatalf("Failed to create ephemeral root: %v", err)
|
||||
}
|
||||
|
||||
child := &types.Issue{
|
||||
Title: "Wisp Step",
|
||||
Status: types.StatusClosed,
|
||||
Priority: 2,
|
||||
IssueType: types.TypeTask,
|
||||
Ephemeral: true,
|
||||
}
|
||||
if err := s.CreateIssue(ctx, child, "test"); err != nil {
|
||||
t.Fatalf("Failed to create child: %v", err)
|
||||
}
|
||||
if err := s.AddDependency(ctx, &types.Dependency{
|
||||
IssueID: child.ID,
|
||||
DependsOnID: root.ID,
|
||||
Type: types.DepParentChild,
|
||||
}, "test"); err != nil {
|
||||
t.Fatalf("Failed to add dependency: %v", err)
|
||||
}
|
||||
|
||||
result, err := squashMolecule(ctx, s, root, []*types.Issue{child}, false, "", "test")
|
||||
if err != nil {
|
||||
t.Fatalf("squashMolecule failed: %v", err)
|
||||
}
|
||||
if !result.WispSquash {
|
||||
t.Error("expected WispSquash=true for ephemeral root")
|
||||
}
|
||||
|
||||
closed, err := s.GetIssue(ctx, root.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get root after squash: %v", err)
|
||||
}
|
||||
if closed.Status != types.StatusClosed {
|
||||
t.Errorf("root status = %v, want closed", closed.Status)
|
||||
}
|
||||
if closed.Ephemeral {
|
||||
t.Errorf("root Ephemeral should be false after squash, got true (issue: closed wisp roots leak as duplicate JSONL rows on every export)")
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Spawn --attach Tests (bd-f7p1)
|
||||
// =============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue