The cable inspector prints the engine's verdict instead of asserting one (#1303) #1304

Merged
jaylouisw merged 1 commit from fix/cable-verdict into main 2026-11-10 00:22:52 +00:00
Owner

The cable inspector prints the engine's verdict instead of asserting one.

Fixes #1303.

The lie

For every cable, unconditionally, the inspector said:

Cages mate and the media is supported at both ends — this cable passed the physical-layer check when it was
created. An impossible combination is refused at that moment, not silently accepted.

Nothing computed that. It was a sentence in the renderer.

And there is a path that produces a cable nobody ever checked: POST /topologies/:id/load swaps a whole document
in with no validation at all (Topology.fromJSON(body), straight into the map). A hand-edited file, or one
written before a physical-layer rule existed, carried an impossible cable through the UI wearing the same confident
sentence as a good one — while validateTopology() had the exact answer available and, by its own comment,
"nothing but tests ever called it".

Measured: a document whose only cable claims 10gbase-sr between two Aruba CX 6000 RJ45 ports loads silently. The
engine's verdict it never showed anyone:

E_MEDIA_NOT_SUPPORTED: 10GBASE-SR (10gbase-sr) is not supported by both Aruba CX 6000 24G 4SFP (R8N88A)/1/1/1
and Aruba CX 6000 24G 4SFP (R8N88A)/1/1/1; possible media: 10BASE-T, 100BASE-TX, 1000BASE-T.

A 5 km copper run (1000BASE-T reaches 100 m) loads the same way.

After

  • server/index.js runs validateTopology(topo) when it builds a state payload, so state.verdicts carries
    {ok, errorCount, warningCount, byLink, issues} — one verdict per cable, filed under the cable that caused
    it
    , so a panel with one cable selected does not filter the whole lab on every render;
  • the inspector prints the engine's message for the selected cable in a red .verdict.bad box; a good cable says
    "checked by the engine, not assumed by this panel";
  • loading still takes the document as written — an imported lab has to be fixable in place — but the response
    carries the verdict and the UI says Imported, but 1 cable cannot be used instead of Topology imported;
  • a payload with no verdict at all reads This cable has not been checked, never the reassuring sentence;
  • an issue with no linkId (a lab-level problem) is not hidden by the per-cable filter, or the panel would
    report a clean cable inside a broken lab.

Evidence

test/cable-verdict.test.js — 20 checks.

Server half, over real HTTP against a spawned server on a scratch data directory (probing readiness with a real
request, not a log line): an empty board still carries a checked verdict object; a good document loads with zero
errors; an impossible one loads with errorCount 1 and E_MEDIA_NOT_SUPPORTED; the state anyone reads afterwards
agrees and files the issue against the cable; and an over-length run is flagged at load time.

Panel half, loading faceplate.js then app.js the way index.html does: the old sentence is gone; a good
cable names who checked it; an impossible one is painted as a fault with the engine's message; an over-length run
is reported; an unannotated payload says not checked; and a lab-level issue reaches a selected cable.

With web/app.js reverted, 8 of the 20 fail (the old sentence comes back verbatim). With server/index.js
reverted, 11 of the 20 fail (no verdicts anywhere).

test/ui-render.test.js asserted the old sentence — it now asserts the new contract. docs/CONNECTORS.md
explains that validateTopology() is called at runtime, and why.

Suite: 167 suites, 6,817 assertions, 0 failed.

The cable inspector prints the engine's verdict instead of asserting one. Fixes #1303. ## The lie For **every** cable, unconditionally, the inspector said: > Cages mate and the media is supported at both ends — this cable passed the physical-layer check when it was > created. An impossible combination is refused at that moment, not silently accepted. Nothing computed that. It was a sentence in the renderer. And there is a path that produces a cable nobody ever checked: `POST /topologies/:id/load` swaps a whole document in with **no validation at all** (`Topology.fromJSON(body)`, straight into the map). A hand-edited file, or one written before a physical-layer rule existed, carried an impossible cable through the UI wearing the same confident sentence as a good one — while `validateTopology()` had the exact answer available and, by its own comment, *"nothing but tests ever called it"*. Measured: a document whose only cable claims `10gbase-sr` between two Aruba CX 6000 RJ45 ports loads silently. The engine's verdict it never showed anyone: ``` E_MEDIA_NOT_SUPPORTED: 10GBASE-SR (10gbase-sr) is not supported by both Aruba CX 6000 24G 4SFP (R8N88A)/1/1/1 and Aruba CX 6000 24G 4SFP (R8N88A)/1/1/1; possible media: 10BASE-T, 100BASE-TX, 1000BASE-T. ``` A 5 km copper run (`1000BASE-T` reaches 100 m) loads the same way. ## After * `server/index.js` runs `validateTopology(topo)` when it builds a state payload, so `state.verdicts` carries `{ok, errorCount, warningCount, byLink, issues}` — one verdict per cable, **filed under the cable that caused it**, so a panel with one cable selected does not filter the whole lab on every render; * the inspector prints the engine's message for the selected cable in a red `.verdict.bad` box; a good cable says *"checked by the engine, not assumed by this panel"*; * loading still takes the document as written — an imported lab has to be fixable in place — but the response carries the verdict and the UI says `Imported, but 1 cable cannot be used` instead of `Topology imported`; * a payload with no verdict at all reads `This cable has not been checked`, never the reassuring sentence; * an issue with **no** `linkId` (a lab-level problem) is not hidden by the per-cable filter, or the panel would report a clean cable inside a broken lab. ## Evidence `test/cable-verdict.test.js` — 20 checks. **Server half, over real HTTP** against a spawned server on a scratch data directory (probing readiness with a real request, not a log line): an empty board still carries a checked verdict object; a good document loads with zero errors; an impossible one loads with `errorCount 1` and `E_MEDIA_NOT_SUPPORTED`; the state anyone reads afterwards agrees and files the issue against the cable; and an over-length run is flagged at load time. **Panel half**, loading `faceplate.js` then `app.js` the way `index.html` does: the old sentence is gone; a good cable names who checked it; an impossible one is painted as a fault with the engine's message; an over-length run is reported; an unannotated payload says `not checked`; and a lab-level issue reaches a selected cable. With `web/app.js` reverted, **8 of the 20 fail** (the old sentence comes back verbatim). With `server/index.js` reverted, **11 of the 20 fail** (no verdicts anywhere). `test/ui-render.test.js` asserted the old sentence — it now asserts the new contract. `docs/CONNECTORS.md` explains that `validateTopology()` is called at runtime, and why. Suite: 167 suites, 6,817 assertions, 0 failed.
The cable inspector prints the engine's verdict instead of asserting one (#1303)
Some checks failed
CI / Classify the change (pull_request) Successful in 15s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 19s
CI / Test (Node 20) (pull_request) Failing after 2m15s
CI / Test (Node 18) (pull_request) Successful in 2m25s
CI / Server smoke test (pull_request) Successful in 30s
CI / Docker build (pull_request) Successful in 41s
CI / Test (Node 22) (pull_request) Successful in 1m55s
4be9f51d00
For every cable, unconditionally, the cable inspector said:

  "Cages mate and the media is supported at both ends - this cable passed the physical-layer check when it was
   created. An impossible combination is refused at that moment, not silently accepted."

Nothing computed that; it was a sentence in the renderer. And there is a path that produces a cable nobody ever
checked: POST /topologies/:id/load swaps a whole document in with no validation at all (Topology.fromJSON(body),
straight into the map). A hand-edited file, or one written before a physical-layer rule existed, carried an
impossible cable through the UI wearing the same confident sentence as a good one - while validateTopology() had
the exact answer available and, by its own comment, "nothing but tests ever called it".

Measured: a document whose only cable claims 10gbase-sr between two Aruba CX 6000 RJ45 ports loads silently, and
the engine's verdict for it is E_MEDIA_NOT_SUPPORTED, naming both ends and the media that would work. A 5 km
copper run (1000BASE-T reaches 100 m) loads the same way.

  * server/index.js runs validateTopology(topo) when it builds a state payload, so state.verdicts carries
    {ok, errorCount, warningCount, byLink, issues} - one verdict per cable, filed under the cable that caused it,
    so a panel with one cable selected does not filter the whole lab on every render;
  * the inspector prints the engine's message for the selected cable in a red .verdict.bad box, and a good cable
    says "checked by the engine, not assumed by this panel";
  * loading still takes the document as written - an imported lab has to be fixable in place - but the response
    carries the verdict and the UI says "Imported, but 1 cable cannot be used" instead of "Topology imported";
  * a payload with no verdict at all reads "This cable has not been checked", never the reassuring sentence;
  * an issue with no linkId (a lab-level problem) is not hidden by the per-cable filter, or the panel would report
    a clean cable inside a broken lab.

test/cable-verdict.test.js: 20 checks. The server half runs over real HTTP against a scratch data directory
(spawned, probed, killed): an empty board still carries a checked verdict object; a good document loads with zero
errors; an impossible one loads with errorCount 1 and E_MEDIA_NOT_SUPPORTED; the state anyone reads afterwards
agrees; the issue is filed against the cable; and an over-length run is flagged at load time. The panel half loads
faceplate.js then app.js the way index.html does and asserts the old sentence is gone, a good cable names who
checked it, an impossible one is painted as a fault with the engine's message, an over-length run is reported, an
unannotated payload says "not checked", and a lab-level issue reaches a selected cable.

With web/app.js reverted, 8 of the 20 fail (the old sentence comes back verbatim). With server/index.js reverted,
11 of the 20 fail (no verdicts anywhere).

test/ui-render.test.js asserted the old sentence; it now asserts the new contract - not checked, and never an
assumption. docs/CONNECTORS.md explains that validateTopology() is called at runtime, and why.

Suite: 167 suites, 6,817 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-10 00:22:48 +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!1304
No description provided.