Every printed config line has a no form, and no vlan stops lying (#1277) #1278

Merged
jaylouisw merged 1 commit from fix/config-undo into main 2026-11-09 21:37:04 +00:00
Owner

Every printed config line now has a no form, and no vlan stops reporting work it did not do.

Fixes #1277.

The gap

show running-config is the backup. The suite already held it to two rules — it replays, and it is complete
— and it failed the third: you cannot edit it back.

r1(config)#hostname ripper
r1(config)#no hostname
% Unrecognized config command: no hostname ripper

r1(config)#no ip dhcp pool P1
% E_DHCP_BAD_RANGE: DHCP pool P1: both rangeStart and rangeEnd ...     <- parsed as a pool body line

r1(config)#no dns zone test.example
% Unrecognized config command: no dns zone test.example

r1(config-if)#no ip access-group 101 in
% Unrecognized interface command: no ip access-group 101 in

and the mirror image, which is worse than missing because it lies:

sw1(config)#no vlan 42
VLAN 42 removed                    <- there is no VLAN 42

The rule this PR makes testable

Add a command, remove it, and show running-config comes back byte for byte to what it was. Not "the
message looks right" — the same text. That is the assertion in test/config-undo.test.js, 48 checks,
24 of which fail with engine/cli.js reverted.

The no forms, and what they say when there is nothing to remove

command no form absent
hostname <name> no hostname % No hostname set (the device is named …)
ip dhcp pool <name> no ip dhcp pool <name> % No DHCP pool named nope
dns zone <name> no dns zone <name> % No DNS zone named nope.example
ip access-group <n> in|out no ip access-group [<n>] [in|out] % No access list 101 applied in on Gi0
vlan <id> no vlan <id> % VLAN 99 does not exist

Three refusals that are load-bearing, not tidy

  • no ip access-group 103 in while 102 is applied refuses and names 102. Silently clearing "whatever is
    bound" would remove a policy the operator did not ask about.

  • no vlan 20 while ports carry it refuses, naming up to five and counting the rest:

    % VLAN 20 is still carried by 1 port(s): Fa0/3 - move them off it first
    

    Deleting a VLAN behind the ports' backs left show running-config no longer printing vlan 20 while
    show vlan still listed it from the member ports — two descriptions of one switch that disagreed, the same
    class as #1232, #1256 and #1262. Once the port is moved off it, the same command deletes it cleanly.

  • no hostname restores the name the box had before the hostname was typed, because hostname sets both
    the config line and the canvas label so the two cannot disagree (#21). Undoing only half of it leaves a
    clean config over a label that lies.

Also

docs/CLI.md gains an "Undoing a command" section — the rule, the sample refusals, the table — and the
config-mode command table lists the new forms. help lists them too.

Suite: 152 suites, 6,380 assertions, 0 failed.

Every printed config line now has a `no` form, and `no vlan` stops reporting work it did not do. Fixes #1277. ## The gap `show running-config` is the backup. The suite already held it to two rules — it replays, and it is complete — and it failed the third: **you cannot edit it back.** ``` r1(config)#hostname ripper r1(config)#no hostname % Unrecognized config command: no hostname ripper r1(config)#no ip dhcp pool P1 % E_DHCP_BAD_RANGE: DHCP pool P1: both rangeStart and rangeEnd ... <- parsed as a pool body line r1(config)#no dns zone test.example % Unrecognized config command: no dns zone test.example r1(config-if)#no ip access-group 101 in % Unrecognized interface command: no ip access-group 101 in ``` and the mirror image, which is worse than missing because it lies: ``` sw1(config)#no vlan 42 VLAN 42 removed <- there is no VLAN 42 ``` ## The rule this PR makes testable Add a command, remove it, and `show running-config` comes back **byte for byte** to what it was. Not "the message looks right" — the same text. That is the assertion in `test/config-undo.test.js`, 48 checks, **24 of which fail with `engine/cli.js` reverted**. ## The `no` forms, and what they say when there is nothing to remove | command | `no` form | absent | |---|---|---| | `hostname <name>` | `no hostname` | `% No hostname set (the device is named …)` | | `ip dhcp pool <name>` | `no ip dhcp pool <name>` | `% No DHCP pool named nope` | | `dns zone <name>` | `no dns zone <name>` | `% No DNS zone named nope.example` | | `ip access-group <n> in\|out` | `no ip access-group [<n>] [in\|out]` | `% No access list 101 applied in on Gi0` | | `vlan <id>` | `no vlan <id>` | `% VLAN 99 does not exist` | ## Three refusals that are load-bearing, not tidy * **`no ip access-group 103 in` while 102 is applied** refuses and names 102. Silently clearing "whatever is bound" would remove a policy the operator did not ask about. * **`no vlan 20` while ports carry it** refuses, naming up to five and counting the rest: ``` % VLAN 20 is still carried by 1 port(s): Fa0/3 - move them off it first ``` Deleting a VLAN behind the ports' backs left `show running-config` no longer printing `vlan 20` while `show vlan` still listed it from the member ports — two descriptions of one switch that disagreed, the same class as #1232, #1256 and #1262. Once the port is moved off it, the same command deletes it cleanly. * **`no hostname`** restores the name the box had *before* the hostname was typed, because `hostname` sets both the config line and the canvas label so the two cannot disagree (#21). Undoing only half of it leaves a clean config over a label that lies. ## Also `docs/CLI.md` gains an "Undoing a command" section — the rule, the sample refusals, the table — and the config-mode command table lists the new forms. `help` lists them too. Suite: 152 suites, 6,380 assertions, 0 failed.
Every printed config line has a no form, and no vlan stops lying (#1277)
All checks were successful
CI / Classify the change (pull_request) Successful in 13s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 17s
CI / Test (Node 20) (pull_request) Successful in 2m1s
CI / Test (Node 18) (pull_request) Successful in 2m6s
CI / Server smoke test (pull_request) Successful in 35s
CI / Docker build (pull_request) Successful in 49s
CI / Test (Node 22) (pull_request) Successful in 1m56s
bdcd199e0b
`show running-config` is the backup, and the suite already held it to two rules: it replays, and it is
complete. It failed the third: you cannot edit it back. Four commands were accepted, printed, and impossible to
remove from the console:

  hostname <name>          no hostname           -> "% Unrecognized config command"
  ip dhcp pool <name>      no ip dhcp pool <n>   -> parsed as a pool body line, refused as a bad range
  dns zone <name>          no dns zone <name>    -> "% Unrecognized config command"
  ip access-group <n> in   no ip access-group    -> "% Unrecognized interface command"

and the mirror image, `no vlan 42` printing "VLAN 42 removed" whether or not a VLAN 42 existed.

Now each has a `no` form, and removing something that is not there refuses in one sentence naming the thing:

  % No hostname set (the device is named ASR 1001-X aggregation services router-r1)
  % No DHCP pool named nope
  % No DNS zone named nope.example
  % No access list 101 applied in on Gi0
  % VLAN 99 does not exist

Three of those refusals are load-bearing rather than tidy:

* `no ip access-group 103 in` while 102 is applied refuses and names 102. Silently clearing "whatever is
  bound" would remove a policy the operator did not ask about.
* `no vlan 20` refuses while ports still carry it, naming up to five and counting the rest. Deleting a VLAN
  behind the ports' backs left `show running-config` no longer printing `vlan 20` while `show vlan` still
  listed it from the member ports - two descriptions of one switch that disagreed, the same class as #1232,
  #1256 and #1262.
* `no hostname` restores the name the box had before, because `hostname` sets both the config line and the
  canvas label so the two cannot disagree (#21); undoing half of it leaves a clean config over a lying label.

test/config-undo.test.js (48 checks, 24 of which fail with engine/cli.js reverted) holds the rule the docs now
state: add a command, remove it, and the printed config comes back byte for byte - not "the message looks
right", but the same text. It covers all five features, both access-group directions and the unqualified
form, the wrong-list refusal, the in-use VLAN refusal followed by the same VLAN deleting cleanly once the
port is moved off it, and one shape for every refusal (leading %, the thing named, no JS value leaking).

docs/CLI.md: new "Undoing a command" section with the rule, the sample refusals, the table of no forms, and
why the in-use and wrong-list refusals exist; the config-mode table now lists the new no forms.

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