Repository navigation
Runs always end: PR before the checks, rounds that survive continuations, and a ceiling on every run - #485
Merged
Conversation
…ons, and a ceiling on every run
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
A small ticket finished all its tasks, then spent hours and a large amount of spend without opening a pull request. This changes the design so that can't recur. The draft pull request now opens as soon as the work is built, and the checks run on it. A check runs once on a head. A run with no real progress is handed to a person, and every run has an absolute ceiling held in layers that don't depend on each other.
Root cause
passes/mod.rsrun_passes: the only gate for the checks wasGate::Checks, and it came before the pull request, so every step resumed there and re-ran all of them. The pull request came last, with whatever time was left.proof.rsprove,feature/mod.rsgate,link_checks.rsgate,test_fix.rsgate:let mut rounds = 0was a local, so each step had new fix rounds.feature/mod.rsandtest_fix.rsfix rounds passedNoneas their deadline, so a round ran until the time limit cut the whole step off.steps.rsstalled_aftercounts a moved branch head as progress, and every fix is a commit, so the stall stop never fired. Only the 50-step ceiling applied.Earlier fixes, and why the problem survived them
This does not close one gap: a run that really makes progress forever on a very large ticket is only stopped by the absolute ceiling, not by the no-progress guard. That is intended.
Limits (all in
run_guard.rsandrun_ceiling.rs)worst_normal_run)These are sized from the code's own caps and a typical cost per step. They are not sized from recorded run histories: the production read was refused by the permission system, and the repository's fixtures only hold short runs. The real distribution should be checked against them before relying on the ceilings as tight.
The run's shape, replayed (
incidents/p_finished_work_loop.rs): with the guard alone it stops at its fourth continuation, at about a third of the original spend. With no word that its tasks were done, the spend limit stops it a few steps later ($20 since the last real progress). The per-step cost is the total divided by the steps, since only the total was recorded. With the new order, the pull request is open before any of those checks run.Behaviour that relied on checks before the PR
draft_hold).stop_kindfor it.pr::apply_checks), but the writer no longer sees them, including the failing-test evidence for a small test fix's four-section description.Kept before the PR, on purpose
stop_gate::existing_work): it exists to avoid a second PR.What can't be done exactly as asked
Changes
run_guard.rs(new): the no-progress guard, called fromupdate_pass,try_auto_continueandimplement::run, so a later pass is covered. Holds the per-run ledger of checks. One ending: draft with Open items,needs_input, a plain reason, one notification,loop_stop_reasonrecorded, and arun_loop_stoppedlog line with a metric filter.run_ceiling.rs(new): lifetime counts on the run record, the entry guard at the worker's one entry point, and the step's model allowance.common/messages.rs:WorkerMessage::run_refhas no catch-all, so a new message kind doesn't compile until it says whether it belongs to a run.common/usage.rs:UsageMeter::admitrefuses once the run's allowance is spent or closed.model_call_sitesalready fails the build for a model call that skipsadmit.lambda/stuck-run-cleanup: ends any run over its ceiling, from outside the worker, whatever its last update says.steps.rs: newGate::PrbeforeGate::Checks; an in-flight run at the old checks gate with no PR goes to the PR first. Continuations no longer write fakeplanandimplementpasses.mod.rs: single and multi repository paths open the PR first.proof.rs,feature,link_checks.rsandtest_fix.rs: results and rounds in the ledger by head; every fix round stops at the step's deadline.loops_stopped, by reason. Dashboard pin moves to the run steps and analytics change.Every loop in the run path
try_auto_continue: guard and ceilingresume_run_to_runningrefuse a stopped runupdate_pass,implement::run, continuation limitsupdate_pass,implement::runMAX_AUTO_FIX_PUSHESandMAX_CI_FIX_CYCLES, plusupdate_passclaim_auto_fix_slot, pluson_passupdate_passupdate_passpr::resolve_conflictsbefore the PRVerification
cargo fmt --all --checkandcargo clippy --workspace --all-targets -- -D warnings: clean.cargo test -p worker -p common -p gateway: worker 1267 passed, common 1429 and 2, gateway 731, 0 failed.python3 -m unittest discover -s lambda/tests: 354 passed, 0 failed.check:openapi, andrun-steps,audit-runsandanalyticsPlaywright specs (39 passed). The full suite is left to CI.infrawas not run locally for the new metric filter; left to CI.How each layer was tested.
incidents/q_run_ceiling.rsdrives the realrun_ceiling::admitand the realUsageMeter::admitwith an adversarial handler that always sends the run back, for each run message kind and every pass, against an in-memory record. Each layer is removed in turn and the others still end the run within the ceiling; with all removed it never ends, so the test can fail. The sweep's own code is tested in Python, including its handler against a fake table; in the Rust test it is the same decision, not the Python.Not verified. None of this has run against real AWS or a real run: the orchestration in
run_passesis covered by source-structure tests and the pure logic it calls, not an end-to-end run. No deploy.