feat(sim): the frame inspector + the handshake-refusal path - #19
Merged
Conversation
Milestone 1e (docs: design/playground-simulation.md) — completes Phase 1. - framedecode.ts — read a raw frame back with the same framing / handshake decoders the runtime uses, plus a JSON decode of the sub-frames. Resolves a datagram call id to a function name; reverses the handshake's wire-format / framing name hashes. - framelog.ts — rows are now <details>: direction, kind, function, Δ since the previous frame, byte length; expand for the decoded envelope (params / ok / err), a hex toggle, and the framing name. Handshake and unknown frames read distinctly; a "clear" button; a refusal row. - version-skew / handshake refusal. Each instance snapshots the schema's `ir_hash` when placed; `rebuild` leaves it alone, so editing a schema and returning keeps a surviving instance on the old IR. `resyncInstance` (a button in the inspector, shown only when the snapshot is stale) snaps it forward. `engine.connect` handshakes each end with its own instance's hash and no longer throws on a mismatch — it returns `LiveConnection.error = "handshake"`; the wire goes red, the call form hides, and the log gets a "connection refused · handshake" row. - a per-connection latency knob (ms) in the inspector. - view.test.ts: the 1d call test now also checks the labelled handshake frames and an expanded request frame's decoded params; a new test drives the whole refusal demo (connect on V1 → edit to V2 → resync only the server → refused). 15/15 sim tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Milestone 1e — completes Phase 1.
Frame inspector
framedecode.tsreads a raw frame back with the same framing /Handshakedecoders the runtime uses, then JSON-decodes the sub-frames. It resolves a datagram call id → function name and reverses the handshake's wire-format / framing FNV name-hashes.framelog.tsrows are<details>now: direction, kind, function, Δ since the previous frame, byte length — expand for the decoded envelope (params / ok / err · ordinal), a hex toggle, and the framing name. Handshake / unknown frames read distinctly; a clear button.Version skew → handshake refusal
Each instance snapshots the schema's
ir_hashwhen placed.rebuildleaves it alone, so editing a schema and returning keeps a surviving instance on the old IR.resyncInstance— a button in the inspector, shown only when the snapshot is stale — snaps it forward.engine.connectnow handshakes each end with its own instance's hash and doesn't throw on a mismatch: it returnsLiveConnection.error = "handshake". The wire turns red, the call form hides, and the log gets aconnection refused · handshakerow. Both handshake frames are still captured.Also: a per-connection latency knob (ms) in the inspector.
Tests
The 1e test drives the whole demo: connect on V1 →
setShape(V2)(both stay live) → resync only the server →wire-refused+ aframe-refusedrow + "connection refused · handshake" in the inspector.15/15 sim tests pass.
npm run buildgreen; +~1.3 KB gz.