Repository navigation
fix(planner): the trust slider always works — YAML k is a first-boot seed - #1018
Conversation
…seed Owner report (#1017): the Plan card's forecast-trust slider was permanently disabled on any site with an explicit pv_forecast_safety_k in config.yaml, with a note telling the operator to go edit the file — a config file acting as a user interface. The reporter's box had pv_forecast_safety_k: 1, the same value as "balanced", so the lock bought nothing at all. The field now follows the same stored-wins contract forecast_trust got in #968: on a first boot with nothing stored it seeds the nearest trust step (k ≤ 0.25 → bold, < 1.5 → balanced, else cautious) and is never consulted again — EffectiveSafetyK is the trust mapping, YAMLCustomK and the dead PVSafetyK helper are gone, the API stops reporting yaml_custom/planner_yaml_custom, and the UI loses the disable + the "config.yaml wins" note. Closes #1017. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01C1d4uknzs7QUv7nE9rW4fi
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99b37ac20b
ℹ️ 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".
| } else if yamlK != nil { | ||
| trust = TrustFromSafetyK(*yamlK) |
There was a problem hiding this comment.
Migrate legacy YAML K before honoring seeded trust
On upgrades from the previous release, this branch is skipped because that release already persisted forecast_trust—usually balanced—during startup even when pv_forecast_safety_k controlled the effective haircut. Consequently, an existing site with YAML k: 0 or k: 2 silently changes to k=1 after upgrading instead of seeding bold or cautious as intended. Add an explicit one-time migration marker or otherwise distinguish the automatically seeded preference from a value the user selected; the added test only exercises empty SQLite and therefore misses the actual upgrade state.
AGENTS.md reference: AGENTS.md:L81-L84
Useful? React with 👍 / 👎.
| func (p *Planner) EffectiveSafetyK(trust ForecastTrust) float64 { | ||
| if p != nil && p.PVForecastSafetyK != nil { | ||
| return *p.PVForecastSafetyK | ||
| } | ||
| return trust.SafetyK() |
There was a problem hiding this comment.
Remove the now-ignored K control from Settings
When planner.pv_forecast_safety_k already exists, web/settings/tabs/planner.js still renders an editable numeric field and describes it as directly changing the forecast hedge, including a live k·σ preview. Since EffectiveSafetyK now ignores that field, saving it—even followed by a restart—cannot affect planning, so Settings exposes a dead and misleading control. Remove or relabel that field as a migration-only value, or route edits through the stored planner preference.
Useful? React with 👍 / 👎.


Closes #1017. Owner report: the "Follow the forecast" slider cannot be dragged on any site with an explicit
pv_forecast_safety_kin config.yaml — the UI note says the file wins. The reporter's box haspv_forecast_safety_k: 1, identical to the "balanced" mapping, so the lock bought nothing.What
Same stored-wins contract
forecast_trustgot in #968, completed for the haircut:pv_forecast_safety_kseeds the first boot only:TrustFromSafetyKmaps it to the nearest step (≤ 0.25 → bold, < 1.5 → balanced, else cautious) when neither SQLite nor a YAMLforecast_trusthas a value; the result persists and the slider owns it from then on.EffectiveSafetyKis the trust mapping, always.YAMLCustomKdeleted; the unusedPVSafetyKhelper (which still honored YAML verbatim) deleted with its tests — dead code carrying the old rule invites the bug back.yaml_custom/planner_yaml_customremoved from/api/planner/prefsand/api/status; UI: the disable, the note element, and the yaml fallback in the hedge line removed.Upgrade effect on the reporter's site: stored trust "balanced" (k=1) — numerically identical to the YAML value, so plans do not change; the slider becomes live.
Tests
TestResolvePlannerPrefsSeedsFromYAMLK— k seeds once, stored always beats YAMLTestPlannerEffectiveSafetyKFollowsTrust,TestPlannerSafetyKFollowsTrustNotYAML— mapping wins regardless of YAMLTestYAMLKNeverLocksTheSlider— prefs endpoint reports no lock and the mapped k🤖 Generated with Claude Code
https://claude.ai/code/session_01C1d4uknzs7QUv7nE9rW4fi
Note
Medium Risk
Changes how MPC downside-PV planning (
PVForecastSafetyK) is sourced for sites that relied on YAML overriding the UI; behavior should match stored trust after first boot, but first-boot seeding and removed lock semantics affect planner economics.Overview
Fixes sites where an explicit
pv_forecast_safety_kinconfig.yamlpermanently disabled the Plan card’s “Follow the forecast” slider and showed a “config.yaml wins” note (#1017).Preference resolution now treats that YAML field as a first-boot seed only: when SQLite has no
forecast_trust,ResolvePlannerPrefscan mappv_forecast_safety_kto the nearest trust step via newTrustFromSafetyK(≤0.25 → bold, <1.5 → balanced, else cautious), persist it, and the slider owns the value afterward—same stored-wins contract asforecast_trust.EffectiveSafetyKalways returns the trust step’s haircut scale; it no longer prefers YAML over the slider. RemovedPVSafetyK,YAMLCustomK, and API/UIyaml_custom/planner_yaml_custom.The dashboard always enables the trust slider, drops the YAML override message, and derives the hedge line from the slider (not a YAML lock). Boot passes
yamlKintoResolvePlannerPrefs; MPC still getsEffectiveSafetyK(trust)from live prefs.Reviewed by Cursor Bugbot for commit 99b37ac. Bugbot is set up for automated code reviews on this repo. Configure here.