Skip to content

feat(sim): the wire — vendored runtime, route B, headless tests - #16

Merged
Kinflou merged 1 commit into
masterfrom
feat/sim-1b-wire
Sep 2, 2026
Merged

feat(sim): the wire — vendored runtime, route B, headless tests#16
Kinflou merged 1 commit into
masterfrom
feat/sim-1b-wire

Conversation

@Kinflou

@Kinflou Kinflou commented Sep 2, 2026

Copy link
Copy Markdown
Member

Milestone 1b of playground simulation.

Vendored @comline/runtime

app/src/sim/runtime/ is runtime/src/ from comline-typescript@5c20074, copied verbatim (unpublished workspace package, version 0.0.0 — pinned by copy the way wasm/Cargo.toml pins comline-core by rev). VENDORED.md records the commit and the re-vendor steps. _fixture_chat.ts is the generated chat.ts from the same commit, its @comline/runtime import repointed — it's the drift guard's reference.

transport.ts — the tapped wire

Tap records every frame ({ seq, from, to, bytes, at, kind }) and notifies listeners; TappedTransport wraps one duplex() end and passes send/recv straight through (optional fixed delivery latency). wire(a, b) = a tapped connection between two named endpoints.

generic.ts — route B

GenericClient / GenericDispatch read a ProtocolShape and do what a generated <Proto>Client / <Proto>Dispatcher does — any compiled schema is wireable with no codegen. SimRemoteError maps an err ordinal back to its name via the calling function's throws.

Tests — node --test via tsx

✔ send round-trips a decoded reply (datagram)
✔ send round-trips over JSON-RPC framing
✔ a raised error comes back as SimRemoteError with the ordinal's name
✔ a one-way call sends a request and expects no response
✔ drift guard — GenericDispatch frames match the generated ChatDispatcher

The drift guard runs a send call through GenericDispatch and through the committed generated ChatDispatcher/serveChat on separate tapped wires and asserts the post-handshake frames are byte-identical.

CI runs npm test (Node 22) before the site build; tsconfig.test.json typechecks the sim/ scope with @types/node (kept out of the browser build, which still excludes *.test.ts).

No UI, no app-bundle change — nothing imports sim/ from an entry yet (that's 1d).

Milestone 1b (docs: design/playground-simulation.md).

- app/src/sim/runtime/ — @comline/runtime src/ copied verbatim from
  comline-typescript @ 5c20074 (unpublished workspace package; pinned by
  copy, VENDORED.md records the commit + re-vendor steps). Plus the
  generated chat.ts fixture for the drift guard.

- transport.ts — Tap (records every frame, notifies listeners) and
  TappedTransport wrapping one duplex() end; `wire(a, b)` builds a tapped
  connection with an optional fixed delivery latency.

- generic.ts — GenericClient / GenericDispatch: read a ProtocolShape and
  do what a generated <Proto>Client / dispatcher does, so any compiled
  schema is wireable with no codegen. SimRemoteError maps an err ordinal
  back to its name via the calling function's throws.

- wire.test.ts (node --test via tsx): send round-trips a decoded reply
  over datagram and JSON-RPC; a raised error comes back as SimRemoteError
  with the ordinal's name; a one-way call sends a request and no reply;
  and the drift guard — GenericDispatch's frames are byte-identical to the
  generated ChatDispatcher's for a send call.

- CI runs `npm test` (node 22) before the site build; tsconfig.test.json
  typechecks the sim scope with @types/node.

No UI, no app-bundle change (nothing imports sim/ from an entry yet).
@Kinflou
Kinflou merged commit da0e7cd into master Sep 2, 2026
2 checks passed
@Kinflou
Kinflou deleted the feat/sim-1b-wire branch September 2, 2026 16:40
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