Repository navigation
feat(schedule): gate spend on progress, spend only after writeback - #325
Open
raymondginger2018-sudo wants to merge 1 commit into
Open
raymondginger2018-sudo wants to merge 1 commit into
raymondginger2018-sudo wants to merge 1 commit into
Conversation
Two optional control-plane layers on top of the keepalive scheduler, both inert by default so existing callers behave exactly as before: - SpendGate is asked before each turn and adds the signal the continuation gate cannot see: a brake on runs that reported no progress (RunOutcome.progress_made is False). Fail-closed: an unset field never defaults to "run". - run_turn orders one turn as execute -> typed result -> validation -> durable writeback -> spend, so quota is never spent on a turn that did not write back. Asking for spend without a writeback raises instead of silently spending. - core/schedule/should_run.py (new): ShouldRunDecision + SpendGate - core/schedule/turn_transaction.py (new): TurnReceipt + run_turn - core/schedule/scheduler.py: consult the gate between runs - core/schedule/__init__.py: export both layers - tests/test_schedule.py: 23 cases (11 gate, 7 transaction, 3 scheduler)
This branch has not been deployed
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.
Summary
Two optional control-plane layers on top of the keepalive scheduler. Both are inert by
default, so a caller that passes neither behaves exactly as before.
SpendGate is asked before each turn and adds the one signal the continuation gate cannot
see: a brake on runs that reported no progress (
RunOutcome.progress_made is False). It isfail-closed — an unset field never defaults to "run".
run_turn orders one turn as execute → typed result → validation → durable writeback →
spend, so quota is never spent on a turn that did not write back. Asking for spend without a
writeback raises rather than quietly spending, and a failed spend keeps the writeback.
Both module docstrings record which decisions mirror the LOOPX contracts and why, so the
next reader does not have to reconstruct the provenance.
Changes
core/schedule/should_run.py(new):ShouldRunDecision+SpendGatecore/schedule/turn_transaction.py(new):TurnReceipt+run_turncore/schedule/scheduler.py: consult the gate between runs; document both layerscore/schedule/__init__.py: export bothtests/test_schedule.py: 23 cases — 11 gate, 7 transaction, 3 schedulerBehaviour
Unchanged when unused.
spend_gate=Noneand no writeback/spend hooks reproduce the previousscheduler path exactly; the new tests pin that the layers stay out of the way.
Tests
Scope note
The full local CI replay was not run. Verification is targeted (the schedule suite plus
lint). Upstream CI is the authoritative gate.