Repository navigation
WP3: vehicle form, observation guard, asap bays, done events, queue with move-by - #11
Merged
Merged
Conversation
…ueue with move-by
- POST /sessions accepts vehicle{model,battery_kwh,max_kw}, soc_now,
target_soc: kwh_needed = (target - now) * battery; need_confidence
declared | history (bay median) | site (day median) replaces the 8.0 default.
car() plans with min(bay, car); the sim draws min(limit, car_kw * taper).
- Observation guard: 5 min under 80 % of the limit (not tapering) -> max_kw =
metered * 1.05 for the session, event cap_observed.
- site.json connectors_asap [c41, c42]: those bays are always ASAP.
- Sim.tick emits done (+ idle_since); Sim.waiting holds arrivals with no bay
and plugs them FIFO as bays free; a done car idle >= 10 min is unplugged
when someone waits (assumption A5). resolve() gives the slackest plugged
cars a move-by deadline (now + e_rem / p_max), one per waiting car, never
urgent or < 1 h slack; event move_by. /demo/oversubscribe queues instead
of dropping.
- Additive contract: SessionOut/ConnectorMeter/MeterMsg/StatusOut fields,
EventMsg names done | cap_observed | move_by. Contract files regenerated.
- 5 new tests (69): 3.3 kW car planned at 3.3 and full by its deadline;
need from history/site; guard trips and the plan follows; asap bay at
full power with 8 h slack; queue of 60 late cars tightens the slackest,
waiting cars get bays, done events fire. smoke OK; prove unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017thvbGo7rTVnG2f46cLMzU
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.
WP3 of
prompt.md(solutions.md§3, §10, §11). Plan and deviations:.docs/implementation-plan.md(A5, deviations 6 and 8).What changed
POST /sessionstakes optionalvehicle {model, battery_kwh, max_kw},soc_now,target_soc(default 1.0).kwh_needed = (target − now) × batterywhen given; the brain plans withmin(bay, car).need_confidenceon the session:declared(form or typed kWh) →history(this bay's median) →site(the day's median). The old hard-coded8.0default is gone.max_kw = metered × 1.05for the rest of the session and acap_observedevent. The sim carriescar_kw(what the car can physically draw) separately frommax_kw(what the planner believes) so this is testable.connectors_asapinsite.json(c41,c42— clear of both replayed datasets and the smoke bays): those bays are always ASAP incar().Sim.tickemitsdoneand stampsidle_since;ConnectorMeter.idle_min.Sim.waitingholds arrivals with no free bay and plugs them first-come-first-served as bays free (plug_inevents carrywaited_min). A5: a done car idle ≥ 10 min is unplugged when someone is waiting — the sim's stand-in for "done, please move"; real-world signal is OCPP StatusNotification.deadline = now + e_rem / p_max(+ one slot), one tightened car per waiting car, never an urgent car or one with < 1 h slack; eventmove_by./demo/oversubscribenow queues instead of dropping and reportswaiting.SessionOut,ConnectorMeter,MeterMsg.waiting,StatusOut.waiting/connectors_asap, event names); contract files regenerated.Tests (fail on old code) — 69 pass
max_kw3.47, event, plan follows.doneevents fire.smoke.py: van onc41at full power; PHEV form → 8 kWh declared, capped at 3.3. SMOKE OK.prove.pyunchanged: CO₂ −64.6 %, bill −2.9 %, peak −1.0 %, 0 fallbacks (564 solves now —doneevents re-solve).🤖 Generated with Claude Code
https://claude.ai/code/session_017thvbGo7rTVnG2f46cLMzU