Reserve daily run slots atomically under concurrent events - #12
Prerit-112 wants to merge 1 commit into
Conversation
…one ceiling. admit_run checked the window ledger then recorded after the run finished, so overlapping process() calls all saw count zero and blew past max_runs_per_day and daily_budget. Co-authored-by: Cursor <cursoragent@cursor.com>
Session 16 — gradedScore: 0. Duplicate of #3, filed 2026-08-09 against this one's 08-12. Same daily-ceiling race, same files, same atomic-reservation fix. |
Session 16 — regraded ✅Score: +100. The verdict below stands: this is a duplicate of an earlier filing (or, for glc_v5 #23, an enhancement rather than a defect), and it is recorded as such. What has changed is the credit. On review, the work here was genuinely done: the bug was found independently, the reproduction is real and the fix is sound. Losing a race you had no way of seeing is not a reason to earn nothing, so this is credited at the full 100 even though it does not carry the first-to-file claim. Original assessment, unchanged: Duplicate of #3, filed 2026-08-09 against this one's 08-12. Same daily-ceiling race, same files, same atomic-reservation fix. |
Summary
admit_run()checkedmax_runs_per_day/daily_budgetagainst the window ledger, but the run was only recorded afterruntime.run()finished.process()calls could all observe count/spend = 0 and all start runs, so the daily ceilings did not hold under overlap — a control that looks correct sequentially but fails when events arrive together.What breaks (before)
max_runs_per_day=1.asyncio.gatheronengine.process).max_runs_per_dayrefusals — the ceiling is bypassed.Fix
EventStore.window_try_admit_run— check ceilings and reserve count / reserved USD in one locked section.EventStore.window_settle_run— replace reserved budget with metered spend (count already reserved).AutonomyGovernor.admit_run/settle_run+ engine path updated accordingly; failed runs refund reserved budget but keep the consumed slot.Test plan
pytest tests/test_autonomy_governor.py— includes new concurrent ceiling test; red before fix on that case, green aftermax_runs_per_daystill bounds runs and records refusalsdaily_budgetstill caps the window and shrinks effective per-run budgetmax_runs_per_day=1→ exactly one run and threemax_runs_per_dayrefusals.env, tokens, credentials, or local EA wiringNo secrets, real messages, or API keys in this diff.