Commit Graph

305 Commits

Author SHA1 Message Date
Steve Yegge
fb9b5864af feat: Add bd repos multi-repo commands and fix bd ready for in_progress issues
- Add 'bd repos' command for multi-repository management (bd-123)
  - bd repos list: show all cached repositories
  - bd repos ready: aggregate ready work across repos
  - bd repos stats: combined statistics across repos
  - bd repos clear-cache: clear repository cache
  - Requires global daemon (bd daemon --global)

- Fix bd ready to show in_progress issues (bd-165)
  - bd ready now shows both 'open' and 'in_progress' issues with no blockers
  - Allows epics/tasks ready to close to appear in ready work
  - Critical P0 bug fix for workflow

- Apply code review improvements to repos implementation
  - Use strongly typed RPC responses (remove interface{})
  - Fix clear-cache lock handling (close connections outside lock)
  - Add error collection for per-repo failures
  - Add context timeouts (1-2s) to prevent hangs
  - Add lock strategy comments

- Update documentation (README.md, AGENTS.md)
- Add comprehensive tests for both features

Amp-Thread-ID: https://ampcode.com/threads/T-1de989a1-1890-492c-9847-a34144259e0f
Co-authored-by: Amp <amp@ampcode.com>
2025-10-18 00:37:27 -07:00
Steve Yegge
56a379dc5a Add GitHub Issues migration script (bd-68)
- New gh2jsonl.py script supports GitHub API and JSON file import
- Maps GitHub labels to bd priority/type/status
- Preserves metadata, assignees, timestamps, external refs
- Auto-detects cross-references and creates dependencies
- Production-ready: User-Agent, rate limit handling, UTF-8 support
- Comprehensive README with examples and troubleshooting
- Tested and reviewed

Amp-Thread-ID: https://ampcode.com/threads/T-2fc85f05-302b-4fc9-8cac-63ac0e03c9af
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 23:55:51 -07:00
Steve Yegge
9fb46d41b8 Implement daemon auto-start with comprehensive improvements (bd-124)
- Auto-starts daemon on first bd command (unless --no-daemon or BEADS_AUTO_START_DAEMON=false)
- Exponential backoff on failures: 5s, 10s, 20s, 40s, 80s, 120s (max)
- Lockfile prevents race conditions when multiple commands start daemon simultaneously
- Stdio redirected to /dev/null to prevent daemon output in foreground
- Uses os.Executable() for security (prevents PATH hijacking)
- Socket readiness verified with actual connection test
- Accepts multiple falsy values: false, 0, no, off (case-insensitive)
- Working directory set to database directory for local daemon context
- Comprehensive test coverage including backoff math and concurrent starts

Fixes:
- Closes bd-1 (won't fix - compaction keeps DBs small)
- Closes bd-124 (daemon auto-start implemented)

Documentation updated in README.md and AGENTS.md

Amp-Thread-ID: https://ampcode.com/threads/T-b10fe866-ab85-417f-9c4c-5d1f044c5796
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 23:42:57 -07:00
Steve Yegge
0dac4b9003 Fix global daemon implementation and improve security
- bd-159: Global daemon now runs in routing mode without opening DB
- bd-158: Set socket permissions to 0600 for security
- bd-160: Reject --auto-commit/--auto-push with --global
- bd-157: Verified stale socket cleanup (already working)
- bd-56: Closed as won't-do (cycle prevention is better)
- bd-73: Multi-repo support complete
2025-10-17 23:17:22 -07:00
Steve Yegge
0795797bac docs: Document multi-repo workflow with global daemon
Implements bd-122: Document how to use beads across multiple projects

Added comprehensive multi-repo documentation:
- README.md: Global daemon section with architecture diagram
- AGENTS.md: MCP multi-repo configuration (global daemon + per-project)
- integrations/beads-mcp/README.md: BEADS_WORKING_DIR usage
- Mermaid diagram showing one daemon serving multiple repos

Documentation covers:
- Global daemon (bd daemon --global) for system-wide usage
- Per-project MCP instances with BEADS_WORKING_DIR
- Comparison table (local vs global)
- When to use each approach
- Example workflows for multi-project setups

Benefits of global daemon:
- One daemon process for all repos
- Automatic socket discovery (local -> global fallback)
- Better resource usage
- Per-request context routing to correct database

Amp-Thread-ID: https://ampcode.com/threads/T-ea606216-b886-4af0-bba8-56d000362d01
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:49:22 -07:00
Steve Yegge
958bbc0853 feat(daemon): Add --global flag for multi-repo support
Implements bd-121: Global daemon with system-wide socket

Changes:
- Add --global flag to daemon command
- Use ~/.beads/bd.sock when --global is set
- Skip git repo validation for global daemon
- Update daemon discovery to check ~/.beads/ as fallback
- Both Go CLI and Python MCP client check global socket
- Update all tests to pass global parameter

Benefits:
- Single daemon serves all repos on system
- No per-repo daemon management needed
- Better resource usage for users with many repos
- Automatic fallback when local daemon not running

Usage:
  bd daemon --global         # Start global daemon
  bd daemon --status --global # Check global status
  bd daemon --stop --global   # Stop global daemon

Related: bd-73 (multi-repo epic)
Amp-Thread-ID: https://ampcode.com/threads/T-ea606216-b886-4af0-bba8-56d000362d01
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:45:33 -07:00
Steve Yegge
ad8f52eb87 fix(blocked): Add nil check for BlockedBy field
Fixes #74 - prevents panic when BlockedBy is nil

Amp-Thread-ID: https://ampcode.com/threads/T-ea606216-b886-4af0-bba8-56d000362d01
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:41:27 -07:00
Steve Yegge
3446bb0ee4 Merge pull request #76 from ghoseb/fix/windows-stdio-crash
fix(mcp): Fix AsyncIO crash on Windows
2025-10-17 22:25:42 -07:00
Steve Yegge
62bd4ff7c7 Merge pull request #75 from mshuffett/fix/mcp-plugin-bugs
fix(mcp): Fix three critical bugs in beads MCP plugin
2025-10-17 22:23:59 -07:00
Steve Yegge
048522c41a Add prefix validation to prevent wrong-database issue creation
Closes bd-156 (originally bd-151, remapped during auto-import)

Validates that explicit --id prefix matches database prefix from config.
Prevents accidental creation of issues with wrong prefix (e.g., creating
'bd-118' in a database configured for 'vc-' prefix).

Features:
- Checks issue_prefix from config table when --id is provided
- Fails with helpful error message showing the mismatch
- Suggests correct prefix format
- Adds --force flag to override validation if intentional
- Only validates in direct mode (daemon needs RPC enhancement)

Example: bd create 'Test' --id vc-99  # Error: prefix mismatch, use bd-99
  bd create 'Test' --id vc-99 --force  # OK, forced override
Amp-Thread-ID: https://ampcode.com/threads/T-4e1ac6f1-7465-442a-a385-adaa98b539ad
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:20:18 -07:00
Steve Yegge
6ab9cc9a91 Fix inverted version comparison logic
Closes bd-149

The version mismatch warning was using string comparison (Version < dbVersion)
which incorrectly compared v0.9.10 < v0.9.9 as true (lexicographically '1' < '9').

Now uses golang.org/x/mod/semver.Compare for proper semantic versioning:
- v0.9.10 > v0.9.9 correctly returns 1 (binary is NEWER)
- v0.9.9 < v0.9.10 correctly returns -1 (binary is OUTDATED)

Amp-Thread-ID: https://ampcode.com/threads/T-4e1ac6f1-7465-442a-a385-adaa98b539ad
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:14:36 -07:00
Steve Yegge
63c538616d Fix bd delete panic when daemon is running
Closes bd-155

When daemon is running, store is nil because PersistentPreRun returns
early after connecting to daemon. The delete command (both single and
batch) now falls back to direct storage access when store is nil,
following the pattern used by other commands like ready and blocked.

Amp-Thread-ID: https://ampcode.com/threads/T-4e1ac6f1-7465-442a-a385-adaa98b539ad
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 22:06:21 -07:00
Steve Yegge
c17174b80a fix: bd list --status all showing 0 issues (bd-148)
The status filter was treating 'all' as a literal status value instead of
a special case meaning 'show all statuses'. This caused the SQL query to
filter for 'WHERE status = all' which matched no issues.

Fixed by checking if status is 'all' and skipping the filter in that case.

- Fix list.go to skip status filter when status == 'all'
- Update CHANGELOG with fix details
- All tests pass
2025-10-17 21:56:03 -07:00
Michael Shuffett
74b460b298 fix(mcp): Fix three critical bugs in beads MCP plugin
This PR fixes three bugs that prevented the MCP plugin from working:

1. **Fixed parameter name mismatch in tools.py**
   - Changed `workspace_root=workspace_root` to `working_dir=workspace_root`
   - The `create_bd_client()` function expects `working_dir` parameter,
     but tools.py was passing `workspace_root`
   - This caused "got an unexpected keyword argument 'workspace_root'" error

2. **Added version check guard for daemon client**
   - Added `hasattr(_client, '_check_version')` check before calling
   - BdDaemonClient doesn't have `_check_version()` method, only BdCliClient does
   - This caused "'BdDaemonClient' object has no attribute '_check_version'" error

3. **Implemented proper daemon socket detection for fallback**
   - Added synchronous socket file existence check before creating daemon client
   - Walks up directory tree looking for `.beads/bd.sock` file
   - Only creates daemon client if socket exists, otherwise falls back to CLI
   - Previously, daemon client was created but failed on first method call
   - This enables the documented "prefer_daemon with automatic CLI fallback" behavior

**Testing:**
- Verified MCP tools work correctly with single-repo setup
- Confirmed automatic fallback to CLI when daemon isn't running
- Tested on macOS with bd v0.9.9

**Related Issues:**
- Addresses symptoms similar to #65 (Windows BEADS_WORKING_DIR issue)
2025-10-17 21:16:19 -07:00
Baishampayan Ghose
67739fbdc7 fix(mcp): Fix AsyncIO crash on Windows
Since our implementation uses `async` IO for subprocess communication, it's
crucial to utilize the `fastMCP.run_async()` entry-point of FastMCP.

This should fix crashes on Windows.

ref: steveyegge/beads#53
2025-10-18 09:45:17 +05:30
Steve Yegge
ee94d817ed feat: Add batch deletion support (bd-127)
- Add DeleteIssues() method in sqlite.go for atomic batch deletion
- Support multiple issue IDs as arguments or from file
- Add --from-file flag to read IDs from file (supports comments)
- Add --dry-run mode for safe preview without deleting
- Add --cascade flag for recursive deletion of dependents
- Add --force flag to orphan dependents instead of failing
- Pre-collect connected issues before deletion for text reference updates
- Add orphan deduplication to prevent duplicate IDs
- Add rows.Err() checks in all row iteration loops
- Full transaction safety - all deletions succeed or none do
- Comprehensive statistics tracking (deleted, dependencies, labels, events)
- Update README and CHANGELOG with batch deletion docs

Fixed critical code review issues:
- Dry-run mode now properly uses dryRun parameter instead of deleting data
- Text references are pre-collected before deletion so they update correctly
- Added orphan deduplication and error checks
- Updated defer rollback pattern per Go best practices
2025-10-17 21:13:23 -07:00
Steve Yegge
c6ce88ebc7 Add Homebrew formula for v0.9.10 2025-10-17 19:33:14 -07:00
Steve Yegge
2678e572b9 Resolve merge conflict in issues.jsonl
Amp-Thread-ID: https://ampcode.com/threads/T-39c59655-3e0d-4060-85d1-cfcc7fa095ba
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 19:25:02 -07:00
Steve Yegge
52e2993bf6 chore: Bump version to 0.9.10
Updated all component versions:
- bd CLI: 0.9.9 → 0.9.10
- Plugin: 0.9.9 → 0.9.10
- MCP server: 0.9.9 → 0.9.10
- Documentation: 0.9.9 → 0.9.10

Generated by scripts/bump-version.sh
2025-10-17 18:15:29 -07:00
Steve Yegge
2b043b974f Auto-sync: export issues to JSONL 2025-10-17 18:15:13 -07:00
Steve Yegge
465e11cce2 Update AGENTS.md to recommend MCP server usage 2025-10-17 18:14:27 -07:00
Steve Yegge
e9729abd73 Fix bd-120: Fix nil pointer crash in export command when daemon is running
Amp-Thread-ID: https://ampcode.com/threads/T-f6d324a9-aa24-4cf8-9962-7391602c8c91
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 17:40:16 -07:00
Steve Yegge
afae421032 Sync issues: closed bd-105, bd-114, bd-115 2025-10-17 17:33:33 -07:00
Steve Yegge
ac5578d5f1 Complete daemon RPC with per-request context routing (bd-115)
- MCP server now uses daemon client by default with CLI fallback
- Added BEADS_USE_DAEMON environment variable (default: enabled)
- Created multi-repo integration test (all tests pass)
- Updated .gitignore for daemon runtime files
- Added SETUP_DAEMON.md with migration instructions
- Closed bd-105 (investigation complete) and bd-114 (multi-server confusion)

This enables single MCP server to handle multiple repos via daemon
with per-request context routing. No more multiple MCP server configs!

Amp-Thread-ID: https://ampcode.com/threads/T-c222692e-f6ef-4649-9726-db59470b82ef
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 16:55:14 -07:00
Steve Yegge
b40de9bc41 Implement daemon RPC with per-request context routing (bd-115)
- Added per-request storage routing in daemon server
  - Server now supports Cwd field in requests for database discovery
  - Tree-walking to find .beads/*.db from any working directory
  - Storage caching for performance across requests

- Created Python daemon client (bd_daemon_client.py)
  - RPC over Unix socket communication
  - Implements full BdClientBase interface
  - Auto-discovery of daemon socket from working directory

- Refactored bd_client.py with abstract interface
  - BdClientBase abstract class for common interface
  - BdCliClient for CLI-based operations (renamed from BdClient)
  - create_bd_client() factory with daemon/CLI fallback
  - Backwards-compatible BdClient alias

Next: Update MCP server to use daemon client when available
2025-10-17 16:28:29 -07:00
Steve Yegge
b8bcffba1d Complete script reorganization: move remaining scripts to scripts/ directory
Amp-Thread-ID: https://ampcode.com/threads/T-8d943ad6-b0ae-403c-94d0-8cce0feefa08
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 15:57:00 -07:00
Steve Yegge
5222f094f8 Document bd-105/bd-114 analysis: MCP context routing crisis
- bd-105: Comprehensive root cause analysis with 3 architectural paths
- bd-114: Documented as symptom of bd-105 (multi-server workaround backfire)
- Clarified daemon (v0.9.9) is orthogonal: solves concurrency, not routing
- Recommended solution: PATH 1 (SetContext/WhereAmI) - 8h effort, P0/P1
- Research complete: 1,034 misroutes quantified, MCP protocol analyzed

Amp-Thread-ID: https://ampcode.com/threads/T-8d943ad6-b0ae-403c-94d0-8cce0feefa08
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 15:55:19 -07:00
Daan van Etten
02d53ff3b5 Add fallback for 'bd blocked' command when daemon is running (#71)
The 'blocked' command doesn't have RPC support in the daemon yet.
When the daemon is running, store is nil, causing a panic.

This fix detects when daemon is running but store is nil, and opens
a direct database connection as a fallback. This allows the command
to work even when the daemon is active, until proper RPC support
is added.
2025-10-17 15:17:17 -07:00
Daan van Etten
991a2d995a Fix panic in 'bd stats' when daemon is running (#69)
The statsCmd was not checking if a daemon client was available before
trying to access the store directly. When the daemon is running, store
is nil, causing a panic.

This fix adds a check for daemonClient and uses RPC to get statistics
when the daemon is available, falling back to direct store access only
when running in direct mode.
2025-10-17 15:17:11 -07:00
Daan van Etten
7fde57c1ab Fix panics in dep commands when daemon is running (#72)
Multiple dep commands were directly accessing store without checking if
daemon was available, causing nil pointer dereferences when daemon was
running.

Fixed commands:
- dep add: Now uses RPC when daemon is available
- dep remove: Now uses RPC when daemon is available
- dep tree: Added fallback to direct storage when daemon lacks RPC support
- dep cycles: Added fallback to direct storage when daemon lacks RPC support

The commands with RPC support (add/remove) now use the daemon client
when available. Commands without RPC support (tree/cycles) fall back
to opening a direct database connection when the daemon is running.
2025-10-17 15:17:01 -07:00
Sophie Smithburg
34b5863f39 fix: Update Nix flake vendorHash for Go dependencies (#68)
The vendorHash in the flake was outdated, causing build failures.
Updated to match current Go module dependencies.

Also bumped version to 0.9.9 to match current project version.

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

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-17 15:16:53 -07:00
Daan van Etten
6ba77e57e3 Fix daemon database discovery to match other commands (#70)
The daemon command was failing to find the database while other commands
like 'bd list' could find it. This was because ensureBeadsDir() was not
using the same database discovery logic as other commands.

This fix updates ensureBeadsDir() to use beads.FindDatabasePath() API,
the same discovery mechanism used by all other commands, ensuring
consistent behavior across the CLI.
2025-10-17 15:16:08 -07:00
Steve Yegge
4ce33efa81 Update MCP server warning to clarify bd binary works for multi-repo 2025-10-17 14:34:09 -07:00
Steve Yegge
ff0ce6c3a7 Improve MCP client working directory handling
- Use os.getcwd() directly instead of PWD fallback (more reliable)
- Add cwd parameter to _run_command for per-command overrides

Amp-Thread-ID: https://ampcode.com/threads/T-bf7caacc-f242-4224-b730-1f4442a7ed50
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 14:22:26 -07:00
Steve Yegge
14c744861c Add epic closure management commands (fixes #62)
- Add 'bd epic status' to show epic completion with child progress
- Add 'bd epic close-eligible' to bulk-close completed epics
- Add GetEpicsEligibleForClosure() storage method
- Update 'bd stats' to show count of epics ready to close
- Add EpicStatus type for tracking epic/child relationships
- Support --eligible-only, --dry-run, and --json flags
- Fix golangci-lint config version requirement

Addresses GitHub issue #62 - epics now have visibility and
management tools for closure when all children are complete.

Amp-Thread-ID: https://ampcode.com/threads/T-e8ac3f48-f0cf-4858-8e8f-aace2481c30d
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 13:50:20 -07:00
Juan Vargas
e6a69401c9 Add SQLite native time format to connection string (#61)
Use _time_format=sqlite parameter in modernc.org/sqlite connection
string to ensure DATETIME columns use SQLite's native time format
(format 7 with timezone) instead of Go's default String() format.

This improves compatibility with SQLite's date/time functions and
ensures consistent time representation across the database.
2025-10-17 11:35:43 -07:00
Ben Madore
789145f842 Add .gitignore to .beads directory during init (#64)
- Create .gitignore file in .beads/ when running bd init
    - Ignores *.db and *.db-* patterns to prevent database commits
    - Add test coverage to verify .gitignore creation
    - Add .claude/settings.local.json to project .gitignore

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

    Co-Authored-By: Claude <noreply@anthropic.com>

Co-authored-by: Ben Madore <madorb@users.noreply.github.com>
2025-10-17 11:24:39 -07:00
Steve Yegge
a971762b0e Remove ~/.beads fallback behavior
- Remove ~/.beads/default.db fallback from FindDatabasePath()
- Update daemon to error if no database found instead of falling back
- Update main.go to require explicit database initialization
- Add help/version/quickstart to commands that don't need database
- Add MCP client debug logging for database routing

Amp-Thread-ID: https://ampcode.com/threads/T-2b757a14-cf10-400e-a83c-30349182dd82
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 10:56:52 -07:00
Steve Yegge
49f3faf5d7 Delete test stub issues and renumber to compact ID space 2025-10-17 01:32:59 -07:00
Steve Yegge
a4381affeb Add CLI output tests, remove obsolete design docs (bd-37)
- Added cmd/bd/output_test.go with 7 new tests for CLI output functions
- Improved coverage: outputJSON (0→60%), printCollisionReport (0→100%), printRemappingReport (0→100%)
- Removed obsolete design documents that were implemented or superseded:
  - DAEMON_DESIGN.md (daemon implemented)
  - DAEMON_STRESS_TEST.md (stress testing complete)
  - DESIGN.md (general design, superseded by other docs)
  - DUPLICATES_REPORT.md (old analysis)
  - REVIEW_BD379.md (completed review)
- Closed bd-37: All critical features now have test coverage

Amp-Thread-ID: https://ampcode.com/threads/T-9ee0fcdd-3675-42ea-966b-64ee3d9248a3
Co-authored-by: Amp <amp@ampcode.com>
2025-10-17 01:15:39 -07:00
Steve Yegge
1a82bbaee3 chore: Bump version to 0.9.9
Updated all component versions:
- bd CLI: 0.9.8 → 0.9.9
- Plugin: 0.9.8 → 0.9.9
- MCP server: 0.9.8 → 0.9.9
- Documentation: 0.9.8 → 0.9.9

Generated by scripts/bump-version.sh
2025-10-17 00:33:27 -07:00
Steve Yegge
7790c5e95c Add 0.9.9 release notes 2025-10-17 00:33:20 -07:00
Steve Yegge
3116b7b8cc Add comprehensive tests for init command (bd-70)
- Add TestInitCommand with subtests for default prefix, custom prefix, quiet flag, and prefix normalization
- Add TestInitAlreadyInitialized to verify re-initialization works correctly
- Tests verify database creation, config storage, and metadata
- Tests verify -q/--quiet flag suppresses output correctly
- All tests pass

The -q flag was already working correctly; this just adds test coverage.
2025-10-17 00:09:26 -07:00
Steve Yegge
55ce3e677a Add comprehensive daemon RPC integration tests (bd-117)
- Add TestDaemonRPCServerIntegration for basic RPC integration
- Add TestDaemonConcurrentOperations for concurrent client tests
- Add TestDaemonSocketCleanupOnShutdown for socket cleanup verification
- Add TestDaemonServerStartFailureSocketExists for socket conflict handling
- Add TestDaemonGracefulShutdown for graceful shutdown verification
- Use /tmp directly to avoid macOS socket path length limits (104 chars)
- Add mockDaemonServer with ready signaling to avoid race conditions
2025-10-17 00:03:54 -07:00
Steve Yegge
15b60b4ad0 Phase 4: Atomic operations and stress testing (bd-114, bd-110)
Completes daemon architecture implementation:

Features:
- Batch/transaction API (OpBatch) for multi-step atomic operations
- Request timeout and cancellation support (30s default, configurable)
- Comprehensive stress tests (4-10 concurrent agents, 800-1000 ops)
- Performance benchmarks (daemon 2x faster than direct mode)

Results:
- Zero ID collisions across 1000+ concurrent creates
- All acceptance criteria validated for bd-110
- Create: 2.4ms (daemon) vs 4.7ms (direct)
- Update/List: similar 2x improvement

Tests Added:
- TestStressConcurrentAgents (8 agents, 800 creates)
- TestStressBatchOperations (4 agents, 400 batch ops)
- TestStressMixedOperations (6 agents, mixed read/write)
- TestStressNoUniqueConstraintViolations (10 agents, 1000 creates)
- BenchmarkDaemonCreate/Update/List/Latency
- Fixed flaky TestConcurrentRequests (shared client issue)

Files:
- internal/rpc/protocol.go - Added OpBatch, BatchArgs, BatchResponse
- internal/rpc/server.go - Implemented handleBatch with stop-on-failure
- internal/rpc/client.go - Added SetTimeout and Batch methods
- internal/rpc/stress_test.go - All stress tests
- internal/rpc/bench_test.go - Performance benchmarks
- DAEMON_STRESS_TEST.md - Complete documentation

Closes bd-114, bd-110

Amp-Thread-ID: https://ampcode.com/threads/T-1c07c140-0420-49fe-add1-b0b83b1bdff5
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 23:46:12 -07:00
Steve Yegge
39b586a7be Phase 2: Add client auto-detection in bd commands (bd-112)
- Add daemon client infrastructure to main.go with TryConnect logic
- Update PersistentPreRun to detect daemon socket and route through RPC
- Add --no-daemon flag to force direct storage mode
- Update all commands (create, update, close, show, list, ready) to use daemon when available
- Maintain backward compatibility with graceful fallback to direct mode
- All commands work identically in both daemon and direct modes

Part of bd-110 daemon architecture implementation.

Amp-Thread-ID: https://ampcode.com/threads/T-bfe2c083-be7c-4064-8673-fa69c22a730e
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 23:13:22 -07:00
Steve Yegge
5c0fac6e17 feat: Phase 1 RPC protocol infrastructure for daemon architecture (bd-111)
Implemented Unix socket RPC foundation to enable daemon-based concurrent access:

New files:
- internal/rpc/protocol.go: Request/Response types with 13 operations
- internal/rpc/server.go: Unix socket server with storage adapter
- internal/rpc/client.go: Client with auto-detection and typed methods
- internal/rpc/rpc_test.go: Integration tests

Features:
- JSON-based protocol over Unix sockets
- Adapter pattern for context/actor propagation to storage API
- Ping/health checks for daemon detection
- All core operations: create, update, close, list, show, ready, stats, deps, labels
- Graceful socket cleanup and signal handling
- Concurrent request support

Tests: 49.3% coverage, all passing

Related issues:
- bd-110: Daemon architecture epic
- bd-111: Phase 1 (completed)
- bd-112: Phase 2 (client auto-detection)
- bd-113: Phase 3 (daemon command)
- bd-114: Phase 4 (atomic operations)

Amp-Thread-ID: https://ampcode.com/threads/T-796c62e6-93b6-41c7-9cb5-8acc4a35ba9a
Co-authored-by: Amp <amp@ampcode.com>
2025-10-16 22:49:19 -07:00
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