A show describes an instant, not a cache (#1360) #1361

Merged
jaylouisw merged 1 commit from fix/show-instant into main 2026-11-10 12:27:07 +00:00
Owner

A show describes an instant, not a cache.

Fixes #1360.

show ip route printed whatever the last computeOspf() happened to leave on the device. The control planes are
results — computeStp(), computeVrrp(), computeOspf(), computeBgp() each write conclusions onto the devices
and each honours runAtMs — but the console never asked them.

Measured on two ISR 4331s with a segment behind each, OSPF on all four interfaces:

fresh console, show ip route, no run behind it, settled lab   ->  (none)
same, after computeOspf() at Infinity                         ->  O 192.168.2.0/24 via 10.0.0.2
computeOspf() at 5000  (OSPF converges at 16000)              ->  (none)
same at 20000                                                 ->  O 192.168.2.0/24 via 10.0.0.2
  • A false negative: a console with no run behind it reports (no O routes) on a fully converged lab — the routes
    only appear if a ping or a load ran the OSPF computation first.
  • History dependence: ask at instant 5000 after a settled run and it prints routes that will not exist for another
    11000 ms. The same question, asked twice, answers differently.

Same family as dev.stp in #1336 — the console reading a cache instead of the model.

Fixes

CliSession._refreshControlPlane() runs the control planes at the instant the session is standing at, before _show()
produces output — the same four computations the packet path already runs before it sends anything. It is
config-guarded: only processes the device is configured to run are recomputed, because recomputing an unconfigured
process does not give the same answer twice — it erases the device's learned routes. A show may compute; it must
not destroy. That guard is not theoretical: the first version recomputed unconditionally and
test/routes-agreement.test.js caught it, a fixture-installed ospfRoutes coming back as one prefix instead of four.

Evidence

test/control-plane-instant.test.js — 12 checks. A settled lab's show ip route lists the OSPF route to the far
segment; at 5000 ms it does not; at 20000 ms it is back and identical. Five questions asked in the order
settled/early/settled/early/late give the same answers as asked alone, in both directions. show vrrp says the
election is pending at 1000 ms and not at 20000, and asking again gives the same answer. Asking does not rewrite the
configuration, and every row still carries its distance or says it is directly connected.

With engine/cli.js reverted, 3 of the 12 fail: (none) on a settled lab, and show vrrp reporting an election
result before the election could have settled.

(The spanning-tree case from #1336 is guarded in test/console-over-http.test.js, on a switch — a router runs no STP.)

docs/ARCHITECTURE.md: "A show describes an instant, not a cache".

Suite: 184 suites, 7,127 assertions, 0 failed.

A show describes an instant, not a cache. Fixes #1360. `show ip route` printed whatever the last `computeOspf()` happened to leave on the device. The control planes are **results** — `computeStp()`, `computeVrrp()`, `computeOspf()`, `computeBgp()` each write conclusions onto the devices and each honours `runAtMs` — but the console never asked them. Measured on two ISR 4331s with a segment behind each, OSPF on all four interfaces: ``` fresh console, show ip route, no run behind it, settled lab -> (none) same, after computeOspf() at Infinity -> O 192.168.2.0/24 via 10.0.0.2 computeOspf() at 5000 (OSPF converges at 16000) -> (none) same at 20000 -> O 192.168.2.0/24 via 10.0.0.2 ``` * **A false negative:** a console with no run behind it reports `(no O routes)` on a fully converged lab — the routes only appear if a `ping` or a load ran the OSPF computation first. * **History dependence:** ask at instant 5000 after a settled run and it prints routes that will not exist for another 11000 ms. The same question, asked twice, answers differently. Same family as `dev.stp` in #1336 — the console reading a cache instead of the model. ## Fixes `CliSession._refreshControlPlane()` runs the control planes at the instant the session is standing at, before `_show()` produces output — the same four computations the packet path already runs before it sends anything. It is **config-guarded**: only processes the device is configured to run are recomputed, because recomputing an unconfigured process does not give the same answer twice — it **erases** the device's learned routes. A `show` may compute; it must not destroy. That guard is not theoretical: the first version recomputed unconditionally and `test/routes-agreement.test.js` caught it, a fixture-installed `ospfRoutes` coming back as one prefix instead of four. ## Evidence `test/control-plane-instant.test.js` — **12 checks**. A settled lab's `show ip route` lists the OSPF route to the far segment; at 5000 ms it does not; at 20000 ms it is back and identical. Five questions asked in the order settled/early/settled/early/late give the same answers as asked alone, in both directions. `show vrrp` says the election is pending at 1000 ms and not at 20000, and asking again gives the same answer. Asking does not rewrite the configuration, and every row still carries its distance or says it is directly connected. With `engine/cli.js` reverted, **3 of the 12 fail**: `(none)` on a settled lab, and `show vrrp` reporting an election result before the election could have settled. (The spanning-tree case from #1336 is guarded in `test/console-over-http.test.js`, on a switch — a router runs no STP.) `docs/ARCHITECTURE.md`: "A show describes an instant, not a cache". Suite: 184 suites, 7,127 assertions, 0 failed.
A show describes an instant, not a cache (#1338)
All checks were successful
CI / Classify the change (pull_request) Successful in 10s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 14s
CI / Test (Node 20) (pull_request) Successful in 2m18s
CI / Test (Node 18) (pull_request) Successful in 2m30s
CI / Server smoke test (pull_request) Successful in 31s
CI / Docker build (pull_request) Successful in 44s
CI / Test (Node 22) (pull_request) Successful in 2m13s
ecaf28d394
`show ip route` printed whatever the last computeOspf() happened to leave on the device. The control planes are
results - computeStp(), computeVrrp(), computeOspf() and computeBgp() each write conclusions onto the devices and each
honours runAtMs - but the console never asked them, so:

  * a console with no run behind it reported "(no O routes)" on a lab that was fully converged. The routes only
    appear if something (a ping, a load) ran the OSPF computation first;
  * the answer to the same question depended on which run happened BEFORE it: show ip route at instant 5000 could
    print routes installed by a settled run 20000 ms later.

Measured on two ISR 4331s with a segment behind each, OSPF configured on all four interfaces:

  fresh console, show ip route, no run behind it, settled lab  ->  (none)
  same, after computeOspf() at Infinity                        ->  O 192.168.2.0/24 via 10.0.0.2
  computeOspf() at 5000 (OSPF converges at 16000)              ->  (none)

So the computation was right and the command never ran it.

Fixes: CliSession._refreshControlPlane() runs the control planes at the instant the session is standing at, before
_show() produces any output - the same four computations the packet path already runs before it sends anything. It
is config-guarded: only the processes the device is configured to run are recomputed, because recomputing an
unconfigured process does not give the same answer twice - it ERASES the device's learned routes. A show may compute;
it must not destroy. That guard is not theoretical: the first version recomputed unconditionally and test/
routes-agreement.test.js caught it, with a device whose ospfRoutes had been installed by its fixture coming back with
one prefix instead of four.

test/control-plane-instant.test.js: 12 checks. A settled lab's show ip route lists the OSPF route to the far segment,
at 5000 ms it does not, at 20000 ms it is back and identical; five questions asked in the order settled/early/settled/
early/late give the same answers as asked alone, in both directions; show vrrp says the election is pending at 1000 ms
and not at 20000, and asking again gives the same answer; asking does not rewrite the configuration and every row
still carries its distance or says it is directly connected.

With engine/cli.js reverted, 3 of the 12 fail: "(none)" on a settled lab, and show vrrp reporting an election result
before the election could have settled.

(The spanning-tree case from #1336 is guarded in test/console-over-http.test.js, on a switch; a router runs no STP.)

docs/ARCHITECTURE.md: "A show describes an instant, not a cache".

Suite: 184 suites, 7,127 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-10 12:27:03 +00:00
jaylouisw force-pushed fix/show-instant from ecaf28d394
All checks were successful
CI / Classify the change (pull_request) Successful in 10s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 14s
CI / Test (Node 20) (pull_request) Successful in 2m18s
CI / Test (Node 18) (pull_request) Successful in 2m30s
CI / Server smoke test (pull_request) Successful in 31s
CI / Docker build (pull_request) Successful in 44s
CI / Test (Node 22) (pull_request) Successful in 2m13s
to 77585356d5
Some checks failed
CI / Classify the change (pull_request) Successful in 12s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 12s
CI / Test (Node 18) (pull_request) Failing after 2m35s
CI / Test (Node 20) (pull_request) Failing after 2m21s
CI / Server smoke test (pull_request) Successful in 28s
CI / Docker build (pull_request) Successful in 45s
CI / Test (Node 22) (pull_request) Failing after 2m26s
2026-11-10 12:27:03 +00:00
Compare
Sign in to join this conversation.
No description provided.