Skip to content

feat(runtime): framing, transport, Client, Server - #7

Merged
Kinflou merged 1 commit into
mainfrom
feat/ts-runtime-client-server
Sep 2, 2026
Merged

feat(runtime): framing, transport, Client, Server#7
Kinflou merged 1 commit into
mainfrom
feat/ts-runtime-client-server

Conversation

@Kinflou

@Kinflou Kinflou commented Sep 2, 2026

Copy link
Copy Markdown
Member

The second layer of @comline/runtime — what a generated <Proto>Client / dispatcher will plug into.

Piece Notes
Framing + DatagramFraming request [call_id:u16 LE][request_id:u64 LE][params], response [request_id:u64 LE][tag-byte envelope]wire-compatible with comline_runtime::contract::DatagramFraming (header layout byte-checked)
JsonRpcFraming {"jsonrpc":"2.0","method":…,"params":…,"id":…} etc. — matches comline_runtime::framing::JsonRpcFraming (frame wording byte-checked)
envelope.ts the [0]payload / [1]id:u16 body tag-byte form
Transport + duplex() a connected in-memory pair; close() ends a serve loop
Client connect() runs the handshake; call() frames/sends/awaits/returns the raw Envelope; notify() fire-and-forget
Server serve() / serveHandshaked(): decode → resolve against Dispatch.calls() → dispatch into a Reply → frame by outcome (none → silent, ok, err+ordinal)

Tests: a full hand-written Chat client ⇆ provider round-trip over duplex() (request/response, a raised typed error, a one-way notify) run against both framings, plus a handshake wire-format-mismatch rejection. 19 tests, npm test green.

Next: the generator emits <Proto>Client / <Proto>Dispatcher against this package; then lib mode (npm package output); then a stream transport + a MessagePack codec.

The second layer of @comline/runtime — the pieces a generated
<Proto>Client / dispatcher plug into:

  - Framing interface + DatagramFraming (compact `[call_id:u16][request_id:u64]
    [params]` request, `[request_id:u64][tag-byte envelope]` response) and
    JsonRpcFraming (`{"jsonrpc":"2.0",...}`), both wire-compatible with
    comline-runtime — the datagram header layout and the JSON-RPC frame
    wording are byte-checked in the tests.
  - envelope.ts — the `[0]payload` / `[1]id:u16 body` tag-byte form.
  - Transport interface + duplex() — a connected in-memory pair; close()
    ends a serve loop.
  - Client — connect() runs the handshake; call() frames / sends / awaits /
    returns the raw Envelope; notify() is fire-and-forget.
  - Server — serve() / serveHandshaked(): decode request, resolve the call
    against Dispatch.calls(), dispatch into a Reply, frame the response by
    outcome (none -> silent, ok, err+ordinal).

Tests add a full hand-written Chat client ⇆ provider round-trip over
duplex() — request/response, a raised typed error, a one-way notify — run
against both framings, plus a handshake wire-format-mismatch rejection.
@Kinflou
Kinflou merged commit 1a8f0ab into main Sep 2, 2026
4 checks passed
@Kinflou
Kinflou deleted the feat/ts-runtime-client-server branch September 2, 2026 08:53
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