Repository navigation
fix(poll): bound the settle loop by a sleep budget, not a pass count - #1371
Conversation
A rollup that goes pending again between a clean read and the 30s read that confirms it sends the pass back to the top of the loop. Each pass charged its own confirm read, so nine passes could sleep 810s where the skills run this poll in the foreground under the harness's 10-minute command cap — a poll killed there returns no verdict at all. Draw both sleeps from one budget. The longest green (pending through eight reads, clean on the ninth) still takes 570s, the ~9.5 minutes monitor-ci documents; a flapping rollup now spends that same budget on more reads instead of running 4.5 minutes past the cap.
tend-agent
left a comment
There was a problem hiding this comment.
The budget bounds the sleeps, not the wall clock the 10-minute cap actually measures. Walking _settle over every clean/pending/read-failure sequence, the 570 s worst case is also reachable with 12 rollup reads (five confirm passes plus two pending ones), so the cap has to cover 570 s of sleep plus those reads and the commit-resolve and head-note calls around them — and poll() adds a further sleep(10) when the first commit-resolve call fails, taking the sleep total to 580 s on that path.
That leaves on the order of 20 s of headroom for ~15 gh round trips, and the retry path can still cross. None of it is introduced here — the pending-through-eight-then-clean path already slept 570 s before this change, and the change strictly shrinks the worst case from 810 s. But MAX_SLEEP_SEC's comment names the cap as the figure that has to hold, and as written it holds only for the sleeps. Worth deciding either way: draw poll()'s retry sleep from the same budget and leave the reads explicit slack, or state in the comment that the request time is deliberately unbudgeted.
How the bound was checked
Total sleep is POLL_BUDGET_SEC - budget_at_exit, and the loop exits at a budget of 30, 0, or -30, so 570 s is the true maximum — confirmed by exhaustively driving _settle with an injected sleep and a stubbed fetch_rollup over every sequence of clean / pending / None reads up to length 14: max sleep 570 s, max reads 12, and the two co-occur.
The new regression test does fail against the old loop (assert 810 <= 570), and the rest of the suite passes apart from the two test_refresh_consumers.py DNS failures the sandbox always has.
Regenerates the nine `tend-*.yaml` workflows from tend 0.3.1, up from 0.2.15. Behavior here is unchanged: the only substantive diff is two new action inputs, `merge: maintainer` and `control_plane_owner: ""`, both of which are the action's own defaults. `maintainer` is the merge authority this repo already runs under — the bot proposes, a maintainer merges. What the upgrade changes for this repo: - **`tend check` audits protected refs and credential environments more strictly** ([max-sixty/tend#1382](max-sixty/tend#1382)). A protected branch must now restrict creation, update and deletion together rather than update alone, and the credential audit no longer treats a ref-qualified reusable workflow as this tree's copy. This repo does not clear the new bar yet — the nightly filed #4242 with the single ruleset gap and the remediation. - **Yolo merge mode exists, and is off** ([max-sixty/tend#1172](max-sixty/tend#1172), [#1390](max-sixty/tend#1390)). The new inputs are how a repo would opt into letting the bot merge its own PRs; leaving them at the defaults keeps the current arrangement, and the `merge: maintainer` value is what the mitmproxy cache step is now gated on. - **`review-runs` sees the whole night** ([max-sixty/tend#1377](max-sixty/tend#1377)). Run listing now pages to the Actions ceiling instead of stopping at the first page, so a busy night's early runs stop falling out of the census; [#1374](max-sixty/tend#1374) keeps each correction row's author alongside it. - **CI polling is bounded by elapsed time, not iteration count** ([max-sixty/tend#1376](max-sixty/tend#1376), reinstating [#1371](max-sixty/tend#1371) after [#1375](max-sixty/tend#1375) reverted it). A settle loop against slow checks now stops on a sleep budget, so a long matrix can't quietly stretch a session. - **Install-test drift detection tightened** ([max-sixty/tend#1381](max-sixty/tend#1381)): generator output a PR never committed now fails tend's own drift check, which is the check that makes a regeneration PR like this one trustworthy. Full comparison: [0.2.15...0.3.1](max-sixty/tend@0.2.15...0.3.1). This PR does not touch `.config/tend.yaml`, whose `sandbox_setup:` key 0.3.1 now warns "will be refused in a later release". That migration is a separate change. #4240 overlaps this completely: it was generated with the same 0.3.1, so it carries the identical headers and the identical `merge: maintainer` / `control_plane_owner: ""` on the same lines, underneath a Claude → Codex harness swap. The only thing that distinguishes the two is which harness the action runs. Whichever lands first leaves the other conflicting on the eight `uses:` lines, resolved by regeneration rather than by hand. So this PR is worth landing on its own only for as long as the Codex cutover stays in draft — if that lands first, close this one. Verified by regenerating in the merged tree: `uvx [email protected] init` reproduces these nine files byte-for-byte, and the action declares `default: maintainer` and `default: ""` for the two new inputs at `0.3.1`, so neither changes behavior. Co-authored-by: worktrunk-bot <[email protected]>
_settlecould sleep 810 s — 4.5 minutes past the 10-minute command cap its callers run it under — so the poll was killed and the session got no verdict on the commit it had just pushed.The loop reads the rollup every 60 s, and a read that shows nothing pending is confirmed by a second read 30 s later. A check that registers inside that 30 s window sends the pass back to the top.
for _ in range(9)counted passes, not seconds, so every pass could charge its own confirmation: nine passes × 90 s. #695, which trimmed this loop to fit the cap in the first place, budgeted for "one at-most-once 30 s grace re-check" — the implementation never enforced the "at most once".Both sleeps now draw on a single budget. The longest green path is unchanged at 570 s (pending through eight reads, clean on the ninth), which is the ~9.5 minutes
monitor-cidocuments. A flapping rollup spends that same budget on more reads — 12 rather than 9 in the regression test — instead of overrunning.Reachable from every caller that polls:
nightly's Step 7 andmonitor-ciboth invoke it in the foreground withtimeout: 600000, andreview'sreferences/approving.mdruns the siblingapprovalcommand the same way.Measured, before and after
The regression test drives
pollagainst a rollup alternating clean/pending and sums the injected sleeps. Before: 810 s. After: 540 s.Every path, with the fix in place (
settled, seconds slept, rollup reads):