Repository navigation
fix: Codex review follow-ups for v0.107.0 (P1 + P2) - #383
Merged
Merged
Conversation
Four findings from Codex on the dispatch / loadmodel changes shipped in v0.107.0. Two are P1 (regressions that defeat their own PR's purpose); two are P2 (defensive predicate + observability gap). P1 (PR #377): SeedHeatingCoef preserves learned value across restarts. main.go called SetHeatingCoef unconditionally at startup, clobbering the persisted online-fit value with the config seed. Every binary update wiped the adaptive learning. New SeedHeatingCoef is a no-op when the model already has samples; operator config is the cold-start prior, observation drives the value once learning has begun. SetHeatingCoef remains for explicit operator override (eg. API endpoint, manual reset). P1 (PR #378): Cover-load carve-out forces grid_target=0. The carve-out only set useEnergyPath=false; production wires PlanTarget alongside SlotDirective, so the !useEnergyPath branch called PlanTarget and then SetGridTarget(plannedImportW). A cover-load slot with 1.7 kW planned import then made PI try to import 1.7 kW — the opposite of the carve-out's purpose. Fix routes both carve-out predicates to SetGridTarget(0) and skips the legacy PlanTarget block. P2 (PR #375): passiveArbitrageIdleSlot predicate tightened. Was `dir.BatteryEnergyWh <= idleWhGate` which matched any negative-energy slot (planned discharge). Tightened to |BatteryEnergyWh| ≤ idleWhGate. The planned-discharge case folds into coverLoadDischargeSlot, which is now extended to planner_passive_arbitrage too (was arbitrage-only). The live-export gate fires on either predicate. P2 (PR #379): SlotDeliveryStats.SignMismatchCount. Planned -425 Wh vs actual +425 Wh would have scored |ratio|=1.0=on-target — the largest possible miss, invisible. New counter fires when planned and actual have opposite signs for non-idle slots; the magnitude over/under counters then only fire on same-sign cases, keeping their semantics clean. Tests: - TestSeedHeatingCoefDoesNotOverwriteLearnedValue - TestSeedHeatingCoefAppliesOnColdStart - TestPlannerArbitrageCoverLoadChasesGridZeroNotPlannedImport - TestCoverLoadDischargeDoesNotAbsorbLiveSurplus (both modes) - TestSlotMetricsDetectsSignMismatch Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
4 tasks done
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.
Summary
Four Codex review findings on the dispatch / loadmodel changes that shipped in v0.107.0. Two P1 + two P2.
P1 — Heating coefficient survives restarts (#377 review)
main.gocalledloadSvc.SetHeatingCoef(cfg.Weather.HeatingWPerDegC)at startup, unconditionally overwriting the persisted online-fit value. Every binary update wiped the adaptive learning. NewSeedHeatingCoef(w)is a no-op when the model has samples; operator config is the cold-start prior, observation drives the value once learning has begun.P1 — Cover-load carve-out forces grid_target=0 (#378 review)
The cover-load carve-out only set
useEnergyPath=false; production wires bothSlotDirectiveandPlanTarget, so!useEnergyPathcalledPlanTargetandSetGridTarget(plannedImportW). A cover-load slot with +1.7 kW planned import then made PI try to import 1.7 kW — the opposite of the carve-out's purpose. Fix routes both carve-out predicates (passiveArbitrageIdleSlot,coverLoadDischargeSlot) toSetGridTarget(0)and skips the legacy PlanTarget block.P2 — Predicate tightened to true idle (#375 review)
passiveArbitrageIdleSlotusedBatteryEnergyWh <= idleWhGate, true for any negative-energy slot. Tightened to|BatteryEnergyWh| <= idleWhGate. The planned-discharge case folds intocoverLoadDischargeSlot, which is now extended toplanner_passive_arbitragetoo (was arbitrage-only). The live-export gate fires on either predicate.P2 — SlotDeliveryStats catches sign mismatches (#379 review)
Planned
-425 Whvs actual+425 Whwould have scored|actual|/|planned| = 1.0 = on-target— the largest possible miss, invisible on/api/status. NewSignMismatchCountfires when planned and actual have opposite signs (and both above idle cutoff); magnitude over/under counters then only fire on same-sign cases.Test plan
TestSeedHeatingCoefDoesNotOverwriteLearnedValueTestSeedHeatingCoefAppliesOnColdStartTestPlannerArbitrageCoverLoadChasesGridZeroNotPlannedImportTestCoverLoadDischargeDoesNotAbsorbLiveSurplus/{arbitrage,passive_arbitrage}TestSlotMetricsDetectsSignMismatchgo test ./...green (unit + e2e)make verify-allclean🤖 Generated with Claude Code