diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index b1a8c683..419496a2 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -232,7 +232,7 @@ {"id":"bd-gfo3","title":"Merge: bd-ykd9","description":"branch: polecat/Doctor\ntarget: main\nsource_issue: bd-ykd9\nrig: beads","status":"open","priority":2,"issue_type":"merge-request","created_at":"2025-12-23T13:34:43.778808-08:00","updated_at":"2025-12-23T13:34:43.778808-08:00"} {"id":"bd-gjla","title":"Test Thread","description":"Initial message for threading test","status":"tombstone","priority":2,"issue_type":"message","created_at":"2025-12-16T18:19:51.704324-08:00","updated_at":"2025-12-17T16:11:17.070763-08:00","dependencies":[{"issue_id":"bd-gjla","depends_on_id":"bd-f5cc","type":"duplicates","created_at":"2025-12-18T13:45:31.137191-08:00","created_by":"migration"}],"deleted_at":"2025-12-17T16:11:17.070763-08:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"message"} {"id":"bd-gocx","title":"Run bump-version.sh 0.32.1","description":"Execute ./scripts/bump-version.sh 0.32.1 to update all version references","status":"closed","priority":1,"issue_type":"task","created_at":"2025-12-20T21:53:18.470174-08:00","updated_at":"2025-12-20T21:54:54.500836-08:00","closed_at":"2025-12-20T21:54:54.500836-08:00","close_reason":"Version bumped to 0.32.1","dependencies":[{"issue_id":"bd-gocx","depends_on_id":"bd-an4s","type":"parent-child","created_at":"2025-12-20T21:53:18.471793-08:00","created_by":"daemon"},{"issue_id":"bd-gocx","depends_on_id":"bd-x3j8","type":"blocks","created_at":"2025-12-20T21:53:29.688436-08:00","created_by":"daemon"}]} -{"id":"bd-gqxd","title":"Enrich MutationEvent with title and assignee","description":"Current MutationEvent only has IssueID, no context. Add Title and Assignee fields so activity feeds can display meaningful info without extra lookups. Emit these fields when creating mutation events in server_core.go.","status":"in_progress","priority":2,"issue_type":"feature","assignee":"beads/furiosa","created_at":"2025-12-23T16:26:34.907259-08:00","updated_at":"2025-12-23T16:32:00.116813-08:00"} +{"id":"bd-gqxd","title":"Enrich MutationEvent with title and assignee","description":"Current MutationEvent only has IssueID, no context. Add Title and Assignee fields so activity feeds can display meaningful info without extra lookups. Emit these fields when creating mutation events in server_core.go.","status":"in_progress","priority":2,"issue_type":"feature","assignee":"beads/furiosa","created_at":"2025-12-23T16:26:34.907259-08:00","updated_at":"2025-12-23T16:34:30.466868-08:00"} {"id":"bd-gxq","title":"Simplify bd onboard to minimal AGENTS.md snippet pointing to bd prime","description":"## Context\nGH#604 raised concerns about bd onboard bloating AGENTS.md with ~100+ lines of static instructions that:\n- Load every session whether beads is being used or not\n- Get stale when bd upgrades\n- Waste tokens\n\n## Solution\nSimplify `bd onboard` to output a minimal snippet (~2 lines) that points to `bd prime`:\n\n```markdown\n## Issue Tracking\nThis project uses beads (`bd`) for issue tracking.\nRun `bd prime` for workflow context, or hooks auto-inject it.\n```\n\n## Rationale\n- `bd prime` is dynamic, concise (~80 lines), and always matches installed bd version\n- Hooks already auto-inject `bd prime` at session start when .beads/ detected\n- AGENTS.md only needs to mention beads exists, not contain full instructions\n\n## Implementation\n1. Update `cmd/bd/onboard.go` to output minimal snippet\n2. Keep `--output` flag for BD_GUIDE.md generation (may still be useful)\n3. Update help text to explain the new approach","status":"closed","priority":1,"issue_type":"task","created_at":"2025-12-18T11:42:38.604891-08:00","updated_at":"2025-12-18T11:47:28.020419-08:00","closed_at":"2025-12-18T11:47:28.020419-08:00","close_reason":"Implemented: bd onboard now outputs minimal snippet pointing to bd prime"} {"id":"bd-h0we","title":"Review SQLite indexes and scaling bottlenecks","description":"Audit the beads SQLite schema for:\n\n## Index Review\n- Are all frequently-queried columns indexed?\n- Are compound indexes needed for common query patterns?\n- Any missing indexes on foreign keys or filter columns?\n\n## Scaling Bottlenecks\n- How does performance degrade with 10k, 100k, 1M issues?\n- Full table scans in hot paths?\n- JSONL export/import performance at scale\n- Transaction contention in multi-agent scenarios\n\n## Common Query Patterns to Optimize\n- bd ready (status + blocked_by resolution)\n- bd list with filters (status, type, priority, labels)\n- bd show with dependency graph traversal\n- bd sync import/export\n\n## Deliverables\n- Document current indexes\n- Identify missing indexes\n- Benchmark key operations at scale\n- Recommend schema improvements","status":"closed","priority":2,"issue_type":"task","created_at":"2025-12-21T23:41:06.481881-08:00","updated_at":"2025-12-22T22:59:25.178175-08:00","closed_at":"2025-12-22T22:59:25.178175-08:00","close_reason":"Completed comprehensive review. Created 7 follow-up issues:\n- bd-bha9: updated_at index (P2)\n- bd-a9y3: (status, priority) composite (P3) \n- bd-jke6: labels covering index (P3)\n- bd-8x3w: dependencies (issue_id, type) (P3)\n- bd-lk39: events composite (P4)\n- bd-zw72: cache scaling investigation (P3)\n- bd-m964: FTS5 consideration (P4)\n\nKey findings:\n1. Current schema has good coverage for hot paths\n2. blocked_issues_cache provides 25x speedup for GetReadyWork\n3. Main gaps are composite indexes for common filter combinations\n4. Scaling concerns start at 100K+ issues, primarily around text search and cache rebuild"} {"id":"bd-h27p","title":"Merge: bd-g4b4","description":"branch: polecat/Hooker\ntarget: main\nsource_issue: bd-g4b4\nrig: beads","status":"open","priority":3,"issue_type":"merge-request","created_at":"2025-12-23T13:38:50.707153-08:00","updated_at":"2025-12-23T13:38:50.707153-08:00"} diff --git a/cmd/bd/mol_run.go b/cmd/bd/mol_run.go index 82861b89..ec322521 100644 --- a/cmd/bd/mol_run.go +++ b/cmd/bd/mol_run.go @@ -6,6 +6,8 @@ import ( "strings" "github.com/spf13/cobra" + "github.com/steveyegge/beads/internal/beads" + "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" @@ -25,9 +27,15 @@ This command: After a crash or session reset, the pinned root issue ensures the agent can resume from where it left off by checking 'bd ready'. +The --template-db flag enables cross-database spawning: read templates from +one database (e.g., main) while writing spawned instances to another (e.g., wisp). +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 bd-qqc --var version=0.32.0 --var date=2025-01-01 + bd --db .beads-wisp/beads.db mol run mol-patrol --template-db .beads/beads.db`, Args: cobra.ExactArgs(1), Run: runMolRun, } @@ -49,6 +57,7 @@ func runMolRun(cmd *cobra.Command, args []string) { } varFlags, _ := cmd.Flags().GetStringSlice("var") + templateDB, _ := cmd.Flags().GetString("template-db") // Parse variables vars := make(map[string]string) @@ -61,15 +70,42 @@ func runMolRun(cmd *cobra.Command, args []string) { vars[parts[0]] = parts[1] } - // Resolve molecule ID - moleculeID, err := utils.ResolvePartialID(ctx, store, args[0]) + // Determine which store to use for reading the template + // If --template-db is set, open a separate connection for reading the template + // This enables cross-database spawning (read from main, write to wisp) + // + // Auto-discovery: if --db contains ".beads-wisp" (wisp storage) but --template-db + // is not set, automatically use the main database for templates. This handles the + // common case of spawning patrol molecules from main DB into wisp storage. + templateStore := store + if templateDB == "" && strings.Contains(dbPath, ".beads-wisp") { + // Auto-discover main database for templates + templateDB = beads.FindDatabasePath() + if templateDB == "" { + fmt.Fprintf(os.Stderr, "Error: cannot find main database for templates\n") + fmt.Fprintf(os.Stderr, "Hint: specify --template-db explicitly\n") + os.Exit(1) + } + } + if templateDB != "" { + var err error + templateStore, err = sqlite.NewWithTimeout(ctx, templateDB, lockTimeout) + if err != nil { + fmt.Fprintf(os.Stderr, "Error opening template database %s: %v\n", templateDB, err) + os.Exit(1) + } + defer templateStore.Close() + } + + // Resolve molecule ID from template store + moleculeID, err := utils.ResolvePartialID(ctx, templateStore, args[0]) if err != nil { fmt.Fprintf(os.Stderr, "Error resolving molecule ID %s: %v\n", args[0], err) os.Exit(1) } - // Load the molecule subgraph - subgraph, err := loadTemplateSubgraph(ctx, store, moleculeID) + // Load the molecule subgraph from template store + subgraph, err := loadTemplateSubgraph(ctx, templateStore, moleculeID) if err != nil { fmt.Fprintf(os.Stderr, "Error loading molecule: %v\n", err) os.Exit(1) @@ -132,6 +168,7 @@ func runMolRun(cmd *cobra.Command, args []string) { func init() { molRunCmd.Flags().StringSlice("var", []string{}, "Variable substitution (key=value)") + molRunCmd.Flags().String("template-db", "", "Database to read templates from (enables cross-database spawning)") molCmd.AddCommand(molRunCmd) }