Repository navigation
Bound the deploy gate's agent wait by the page's activity, not a fixed clock - #500
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
TURN_LIMIT = 600 puts this step's tail past the job's own budget. The deploy step waits out the release first, under deadline=$(( SECONDS + 900 )), and only then runs the agent pass — so a rollout that drains most of that budget and then verifies leaves the agent pass starting around sixteen minutes into the step, followed by agent_session's own 180s, up to TURN_LIMIT, and the reload and presentation checks after it. That is roughly 34 minutes of job against timeout-minutes: 30. At TURN_PATIENCE the same tail came to about 29, so this is the change that crosses the line rather than an overrun that was already there.
The consequence lands on exactly what the PR is for: a job cancelled on timeout prints exceeded the maximum execution time, not the reading-carrying message the wait was extended to produce — and the deployment has already happened, so main goes red with less to read than before. Raising timeout-minutes in .github/workflows/publish-site.yaml keeps the new bound's worst case inside the job.
I have not seen that tail: across the last fifteen publish-site runs the longest Verify the exact public release in Chrome step was about eight minutes end to end, which puts the release wait near 100s of its 900s. So this is the boundary rather than the common path. It is worth naming because the comment on TURN_LIMIT states the arithmetic as settled — "what this step can add and still sit inside the job's thirty minutes beside the release wait ahead of it" — and that is the part that does not hold at the budget it names.
`TURN_LIMIT` moves the verify step's worst case to roughly 32 minutes — the release wait's own 900 seconds, then the agent pass with `agent_session`'s 180, the turn's 600, and the browser checks either side — which no longer fits `timeout-minutes: 30` beside the three minutes the build, image push and deploy take ahead of it. A job cancelled on timeout prints `exceeded the maximum execution time` rather than the reading the wait was extended to report, so the budget now clears that tail, and the comments on both bounds name the job as what holds them.
|
Taken — The arithmetic the review names is the one I recorded, so the comment on 45 rather than 35: the release-wait loop can start one more One consequence worth noting: |
…lease (#487) `publish-site` deployed release `c7531bac…` to leaf.page successfully, verified it, printed `✓ leaf.page serves release c7531bac… in /usr/bin/google-chrome` — and then failed six seconds later on the very reading it had just satisfied ([run 34313146474](https://github.com/max-sixty/leaf/actions/runs/34313146474)): `RuntimeError: https://leaf.page/api/state reached a different container release`. The deployment was fine; the gate contradicted itself. **This shape has now reddened `main` six times**, most recently at [run 34368424112](https://github.com/max-sixty/leaf/actions/runs/34368424112) (`52fab476`, release `7468df4d…`): the wait ended green at 15:15:19 with `✓ leaf.page serves release 7468df4d… in /usr/bin/google-chrome`, and the `LEAF_VERIFY_AGENT=1` pass raised `https://leaf.page/api/state reached a different container release` eight seconds later, at the container-release check `main()` re-runs through `verify_page`. Each occurrence has left a good deployment sitting behind a red default branch. The other red shapes on this step have been fixed as they were found — #483, #490, #500 and #508 have landed, #507 is open on the post-turn reload — and none of them touches this one, which raises before `verify_agent_turn` is reached. The comments below record the intervening runs. ## Why the gate disagreed with itself The deploy step is two invocations of the same script ([`publish-site.yaml`](https://github.com/max-sixty/leaf/blob/c9a0a27a4f3545488ec74018c11018514727c432/.github/workflows/publish-site.yaml#L103-L111)): a `until` loop that re-runs the release verification until it holds, then one `LEAF_VERIFY_AGENT=1` run for the deployed agent turn. The second run is a superset of the first — `main()` ran every page check before reaching `verify_agent_turn` — so it re-sampled the same readings, with none of the loop's protection. That re-sample is not idempotent, because a container rollout drains one allocation at a time. Each browser context the script opens is a new reader session, and the Worker keys a container on that session alone ([`worker/src/index.ts`](https://github.com/max-sixty/leaf/blob/c9a0a27a4f3545488ec74018c11018514727c432/worker/src/index.ts#L497)), so every invocation asks Cloudflare for a fresh allocation and gets whichever image that allocation happens to be running. The run's own timeline is the demonstration: six allocations landed on the previous image, one landed on the new one at 05:05:28 and ended the wait, and the allocation six seconds later landed on the previous image again and raised at [`verify-site.py:224`](https://github.com/max-sixty/leaf/blob/c9a0a27a4f3545488ec74018c11018514727c432/scripts/verify-site.py#L224-L226). Nothing regressed in between — the rollout was still draining, which is exactly the condition the loop exists to wait out. So the loop already states the policy: one coherent sample ends the wait. The second invocation quietly re-litigated it, and turned a rollout still in progress into a red default branch. ## The change The agent pass now runs the agent turn alone, and the release pass stays where the wait protects it. No claim is dropped: the loop's final iteration verifies the document, module graph, edge projection, session identity, cross-tab activation and container release seconds earlier, and the agent turn's own claim — one deployed Codex turn revising and answering a private page — is unrelated to which allocation the rollout is on. The turn is still run exactly once and is still fatal on failure; this deliberately does not put it inside the retry loop, since a hosted turn that edits a reader's page without answering for it is worth a red run rather than a retry. Removing the duplicate work also takes three page loads and the cross-tab check off every deployment, and the agent pass now prints a line on success instead of passing silently. ## Verification - `uv run pytest tests/test_website_server.py` — 20 passed. That module loads `scripts/verify-site.py` and covers its helpers. - `uv run pre-commit run --files scripts/verify-site.py .github/workflows/publish-site.yaml` — passed, actionlint and ruff included. - The changed step itself only runs on pushes to `main`, so this branch's CI cannot exercise it; merging re-runs `publish-site`, since both changed files are in its trigger paths. ## Relation to #483 #483 is open against the other red run of this step (`did not render the agent's published heading`) and rewrites `verify_agent_turn`'s waits. This branch touches `main()` and the workflow comment only — the two do not overlap, and [run 34312209085](https://github.com/max-sixty/leaf/actions/runs/34312209085) hit both shapes, so both are needed to keep this step green. Co-authored-by: leaf-agent <[email protected]>
publish-sitedeployed release8d6cb096…to leaf.page successfully and then failed its own post-deploy agent gate (run 34321790244):RuntimeError: https://leaf.page/examples/design-decision/ agent published but did not reply. The hosted turn had reached the model, read the page and published the revision the comment asked for — the gate's own revision check passed — and then the gate stopped watching five minutes after posting the comment and reported the turn as unanswered.What ran out was the gate's clock, not the turn
verify_agent_turngave the turn a flattime.monotonic() + 300and readdeployment verifiedout of whatever state existed when that expired. Nothing derives that number: a hosted Codex turn runs at the model's pace, and the same step's green run on7299eec2finished in about 150 seconds, so 300 is roughly two green turns of headroom and no more. Three of the last ten deployments crossed it — 34317965825, 34318460923 and this one — each with the revision already published, which is the turn at the far end of its work rather than a turn that failed.The sentence the gate raised is the second half of the problem.
agent published but did not replyis a claim about the agent, and a fixed budget has nothing on which to base it: the gate could not tell a turn still working from a container that had dropped its session, so both shapes reached the log under the same wording.Bounding the wait by what the page says
The page already derives that distinction.
activityis the one canonical reading Leaf folds from status, claim, watcher lease, pickup and unsettled reader moves, andapi/statecarries it: while the turn owes this comment an answer, the comment stands inactivity.obligationsand the reading beside it names the turn holding it (handling, orworkingonce the stream speaks). When the turn ends — includingworker/server.py's_finish_turnsettling a fallback for a turn that finished silently — the obligation clears.So the wait now consults it.
TURN_PATIENCE(300s, the budget as it stood) still ends the wait on a page that says nothing is answering, and a page that says a turn is still on this comment holds it open toTURN_LIMIT(600s). The extension is one-directional by construction: the projection can only prolong the wait, never end it early, so a momentarily odd reading costs a slower red run rather than a wrong one. Both failure messages now carry the reading they judged, so the two shapes are distinguishable in the log.The job's budget holds the new tail
TURN_LIMITis sized against the job rather than the model, so the job is the second half of this change. The verify step waits out the release first under its owndeadline=$(( SECONDS + 900 ))and only then runs the agent pass, which adds a page verification,agent_session's 180s, the turn's wait and the reload and presentation checks after it — roughly 32 minutes at the new bound, behind the three the build, image push and deploy take. That no longer fitstimeout-minutes: 30, so.github/workflows/publish-site.yamlnow budgets 45. The consequence of leaving it lands on exactly what this PR is for: a job cancelled on timeout printsexceeded the maximum execution timeinstead of the reading the wait was extended to report, and the deployment has already happened, so main would go red with less to read than before. This is the boundary rather than the common path — across the last fifteenpublish-siteruns the longest verify step was about eight minutes end to end, putting the release wait near 100s of its 900 — but atTURN_PATIENCEthe same tail came to about 29 minutes, so the raised bound is what crosses the line.activity's own 15-minute working grace bounds the other side: a turn that stops speaking readsstalledand ends the wait atTURN_PATIENCEregardless.Verification
uv run pytest tests/test_website_server.py— 26 passed. Two new cases pinstill_answeringfrom both sides: one drives a real delivery throughprepare_codex_delivery/accept_codex_deliveryand asserts the helper against the projectionfull_stateactually produces (handlingwith the obligation standing), then runs_finish_turnand asserts it stops there; the other pins the readings that must not extend the wait.uv run pre-commit run --files .github/workflows/publish-site.yaml scripts/verify-site.py tests/test_website_server.py— passed, ruff and actionlint included.publish-sitestep; nothing here changes what the gate asserts about a turn, only how long it is willing to watch one.What this does not do
scripts/verify-site.pyis not inpublish-site's trigger paths, but.github/workflows/publish-site.yamlis, so merging this re-runs the workflow and exercises the gate on the merge commit.This is the third distinct shape this step has produced today and is independent of the other two. #487 is open against the release re-sample (
reached a different container release) and touchesmain(); #483 rewrote what this wait reads and merged asca67a550. This branch touches the wait's bound and the job budget that holds it, and does not overlap either.