Repository navigation
WP1: shared-savings price, three urgency bands, first-hour floor - #9
Merged
Merged
Conversation
- scheduler.price(slack, *, r, saving_usd, kwh, alpha, urgent): business.md
§7b, R - alpha*S/E clamped to [0, R]; urgent or < 1 h slack pays exactly R.
No hardcoded prices left in noonshift/.
- POST /sessions/{id}/urgency {level: now|soon|priority, leave_at?};
/boost is the alias of "now". Per-car floor_alpha / priority in solve_lp
(priority car's shortfall weighs prio-fold in the fairness term and costs
prio * M_SHORT, so it gives way last).
- First-hour floor: min(need, 3.5 kWh) 60 min after plug-in, elastic through
the floor slack. prove.py: CO2 -69.3 % -> -64.6 %, bill -3.3 % -> -2.9 %,
peak -1.0 %, 0 fallbacks. The floor alone costs 4.8 pts (16.0 -> 14.9 kg).
- Correctness fix the floor exposed: slot 0 only has its remaining minutes
ahead (dur[0]); floor checkpoints are times since arrival, pro rata inside
the slot containing the mark. Without it a mid-slot re-solve after every
plug-in event booked energy that could no longer be delivered.
- site.json: employee_rate_usd_per_kwh 0.25, driver_share 0.5,
noonshift_share 0.2. Contract files regenerated (additive).
- 10 new tests (63 total); smoke.py exercises soon + priority.
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.
WP1 of
prompt.md. Plan and deviations:.docs/implementation-plan.md.prove.py before → after
530 solves, max 67 ms, 0 fallbacks, GATE PASS. With the first-hour floor switched off the after-code gives 69.4 %, so the floor alone costs 4.8 points of CO₂ saving (16.0 → 14.9 kg/day, $0.23/day) — above the 2–3 % the spec guessed, well under the 15 % gate. Kept: it is the trust promise (
business.md§4).What changed
price(slack, *, r, saving_usd, kwh, alpha, urgent)=R − α·max(S,0)/E, clamped to[0, R]; urgent or < 1 h slack → exactlyR. Tier labels unchanged.git grep "0.40" noonshift/→ nothing./pricepreview uses today's site saving rate so far (estimate).POST /sessions/{id}/urgency {level, leave_at?};/boost= alias ofnow.now→ deadline = now + boost;soon→ deadline =leave_at(< 15 min ⇒now);priority→floor_alpha 0.9,priority 2.0insolve_lp(shortfall weighs 2× in the fairness term and costs 2×M_SHORT). Eventboostfornow(both front-ends already handle it),urgencyfor the other two.min(need, 3.5 kWh)by arrival + 60 min, elastic through the floor slack.test_first_hour_floor_holds_for_every_car_on_the_day— asserted for the first hour only; the docstring says why (beyond it the 50 % pro-rata floor is the guarantee; a dumb-charger bound over every rolling hour would forbid shifting).Assumptions (spec asked to confirm)
employee_rate_usd_per_kwh: code default0.0(free);data/site.jsonships0.25(flat employee rate case, §0b) so the demo shows the §7b math instead of three $0.00 chips. Set to 0 for a free site./boost=urgency now→ WattWise "Charge now" forfeits the discount, per §4b.price()denominator iskwh_neededwhile charging (the receipt's saving covers the planned series;kwh_deliveredis 0 at plug-in) andkwh_deliveredonce ended.Tests
63 pass (10 new): price ≤ R / urgent = R / §6b 0.247;
nowfull power next slot;priority≥ 90 % pro-rata at every checkpoint and 0 shortfall when oversubscribed; 3.5 kWh at 60 min (unit + every car on the day); mass arrival bursts the block, never the feed.smoke.py→ SMOKE OK incl.soon+priority.🤖 Generated with Claude Code
https://claude.ai/code/session_017thvbGo7rTVnG2f46cLMzU