Adds 11 new test files exercising every bd mol/wisp/pour subcommand against a real proxied-server (dolt sql-server via testcontainers), following the existing t.Parallel() + newSharedProxiedProject pattern from ready_wisp_proxied_integration_test.go. Covers show, current, progress, last-activity, stale, ready --gated, distill, pour, bond, squash, burn, and wisp create/list/gc — 47 subtests total. Running these against a live container surfaced and fixed two real bugs in the proxied-server mol port (cmd/bd/mol_port.go): - uowMolReader.GetIssue/GetIssuesByIDs never hydrated Labels (the domain layer's IssueUseCase.GetIssue doesn't join labels the way storage.DoltStorage.GetIssue does), which broke every isProto/ isProtoIssue check downstream (pour, wisp create, bond). - uowMolWriter.AddDependency routed to the wisp_dependencies table whenever either end of a dependency was a wisp; it must route based on dep.IssueID alone (the depender), since the target column (depends_on_wisp_id vs depends_on_issue_id) is already resolved dynamically by the underlying repo insert. The old routing caused an FK violation whenever a persistent digest issue was linked to an ephemeral wisp root during squash. Also fixes a real nil-pointer panic in wisp_proxied_server.go's runWispPurgeClosedProxiedServer: it closed the UnitOfWork's connection before a loop that still called IsInfraTypeCtx through it. Testing also surfaced two pre-existing (not introduced here) bugs shared identically by both backends, confirmed by manually running the embedded CLI: `bd mol stale --all` can never surface childless epics (GetEpicsEligibleForClosure skips zero-child epics before --all is consulted), and `bd mol bond` can never produce a "compound_proto" result via any real CLI invocation (its dispatch checks issue.IsTemplate, which is only set on never-persisted formula-cooked subgraphs, while bondProtoProto assumes its operands are already-persisted DB issues). The new tests document these as parity guards rather than silently skipping them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
118 lines
4 KiB
Go
118 lines
4 KiB
Go
//go:build cgo
|
|
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
func TestProxiedServerMolSquash(t *testing.T) {
|
|
requireSharedProxiedServer(t)
|
|
t.Parallel()
|
|
bd := buildEmbeddedBD(t)
|
|
|
|
t.Run("basic_squash_deletes_ephemeral_children", func(t *testing.T) {
|
|
t.Parallel()
|
|
p := newSharedProxiedProject(t, bd, "msq")
|
|
root := bdProxiedCreate(t, bd, p.dir, "Squash root", "--type", "epic", "--ephemeral")
|
|
child := bdProxiedCreate(t, bd, p.dir, "Squash child", "--type", "task", "--parent", root.ID, "--ephemeral")
|
|
|
|
out, err := bdProxiedRun(t, bd, p.dir, "mol", "squash", root.ID, "--json")
|
|
if err != nil {
|
|
t.Fatalf("bd mol squash --json: %v\n%s", err, out)
|
|
}
|
|
var got struct {
|
|
DigestID string `json:"digest_id"`
|
|
SquashedCount int `json:"squashed_count"`
|
|
DeletedCount int `json:"deleted_count"`
|
|
WispSquash bool `json:"wisp_squash"`
|
|
}
|
|
if err := json.Unmarshal(out, &got); err != nil {
|
|
t.Fatalf("unmarshal: %v\n%s", err, out)
|
|
}
|
|
if got.SquashedCount != 1 || got.DeletedCount != 1 {
|
|
t.Errorf("squashed/deleted = %d/%d, want 1/1", got.SquashedCount, got.DeletedCount)
|
|
}
|
|
if got.DigestID == "" {
|
|
t.Fatal("expected non-empty digest_id")
|
|
}
|
|
if !got.WispSquash {
|
|
t.Error("expected wisp_squash=true for an ephemeral root")
|
|
}
|
|
|
|
db := openProxiedDB(t, p)
|
|
var count int
|
|
if err := db.QueryRow("SELECT COUNT(*) FROM wisps WHERE id = ?", child.ID).Scan(&count); err != nil {
|
|
t.Fatalf("query wisps: %v", err)
|
|
}
|
|
if count != 0 {
|
|
t.Errorf("expected squashed child %s to be deleted from wisps table", child.ID)
|
|
}
|
|
|
|
var rootStatus string
|
|
var rootEphemeral bool
|
|
if err := db.QueryRow("SELECT status, ephemeral FROM wisps WHERE id = ?", root.ID).Scan(&rootStatus, &rootEphemeral); err != nil {
|
|
t.Fatalf("query root wisp row: %v", err)
|
|
}
|
|
if rootStatus != "closed" {
|
|
t.Errorf("root status = %s, want closed", rootStatus)
|
|
}
|
|
if rootEphemeral {
|
|
t.Error("root wisp flag should be cleared after squash")
|
|
}
|
|
})
|
|
|
|
t.Run("keep_children_preserves_wisps", func(t *testing.T) {
|
|
t.Parallel()
|
|
p := newSharedProxiedProject(t, bd, "msqk")
|
|
root := bdProxiedCreate(t, bd, p.dir, "Keep-children root", "--type", "epic", "--ephemeral")
|
|
child := bdProxiedCreate(t, bd, p.dir, "Keep-children child", "--type", "task", "--parent", root.ID, "--ephemeral")
|
|
|
|
out, err := bdProxiedRun(t, bd, p.dir, "mol", "squash", root.ID, "--keep-children", "--json")
|
|
if err != nil {
|
|
t.Fatalf("bd mol squash --keep-children --json: %v\n%s", err, out)
|
|
}
|
|
var got struct {
|
|
DeletedCount int `json:"deleted_count"`
|
|
KeptChildren bool `json:"kept_children"`
|
|
}
|
|
if err := json.Unmarshal(out, &got); err != nil {
|
|
t.Fatalf("unmarshal: %v\n%s", err, out)
|
|
}
|
|
if got.DeletedCount != 0 || !got.KeptChildren {
|
|
t.Errorf("deleted_count/kept_children = %d/%v, want 0/true", got.DeletedCount, got.KeptChildren)
|
|
}
|
|
|
|
db := openProxiedDB(t, p)
|
|
var count int
|
|
if err := db.QueryRow("SELECT COUNT(*) FROM wisps WHERE id = ?", child.ID).Scan(&count); err != nil {
|
|
t.Fatalf("query wisps: %v", err)
|
|
}
|
|
if count != 1 {
|
|
t.Errorf("expected kept child %s to survive squash", child.ID)
|
|
}
|
|
})
|
|
|
|
t.Run("agent_summary_used_verbatim", func(t *testing.T) {
|
|
t.Parallel()
|
|
p := newSharedProxiedProject(t, bd, "msqs")
|
|
root := bdProxiedCreate(t, bd, p.dir, "Summary root", "--type", "epic", "--ephemeral")
|
|
bdProxiedCreate(t, bd, p.dir, "Summary child", "--type", "task", "--parent", root.ID, "--ephemeral")
|
|
|
|
out, err := bdProxiedRun(t, bd, p.dir, "mol", "squash", root.ID, "--summary", "Agent-provided summary text", "--json")
|
|
if err != nil {
|
|
t.Fatalf("bd mol squash --summary --json: %v\n%s", err, out)
|
|
}
|
|
var got struct {
|
|
DigestID string `json:"digest_id"`
|
|
}
|
|
if err := json.Unmarshal(out, &got); err != nil {
|
|
t.Fatalf("unmarshal: %v\n%s", err, out)
|
|
}
|
|
digest := bdProxiedShow(t, bd, p.dir, got.DigestID)
|
|
if digest.Description != "Agent-provided summary text" {
|
|
t.Errorf("digest description = %q, want %q", digest.Description, "Agent-provided summary text")
|
|
}
|
|
})
|
|
}
|