Add daemon fallback visibility and version compatibility checks

Implemented bd-150: Improve daemon fallback visibility and user feedback
- Added DaemonStatus struct to track connection state
- Enhanced BD_DEBUG logging with detailed diagnostics and timing
- Added BD_VERBOSE mode with actionable warnings when falling back
- Implemented health checks before using daemon
- Clear fallback reasons: connect_failed, health_failed, auto_start_disabled, auto_start_failed, flag_no_daemon
- Updated documentation

Implemented bd-151: Add version compatibility checks for daemon RPC protocol
- Added ClientVersion field to RPC Request struct
- Client sends version (0.9.10) in all requests
- Server validates version compatibility using semver:
  - Major version must match
  - Daemon >= client for backward compatibility
  - Clear error messages with directional hints (upgrade daemon vs upgrade client)
- Added ClientVersion and Compatible fields to HealthResponse
- Implemented 'bd version --daemon' command to check compatibility
- Fixed batch operations to propagate ClientVersion for proper checks
- Updated documentation with version compatibility section

Code review improvements:
- Propagate ClientVersion in batch sub-requests
- Directional error messages based on which side is older
- Made ServerVersion a var for future unification

Amp-Thread-ID: https://ampcode.com/threads/T-b5fe36b8-c065-44a9-a55b-582573671609
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-10-19 08:04:48 -07:00
parent 5fefce4e85
commit 22daa12665
7 changed files with 515 additions and 200 deletions

View File

@@ -523,7 +523,23 @@ bd --db ~/otherproject/.beads/other.db list
- `BEADS_DB` - Override database path
- `BEADS_AUTO_START_DAEMON` - Enable/disable automatic daemon start (default: `true`). Set to `false` or `0` to disable.
- `BD_ACTOR` - Set actor name for change tracking (defaults to `$USER`)
- `BD_DEBUG` - Enable debug logging for troubleshooting
- `BD_DEBUG` - Enable debug logging (connection attempts, auto-start timing, health checks)
- `BD_VERBOSE` - Show warnings when falling back from daemon to direct mode
### Version Compatibility
The daemon and CLI check version compatibility automatically:
- **Major version** must match (e.g., 1.x.x client requires 1.x.x daemon)
- **Minor version** backward compatible (e.g., daemon 1.2.x supports client 1.1.x)
- **Patch version** always compatible
When versions mismatch, you'll see a clear error message with instructions to restart the daemon.
Check daemon version and compatibility:
```bash
bd version --daemon # Show daemon and client versions
bd version --daemon --json # JSON output with compatibility info
```
## Dependency Model
@@ -927,6 +943,7 @@ bd daemon --status # Show daemon status
bd daemon --stop # Stop running daemon
bd daemon --global # Run as global daemon (see below)
bd daemon --migrate-to-global # Migrate from local to global daemon
bd version --daemon # Check daemon version and compatibility
```
Log rotation is automatic and configurable via environment variables: