Skip to content

feat(protocol): version the daemon wire protocol - #15

Merged
msmps merged 1 commit into
mainfrom
feat/protocol-version
Jul 11, 2026
Merged

feat(protocol): version the daemon wire protocol#15
msmps merged 1 commit into
mainfrom
feat/protocol-version

Conversation

@msmps

@msmps msmps commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Adds protocol versioning to the client↔daemon wire protocol, piggybacked on every message rather than a handshake roundtrip:

  • PROTOCOL_VERSION = 1; Request and Response gain protocol: u32 with #[serde(default)], so messages from binaries that predate versioning deserialize as version 0.
  • Request::new() stamps the client version; both Response constructors stamp the daemon version.
  • The client warns on stderr when the running daemon speaks an older protocol, with the actionable fix: run 'pilotty stop' so the daemon restarts with the current binary (auto-start then spawns the new one).

Why piggybacked instead of a hello/ack: the only realistic mismatch is version skew with an already-running daemon (mid-upgrade). Additive JSON fields detect that for free; a handshake would add a roundtrip to every thin-client invocation to negotiate something that almost never fails.

Why warning-only: every current command exists in version 0, so nothing needs hard gating yet. Commands introduced at version 1+ will check the field and error helpfully when the daemon is older.

Compatibility

  • New client → old daemon: unknown protocol field ignored (guard test prevents deny_unknown_fields regressions).
  • Old client → new daemon: missing field parses as 0; all v0 commands answer normally.
  • Wire cost: +14 bytes per message.

Tests

Five new wire-compat tests in protocol.rs covering both skew directions and constructor stamping. Full suite: 181 passed, 0 failed; clippy clean under -D warnings.

🤖 Generated with Claude Code

Request and Response now carry a protocol field (PROTOCOL_VERSION = 1,
serde default 0 for binaries that predate versioning). The client warns
on stderr when the running daemon is older than the client and suggests
'pilotty stop' so auto-start relaunches the current binary.

Warning-only for now: every current command exists in version 0. Hard
gating begins when version-1-only commands ship and check this field.

Compat covered by tests: unknown fields stay ignored in both directions
(guarded against deny_unknown_fields), missing fields parse as 0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@msmps
msmps merged commit 5a65b1c into main Jul 11, 2026
6 checks passed
@msmps
msmps deleted the feat/protocol-version branch July 11, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant