The catalogue refuses two ports with one name, two files for one box, and nonsense templates (#1317) #1318
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1318
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/catalogue-gates"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The catalogue refuses two ports with one name, two files for one box, and nonsense templates.
Fixes #1317.
docs/DEVICE_SCHEMA.mdalready says:Neither was true at load — the importer enforced the second,
loadCatalog()enforced neither. The tree is cleantoday (0 duplicate port names, 0 duplicate model keys) and nothing kept it that way.
1. Two ports with one name: the spec describes 5, the device has 4
Ports are kept in a map keyed by name, so the later
Gi2silently replaced the earlier one. A 28-port switch writtenwith a clash became a 27-port switch — and the canvas, the inspector count and the port audit all agreed with each
other and all disagreed with the file.
2. Two files for one box
modelKey()squashes punctuation and is what the importer gates on (#60), but nothing re-checked it at load. A filearriving by a rebase, a copy or a hand edit put two entries in the palette for one machine, and
POST /devices {model}took whichever sorted first.3. A template prefix or start of the wrong type
prefix: 5withstart: "1"expanded toGi10, Gi11, Gi12, Gi13— numbering that begins at ten becausestart + iconcatenated a string.
Gates added
Each is a
brokenSpec()entry naming the file — the existing convention, so a broken spec stays in the catalogue andcannot be mistaken for a working device:
port name "Gi2" is used 2 times - a device would keep 4 of the 5 ports the spec describesdeclares Cisco ASR1001-X, which asr1001x.json already declaresportTemplate.prefixmust be a string,starta whole number ≥ 0Enforced at load, not only at import, because import is not the only door.
Evidence
test/catalogue-hygiene.test.js— 25 checks. The shipped catalogue loads with 0 broken, no duplicate port names,no duplicate model keys, every entry naming a vendor/model/category and every one with something to cable to — the
state, pinned. Then each gate, with the engine measured first (
expandInterfacesgives 5, the device keeps 4) sothe rule is justified by what the engine does rather than by taste;
ASR1001-XandASR 1001-Xare one box while twovendors may share a model name;
prefix 5,start "1"andstart -1all refused. And the other half of the rule:four legitimate shapes all load — template-only (207 specs use it), template plus extra explicit ports (25 ports, not
24 and not 1), explicit only, and a template with no
start.With
devices/registry.jsreverted, 6 of the 25 fail — the clash loads happily as a 4-port device with nomessage, and both files for one box load.
docs/DEVICE_SCHEMA.md: "What the loader refuses" — the table of reasons, and why the last two used to pass.Suite: 174 suites, 6,970 assertions, 0 failed.