Skip to content

fix(planner): the trust slider always works — YAML k is a first-boot seed - #1018

Merged
frahlg merged 1 commit into
masterfrom
trust-slider-ui-first
Aug 30, 2026
Merged

frahlg merged 1 commit into
masterfrom
trust-slider-ui-first

Conversation

@frahlg

@frahlg frahlg commented Aug 30, 2026 •

Copy link
Copy Markdown
Member

Closes #1017. Owner report: the "Follow the forecast" slider cannot be dragged on any site with an explicit pv_forecast_safety_k in config.yaml — the UI note says the file wins. The reporter's box has pv_forecast_safety_k: 1, identical to the "balanced" mapping, so the lock bought nothing.

What

Same stored-wins contract forecast_trust got in #968, completed for the haircut:

  • pv_forecast_safety_k seeds the first boot only: TrustFromSafetyK maps it to the nearest step (≤ 0.25 → bold, < 1.5 → balanced, else cautious) when neither SQLite nor a YAML forecast_trust has a value; the result persists and the slider owns it from then on.
  • EffectiveSafetyK is the trust mapping, always. YAMLCustomK deleted; the unused PVSafetyK helper (which still honored YAML verbatim) deleted with its tests — dead code carrying the old rule invites the bug back.
  • API: yaml_custom / planner_yaml_custom removed from /api/planner/prefs and /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 YAML
  • TestPlannerEffectiveSafetyKFollowsTrust, TestPlannerSafetyKFollowsTrustNotYAML — mapping wins regardless of YAML
  • TestYAMLKNeverLocksTheSlider — prefs endpoint reports no lock and the mapped k
  • web: prefsFromStatus tests updated (451 green)

🤖 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_k in config.yaml permanently 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, ResolvePlannerPrefs can map pv_forecast_safety_k to the nearest trust step via new TrustFromSafetyK (≤0.25 → bold, <1.5 → balanced, else cautious), persist it, and the slider owns the value afterward—same stored-wins contract as forecast_trust. EffectiveSafetyK always returns the trust step’s haircut scale; it no longer prefers YAML over the slider. Removed PVSafetyK, YAMLCustomK, and API/UI yaml_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 yamlK into ResolvePlannerPrefs; MPC still gets EffectiveSafetyK(trust) from live prefs.

Reviewed by Cursor Bugbot for commit 99b37ac. Bugbot is set up for automated code reviews on this repo. Configure here.

…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
@frahlg
frahlg merged commit 44c62d1 into master Aug 30, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-30T10:21:01.886962Z 99b37ac PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +122 to +123
} else if yamlK != nil {
trust = TrustFromSafetyK(*yamlK)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines 148 to 149
func (p *Planner) EffectiveSafetyK(trust ForecastTrust) float64 {
if p != nil && p.PVForecastSafetyK != nil {
return *p.PVForecastSafetyK
}
return trust.SafetyK()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Cursor Bugbot completed successfully with no findings that need human review, and no approval policy requires a human reviewer. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@frahlg
frahlg deleted the trust-slider-ui-first branch November 11, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forecast-trust slider is locked whenever pv_forecast_safety_k exists in config.yaml

1 participant