SAFETY-121: a recurring overload warns every quarter #204

Merged
admin merged 2 commits from SAFETY-121 into release/1.0 2026-10-21 12:41:12 +02:00
Owner

SAFETY-121 (Trello 6ad85901d4b96fa25025c529), follow-up of SAFETY-119 rig test F-1. Report: reports/SAFETY-121-dev-report.md. DECISIONS: DECISIONS/SAFETY-121-bound-every-quarter.md.

F-1. On a 5 s meter, with a steady overload (2 x 2500 W, house 5100 W), bee7431 warned once in 70 min. The loop was at its bound on 4-5 cycles each quarter, all inside SAFETY-119's settle (12 cycles, 60 s at 5 s) and under its budget of 8 per 900 s.

Why the sim differed. test_safety119.py fed the meter one cycle behind the battery reading (5 s at a 5 s meter). After the loop left its rail, the guard's charge headroom was off by up to 5000 W, so the charge and the guard chased each other: about 20 bound cycles a quarter at 5 s (rig: 4-5). With the meter read in the same cycle (the rig's shape) the sim gives 3-5 a quarter, and bee7431 warns in 0-2 of 7 quarters, as on the rig.

Rule. After a hand-back the loop's bound is hidden until 4 cycles and 22 s have passed (HANDBACK_CYCLES, SHORT_SPAN_S). Across hand-backs at most 11 bound cycles are hidden in any 900 s (ROLLING_BOUND_CYCLES), at every cycle length. A bound that lasts past the settle counts on its first cycle after it, so the number of bound cycles in a quarter does not matter. The cycle-length table and its tracking are gone. A stop keeps the budget. An over-rating always counts. Commands unchanged.

Measured (2 h runs, goodwe-addon-checks:1; quarters warned of 7, new / bee7431 / no fix):

meter quarter edge: runs with a warning (new / bee7431 / no fix) overload, sim's old shape overload, rig's shape (5100 W; 5300 W at 15-30 s)
1 s 0/70 / 0/70 / 68/70 7 / 7 / 7 7 / 7 / 7
2 s 0/70 / 0/70 / 39/70 7 / 7 / 7 7 / 7 / 7
5 s 0/70 / 0/70 / 40/70 7 / 7 / 7 7 / 0-2 / 7
10 s 0/70 / 0/70 / 40/70 7 / 7 / 7 7 / 0 / 7
15 s 0/70 / 0/70 / 40/70 7 / 4-7 / 7 7 / 0 / 7
20 s 0/60 / 0/60 / 30/60 7 / 5-7 / 7 7 / 0 / 7
30 s 0/60 / 0/60 / 30/60 7 / 3-5 / 7 6-7 / 0 / 6-7

Quarter-edge seeds 1-30 (meter in the same cycle) and 1-40 (1-30 at 20/30 s; the test's 1-2 cycle delay). Commands are identical to no fix and to bee7431 in all 1013 runs. First warning after one hand-back, later than no fix by: 11 / 22 / 24 / 25 / 30 / 45 / 60 / 90 / 180 s at 1 / 2 / 3 / 5 / 10 / 15 / 20 / 30 / 60 s (bee7431: 10 / 20 / 30 / 40 / 80 / 90 / 80 / 120 / 240 s).

Limits (DECISIONS): a meter that jitters by 30 % with cycle_floor_s 15 and the test's meter delay false-alarms on 2, 2, 5 of 11 seeds at 15, 20, 30 s (bee7431: 4, 0, 10). The overload there at 5100 W leaves up to 4 quiet quarters at 15/20 s (bee7431: none warned on some seeds), with the first warning up to 61 min later than without the fix. These numbers depend on the jitter draw (review's draw: 4, 4, 5 of 11 at the quarter edge; bee7431 4, 1, 9). Above about 40 s per cycle, a bound that never outlasts a settle uses up the budget only if the wire changes hands every few cycles.

Tests. test_safety119.py: the rig's shape at 1, 2, 5, 10 and 15 s warns in every quarter, and SAFETY-119's settle and budget warn in at most one quarter (F-1 caught). The old shape warns every quarter at 2-15 s. Quarter edge silent at 1-15 s (seeds 1-3). Budget margins: 8 warns at 2 s seed 25, 14 misses at 1 s. Delays after one hand-back at 1, 5, 10 s. Settle and budget boundaries at 0.5-60 s, no clock, refill. A stop keeps the budget (review F2 X3). X4 (shortest cycle kept): that code path is gone. test_safety84/87 re-pinned: only OUTPUT_CLAMP log rows differ from bee7431 and from no fix.

Mutations (purged copies, each caught by test_safety119.py): settle 12 cycles, settle 3, span-or-cycles, no span, budget 8, budget 14, a stop resets the budget (X3), budget per hand-back, an over-rating uses the budget, budget never refills, no budget, settle one cycle longer.

No user text, CHANGELOG or version change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Bdqr7PiaHcBnzPituu2yTC

SAFETY-121 (Trello 6ad85901d4b96fa25025c529), follow-up of SAFETY-119 rig test F-1. Report: `reports/SAFETY-121-dev-report.md`. DECISIONS: `DECISIONS/SAFETY-121-bound-every-quarter.md`. **F-1.** On a 5 s meter, with a steady overload (2 x 2500 W, house 5100 W), bee7431 warned once in 70 min. The loop was at its bound on 4-5 cycles each quarter, all inside SAFETY-119's settle (12 cycles, 60 s at 5 s) and under its budget of 8 per 900 s. **Why the sim differed.** `test_safety119.py` fed the meter one cycle behind the battery reading (5 s at a 5 s meter). After the loop left its rail, the guard's charge headroom was off by up to 5000 W, so the charge and the guard chased each other: about 20 bound cycles a quarter at 5 s (rig: 4-5). With the meter read in the same cycle (the rig's shape) the sim gives 3-5 a quarter, and bee7431 warns in 0-2 of 7 quarters, as on the rig. **Rule.** After a hand-back the loop's bound is hidden until 4 cycles and 22 s have passed (`HANDBACK_CYCLES`, `SHORT_SPAN_S`). Across hand-backs at most 11 bound cycles are hidden in any 900 s (`ROLLING_BOUND_CYCLES`), at every cycle length. A bound that lasts past the settle counts on its first cycle after it, so the number of bound cycles in a quarter does not matter. The cycle-length table and its tracking are gone. A stop keeps the budget. An over-rating always counts. Commands unchanged. **Measured** (2 h runs, `goodwe-addon-checks:1`; quarters warned of 7, new / bee7431 / no fix): | meter | quarter edge: runs with a warning (new / bee7431 / no fix) | overload, sim's old shape | overload, rig's shape (5100 W; 5300 W at 15-30 s) | |---|---|---|---| | 1 s | 0/70 / 0/70 / 68/70 | 7 / 7 / 7 | 7 / 7 / 7 | | 2 s | 0/70 / 0/70 / 39/70 | 7 / 7 / 7 | 7 / 7 / 7 | | 5 s | 0/70 / 0/70 / 40/70 | 7 / 7 / 7 | **7 / 0-2 / 7** | | 10 s | 0/70 / 0/70 / 40/70 | 7 / 7 / 7 | **7 / 0 / 7** | | 15 s | 0/70 / 0/70 / 40/70 | 7 / 4-7 / 7 | **7 / 0 / 7** | | 20 s | 0/60 / 0/60 / 30/60 | 7 / 5-7 / 7 | 7 / 0 / 7 | | 30 s | 0/60 / 0/60 / 30/60 | 7 / 3-5 / 7 | 6-7 / 0 / 6-7 | Quarter-edge seeds 1-30 (meter in the same cycle) and 1-40 (1-30 at 20/30 s; the test's 1-2 cycle delay). Commands are identical to no fix and to bee7431 in all 1013 runs. First warning after one hand-back, later than no fix by: 11 / 22 / 24 / 25 / 30 / 45 / 60 / 90 / 180 s at 1 / 2 / 3 / 5 / 10 / 15 / 20 / 30 / 60 s (bee7431: 10 / 20 / 30 / 40 / 80 / 90 / 80 / 120 / 240 s). **Limits** (DECISIONS): a meter that jitters by 30 % with `cycle_floor_s` 15 and the test's meter delay false-alarms on 2, 2, 5 of 11 seeds at 15, 20, 30 s (bee7431: 4, 0, 10). The overload there at 5100 W leaves up to 4 quiet quarters at 15/20 s (bee7431: none warned on some seeds), with the first warning up to 61 min later than without the fix. These numbers depend on the jitter draw (review's draw: 4, 4, 5 of 11 at the quarter edge; bee7431 4, 1, 9). Above about 40 s per cycle, a bound that never outlasts a settle uses up the budget only if the wire changes hands every few cycles. **Tests.** `test_safety119.py`: the rig's shape at 1, 2, 5, 10 and 15 s warns in every quarter, and SAFETY-119's settle and budget warn in at most one quarter (F-1 caught). The old shape warns every quarter at 2-15 s. Quarter edge silent at 1-15 s (seeds 1-3). Budget margins: 8 warns at 2 s seed 25, 14 misses at 1 s. Delays after one hand-back at 1, 5, 10 s. Settle and budget boundaries at 0.5-60 s, no clock, refill. A stop keeps the budget (review F2 X3). X4 (shortest cycle kept): that code path is gone. test_safety84/87 re-pinned: only OUTPUT_CLAMP log rows differ from bee7431 and from no fix. **Mutations** (purged copies, each caught by `test_safety119.py`): settle 12 cycles, settle 3, span-or-cycles, no span, budget 8, budget 14, a stop resets the budget (X3), budget per hand-back, an over-rating uses the budget, budget never refills, no budget, settle one cycle longer. No user text, CHANGELOG or version change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Bdqr7PiaHcBnzPituu2yTC
admin added 1 commit 2026-10-21 10:09:56 +02:00
SAFETY-121: a recurring overload warns every quarter
checks / unit (pull_request) Successful in 44m51s
infra-pin / fresh (pull_request) Successful in 1s
8bf25696cb
TEST-23 F-1: on a 5 s meter a steady overload warned once in 70 min. The
loop was at its bound 4-5 cycles a quarter, all inside SAFETY-119's settle
of 12 cycles (60 s) and under its budget of 8 per 900 s. The simulation
fed the meter a cycle behind the battery reading, so the guard and the
charge chased each other and gave ~20 bound cycles a quarter.

The settle is now 4 cycles and 22 s (HANDBACK_CYCLES, SHORT_SPAN_S), and
the rolling budget one number, 11 per 900 s, at every cycle length. The
cycle length is no longer tracked. Commands unchanged; the re-pinned
digests of test_safety84/87 differ from bee7431 in OUTPUT_CLAMP rows only.
test_safety119 runs the rig's shape (meter in the same cycle) at 1-15 s
and checks a stop keeps the budget (review F2, X3).

Co-Authored-By: Claude <noreply@anthropic.com>
admin added 1 commit 2026-10-21 11:55:26 +02:00
SAFETY-121 review: DECISIONS limits state the jitter spread and the slow-cycle case
checks / unit (pull_request) Successful in 44m29s
infra-pin / fresh (pull_request) Successful in 1s
24f31a9c3a
The jittery-meter numbers depend on the draw (review: 4, 4, 5 of 11 at the
quarter edge; up to 4 quiet quarters at 20 s; first warning up to 61 min
later). Above about 40 s per cycle, a short bound can still use up the
budget when the wire changes hands every few cycles. Text only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Review (Opus) of 8bf2569: right. I pushed a text-only fix as 24f31a9 (DECISIONS limits and PR body); CI run 1363 checks / unit 80/80 and 1364 infra-pin / fresh are green on it. Merging 24f31a9.

Check 2 in plain words (for the owner):

  • With the default 5 s meter and the rig's shape, a steady overload now warns in every quarter, the same as before SAFETY-119. The same holds at 1, 2 and 3 s.
  • One hand-back to a loop that stays at its limit warns 25 s later than without the fix at 5 s (11 s at 1 s, 45 s at 15 s).
  • It can still be late in one setup: a 15 or 20 s meter whose interval jitters by about 30 %, with the house only about 100 W over the rating. There it warned in 3 to 7 of 7 quarters, with up to 4 quiet quarters in a row (1 h). At 200 W over, at most 1 quiet quarter.
  • "Never" is possible only for a bound shaped like the false alarm: the loop at its limit for at most 3 cycles (or 22 s) right after each hand-back, and no more than 11 such cycles in any 15 min. No rig-shaped or steady run did that. With cycles over about 40 s (non-default settings), a short bound like that is never counted unless the wire changes hands every few cycles.
  • A command over the rating still always warns. The cap and the commands did not change.

Evidence (goodwe-addon-checks:1, my own harness, 2 h runs, 2499 runs on 8bf2569 / bee7431 / no fix, scratch/SAFETY-121/review/):

  • Rig shape matches the rig: at 5 s, the first bound cycle is 30-35 s after the hand-back (rig 34-36 s), 3-6 bound cycles and 1-6 hand-backs a quarter (rig 4-5 and 1-3). At 1 s: 5-6 s after (rig 4-6 s), 23-29 bound cycles a quarter (rig 27).
  • bee7431 reproduces F-1 in the sim: 5 s, 5100 W, seeds 0-5: 0-2 of 7 quarters (5050 W: 0). Head: 7 of 7. The old shape (meter a cycle late) gives 8-14 hand-backs and about 21 bound cycles a quarter at 5 s; the dev's explanation holds.
  • Quarter edge: 0 notifications on head at 1 s (10 seeds), 2, 5, 15 and 20 s (seeds 1-30), both meter shapes; no fix 29-30/30 with the test's delay. Jittery map delay: head 4, 4, 5 of 11 at 15, 20, 30 s (bee7431 4, 1, 9). The 20 s regression is real (here 1 -> 4 seeds, 5 notifications in 22 h against 87 without the fix); small and now stated with both draws.
  • Commands identical head / bee7431 / no fix in every run. s84/s87: head digests = head pins; vs bee7431 and no fix only OUTPUT_CLAMP rows differ.
  • Mutations: dev M1, M5, M7, M11 re-run, all caught. Mine, all caught: settle in seconds only, budget window 450 s, a stop keeps the settle, budget per calendar quarter.
  • Full suite 80/80 with the hwsim line.

Findings

  • R1 (medium, owner info, not blocking): app/main.py:5891, jittery 15/20 s meter: up to 2/4 quiet quarters, first warning up to 31 min (dev: 61 min) later than without the fix. This is better than bee7431 (0-2 quarters) and stated in DECISIONS.
  • R2 (low, text, fixed in 24f31a9): DECISIONS/SAFETY-121-bound-every-quarter.md:84-85. "Over 40 s it cannot use up 11 in 900 s" is too strong; with a hand-back every 4 cycles it can (synthetic, 60 s: counted after 900 s). The jitter figures were from one draw; added the review's draw and the 61 min delay. The PR body has the same change.
  • R3 (info): an add-on restart starts with an empty budget (new Controller). It is a one-off of at most 11 hidden cycles.
**Review (Opus) of 8bf2569: right. I pushed a text-only fix as 24f31a9 (DECISIONS limits and PR body); CI run 1363 `checks / unit` 80/80 and 1364 `infra-pin / fresh` are green on it. Merging 24f31a9.** **Check 2 in plain words (for the owner):** - With the default 5 s meter and the rig's shape, a steady overload now warns in every quarter, the same as before SAFETY-119. The same holds at 1, 2 and 3 s. - One hand-back to a loop that stays at its limit warns 25 s later than without the fix at 5 s (11 s at 1 s, 45 s at 15 s). - It can still be late in one setup: a 15 or 20 s meter whose interval jitters by about 30 %, with the house only about 100 W over the rating. There it warned in 3 to 7 of 7 quarters, with up to 4 quiet quarters in a row (1 h). At 200 W over, at most 1 quiet quarter. - "Never" is possible only for a bound shaped like the false alarm: the loop at its limit for at most 3 cycles (or 22 s) right after each hand-back, and no more than 11 such cycles in any 15 min. No rig-shaped or steady run did that. With cycles over about 40 s (non-default settings), a short bound like that is never counted unless the wire changes hands every few cycles. - A command over the rating still always warns. The cap and the commands did not change. **Evidence** (`goodwe-addon-checks:1`, my own harness, 2 h runs, 2499 runs on 8bf2569 / bee7431 / no fix, `scratch/SAFETY-121/review/`): - Rig shape matches the rig: at 5 s, the first bound cycle is 30-35 s after the hand-back (rig 34-36 s), 3-6 bound cycles and 1-6 hand-backs a quarter (rig 4-5 and 1-3). At 1 s: 5-6 s after (rig 4-6 s), 23-29 bound cycles a quarter (rig 27). - bee7431 reproduces F-1 in the sim: 5 s, 5100 W, seeds 0-5: 0-2 of 7 quarters (5050 W: 0). Head: 7 of 7. The old shape (meter a cycle late) gives 8-14 hand-backs and about 21 bound cycles a quarter at 5 s; the dev's explanation holds. - Quarter edge: 0 notifications on head at 1 s (10 seeds), 2, 5, 15 and 20 s (seeds 1-30), both meter shapes; no fix 29-30/30 with the test's delay. Jittery map delay: head 4, 4, 5 of 11 at 15, 20, 30 s (bee7431 4, 1, 9). The 20 s regression is real (here 1 -> 4 seeds, 5 notifications in 22 h against 87 without the fix); small and now stated with both draws. - Commands identical head / bee7431 / no fix in every run. s84/s87: head digests = head pins; vs bee7431 and no fix only OUTPUT_CLAMP rows differ. - Mutations: dev M1, M5, M7, M11 re-run, all caught. Mine, all caught: settle in seconds only, budget window 450 s, a stop keeps the settle, budget per calendar quarter. - Full suite 80/80 with the hwsim line. **Findings** - R1 (medium, owner info, not blocking): `app/main.py:5891`, jittery 15/20 s meter: up to 2/4 quiet quarters, first warning up to 31 min (dev: 61 min) later than without the fix. This is better than bee7431 (0-2 quarters) and stated in DECISIONS. - R2 (low, text, fixed in 24f31a9): `DECISIONS/SAFETY-121-bound-every-quarter.md:84-85`. "Over 40 s it cannot use up 11 in 900 s" is too strong; with a hand-back every 4 cycles it can (synthetic, 60 s: counted after 900 s). The jitter figures were from one draw; added the review's draw and the 61 min delay. The PR body has the same change. - R3 (info): an add-on restart starts with an empty budget (new Controller). It is a one-off of at most 11 hidden cycles.
admin merged commit e077ae7f97 into release/1.0 2026-10-21 12:41:12 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/goodwe-addon#204