One switchport sentence for the console and the inspector panel (#1291) #1292

Merged
jaylouisw merged 1 commit from fix/switchport-sentence into main 2026-11-09 22:59:15 +00:00
Owner

One switchport sentence for the console and the panel.

Fixes #1291.

show interfaces <port> prints one line saying what the port does with a frame; the inspector panel shows the
same fact under a VLAN heading. The browser cannot require the engine, so the rule exists twice on purpose —
and the two copies had drifted.

Before

port state                          panel said                  console said
{access, nativeVlan 20}             access 1                    access VLAN 1 · trunk staged: native 20 (not in use)
{access, accessVlan 20}             access 20                   access VLAN 20
{trunk, allowedVlans: []}           trunk · native 1 · allowed  (nothing)
                                                                trunk · native 1 · allowed none
{access, allowedVlans: [10,20]}     access 1                    access VLAN 1 · trunk staged: allowed 10,20 (not in use)

Three lies and one second spelling:

  • the panel knew nothing about parameters stored but not in force, so a port staged for a trunk looked
    identical to a plain access port;
  • || 1 on every field made an unset trunk native VLAN indistinguishable from a native VLAN of 1;
  • an empty allowed list — a trunk classifyEgress drops every VLAN on — was rendered with the list missing;
  • access 20 versus access VLAN 20 meant an operator comparing the two had to translate.

After

access VLAN 20
access VLAN 1 · trunk staged: native 20 (not in use)
trunk · native 30 · allowed 10,20
trunk · native 1 · allowed none

One string, written once in engine/vlan.js as switchportSentence(), printed by the console after
switchport: and mirrored in web/app.js for the panel.

The staged clause is read from the stored fields, not the normalised ones — the normaliser derives a native
VLAN from the access VLAN when the field is absent, so asking it would report a staged parameter on every access
port in a non-default VLAN. An empty allowed list prints none, not all, because classifyEgress drops every
VLAN on it.

Evidence

test/switchport-agreement.test.js — 13 checks over a 360-state matrix (mode × access VLAN × native VLAN ×
allowed list):

  • engine and panel produce the same sentence for every state; the matrix reaches at least six distinct
    sentences, so it is not testing one branch;
  • vlanSummary(iface) is the sentence and nothing else;
  • every claim the sentence makes is checked against classifyEgress: allowed all carries every probed
    VLAN, allowed none carries none, a listed VLAN is carried and an unlisted one is not, access VLAN N
    carries N, and anything the sentence calls staged is not carried;
  • five real ports (four states) confirm console text == engine sentence == panel rendering;
  • a trunk allowing nothing says none in both implementations while the data plane drops.

test/ui-render.test.js asserts the console's words (access VLAN 20) instead of the old panel spelling;
test/show-interfaces-port.test.js expectations updated to the one sentence.

With web/app.js reverted the suite fails immediately (switchportSentence is not exported), and with both
files reverted engine/vlan.js has no function to compare against — the before/after table above was captured
by evaluating the old vlanSummary body against the new engine function.

docs/CLI.md: the switchport examples are the canonical sentences, with allowed none explained and the rule's
home recorded.

Suite: 161 suites, 6,726 assertions, 0 failed.

One switchport sentence for the console and the panel. Fixes #1291. `show interfaces <port>` prints one line saying what the port does with a frame; the inspector panel shows the same fact under a `VLAN` heading. The browser cannot `require` the engine, so the rule exists twice on purpose — and the two copies had drifted. ## Before ``` port state panel said console said {access, nativeVlan 20} access 1 access VLAN 1 · trunk staged: native 20 (not in use) {access, accessVlan 20} access 20 access VLAN 20 {trunk, allowedVlans: []} trunk · native 1 · allowed (nothing) trunk · native 1 · allowed none {access, allowedVlans: [10,20]} access 1 access VLAN 1 · trunk staged: allowed 10,20 (not in use) ``` Three lies and one second spelling: * the panel knew nothing about parameters **stored but not in force**, so a port staged for a trunk looked identical to a plain access port; * `|| 1` on every field made an unset trunk native VLAN indistinguishable from a native VLAN of 1; * an **empty allowed list** — a trunk `classifyEgress` drops every VLAN on — was rendered with the list missing; * `access 20` versus `access VLAN 20` meant an operator comparing the two had to translate. ## After ``` access VLAN 20 access VLAN 1 · trunk staged: native 20 (not in use) trunk · native 30 · allowed 10,20 trunk · native 1 · allowed none ``` One string, written once in `engine/vlan.js` as `switchportSentence()`, printed by the console after `switchport: ` and mirrored in `web/app.js` for the panel. The staged clause is read from the **stored** fields, not the normalised ones — the normaliser derives a native VLAN from the access VLAN when the field is absent, so asking it would report a staged parameter on every access port in a non-default VLAN. An empty allowed list prints `none`, not `all`, because `classifyEgress` drops every VLAN on it. ## Evidence `test/switchport-agreement.test.js` — 13 checks over a **360-state matrix** (mode × access VLAN × native VLAN × allowed list): * engine and panel produce the same sentence for every state; the matrix reaches at least six distinct sentences, so it is not testing one branch; * `vlanSummary(iface)` is the sentence and nothing else; * **every claim the sentence makes is checked against `classifyEgress`**: `allowed all` carries every probed VLAN, `allowed none` carries none, a listed VLAN is carried and an unlisted one is not, `access VLAN N` carries N, and anything the sentence calls *staged* is **not** carried; * five real ports (four states) confirm `console text == engine sentence == panel rendering`; * a trunk allowing nothing says `none` in both implementations while the data plane drops. `test/ui-render.test.js` asserts the console's words (`access VLAN 20`) instead of the old panel spelling; `test/show-interfaces-port.test.js` expectations updated to the one sentence. With `web/app.js` reverted the suite fails immediately (`switchportSentence is not exported`), and with both files reverted `engine/vlan.js` has no function to compare against — the before/after table above was captured by evaluating the old `vlanSummary` body against the new engine function. `docs/CLI.md`: the switchport examples are the canonical sentences, with `allowed none` explained and the rule's home recorded. Suite: 161 suites, 6,726 assertions, 0 failed.
One switchport sentence for the console and the panel (#1291)
Some checks failed
CI / Classify the change (pull_request) Successful in 12s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 16s
CI / Test (Node 18) (pull_request) Failing after 2m37s
CI / Test (Node 20) (pull_request) Failing after 2m31s
CI / Server smoke test (pull_request) Successful in 46s
CI / Docker build (pull_request) Successful in 53s
CI / Test (Node 22) (pull_request) Successful in 2m27s
bc2577d86f
`show interfaces <port>` prints one line saying what the port does with a frame, and the inspector panel shows
the same fact under a `VLAN` heading. The browser cannot require the engine, so the rule exists twice on
purpose - and the two copies had drifted:

  port state                          panel said                  console said
  {access, nativeVlan 20}             access 1                    access VLAN 1 · trunk staged: native 20 (not in use)
  {trunk, allowedVlans: []}           trunk · native 1 · allowed  (nothing) -> claimed "allowed"
                                                                  trunk · native 1 · allowed none
  {access, allowedVlans: [10,20]}     access 1                    access VLAN 1 · trunk staged: allowed 10,20 (not in use)

Three separate lies, and one second spelling:

  * the panel knew nothing about parameters stored but not in force, so a port staged for a trunk looked
    identical to a plain access port;
  * `|| 1` on every field made an unset trunk native VLAN indistinguishable from a native VLAN of 1;
  * an empty allowed list - a trunk `classifyEgress` drops every VLAN on - was rendered with the list missing;
  * and `access 20` in the panel vs `access VLAN 20` in the console meant an operator comparing the two had to
    translate.

Now there is one sentence, written once in engine/vlan.js as switchportSentence(), printed by the console after
`switchport: ` and mirrored in web/app.js for the panel - the same string in both places:

  access VLAN 20
  access VLAN 1 · trunk staged: native 20 (not in use)
  trunk · native 30 · allowed 10,20
  trunk · native 1 · allowed none

The staged clause is read from the stored fields, not the normalised ones: the normaliser derives a native VLAN
from the access VLAN when the field is absent, so asking it would report a staged parameter on every access port
in a non-default VLAN. An empty allowed list prints `none` rather than `all`, because classifyEgress drops every
VLAN on it.

test/switchport-agreement.test.js: 13 checks over a 360-state matrix (mode x access VLAN x native VLAN x allowed
list). Engine and panel produce the same sentence for every state, and the matrix reaches at least six distinct
sentences so it is not testing one branch. vlanSummary(iface) is the sentence and nothing else. Every claim the
sentence makes is checked against classifyEgress: `allowed all` carries every probed VLAN, `allowed none` carries
none, a listed VLAN is carried and an unlisted one is not, `access VLAN N` carries N, and anything called
"staged" is NOT carried. Then five real ports (four states) confirm console text == engine sentence == panel
rendering, and a trunk that allows nothing says `none` in both implementations while the data plane drops.

test/ui-render.test.js: asserts the console's words (access VLAN 20) rather than the old panel spelling.
test/show-interfaces-port.test.js: expectations updated to the one sentence.

docs/CLI.md: the switchport line examples are the canonical sentences, plus why `allowed none` exists and where
the rule lives.

Suite: 161 suites, 6,726 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-09 22:59:11 +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!1292
No description provided.