fix(calibration): implement the grid power safety guard#3
Open
bvweerd wants to merge 1 commit into
Open
Conversation
CALIB_MAX_GRID_W ("abort if |grid_w| exceeds this") was defined but
never used — the documented safety check did not exist. During
calibration the controller is suspended and arrays are forced to
20-30%, so a consumption spike could drive a large uncontrolled grid
exchange with nothing watching.
The calibrator now accepts an async read_grid callable (wired to the
coordinator's grid reading) and checks it on every settling poll; when
|grid| exceeds the limit the array's calibration fails with a clear
message and the original setpoint is restored via the existing finally
block. Unavailable grid reads are ignored (fail-open).
Also removes the dead CALIB_BASELINE_SAMPLES and CALIB_STEP_* constants
left over from the previous grid-based calibration approach.
https://claude.ai/code/session_01RUWpwxbGsgR3PoLHLq4Djz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CALIB_MAX_GRID_W("Abort if |grid_w| exceeds this") was defined inconst.pybut never referenced — the documented safety guard did not exist. During calibration normal control is suspended and the array under test is forced to a 20–30% limit, so a consumption or production spike could drive a large uncontrolled grid exchange with nothing watching for it.Fix
ArrayCalibratoraccepts an optional asyncread_gridcallable; the coordinator wires it to its own grid reading.CALIB_MAX_GRID_W(3000 W) the array's calibration fails with a clear message (Aborted: |grid| exceeded 3000 W during calibration).finallyblock guarantees the original setpoint is restored on abort.CALIB_BASELINE_SAMPLESandCALIB_STEP_*constants left over from the earlier grid-based calibration approach.Tests
Two new tests in
tests/test_calibration.py: abort with setpoint restore when the limit is exceeded, and no abort when the grid read returnsNone. Full suite: 128 passed.https://claude.ai/code/session_01RUWpwxbGsgR3PoLHLq4Djz
Generated by Claude Code