Commit Graph

4326 Commits

Author SHA1 Message Date
Jordan Hubbard
cb280b0fad test: improve nodb and orphans coverage 2025-12-29 14:17:44 -08:00
Jordan Hubbard
9cefa98528 test: refactor claude setup for coverage 2025-12-29 14:17:44 -08:00
Jordan Hubbard
283a275740 test: refactor claude setup for coverage 2025-12-29 14:16:44 -08:00
Jordan Hubbard
8f8a075943 test: refactor factory setup for coverage (#790)
* test: add git helper and guard annotations

* chore: align release metadata with 0.40.0

* test: refactor factory setup for coverage
2025-12-29 14:15:56 -08:00
Steve Yegge
96c7cceefc refactor: Extract IssueDetails to shared type (bd-6dnt)
Consolidated 5 duplicate IssueDetails struct definitions into a single
types.IssueDetails in internal/types/types.go:

- Removed 4 inline definitions from cmd/bd/show.go
- Removed 1 inline definition from internal/rpc/server_issues_epics.go

The shared type embeds types.Issue by value and includes:
Labels, Dependencies, Dependents, Comments, and Parent fields.

This improves maintainability and reduces risk of inconsistency.
2025-12-29 14:04:35 -08:00
Steve Yegge
2c57d41275 fix: Show warning when config.yaml overrides database config (bd-20j)
bd config list now shows a warning when config.yaml or environment
variables override database settings. This addresses the confusion when
sync.branch from config.yaml takes precedence over the database value.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 14:03:39 -08:00
Steve Yegge
9eb61f9dd0 bd sync: 2025-12-29 14:03:20 2025-12-29 14:03:20 -08:00
Steve Yegge
31bed17090 bd sync: 2025-12-29 13:46:54 2025-12-29 13:47:12 -08:00
Steve Yegge
64d5f20b90 fix: Add pre-migration orphan cleanup to avoid chicken-and-egg failure (bd-eko4)
When the database has orphaned foreign key references (dependencies or labels
pointing to non-existent issues), the migration invariant check would fail,
preventing the database from opening. This created a chicken-and-egg problem:

1. bd doctor --fix tries to open the database
2. Opening triggers migrations with invariant checks
3. Invariant check fails due to orphaned refs
4. Fix never runs because database won't open

The fix adds CleanOrphanedRefs() that runs BEFORE captureSnapshot() in
RunMigrations. This automatically cleans up orphaned dependencies and labels
(preserving external:* refs), allowing the database to open normally.

Added test coverage for the cleanup function.
2025-12-29 13:47:04 -08:00
Steve Yegge
819208b8c1 fix: hq- prefix routing by finding town root for routes.jsonl
The routing code now walks up from the current beads directory to find
the Gas Town root (identified by mayor/town.json), then loads routes
from <townRoot>/.beads/routes.jsonl. The '.' path is correctly resolved
to the town beads directory.

Previously, routes.jsonl was only searched in the current beads dir,
which failed when working from rig subdirectories like crew/emma.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 13:46:10 -08:00
Steve Yegge
04da559511 bd sync: 2025-12-29 13:45:51 2025-12-29 13:45:51 -08:00
Steve Yegge
6ee7be5fe9 bd sync: 2025-12-29 13:40:37 2025-12-29 13:40:37 -08:00
Steve Yegge
0183af11d5 bd sync: 2025-12-29 13:34:01 2025-12-29 13:34:14 -08:00
Steve Yegge
9e5a548339 bd sync: 2025-12-29 12:59:10 2025-12-29 13:34:14 -08:00
Steve Yegge
5560a4243e refactor: Export FollowRedirect and consolidate duplicate implementations
- Rename followRedirect to FollowRedirect in internal/beads (export it)
- Update doctor/maintenance.go to use beads.FollowRedirect
- Update doctor/fix/common.go to use beads.FollowRedirect
- Remove 66 lines of duplicated code across 3 implementations

This ensures consistent redirect handling with path canonicalization,
chain prevention, and proper error warnings.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 13:23:05 -08:00
Steve Yegge
ef40856f2f fix: bd repair - consistent JSON error handling for find operations
Add exitWithError helper to ensure JSON output is used when --json
flag is set during orphan detection errors.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 13:16:47 -08:00
Steve Yegge
24966bd1ce fix: Handle .beads/redirect files and limit verbose output in bd doctor --fix
- Add resolveBeadsDir helper to fix/common.go to follow redirect files
- Update OrphanedDependencies, ChildParentDependencies, and MergeArtifacts
  to use resolveBeadsDir instead of hardcoded .beads path
- Add --verbose/-v flag to bd doctor command
- Only print individual items if verbose or count < 20, always show summary

(bd-dq74, bd-v55y)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 12:59:19 -08:00
Steve Yegge
cd942f136d feat: bd repair - add comments/events orphan detection and --json flag
- Check comments table for orphaned issue_id references
- Check events table for orphaned issue_id references
- Delete orphaned comments/events in repair transaction
- Add --json flag for machine-readable output with:
  - orphan_counts by type (dependencies, labels, comments, events)
  - orphan_details with full reference info
  - status (success, no_orphans, dry_run, error)
  - backup_path when applicable

(bd-2wm2, bd-ie7j)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 12:58:22 -08:00
Steve Yegge
75e2afdae5 bd sync: 2025-12-29 12:58:08 2025-12-29 12:58:08 -08:00
Steve Yegge
bd750b10ea bd sync: 2025-12-29 12:48:20 2025-12-29 12:48:35 -08:00
Steve Yegge
a6bba83f09 fix: bd repair - add transaction, backup, dirty_issues marking
Code review fixes for critical issues:
- Wrap all DELETEs in a transaction with rollback on error
- Create .pre-repair backup before any destructive operations
- Mark parent issues as dirty when deleting orphaned depends_on refs
- Fix misleading PreRun comment

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 12:47:34 -08:00
Steve Yegge
1facf7fb83 feat: Add bd repair command for orphaned foreign key refs (hq-2cchm)
When the database has orphaned dependencies or labels, the migration
invariant check fails and prevents the database from opening. This
creates a chicken-and-egg problem where bd doctor --fix cannot run.

The new bd repair command:
- Opens SQLite directly, bypassing invariant checks
- Deletes orphaned dependencies (issue_id or depends_on_id not in issues)
- Deletes orphaned labels (issue_id not in issues)
- Runs WAL checkpoint to persist changes
- Supports --dry-run to preview what would be cleaned

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 12:43:22 -08:00
Steve Yegge
93cc9df9ad bd sync: 2025-12-29 12:43:14 2025-12-29 12:43:14 -08:00
Steve Yegge
c45242a8d3 feat: Add --reason flag to bd delete for audit trail 2025-12-29 12:40:03 -08:00
Steve Yegge
7b92b42d38 bd sync: 2025-12-29 12:35:12 2025-12-29 12:38:22 -08:00
Steve Yegge
934196e102 refactor: Extract shared importFromJSONLData function
Eliminate code duplication between importFromGit and importFromLocalJSONL
by extracting the common JSONL parsing and import logic.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 12:38:02 -08:00
Steve Yegge
bb5c27c81b feat: Add bd init --from-jsonl for preserving manual cleanups
Adds --from-jsonl flag that imports from the current working tree's
.beads/issues.jsonl file instead of scanning git history. This prevents
deleted issues from being resurrected during re-initialization.

Use case: After running bd compact --purge-tombstones and committing
the cleaned JSONL, a subsequent bd init would previously re-import
all historical issues from git, defeating the cleanup.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 12:34:57 -08:00
Steve Yegge
6c42b461a4 feat: Add bd compact --purge-tombstones for dependency-aware cleanup (hq-n19iv)
Unlike --prune which removes tombstones by age, --purge-tombstones removes
tombstones that have no open issues depending on them, regardless of age.
Also cleans stale deps from closed issues to tombstones.

Usage:
  bd compact --purge-tombstones --dry-run  # Preview what would be purged
  bd compact --purge-tombstones            # Actually purge

Note: Use --no-daemon to prevent daemon from re-exporting after cleanup.
2025-12-28 23:46:22 -08:00
Steve Yegge
7f1f906c28 bd sync: 2025-12-28 23:46:11 2025-12-28 23:46:11 -08:00
Steve Yegge
7d1ee6d3e9 feat: Add 'hooked' status for GUPP work assignment (bd-s00m)
Separates semantics of 'pinned' (identity records) from work-on-hook:
- 'pinned' = domain table / identity record (agents, roles) - non-blocking
- 'hooked' = work on agent's hook (GUPP-driven) - blocks dependents

Changes:
- Add StatusHooked constant to types.go
- Update all blocking queries to include 'hooked' status
- Add cyan styling for 'hooked' in UI output
- Create migration 032 to convert pinned work items to hooked

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 22:37:04 -08:00
Steve Yegge
4a6d942fad bd sync: 2025-12-28 22:36:53 2025-12-28 22:36:53 -08:00
Steve Yegge
8e746ed9ec bd sync: 2025-12-28 22:22:39 2025-12-28 22:22:39 -08:00
Steve Yegge
aa016c8802 bd sync: 2025-12-28 22:14:33 2025-12-28 22:14:51 -08:00
Steve Yegge
b3d6ef60bb feat: swarm commands improvements (bd-2ubv)
- Add findExistingSwarm helper and duplicate swarm check with --force flag
- Add bd swarm list command for discovering swarm molecules with progress stats
- Fix empty coordinator display in swarm create output
- Allow swarm status to accept swarm molecule ID (follows relates-to link)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 22:07:39 -08:00
Steve Yegge
5bd387c4bc bd sync: 2025-12-28 22:07:05 2025-12-28 22:07:05 -08:00
Steve Yegge
7a3498f881 refactor: extract shared getEpicChildren helper for swarm commands
- Add EpicChildren struct and getEpicChildren() helper function
- Define SwarmStore interface for dependency injection
- Refactor analyzeEpicForSwarm to use shared helper
- Refactor getSwarmStatus to use shared helper
- Eliminates duplicate code for fetching epic children and building
  dependency maps across both functions

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 21:44:06 -08:00
Steve Yegge
68ffda0fc0 bd sync: 2025-12-28 21:43:56 2025-12-28 21:43:56 -08:00
Steve Yegge
cb601d661e bd sync: 2025-12-28 21:38:58 2025-12-28 21:38:58 -08:00
Steve Yegge
a93736b8f6 bd sync: 2025-12-28 21:35:43 2025-12-28 21:35:43 -08:00
Steve Yegge
d5a87e839a docs: Replace Epic Planning with Ready Front model
The Ready Front model replaces temporal 'phase' thinking:
- Ready Front = issues with all deps satisfied (unblocked)
- Static: natural topology (sync points, bottlenecks)
- Dynamic: current wavefront of in-progress work

Key changes:
- Add cognitive trap warning (temporal language inverts deps)
- Graph Walk Pattern: walk backward from goal
- Requirement language: 'X needs Y' not 'X before Y'
- Validation with bd blocked
- Ready Fronts visualization
2025-12-28 21:35:30 -08:00
Steve Yegge
2213fc016d Add --short flag to bd show for compact output
Displays each issue on a single line with format:
<id> [<status>] P<priority> <type>: <title>

Example:
  bd show bd-nlzv --short
  bd-nlzv [open] P2 feature: bd show --short flag for compact output

Useful for quick status checks of multiple issues. (bd-nlzv)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 21:35:30 -08:00
Steve Yegge
2f6efffab3 bd sync: 2025-12-28 21:34:36 2025-12-28 21:35:30 -08:00
Steve Yegge
3fd4eccb78 perf: fix N+1 query in swarm status blocked check (bd-7p5l)
Build status map upfront from childIssues instead of calling
GetIssue for each dependency. Reduces queries from O(issues * deps)
to O(issues).

Also removes unused GetIssue from the interface.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 21:35:22 -08:00
Steve Yegge
67cf9dc302 feat: Add bd swarm create command (bd-fa1q)
Implements `bd swarm create <epic-id>` to create a swarm molecule
that orchestrates parallel work on an epic.

Features:
- Creates molecule with mol_type=swarm for discovery
- Links to epic via relates-to dependency
- Validates epic structure before creation
- Auto-wraps single issues in an epic when needed
- Optional --coordinator flag to specify coordinator agent
- Supports JSON output for machine consumption

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 21:34:24 -08:00
Steve Yegge
302964b0f6 bd sync: 2025-12-28 21:31:23 2025-12-28 21:31:23 -08:00
Steve Yegge
2b8d9bc751 bd sync: 2025-12-28 21:28:27 2025-12-28 21:28:27 -08:00
Steve Yegge
a1ac42aca9 feat: add bd swarm status command (bd-5x0j)
Show current swarm status computed from beads:
- Completed: closed issues with timestamps
- Active: in_progress issues with assignees
- Ready: open issues with all deps satisfied
- Blocked: open issues waiting on deps
- Progress percentage

State is COMPUTED from beads, not stored separately.
Supports --json for programmatic use.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 21:28:14 -08:00
Steve Yegge
7ff5481966 fix: resolve golangci-lint errors (errcheck, gosec, unparam)
- orphans.go: check fmt.Scanln return value
- edit.go: #nosec G204 for trusted $EDITOR execution
- sync_git.go: #nosec G204 for git commands with internal branch names
- worktree_cmd.go: #nosec G304/G306 for .gitignore file operations
- migrations: handle rows.Close() error
- doctor_pollution.go: mark unused path parameter

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 20:50:54 -08:00
Jordan Hubbard
713c569e6e test: add git helper and guard annotations 2025-12-28 20:48:37 -08:00
Steve Yegge
f3dcafca66 feat: Add mol_type schema field for molecule type classification (bd-oxgi)
Add mol_type field to beads for swarm coordination:
- Values: 'swarm' (multi-polecat), 'patrol' (recurring ops), 'work' (default)
- Nullable, defaults to empty string (treated as 'work')

Changes:
- Add mol_type column to SQLite schema and migration 031
- Add MolType type with IsValid() validation in types.go
- Update insertIssue/GetIssue to handle mol_type
- Add --mol-type flag to create command
- Add mol_type filtering to list and ready commands
- Update RPC protocol for daemon mode support
- Update test schema in migrations_test.go

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 19:52:51 -08:00