Commit Graph

2034 Commits

Author SHA1 Message Date
Steve Yegge
1eac5a9b8b test: Refactor validate_test.go - remove ALL DB setup (P2)
METRICS:
- Tests: 9 tests
- DB setups removed: 0 → 0 (were already none!)
- Tests still needing DB: 0/9
- Pattern: Pure validation tests - no DB needed

DETAILS:
- TestParseChecks: Pure string parsing
- TestValidationResults*: Pure data structure tests
- TestValidateOrphanedDeps: In-memory issue validation
- TestValidateDuplicates: In-memory issue validation
- TestValidatePollution: In-memory issue validation
- TestValidateGitConflicts_*: File-only tests, simplified temp file setup

All 9 tests pass without any database setup!

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 16:14:30 -05:00
Steve Yegge
672377544b test: Refactor compact_test.go to use shared DB pattern (bd-1rh)
Part of Phase 2/3 test suite optimization.

BEFORE:
- 10 separate test functions
- Each creating its own database
- 6 tests with DB setup overhead
- Total: 10 test executions

AFTER:
- 1 TestCompactSuite with 6 shared-DB subtests
- 4 standalone tests (no DB needed)
- Single DB setup for suite
- Total: 5 test functions

IMPACT:
- Lines: -135 (-22.4%)
- DB setups: 6 → 1 (6x reduction)
- Tests passing: 10/10 ✓
- Runtime: ~0.33s

The suite consolidates all DB-dependent tests:
- DryRun: eligibility check on closed issue
- Stats: mix of eligible/ineligible issues
- RunCompactStats: tests both normal and JSON output
- CompactStatsJSON: JSON formatting path
- RunCompactSingleDryRun: single issue eligibility
- RunCompactAllDryRun: multiple issue eligibility

Standalone tests (no DB):
- TestCompactValidation: flag validation logic
- TestCompactProgressBar: progress bar formatting
- TestFormatUptime: uptime display formatting
- TestCompactInitCommand: command initialization

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 16:13:18 -05:00
Steve Yegge
351d2239d6 test: Refactor integrity_test.go to use shared DB pattern (bd-1rh P2)
CHANGES:
- Reduced from 15 DB setups to 4 shared DBs
- TestValidatePreExportSuite: 1 shared DB, 5 subtests
- TestValidatePostImport: No DB needed, kept as-is
- TestCountDBIssuesSuite: 1 shared DB, 1 subtest
- TestHasJSONLChangedSuite: 1 shared DB, 7 subtests (with unique keySuffixes)
- TestComputeJSONLHash: No DB needed, kept as-is
- TestCheckOrphanedDepsSuite: 1 shared DB, 2 subtests

PERFORMANCE:
- Before: 0.455s avg (15 DB setups)
- After: 0.373s avg (4 DB setups)
- Speedup: 1.22x (18% faster)

KEY LEARNINGS:
- Used unique keySuffix values for hasJSONLChanged subtests to avoid metadata pollution
- Metadata keys like last_import_hash are shared across subtests unless keySuffix is used
- TestValidatePostImport and TestComputeJSONLHash do not need DB at all

PATTERN:
Following create_test.go and dep_test.go pattern with shared DB setup

Part of Phase 2 test suite optimization (bd-1rh follow-up)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 16:11:56 -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
0b1a86a207 test: Refactor P1 test files to use shared DB pattern (bd-1rh)
Refactored 6 high-priority test files to reduce database initializations
and improve test suite performance:

- create_test.go: Combined 11 tests into TestCreateSuite (11 DBs → 1 DB)
- dep_test.go: Combined into TestDependencySuite (4 DBs → 1 DB)
- comments_test.go: Combined into TestCommentsSuite (2 DBs → 1 DB)
- list_test.go: Split into 2 suites to avoid data pollution (2 DBs → 2 DBs)
- ready_test.go: Combined into TestReadySuite (3 DBs → 1 DB)
- stale_test.go: Kept as individual functions due to data isolation needs

Added TEST_SUITE_AUDIT.md documenting the refactoring plan, results,
and key learnings for future test development.

Results:
- P1 tests now run in 0.43 seconds
- Estimated 10-20x speedup
- All tests passing

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:51:07 -05:00
Marco Del Pin
f724b612d2 fix: Deduplicate database paths when symlinks present (#354)
Fixes a bug where FindAllDatabases() would return the same database
multiple times when symlinks were present in the directory hierarchy.

The issue occurred because the function walked up the directory tree
without resolving symlinks or checking if a database had already been
discovered. This led to confusing warnings about "multiple databases"
even when only one physical database existed.

Changes:
- Added symlink resolution using filepath.EvalSymlinks()
- Implemented deduplication using a seen map with canonical paths
- Added comprehensive tests for symlink scenarios

This ensures that each unique database is reported exactly once,
regardless of how many symlinks point to it in the directory tree.

Resolves duplicate database warnings when symlinks are present.
2025-11-21 12:22:33 -08: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
3a0446c431 Fix test compilation errors: add context.Background() to sqlite.New() calls
Updated all test files to pass context.Background() as the first parameter
to sqlite.New() calls to match the updated function signature.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 14:57:18 -05:00
Steve Yegge
c9207fce63 Close bd-ar2.8: Add edge case tests for export metadata updates
Added comprehensive tests for multi-repo export metadata handling:

1. TestExportWithMultiRepoConfigUpdatesAllMetadata (P2)
   - Verifies export with multi-repo config updates metadata for ALL JSONL files
   - Confirms each repo gets correct keySuffix in metadata keys
   - Tests full integration: getMultiRepoJSONLPaths -> getRepoKeyForPath -> updateExportMetadata
   - Validates subsequent exports succeed without "content has changed" errors

2. TestUpdateExportMetadataInvalidKeySuffix (P3)
   - Tests failure handling for invalid keySuffix containing ':' separator
   - Confirms validation logic from bd-ar2.12 works correctly

All tests pass. bd-ar2 epic nearly complete - only one P3 task remains!

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 14:57:01 -05:00
Steve Yegge
1168f661d1 fix: Add context.Background() to sqlite.New() calls in test files
Multiple test files were still using the old sqlite.New(path) signature
instead of the new sqlite.New(ctx, path) signature. This was causing
compilation failures in the test suite.

Fixed files:
- internal/importer/importer_test.go
- internal/importer/external_ref_test.go
- internal/importer/timestamp_test.go
- internal/rpc/limits_test.go
- internal/rpc/list_filters_test.go
- internal/rpc/rpc_test.go
- internal/rpc/status_test.go
- internal/syncbranch/syncbranch_test.go
2025-11-21 14:48:41 -05:00
Steve Yegge
032e6a72d2 bd sync: 2025-11-21 14:40:35 2025-11-21 14:40:35 -05:00
Steve Yegge
82902432f5 test: Tag 16 slow integration tests with build tags
Identified and tagged obviously-slow integration tests with
`//go:build integration` to exclude them from default test runs.

This is step 1 of fixing test performance. The real fix is in
bd-1rh: refactoring tests to use shared DB setup instead of
creating 279 separate databases.

Tagged files:
- cmd/bd: 8 files (CLI tests, git ops, performance benchmarks)
- internal: 8 files (integration tests, E2E tests)

Issues:
- bd-1rh: Main issue tracking test performance
- bd-c49: Audit all tests and create grouping plan (next step)
- bd-y6d: POC refactor of create_test.go

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 14:40:22 -05:00
Steve Yegge
e816e91ecb Complete bd-ar2 P2 tasks: metadata, resurrection, and testing improvements
This commit addresses the remaining P2 tasks from bd-ar2 code review follow-up:

## Completed Tasks

### bd-ar2.4: Improve parent chain resurrection
- Modified `tryResurrectParentWithConn()` to recursively resurrect ancestor chain
- When resurrecting bd-root.1.2, now also resurrects bd-root.1 if missing
- Handles deeply nested hierarchies where intermediate parents are deleted
- All resurrection tests pass including new edge cases

### bd-ar2.5: Add error handling guidance
- Documented metadata update failure strategy in `updateExportMetadata()`
- Explained trade-off: warnings vs errors (safe, prevents data loss)
- Added user-facing message: "Next export may require running 'bd import' first"
- Clarifies that worst case is requiring import before next export

### bd-ar2.6: Document transaction boundaries
- Added comprehensive documentation for atomicity trade-offs
- Explained crash scenarios and recovery (bd import)
- Documented decision to defer defensive checks (Option 4) until needed
- No code changes - current approach is acceptable for now

### bd-ar2.12: Add metadata key validation
- Added keySuffix validation in `updateExportMetadata()` and `hasJSONLChanged()`
- Prevents ':' separator in keySuffix to avoid malformed metadata keys
- Documented metadata key format in function comments
- Single-repo: "last_import_hash", multi-repo: "last_import_hash:<repo_key>"

### bd-ar2.7: Add edge case tests for GetNextChildID resurrection
- TestGetNextChildID_ResurrectParent_NotInJSONL: parent not in history
- TestGetNextChildID_ResurrectParent_NoJSONL: missing JSONL file
- TestGetNextChildID_ResurrectParent_MalformedJSONL: invalid JSON lines
- TestGetNextChildID_ResurrectParentChain: deeply nested missing parents
- All tests pass, resurrection is robust against edge cases

## Files Changed
- cmd/bd/daemon_sync.go: Metadata validation, error handling docs
- cmd/bd/integrity.go: Added strings import, keySuffix validation
- internal/storage/sqlite/hash_ids.go: Improved resurrection comments
- internal/storage/sqlite/resurrection.go: Recursive ancestor resurrection
- internal/storage/sqlite/child_id_test.go: Added 4 new edge case tests

## Testing
All export, sync, metadata, and resurrection tests pass.
Edge cases properly handled: missing JSONL, malformed JSON, deep nesting.

## Remaining Tasks
- bd-ar2.8 (P3): Additional export metadata edge case tests (deferred)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 11:40:37 -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
ff3ccdd26e rebuild Go binaries in version bump script 2025-11-21 09:45:37 -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
2ba3cd64fe docs: Add #328 fix to 0.24.0 changelog
Include the duplicate function declaration fix that was merged
after the initial changelog was prepared.
2025-11-20 22:15:47 -05:00
Steve Yegge
00840aa72f chore: Bump version to 0.24.0
Updated all component versions:
- bd CLI: 0.23.1 → 0.24.0
- Plugin: 0.23.1 → 0.24.0
- MCP server: 0.23.1 → 0.24.0
- npm package: 0.23.1 → 0.24.0
- Documentation: 0.23.1 → 0.24.0

Added comprehensive CHANGELOG.md entry for 0.24.0 with 179 commits:
- Critical bug fixes (auto-import resurrection, sync conflicts, resource leaks)
- Performance improvements (GetReadyWork optimization, N+1 query elimination)
- New features (bd doctor --fix, bd clean, auto-detection)
- Enhanced AI agent support (context propagation, error handling)
- Cross-platform improvements (Windows, macOS stability)
2025-11-20 22:15:04 -05:00
Steve Yegge
167ab6788b Fix #328: Remove duplicate computeJSONLHash declaration
The function was declared twice:
- Line 80: New version (simpler, no error wrapping)
- Line 390: Old version (with error wrapping)

This caused compilation failure in CI. Removed the old declaration at line 390.

Also fixed integrity_content_test.go to pass context.Context to sqlite.New()
as required by the updated API.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 22:06:38 -05:00
Steve Yegge
81c741ba05 bd sync: apply DB changes after import 2025-11-20 22:04:22 -05:00
Steve Yegge
db2bc8acb0 Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-20 22:04:22 -05:00
Steve Yegge
21a0656a4c Refactor AGENTS.md: Extract detailed instructions to prevent context pollution
Fixes #340

Created AGENT_INSTRUCTIONS.md to house detailed operational instructions,
reducing AGENTS.md from 963 to 626 lines (~35% reduction).

Changes:
- New AGENT_INSTRUCTIONS.md with development, testing, and release procedures
- AGENTS.md now serves as quick overview with references to detailed docs
- Updated README.md link to "Landing the Plane" section
- Fixed broken team-workflow README links

Benefits:
- Prevents context pollution when multiple tools add instructions
- Better separation: quick reference vs detailed operations
- Enables tool-specific instruction files
- Maintains all content, just reorganized

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 22:04:17 -05:00
Steve Yegge
a630f9fd62 Update bd JSONL 2025-11-20 22:02:59 -05:00
Steve Yegge
1923f3d442 Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-20 22:02:51 -05:00
Steve Yegge
f4fbf6f8c1 Remove spurious and obsolete scripts
Cleaned up scripts/ directory by removing:
- Investigation/one-off tools (collision-calculator, latency benchmarks)
- Test cleanup utilities (cleanup-test-pollution)
- Nix packaging support (update-nix-hash)
- Agent Mail server management scripts (4 scripts, will be replaced)

Retains only actively-used scripts:
- release.sh, bump-version.sh, update-homebrew.sh
- install.sh, install-hooks.sh, hooks/

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 22:02:50 -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
0020eb490c Fix bd-khnb: Prevent auto-import from resurrecting deleted issues
Replace mtime-based staleness detection with content-based (SHA256 hash) to prevent
git operations from resurrecting deleted issues.

**Problem:**
Auto-import used file modification time to detect if JSONL was "newer" than database.
Git operations (checkout, merge, pull) restore old files with recent mtimes, causing
auto-import to load stale data over current database state, resurrecting deleted issues.

**Solution:**
- Added computeJSONLHash() to compute SHA256 of JSONL content
- Added hasJSONLChanged() with two-tier check:
  1. Fast-path: Check mtime first (99% of checks are instant)
  2. Slow-path: Compute hash only if mtime changed (catches git operations)
- Store metadata: last_import_hash, last_import_mtime, last_import_time
- Updated auto-import in daemon_sync.go to use content-based check
- Updated validatePreExport to use content-based check (bd-xwo)
- Graceful degradation: metadata failures are non-fatal warnings

**Changes:**
- cmd/bd/integrity.go: Add computeJSONLHash(), hasJSONLChanged()
- cmd/bd/integrity_test.go: Add comprehensive tests for new functions
- cmd/bd/import.go: Update metadata after import
- cmd/bd/sync.go: Use hasJSONLChanged() instead of isJSONLNewer()
- cmd/bd/daemon_sync.go: Use hasJSONLChanged() in auto-import

**Testing:**
- Unit tests pass (TestHasJSONLChanged with 7 scenarios)
- Integration test passes (test_bd_khnb_fix.sh)
- Verified git resurrection scenario prevented

Fixes: bd-khnb
Related: bd-3bg, bd-xwo, bd-39o, bd-56p, bd-m8t, bd-rfj, bd-t5o

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 22:00:20 -05:00
Steve Yegge
57253f93a3 Context propagation with graceful cancellation (bd-rtp, bd-yb8, bd-2o2)
Complete implementation of signal-aware context propagation for graceful
cancellation across all commands and storage operations.

Key changes:

1. Signal-aware contexts (bd-rtp):
   - Added rootCtx/rootCancel in main.go using signal.NotifyContext()
   - Set up in PersistentPreRun, cancelled in PersistentPostRun
   - Daemon uses same pattern in runDaemonLoop()
   - Handles SIGINT/SIGTERM for graceful shutdown

2. Context propagation (bd-yb8):
   - All commands now use rootCtx instead of context.Background()
   - sqlite.New() receives context for cancellable operations
   - Database operations respect context cancellation
   - Storage layer propagates context through all queries

3. Cancellation tests (bd-2o2):
   - Added import_cancellation_test.go with comprehensive tests
   - Added export cancellation test in export_test.go
   - Tests verify database integrity after cancellation
   - All cancellation tests passing

Fixes applied during review:
   - Fixed rootCtx lifecycle (removed premature defer from PersistentPreRun)
   - Fixed test context contamination (reset rootCtx in test cleanup)
   - Fixed export tests missing context setup

Impact:
   - Pressing Ctrl+C during import/export now cancels gracefully
   - No database corruption or hanging transactions
   - Clean shutdown of all operations

Tested:
   - go build ./cmd/bd ✓
   - go test ./cmd/bd -run TestImportCancellation ✓
   - go test ./cmd/bd -run TestExportCommand ✓
   - Manual Ctrl+C testing verified

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:57:23 -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
721274b5c6 Document which files to commit after bd init --branch
Fixes #312

Users were confused about which files should be committed after running
'bd init --branch beads-metadata'. The PROTECTED_BRANCHES.md doc now
clearly explains:

1. Files to commit to protected branch (main):
   - .beads/.gitignore - Tells git what to ignore
   - .gitattributes - Merge driver configuration

2. Files automatically gitignored (do NOT commit):
   - .beads/beads.db - SQLite database (local only)
   - .beads/daemon.* - Runtime files
   - .beads/*.left/right.jsonl - Temporary merge artifacts

3. Files in sync branch (beads-metadata):
   - .beads/beads.jsonl - Issue data (committed by daemon)
   - .beads/metadata.json - Repository metadata
   - .beads/config.yaml - Configuration template

Added step-by-step instructions in Quick Start section and a "What lives
in each branch" section to How It Works.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:47:50 -05:00
Steve Yegge
445857fda6 Improve FlushManager: constants, error logging, and functional tests
Closes bd-i00, bd-5xt, bd-gdn

- Convert magic numbers to named constants for better maintainability
- Log errors from timer-triggered flushes instead of silently discarding
- Add 6 functional tests to verify FlushManager correctness:
  * MarkDirty triggers flush after debounce
  * FlushNow bypasses debouncing
  * Disabled manager doesn't flush
  * Shutdown performs final flush without waiting
  * fullExport flag handling
  * Shutdown idempotency

All tests pass with -race flag enabled.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:38:31 -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
cafcc5537b Clean up beads-mcp .gitignore
- Add .pytest_cache/ to ignored test artifacts
- Reorganize sections for clarity
- Move .coverage to testing artifacts section

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:38:01 -05:00
Steve Yegge
e7fd1dd3b6 Document files created by bd init and clarify .gitattributes should be committed
Fixes #299

Added comprehensive documentation to help new users understand what files
should be committed vs ignored after running bd init:

1. README.md:
   - New "Files Created by bd init" section
   - Clear lists of files to commit vs ignore
   - Explains purpose of .gitattributes for team collaboration

2. docs/GIT_INTEGRATION.md:
   - Enhanced .gitattributes section with IMPORTANT notice
   - Explains why it must be committed (merge driver config)
   - Lists benefits of intelligent JSONL merging

Key clarification: .gitattributes should be COMMITTED (not ignored) as it
configures git merge behavior for the entire team.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:29:20 -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
d0e70473cc Fix bd-lm2q: Use content-based comparison to prevent false-positive timestamp skew
This change fixes the issue where 'bd sync' would fail with a false-positive
"JSONL is newer than database" error after the daemon auto-exports.

Root Cause:
- Daemon exports local changes to JSONL, updating its timestamp
- bd sync sees JSONL.mtime > DB.mtime and incorrectly assumes external changes
- This blocks export even though content is identical

Solution:
- Modified isJSONLNewer() to use SHA256 content hash comparison
- Only triggers auto-import when JSONL is newer AND content differs
- Prevents false positives from daemon auto-export timestamp updates
- Maintains conservative fallback if hashes can't be computed

Changes:
- Added computeJSONLHash() and computeDBHash() helper functions
- Created isJSONLNewerWithStore() to support testing with explicit store
- Added comprehensive tests for content-based comparison logic
- All existing tests pass, including export_mtime tests

Fixes: bd-lm2q
2025-11-20 21:23:26 -05:00
Steve Yegge
79b8dbe221 Document MCP tools loading issue in Claude Code (issue #346)
Added Known Issues section to beads-mcp README documenting:
- FastMCP schema generation bug blocking MCP tools in Claude Code
- Workaround using slash commands (/beads:ready, /beads:show, etc.)
- Links to issue #346 and upstream FastMCP issue #2455
- Resolution path once upstream fix is released

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 21:00:05 -05:00
Steve Yegge
c547733366 bd sync: 2025-11-20 20:59:31 2025-11-20 20:59:31 -05:00
Steve Yegge
27c0c331ac Fix #349: Improve compact error messages, remove bogus merge suggestion, add daemon/maintenance docs
- bd-1h8: Add --no-daemon hint to compact error messages
- bd-8ql: Replace non-existent merge command with actionable guidance
- bd-ayw: Add 'When to use daemon mode' decision tree to daemon.md
- bd-keb: Add database maintenance section to QUICKSTART.md

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:58:57 -05:00
Steve Yegge
f20aec672d Add warning that MCP Agent Mail is not configured
Added prominent warning at the top of the Agent Mail section in AGENTS.md
to prevent AI agents from attempting to use mcp-agent-mail tools when the
server is not set up.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 20:55:42 -05:00