Commit Graph

422 Commits

Author SHA1 Message Date
Steve Yegge
a44ddf5cfc Fix autoimport test failures and cleanup test issues
This commit fixes all 7 failing autoimport tests by correcting a bug
in import_shared.go where the function returned early when no issue
prefix was configured, preventing any imports from happening.

Changes:
- Fix early return bug in importIssuesCore (import_shared.go:85-121)
- Now continues with import even when prefix is not configured
- Only validates prefixes when a prefix is actually set
- Delete test issues bd-50 through bd-63 (14 cleanup issues)

All tests now pass:
 TestAutoImportMultipleCollisionsRemapped
 TestAutoImportAllCollisionsRemapped
 TestAutoImportExactMatchesOnly
 TestAutoImportNewIssuesOnly
 TestAutoImportIfNewer
 TestAutoImportNoCollision
 TestAutoImportClosedAtInvariant

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-21 23:43:04 -07:00
Steve Yegge
582bd6e183 Fix bd-49: Sync counters after deletions to prevent desync
- Call SyncAllCounters() after DeleteIssue and DeleteIssues
- Change SyncAllCounters to use excluded.last_id (allows counter to decrease)
- Delete orphaned counter rows when no issues remain for a prefix
- Add comprehensive tests in counter_sync_test.go

Fixes the issue where deleting issues left counters at high values, causing
new issues to skip IDs. Now counters accurately reflect the max existing ID.

Closes bd-49

Amp-Thread-ID: https://ampcode.com/threads/T-c3bdb8b9-d67b-4de5-901e-7ea76fc9e399
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 23:33:01 -07:00
Steve Yegge
2aeaa283d4 Add database isolation canary test
- Created TestDatabaseIsolation in internal/rpc/isolation_test.go
- Single-issue test verifies test DB isolation works correctly
- Prevents repeat of stress test pollution incident
- Test passes cleanly without polluting production database

Closes bd-44

Amp-Thread-ID: https://ampcode.com/threads/T-b3e81b42-2498-45b5-9c8b-beb27f7e9550
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 22:44:45 -07:00
Steve Yegge
1bf9c13dc6 finally scrubbed the database to 48 issues after removing thousands of test issues 2025-10-21 22:38:07 -07:00
Steve Yegge
e95a1b8069 Clean up remaining 51 test issues (Version/Comment tests) 2025-10-21 22:37:11 -07:00
Steve Yegge
ed7f5a9386 Remove stress tests and clean up 1000+ polluted test issues
- Deleted internal/rpc/stress_test.go (was polluting production DB)
- Removed 1002 test issues (Agent X Issue Y, Multi-ID tests)
- Back to 99 real issues from 1101 total
- Closes bd-48
2025-10-21 22:35:05 -07:00
Steve Yegge
5aa5940147 Add multi-ID support to update, show, and label commands
Implements GitHub issue #58: Allow multiple issue IDs for batch operations.

Changes:
- update: Now accepts multiple IDs for batch status/priority updates
- show: Displays multiple issues with separators between them
- label add/remove: Apply labels to multiple issues at once
- All commands return arrays in JSON mode for consistency

Commands already supporting multiple IDs:
- close (already implemented)
- reopen (already implemented)

Updated AGENTS.md with correct multi-ID syntax examples.

Amp-Thread-ID: https://ampcode.com/threads/T-518a7593-6e16-4b08-8cf8-741992b5e3b6
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 22:18:22 -07:00
Steve Yegge
16f53c99a2 Fix stress test polluting project database
The TestStressNoUniqueConstraintViolations test was creating 1000 test
issues in the project's real database instead of its temp database.

Root cause: The RPC client automatically sets req.Cwd to os.Getwd() when
not explicitly provided. The server's getStorageForRequest() then uses
findDatabaseForCwd() to locate and open the database for that working
directory. Since the test ran from the project directory, it discovered
and used .beads/bd.db instead of the temp database.

Fix: Change working directory to the temp directory before running the
test, so the client's automatic Cwd detection points to the temp .beads/
directory instead of the project's.

Also ensures .beads subdirectory exists in temp dir for proper discovery.
2025-10-21 22:17:15 -07:00
Steve Yegge
5ab0f996b9 Clean up 1000 test issues created by stress tests 2025-10-21 22:10:30 -07:00
Steve Yegge
399fc73913 Fix labels and dependencies not saved in daemon mode (fixes #101)
The daemon's handleCreate function was ignoring createArgs.Labels and
createArgs.Dependencies, causing labels and deps specified during issue
creation to be lost when using daemon mode.

Added label and dependency processing after issue creation to match
the direct mode behavior in cmd/bd/main.go.

Fixes: #101
Amp-Thread-ID: https://ampcode.com/threads/T-cc80f8d7-264c-446e-b34f-79c4a7713b77
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 22:05:01 -07:00
Steve Yegge
473650f3ed Update issues.jsonl - close bd-49 2025-10-21 21:59:38 -07:00
Steve Yegge
d4e7af99a1 Fix bd-49: Daemon detects external DB modifications via mtime check
- Add dbMtime field to StorageCacheEntry to track DB file modification time
- Check mtime on cache hits and evict stale entries if DB changed externally
- Close and reopen storage when external modifications detected
- Fixes issue where daemon served stale data after direct DB operations

Amp-Thread-ID: https://ampcode.com/threads/T-631d5cca-0b26-47cb-b633-118b788483cf
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 21:55:23 -07:00
Steve Yegge
a8abc07e17 Sync beads database
Amp-Thread-ID: https://ampcode.com/threads/T-809fdd68-f777-4cd1-8653-b1c32a56e064
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 21:45:59 -07:00
Steve Yegge
eccd6012ec Delete 4 duplicate merge-related issues, renumber to bd-1 through bd-44 2025-10-21 21:09:54 -07:00
Steve Yegge
d582bd9cca Sync issues.jsonl after cleanup 2025-10-21 21:08:03 -07:00
Steve Yegge
2c4033ed91 Clean up issue database: delete 166 old/closed issues, keep 48, renumber bd-1 to bd-48
Amp-Thread-ID: https://ampcode.com/threads/T-fe7e9e31-d738-459b-b518-c8ebd3fd708a
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 21:01:36 -07:00
Steve Yegge
d2caceb11e Export issues from clean database 2025-10-21 20:52:51 -07:00
Steve Yegge
2426f556d4 Fix prefix validation critical bugs from oracle review
- Boundary-aware ID replacement (prevents wy-1 corrupting wy-10)
- Sort IDs by length descending before replacement
- Validate configured prefix is not empty
- Validate ID format before renaming (numeric suffix required)
- All critical issues from oracle review addressed
2025-10-21 20:49:03 -07:00
Steve Yegge
7072531843 Document stress test pollution investigation (vc-248) 2025-10-21 20:47:57 -07:00
Steve Yegge
3fda1b803b Update issue status: close bd-188 2025-10-21 20:43:54 -07:00
Steve Yegge
656ee6b65d Update issues.jsonl after bd init fix 2025-10-21 20:39:27 -07:00
Steve Yegge
7f82708b90 Fix bd init to auto-import issues from git on fresh clone
Prevents agents from creating duplicate low-numbered issues when starting
with a fresh git clone that already has issues.jsonl in git history.

Changes:
- bd init now checks for existing issues in git after DB creation
- Auto-imports with collision resolution if found
- Updates AGENTS.md to simplify onboarding (just 'bd init')

Fixes the scenario where:
1. Fresh clone has .beads/issues.jsonl in git (212 issues)
2. Agent runs bd init (creates empty DB)
3. Agent starts creating bd-1, bd-2, etc (collisions with git)

Now bd init automatically imports all issues from git on first run.

Amp-Thread-ID: https://ampcode.com/threads/T-8a41f14d-d4c3-4c50-a18b-5f112110f138
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 20:38:35 -07:00
Steve Yegge
36bd877e7c Renumber issues to compact ID space (bd-1 to bd-212) 2025-10-21 20:37:38 -07:00
Steve Yegge
2f9bac9b3e Sync issues after daemon work 2025-10-21 20:36:04 -07:00
Steve Yegge
645d268e43 Implement database handshake protocol in RPC layer
- Add ExpectedDB field to RPC Request
- Server validates client's expected DB matches daemon's DB
- Return clear error on mismatch with both paths
- Old clients (no ExpectedDB) still work with warning
- Add Path() method to storage.Storage interface
- Tests verify cross-database connections rejected

Prevents database pollution when client connects to wrong daemon.

Amp-Thread-ID: https://ampcode.com/threads/T-c4454192-39c6-4c67-96a9-675cbfc4db92
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 20:35:55 -07:00
Steve Yegge
e1a445afd2 Remove global socket fallback, enforce local-only daemons
- Remove ~/.beads/bd.sock fallback in getSocketPath()
- Always return local socket path (.beads/bd.sock)
- Add migration warning if old global socket exists
- Update AGENTS.md to remove global daemon references
- Document breaking change in CHANGELOG.md
- Fix test isolation: tests now use temp .beads dir and chdir

Prevents cross-project daemon connections and database pollution.
Each project must use its own local daemon.

Amp-Thread-ID: https://ampcode.com/threads/T-c4454192-39c6-4c67-96a9-675cbfc4db92
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 20:35:55 -07:00
Steve Yegge
3e44951f15 Add prefix validation on bulk import
- Detects prefix mismatches during import
- Shows warning with mismatched prefixes and counts
- Added --rename-on-import flag to automatically fix prefixes
- Auto-import is lenient about prefixes (doesn't enforce)
- All tests passing
2025-10-21 20:34:37 -07:00
Steve Yegge
aba982f785 Update issues.jsonl and documentation
Amp-Thread-ID: https://ampcode.com/threads/T-fea21f01-c136-437f-a61f-226872ae7a38
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 20:29:10 -07:00
Steve Yegge
7fc65c0f26 Sync issue tracking after merge work 2025-10-21 19:57:24 -07:00
Steve Yegge
2de58621a7 Fix misleading 'bd ready' message when all issues closed
Now distinguishes between:
- 'No open work found (all issues are closed)' - when everything is done
- 'No ready work found (all issues have blocking dependencies)' - when work exists but is blocked
2025-10-21 19:54:01 -07:00
Steve Yegge
7ae148cf2b Add --id flag to bd list for filtering by specific issue IDs
- Add --id flag accepting comma-separated IDs
- Implements ID filtering at CLI, RPC, and storage layers
- Normalizes IDs (trim, dedupe, remove empty) like labels
- Guards against excessive ID lists (max 1000)
- Works with other filters (status, priority, etc.)

Closes bd-200

Amp-Thread-ID: https://ampcode.com/threads/T-377464f2-1e7f-46f9-b23e-1e3cfd611061
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 19:53:27 -07:00
Steve Yegge
edd4ec95c5 Implement bd merge command with dependency migration and text references
- Add performMerge() with dependency migration in both directions
- Implement updateMergeTextReferences() for text reference updates
- Close source issues with 'Merged into bd-X' reason
- Fix store initialization panic by checking daemon mode earlier
- Add TODO for transaction support (deferred, see bd-215 for idempotency approach)

Closes bd-202, bd-193, bd-194, bd-195, bd-196
Related: bd-190 (merge epic), bd-215 (idempotency enhancement)

Amp-Thread-ID: https://ampcode.com/threads/T-30fe297d-4713-4f84-abc9-3bd264caa4c6
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 19:39:22 -07:00
Steve Yegge
0921cb7eaa Update issues
Amp-Thread-ID: https://ampcode.com/threads/T-887df83f-0ef0-45ee-82ac-776e43e01095
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 19:24:54 -07:00
Steve Yegge
272c56a9b7 Database recovery: Remove 9k test issues, restore clean state
Restored to commit ce13140 (196 legitimate issues) + today's work:
- bd-192: Closed (merge validation implemented)
- bd-191: Updated with simplified approach notes
- bd-200: Created (--id flag feature request from filter-flag-design.md)

Test pollution analysis:
- 3:28pm (743f64d): 186 issues (clean baseline)
- 4:47pm (ce13140): 196 issues (+10 merge epic work) ✓
- 5:48pm (6e29eef): 9365 issues (+9169 test pollution) ✗
- Now: 198 issues (196 + bd-192 closed + bd-200 created) ✓

The 9k test issues (bd-1000 through bd-9169) were accidentally
committed from ~/src/vc test workers that bypassed isolation.

Amp-Thread-ID: https://ampcode.com/threads/T-22945597-9f4f-413b-afde-dcf3099eb2f0
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 18:34:28 -07:00
Steve Yegge
c0807e50e3 Implement merge validation logic (bd-192)
- Add merge command with --into and --dry-run flags
- Validate target and source issues exist
- Validate no self-merge attempts
- Add comprehensive test coverage
- Capture --id flag feature request as bd-9369

Amp-Thread-ID: https://ampcode.com/threads/T-22945597-9f4f-413b-afde-dcf3099eb2f0
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 18:23:17 -07:00
Steve Yegge
6e29eef0c2 Revert bd-191: Remove merged_into schema field
Use simpler approach for bd-190 merge feature:
- Close merged issues with reason 'Merged into bd-X'
- No schema changes or migrations needed
- Parseable close reason is cleaner than separate field

Also updated merge epic child issues with simplified design.
2025-10-21 17:48:09 -07:00
Steve Yegge
ce13140ff2 Add epic bd-190 with 9 child tasks for merge command implementation 2025-10-21 16:47:11 -07:00
Steve Yegge
743f64dd46 Restore clean database state - 186 legitimate issues 2025-10-21 15:28:29 -07:00
Steve Yegge
acc813e528 Fix #94: Handle NULL assignee in epic status query
- Use sql.NullString to scan nullable assignee column
- Prevents 'converting NULL to string is unsupported' error
- Only set assignee if value is valid (not NULL)
2025-10-21 15:01:26 -07:00
Steve Yegge
ec946ee48b Fix #97: Add daemon mode check to rename-prefix command
- Prevents nil pointer dereference when daemon is active
- Ensures direct mode or fails gracefully
- Lower Python requirement to 3.10+ for beads-mcp (#99)

Amp-Thread-ID: https://ampcode.com/threads/T-740c6f9c-b8f0-4155-8bfa-7075eea2df22
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 14:56:18 -07:00
Steve Yegge
52d6fd8deb Sync issue updates: close bd-189, create bd-188 2025-10-21 14:10:26 -07:00
Steve Yegge
3f4878eb09 Auto-import from git on empty DB (bd-189)
- Add checkAndAutoImport() that detects empty DB with issues in git
- Automatically imports from git HEAD:.beads/issues.jsonl
- Integrated into list, ready, and stats commands
- Zero cognitive load for agents in fresh clones
- Makes JSONL truly the source of truth
- DB becomes ephemeral cache that auto-rebuilds

Also:
- Update AGENTS.md onboarding section with import instructions
- Merge PR #98 (enhanced .gitignore)

Amp-Thread-ID: https://ampcode.com/threads/T-ffcb5e95-e5a0-486b-a0ae-ce8bd861ab9d
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 14:10:26 -07:00
Ben Madore
cfe15a9d34 Enhance .gitignore created during bd init (#98)
- Expand .gitignore to include all SQLite-related files (journal, WAL, SHM)
- Add daemon runtime files (logs, PID, socket)
- Include legacy database filenames
- Explicitly allow JSONL files with !*.jsonl pattern
- Add test coverage to verify .gitignore content
2025-10-21 13:59:19 -07:00
Steve Yegge
34593cad8c Add RPC support for compact command (bd-184)
- Added OpCompact and OpCompactStats operation constants
- Added CompactArgs, CompactStatsArgs, and response types to RPC protocol
- Implemented handleCompact and handleCompactStats in RPC server
- Updated compact command to use RPC when daemon is available
- Fixed RPC client to include Cwd for proper database routing
- Compact now works in daemon mode with --no-daemon flag

Amp-Thread-ID: https://ampcode.com/threads/T-87885d07-80ad-466d-9ffb-cc96fab4853f
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 00:29:50 -07:00
Steve Yegge
6a6b5099e9 Sync issues from agent updates
Amp-Thread-ID: https://ampcode.com/threads/T-87885d07-80ad-466d-9ffb-cc96fab4853f
Co-authored-by: Amp <amp@ampcode.com>
2025-10-21 00:17:05 -07:00
Steve Yegge
3e991d2eea Track GH #66: Implement bd quickstart command (bd-183) 2025-10-21 00:13:31 -07:00
Steve Yegge
f4dd9e09a1 Fix MCP update tool bypassing close approval workflow
- Detect when update is called with status='closed'
- Redirect to close_issue to preserve approval workflow
- Ensures closing tasks always requires same approval regardless of tool used

Fixes #90

Amp-Thread-ID: https://ampcode.com/threads/T-9eab3a82-18f3-4ae3-a2d5-d114811383c1
Co-authored-by: Amp <amp@ampcode.com>
2025-10-20 23:47:56 -07:00
Steve Yegge
f41cd8816e Fix bd-180: bd import now creates database if .beads/ directory exists
Previously, 'bd import' would fail if the database didn't exist, even when
importing into a directory with a .beads/ folder. This made it impossible
to recreate a database from JSONL after schema changes or database removal.

Changes:
- Allow import command to create database when .beads/ directory exists
- Prefer local .beads/vc.db over ancestor databases for import operations
- Enable the workflow: mv .beads/vc.db backup && bd import .beads/issues.jsonl

Fixes #180

Amp-Thread-ID: https://ampcode.com/threads/T-7842ea55-6ce4-4162-9ad8-299124a15946
Co-authored-by: Amp <amp@ampcode.com>
2025-10-20 23:36:40 -07:00
Steve Yegge
50a0846763 chore: Add Homebrew formula for v0.10.1 and remove old formulas 2025-10-20 22:21:08 -07:00
Steve Yegge
19b3200cd4 chore: Bump version to 0.10.1
Updated all component versions:
- bd CLI: 0.10.0 → 0.10.1
- Plugin: 0.10.0 → 0.10.1
- MCP server: 0.9.11 → 0.10.1
- Documentation: 0.10.0 → 0.10.1

Includes fix for bd-179 (derive prefix from database filename)
2025-10-20 22:18:41 -07:00