Commit Graph

258 Commits

Author SHA1 Message Date
Steve Yegge
b87ef26b22 Fix renumber counter: Force reset to actual max ID
The counter wasn't being properly reset after renumbering because
SyncAllCounters uses MAX(old, new) which kept higher values from
deleted issues.

Solution: Add ResetCounter() method to delete the counter entry,
then SyncAllCounters recreates it from the actual max ID in database.

Now after renumbering 108 issues to bd-1..bd-108, the counter is
correctly set to 108 and next issue will be bd-109.
2025-10-16 21:51:35 -07:00
Steve Yegge
3759eca598 Fix renumber: Update counter after renumbering
After renumbering issues to bd-1 through bd-108, the counter was still
at the old value (346), causing next issue to be bd-347 instead of bd-109.

Fix: Call SyncAllCounters after renumbering to recalculate counter from
actual max ID in database.
2025-10-16 21:48:34 -07:00
Steve Yegge
8298cbd375 Fix bd-346: Auto-flush after renumber/rename-prefix now does full export
Problem: Incremental flush merged dirty issues with existing JSONL, leaving
old IDs when issues were renamed (e.g., test-3 remained after renumbering to test-2).

Solution:
- Add needsFullExport flag to force complete JSONL rebuild from DB
- Skip loading existing JSONL when fullExport=true (start with empty map)
- Use markDirtyAndScheduleFullExport() in renumber and rename-prefix commands
- PersistentPostRun flushes immediately before process exits (respects fullExport)

Test: Verified renumber with gaps correctly exports only current IDs to JSONL
2025-10-16 21:29:20 -07:00
Steve Yegge
55cd9e062b Fix bd-345: Use UUID-based temp IDs in renumber to prevent collisions
- Replace predictable temp IDs (temp-renumber-N) with UUIDs (temp-<uuid>)
- Fetch dependencies before ID updates to preserve them correctly
- Add comprehensive tests for renumbering with ID gaps, dependencies, and text refs
- All tests pass
2025-10-16 21:21:17 -07:00
Steve Yegge
86cbcbfd3a Clean up wrong-project issues and test data
Removed 237 issues that were accidentally added from wyvern project:
- 225 test issues (Test incremental 2, Test merged features)
- 12 wyvern deployment issues (SSL certs, Docker, OAuth, GCR, etc.)

Now down to 107 legitimate beads issues (IDs 1-344 with gaps).
Next step: renumber to compact ID space.
2025-10-16 21:12:05 -07:00
Steve Yegge
2fd0b85232 Update JSONL timestamps after local db creation 2025-10-16 20:52:35 -07:00
Steve Yegge
8347e5bcd7 Fix: Add auto-flush to renumber, rename-prefix, and compact commands
These commands modify issues in bulk but weren't triggering auto-export
to JSONL. This caused database and JSONL to get out of sync.

Added markDirtyAndScheduleFlush() calls to:
- bd renumber (after renumbering completes)
- bd rename-prefix (after prefix rename completes)
- bd compact (after single/batch compaction)
- bd delete (already had it)

Fixes the issue where massive cleanups weren't exported to JSONL.

Amp-Thread-ID: https://ampcode.com/threads/T-a43dc9fa-e9bc-43c7-9055-33acc08bc642
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 20:50:40 -07:00
Steve Yegge
872f203c57 Add RPC infrastructure and updated database
- RPC Phase 1: Protocol, server, client implementation
- Updated renumber.go with proper text reference updates (3-phase approach)
- Clean database exported: 344 issues (bd-1 to bd-344)
- Added DAEMON_DESIGN.md documentation
- Updated go.mod/go.sum for RPC dependencies

Amp-Thread-ID: https://ampcode.com/threads/T-456af77c-8b7f-4004-9027-c37b95e10ea5
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 20:36:23 -07:00
Steve Yegge
44550df33e Database cleanup and renumbering
- Closed 82 duplicate issues
- Deleted 330 test/duplicate issues
- Implemented bd renumber command with proper text reference updates
- Cleaned database: 674 → 344 issues (49% reduction)
- All issues now numbered bd-1 through bd-344
- Added RPC infrastructure (Phase 1) for daemon support
- Delete helper scripts for cleanup operations

Fixes: bd-696, bd-667, bd-698
Related: bd-695 (Epic: Database cleanup)
Amp-Thread-ID: https://ampcode.com/threads/T-456af77c-8b7f-4004-9027-c37b95e10ea5
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 20:36:12 -07:00
Steve Yegge
08a6bf2681 Update issues database and main command
Amp-Thread-ID: https://ampcode.com/threads/T-ad2e485a-ee9a-4055-886d-c875a2824091
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 19:25:33 -07:00
Steve Yegge
f32d90af4e Implement bd delete command with comprehensive cleanup 2025-10-16 19:18:23 -07:00
Steve Yegge
27542648ad Fix bd-663: Treat metadata errors as first import instead of failing
- GetMetadata() failures now set lastHash='' instead of returning early
- Allows auto-import to recover from corrupt/missing metadata
- Prevents auto-import from being permanently disabled
- All tests pass

Amp-Thread-ID: https://ampcode.com/threads/T-4e4a57c4-9ac0-43dc-a78e-b7e88123cc65
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 19:15:48 -07:00
Steve Yegge
ef31d98b43 Fix bd-666: Replace N+1 query pattern in auto-import with batch fetch
- Batch fetch all existing issues with SearchIssues() upfront
- Use O(1) map lookup instead of O(n) GetIssue() calls
- Improves performance dramatically with 1000+ issues
- All tests pass
2025-10-16 19:14:17 -07:00
Steve Yegge
37d60d624d Add critical warning banner about multiple workstreams
Amp-Thread-ID: https://ampcode.com/threads/T-36d8c02f-09ec-4921-b09d-ea5cd8ede317
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 19:13:04 -07:00
Steve Yegge
958124ba53 Document CGO_ENABLED=1 workaround for macOS crashes (closes #3, bd-87)
Amp-Thread-ID: https://ampcode.com/threads/T-2d5aef9f-a58d-4590-91f0-3cde2b3b1db4
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 18:23:30 -07:00
Steve Yegge
9505a72bdc Update issues.jsonl (bd-421 closed) 2025-10-16 18:08:58 -07:00
Steve Yegge
fc29beae6d Fix bd-421: Add deduplication to prevent importing duplicate issues
- Added deduplicateIncomingIssues() to consolidate content-identical issues
- DetectCollisions now deduplicates within incoming batch before processing
- Keeps issue with smallest ID when duplicates found
- Added comprehensive test suite in collision_dedup_test.go
- Export clean JSONL with bd-421 fix applied

Amp-Thread-ID: https://ampcode.com/threads/T-c17dd8bf-c298-4a80-baa5-55fa7c7bb9a3
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 18:08:58 -07:00
Steve Yegge
2abccb7a88 Implement bd restore command and flip ready work sort order
- Add bd restore command to view full history of compacted issues from git
- Command temporarily checks out historical commit, reads JSONL, displays original content
- Read-only operation, no database or git state modification
- Flip ready work sort to created_at ASC (older issues first within priority tier)
- Prevents issue treadmill effect, surfaces old P1s for triage
- Update README.md and AGENTS.md with restore documentation

Closes bd-407, bd-383
2025-10-16 18:06:53 -07:00
Steve Yegge
97e74b8585 Add comprehensive integration tests for auto-import collision detection (bd-401)
- Created autoimport_collision_test.go with 10 new test scenarios
- Added helper functions: createTestDBWithIssues, writeJSONLFile, captureStderr
- Tests cover: multiple collisions, all collisions, exact matches, hash fast path,
  parse errors, empty JSONL, new issues only, field conflicts, JSONL not found
- Achieved 75.3% coverage of autoImportIfNewer function
- All 17 auto-import tests passing in ~1 second
- Tests verify collision auto-remapping behavior

Closes bd-401

Amp-Thread-ID: https://ampcode.com/threads/T-d3cbaebd-54e8-425e-8e4a-d41cf5ccd247
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 17:44:58 -07:00
Steve Yegge
fe8d208255 Clean up duplicate issues (bd-384, bd-387, bd-385) 2025-10-16 17:44:03 -07:00
Steve Yegge
65f59e6b01 Add compacted_at_commit field and git commit capture during compaction
- Add compacted_at_commit field to Issue type (bd-405)
- Add database schema and migration for new field
- Create GetCurrentCommitHash() helper function
- Update ApplyCompaction to store git commit hash (bd-395)
- Update compaction calls to capture current commit
- Update tests to verify commit hash storage
- All tests passing

Amp-Thread-ID: https://ampcode.com/threads/T-5518cccb-7fc9-4dcd-ba5a-e22cd10e45d7
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 17:43:38 -07:00
Travis Cline
b17fcdbb2a Add scripttest-based integration tests (#59)
- Complete test coverage for all major bd commands:
  blocked, close, create, dep (add/remove/tree), export, help,
  import, init, list, quickstart, ready, show, stats, update, version
- Test data files validate command behavior and output
- Enables automated testing of full CLI workflows
2025-10-16 17:11:54 -07:00
Steve Yegge
363cd3b4e6 Add rename-prefix command (bd-420)
- Implement bd rename-prefix command with --dry-run and --json flags
- Add prefix validation (max 8 chars, lowercase, starts with letter)
- Update all issue IDs and text references atomically per issue
- Update dependencies, labels, events, and counters
- Fix counter merge to use MAX() to prevent ID collisions
- Update snapshot tables for FK integrity
- Add comprehensive tests for validation and rename workflow
- Document in README.md and AGENTS.md

Known limitation: Each issue updates in its own transaction.
A failure mid-way could leave mixed state. Acceptable for
intended use case (infrequent operation on small DBs).

Amp-Thread-ID: https://ampcode.com/threads/T-7e77b779-bd88-44f2-9f0b-a9f2ccd54d38
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 17:05:27 -07:00
Steve Yegge
598476d3b5 Add release process documentation 2025-10-16 15:37:00 -07:00
Steve Yegge
3803849d70 Merge collision resolution: 73 issues remapped, all bd-300 series preserved 2025-10-16 15:35:41 -07:00
Steve Yegge
a7a4600b31 Condense COMPACTION.md into README and make README more succinct 2025-10-16 15:22:44 -07:00
Steve Yegge
1eb59fa120 chore: Bump version to 0.9.8
Updated all component versions:
- bd CLI: 0.9.7 → 0.9.8
- Plugin: 0.9.7 → 0.9.8
- MCP server: 0.9.7 → 0.9.8
- Documentation: 0.9.7 → 0.9.8

Generated by scripts/bump-version.sh
2025-10-16 15:10:43 -07:00
Steve Yegge
c398eb2f5f Add 0.9.8 release notes 2025-10-16 15:07:04 -07:00
Steve Yegge
c3e3326bba Fix critical bugs: bd-169, bd-28, bd-393
- bd-169: Add -q/--quiet flag to bd init command
- bd-28: Improve error handling in RemoveDependency
  - Now checks RowsAffected and returns error if dependency doesn't exist
  - New removeDependencyIfExists() helper for collision remapping
- bd-393: CRITICAL - Fix auto-import skipping collisions
  - Auto-import was LOSING work from other workers
  - Now automatically remaps collisions to new IDs
  - Calls RemapCollisions() instead of skipping

All tests pass.

Amp-Thread-ID: https://ampcode.com/threads/T-cba86837-28db-47ce-94eb-67fade82376a
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 15:00:54 -07:00
Steve Yegge
211e1cf523 Update issues.jsonl after rebase 2025-10-16 14:55:27 -07:00
Steve Yegge
66d0dc4332 Fix: Export clean JSONL after rebase 2025-10-16 14:55:14 -07:00
Steve Yegge
2c134e237b Fix bd-306: Use PID suffix for temp files to avoid concurrent collisions
- Change temp filename from issues.jsonl.tmp to issues.jsonl.tmp.<pid>
- Prevents race conditions when multiple bd commands run concurrently
- Added issues bd-300 through bd-306 (git-based restoration epic)
2025-10-16 14:54:12 -07:00
Steve Yegge
5bfecf85f0 Close bd-306 (implemented daemon/auto-sync instead)
Amp-Thread-ID: https://ampcode.com/threads/T-6185b498-94d8-4034-b5e6-fe9bd3075592
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 14:24:46 -07:00
Steve Yegge
a3023cd42c removed old file 2025-10-16 14:23:51 -07:00
Steve Yegge
fcc2aaac51 Update issues.jsonl - close bd-437 2025-10-16 14:22:38 -07:00
Steve Yegge
4fe648d140 Fix bd-437: Use addDependencyUnchecked during collision resolution
When remapping dependencies during collision resolution, skip semantic
validation (like parent-child direction checks) since we're just updating
IDs on existing dependencies that were already validated.

Fixes parent-child validation error during import --resolve-collisions.
2025-10-16 13:42:47 -07:00
Steve Yegge
21bd7809b5 Add cycle detection performance benchmarks (bd-311)
- Created comprehensive benchmark suite for cycle detection
- Tested linear chains, tree structures, and dense graphs
- Results: 3-4ms overhead per AddDependency is acceptable
- Documented findings in test file and DESIGN.md
- Closed bd-311 and epic bd-307
2025-10-16 13:32:44 -07:00
Steve Yegge
1e32041fe6 Implement cycle detection and prevention improvements
- Add diagnostic warnings when cycles detected after dep add (bd-309)
- Add semantic validation for parent-child dependency direction (bd-308)
- Document cycle handling behavior in code, README, and DESIGN (bd-310)

Changes:
- cmd/bd/dep.go: Add DetectCycles() call and warning after dep add
- internal/storage/sqlite/dependencies.go: Add parent-child direction validation and comprehensive cycle prevention comments
- internal/storage/sqlite/dependencies_test.go: Add TestParentChildValidation
- README.md: Add dependency types and cycle prevention section with examples
- DESIGN.md: Add detailed cycle prevention design rationale and trade-offs
2025-10-16 13:18:07 -07:00
Steve Yegge
6753024eb0 Close bd-89 and bd-199 - both already fixed 2025-10-16 13:15:57 -07:00
Steve Yegge
11a6755ab3 Update issues.jsonl 2025-10-16 13:10:41 -07:00
Steve Yegge
3f4f7cc185 Implement bd daemon command with production-ready improvements
- Add bd daemon command for background git sync (bd-273)
- Implement PID file management with atomic creation (O_EXCL)
- Add session detachment (Setsid) to survive terminal closure
- Implement graceful shutdown with SIGTERM/SIGINT/SIGHUP handling
- Add context cancellation and per-sync timeouts (2min)
- Use secure file permissions (0600 for PID/log, 0700 for .beads)
- Add startup confirmation before reporting success
- Implement interval validation and comprehensive error handling
- Add full test coverage for daemon lifecycle
- Update README.md with daemon documentation

All oracle review recommendations implemented.

Resolves: bd-273
Amp-Thread-ID: https://ampcode.com/threads/T-117c4016-b25d-462a-aa75-6060df4b2892
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 13:10:19 -07:00
Steve Yegge
2b934913bb Implement bd daemon command with production-ready improvements
- Add bd daemon command for background git sync (bd-273)
- Implement PID file management with atomic creation (O_EXCL)
- Add session detachment (Setsid) to survive terminal closure
- Implement graceful shutdown with SIGTERM/SIGINT/SIGHUP handling
- Add context cancellation and per-sync timeouts (2min)
- Use secure file permissions (0600 for PID/log, 0700 for .beads)
- Add startup confirmation before reporting success
- Implement interval validation and comprehensive error handling
- Add full test coverage for daemon lifecycle
- Update README.md with daemon documentation

All oracle review recommendations implemented.
2025-10-16 13:09:55 -07:00
Steve Yegge
2006cbfa0d Resolve JSONL merge conflict with clean export
Amp-Thread-ID: https://ampcode.com/threads/T-4bc33003-b8be-4a0c-abca-165a424cc645
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 12:52:46 -07:00
Steve Yegge
6173adfc74 Update bd-251: clarify compaction is permanent decay, not restorable 2025-10-16 12:51:40 -07:00
Steve Yegge
a0b2110629 Update issues.jsonl after bd-272 completion 2025-10-16 12:50:32 -07:00
Steve Yegge
669636c828 Fix bd sync critical issues from code review
- Fix dry-run to not mutate state (no export/clear dirty flags)
- Use os.Executable() for import to avoid path hijacking
- Add preflight checks for merge/rebase in progress
- Add upstream tracking validation with helpful hints
- Use CommandContext for all git operations (enable cancellation)
- Add chmod(0644) to exportToJSONL for consistency with export.go

All critical issues from Oracle review addressed.
2025-10-16 12:43:43 -07:00
Steve Yegge
6f60a318df chore: final sync 2025-10-16 12:23:37 -07:00
Steve Yegge
3acaebf191 chore: merge and sync issues 2025-10-16 12:23:30 -07:00
Steve Yegge
91fdaeee1c fix: Resolve false positive merge conflict detection in auto-import
- Changed from substring matching to standalone line detection
- Only flags actual Git conflict markers on their own lines
- Prevents false alarms from conflict markers in issue descriptions
- Fixes bd-313

Amp-Thread-ID: https://ampcode.com/threads/T-2acdebf1-e4ce-4534-8538-4e7c4fb84232
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 12:23:14 -07:00
Steve Yegge
96e92de7c6 Implement bd sync command for automated git-based synchronization
- Added bd sync command that wraps export → commit → pull → import → push workflow
- Automatically resolves collisions during pull/import
- Supports --dry-run, --message, --no-pull, --no-push flags
- Updated README with bd sync documentation
- Addresses bd-272 (Phase 1: git-based sync)
2025-10-16 12:22:35 -07:00