The inspector header counts what can carry, not what is enabled (#1299) #1300

Merged
jaylouisw merged 1 commit from fix/inspector-port-count into main 2026-11-09 23:45:53 +00:00
Owner

The inspector header counts ports that can carry, not ports that are enabled.

Fixes #1299.

The defect

renderDeviceTab() drew 28 ports · 28 up on a switch with nothing plugged in — the count was of enabled
and the word was "up". Two lines above, the front panel painted every socket notconnect, and the console said
down (no cable) for all 28. Three surfaces, two answers, and the wrong one was the summary: the single line
people read.

Worse than the empty case — it also counted as up a port whose peer had shut down (down (peer shut down), the
top cause of "the link is up but nothing passes") and a port whose cable had been taken down (down (link down)); and it dropped shut ports from the accounting instead of naming them, so 28 ports · 27 up told you
neither that 27 were dead nor that one was administratively down.

Measured before the fix — panel vs show ip interface brief on a CX 6000:

situation panel console
nothing plugged in 28 up 0 up
one cable to a live peer 28 up 1 up
cable to a peer whose port is shut 28 up 0 up
cable whose link was taken down 28 up 0 up
one cabled port shut down 27 up 0 up
a router with one live cable 3 up 1 up

The rule already existed and every other surface used it (PFFaceplate.portState / portVerdict, #1238). The
header was the one place that re-derived the answer.

After

28 ports · 1 up · 27 down (no cable)
28 ports · 0 up · 27 down (no cable) · 1 down (link down)
28 ports · 0 up · 27 down (no cable) · 1 administratively down
  • the count comes from the same portVerdict() the rows, faceplate, tooltip and status bar use;
  • every port that is not up is accounted for by the reason the console prints, in the console's own words, so the
    summary cannot disagree with the rows under it;
  • at most four segments — a summary that needs five is a table;
  • with the state rule absent (faceplate.js failed to load) the header says unknown (no state rule loaded)
    instead of falling back to enabled, the guess that caused this.

Evidence

test/inspector-port-count.test.js — 10 checks over 7 situations (nothing plugged in, live cable, dead peer, link
down, cabled port shut, a mixture, a router):

  • the header's up-count must equal the console's;
  • every port must be in exactly one bucket;
  • each bucket's count must equal the number of ports the console describes that way;
  • no reason the console gives may be missing from the header;
  • plus the reported sentence, the four-segment limit, the singular 1 port, and the no-rule fallback.

With web/app.js reverted, 5 of the 10 fail — the up-count check reports all seven situations wrong, e.g.
router-cabled: header says 3 up, console says 1.

docs/LINK-STATE.md: the header added to the table of callers of the rule, and a section on why a summary that
guesses is worse than one that admits it cannot tell.

Suite: 165 suites, 6,777 assertions, 0 failed.

The inspector header counts ports that can carry, not ports that are enabled. Fixes #1299. ## The defect `renderDeviceTab()` drew `28 ports · 28 up` on a switch with **nothing plugged in** — the count was of `enabled` and the word was "up". Two lines above, the front panel painted every socket `notconnect`, and the console said `down (no cable)` for all 28. Three surfaces, two answers, and the wrong one was the summary: the single line people read. Worse than the empty case — it also counted as up a port whose peer had shut down (`down (peer shut down)`, the top cause of "the link is up but nothing passes") and a port whose cable had been taken down (`down (link down)`); and it dropped shut ports from the accounting instead of naming them, so `28 ports · 27 up` told you neither that 27 were dead nor that one was administratively down. Measured before the fix — panel vs `show ip interface brief` on a CX 6000: | situation | panel | console | |---|---|---| | nothing plugged in | 28 up | 0 up | | one cable to a live peer | 28 up | 1 up | | cable to a peer whose port is shut | 28 up | 0 up | | cable whose link was taken down | 28 up | 0 up | | one cabled port shut down | 27 up | 0 up | | a router with one live cable | 3 up | 1 up | The rule already existed and every other surface used it (`PFFaceplate.portState` / `portVerdict`, #1238). The header was the one place that re-derived the answer. ## After ``` 28 ports · 1 up · 27 down (no cable) 28 ports · 0 up · 27 down (no cable) · 1 down (link down) 28 ports · 0 up · 27 down (no cable) · 1 administratively down ``` * the count comes from the same `portVerdict()` the rows, faceplate, tooltip and status bar use; * every port that is not up is accounted for by the reason the console prints, in the console's own words, so the summary cannot disagree with the rows under it; * at most four segments — a summary that needs five is a table; * with the state rule absent (`faceplate.js` failed to load) the header says `unknown (no state rule loaded)` instead of falling back to `enabled`, the guess that caused this. ## Evidence `test/inspector-port-count.test.js` — 10 checks over 7 situations (nothing plugged in, live cable, dead peer, link down, cabled port shut, a mixture, a router): * the header's up-count must equal the console's; * every port must be in exactly one bucket; * each bucket's count must equal the number of ports the console describes that way; * no reason the console gives may be missing from the header; * plus the reported sentence, the four-segment limit, the singular `1 port`, and the no-rule fallback. With `web/app.js` reverted, **5 of the 10 fail** — the up-count check reports all seven situations wrong, e.g. `router-cabled: header says 3 up, console says 1`. `docs/LINK-STATE.md`: the header added to the table of callers of the rule, and a section on why a summary that guesses is worse than one that admits it cannot tell. Suite: 165 suites, 6,777 assertions, 0 failed.
The inspector header counts ports that can carry, not ports that are enabled (#1299)
Some checks failed
CI / Classify the change (pull_request) Successful in 16s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 20s
CI / Test (Node 18) (pull_request) Failing after 24s
CI / Test (Node 20) (pull_request) Successful in 2m42s
CI / Test (Node 22) (pull_request) Successful in 2m22s
CI / Server smoke test (pull_request) Successful in 34s
CI / Docker build (pull_request) Successful in 46s
f50333fe4d
renderDeviceTab() drew "28 ports · 28 up" on a switch with nothing plugged in: the count was of `enabled` and the
word was "up". Two lines above, the front panel painted every one of those sockets notconnect, and the console
said `down (no cable)` for all 28. Three surfaces, two answers, and the wrong one was the summary - the single
line people read.

Worse than the empty case: it also counted as up a port whose peer had shut down (`down (peer shut down)`, the
top cause of "the link is up but nothing passes") and a port whose cable had been taken down (`down (link
down)`), and it dropped shut ports from the accounting instead of naming them, so `28 ports · 27 up` told you
neither that 27 were dead nor that one was administratively down.

Measured before the fix, panel vs `show ip interface brief` on a CX 6000:

  nothing plugged in                  panel 28 up   console 0 up
  one cable to a live peer            panel 28 up   console 1 up
  cable to a peer whose port is shut  panel 28 up   console 0 up
  cable whose link was taken down     panel 28 up   console 0 up
  one cabled port shut down           panel 27 up   console 0 up
  a router with one live cable        panel  3 up   console 1 up

The rule already existed and every other surface used it (PFFaceplate.portState / portVerdict, #1238). The header
was the one place that re-derived the answer.

Now:

  28 ports · 1 up · 27 down (no cable)
  28 ports · 0 up · 27 down (no cable) · 1 down (link down)
  28 ports · 0 up · 27 down (no cable) · 1 administratively down

  * the count comes from the same portVerdict() the rows, faceplate, tooltip and status bar use;
  * every port that is not up is accounted for by the reason the console prints, in the console's own words, so
    the summary cannot disagree with the rows under it;
  * at most four segments: a summary that needs five is a table;
  * with the state rule absent (faceplate.js failed to load) the header says "unknown (no state rule loaded)"
    instead of falling back to `enabled` - the guess that caused this.

test/inspector-port-count.test.js: 10 checks over 7 situations (nothing plugged in, live cable, dead peer, link
down, cabled port shut, a mixture, a router). The header's up-count must equal the console's; every port must be
in exactly one bucket; each bucket's count must equal the number of ports the console describes that way; and no
reason the console gives may be missing from the header. Plus the reported sentence itself, the four-segment
limit, the singular "1 port", and the no-rule fallback. With web/app.js reverted, 5 of the 10 fail - the up-count
check reports all seven situations wrong, e.g. "router-cabled: header says 3 up, console says 1".

docs/LINK-STATE.md: the header added to the table of callers, and a section on why a summary that guesses is
worse than one that admits it cannot tell.

Suite: 165 suites, 6,777 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-09 23:45: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!1300
No description provided.