Skip to content

WP2: fail-safe an inspector accepts - static share under everything - #10

Merged
Neal006 merged 1 commit into
mainfrom
worktree-wp2-safe-share
Sep 13, 2026
Merged

Neal006 merged 1 commit into
mainfrom
worktree-wp2-safe-share

Conversation

@Neal006

@Neal006 Neal006 commented Sep 13, 2026

Copy link
Copy Markdown
Owner

WP2 of prompt.md (solutions.md §5). Plan and deviations: .docs/implementation-plan.md (A4, deviation 5).

What changed

  • sim.safe_share_kw(site) = min(p_max, (feed − max building load) / n_connectors) → 1.833 kW on site-1 (site.json: safe_share_kw). 60 × 1.833 = 110 kW = feed − worst building load, with no controller at all.
  • Connector(id, p_max_kw, safe_kw): plug-in starts on the static share; a dynamic set_limit expires 15 sim-minutes after it was last refreshed (DYN_VALID_MIN) and the connector reverts to the share — the sim now behaves like a charger holding an OCPP profile with valid_to. In normal operation apply_limits() refreshes every minute, so nothing changes.
  • pick_mode("full") plan, the apply_limits() no-plan fallback and the scheduler's linprog fallback (_full_power(cars, site)) all return the static share instead of p_max.
  • ocpp_gateway: two profiles per connector — static share at stack_level 0, no expiry, sent once after BootNotification; dynamic plan at stack_level 1, valid_to = now + 15 min, re-sent every 10 sim-minutes. The simulated charge point keeps both (Charger.profiles) and applies the highest live one; python -m noonshift.ocpp_gateway shows the revert once the dynamic profile expires. Gotcha found on the way: await self.call() inside an @after handler deadlocks the ocpp message loop — it is sent as a task.
  • StatusOut.safe_share_kw (additive); contract files regenerated.

Tests (fail on old code)

  • test_when_the_control_loop_dies_the_site_falls_back_to_the_static_share: play to 10:30, then 6 h of sim.tick() with no step() — EV kW never exceeds feed − building, and after 15 min never exceeds n × share; every plugged car ends on the share.
  • test_demo_signal_outage…: the full rung now puts every charger on the share (was p_max).
  • Sim self-check rewritten: no-controller replay peaks at 52 kW; fail-open replay 104 kW.

64 pass · smoke.py SMOKE OK · prove.py unchanged: CO₂ −64.6 %, bill −2.9 %, peak −1.0 %, 0 fallbacks, max 63 ms.

Assumption

  • A4 safe_share_kw default = the computed value above; the demo ships it explicitly in site.json.

🤖 Generated with Claude Code

https://claude.ai/code/session_017thvbGo7rTVnG2f46cLMzU

…hing

- sim.safe_share_kw(site) = min(p_max, (feed - max building load) / n)
  (1.833 kW on site-1); Connector carries safe_kw: plug-in starts on it,
  and a dynamic limit expires DYN_VALID_MIN (15) minutes after the last
  set_limit, exactly like an OCPP profile with valid_to.
- pick_mode("full") plan, apply_limits() fallback and scheduler's linprog
  fallback (_full_power) return the static share, not p_max.
- ocpp_gateway: two profiles per connector - static share at stack 0 sent
  once after BootNotification (as a task; awaiting inside @after deadlocks
  the message loop), dynamic plan at stack 1 with valid_to = now + 15 min,
  refreshed every 10 sim-min. Charger keeps profiles and applies the highest
  live one; self-check shows the revert once the dynamic one expires.
- StatusOut.safe_share_kw (additive); site.json: safe_share_kw 1.833.
- Tests: kill the control loop at 10:30 and tick 6 h - site never exceeds
  headroom, after 15 min never exceeds n * share; full rung = share.
  64 pass; smoke OK; prove.py unchanged (64.6 %, 0 fallbacks).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017thvbGo7rTVnG2f46cLMzU
Copilot AI lite review requested due to automatic review settings September 13, 2026 00:24

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Neal006
Neal006 merged commit 7aef92a into main Sep 13, 2026
3 checks passed
@Neal006
Neal006 deleted the worktree-wp2-safe-share branch September 13, 2026 00:45
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.

2 participants