From b2b5a97bcae425571bb94384f151090563f4eb81 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 08:25:50 -0800 Subject: [PATCH] chore(verify): drop the statechart views no skill draws Eight `*.view.ts` files, `Chart.cfg`, and its `Story` definition existed only for a `/statechart` skill that is not in this repository or its history. Co-Authored-By: Claude --- .claude/skills/verify-resume/SKILL.md | 2 - js/publish/verify/Publish.view.ts | 38 ------ js/publish/verify/README.md | 17 +-- js/room/verify/README.md | 9 +- js/room/verify/Room.cfg | 2 +- js/room/verify/Room.view.ts | 64 --------- js/watch/verify/Failover.view.ts | 82 ------------ js/watch/verify/README.md | 5 +- js/watch/verify/Watch.view.ts | 51 -------- rs/moq-net/verify/reconnect/Handover.view.ts | 121 ------------------ rs/moq-net/verify/resume/Chart.cfg | 22 ---- rs/moq-net/verify/resume/ResumeReader.tla | 9 -- rs/moq-net/verify/resume/ResumeReader.view.ts | 76 ----------- rs/moq-net/verify/route/RouteHandoff.view.ts | 110 ---------------- .../subscribe/SubscribeAccounting.view.ts | 109 ---------------- 15 files changed, 14 insertions(+), 703 deletions(-) delete mode 100644 js/publish/verify/Publish.view.ts delete mode 100644 js/room/verify/Room.view.ts delete mode 100644 js/watch/verify/Failover.view.ts delete mode 100644 js/watch/verify/Watch.view.ts delete mode 100644 rs/moq-net/verify/reconnect/Handover.view.ts delete mode 100644 rs/moq-net/verify/resume/Chart.cfg delete mode 100644 rs/moq-net/verify/resume/ResumeReader.view.ts delete mode 100644 rs/moq-net/verify/route/RouteHandoff.view.ts delete mode 100644 rs/moq-net/verify/subscribe/SubscribeAccounting.view.ts diff --git a/.claude/skills/verify-resume/SKILL.md b/.claude/skills/verify-resume/SKILL.md index 2db1f48d49a..6d9eeaa9d2e 100644 --- a/.claude/skills/verify-resume/SKILL.md +++ b/.claude/skills/verify-resume/SKILL.md @@ -30,8 +30,6 @@ just rs tla moq-net/verify/resume/ResumeReader.tla -config rs/moq-net/verify/res The first checks every rule over two routes, three groups, two switches, and a reader holding each group until it finishes it: about 14.3M distinct states, in minutes. The second trades a group for a third route, so a route can come up after another failed: about 7.1M states, in minutes. Both pass at the sync commit. `just test tla rs/moq-net/verify/resume` runs every config here, as Nightly does, and fails if a config with an `\* Open finding:` line passes. -`Chart.cfg` is a story (`Story`) small enough to draw whole, where the reader switches to a route that holds an older group and asks it for that group. - ## Open findings None at the sync commit. diff --git a/js/publish/verify/Publish.view.ts b/js/publish/verify/Publish.view.ts deleted file mode 100644 index 49ad13e66fd..00000000000 --- a/js/publish/verify/Publish.view.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Statechart labels for Publish.tla: what the publisher's badge says, and whether viewers -// can find the broadcast, with each step as the publisher or the network makes it happen. - -type Vars = { - camera: "off" | "asking" | "capturing" | "denied" | "lost" | "failed"; - settled: boolean; - announced: boolean; - net: "connecting" | "connected"; -}; - -const badge = (v: Vars) => { - if (v.camera === "denied") return "CAMERA DENIED"; - if (v.camera === "failed") return "CAMERA FAILED"; - if (v.net === "connecting") return "CONNECTING"; - if (v.camera === "capturing") return "LIVE"; - return "NO SOURCE"; -}; - -export const title = "Publishing a camera broadcast"; - -export const state = (v: Vars) => - `${badge(v)}, viewers ${v.announced && v.net === "connected" ? "can" : "cannot"} find it`; - -const steps: Record = { - Choose: "you pick the camera", - Grant: "you allow the camera", - Deny: "you deny the camera", - Settle: "the encoders settle", - Lost: "the camera is lost", - Reopened: "the camera reopens", - Spent: "the reopen budget runs out", - Connect: "the connection opens", - Drop: "the connection drops", -}; - -// Hides "you stop the camera", which every selected state has and which leads back to the start: -// StopStopsPublishing checks it. -export const step = (action: string) => steps[action] ?? null; diff --git a/js/publish/verify/README.md b/js/publish/verify/README.md index 8bbf806a888..e2fba546a23 100644 --- a/js/publish/verify/README.md +++ b/js/publish/verify/README.md @@ -1,11 +1,10 @@ # Publish flow -`Publish.tla` is a TLA+ model of going live with ``, written to be -drawn as a statechart. It follows the camera and microphone capture (asking, +`Publish.tla` is a TLA+ model of going live with ``. +It follows the camera and microphone capture (asking, capturing, denied, a lost device reopening within its retry budget, failed), the encoders -settling, the `source`-mode announce gate in `src/announce.ts`, and the relay connection. The -chart labels each state with what the status badge says and whether viewers can find the -broadcast. +settling, the `source`-mode announce gate in `src/announce.ts`, and the relay connection, along +with what the status badge says and whether viewers can find the broadcast. | Rule | Holds when | Today | | --- | --- | --- | @@ -13,10 +12,9 @@ broadcast. | `StopStopsPublishing` | A publisher who stopped the camera publishes nothing. | Holds. | | `DenialIsShown` | A publisher who refused the camera is told so. | Holds. | -The chart also shows that a camera lost after going live keeps the broadcast announced (by +A camera lost after going live keeps the broadcast announced (by design, so a capture gap only edits the catalog) while the badge says NO SOURCE, then CAMERA -FAILED once the reopen budget runs out. It hides "you stop the camera", which every selected -state has. +FAILED once the reopen budget runs out. ## Run @@ -24,8 +22,7 @@ state has. just test tla js/publish ``` -This must pass, as Nightly checks. The chart draws from -`Publish.tla`, `Publish.cfg`, and `Publish.view.ts`. +This must pass, as Nightly checks. ## Left out diff --git a/js/room/verify/README.md b/js/room/verify/README.md index e76fe7e6b99..1e8a1dac884 100644 --- a/js/room/verify/README.md +++ b/js/room/verify/README.md @@ -1,6 +1,6 @@ # Room flow -`Room.tla` is a TLA+ model of you and Bob in a room, written to be drawn as a statechart. +`Room.tla` is a TLA+ model of you and Bob in a room. Your side is `src/local.ts`: joining announces your camera broadcast, and a live screen share announces your screen broadcast while joined. Your view of Bob is `src/room.ts`: each of his announcements adds or removes one of his broadcasts, and your connection dropping removes him @@ -10,8 +10,8 @@ until the reconnect announces him again. | --- | --- | | `LeavingStopsPublishing` | Someone who has not joined the room, or has left it, publishes nothing to it. | -The chart also shows every participant leaving your screen while your connection is down and -coming back once it reconnects. +Every participant also leaves your screen while your connection is down and +comes back once it reconnects. ## Run @@ -19,8 +19,7 @@ coming back once it reconnects. just test tla js/room ``` -The chart draws from -`Room.tla`, `Room.cfg`, and `Room.view.ts`. `Room.cfg` plays only Bob's camera; add `"screen"` to +`Room.cfg` plays only Bob's camera; add `"screen"` to `Kinds` to play his share too. ## Left out diff --git a/js/room/verify/Room.cfg b/js/room/verify/Room.cfg index d58f2ae5945..85326a949e0 100644 --- a/js/room/verify/Room.cfg +++ b/js/room/verify/Room.cfg @@ -1,4 +1,4 @@ -\* Bob only joins and leaves, which keeps the chart readable; add "screen" to play his share too. +\* Bob only joins and leaves; add "screen" to play his share too. SPECIFICATION Spec CONSTANT Kinds = {"camera"} INVARIANT LeavingStopsPublishing diff --git a/js/room/verify/Room.view.ts b/js/room/verify/Room.view.ts deleted file mode 100644 index ea4382d8c26..00000000000 --- a/js/room/verify/Room.view.ts +++ /dev/null @@ -1,64 +0,0 @@ -// Statechart labels for Room.tla: what you publish, your connection, what Bob publishes, and -// what of Bob is on your screen. - -type Vars = { - joined: boolean; - sharing: boolean; - conn: "up" | "down"; - bob: string[]; - seen: string[]; -}; - -const broadcasts = (kinds: string[], none: string) => { - const camera = kinds.includes("camera"); - const screen = kinds.includes("screen"); - if (camera && screen) return "camera and screen"; - if (camera) return "camera"; - if (screen) return "screen only"; - return none; -}; - -const you = (v: Vars) => { - if (v.joined) return v.sharing ? "joined, sharing" : "joined"; - return v.sharing ? "not joined, sharing" : "not joined"; -}; - -export const title = "Joining and leaving a room"; - -export const state = (v: Vars) => ({ - You: you(v), - Connection: v.conn === "up" ? "connected" : "reconnecting", - Bob: broadcasts(v.bob, "not in the room"), - "Bob on your screen": broadcasts(v.seen, "absent"), -}); - -export const step = (action: string, from: Vars, to: Vars) => { - const started = to.bob.find((k) => !from.bob.includes(k)); - const ended = from.bob.find((k) => !to.bob.includes(k)); - const shown = to.seen.find((k) => !from.seen.includes(k)); - const hidden = from.seen.find((k) => !to.seen.includes(k)); - switch (action) { - case "Join": - return "you join"; - case "Leave": - return "you leave"; - case "Share": - return "you share your screen"; - case "StopSharing": - return "your share ends"; - case "Drop": - return "your connection drops"; - case "Reconnect": - return "you reconnect"; - case "BobStarts": - return started === "camera" ? "Bob joins" : "Bob shares his screen"; - case "BobEnds": - return ended === "camera" ? "Bob leaves" : "Bob's share ends"; - case "SeeStart": - return `Bob's ${shown} announcement arrives`; - case "SeeEnd": - return `Bob's ${hidden} end arrives`; - default: - return null; - } -}; diff --git a/js/watch/verify/Failover.view.ts b/js/watch/verify/Failover.view.ts deleted file mode 100644 index dbd8c49555e..00000000000 --- a/js/watch/verify/Failover.view.ts +++ /dev/null @@ -1,82 +0,0 @@ -// Statechart labels for Failover.tla: how many relays are up, where the viewer's connection -// is, whether the relays reach the origin, and what the viewer's screen shows. The two relays are -// alike, so labels name them by role ("your relay", "the other relay") rather than by number. - -type Vars = { - up: number[]; - on: number; - loop: "serving" | "migrating" | "dialing" | "waiting" | "stopped"; - pin: number; - path: "ok" | "lost"; - heard: boolean; - handle: boolean; - media: "playing" | "waiting"; -}; - -const relays = (up: number[]) => ["none up", "one up", "both up"][up.length]; - -const connection = (v: Vars) => { - switch (v.loop) { - case "serving": - return v.pin ? "on the relay it was sent to" : "on a relay"; - case "migrating": - return "on a leaving relay, dialing another"; - case "stopped": - return "stopped"; - default: - return v.pin ? "redialing only the relay it was sent to" : "redialing"; - } -}; - -const screen = (v: Vars) => { - if (v.handle) return v.media === "waiting" ? "spinner" : "playing"; - if (v.on && v.heard) return "OFFLINE"; - return v.loop === "stopped" ? "could not connect, and why" : "CONNECTING"; -}; - -export const title = "Relay failover, from the viewer's side"; - -export const state = (v: Vars) => ({ - Relays: relays(v.up), - Connection: connection(v), - Origin: v.path === "ok" ? "reachable" : "unreachable", - Screen: screen(v), -}); - -export const step = (action: string, from: Vars, to: Vars) => { - const gone = from.up.find((r) => !to.up.includes(r)); - switch (action) { - case "GoawayRestart": - return "your relay restarts and sends GOAWAY"; - case "GoawayTo": - return "your relay sends you to the other relay"; - case "GoawayRefused": - return "your relay sends you to another host"; - case "Replaced": - return "the replacement connects"; - case "HandoverEnds": - return "the handover ends first"; - case "Crash": - return gone === from.on ? "your relay crashes" : "the other relay crashes"; - case "Recover": - return "a relay comes back"; - case "BackoffEnds": - return null; - case "Connected": - return "the redial connects"; - case "DialFails": - return "the redial fails"; - case "Initial": - return "the relay's announcements arrive"; - case "Frames": - return "frames arrive"; - case "Reroute": - return "the relays move to another path to the origin"; - case "PathLost": - return "the relays lose the origin"; - case "PathBack": - return "the relays reach the origin again"; - default: - return null; - } -}; diff --git a/js/watch/verify/README.md b/js/watch/verify/README.md index 7beafa7580e..5e9e075fecd 100644 --- a/js/watch/verify/README.md +++ b/js/watch/verify/README.md @@ -1,6 +1,6 @@ # Watch flows -TLA+ models of two viewer flows, written to be drawn as statecharts. Each +TLA+ models of two viewer flows. Each models what the code does today, in the viewer's words, so a rule that breaks is a bug a viewer can hit. @@ -46,8 +46,7 @@ just test tla js/watch This runs every config, as Nightly does. `Watch.cfg` and `Failover.cfg` check the rules that hold and must pass; each rule that breaks has its own config, marked `\* Open finding:`, which must fail until the fix moves its rule into the passing one. A config checks the spec its name starts -with. A chart draws from the spec, a config, and its `.view.ts`; a -finding's config charts its break. +with. ## Left out diff --git a/js/watch/verify/Watch.view.ts b/js/watch/verify/Watch.view.ts deleted file mode 100644 index 3ff83d2b6f0..00000000000 --- a/js/watch/verify/Watch.view.ts +++ /dev/null @@ -1,51 +0,0 @@ -// Statechart labels for Watch.tla: the relay connection, the publisher, and what the -// viewer's screen shows, with each step as the viewer or the network makes it happen. - -type Vars = { - net: "connecting" | "connected" | "retrying" | "refused"; - heard: boolean; - live: boolean; - active: boolean; - status: "connecting" | "offline" | "loading" | "live" | "unsupported"; - media: "none" | "playing" | "stalled"; - paused: boolean; -}; - -const connection = { connecting: "dialing", connected: "connected", retrying: "waiting to redial", refused: "refused" }; - -const screen = (v: Vars) => { - if (v.net === "refused") return "could not connect, and why"; - if (v.status === "connecting") return "CONNECTING"; - if (v.status === "unsupported") return "UPDATE YOUR PLAYER"; - if (v.status === "offline") return "OFFLINE"; - if (v.paused) return "paused"; - if (v.status === "loading" || v.media !== "playing") return "spinner"; - return "playing"; -}; - -export const title = "Watching a broadcast"; - -export const state = (v: Vars) => ({ - Connection: connection[v.net], - Publisher: v.live ? "live" : "not live", - Screen: screen(v), -}); - -const steps: Record = { - Connect: "the connection opens", - DialFails: "a dial fails", - Redial: "the backoff ends", - Refused: "the relay refuses the token", - Initial: "the relay's announcements arrive", - Drop: "the connection drops", - Start: "the publisher goes live", - Stop: "the publisher stops", - CatalogArrives: "the catalog arrives", - CatalogTooNew: "the catalog needs a newer player", - Frames: "frames arrive", - Stall: "the video stalls", - Pause: "you pause", - Play: "you press play", -}; - -export const step = (action: string) => steps[action] ?? null; diff --git a/rs/moq-net/verify/reconnect/Handover.view.ts b/rs/moq-net/verify/reconnect/Handover.view.ts deleted file mode 100644 index 2c52dace93b..00000000000 --- a/rs/moq-net/verify/reconnect/Handover.view.ts +++ /dev/null @@ -1,121 +0,0 @@ -// Statechart labels for Handover.tla: what the connection handle reports, what -// the policy holds, and each step as the event that happens. - -type Sess = { ep: string; open: boolean; by: string; closing: boolean; goaway: string; age: number }; -type Vars = { - phase: string; - live: number; - pred: number; - probe: string; - target: string; - queue: Record; - sess: Record; - dial: string; - dialTo: string; - lc: string; - migrating: boolean; - misdials: number; -}; - -const at = (v: Vars, s: number) => v.sess[String(s)]; - -const goaway = (s: Sess) => - s.goaway === "-" ? "" : s.goaway === "" ? ", told to restart" : `, told to go to ${s.goaway}`; - -const session = (v: Vars, s: number, role: string) => { - if (s === 0) return null; - const x = at(v, s); - return `${role} on ${x.ep}${x.open ? "" : " (closed)"}${goaway(x)}`; -}; - -const handle = (v: Vars) => { - switch (v.lc) { - case "connecting": - return "Connecting"; - case "live": - return v.migrating ? "Migrating" : "Connected"; - case "offline": - return "Disconnected"; - default: - return "Closed"; - } -}; - -const policy = (v: Vars) => { - const doing = - v.phase === "start" - ? `about to dial ${v.target}` - : v.phase === "dialing" - ? `dialing ${v.dialTo}${v.dial === "handshake" ? " over the preferred transport" : ""}` - : v.phase === "backoff" - ? `backing off, next dial ${v.target}` - : v.phase === "done" - ? "gave up" - : null; - const parts = [session(v, v.live, "serving"), session(v, v.pred, "draining"), doing].filter(Boolean); - return parts.join("; "); -}; - -export const title = "A client connection across GOAWAY handovers and fallback probes"; - -export const state = (v: Vars) => ({ "The handle reports": handle(v), "The policy": policy(v) }); - -const changed = (from: Vars, to: Vars) => - Object.keys(to.sess).find((k) => JSON.stringify(from.sess[k]) !== JSON.stringify(to.sess[k])); - -export const step = (action: string, from: Vars, to: Vars) => { - switch (action) { - case "Pop": - return `the handle hears ${from.queue["1"] === "Offline" ? "that nothing serves" : from.queue["1"].toLowerCase()}`; - case "Retire": - return at(from, from.pred).open - ? "the old session overstays its handover" - : "the old session's close is noticed"; - case "IdleClose": - return "the old session, carrying nothing, starts closing"; - case "Dial": - return `the policy dials ${to.dialTo}`; - case "Abandon": - return "the dial times out"; - case "BackoffEnds": - return "the backoff ends"; - case "LiveEnds": { - const s = at(from, from.live); - if (to.phase === "live") return "the policy keeps serving through the restart"; - if (s.goaway !== "-") - return s.goaway === "" - ? "the policy migrates in place" - : `the policy follows the GOAWAY to ${s.goaway}`; - return "the policy sees the session closed"; - } - case "ProbeAsk": - return "the policy probes the preferred transport"; - case "ProbeAbandon": - return "the probe times out"; - case "Connected": - return `a session to ${from.dialTo} connects`; - case "Failed": - return to.phase === "done" ? "the dial fails for good" : "the dial fails"; - case "ProbeFails": - return "the probe fails"; - case "ProbeGetsThrough": - return to.phase === "dialing" - ? "the probe gets through, so the fallback drains" - : "the probe gets through, but a GOAWAY came first"; - case "Peer": { - const k = changed(from, to); - if (!k) return null; - const [a, b] = [from.sess[k], to.sess[k]]; - const who = Number(k) === from.live ? "the live session" : "the old session"; - if (a.goaway !== b.goaway) - return `the peer tells ${who} ${b.goaway === "" ? "to restart" : `to go to ${b.goaway}`}`; - if (a.open !== b.open) return `${who} closes`; - if (a.age !== b.age) return "the live session turns healthy"; - return "the old session stops carrying anything"; - } - case "Clock": - return "a deadline passes"; - default: - return null; - } -}; diff --git a/rs/moq-net/verify/resume/Chart.cfg b/rs/moq-net/verify/resume/Chart.cfg deleted file mode 100644 index cb1701bcb1b..00000000000 --- a/rs/moq-net/verify/resume/Chart.cfg +++ /dev/null @@ -1,22 +0,0 @@ -\* The failover story to chart (see `Story`): two groups, a second -\* route that comes up holding both, and one switch. Small enough to chart -\* whole; ResumeReader.cfg and ThreeRoutes.cfg do the checking. -CONSTANTS - G = 2 - MaxTracks = 2 - MaxSwitches = 1 - Hold = FALSE - -SPECIFICATION Spec - -CONSTRAINT - Story - -INVARIANTS - OnceEach - CleanEndIsComplete - EndWaitsForReplaced - CleanEndIsDeclared - FailsOnlyUnroutable - QuietIsSettled - CopiesBounded diff --git a/rs/moq-net/verify/resume/ResumeReader.tla b/rs/moq-net/verify/resume/ResumeReader.tla index 3c872f0332c..a58b67472b8 100644 --- a/rs/moq-net/verify/resume/ResumeReader.tla +++ b/rs/moq-net/verify/resume/ResumeReader.tla @@ -482,15 +482,6 @@ CopiesBounded == Cardinality({i \in 1 .. Len(rd.copies) : rd.copies[i].t = t /\ rd.copies[i].done = "no"}) <= 2 -\* Chart.cfg's story: route 1 carries only the newest group -\* and route 2 lands every group newest first, with no route failing, so a -\* switch has to ask route 2 for the older group. -Story == - /\ Landed(1) \subseteq {G - 1} - /\ \A t \in Tracks : ~trk[t].failed - /\ ~trk[1].fin - /\ \A i \in 1 .. Len(trk[2].arr) : trk[2].arr[i] = G - i - TypeOK == /\ rd.ended \in {"no", "ok", "err"} /\ rd.dlv \subseteq Groups diff --git a/rs/moq-net/verify/resume/ResumeReader.view.ts b/rs/moq-net/verify/resume/ResumeReader.view.ts deleted file mode 100644 index a7099dbb839..00000000000 --- a/rs/moq-net/verify/resume/ResumeReader.view.ts +++ /dev/null @@ -1,76 +0,0 @@ -// Statechart labels for ResumeReader.tla: which route the front serves, -// what the reader holds, and each step as what happens to a route or the reader. - -type Copy = { t: number; rep: boolean }; -type Track = { made: boolean; failed: boolean; fin: boolean; arr: Record }; -type Vars = { - trk: Record; - front: { cur: number; end: string }; - rd: { dlv: number[]; ended: string; copies: Record }; -}; - -const groups = (v: Vars) => [...v.rd.dlv].sort((a, b) => a - b); - -const routes = (v: Vars) => { - if (v.front.end === "ok") return "track declared over"; - if (v.front.end === "err") return "no route left"; - const what = (t: Track) => (t.failed ? "failed" : t.fin ? "complete" : "up"); - const serving = v.trk[String(v.front.cur)]; - const others = Object.entries(v.trk) - .filter(([k, t]) => t.made && k !== String(v.front.cur)) - .map(([k, t]) => `route ${k} ${what(t)}`); - const head = `route ${v.front.cur} serves${serving.fin ? ", complete" : ""}`; - return [head, ...others].join("; "); -}; - -const reader = (v: Vars) => { - const has = groups(v); - const held = has.length ? `has ${has.join(", ")}` : "has nothing"; - if (v.rd.ended === "ok") return `ended cleanly, ${held}`; - if (v.rd.ended === "err") return `failed, ${held}`; - const copies = Object.values(v.rd.copies); - const old = copies.filter((c) => c.rep).length; - return old ? `${held}, still reading ${old} older cop${old === 1 ? "y" : "ies"}` : held; -}; - -export const title = "One reader of a track served across route changes"; - -export const state = (v: Vars) => ({ Front: routes(v), Reader: reader(v) }); - -const len = (r: Record) => Object.keys(r).length; - -export const step = (action: string, from: Vars, to: Vars) => { - const changed = Object.keys(to.trk).find((k) => JSON.stringify(to.trk[k]) !== JSON.stringify(from.trk[k])); - switch (action) { - case "Up": - return `route ${changed} comes up`; - case "Down": - return `route ${changed} fails`; - case "Land": { - const t = to.trk[changed ?? ""]; - return `group ${t.arr[String(len(t.arr))]} lands on route ${changed}`; - } - case "Finish": - return `route ${changed} declares the end`; - case "Serve": - return `the front switches to route ${to.front.cur}`; - case "FrontFinish": - return "a route the front served completed"; - case "FrontFail": - return "the front gives up"; - case "Read": { - const got = to.rd.dlv.find((g) => !from.rd.dlv.includes(g)); - if (got !== undefined) return `the reader gets group ${got}`; - if (to.rd.ended !== from.rd.ended) return "the reader reads the end"; - const before = len(from.rd.copies); - const after = len(to.rd.copies); - if (after > before) return "the reader asks the serving route for an older group it lacks"; - if (after < before) return "the reader lets an older copy go"; - return "the reader polls"; - } - case "Drop": - return "the reader finishes a group"; - default: - return null; - } -}; diff --git a/rs/moq-net/verify/route/RouteHandoff.view.ts b/rs/moq-net/verify/route/RouteHandoff.view.ts deleted file mode 100644 index 9e7c1f03afa..00000000000 --- a/rs/moq-net/verify/route/RouteHandoff.view.ts +++ /dev/null @@ -1,110 +0,0 @@ -// Statechart labels for RouteHandoff.tla: each relay's routes and what its -// reader shows, and each step as the message that arrives. - -// A sequence, such as a path, is keyed from 1; a hop is <>. -type Hop = Record; -type Path = Record; -type Route = { on: boolean; held: boolean; next: number; path: Path }; -type Node = { - rt: Record; - doubt: number[]; - wait: number[]; - shown: Record; -}; -type Msg = { t: string; k: string; path: Path; hop: Hop; gone: boolean }; -type Vars = { - st: Record; - q: Record>; - up: number[][]; - burst: number; - churn: number; -}; - -const ORIGIN = "0"; -const name = (n: string | number) => (String(n) === ORIGIN ? "the publisher" : `relay ${n}`); -const hops = (path: Path) => Object.keys(path).length - 1; - -const route = (key: string, r: Route) => { - if (!r.on) return null; - if (r.held) return `${key} held${r.next >= 0 ? ` under ${name(r.next)}` : ""}`; - const n = hops(r.path); - return `${key} via ${name(r.next)}, ${n} hop${n === 1 ? "" : "s"}`; -}; - -const relay = (s: Node) => { - const routes = Object.entries(s.rt) - .map(([key, r]) => route(key === "root" ? "root" : `"${key}"`, r)) - .filter((r) => r !== null); - const shows = Object.entries(s.shown) - .filter(([, x]) => x.item >= 0) - .map(([c, x]) => `${c} item ${x.item}${x.avail ? "" : " (unavailable)"}`); - const doubt = s.doubt.length ? `, doubts ${s.doubt.map(name).join(" and ")}` : ""; - // A doubt no route names any more is forgotten before its timer fires. - const timers = s.wait.filter((x) => !s.doubt.includes(x)); - const wait = timers.length ? `, timer running on ${timers.map(name).join(" and ")}` : ""; - return `${routes.join("; ") || "no route"}${shows.length ? `, shows ${shows.join(", ")}` : ""}${doubt}${wait}`; -}; - -const sessions = (v: Vars) => - v.up - .map((l) => [...l].sort((a, b) => a - b).join("–")) - .sort() - .join(", ") || "none"; - -export const title = "One publisher's routes across a mesh of relays"; - -export const state = (v: Vars) => ({ - "Open sessions": sessions(v), - ...Object.fromEntries( - Object.keys(v.st) - .filter((n) => n !== ORIGIN) - .map((n) => [`Relay ${n}`, relay(v.st[n])]), - ), - "Messages this burst": `${v.burst} for ${v.churn} change${v.churn === 1 ? "" : "s"}`, -}); - -const len = (s: Record | undefined) => (s ? Object.keys(s).length : 0); - -// A queue key `<>` is a tuple, keyed from 1. -const ends = (key: string | undefined) => { - const tuple = key ? JSON.parse(key) : {}; - return [tuple["1"] ?? "?", tuple["2"] ?? "?"]; -}; - -export const step = (action: string, from: Vars, to: Vars) => { - switch (action) { - case "Announce": - return "the publisher announces a claim"; - case "Unannounce": - return "the publisher withdraws a claim"; - case "Connect": - case "Disconnect": { - const before = new Set(from.up.map((l) => [...l].sort().join("–"))); - const after = new Set(to.up.map((l) => [...l].sort().join("–"))); - const changed = [...before, ...after].find((l) => before.has(l) !== after.has(l)); - return `the ${changed} session ${action === "Connect" ? "opens" : "closes"}`; - } - case "Lift": { - const n = Object.keys(from.st).find((k) => len(to.st[k].doubt) < len(from.st[k].doubt)); - return n ? `${name(n)}'s timer fires and its doubt lifts` : "a timer fires"; - } - case "Deliver": { - const d = Object.keys(from.q).find((k) => len(to.q[k]) === len(from.q[k]) - 1); - const [m, n] = ends(d); - const msg = from.q[d ?? ""]?.["1"]; - if (!msg) return "a message arrives"; - const key = msg.k === "root" ? "root" : `"${msg.k}"`; - const what = - msg.t === "dead" - ? `news that ${name(msg.hop["1"])}'s session to ${name(msg.hop["2"])} closed${msg.gone ? ", and its routes through it end" : ""}` - : msg.t === "offer" - ? `${key} route (${hops(msg.path)} hop${hops(msg.path) === 1 ? "" : "s"})` - : msg.t === "claims" - ? `${key} claims` - : `${key} route ${msg.t}`; - return `${name(m)}'s ${what} reaches ${name(n)}`; - } - default: - return null; - } -}; diff --git a/rs/moq-net/verify/subscribe/SubscribeAccounting.view.ts b/rs/moq-net/verify/subscribe/SubscribeAccounting.view.ts deleted file mode 100644 index 25ba21cea47..00000000000 --- a/rs/moq-net/verify/subscribe/SubscribeAccounting.view.ts +++ /dev/null @@ -1,109 +0,0 @@ -// Statechart labels for SubscribeAccounting.tla: what each side holds for the -// group, which update each side is on, and each step as the event that happens. - -type Stream = { g: number; pub: string; err: string; wasFin: boolean; sub: string }; -type Msg = { type: string; g: number; err: string; u: number }; -type Vars = { - cur: Record; - streams: Record; - reoffered: number[]; - redrop: number[]; - resp: Record; - sup: number; - pup: number; - acct: number[]; - rec: Record; - cached: Record; - got: number[]; -}; - -const list = (seq: Record | undefined) => Object.values(seq ?? {}); - -const publisher = (v: Vars) => { - const last = list(v.streams).at(-1); - const base = last - ? { - open: "serving", - fin: "FIN sent, unacknowledged", - acked: "served, acknowledged", - reset: last.err === "old" ? "stream reset as stale" : "stream reset", - }[last.pub] - : { pending: "nothing sent", stale: "named stale", final: "named dropped", skip: "named skipped" }[v.cur["0"]]; - const next = v.reoffered.length ? ", to serve again" : v.redrop.length ? ", to drop again" : ""; - return `${base}${next}`; -}; - -const subscriber = (v: Vars) => { - const got = v.got.length > 0; - const base = { - none: "nothing yet", - open: "receiving", - whole: "has it whole", - aborted: "reset mid-group", - evicted: got ? "had it whole, evicted" : "evicted", - }[v.cached["0"]]; - const rec = { none: "", stale: ", recorded stale", final: ", recorded dropped", skip: ", recorded skipped" }[ - v.rec["0"] - ]; - const owed = v.acct.length ? "" : ", owed"; - return `${base}${rec}${owed}`; -}; - -export const title = "One lite-07 group: Group Streams, drops, and updates"; - -export const state = (v: Vars) => ({ - Publisher: publisher(v), - Subscriber: subscriber(v), - Updates: v.sup === v.pup ? `on update ${v.sup}` : `update ${v.sup} sent, publisher on ${v.pup}`, -}); - -export const step = (action: string, from: Vars, to: Vars) => { - switch (action) { - case "CursorHand": - return "the publisher serves the group"; - case "CursorGiveUp": - return { - stale: "the publisher gives the group up as stale", - final: "the publisher drops the group", - skip: "the publisher skips the group", - }[to.cur["0"]]; - case "StreamFin": - return "the publisher writes the FIN"; - case "StreamFail": { - const failed = list(to.streams).find((s, i) => s.pub === "reset" && list(from.streams)[i]?.pub !== "reset"); - return failed?.err === "old" ? "the group goes stale and its stream resets" : "the stream fails and resets"; - } - case "StreamAck": - return "the publisher's FIN is acknowledged"; - case "PubOutcomes": - return "the publisher names the reset stream in a drop"; - case "PubRedrop": - return "the publisher drops it again"; - case "PubReoffer": - return "the publisher serves it again"; - case "PubUpdate": - return "the update reaches the publisher"; - case "PubFold": - return "the publisher's record folds the group under the pool's debt"; - case "TailFold": - return "the subscriber's tail forgets the group finished, under the pool's debt"; - case "SubHeader": - return "a Group Stream's header arrives"; - case "SubFin": - return "the subscriber reads the stream to its FIN"; - case "SubReset": - case "SubResetHeld": - return "the stream's reset arrives"; - case "Evict": - return "the subscriber's cache evicts the group"; - case "SubRecv": { - const msg = from.resp["1"]; - if (msg.type === "skip") return "a skip arrives"; - return msg.err === "old" ? `a stale drop under update ${msg.u} arrives` : "a drop arrives"; - } - case "SubUpdate": - return "the subscriber sends an update"; - default: - return null; - } -};