Commit Graph

1146 Commits

Author SHA1 Message Date
Steve Yegge
ce433bb2e8 Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-21 20:26:42 -05:00
Steve Yegge
c8bf6a6590 bd sync: 2025-11-21 20:22:28 2025-11-21 20:22:28 -05:00
Steve Yegge
364cedee5d bug: File bd-7yg for merge driver placeholder issue
Documents critical bug affecting all users where git merge driver
uses invalid %L/%R placeholders instead of standard %A/%B.

Discovered while resolving merge conflict - automatic JSONL merge
fails with 'open 7: no such file or directory' error.
2025-11-21 19:52:18 -05:00
Steve Yegge
5ae76d24d4 chore: Close 4 test coverage issues (bd-yxy, bd-nbc, bd-lln, bd-gra)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 19:33:12 -05:00
Steve Yegge
3f17627a39 test: Mark TestAutoFlushDebounce as obsolete
Debouncing functionality has been refactored from module-level variables
to the FlushManager, which is thoroughly tested in flush_manager_test.go.

The TestAutoFlushDebounce test referenced old variables (flushDebounce, etc.)
that no longer exist in the codebase. Rather than rewriting it to test the old
auto-flush code paths, we skip it and rely on the comprehensive FlushManager tests.

Fixes + Opts completed from MAIN_TEST_OPTIMIZATION_PLAN.md:
-  Fix 1: rootCtx initialization (already done)
-  Fix 2: Reduced sleep durations (already done)
-  Opt 3: Fixed TestAutoFlushDebounce (marked obsolete)

All TestAuto* tests now pass in 1.9s.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 19:00:44 -05:00
Steve Yegge
822baa0bc9 fix(test): Fix hanging tests by initializing rootCtx (bd-n25)
Problem:
- 10 tests in main_test.go were hanging indefinitely
- Tests calling flushToJSONL() or autoImportIfNewer() would timeout
- Root cause: rootCtx was nil in test environment

Solution:
1. Initialize rootCtx with 30s timeout in all affected tests:
   - TestAutoFlushOnExit
   - TestAutoFlushJSONLContent
   - TestAutoFlushErrorHandling
   - TestAutoImportIfNewer
   - TestAutoImportDisabled
   - TestAutoImportWithUpdate
   - TestAutoImportNoUpdate
   - TestAutoImportMergeConflict
   - TestAutoImportConflictMarkerFalsePositive
   - TestAutoImportClosedAtInvariant

2. Reduce sleep durations by 10x (200ms→20ms, 100ms→10ms)

3. Fix JSONL path issue in TestAutoFlushJSONLContent

Results:
- Before: Tests hung indefinitely (∞)
- After: All 16 tests complete in ~1-2 seconds
- 15 passing, 1 skipped (TestAutoFlushDebounce needs config fix)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 18:47:38 -05:00
Steve Yegge
6f3b0e7c99 doc: Document main_test.go refactoring analysis (bd-1rh)
Analysis shows main_test.go is NOT a good candidate for shared DB pattern
due to global state manipulation and integration test characteristics.

Changes:
- Added MAIN_TEST_REFACTOR_NOTES.md documenting findings
- Fixed unused import in duplicates_test.go (from recent pull)

Key findings:
- 18 tests with 14 newTestStore() calls
- Tests manipulate global state (autoFlushEnabled, isDirty, etc.)
- Tests simulate workflows (flush, import) not just CRUD
- Shared DB causes deadlocks between flush ops and cleanup
- Integration tests need process-level isolation

Recommendation: Leave as-is or use Option 2 (grouped tests without
shared DB). Focus P2 efforts on integrity_test.go instead.

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 18:00:23 -05:00
Steve Yegge
8ac10a28f2 Update bd JSONL
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:52:36 -05:00
Steve Yegge
e16265515a ran bd cleanup 2025-11-21 15:12:22 -05:00
Steve Yegge
1c91c65d69 bd sync: 2025-11-21 15:11:55 2025-11-21 15:11:55 -05:00
Steve Yegge
bdc1487f48 Close bd-ar2, bd-dvd, and bd-ymj: Complete code review follow-up work
Closes three tickets related to GitHub #334 and #278:

- bd-dvd: Parent resurrection fix (GetNextChildID now resurrects parents)
- bd-ymj: Export metadata fix (prevents false JSONL changed errors)
- bd-ar2: Code review epic with 12 subtasks (all completed)

All fixes implemented in commit 4c5f99c and follow-up improvements.
Updated GH #334 with fix details and marked as triaged.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:10:32 -05:00
Steve Yegge
032e6a72d2 bd sync: 2025-11-21 14:40:35 2025-11-21 14:40:35 -05:00
Steve Yegge
cd8cb8b86a Fix bd-ar2 code review issues: metadata tracking and multi-repo support
This commit addresses critical code review findings from bd-dvd and bd-ymj fixes:

## Completed Tasks

### bd-ar2.1: Extract duplicated metadata update code
- Created `updateExportMetadata()` helper function
- Eliminated 22-line duplication between createExportFunc and createSyncFunc
- Single source of truth for metadata updates

### bd-ar2.2: Add multi-repo support to export metadata updates
- Added per-repo metadata key tracking with keySuffix parameter
- Both export and sync functions now update metadata for all repos

### bd-ar2.3: Fix tests to use actual daemon functions
- TestExportUpdatesMetadata now calls updateExportMetadata() directly
- Added TestUpdateExportMetadataMultiRepo() for multi-repo testing
- Fixed export_mtime_test.go tests to call updateExportMetadata()

### bd-ar2.9: Fix variable shadowing in GetNextChildID
- Changed `err` to `resurrectErr` to avoid shadowing
- Improves code clarity and passes linter checks

### bd-ar2.10: Fix hasJSONLChanged to support per-repo keys
- Updated hasJSONLChanged() to accept keySuffix parameter
- Reads metadata with correct per-repo keys
- All callers updated (validatePreExport, daemon import, sync command)

### bd-ar2.11: Use stable repo identifiers instead of paths
- Added getRepoKeyForPath() helper function
- Uses stable identifiers like ".", "../frontend" instead of absolute paths
- Metadata keys now portable across machines and clones
- Prevents orphaned metadata when repos are moved

## Files Changed
- cmd/bd/daemon_sync.go: Helper functions, metadata updates
- cmd/bd/integrity.go: hasJSONLChanged() with keySuffix support
- cmd/bd/sync.go: Updated to use getRepoKeyForPath()
- cmd/bd/*_test.go: Tests updated for new signatures
- internal/storage/sqlite/hash_ids.go: Fixed variable shadowing

## Testing
All export, sync, and integrity tests pass.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 11:28:25 -05:00
Steve Yegge
ff2a2250f3 Close bd-9f86-baseline-test: test compilation errors fixed 2025-11-21 11:04:34 -05:00
Steve Yegge
1dd307159d bd sync: 2025-11-21 10:29:36 2025-11-21 10:29:36 -05:00
Steve Yegge
4c5f99c5bd Fix bd-dvd and bd-ymj: Parent resurrection and export metadata
Bug 1 (bd-dvd): GetNextChildID now attempts parent resurrection from JSONL
before failing. Added TryResurrectParent call to match CreateIssue behavior.

Bug 2 (bd-ymj): Export now updates last_import_hash metadata to prevent
'JSONL content has changed' errors on subsequent exports.

Files changed:
- internal/storage/sqlite/hash_ids.go: Add resurrection attempt
- cmd/bd/daemon_sync.go: Add metadata updates after export
- Tests added for both fixes
- Fixed pre-existing bug in integrity_content_test.go

Follow-up work tracked in epic bd-ar2 (9 issues for improvements).

Fixes GH #334
2025-11-21 10:29:30 -05:00
Steve Yegge
1806183d5f feat: Add bd search command for efficient text queries (#347)
Adds a new `bd search` command optimized for quick text searches,
addressing the issue where Claude using MCP bd list consumes 30k tokens.

Features:
- Searches across title, description, and ID with OR logic
- Default limit of 50 results (vs unlimited for bd list)
- Supports key filters: --status, --assignee, --type, --label
- Works in both daemon and direct modes
- Provides --json and --long output formats

Examples:
  bd search "performance" --status open
  bd search "database" --label backend --limit 10
  bd search "bd-5q"  # Search by partial ID

This provides a more efficient alternative to bd list when users
just want to find issues quickly without loading all results.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 22:44:19 -05:00
Steve Yegge
81c741ba05 bd sync: apply DB changes after import 2025-11-20 22:04:22 -05:00
Steve Yegge
a630f9fd62 Update bd JSONL 2025-11-20 22:02:59 -05:00
Steve Yegge
e28e3ea5f1 Close bd-khnb: Auto-import resurrection bug fixed
The critical bug where git operations could resurrect deleted issues
has been resolved with content-based staleness detection.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 22:00:33 -05:00
Steve Yegge
91c684cdbe Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-20 21:54:12 -05:00
Steve Yegge
a17e4af725 Fix context propagation lifecycle bugs
Critical fixes to context propagation implementation (bd-rtp, bd-yb8, bd-2o2):

1. Fix rootCtx lifecycle in main.go:
   - Removed premature defer rootCancel() from PersistentPreRun (line 132)
   - Added proper cleanup in PersistentPostRun (lines 544-547)
   - Context now properly spans from setup through command execution to cleanup

2. Fix test context contamination in cli_fast_test.go:
   - Reset rootCtx and rootCancel to nil in test cleanup (lines 139-140)
   - Prevents cancelled contexts from affecting subsequent tests

3. Fix export tests missing context in export_test.go:
   - Added rootCtx initialization in 5 export test subtests
   - Tests now properly set up context before calling exportCmd.Run()

These fixes ensure:
- Signal-aware contexts work correctly for graceful cancellation
- Ctrl+C properly cancels import/export operations
- Database integrity is maintained after cancellation
- All cancellation tests pass (TestImportCancellation, TestExportCommand)

Tested:
- go build ./cmd/bd ✓
- go test ./cmd/bd -run TestImportCancellation ✓
- go test ./cmd/bd -run TestExportCommand ✓

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:54:11 -05:00
Steve Yegge
4b6ddb6aeb generated README.md 2025-11-20 21:54:08 -05:00
Steve Yegge
be37a13ceb bd sync: 2025-11-20 21:47:55 2025-11-20 21:47:55 -05:00
Steve Yegge
0444271cc3 bd sync: Update beads.jsonl after rebase
Merge metadata updates from remote.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:38:11 -05:00
Steve Yegge
a42e84ca9c Add issues bd-gdn, bd-5xt, bd-i00 for future improvements 2025-11-20 21:24:39 -05:00
Steve Yegge
a9b2f9f553 Fix race condition in auto-flush mechanism (issue bd-52)
Critical fixes to code review findings:

1. Remove global state access from flushToJSONLWithState
   - FlushManager now has true single ownership of flush state
   - No more race conditions from concurrent global state access
   - flushToJSONLWithState trusts only the flushState parameter
   - Legacy wrapper handles success detection via failure count

2. Fix shutdown timeout data loss risk
   - Increased timeout from 5s → 30s to prevent data loss
   - Added detailed comments explaining the timeout rationale
   - Better error message indicates potential data loss scenario

Implementation details:
- New FlushManager uses event-driven single-owner pattern
- Channels eliminate shared mutable state (markDirtyCh, flushNowCh, etc.)
- Comprehensive race detector tests verify concurrency safety
- Backward compatible with existing tests via legacy code path
- ARCHITECTURE.md documents design principles and guarantees

Test results:
- All race detector tests pass (TestFlushManager*)
- Legacy API compatibility verified (TestMarkDirtyAndScheduleFlush*)
- No race conditions detected under concurrent load

Future improvements tracked as beads:
- bd-gdn: Add functional tests for flush correctness verification
- bd-5xt: Log errors from timer-triggered flushes
- bd-i00: Convert magic numbers to named constants

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:24:31 -05:00
Steve Yegge
4a566edaa6 bd sync: Update issue metadata
- Update comment IDs for bd-1h8, bd-8ql
- Add new issues bd-1pj6, bd-49kw

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:23:50 -05:00
Steve Yegge
c547733366 bd sync: 2025-11-20 20:59:31 2025-11-20 20:59:31 -05:00
Steve Yegge
7109c47c37 Track issues bd-1h8, bd-8ql, bd-ayw, bd-keb for GitHub #349 2025-11-20 20:52:04 -05:00
Steve Yegge
7b6370f3fa Delete 497 closed beads (resurrection bug cleanup)
Removed all closed beads that were resurrected by the auto-import bug
documented in bd-khnb. Database now at 46 beads (all open/active).

The resurrection happened when:
- Earlier git operation restored old JSONL with 538 issues
- bd migrate --update-repo-id triggered daemon startup
- Auto-import saw "newer" JSONL (recent mtime from git)
- Imported old data over cleaned database
- 490 previously deleted issues resurrected

This cleanup removes those resurrected closed issues.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:50:39 -05:00
Steve Yegge
b2c50bc88a Add bd-khnb: Critical bug in auto-import resurrects deleted issues
Filed bug report for critical data loss issue where bd migrate --update-repo-id
(and other operations) can trigger auto-import that resurrects deleted issues.

Root cause: Auto-import uses mtime-based staleness detection, which fails when
git operations restore old JSONL files with recent mtimes.

Impact: User deletions can be silently undone after git checkout/merge/pull.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:50:39 -05:00
Steve Yegge
f0d3d7345c Fix 'landing the plane' instructions - emphasize git push is CRITICAL
The previous instructions mentioned sync carefully but didn't emphasize that
git push is absolutely required for the plane to actually land. Multiple agents
have failed to push, leaving work uncommitted on the runway.

Changes:
- Added explicit 'git push' step with CRITICAL emphasis
- Added verification step to check 'up to date with origin/main'
- Updated example workflow to show push as mandatory step
- Added clear statement: 'The plane has NOT landed until git push completes'

The metaphor is obvious - if you don't push, the plane is still on the ground!

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:44:26 -05:00
Steve Yegge
d5239eeef9 Refactor: Extract duplicated validation logic to internal/validation
Extracted repeated priority and ID validation patterns from CLI commands
into reusable functions in internal/validation/bead.go.

Changes:
- Added ValidatePriority(): Combines parsing and error handling
- Added ValidateIDFormat(): Validates ID format and extracts prefix
- Added ValidatePrefix(): Validates prefix matching with database config
- Updated create.go and show.go to use new validation functions
- Simplified force flag logic to always call ValidatePrefix()
- Added comprehensive tests for all validation functions
- Added TODO comment for daemon mode validation enhancement

Results:
- Reduced code duplication by ~20 lines
- Centralized validation logic for easier maintenance
- Consistent error messages across all commands
- All tests passing

Fixes bd-g5p7

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:39:23 -05:00
Steve Yegge
13be84d99f Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-20 20:23:28 -05:00
Steve Yegge
3520321591 bd sync: 2025-11-20 20:22:39 2025-11-20 20:22:40 -05:00
Steve Yegge
62e39d0ec1 Delete 490 closed beads to streamline database
Removed all closed beads (490 total, 497 including cascade deletions):
- Completed feature implementations
- Fixed bugs and resolved issues
- Test issues from development
- Deprecated/removed features
- Refactoring tasks

Database reduced from 538 to 48 beads (46 open, 2 other states)

All deleted beads preserved in git history for reference.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:22:07 -05:00
Steve Yegge
e8355c26f0 Add 'bd clean' command to remove temporary merge artifacts
This command cleans up temporary files created during git merges by reading
patterns directly from .beads/.gitignore (Merge artifacts section).

Files removed:
- 3-way merge snapshots (beads.base.jsonl, beads.left.jsonl, beads.right.jsonl)
- Merge metadata (*.meta.json)
- Git merge driver temp files (*.json[0-9], *.jsonl[0-9])

Files preserved:
- beads.jsonl (source of truth)
- beads.db (SQLite database)
- metadata.json, config.yaml
- All daemon files

Usage:
  bd clean           # Clean up temporary files
  bd clean --dry-run # Preview what would be deleted

Implementation:
- Reads patterns from .beads/.gitignore instead of hardcoding them
- No --force flag needed - just runs by default
- Only cleans truly temporary merge artifacts, never the database

Also:
- Restored beads.jsonl to 538 issues from commit 6cd3a32
- Set issue-prefix to "bd" in config.yaml

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:21:37 -05:00
Steve Yegge
6cd3a32329 Restore beads.jsonl to 538 issues from d99222d 2025-11-20 19:59:19 -05:00
Steve Yegge
8d52f1deb5 removed zombie backup 2025-11-20 19:51:04 -05:00
Steve Yegge
d99222d895 Restore stable state: revert to beads.jsonl with 538 issues
- Revert migration to issues.jsonl (was causing data corruption)
- Backup issues.jsonl for reference
- Database and beads.jsonl now in sync (538 issues)
- Clean slate for stable operations
2025-11-20 19:48:26 -05:00
Steve Yegge
764886b3e7 bd sync: 2025-11-20 19:38:13 2025-11-20 19:38:13 -05:00
Steve Yegge
f01326832f Enhance bd doctor with bd prime migration recommendations (bd-0fvq)
Add comprehensive detection and migration guidance for old beads integration
patterns. This helps users adopt the more efficient bd prime approach.

Changes:
- Enhanced CheckLegacyBeadsSlashCommands with detailed migration steps
  and token efficiency benefits (99% reduction: ~10.5k → ~50 tokens)
- Added CheckAgentDocumentation to detect missing AGENTS.md/CLAUDE.md
  and suggest bd onboard or bd setup claude
- Enhanced CheckClaude to recommend bd prime hooks for MCP-only setups
  with clear token efficiency messaging
- Added comprehensive tests for all new checks

bd doctor now detects:
1. Old slash command patterns (/beads:*) and recommends bd prime hooks
2. Missing agent documentation and suggests creating it
3. MCP-only setups without hooks and shows token savings potential
4. Provides clear migration paths and benefits for all scenarios

Token efficiency messaging:
- MCP mode: ~50 tokens vs ~10.5k for full scan (99% reduction)
- CLI mode: ~1-2k tokens with automatic context recovery
- Hooks auto-refresh context on SessionStart and PreCompact

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:36:48 -05:00
Steve Yegge
1458519536 Merge remote-tracking branch 'origin/main'
Resolved JSONL conflicts using bd merge tool.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:31:16 -05:00
Steve Yegge
8b0a8faa76 Merge remote-tracking branch 'origin/main'
Resolved JSONL conflicts using bd merge tool.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:31:00 -05:00
Steve Yegge
4f481c88b1 Close bd-5qim (GetReadyWork optimization completed in 690c73f) 2025-11-20 19:30:27 -05:00
Steve Yegge
25e0ff6335 bd sync: 2025-11-20 19:29:56 2025-11-20 19:29:56 -05:00
Steve Yegge
8952254ed8 Update bd JSONL
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:29:44 -05:00
Steve Yegge
109b9d275a Close bd-g9eu (TestRoutingIntegration investigation)
Issue was already fixed in commit 8e05847. Build error was due to
accidentally deleted sqlite.go, now restored.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:24:16 -05:00
Steve Yegge
88210fe039 Clean up spurious and duplicate issues
Deleted 94 spurious test and duplicate issues:
- 39 simple test placeholders (Issue 1/2, Test issue 0/1/2, Batch/Rapid tests)
- 29 additional test issues with empty descriptions
- 3 test epic issues
- 23 duplicate issues (kept oldest instance of each)

Also cleaned up:
- 10 dependency links
- 17 labels
- 127 events

Reduced issue count from 540 to 446 issues.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 19:22:47 -05:00