Skip to content

refactor(wire_frame): port FrameV1 onto backend_sdk codecs (partial #718) - #736

Merged
zackees merged 1 commit into
mainfrom
feat/718-framev1-backend-sdk
Jun 14, 2026
Merged

zackees merged 1 commit into
mainfrom
feat/718-framev1-backend-sdk

Conversation

@zackees

@zackees zackees commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Closes part of #718 (the crates/zccache/src/protocol/wire_frame.rs slice). The transport.rs / connection.rs work in the issue body has a much larger blast radius and will land as a follow-up.

What changed

crates/zccache/src/protocol/wire_frame.rs now delegates outer-envelope construction and decoding to running-process backend_sdk codecs:

  • Encode: Frame::request(ZCCACHE_FRAME_PAYLOAD_PROTOCOL, payload).with_request_id(id) + frame_ext::encode_framed (and Frame::response_to(&template, payload) on the response path). Replaces hand-rolled Frame { … } literal + [1][LE len][prost] byte assembly in encode_frame_v1_message.
  • Decode: frame_ext::try_decode_framed + buffer advance, replacing hand-rolled body-length parsing + Frame::decode.
  • Payload protocol id: bare pub const ZCCACHE_FRAME_PAYLOAD_PROTOCOL: u32 = 0x7A63; + four hand-rolled collision asserts collapse into one running_process::register_payload_protocol! invocation, which inherits the SDK's compile-time first-party-collision and registered-consumer-range checks (tracks running_process::broker::protocol::registry::ZCCACHE_PAYLOAD_PROTOCOL).

The public API surface — encode_frame_v1_request, encode_frame_v1_response, decode_frame_v1_message, FrameV1Decoded, buffer_starts_running_process_frame, ZCCACHE_FRAME_PAYLOAD_PROTOCOL — is unchanged, so transport.rs, connection.rs, and tests/daemon_wire_frame_v1_test.rs need no edits.

Acceptance

  • Golden bytes identical. All 3 unit tests in protocol::wire_frame::tests pass; all 10 integration tests in tests/daemon_wire_frame_v1_test.rs pass (including live daemon round-trip and mixed-wire/backend-probe coexistence).
  • Net-negative LOC: 1 file changed, 71 insertions(+), 86 deletions(-) — net -15 lines.

What is left in #718 (follow-up)

  • transport.rs: delete try_serve_backend_handle_probe, probe-side ensure_buffered, is_backend_handle_probe_request, backend_handle_probe_response, write_running_process_frame; replace the accept-path call with BackendEndpointMux (legacy detector = existing v15/v16 header check); drop next_frame_request_id + send_frame_v1_request/response once FrameClient owns correlation on the client side.
  • daemon/server/connection.rs: replace ResponseWire::FrameV1 plumbing with the mux payload-handler closure.
  • tests/daemon_wire_frame_v1_test.rs: keep the golden-bytes constants verbatim; replace the bespoke live/mixed-wire harness with the conformance kit.

These are non-trivial restructures of the daemon's accept loop and wire dispatch; splitting them out keeps this PR small and verifiable.

Test plan

  • Build the lib (warm-cache via soldr)
  • soldr test on protocol::wire_frame unit tests (3/3 pass)
  • soldr test on daemon_wire_frame_v1_test integration tests (10/10 pass)
  • Clippy clean with -D warnings

Refs #718, #735

… backend_sdk codecs (refs #718)

Replaces the hand-rolled outer-envelope construction and decode loop in
`crates/zccache/src/protocol/wire_frame.rs` with running-process's
`Frame::request` / `Frame::response_to` + `frame_ext::encode_framed` /
`try_decode_framed`. The bare `pub const ZCCACHE_FRAME_PAYLOAD_PROTOCOL`
plus four hand-rolled collision asserts collapse into a single
`register_payload_protocol!` invocation, picking up the SDK's
compile-time first-party-collision and registered-consumer-range checks.

The public API surface (`encode_frame_v1_request`,
`encode_frame_v1_response`, `decode_frame_v1_message`, `FrameV1Decoded`,
`buffer_starts_running_process_frame`, `ZCCACHE_FRAME_PAYLOAD_PROTOCOL`)
is unchanged, so transport.rs / connection.rs / tests are not touched.

## Acceptance

- Golden bytes identical: `frame_v1_request_golden_bytes_are_frozen`,
  `frame_v1_golden_round_trips`, `frame_v1_rejects_foreign_payload_protocol`
  in the unit tests, plus `request_frame_encodes_to_golden_bytes`,
  `response_frame_encodes_to_golden_bytes`, and the live + mixed-wire
  daemon integration tests in `daemon_wire_frame_v1_test.rs` all pass.
- Net-negative LOC: -15 lines on `wire_frame.rs` (86 deletions, 71
  insertions). The rest of the #718 refactor (mux integration in
  `transport.rs`, `next_frame_request_id` / `send_frame_v1_*` removal,
  `ResponseWire::FrameV1` → mux payload-handler closure in
  `connection.rs`) has a much larger blast radius and is staged for a
  follow-up PR.

Refs #718
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