One naming table, not two (#1247) #1248

Merged
jaylouisw merged 1 commit from refactor/one-iface-name-table into main 2026-11-09 18:28:59 +00:00
Owner

One naming table, not two

Fixes #1247.

engine/iface-name.js holds the spelling rules; engine/cli.js held a hand-copied second version of
PORT_NAME_RULES, portKey and resolvePortName. They agree today by luck. The copy is gone and the CLI
imports the shared module — still re-exporting the three names, because test/mikrotik-naming.test.js
imports them from there, and a re-export cannot drift.

The asymmetry it hid

Device.resolveIface() accepted exact names only, so the engine was stricter than the console that writes
the config. A topology file storing a VRRP group under the spelling somebody typed elected nothing, and
show vrrp called that group Init — a static naming problem reported as a dynamic state. resolveIface()
now resolves through the same table: exact name first, then case, then the vendor fold, and null when
nothing matches or two ports fold together (an ambiguous spelling is refused, not guessed).

Evidence

test/iface-name-agreement.test.js — 16 checks:

  • the CLI's resolver is the shared function (===, and the same for portKey). A pasted copy fails the
    suite immediately — that is the check this PR exists for.
  • a sweep of 20,233 ports across the catalogue: each resolves by its own name, in upper case, and by its
    console spelling where the table has one;
  • a name that matches nothing, an empty name and no name resolve to null — a typo is an error, not a
    guess — and a third spelling folding onto two ports (sfpplus1 where both sfp+1 and sfp-sfpplus1
    exist) is refused;
  • interface combo1 on a MikroTik sets the address on the port the panel calls COMBO1, and the tables go
    on printing the panel spelling;
  • a group stored under a differently-spelled interface name still takes part and is not shown as Init.

Reverting the device change fails 4 of the 16.

docs/CLI.md gains a note on the spellings under "Interface-mode commands".

Suite: 137 suites, 5,933 assertions, 0 failed.

One naming table, not two Fixes #1247. `engine/iface-name.js` holds the spelling rules; `engine/cli.js` held a hand-copied second version of `PORT_NAME_RULES`, `portKey` and `resolvePortName`. They agree today by luck. The copy is gone and the CLI imports the shared module — still re-exporting the three names, because `test/mikrotik-naming.test.js` imports them from there, and a re-export cannot drift. ## The asymmetry it hid `Device.resolveIface()` accepted exact names only, so the engine was stricter than the console that writes the config. A topology file storing a VRRP group under the spelling somebody typed elected nothing, and `show vrrp` called that group `Init` — a static naming problem reported as a dynamic state. `resolveIface()` now resolves through the same table: exact name first, then case, then the vendor fold, and `null` when nothing matches or two ports fold together (an ambiguous spelling is refused, not guessed). ## Evidence `test/iface-name-agreement.test.js` — 16 checks: * **the CLI's resolver is the shared function** (`===`, and the same for `portKey`). A pasted copy fails the suite immediately — that is the check this PR exists for. * a sweep of **20,233 ports** across the catalogue: each resolves by its own name, in upper case, and by its console spelling where the table has one; * a name that matches nothing, an empty name and no name resolve to `null` — a typo is an error, not a guess — and a third spelling folding onto two ports (`sfpplus1` where both `sfp+1` and `sfp-sfpplus1` exist) is refused; * `interface combo1` on a MikroTik sets the address on the port the panel calls `COMBO1`, and the tables go on printing the panel spelling; * a group stored under a differently-spelled interface name still takes part and is not shown as `Init`. Reverting the device change fails 4 of the 16. `docs/CLI.md` gains a note on the spellings under "Interface-mode commands". Suite: 137 suites, 5,933 assertions, 0 failed.
One naming table, not two (#1247)
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 1m48s
CI / Test (Node 18) (pull_request) Successful in 1m53s
CI / Server smoke test (pull_request) Successful in 34s
CI / Docker build (pull_request) Successful in 41s
CI / Test (Node 22) (pull_request) Successful in 1m41s
6eabb85c10
engine/iface-name.js holds the rules that fold a console spelling ("ether1") onto the panel spelling
("eth1"), and engine/cli.js held a hand-copied second version of `PORT_NAME_RULES`, `portKey` and
`resolvePortName`. They had not drifted yet, by luck. Two copies of one rule is the failure mode this repo
has already been bitten by twice - the fabric rule and the port-state rule both needed an agreement test
after diverging - so the copy goes, and the CLI imports the shared module (still re-exporting it, because
`test/mikrotik-naming.test.js` imports it from there and a re-export cannot drift).

The asymmetry it hid: `Device.resolveIface()` accepted exact names only, while the console accepted every
spelling. So the engine was stricter than the thing that writes the config. A topology file storing a VRRP
group under the spelling somebody typed elected nothing, and `show vrrp` called the group Init - a static
config error reported as a dynamic state. `resolveIface()` now resolves through the same table: exact name
first, then case, then the vendor fold, and null when nothing matches or two ports fold together.

test/iface-name-agreement.test.js (16 checks):
* the CLI's resolver *is* the shared function (`===`), so a pasted copy fails the suite immediately;
* a sweep of all 20,233 ports in the catalogue: each resolves by its own name, in any case, and by its
  console spelling where the table has one;
* a name that matches nothing, an empty name and no name all resolve to null - a typo is an error, not a
  guess - and a spelling that folds onto two ports is refused rather than picking one;
* a console spelling configures the port it names (`interface combo1` on a MikroTik sets the address on
  COMBO1) and the tables keep printing the panel spelling;
* a group stored under a differently-spelled interface name still takes part, and is not reported as Init.

Reverting the device change fails 4 of the 16.

Suite: 137 suites, 5,933 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-09 18:28:57 +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!1248
No description provided.