Commit Graph

3741 Commits

Author SHA1 Message Date
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
Ryan Snodgrass
cafc0b9dfb refactor(doctor): consolidate maintenance commands + improve daemon startup
Consolidate clean, repair-deps, validate into bd doctor:
- Add validation checks to doctor (merge artifacts, orphaned deps, duplicates, test pollution, git conflicts)
- Add auto-fix for merge artifacts and orphaned dependencies
- Delete obsolete command files: clean.go, repair_deps.go, validate.go
- Delete orphaned test files: clean_security_test.go, validate_test.go

Improve daemon startup performance:
- Add fast-fail detection when daemon crashed (check lock before retrying)
- Reduce graceful shutdown timeout from 5s to 1s
- Skip daemon connection for root command (just shows help)
- Extract shutdown timeout as constants (daemonShutdownTimeout, daemonShutdownPollInterval)

Other changes:
- Move rename-prefix command to Maintenance group in help
- Fix Makefile to inject git commit hash via ldflags

New files:
- cmd/bd/doctor/validation.go (5 check functions)
- cmd/bd/doctor/fix/validation.go (2 fix functions)
2025-12-22 20:21:30 -08:00
Steve Yegge
e60dfaf1f1 Merge pull request #713 from cpdata/fix/daemon-duplicate-log-messages
Reviewed by dave (beads crew worker)
2025-12-22 20:18:02 -08:00
Steve Yegge
c4fc27de57 Merge pull request #711 from cpdata/fix/worktree-health-check-redundancy
Reviewed by dave (beads crew worker)
2025-12-22 20:17:59 -08:00
Steve Yegge
9621ccb637 Merge pull request #708 from cpdata/docs/daemon-event-driven-mode
Reviewed by dave (beads crew worker)
2025-12-22 20:17:57 -08:00
Steve Yegge
7c24cf63bd Merge pull request #707 from cpdata/feat/auto-pull-config
Reviewed by dave (beads crew worker)
2025-12-22 20:17:54 -08:00
Steve Yegge
90ce008047 Merge pull request #705 from crcatala/fix/add-interactions-jsonl-to-gitignore-allowlist
Reviewed by dave (beads crew worker)
2025-12-22 20:17:51 -08:00
Steve Yegge
62bbae9c78 feat(types): add HOP entity tracking types (bd-7pwh)
- Add EntityRef type for structured entity references with URI support
- Add Creator field to Issue for tracking who created work
- Add Validation type and Validations field for proof-of-stake approvals
- Fix RemoveDependency FK violation on external deps (bd-a3sj)
- Include all new fields in content hash computation
- Full test coverage for all new types

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-22 20:10:09 -08:00
Steve Yegge
6a2909c686 Add Claude Code settings for zoey crew worker 2025-12-22 18:01:44 -08:00
Steve Yegge
808c33b7a0 feat: add molecule navigation commands (bd-sal9, bd-ieyy)
Add bd mol current: Shows current position in molecule workflow
- Displays all steps with status indicators (done/current/ready/blocked/pending)
- Infers molecule from in_progress issues when no ID given
- Supports --for flag to check another agent's molecules

Add bd close --continue: Auto-advances to next molecule step
- After closing, finds parent molecule and next ready step
- Auto-claims next step by default (--no-auto to skip)
- Shows molecule completion message when all steps closed

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 17:37:23 -08:00
Steve Yegge
11dd84a579 bd sync: 2025-12-22 17:36:38 2025-12-22 17:36:38 -08:00
Steve Yegge
8097cd653b bd sync: 2025-12-22 17:04:03 2025-12-22 17:04:03 -08:00
Charles P. Cross
195091711e fix(daemon): deduplicate file and git ref change log messages
The daemon.log was showing duplicate log messages:
- 'File change detected' appeared 4x for a single file change
- 'Git ref change detected' appeared 2x for a single ref update

Root cause:
- fsnotify generates multiple events (Write, Create, Chmod) for single file ops
- Both parent directory and file watchers can trigger for the same change
- Multiple git ref files may be updated simultaneously

Fix:
- Add log deduplication with 500ms window (matching debouncer window)
- Track last log time for file changes and git ref changes separately
- Only log if enough time has passed since last log of same type
- Still trigger debouncer for every event (functionality unchanged)

This reduces log noise while maintaining full functionality.
2025-12-22 19:02:42 -05:00
Steve Yegge
dd9fcd9e36 feat(scripts): add --all, --mcp-local, --restart-daemons flags to bump-version.sh
Improves the version bump workflow with missing local installation steps:

- --install: Now installs bd to BOTH ~/go/bin AND ~/.local/bin
- --mcp-local: Install beads-mcp from local source via uv/pip
- --restart-daemons: Restart all bd daemons to pick up new version
- --all: Shorthand for --install --mcp-local --restart-daemons

Also updated RELEASING.md with flag documentation and recommended workflow.

Closes bd-of2p

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-22 16:02:29 -08:00
Steve Yegge
014efbbd3f bd sync: 2025-12-22 16:02:19 2025-12-22 16:02:19 -08:00
Charles P. Cross
665e5b3a87 fix(worktree): integrate health check into CreateBeadsWorktree to prevent redundant checks
The error message 'path exists but is not a valid git worktree' was appearing
in daemon.log when the daemon attempted to use an existing worktree that was
in the git worktree list but had other issues (broken sparse checkout, etc.).

Root cause:
- CreateBeadsWorktree only checked isValidWorktree (is it in git worktree list)
- CheckWorktreeHealth was called separately and checked additional things
- If the worktree passed isValidWorktree but failed health check, an error
  was logged and repair was attempted

Fix:
- CreateBeadsWorktree now performs a full health check when it finds an
  existing worktree that's in the git worktree list
- If the health check fails, it automatically removes and recreates the
  worktree
- Removed redundant CheckWorktreeHealth calls in daemon_sync_branch.go and
  syncbranch/worktree.go since CreateBeadsWorktree now handles this internally

This eliminates the confusing error message and ensures worktrees are always
in a healthy state after CreateBeadsWorktree returns successfully.
2025-12-22 18:57:43 -05:00
Steve Yegge
3f3bc326a1 bd sync: 2025-12-22 15:48:42 2025-12-22 15:50:50 -08:00
Steve Yegge
07e941a65d bd sync: 2025-12-22 15:40:07 2025-12-22 15:50:50 -08:00