Repository navigation
refactor(control): remove the priority and weighted modes - #1453
Conversation
- #7 priority/weighted: remove ModePriority and ModeWeighted, State.PriorityOrder and Weights, distributePriority/distributeWeighted, their revision hashing, catalogue, contract registry and HA select entries, and the never-read batteries.<name>.weight setting and its Settings field. Priority held every battery at its measured power because nothing set its order. A stored priority or weighted mode boots as self_consumption, is saved back and logged once; the API, HA and the app refuse both. Their 60 golden records are dropped (611 -> 551, deletions only) and the e2e target-following step runs in self_consumption. - #34 HA mode: haCallbacks.SetMode now calls appModes.SetMode, so it goes through control.ApplyMode, only logs a failed save, still applies the export preference and replans without blocking the MQTT handler. - #36 UseCascade: delete the unread control.State field and its initializer. - #37 use_energy_dispatch: drop the deprecated key. Loading YAML or stored settings turns it into planner.legacy_dispatch (the old key still wins), DropRetiredSettings deletes it and battery weights from state.db, and one energyDispatchEnabled helper serves boot and hot reload, which no longer keeps the legacy path after the planner section is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf64b0b477
ℹ️ 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".
| mpcSvc.SetMode(ctx, mm) | ||
| } | ||
| return nil | ||
| return modes.SetMode(ctx, control.Mode(m)) |
There was a problem hiding this comment.
Serialize planner updates from Home Assistant mode changes
When Home Assistant sends two planner-mode commands close together, this now routes both through appModes.SetMode, which acknowledges each command before launching mpc.SetMode in independent goroutines. Those goroutines need not start in command order, so the older command can run last and overwrite the planner mode and plan while ctrl.Mode and the persisted value contain the newer selection; for example, selecting active and then passive arbitrage can leave the planner exporting under active arbitrage. Serialize or coalesce these MPC updates, or verify that the requested mode is still current before replanning.
AGENTS.md reference: AGENTS.md:L28-L30
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ority-weighted-modes # Conflicts: # go/cmd/ftw/main.go
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7
Contract-pair: srcfl/ftw-webapp@follow-core/modes-and-boost
Paired with srcfl/ftw-webapp#73, which drops the same two keys from its copy of
contract/registry.yaml.Round 2 of the multi-agent hardening and refactor review. A skeptic confirmed each finding against the code, and a second reviewer checked this diff and ran its tests. Removals follow the owner decisions of 2026-09-26.
Changes
Evidence
From /home/fredde/repos/ftw/.claude/worktrees/wf_8f55b108-a0d-3/go with the session toolchain (go1.26.8) and GOTMPDIR=/home/fredde/.cache/go-tmp:
Review
The removal is correct. The four findings are fixed, and the only thing blocking the merge is the unpaired webapp contract change.
#7: ModePriority, ModeWeighted, PriorityOrder, Weights, distributePriority, distributeWeighted, their revision hashing, the catalog and registry entries and the generated contract are all gone. A grep over go/, web/, docs/, scripts/, contract/ and config.example.yaml finds no references apart from the migration and its tests. restoreStoredMode (go/cmd/ftw/control_state.go) turns a stored priority or weighted into self_consumption, saves it and logs one Warn line. It runs before the planner-prefs resolution and the planner_arbitrage-to-passive migration, so boot order is right. Any other unknown value keeps the old behaviour. The API, HA and the app all refuse both modes through IsValidMode/ApplyMode. The HA select options come from AllModes. The golden corpus lost only records; the seeded rotations keep empty slots, so every surviving record keeps its seed, and the replay passes. TestMeterClampRespectsNonZeroGridTarget now uses self_consumption, which its own comment already described.
#34: haCallbacks.SetMode now goes through appModes.SetMode and …
Open points:
contract/registry.yaml:149: The paired ftw-webapp change does not exist yet. srcfl/ftw-webapp main still lists{ key: weighted, tier: hidden }andpriorityin contract/registry.yaml, and it is byte-identical to origin/master's copy. It also has a hand-written 'weighted' mode in src/lib/sim/box.ts and src/lib/format/plan.test.ts. The requiredcontractCI job in .github/workflows/test.yml diffs the two copies, so it will fail until a paired ftw-webapp PR removes both lines and this PR's body carriesContract-pair: srcfl/ftw-webapp@<ref>. The author disclosed this. It blocks the merge, but the code here is correct.🤖 Generated with Claude Code
https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7