Repository navigation
[codex] harden fuse safety guards - #342
Conversation
2feb38c to
888ec20
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 888ec204f1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| targets = applyFuseGuard(targets, store, state, fuseMaxW) | ||
| targets = forceFuseDischarge(targets, store, state, driverCapacities, fuseMaxW) | ||
| now := time.Now() | ||
| state.LastDispatch = &now |
There was a problem hiding this comment.
Avoid holding off after manual charge
When an operator exits ModeCharge into a normal mode within MinDispatchIntervalS (default 5s), this new timestamp makes the holdoff branch run before the normal dispatch path, so ComputeDispatch returns only fuseSaverFromZero (usually nil) instead of issuing the new self-consumption target. Because drivers keep following the last charge command until a replacement is sent, leaving manual charge can continue charging for an extra tick; either skip updating LastDispatch here or have mode changes/manual overrides bypass/reset the holdoff.
Useful? React with 👍 / 👎.
Summary
fuse.phasesandfuse.voltagevalues during config validation.applyFuseGuardprediction to subtract only the batteries that are actually controlled in the current dispatch target set.ModeChargetargets through the same fuse guard and reactive fuse-saver as normal dispatch paths.Root cause
The fuse-guard prediction summed every battery reading in telemetry, including stale/offline batteries that were not receiving a replacement target. Because those stale readings are already reflected in the live grid meter, subtracting them again could under-predict fuse pressure and miss an overage.
A second audit finding showed
ModeChargereturnedchargeAll(...)directly before the safety post-processing path, so a manual fill command could push import past the configured fuse.Validation
cd go && go test ./internal/controlmake test