The console over HTTP is the same console (#1336) #1337

Merged
jaylouisw merged 1 commit from fix/console-over-http into main 2026-11-10 11:21:30 +00:00
Owner

The console over HTTP is the same console.

Fixes #1336.

POST /api/topologies/:id/config/:devId ran the console on new Simulator(topo) — a second accounting, with its own
flow state — and took no instant at all. Three consequences, all measured over HTTP.

1. One board, two sets of counters.

POST /flows {bytes: 100}                     -> payload: ports.eth0 = 4 packets in, 114 bytes / 5 out, 209 bytes
POST /config/host {'show interfaces eth0'}   -> "0 packets input, 0 bytes" ... "0 packets output, 0 bytes"

2. Every console answer was given at Infinity. The cable endpoint takes atMs and reports a schedule, so the API
could report a lab mid-convergence and could not ask the console about it.

3. show spanning-tree printed dev.stp, which is written by whichever simulator computed it last. After a cable
was cut at 20000, a console asked at 25000 printed 1/1/1 designated forwarding — the port was still listening.

Fixes

  • the session is built on simForFlows(topo), so the console and the payload share one accounting;
  • :config takes atMs, applying it to the session's simulator on every request (not only when supplied, so a
    cached session cannot pin a later caller to an instant it did not ask for), and answers with runAtMs (null when
    the question was "once everything has settled") and convergence;
  • show spanning-tree recomputes the tree at the attached simulator's instant before reading it.

Evidence

test/console-over-http.test.js — 12 checks. The counters the console prints are the counters the payload
publishes, in both directions (equal, not similar); an answer with no instant says so and carries a convergence
schedule like every other mutation; asked at 25000 it says so; after a cable cut at 20000, show spanning-tree at
25000 says the port is still coming up, and with no instant says it forwards, with the answer reporting when the board
last changed; and two requests in the same cached session with different instants answer differently.

With server/index.js and engine/cli.js reverted, 6 of the 12 fail: "0 packets input, 0 bytes" against a
payload of 4 packets and 114 bytes, no runAtMs or convergence in the answer, and a port still listening reported
as forwarding.

Suite run twice on this branch: 183 suites, 7,115 assertions, 0 failed both times (253.5 s, 252.7 s).

docs/ARCHITECTURE.md: "The console over HTTP".

The console over HTTP is the same console. Fixes #1336. `POST /api/topologies/:id/config/:devId` ran the console on `new Simulator(topo)` — a second accounting, with its own flow state — and took no instant at all. Three consequences, all measured over HTTP. **1. One board, two sets of counters.** ``` POST /flows {bytes: 100} -> payload: ports.eth0 = 4 packets in, 114 bytes / 5 out, 209 bytes POST /config/host {'show interfaces eth0'} -> "0 packets input, 0 bytes" ... "0 packets output, 0 bytes" ``` **2. Every console answer was given at `Infinity`.** The cable endpoint takes `atMs` and reports a schedule, so the API could report a lab mid-convergence and could not ask the console about it. **3. `show spanning-tree` printed `dev.stp`,** which is written by whichever simulator computed it last. After a cable was cut at 20000, a console asked at 25000 printed `1/1/1 designated forwarding` — the port was still listening. ## Fixes * the session is built on `simForFlows(topo)`, so the console and the payload share one accounting; * `:config` takes `atMs`, applying it to the session's simulator on **every** request (not only when supplied, so a cached session cannot pin a later caller to an instant it did not ask for), and answers with `runAtMs` (`null` when the question was "once everything has settled") and `convergence`; * `show spanning-tree` recomputes the tree at the attached simulator's instant before reading it. ## Evidence `test/console-over-http.test.js` — **12 checks**. The counters the console prints are the counters the payload publishes, in both directions (**equal**, not similar); an answer with no instant says so and carries a convergence schedule like every other mutation; asked at 25000 it says so; after a cable cut at 20000, `show spanning-tree` at 25000 says the port is still coming up, and with no instant says it forwards, with the answer reporting when the board last changed; and two requests in the same cached session with different instants answer differently. With `server/index.js` and `engine/cli.js` reverted, **6 of the 12 fail**: "0 packets input, 0 bytes" against a payload of 4 packets and 114 bytes, no `runAtMs` or `convergence` in the answer, and a port still listening reported as forwarding. Suite run twice on this branch: 183 suites, 7,115 assertions, 0 failed both times (253.5 s, 252.7 s). `docs/ARCHITECTURE.md`: "The console over HTTP".
The console over HTTP is the same console (#1335)
All checks were successful
CI / Classify the change (pull_request) Successful in 11s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 14s
CI / Test (Node 20) (pull_request) Successful in 2m31s
CI / Test (Node 18) (pull_request) Successful in 2m39s
CI / Server smoke test (pull_request) Successful in 34s
CI / Docker build (pull_request) Successful in 39s
CI / Test (Node 22) (pull_request) Successful in 2m19s
4c0dbf8138
POST /api/topologies/:id/config/:devId ran the console on `new Simulator(topo)` - a second accounting, with its own
flow state - and it took no instant at all. Three consequences, all measured over HTTP.

1. One board, two sets of counters. A flow opened through /flows counted 4 packets and 114 bytes into the topology's
   flow state; the console, asked `show interfaces eth0`, printed "0 packets input, 0 bytes" - and traffic the console
   generated was invisible to the payload in the same way.

2. Every console answer was given at Infinity. The cable endpoint takes `atMs` and reports a convergence schedule, so
   the API could say "this lab is mid-convergence" and simultaneously could not ask the console about it.

3. `show spanning-tree` printed `dev.stp`, which is written by whichever Simulator computed it last. A console asked
   at instant 25000 - after a cable was cut at 20000 - printed the tree from an earlier pass at Infinity and called a
   port that was still listening "forwarding".

Fixes:

  * the session is built on simForFlows(topo), so the console and the payload share one accounting;
  * /config takes `atMs`, applying it to the session's simulator on every request (not only when supplied, so a
    cached session cannot pin a later caller to an instant it did not ask for), and answers with `runAtMs` (null when
    the question was "once everything has settled") and `convergence`;
  * show spanning-tree recomputes the tree at the attached simulator's instant before reading it.

test/console-over-http.test.js: 12 checks. The counters the console prints are the counters the payload publishes, in
both directions (not similar - equal); an answer with no instant says so and carries a convergence schedule like every
other mutation; asked at 25000 it says so; after a cable cut at 20000, show spanning-tree at 25000 says the port is
still coming up and with no instant says it forwards, and the answer reports when the board last changed; and two
requests in the same cached session with different instants answer differently.

With server/index.js and engine/cli.js reverted, 6 of the 12 fail: "0 packets input, 0 bytes" against a payload of 4
packets and 114 bytes, no runAtMs or convergence in the answer, and a port still listening reported as forwarding.

docs/ARCHITECTURE.md: "The console over HTTP".

Suite: 183 suites, 7,115 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-10 11:21:25 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge!1337
No description provided.