Commit Graph

2076 Commits

Author SHA1 Message Date
Steve Yegge
b8db5ab6fc fix(test): Complete rootCtx initialization fix for all hanging tests (issue #355)
Problem:
- TestFallbackToDirectModeEnablesFlush hung with database deadlock
- TestIdempotentImportNoTimestampChurn and TestImportMultipleUnchangedIssues also hung
- All three tests call flushToJSONL() or autoImportIfNewer() which require rootCtx

Solution:
Applied the same rootCtx initialization pattern from v0.24.1 (commit 822baa0)
to the remaining hanging tests:
- TestFallbackToDirectModeEnablesFlush in direct_mode_test.go
- TestIdempotentImportNoTimestampChurn in import_idempotent_test.go
- TestImportMultipleUnchangedIssues in import_idempotent_test.go

Results:
- Before: Tests hung for 5+ minutes with database deadlock
- After: All tests pass in ~0.1s each

Fixes #355

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 23:09:47 -08:00
Steve Yegge
89aa83a8d9 docs: Add v0.24.1 changelog entry 2025-11-21 22:13:00 -08:00
Steve Yegge
7dc8c15acb chore: Bump version to 0.24.1 2025-11-21 22:06:07 -08:00
Steve Yegge
d6959d8f8c bd sync: 2025-11-21 22:49:21 2025-11-21 22:49:21 -05:00
Steve Yegge
caf89c7899 bd sync: 2025-11-21 22:48:49 2025-11-21 22:48:49 -05:00
Steve Yegge
787fb4e56f feat: Add date and priority filters to bd search (bd-au0.5)
Adds missing date range and priority filtering to bd search for feature
parity with bd list. Part of command standardization epic (bd-au0).

Changes:
- Add date range flags: --created-after/before, --updated-after/before,
  --closed-after/before
- Add priority range flags: --priority-min, --priority-max
- Support multiple date formats (RFC3339, YYYY-MM-DD, etc.)
- Apply filters in both direct mode and daemon RPC mode
- Add comprehensive tests for new filters

Examples:
  bd search "security" --priority-min 0 --priority-max 2
  bd search "bug" --created-after 2025-01-01
  bd search "refactor" --updated-after 2025-01-01 --priority-min 1

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 22:46:12 -05:00
Steve Yegge
0040e8029b feat: Add test infrastructure with automatic skip list
Overview: Added comprehensive test infrastructure to handle the large
test suite (41K LOC, 313 tests in cmd/bd alone) with automatic skipping
of known broken tests.

Changes:
- .test-skip: List of broken tests to skip (with GH issue references)
- scripts/test.sh: Smart test runner that auto-skips broken tests
- docs/TESTING.md: Comprehensive testing guide
- .claude/test-strategy.md: Quick reference for AI agents
- Updated Makefile to use new test script

Known Issues Filed:
- GH #355: TestFallbackToDirectModeEnablesFlush (database deadlock)
- GH #356: TestFindJSONLPathDefault (wrong JSONL filename)

Performance: 3min total (180s compilation, 3.8s execution)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 22:43:04 -05:00
Steve Yegge
3065db261e feat: Add label operations to bd update command
Implements bd-au0.2, completing all P0 tasks in the command standardization epic.

Changes:
- Add --add-label, --remove-label, --set-labels flags to bd update
- Support multiple labels via repeatable flags
- Implement in both daemon and direct modes
- Add comprehensive tests for all label operations

The bd update command now supports:
  bd update <id> --add-label <label>       # Add one or more labels
  bd update <id> --remove-label <label>    # Remove one or more labels
  bd update <id> --set-labels <labels>     # Replace all labels

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 22:17:26 -05:00
Steve Yegge
ae4cd00e52 bd sync: 2025-11-21 21:59:27 2025-11-21 21:59:27 -05:00
Steve Yegge
99e3d21f35 Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-21 21:57:26 -05:00
Steve Yegge
2e2b8d7c2c feat: Accept both integer and P-format for priority flags in bd list
Implements bd-au0.4: Standardize priority flag parsing across all commands.

Changes:
- Use registerPriorityFlag() for main priority flag (was IntP)
- Change priority-min/max from Int to String flags
- Add validation import and use ValidatePriority() for all priority parsing
- Update both direct mode and daemon RPC code paths

Now supports both formats consistently:
- Numeric: --priority 0, --priority-min 1, --priority-max 2
- P-format: --priority P0, --priority-min P1, --priority-max P2

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 21:57:23 -05:00
Steve Yegge
fa727c7d73 refactor: Delete 7 redundant tests from main_test.go (3x speedup)
Problem: main_test.go was testing deprecated legacy path after FlushManager
refactoring (bd-52), duplicating coverage from flush_manager_test.go.

Solution: Delete redundant tests, keep only unique integration tests.

Changes:
- Deleted 7 tests (407 lines) covered by flush_manager_test.go:
  * TestAutoFlushDirtyMarking → TestFlushManagerMarkDirtyTriggersFlush
  * TestAutoFlushDisabled → TestFlushManagerDisabledDoesNotFlush
  * TestAutoFlushDebounce (already skipped, obsolete)
  * TestAutoFlushClearState (tested implicitly in export/sync)
  * TestAutoFlushConcurrency → TestFlushManagerConcurrentMarkDirty
  * TestAutoFlushStoreInactive → TestPerformFlushStoreInactive
  * TestAutoFlushErrorHandling → TestPerformFlushErrorHandling

- Kept 2 unique integration tests:
  * TestAutoFlushOnExit (tests PersistentPostRun)
  * TestAutoFlushJSONLContent (tests actual JSONL output)

- Updated clearAutoFlushState() to no-op when FlushManager exists

Results:
- Before: 18 tests, 1079 lines, ~15-20s
- After: 11 tests, 672 lines, ~5-7s
- Speedup: ~3x faster
- All tests passing 

Files:
- cmd/bd/main_test.go: Deleted 7 tests, removed unused imports
- cmd/bd/autoflush.go: Updated clearAutoFlushState()
- docs/MAIN_TEST_REFACTOR_NOTES.md: Documented solution
- docs/MAIN_TEST_CLEANUP_PLAN.md: Created detailed plan

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 21:29:43 -05:00
Steve Yegge
76ebb2a7b9 chore: Update bd JSONL (todo list from GH #298 work) 2025-11-21 20:52:54 -05:00
Steve Yegge
605fff151e feat: Add GitHub Copilot support with .github/copilot-instructions.md
Addresses GH #298 - GitHub Copilot inconsistently interpreting AGENTS.md

Changes:
- Create .github/copilot-instructions.md (132 lines, Copilot-optimized)
- Update AGENTS.md with prominent Copilot callout
- Enhance bd onboard command to generate copilot-instructions.md

Architecture: Two-file approach for different AI agents
- AGENTS.md (626 lines): Comprehensive guide for all AI agents
- .github/copilot-instructions.md (132 lines): Concise, auto-loaded for Copilot

Note: Untested with GitHub Copilot yet. Feedback from Copilot users welcome!

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-21 20:52:18 -05:00
Steve Yegge
6e702d3ecd Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-21 20:40:23 -05:00
Steve Yegge
ddd209e26a fix: Correct git merge driver placeholders from %L/%R to %A/%B
Git merge drivers only support three placeholders:
- %O (ancestor/base)
- %A (current version)
- %B (other branch's version)

The code was incorrectly using %L and %R, which don't exist in git,
causing them to be passed through literally and breaking JSONL merges.

Changes:
- Fixed merge driver config in init.go, merge.go, README.md, docs
- Added detection in bd doctor with clear error messages
- Added auto-fix in bd doctor --fix
- Added proactive warning in bd sync before git pull
- Added reactive error detection after merge failures
- Updated all tests to use correct placeholders

Now users get helpful guidance at every step:
1. bd doctor detects the issue
2. bd doctor --fix auto-corrects it
3. bd sync warns before pulling if misconfigured
4. Error messages suggest bd doctor --fix when merge fails

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 20:40:18 -05:00
Steve Yegge
8efab3df87 chore: Move design/audit docs from cmd/bd to docs/
Relocate documentation files to centralize all .md files in docs/ directory
(except those with historical precedent in specific locations like commands/,
examples/, integrations/, etc.).

Files moved:
- cmd/bd/doctor/claude.md -> docs/CLAUDE_INTEGRATION.md
- cmd/bd/MAIN_TEST_REFACTOR_NOTES.md -> docs/MAIN_TEST_REFACTOR_NOTES.md
- cmd/bd/TEST_SUITE_AUDIT.md -> docs/TEST_SUITE_AUDIT.md

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 20:31:47 -05:00
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
bb5a480445 feat: Add --body flag as alias for --description
Adds --body as a hidden alias for --description in create/update commands,
following GitHub CLI convention for better agent ergonomics.

The --body flag:
- Works alongside existing --description and -d flags
- Hidden from help output to avoid clutter
- Validates conflicts when both flags used with different values
- Available in both 'bd create' and 'bd update' commands

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 20:08:55 -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
821880419a Merge branch 'main' of https://github.com/steveyegge/beads
# Conflicts:
#	.beads/beads.jsonl
2025-11-21 19:42:35 -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
58fe00057c feat: Complete GH #353 follow-up phases (bd-9nw, bd-u3t, bd-e0o)
Implements all three follow-up phases for sandbox environment support:

**Phase 1 (bd-9nw): Documentation** 
- Comprehensive sandbox troubleshooting section in TROUBLESHOOTING.md
  - Detailed symptoms, root causes, and escape hatches
  - Step-by-step troubleshooting workflow
  - Comparison table for --sandbox, --force, and --allow-stale flags
- Global flags section added to CLI_REFERENCE.md
  - Documents --sandbox, --allow-stale, and --force flags
  - Usage examples and when to use each flag
- GitHub issue #353 comment with immediate workarounds

**Phase 2 (bd-u3t): Sandbox Auto-Detection** 
- Automatic sandbox detection using syscall.Kill permission checks
  - cmd/bd/sandbox_unix.go: Unix/Linux/macOS implementation
  - cmd/bd/sandbox_windows.go: Windows stub (conservative approach)
  - cmd/bd/sandbox_test.go: Comprehensive test coverage
- Auto-enables sandbox mode when detected
  - Shows: "ℹ️  Sandbox detected, using direct mode"
  - Respects explicit --sandbox or --no-daemon flags
- Updated documentation to reflect auto-detection (v0.21.1+)

**Phase 3 (bd-e0o): Enhanced Daemon Robustness** 
- Permission-aware process checks in cmd/bd/daemon_unix.go
  - Correctly handles EPERM (operation not permitted) from syscall.Kill
  - Treats EPERM as "process exists but not signable" = running
  - Prevents false negatives in sandboxed environments
- Metadata health check in cmd/bd/daemon_event_loop.go
  - Periodic verification that metadata is accessible
  - Helps detect external import operations (bd import --force)
  - Non-fatal logging for diagnostics
- Comprehensive test suite in cmd/bd/daemon_unix_test.go
  - Self-check, init process, nonexistent process, parent process tests

**Impact:**
- Codex users: No manual intervention needed, auto-detected
- Stuck states: Three escape hatches (--sandbox, --force, --allow-stale)
- Daemon robustness: Handles permission-restricted environments gracefully
- All three follow-up issues (bd-9nw, bd-u3t, bd-e0o) closed

**Files changed:**
- cmd/bd/main.go: Auto-detection logic in PersistentPreRun
- cmd/bd/sandbox_unix.go: Unix sandbox detection (new)
- cmd/bd/sandbox_windows.go: Windows sandbox detection stub (new)
- cmd/bd/sandbox_test.go: Sandbox detection tests (new)
- cmd/bd/daemon_unix.go: Permission-aware isProcessRunning()
- cmd/bd/daemon_unix_test.go: Process check tests (new)
- cmd/bd/daemon_event_loop.go: Metadata health check
- docs/TROUBLESHOOTING.md: Comprehensive sandbox section
- docs/CLI_REFERENCE.md: Global flags documentation

Closes bd-9nw, bd-u3t, bd-e0o
Related: GH #353

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 19:32:45 -05:00
Steve Yegge
601469eb90 Merge branch 'main' of https://github.com/steveyegge/beads 2025-11-21 19:31:59 -05:00
Steve Yegge
88c7bb6e4c bd sync: 2025-11-21 19:31:56 2025-11-21 19:31:56 -05:00
Steve Yegge
74f384444b test: Add security and error handling tests for lint warnings
Added comprehensive tests to address gosec and errcheck linter warnings:

1. bd-yxy (P0): Command injection prevention tests for git rm in merge command
   - Added merge_security_test.go with tests for shell metacharacters
   - Verified exec.Command safely passes arguments (no shell interpretation)
   - Added #nosec G204 comment explaining why code is safe

2. bd-nbc (P1): Security tests for file path validation in clean command
   - Added clean_security_test.go with path traversal tests
   - Verified filepath.Join safely constructs paths within .beads directory
   - Added #nosec G304 comment documenting safety guarantees

3. bd-lln (P2): Tests for performFlush error handling in FlushManager
   - Added tests documenting that performFlush intentionally returns nil
   - Errors are handled internally by flushToJSONLWithState
   - Tests verify graceful degradation when store is inactive

4. bd-gra (P2): Error handling test for cmd.Help() in search command
   - Added search_test.go documenting Help() error handling
   - Help() errors intentionally ignored (already in error path, will exit anyway)
   - Added #nosec G104 comment explaining rationale

All new tests pass. The linter warnings are false positives or intentional
design decisions, now documented with tests and #nosec comments.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 19:30:48 -05:00
Steve Yegge
d7f4189e3e feat: Add 'bd count' command for counting and grouping issues
Implements a new 'bd count' command that provides efficient issue counting
with filtering and grouping capabilities.

Features:
- Basic count: Returns total count of issues matching filters
- All filtering options from 'bd list' (status, priority, type, assignee, labels, dates, etc.)
- Grouping via --by-* flags: status, priority, type, assignee, label
- JSON output support for both simple and grouped counts
- Both daemon and direct mode support

Implementation:
- Added OpCount operation and CountArgs to RPC protocol
- Added Count() method to RPC client
- Implemented handleCount() server-side handler with optimized bulk label fetching
- Created cmd/bd/count.go with full CLI implementation

Performance optimization:
- Pre-fetches all labels in a single query when using --by-label to avoid N+1 queries

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 19:21:05 -05:00
Steve Yegge
897e952ac3 finished implementing these old docs 2025-11-21 19:19:24 -05:00
Steve Yegge
68e38816fc docs: Make 'land the plane' push mandatory and emphatic
CRITICAL FIX: Agents were stopping before git push, saying 'ready to
push when you are!' which breaks multi-agent coordination workflows.

Changes:
- Make push MANDATORY in landing workflow
- Add emphatic warnings: NEVER stop before push succeeds
- Explicitly state 'ready to push' is a FAILURE
- Explain multi-agent coordination impact
- Add verification requirements

This should prevent agents from leaving work unpushed.
2025-11-21 19:11:43 -05:00
Steve Yegge
65ba2c9a19 feat: Add issue IDs to TODO comments
Updated TODO comments with proper beads issue IDs:
- bd-hdt: Implement auto-merge functionality
- bd-gqo: Implement daemon health checks
- bd-r46: Support --reason flag in daemon mode for reopen

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 19:01:42 -05:00
Steve Yegge
cc7b341adb Merge branch 'main' of https://github.com/steveyegge/beads
# Conflicts:
#	.beads/beads.jsonl
2025-11-21 19:01:38 -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
ad4d6dc147 docs: Remove obsolete design and analysis documents
Remove 5 obsolete documentation files (2,847 lines, 20% reduction):

Removed files:
- HASH_ID_DESIGN.md: Design doc for hash IDs (implemented in v0.20+, bd-166)
- contributor-workflow-analysis.md: Design analysis (superseded by MULTI_REPO_*.md)
- vc-feedback-on-multi-repo.md: Feedback on design (now implemented)
- import-bug-analysis-bd-3xq.md: Bug analysis for specific issue (likely fixed)
- TEST_OPTIMIZATION.md: One-time optimization doc (completed Nov 2025)

All removed files were historical design/analysis documents for features
that are now implemented and documented elsewhere.

Retained files:
- MULTI_REPO_HYDRATION.md: Referenced as internals documentation
- ROUTING.md: Active user-facing feature documentation
- EXCLUSIVE_LOCK.md: Integration documentation for external tools
- ADAPTIVE_IDS.md: Referenced by CONFIG.md
- COLLISION_MATH.md: Referenced by ADAPTIVE_IDS.md and CONFIG.md

Total documentation reduced from 14,043 to 11,196 lines.
2025-11-21 19:00:22 -05:00
Steve Yegge
c2b9f5d358 Merge branch 'main' of https://github.com/steveyegge/beads
# Conflicts:
#	.beads/beads.jsonl
2025-11-21 18:56:03 -05:00
Steve Yegge
b3e76ff1f6 feat: Add sandbox escape hatches for daemon lock issues (GH #353 Phase 1)
Implements three quick fixes for users stuck in sandboxed environments
(e.g., Codex) where daemon cannot be stopped:

1. **--force flag for bd import**
   - Forces metadata update even when DB is synced with JSONL
   - Fixes stuck state caused by stale daemon cache
   - Shows: "Metadata updated (database already in sync with JSONL)"

2. **--allow-stale global flag**
   - Emergency escape hatch to bypass staleness check
   - Shows warning: "⚠️  Staleness check skipped (--allow-stale)"
   - Allows operations on potentially stale data

3. **Improved error message**
   - Added sandbox-specific guidance to staleness error
   - Suggests --sandbox, --force, and --allow-stale flags
   - Provides clear fix steps for different scenarios

Also fixed:
- Removed unused import in cmd/bd/duplicates_test.go

Follow-up work filed:
- bd-u3t: Phase 2 - Sandbox auto-detection
- bd-e0o: Phase 3 - Daemon robustness enhancements
- bd-9nw: Documentation updates

Fixes #353 (Phase 1)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 18:53:34 -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
2101b2543f Merge branch 'main' of https://github.com/steveyegge/beads
# Conflicts:
#	cmd/bd/duplicates_test.go
2025-11-21 16:15:18 -05:00
Steve Yegge
e38c0a58aa test: Refactor duplicates_test.go to use shared DB pattern (P2)
METRICS:
- Tests: 5 tests
- DB setups removed: 1 → 1 shared
- Tests needing DB: 1/5
- Savings: setupTestDB() → newTestStore()

DETAILS:
- TestFindDuplicateGroups: Pure in-memory logic (no DB)
- TestChooseMergeTarget: Pure in-memory logic (no DB)
- TestCountReferences: Pure in-memory logic (no DB)
- TestDuplicateGroupsWithDifferentStatuses: Pure in-memory (no DB)
- TestDuplicatesIntegration: Uses shared DB (was: setupTestDB)

Also fixed: Removed hardcoded IDs, let DB assign them.
All 5 tests pass!

🤖 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
b57ae7981f test: Refactor epic_test.go to use shared DB pattern (P2)
METRICS:
- Tests: 3 tests
- DB setups removed: 2 → 1 shared
- Tests needing DB: 2/3
- Savings: ~1 DB setup eliminated

DETAILS:
- TestEpicCommand: Uses shared DB (was: dedicated setup)
- TestEpicCommandInit: No DB needed (command structure test)
- TestEpicEligibleForClose: Uses shared DB (was: dedicated setup)

Pattern: newTestStore(t, testDB) replaces per-test DB setup.
All 3 tests pass with optimized 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
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
227e76b215 test: Refactor Phase 2 test files to use shared DB pattern (bd-1rh)
Refactored 3 smaller test files for test suite optimization:

FILES ANALYZED:
- validate_test.go (9 tests): NO DB needed - pure validation logic
- epic_test.go (3 tests): 2 DB setups → 1 shared pattern
- duplicates_test.go (5 tests): 1 old setupTestDB → newTestStore

CHANGES:
epic_test.go:
- Replaced 2× manual sqlite.New() with newTestStore()
- Removed duplicate SetConfig calls
- Removed manual Close/defer (handled by helper)
- -40 lines, +6 lines = net -34 lines

duplicates_test.go:
- Replaced old setupTestDB pattern with newTestStore
- Updated test data: bd-1/2/3 → test-1/2/3 (matches prefix)
- Added filepath import
- Removed cleanup() function pattern
- Net changes: proper shared pattern adoption

METRICS:
- Total files changed: 2/3 (validate_test.go needs no DB!)
- DB setups eliminated: 3 → 1 (epic: 2→1, duplicates: 1→0+shared)
- Lines saved: 30 net reduction
- Tests passing: 13/13 ✓

validate_test.go required NO changes - all tests are pure functions
with in-memory data. Even git conflict tests use temp files, not DB.

Part of Phase 2/3 test suite optimization.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 16:14:27 -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