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

@@ -9,6 +9,10 @@ import (
"time"
)
// ClientVersion is the version of this RPC client
// This should match the bd CLI version for proper compatibility checks
var ClientVersion = "0.9.10"
// Client represents an RPC client that connects to the daemon
type Client struct {
conn net.Conn
@@ -86,8 +90,9 @@ func (c *Client) Execute(operation string, args interface{}) (*Response, error)
}
req := Request{
Operation: operation,
Args: argsJSON,
Operation: operation,
Args: argsJSON,
ClientVersion: ClientVersion,
}
reqJSON, err := json.Marshal(req)