The port-naming table exists twice, and the engine is stricter than the console #1247

Closed
opened 2026-11-09 18:28:39 +00:00 by jaylouisw · 0 comments
Owner

What

engine/iface-name.js holds the rules that fold a console spelling onto the panel spelling (ether1 →
eth1, sfp-sfpplus1 → SFP+1). engine/cli.js holds a hand-copied second version of
PORT_NAME_RULES, portKey and resolvePortName.

They agree today, character for character, by luck. Two copies of one rule is the failure mode this repo
has already been bitten by twice: engine/fabric.js vs web/app.js needed test/fabric-agreement.test.js
after they diverged, and the port-state rule needed the same treatment in #1238. When a vendor spelling is
added for the next MikroTik, it will be added to whichever copy the author happens to open, and the console
and the engine will disagree about what a port is called.

The asymmetry it hides

Device.resolveIface() accepts exact names only:

resolveIface(x) {
  if (typeof x === 'string') return this.interfaces.get(x) || null;
  if (x.name && this.interfaces.has(x.name)) return this.interfaces.get(x.name);
  return null;
}

So the engine is stricter than the console that writes the config. A topology file that stores a VRRP
group (or a link, or a DHCP binding) under the spelling an engineer typed resolves to nothing in the engine:
the group takes part in no election, and show vrrp reports it as Init — a static naming problem presented
as a dynamic state.

Expected

  • one table, imported by both, with the CLI re-exporting it so existing importers keep working;
  • Device.resolveIface() resolves through that table: exact name, then case, then the vendor fold, and
    null when nothing matches or two ports fold together;
  • an agreement test that fails the moment a copy comes back (cli.resolvePortName === ifaceName.resolvePortName),
    and a sweep proving every port in the catalogue resolves by its own name, in any case, and by its console
    spelling.

Scope

De-duplication and one resolver. No new commands, no naming changes, no renaming of any port.

## What `engine/iface-name.js` holds the rules that fold a console spelling onto the panel spelling (`ether1` → `eth1`, `sfp-sfpplus1` → `SFP+1`). `engine/cli.js` holds a **hand-copied second version** of `PORT_NAME_RULES`, `portKey` and `resolvePortName`. They agree today, character for character, by luck. Two copies of one rule is the failure mode this repo has already been bitten by twice: `engine/fabric.js` vs `web/app.js` needed `test/fabric-agreement.test.js` after they diverged, and the port-state rule needed the same treatment in #1238. When a vendor spelling is added for the next MikroTik, it will be added to whichever copy the author happens to open, and the console and the engine will disagree about what a port is called. ## The asymmetry it hides `Device.resolveIface()` accepts exact names only: ```js resolveIface(x) { if (typeof x === 'string') return this.interfaces.get(x) || null; if (x.name && this.interfaces.has(x.name)) return this.interfaces.get(x.name); return null; } ``` So the engine is **stricter than the console that writes the config**. A topology file that stores a VRRP group (or a link, or a DHCP binding) under the spelling an engineer typed resolves to nothing in the engine: the group takes part in no election, and `show vrrp` reports it as `Init` — a static naming problem presented as a dynamic state. ## Expected * one table, imported by both, with the CLI re-exporting it so existing importers keep working; * `Device.resolveIface()` resolves through that table: exact name, then case, then the vendor fold, and `null` when nothing matches or two ports fold together; * an agreement test that fails the moment a copy comes back (`cli.resolvePortName === ifaceName.resolvePortName`), and a sweep proving every port in the catalogue resolves by its own name, in any case, and by its console spelling. ## Scope De-duplication and one resolver. No new commands, no naming changes, no renaming of any port.
Sign in to join this conversation.
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#1247
No description provided.