A verb eaten by a join, and the token nobody typed #1456

Merged
jaylouisw merged 1 commit from fix/trunk-allowed-add-remove into main 2026-11-12 01:42:46 +00:00
Owner

Closes #1455

s1(config-if)# switchport trunk allowed vlan add 30
% cannot parse VLAN token "add30"

The branch joined the tokens after switchport trunk allowed vlan with no separator — deliberate, so 10, 20 and 40 - 42 typed with spaces still parsed — and that join ate the verbs IOS puts in front of a list to edit the one already there. The refusal quotes a token nobody typed, and the only way to add a VLAN is to retype the whole list from memory, which is exactly the mistake add/remove exist to prevent.

The change

s1(config-if)# switchport trunk allowed vlan 10,20
s1(config-if)# switchport trunk allowed vlan add 30
Trunk on Fa0/1 allows VLANs 10,20,30 (added 30)
s1(config-if)# switchport trunk allowed vlan remove 10
Trunk on Fa0/1 allows VLANs 20,30 (removed 10)

The verb is read from the token list before anything is glued; only the list is joined.

Four decisions worth keeping:

  • An edit that changes nothing says so. add 10 when 10 is already allowed: already allows VLANs 10: the list is unchanged (10,20). remove 99 when 99 was never allowed: refused, with the list it left alone. A silent success on a no-op teaches an operator that something moved when nothing did.
  • Two footguns are refused, not committed. Removing the last VLAN would leave a trunk carrying nothing — refused, with both ways out named. remove 10 on a trunk allowing all would have to store 4,093 ids — a line no operator would type and no diff would survive — so it points at switchport trunk allowed vlan <list>. add 30 on an all-trunk is already true and says so.
  • A word is named as a word. except 20 gives % Unrecognized "except": this console takes a list (10,20), a range (10-20), "all", "add <list>" or "remove <list>" — never the glued except20. A genuinely malformed numeric list keeps the library's own message.
  • Everything that worked is untouched — spaced lists and ranges, all, no switchport trunk allowed vlan, and the bare command's % Incomplete command.

Evidence

test/trunk-allowed-add-remove.test.js, 42 checks: add is the union and remove the difference, each naming what it did; running-config, the port's switchport line, show vlan brief membership and the engine state are compared after every edit; the printed config line is typed back and proven a no-op; both no-ops and both footguns are checked; the unknown word is quoted as typed; and every pre-existing form is re-asserted word for word.

Reverting engine/cli.js fails 19/42.

Neighbours green: vlan 59, voice-vlan 30, show-vlan 29, show-argument-refusal 77, switchport-mismatch 26, interface-door-atomicity 12, config-roundtrip 46.

Docs: docs/ARCHITECTURE.md § "A verb eaten by a join, and the token nobody typed".

Closes #1455 ``` s1(config-if)# switchport trunk allowed vlan add 30 % cannot parse VLAN token "add30" ``` The branch joined the tokens after `switchport trunk allowed vlan` with no separator — deliberate, so `10, 20` and `40 - 42` typed with spaces still parsed — and that join ate the verbs IOS puts in front of a list to edit the one already there. The refusal quotes a token nobody typed, and the only way to add a VLAN is to retype the whole list from memory, which is exactly the mistake `add`/`remove` exist to prevent. ### The change ``` s1(config-if)# switchport trunk allowed vlan 10,20 s1(config-if)# switchport trunk allowed vlan add 30 Trunk on Fa0/1 allows VLANs 10,20,30 (added 30) s1(config-if)# switchport trunk allowed vlan remove 10 Trunk on Fa0/1 allows VLANs 20,30 (removed 10) ``` The verb is read from the token list before anything is glued; only the list is joined. Four decisions worth keeping: * **An edit that changes nothing says so.** `add 10` when 10 is already allowed: `already allows VLANs 10: the list is unchanged (10,20)`. `remove 99` when 99 was never allowed: refused, with the list it left alone. A silent success on a no-op teaches an operator that something moved when nothing did. * **Two footguns are refused, not committed.** Removing the last VLAN would leave a trunk carrying nothing — refused, with both ways out named. `remove 10` on a trunk allowing **all** would have to store 4,093 ids — a line no operator would type and no diff would survive — so it points at `switchport trunk allowed vlan <list>`. `add 30` on an all-trunk is already true and says so. * **A word is named as a word.** `except 20` gives `% Unrecognized "except": this console takes a list (10,20), a range (10-20), "all", "add <list>" or "remove <list>"` — never the glued `except20`. A genuinely malformed numeric list keeps the library's own message. * **Everything that worked is untouched** — spaced lists and ranges, `all`, `no switchport trunk allowed vlan`, and the bare command's `% Incomplete command`. ### Evidence `test/trunk-allowed-add-remove.test.js`, **42 checks**: add is the union and remove the difference, each naming what it did; running-config, the port's switchport line, `show vlan brief` membership and the engine state are compared after every edit; the printed config line is typed back and proven a no-op; both no-ops and both footguns are checked; the unknown word is quoted as typed; and every pre-existing form is re-asserted word for word. Reverting `engine/cli.js` fails 19/42. Neighbours green: `vlan` 59, `voice-vlan` 30, `show-vlan` 29, `show-argument-refusal` 77, `switchport-mismatch` 26, `interface-door-atomicity` 12, `config-roundtrip` 46. Docs: `docs/ARCHITECTURE.md` § *"A verb eaten by a join, and the token nobody typed"*.
A verb eaten by a join, and the token nobody typed (#1455)
All checks were successful
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 20) (pull_request) Successful in 2m55s
CI / Test (Node 18) (pull_request) Successful in 3m10s
CI / Server smoke test (pull_request) Successful in 27s
CI / Docker build (pull_request) Successful in 42s
CI / Test (Node 22) (pull_request) Successful in 2m41s
9d47638e8e
s1(config-if)# switchport trunk allowed vlan add 30
  % cannot parse VLAN token "add30"

The branch glued the tokens after 'switchport trunk allowed vlan' together with
no separator - deliberate, so '10, 20' and '40 - 42' typed with spaces still
parsed - and the join also ate the verbs IOS puts in front of a list to edit the
one already there. The refusal quoted a token nobody had typed, and the only way
to add a VLAN was to retype the whole list from memory: exactly the mistake
add/remove exist to prevent.

The verb is now read from the token list before anything is glued, and only the
list is joined:

  add 30     -> Trunk on Fa0/1 allows VLANs 10,20,30 (added 30)
  remove 10  -> Trunk on Fa0/1 allows VLANs 20,30 (removed 10)

Four decisions worth keeping:
  * an edit that changes nothing says so: 'already allows VLANs 10: the list is
    unchanged (10,20)', and removing a VLAN that was never allowed is refused
    with the list it left alone;
  * two footguns are refused, not committed: removing the last VLAN (a trunk
    carrying nothing), and removing from a trunk that allows all - which would
    have to store 4,093 ids, a line no operator would type and no diff would
    survive - so it points at the explicit list instead. Adding to an all-trunk
    is already true and says so;
  * a word is named as a word: 'except 20' prints % Unrecognized "except" with
    the accepted forms, never the glued 'except20';
  * everything that worked is untouched: spaced lists and ranges, all, no
    switchport trunk allowed vlan, the bare command's % Incomplete command.

Evidence: test/trunk-allowed-add-remove.test.js, 42 checks; reverting
engine/cli.js fails 19. Suite 228 suites, 8565 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-12 01:42:43 +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!1456
No description provided.