A saved lab reopens with its conversations still in it (#1435) #1436

Merged
jaylouisw merged 1 commit from fix/flows-survive-save-load into main 2026-11-11 18:35:29 +00:00
Owner

Closes #1435.

The flow table lives on the topology — runtime state of the board — but serialize() never wrote it and fromJSON() never read it. A lab with an established TCP flow, saved and reopened, came back with an empty flow table: the reloaded board said nothing was connected while the saved document said a conversation existed.

Fixed

  • serialize() writes flows (id, state, hops, counters) with the board;
  • fromJSON() restores them — same id, same state, same hops, so a later removal still knows the path;
  • the id allocator advances past any restored flow-N, so the next flow cannot collide;
  • a document carrying a flow whose endpoints are not on the board is refused the flow, not the board — reported in loadIssues (E_FLOW_GHOST_ENDPOINT, naming the flow and the missing endpoints), exactly like an unrestorable cable, and the board still opens;
  • a board with no flows serializes flows: [], not a missing key;
  • example labs regenerated (npm run examples) since they now carry flows: [].

Evidence — 16 checks

test/flows-survive-save-load.test.js: the round trip (same id, state, hops), no id collision, ghost endpoints reported and dropped while the board opens, a no-id record reported, and the empty-list case. Reverting engine/topology.js fails the serialize assertion (and crashes the restored path on the missing flowState).

Suite: 218 suites, 8,176 assertions, 0 failed; syntax 286 files OK. Docs: docs/ARCHITECTURE.md, "A saved lab reopens with its conversations still in it".

Closes #1435. The flow table lives on the topology — runtime state of the board — but `serialize()` never wrote it and `fromJSON()` never read it. A lab with an established TCP flow, saved and reopened, came back with an **empty flow table**: the reloaded board said nothing was connected while the saved document said a conversation existed. ### Fixed - `serialize()` writes **`flows`** (id, state, **hops**, counters) with the board; - `fromJSON()` restores them — same id, same state, same hops, so a later removal still knows the path; - the id allocator advances past any restored `flow-N`, so the next flow cannot collide; - a document carrying a flow whose endpoints are **not on the board** is refused the flow, not the board — reported in `loadIssues` (`E_FLOW_GHOST_ENDPOINT`, naming the flow and the missing endpoints), exactly like an unrestorable cable, and the board still opens; - a board with no flows serializes `flows: []`, not a missing key; - example labs regenerated (`npm run examples`) since they now carry `flows: []`. ### Evidence — 16 checks `test/flows-survive-save-load.test.js`: the round trip (same id, state, hops), no id collision, ghost endpoints reported and dropped while the board opens, a no-id record reported, and the empty-list case. Reverting `engine/topology.js` fails the serialize assertion (and crashes the restored path on the missing `flowState`). Suite: **218 suites, 8,176 assertions, 0 failed**; syntax 286 files OK. Docs: `docs/ARCHITECTURE.md`, "A saved lab reopens with its conversations still in it".
A saved lab reopens with its conversations still in it (#1435)
Some checks failed
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 13s
CI / Classify the change (pull_request) Successful in 20s
CI / Test (Node 18) (pull_request) Successful in 3m30s
CI / Test (Node 20) (pull_request) Successful in 3m26s
CI / Test (Node 22) (pull_request) Failing after 52s
CI / Server smoke test (pull_request) Successful in 2m0s
CI / Docker build (pull_request) Successful in 5m19s
c9dad5c239
The flow table lives on the topology, so it is runtime state of the board - but serialize() never wrote it and fromJSON() never read it. A lab with an established TCP flow, saved and reopened, came back with an empty flow table: the reloaded board said nothing was connected while the document said a conversation existed. One more surface that had the fact and one that did not.

Now serialize() writes flows (id, state, hops, counters) with the board, and fromJSON() restores them. A document carrying a flow whose endpoints are not on the board is refused the flow, not the board - reported in loadIssues (E_FLOW_GHOST_ENDPOINT, naming the flow and the missing endpoints), like a cable that cannot be restored, and the board still opens. The id allocator is advanced past any restored flow-N so the next flow cannot collide. Example labs regenerated (they now carry flows: []).

Evidence: test/flows-survive-save-load.test.js, 16 checks - the round trip (same id, state, hops), no id collision, ghost endpoints reported and dropped while the board opens, and an empty board serializing flows: [] rather than omitting the key. Reverting engine/topology.js fails the serialize assertion (the restored run crashes on the missing flowState). Suite: 218 suites, 8,176 assertions, 0 failed; syntax 286 files OK.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-11 18:35: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!1436
No description provided.