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>
- 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>
- 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>
- 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
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.
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>
- 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>
- 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
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>
- 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>
- 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>
- 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
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
- 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>
- 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>
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.
- 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)
- 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>
- 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>
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>