fix: mol run loads all hierarchical children + supports title lookup (bd-c8d5, bd-drcx)

Two issues fixed:

1. bd-c8d5: mol run only created partial children from proto
   - Root cause: children with missing/wrong dependencies were not loaded
   - Fix: loadDescendants now uses two strategies:
     - Strategy 1: Check dependency records for parent-child relationships
     - Strategy 2: Find hierarchical children by ID pattern (parent.N)
   - This catches children that may have broken dependency data

2. bd-drcx: mol run now supports proto lookup by title
   - Can use: bd mol run mol-polecat-work --var issue=gt-xxx
   - Or by ID: bd mol run gt-lwuu --var issue=gt-xxx
   - Title matching is case-insensitive and supports partial matches
   - Shows helpful error on ambiguous matches

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-24 23:33:14 -08:00
parent 81171ff237
commit c429405e0d
3 changed files with 495 additions and 8 deletions

View File

@@ -10,11 +10,10 @@ import (
"github.com/steveyegge/beads/internal/storage/sqlite"
"github.com/steveyegge/beads/internal/types"
"github.com/steveyegge/beads/internal/ui"
"github.com/steveyegge/beads/internal/utils"
)
var molRunCmd = &cobra.Command{
Use: "run <proto-id>",
Use: "run <proto-id-or-title>",
Short: "Spawn proto and start execution (spawn + assign + pin)",
Long: `Run a molecule by spawning a proto and setting up for durable execution.
@@ -24,6 +23,9 @@ This command:
3. Sets root status to in_progress
4. Pins the root issue for session recovery
The proto can be specified by ID or title. Title matching is case-insensitive
and supports partial matches (e.g., "polecat" matches "mol-polecat-work").
After a crash or session reset, the pinned root issue ensures the agent
can resume from where it left off by checking 'bd ready'.
@@ -33,8 +35,9 @@ This is essential for wisp molecule spawning where templates exist in the main
database but instances should be ephemeral.
Example:
bd mol run mol-version-bump --var version=1.2.0
bd mol run bd-qqc --var version=0.32.0 --var date=2025-01-01
bd mol run mol-polecat-work --var issue=gt-xxx # By title
bd mol run gt-lwuu --var issue=gt-xxx # By ID
bd mol run polecat --var issue=gt-xxx # By partial title
bd --db .beads-wisp/beads.db mol run mol-patrol --template-db .beads/beads.db`,
Args: cobra.ExactArgs(1),
Run: runMolRun,
@@ -97,10 +100,10 @@ func runMolRun(cmd *cobra.Command, args []string) {
defer func() { _ = templateStore.Close() }()
}
// Resolve molecule ID from template store
moleculeID, err := utils.ResolvePartialID(ctx, templateStore, args[0])
// Resolve molecule ID from template store (supports both ID and title - bd-drcx)
moleculeID, err := resolveProtoIDOrTitle(ctx, templateStore, args[0])
if err != nil {
fmt.Fprintf(os.Stderr, "Error resolving molecule ID %s: %v\n", args[0], err)
fmt.Fprintf(os.Stderr, "Error resolving molecule %s: %v\n", args[0], err)
os.Exit(1)
}