Commit Graph

3758 Commits

Author SHA1 Message Date
Steve Yegge
da809061db fix: emit rich mutation events for status changes (bd-313v)
- Add emitRichMutation() function for events with metadata
- handleClose now emits MutationStatus with old/new status
- handleUpdate detects status changes and emits MutationStatus
- Add comprehensive tests for rich mutation events

Also:
- Add activity.go test coverage (bd-3jcw):
  - Tests for parseDurationString, filterEvents, formatEvent
  - Tests for all mutation type displays
- Fix silent error handling in --follow mode (bd-csnr):
  - Track consecutive daemon failures
  - Show warning after 5 failures (rate-limited to 30s)
  - Show reconnection message on recovery

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 04:16:26 -08:00
Steve Yegge
3f51ca5454 chore: gitignore .runtime/ (Claude Code runtime) 2025-12-23 04:07:16 -08:00
Steve Yegge
fa9a88e2a3 feat: add waits-for dependency type for fanout gates (bd-xo1o.2)
Adds 'waits-for' dependency type for dynamic molecule bonding:
- DepWaitsFor blocks an issue until spawner's children are closed
- Two gate types: all-children (wait for all) or any-children (first)
- Updated blocked_cache.go CTE to handle waits-for dependencies
- Added --waits-for and --waits-for-gate flags to bd create command
- Added WaitsForMeta struct for gate metadata storage
- Full test coverage for all gate types and dynamic child scenarios

This enables patrol molecules to wait for dynamically-bonded arms to
complete before proceeding (Christmas Ornament pattern).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 04:00:00 -08:00
Steve Yegge
37fd1ce614 feat: add parallel step detection for molecules (bd-xo1o.4)
Add --parallel flag to `bd mol show` that analyzes molecule structure
and identifies which steps can run in parallel. Also add --mol flag to
`bd ready` to list ready steps within a specific molecule.

Features:
- `bd mol show <id> --parallel`: Shows parallel group annotations
- `bd ready --mol <id>`: Lists ready steps with parallel opportunities
- Detects steps at same blocking depth that can parallelize
- Groups steps without mutual blocking deps into parallel groups
- JSON output includes full parallel analysis

Algorithm:
- Build dependency graph from blocking deps (blocks, conditional-blocks)
- Calculate blocking depth (distance from unblocked state)
- Group steps at same depth with no mutual blocking into parallel groups
- Mark steps as ready if open/in_progress with no open blockers

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 03:57:08 -08:00
Steve Yegge
72c1c431ef bd sync: 2025-12-23 03:56:58 2025-12-23 03:56:58 -08:00
Steve Yegge
ce85fd4930 bd sync: 2025-12-23 03:48:52 2025-12-23 03:48:52 -08:00
Steve Yegge
ee04b1ea96 feat: add dynamic molecule bonding with --ref flag (bd-xo1o.1)
Implements the Christmas Ornament pattern for patrol molecules:
- Add CloneOptions struct with ParentID and ChildRef for dynamic bonding
- Add generateBondedID() to create custom IDs like "patrol-x7k.arm-ace"
- Add --ref flag to `bd mol bond` for custom child references
- Variable substitution in childRef (e.g., "arm-{{polecat_name}}")

This enables:
  bd mol bond mol-polecat-arm bd-patrol --ref arm-{{name}} --var name=ace
  # Creates: bd-patrol.arm-ace, bd-patrol.arm-ace.capture, etc.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 03:38:38 -08:00
Steve Yegge
3c86144d26 bd sync: 2025-12-23 03:38:21 2025-12-23 03:38:21 -08:00
Steve Yegge
ac07b2259f bd sync: 2025-12-23 03:22:14 2025-12-23 03:22:25 -08:00
Steve Yegge
be520d90fe feat: add bd activity command for real-time state feed (bd-xo1o.3)
Implements activity feed for watching molecule/issue state changes:
- bd activity: show last 100 events
- bd activity --follow: real-time streaming
- bd activity --mol <id>: filter by molecule prefix
- bd activity --since 5m: time-based filtering
- bd activity --type update: filter by event type

Adds new mutation event types for richer activity display:
- MutationBonded: molecule bonded to parent
- MutationSquashed: wisp squashed to digest
- MutationBurned: wisp discarded
- MutationStatus: status transitions with old/new state

Event symbols: + created, → in_progress, ✓ completed, ⊘ deleted, ◉ squashed

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 03:19:09 -08:00
Steve Yegge
47339f89dd bd sync: 2025-12-23 03:18:57 2025-12-23 03:18:57 -08:00
Steve Yegge
625d5fb374 bd sync: 2025-12-23 02:38:39 2025-12-23 02:39:01 -08:00
Steve Yegge
ff3b8fb8ed docs: draft CHANGELOG for v0.35.0 2025-12-23 02:30:53 -08:00
Ryan
e8d0860571 fix(doctor): use --fix instead of manual commands (#715)
UX improvement: doctor advice now recommends bd doctor --fix instead of manual commands
2025-12-23 02:30:33 -08:00
Steve Yegge
14e1f5a2e0 feat: add --parent flag to bd list command (bd-yqhh)
Filters issues by parent issue ID using parent-child dependencies.

Example: bd list --parent=bd-xyz --status=open

Changes:
- Add ParentID field to IssueFilter type
- Add --parent flag to list command
- Forward parent filter through RPC
- Implement filtering in SQLite and memory storage

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 02:10:42 -08:00
Steve Yegge
a3e967b956 bd sync: 2025-12-23 02:10:31 2025-12-23 02:10:31 -08:00
Steve Yegge
a441559c1c bd sync: 2025-12-23 01:58:29 2025-12-23 01:58:39 -08:00
Steve Yegge
92e6f4c079 refactor: remove legacy autoflush code paths (bd-xsl9)
Remove dual code paths in the autoflush system. FlushManager is now the
only code path for auto-flush operations.

Changes:
- Remove legacy globals: isDirty, needsFullExport, flushTimer
- Remove flushToJSONL() wrapper function (was backward-compat shim)
- Simplify markDirtyAndScheduleFlush/FullExport to just call FlushManager
- Update tests to use FlushManager or flushToJSONLWithState directly

FlushManager handles all flush state internally in its run() goroutine,
eliminating the need for global state. Sandbox mode and tests that do
not need flushing get a no-op when FlushManager is nil.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:56:19 -08:00
Steve Yegge
da15363e2b bd sync: 2025-12-23 01:56:10 2025-12-23 01:56:10 -08:00
Steve Yegge
4a91acb53d bd sync: 2025-12-23 01:42:22 2025-12-23 01:42:22 -08:00
Steve Yegge
b2d3577309 bd sync: 2025-12-23 01:39:41 2025-12-23 01:39:41 -08:00
Steve Yegge
618804560e bd sync: 2025-12-23 01:33:42 2025-12-23 01:33:54 -08:00
Steve Yegge
6f2d1603f5 bd sync: 2025-12-23 01:26:59 2025-12-23 01:33:54 -08:00
Steve Yegge
7fb92ff78c feat: implement conditional bond type for mol bond (bd-kzda)
Conditional bonds now work as documented: "B runs only if A fails".

Implementation:
- Add DepConditionalBlocks dependency type to types.go
- Add IsFailureClose() helper to detect failure keywords in close_reason
- Update blocked cache to handle conditional-blocks:
  - B is blocked while A is open
  - B stays blocked if A closes with success
  - B becomes unblocked if A closes with failure

Failure keywords: failed, rejected, wontfix, cancelled, abandoned,
blocked, error, timeout, aborted (case-insensitive)

Updated bondProtoProto, bondProtoMol, bondMolMol to use
DepConditionalBlocks for conditional bond type.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:32:31 -08:00
Steve Yegge
aa1ce63156 feat: consolidate maintenance commands into bd doctor --fix (bd-bqcc)
Add new Maintenance category to bd doctor with checks for:
- Stale closed issues (older than 30 days)
- Expired tombstones (older than TTL)
- Compaction candidates (info only)

Add fix handlers for cleanup and tombstone pruning via bd doctor --fix.
Add deprecation hints to cleanup, compact, and detect-pollution commands
suggesting users try bd doctor instead.

This consolidation reduces cognitive load - users just need to remember
'bd doctor' for health checks and 'bd doctor --fix' for maintenance.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:31:18 -08:00
Steve Yegge
cfe823da61 refactor: add testEnv helpers, reduce SQLite test file sizes (bd-4opy)
- Add testEnv struct with common test helper methods to test_helpers.go
- Methods include CreateIssue, CreateEpic, AddDep, AddParentChild, Close,
  GetReadyWork, AssertReady, AssertBlocked
- Migrate 12+ tests in ready_test.go to use new helpers (-252 lines)
- Migrate 3 tests in dependencies_test.go to use new helpers (-34 lines)
- Total reduction: ~286 lines from test files

The testEnv pattern makes tests more readable and maintainable by:
- Eliminating boilerplate setup (store, cleanup, ctx)
- Providing semantic helper methods (AddDep vs manual AddDependency)
- Using t.Cleanup for automatic resource management

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:30:06 -08:00
Steve Yegge
59b57f8d06 test: add mol current tests (bd-nurq)
Add tests for molecule progress tracking:
- TestGetMoleculeProgress: tests loading molecule and computing progress
- TestFindParentMolecule: tests walking up parent-child chain
- TestAdvanceToNextStep: tests auto-advancing to next step
- TestAdvanceToNextStepMoleculeComplete: tests molecule completion detection
- TestAdvanceToNextStepOrphanIssue: tests non-molecule issue handling

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:24:36 -08:00
Steve Yegge
4bef1fd712 bd sync: 2025-12-23 01:24:24 2025-12-23 01:24:24 -08:00
Steve Yegge
2a2142aca0 bd sync: 2025-12-23 00:55:12 2025-12-23 00:55:49 -08:00
Steve Yegge
97c2c48a49 bd sync: 2025-12-23 00:13:18 2025-12-23 00:55:49 -08:00
Steve Yegge
ecadb83a1c bd sync: 2025-12-23 00:12:57 2025-12-23 00:55:49 -08:00
Steve Yegge
22ef563597 bd sync: 2025-12-23 00:12:38 2025-12-23 00:55:49 -08:00
Steve Yegge
d677554ef3 fix: prevent parallel execution migration race conditions (GH#720)
When multiple bd commands are run in parallel, they can race during database
migrations, causing "duplicate column name" errors. This happens because:

1. Process A checks if column exists → false
2. Process B checks if column exists → false
3. Process A adds column → succeeds
4. Process B adds column → FAILS (duplicate column)

Changes:
- Wrap RunMigrations in BEGIN EXCLUSIVE transaction to serialize migrations
- Disable foreign keys BEFORE the transaction (PRAGMA must be called outside tx)
- Convert nested BEGIN/COMMIT in migrations 010, 022, 025 to use SAVEPOINTs
  (SQLite does not support nested transactions)
- Remove redundant PRAGMA foreign_keys calls from individual migrations

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 00:55:05 -08:00
Steve Yegge
e79558a972 fix: make database_removal_scenario test more realistic
The test was creating an empty .beads/ directory after simulating rm -rf,
but FindBeadsDir() requires some project files (config.yaml, metadata.json,
or *.db/*.jsonl) to recognize a directory as a valid beads directory.

Updated the test to create a minimal config.yaml like bd init actually does
before auto-import runs. This makes the test more realistic and fixes the
flakiness.
2025-12-23 00:04:55 -08:00
Steve Yegge
9480041605 fix: skip interactions.jsonl in FindJSONLInDir (GH#709)
FindJSONLInDir() was returning interactions.jsonl when issues.jsonl
didn't exist. This caused bd sync to write issue data to the wrong
file after fresh init.

Add interactions.jsonl to the skip list alongside deletions.jsonl
and merge artifacts, so the function correctly defaults to issues.jsonl.
2025-12-22 23:37:45 -08:00
Steve Yegge
bd6fa5cbbb fix: bd create -f now works with daemon mode (GH#719)
When using bd create -f with a running daemon, the command would fail
with 'database not initialized' because it bypassed the daemon RPC path.

The fix adds createIssuesFromMarkdownViaDaemon which:
- Parses the markdown file (no store access needed)
- Converts issue templates to CreateArgs
- Uses daemon Batch RPC to create all issues efficiently
- Preserves all features: labels, dependencies, hooks, JSON output

Tested with daemon and non-daemon modes, verifying priority 0 is
preserved correctly.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 23:30:08 -08:00
Steve Yegge
f795f61108 feat: add performance optimization indexes (bd-bha9, bd-a9y3, bd-jke6, bd-8x3w, bd-lk39)
Migration 026_additional_indexes adds 5 indexes identified during schema review (bd-h0we):

- idx_issues_updated_at: For GetStaleIssues date filtering
- idx_issues_status_priority: For common list query patterns
- idx_labels_label_issue: Covering index for label lookups
- idx_dependencies_issue_type: For blocked issues queries
- idx_events_issue_type: For close reason queries

These indexes improve query performance for common operations,
particularly at scale (10K+ issues).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 23:16:08 -08:00
Steve Yegge
8677e5a6a9 bd sync: 2025-12-22 23:15:36 2025-12-22 23:15:36 -08:00
Steve Yegge
c6888c5ea4 bd sync: 2025-12-22 22:59:43 2025-12-22 22:59:43 -08:00
Steve Yegge
ad02b80330 feat: display external deps in bd dep tree (bd-vks2, bd-mv6h, bd-d9mu)
External dependencies (external:project:capability) are now visible in
the dependency tree output. Previously they were invisible because the
recursive CTE only JOINed against the issues table.

Changes:
- GetDependencyTree now fetches external deps and adds them as synthetic
  leaf nodes with resolution status (satisfied/blocked)
- formatTreeNode displays external deps with special formatting
- Added helper parseExternalRefParts for parsing external refs

Test coverage added for:
- External deps appearing in dependency tree
- Cycle detection ignoring external refs
- CheckExternalDep when target has no .beads directory
- Various invalid external ref format variations

Closes: bd-vks2, bd-mv6h, bd-d9mu
2025-12-22 22:34:18 -08:00
Steve Yegge
73b2e14919 bd sync: 2025-12-22 22:33:34 2025-12-22 22:33:34 -08:00
Steve Yegge
266719cece bd sync: 2025-12-22 21:49:02 2025-12-22 21:49:19 -08:00
Steve Yegge
607e04ccef bd sync: 2025-12-22 21:30:29 2025-12-22 21:49:19 -08:00
Steve Yegge
0c4e17c98a bd sync: 2025-12-22 21:15:48 2025-12-22 21:49:19 -08:00
Steve Yegge
36c652dc01 bd sync: 2025-12-22 20:09:31 2025-12-22 21:49:19 -08:00
Steve Yegge
340417f393 fix: filter satisfied external deps from GetBlockedIssues (bd-396j)
GetBlockedIssues was showing external deps as blocking even when they
were satisfied (had a closed issue with provides:capability label).

Added filterBlockedByExternalDeps() which:
- Collects all external refs from blocked issues
- Checks each with CheckExternalDeps() in batch
- Filters satisfied refs from BlockedBy lists
- Updates BlockedByCount accordingly
- Removes issues with no remaining blockers (unless status=blocked/deferred)

This matches the behavior of GetReadyWork which already filters by
external deps correctly.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 21:48:55 -08:00
Steve Yegge
25061ea9a7 chore: code health review - test fix and error comments (bd-9g1z, bd-ork0)
- Remove TestFindJSONLPathDefault from .test-skip (now passes)
- Add explanatory comments to 24 ignored error locations in cmd/bd:
  - Cobra flag methods (MarkHidden, MarkRequired, MarkDeprecated)
  - Best-effort cleanup/close operations
  - Process signaling operations

Part of code health review epic bd-tggf.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 21:30:57 -08:00
Steve Yegge
fc0b98730a refactor: consolidate duplicate path-finding utilities (bd-74w1, bd-4nqq)
- Add git.GetRepoRoot() with Windows path normalization
- Update beads.findGitRoot() to delegate to git.GetRepoRoot()
- Replace findBeadsDir() with beads.FindBeadsDir() across 8 files
- Remove duplicate findBeadsDir() and findGitRoot() function definitions
- Remove dead test code (TestInfoCommand, TestInfoWithNoDaemon)
- Update tests to work with consolidated APIs

Part of Code Health Review Dec 2025 epic (bd-tggf).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 21:15:41 -08:00
Steve Yegge
ca1927bfaa Merge pull request #717 from steveyegge/consolidate-doctor-commands
Reviewed and fixed by dave (beads crew worker)
2025-12-22 20:31:28 -08:00
Steve Yegge
e2ab727a2c fix(doctor): use context.Background() instead of nil in CheckDuplicateIssues
The nil context caused a panic during store.Close() in tests.
Passing context.Background() fixes the test timeout issue.
2025-12-22 20:21:30 -08:00