Skip to content

Frame through the runtime: its JSON-RPC, and body-bytes requests - #29

Merged
Kinflou merged 1 commit into
mainfrom
feat/runtime-body-framing
Oct 25, 2026
Merged

Kinflou merged 1 commit into
mainfrom
feat/runtime-body-framing

Conversation

@Kinflou

@Kinflou Kinflou commented Oct 25, 2026

Copy link
Copy Markdown
Member

Moves the simulator onto two runtime changes now on main:

  • runtime#49: the jsonrpc feature builds JSON-RPC without std.
  • runtime#50: encode_request_body on Framing and ConnectionFraming.

Changes

  • comline-runtime is pinned to 207b38a, with features = ["alloc", "jsonrpc"].
  • The JSON-RPC copy vendored in src/framing.rs is deleted. WireFraming::Jsonrpc now calls comline_runtime::framing::JsonRpcFraming.
    • runtime#45's found-* vectors in the tests still pass byte for byte.
  • Preencoded and its test are deleted. That was the WireFormat that ignored its value so it could pass encoded bytes through.
    • WireFraming::encode_request now takes the body as &[u8] and calls each framing's encode_request_body.
    • It no longer returns a Result, because nothing in it can fail.
  • serde_json no longer enables raw_value. Only the deleted copy used it, and the runtime turns it on for itself.
  • src/framing.rs's module doc now says the simulator keeps its own request ids, because it plays both ends on one simulated clock.

one_way

Requests now pass the call's real one_way instead of a hard-coded false. This changes no bytes:

  • datagram@1 and datagram@2 have no bit for one-way.
  • The simulator's JSON-RPC behaves like a lockstep Client. It only models server-provided protocols, and the Rust generator puts such a package on a Client, not a Connection (on_connection in generation's connections.rs). Client::notify keeps the id.
  • Only on a Connection is a one-way call sent as a notification with no id.

A new test pins this: one-way and two-way requests come out identical on every framing.

Wasm size (post-wasm-opt, from the CI logs)

The figures are in a comment below.

comline-runtime's `jsonrpc` feature (runtime#49) builds the JSON-RPC
framing without `std`, so the copy vendored in `src/framing.rs` goes and
`WireFraming::Jsonrpc` delegates to `JsonRpcFraming`. runtime#45's
`found-*` vectors still pass byte for byte.

`encode_request_body` (runtime#50) takes params the codec has already
laid out, so `Preencoded`, the `WireFormat` that ignored its value to
smuggle them through, goes too. `WireFraming::encode_request` takes the
body as `&[u8]` and the call's real `one_way`. No frame changes: datagram@2
has no bit for it, and the simulator's JSON-RPC is a lockstep `Client`'s,
whose `notify` keeps the id. A test pins that.

serde_json no longer needs `raw_value` here; the runtime enables what it
uses itself.
@Kinflou

Kinflou commented Oct 25, 2026

Copy link
Copy Markdown
Member Author

Wasm size after wasm-opt -Os, from the CI logs (main run 40226793179 vs this PR's run 40242337525):

build before after change
scripted (pkg-script) 2,203,964 2,195,253 −8,711 bytes
lean (pkg, --no-default-features) 595,508 586,363 −9,145 bytes

CI is green.

@Kinflou
Kinflou merged commit 1eab1f8 into main Oct 25, 2026
1 check passed
@Kinflou
Kinflou deleted the feat/runtime-body-framing branch October 25, 2026 23:14
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