The PoE panel stops powering ports the engine has shut down (#1293) #1294

Merged
jaylouisw merged 1 commit from fix/poe-agreement into main 2026-11-09 23:09:13 +00:00
Owner

The PoE panel stops powering ports the engine has shut down.

Fixes #1293.

The gap

poeSummary() in web/app.js is a second implementation of Simulator.computePoe(), because the browser
cannot require the engine. The engine walks activeInterfaces(), so a shut-down PSE port serves no power. The
panel walked every port:

PSE with its only PSE port shut down, powered device behind it
engine:  { budget: 30, used: 0,     ports: [] }
panel:   { budget: 30, used: 12.95, ports: ['1/1/1/true'] }

With a tight budget the panel then denied the wrong port — it had powered the port the engine skipped, so the
budget ran out on the port the engine was actually powering:

one PSE port shut down, budget 20
engine: powers 1/1/2 (12.95 W, nothing denied)
panel:  powers 1/1/1, denies 1/1/2

test/ui-render.test.js already compared the two — on one lab, with two powered devices and a tight budget,
which is the one arrangement where both copies happen to agree. One comparison is not agreement.

After

  • the panel's power accounting follows the engine: only an enabled PSE port serves power;
  • the PSE port count stays a hardware count — the ports exist whether or not they are up;
  • a device with no budget is still reported as "budget not modelled" and claims no watts;
  • the inspector's sentence matches the accounting: PoE in use 0 W when the only PSE port is shut down, and
    nothing flagged DENIED because nothing was asked for.

Evidence

test/poe-agreement.test.js — 16 checks comparing the two implementations port by port, not just totals:

case what it pins
both devices fit / budget cannot fit both allocation order and denial
one PSE port shut down (budget fine, budget tight) the regression above
both PSE ports shut down no power claimed at all
peer is not a powered device skipped by both
PSE port with nothing plugged in skipped by both
no budget configured panel says "not modelled", claims nothing
sweep of 12 budgets agreement, and neither draws more than it has

Every case compares budget, used, denied and the per-port on/off set, so an implementation cannot agree
on the totals while powering different ports.

With web/app.js reverted, 4 of the 16 fail — including the reversed denial and 25.9 W reported in use with both
PSE ports shut down.

docs/PHYSICAL_LAYER.md: a "Who gets powered, and who reports it" section — active ports only, non-PD peers
skipped, and why the mirror exists and what it got wrong.

Suite: 162 suites, 6,742 assertions, 0 failed.

The PoE panel stops powering ports the engine has shut down. Fixes #1293. ## The gap `poeSummary()` in `web/app.js` is a second implementation of `Simulator.computePoe()`, because the browser cannot `require` the engine. The engine walks `activeInterfaces()`, so a shut-down PSE port serves no power. The panel walked **every** port: ``` PSE with its only PSE port shut down, powered device behind it engine: { budget: 30, used: 0, ports: [] } panel: { budget: 30, used: 12.95, ports: ['1/1/1/true'] } ``` With a tight budget the panel then denied the **wrong** port — it had powered the port the engine skipped, so the budget ran out on the port the engine was actually powering: ``` one PSE port shut down, budget 20 engine: powers 1/1/2 (12.95 W, nothing denied) panel: powers 1/1/1, denies 1/1/2 ``` `test/ui-render.test.js` already compared the two — on one lab, with two powered devices and a tight budget, which is the one arrangement where both copies happen to agree. One comparison is not agreement. ## After * the panel's power accounting follows the engine: only an **enabled** PSE port serves power; * the PSE port *count* stays a hardware count — the ports exist whether or not they are up; * a device with no budget is still reported as "budget not modelled" and claims no watts; * the inspector's sentence matches the accounting: `PoE in use 0 W` when the only PSE port is shut down, and nothing flagged `DENIED` because nothing was asked for. ## Evidence `test/poe-agreement.test.js` — 16 checks comparing the two implementations **port by port**, not just totals: | case | what it pins | |---|---| | both devices fit / budget cannot fit both | allocation order and denial | | one PSE port shut down (budget fine, budget tight) | the regression above | | both PSE ports shut down | no power claimed at all | | peer is not a powered device | skipped by both | | PSE port with nothing plugged in | skipped by both | | no budget configured | panel says "not modelled", claims nothing | | sweep of 12 budgets | agreement, and neither draws more than it has | Every case compares `budget`, `used`, `denied` **and the per-port on/off set**, so an implementation cannot agree on the totals while powering different ports. With `web/app.js` reverted, 4 of the 16 fail — including the reversed denial and 25.9 W reported in use with both PSE ports shut down. `docs/PHYSICAL_LAYER.md`: a "Who gets powered, and who reports it" section — active ports only, non-PD peers skipped, and why the mirror exists and what it got wrong. Suite: 162 suites, 6,742 assertions, 0 failed.
The PoE panel stops powering ports the engine has shut down (#1293)
Some checks failed
CI / Classify the change (pull_request) Successful in 14s
PR rebase / Rebase onto main and arm auto-merge (pull_request) Successful in 17s
CI / Test (Node 20) (pull_request) Successful in 2m28s
CI / Test (Node 18) (pull_request) Successful in 2m36s
CI / Test (Node 22) (pull_request) Failing after 29s
CI / Server smoke test (pull_request) Successful in 49s
CI / Docker build (pull_request) Successful in 1m9s
10c0ac6a88
poeSummary() in web/app.js is a second implementation of Simulator.computePoe(), because the browser cannot
require the engine. The engine walks activeInterfaces(), so a shut-down PSE port serves no power. The panel
walked every port. Measured on a PSE whose only PSE port is shut down, with a powered device behind it:

  engine:  { budget: 30, used: 0,     ports: [] }
  panel:   { budget: 30, used: 12.95, ports: ['1/1/1/true'] }

And with a tight budget the panel marked the wrong port denied, because it powered the port the engine had
skipped and then ran out of budget on the port the engine was actually powering:

  one PSE port shut down, budget 20
  engine: powers 1/1/2 (12.95 W, nothing denied)
  panel:  powers 1/1/1, denies 1/1/2

test/ui-render.test.js already compared the two - on one lab, with two powered devices and a tight budget, which
is the one arrangement where both copies agree. One comparison is not agreement.

Now the panel's power accounting follows the engine: only an enabled PSE port serves power. The PSE port count
stays a hardware count, because the ports exist whether or not they are up, and a device with no budget is still
reported as "budget not modelled" rather than claiming 0 W in use.

test/poe-agreement.test.js: 16 checks comparing the two implementations port by port, not just totals, across
every case a PSE meets - both devices fitting, a budget that cannot fit both, one PSE port shut down (budget fine
and budget tight), both shut down, a peer that is not a powered device, a PSE port with nothing plugged in, a
device with no budget, and a sweep of twelve budgets each also checked for drawing more than it has. The rendered
sentence is checked too: `PoE in use 0 W` when the only PSE port is shut down, nothing flagged DENIED because
nothing was asked for.

With web/app.js reverted, 4 of the 16 fail, including the reversed denial above and 25.9 W reported in use with
both PSE ports shut down.

docs/PHYSICAL_LAYER.md: a "Who gets powered, and who reports it" section - active ports only, non-PD peers
skipped, and why the mirror exists and what it got wrong.

Suite: 162 suites, 6,742 assertions, 0 failed.
jaylouisw scheduled this pull request to auto merge when all checks succeed 2026-11-09 23:09:09 +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!1294
No description provided.