feat(daemon,proxy): serve checked RPC that refuses protocol skew before dispatch

Merged
TH
1d ago
+1120-31

Summary

Adds POST /rpc/checked (also /agent-device/rpc/checked) on the daemon and proxy so the server refuses protocol skew before dispatch, in place of the client's /health probe. Replaces closed #5134. The client opt-in is #5145.

  • Same auth, body and answer as /rpc. The x-agent-device-rpc-protocol header is mandatory.
  • Skew gets 409 plus x-agent-device-refusal (protocol-missing, protocol-mismatch, or upstream-protocol-mismatch through a proxy).
  • The proxy admits both routes through one path and forwards to the upstream checked route.
  • /health and DAEMON_CAPABILITIES list checked-rpc. Additive ledger entries, no protocol bump. ADR 0006 amended.

Security

  • The daemon verifies the transport credential (headers or JSON params.token) before it reads the protocol or method: a wrong credential always gets 401.
  • The 409 comes only after the auth hook, tenant and token gates pass; any earlier failure gets the ordinary /rpc rejection. A refused call reserves no request id.
  • Refusals echo only a bounded id and are built from local values; the proxy never copies an upstream refusal's body or headers, and never follows a redirect on the checked route.
  • No state on disk, no resend.

Before / after

No observable change until a client calls the route. Released servers answer it with 404 before dispatch.

Validation

Head 1633e100df. Ordering, id, reservation, rebuild and redirect tests fail without their fixes (checked by mutation). Proxy and daemon checked tests, test/wire-compat, eager-closure budgets, the layering scan and fallow audit pass locally. CI pending.

šŸ¤– Generated with Claude Code