Repository navigation
Run the deploy gate's agent pass without re-verifying the deployed release - #487
Conversation
|
This shape recurred on The timeline is the same one this PR describes, on a different page. Six loop iterations raised on That the raise moved from Occurrence count for this step since #478 landed: five |
|
Third consecutive Every push to |
`publish-site` deployed release `b8550d06…` to leaf.page, verified it in Chrome, and then failed its agent pass on a message about a missing event ([run 34315250259](https://github.com/max-sixty/leaf/actions/runs/34315250259)): `RuntimeError: https://leaf.page/examples/design-decision/ did not return its deployment-check comment`. No event was missing. The container that answered the POST was still running the previous image, refused a layer it does not speak, and answered with its own generation instead of a state — which the gate read as an absent comment. ## Why the agent pass posts into a container it never checked `verify_agent_turn` opened a context, read `api/state`, and posted the deployment-check comment under `state["layer"]["generation"]`. Both readings are wrong for the container that has to admit the event: - A passive `GET api/state` is answered by the Worker out of the built site ([`worker/src/index.ts`](https://github.com/max-sixty/leaf/blob/7453d8c4eeef8fe22c9959c5701be04ff75df376/worker/src/index.ts#L453-L460)), so the layer it names is the *release's*, whatever the containers are running. The POST is not — it always reaches a container ([`index.ts`](https://github.com/max-sixty/leaf/blob/7453d8c4eeef8fe22c9959c5701be04ff75df376/worker/src/index.ts#L497)), which carries the layer of the image it runs ([`worker/server.py`](https://github.com/max-sixty/leaf/blob/7453d8c4eeef8fe22c9959c5701be04ff75df376/worker/server.py#L631)). - The page checks that *do* assert the container release run in their own browser contexts. The Worker keys a container on the reader session alone, so they answer for their own allocations and say nothing about this one. A container whose layer the request does not match answers `{"layer": <its generation>}` at status 200 without appending ([`http.py`](https://github.com/max-sixty/leaf/blob/7453d8c4eeef8fe22c9959c5701be04ff75df376/skills/leaf/scripts/leaf/http.py#L816-L821)) — a deliberate shape, so a stale runtime gets the current generation rather than a verdict in a vocabulary it no longer speaks. `posted.ok` is therefore true, `accepted["state"]` is absent, and the gate reported the one thing that had not happened. That the rollout was still draining during this pass is in the run's own timeline: nine allocations answered `reached a different container release` between 05:34:47 and 05:36:52 before one landed on the new image and ended the retry loop. A rollout drains one allocation at a time, so the agent pass's fresh session is an independent draw. ## The change `agent_session` establishes the session the turn will use, and only returns one whose container reports the deployed release: it activates through `api/view` — the same passive-state-then-projection probe [#432](#432) added for the page checks — then reads `api/state` back under `Leaf-Release`. It reads two things off that answer, as `verify_page` does: `leaf-session` says the read left the edge at all, and only then does `leaf-release` name a container rather than the manifest. The edge stamps a passive `api/state` with the deployed release unconditionally, so the release check alone would pass a session whose activation never took. Because a container is bound to its session for that session's life, a stale draw is retried with a *new* session rather than re-read on the old one. `verify_agent_turn` then posts under that container's own layer. Nothing in the retry writes: it is three GETs, and the turn is still posted exactly once, after a coherent session exists. The wait is bounded at 180s — the release verification ahead of this pass has already waited out most of the drain, and the step's budget still has to hold the turn's five minutes inside the job's thirty. The POST answer is also checked for what it is, so the next occurrence of any container-side refusal names the answer rather than the missing event. ## Verification - `uv run pytest tests/test_website_server.py` — 23 passed, including a new case that drives the mechanism at the file boundary: a comment posted under a layer the server does not hold is answered `{"layer": <generation>}`, and the log is unchanged. The gate's own path needs a live Worker and a rollout in progress, so this is the boundary that can hold it. - `npm run typecheck --prefix worker` and `npm test --prefix worker` — 57 passed. The passive-state case now asks under a release the edge is not serving and asserts it answers with the deployed one anyway, so it fails against an edge that echoed the request header. That is the reading `leaf-session` is load-bearing for above: an echoing edge would let the release check pass a session that never left the edge. - `uv run pre-commit run --files scripts/verify-site.py tests/test_website_server.py worker/test/index.test.ts` — passed, ruff check and format at the pinned 0.16.1 included. - The changed step only runs on pushes to `main`, so this branch's CI cannot exercise it; merging re-runs `publish-site`. ## Relation to the other two open gate fixes All three failure shapes are live — [run 34315493489](https://github.com/max-sixty/leaf/actions/runs/34315493489), the next commit after this one, failed on the third. They are separate defects in the same function: - #487 stops the agent pass re-verifying the whole site, and touches `main()`. It does not reach this: the pass would still post into an unchecked container, and with the page checks gone there is no release reading in the pass at all — this branch supplies the one that matters. - #483 rewrites what the gate waits for *after* the comment is posted (`did not render the agent's published heading`). This branch changes what happens *before* it. Landing more than one will conflict textually at the top of `verify_agent_turn`; the three changes are to disjoint concerns and compose. --------- Co-authored-by: leaf-agent <[email protected]>
|
The three other fixes to this step have all landed, and the shape this branch names is still what reddens What is new since the earlier recurrences is what has merged in between. #483, #490 and #500 all rewrote The run's other failure, on attempt 1Attempt 1 failed earlier, in Verify the bundled release locally in Chrome, when the local |
|
Recurred again on The timeline is this PR's, once more. Six loop iterations raised on
|
…#508) `publish-site` deployed release `1f9662ae…` to leaf.page, verified it in Chrome, and then failed the agent pass on what the deployed container itself said ([run 34343130285](https://github.com/max-sixty/leaf/actions/runs/34343130285)): `RuntimeError: https://leaf.page/examples/design-decision/ agent returned an unexpected reply; it replied: I couldn't generate a reply just now. Please send a new message to try again.` The agent had already published the requested heading — the `published` and `replies` checks ahead of it passed — so what stopped the run was the reply, not the deployment. Re-running the same job on the same commit confirmed that: [attempt 2](https://github.com/max-sixty/leaf/actions/runs/34343130285/attempts/2) started twelve minutes later, changed nothing, and went green. ## The gate failed on the deployment answering correctly That reply is `worker/server.py`'s `GENERATION_FAILURE_REPLY`, and the container posts it from exactly one place: `_finish_turn`, when the App Server turn it was following ended with a status other than `completed`. So reaching it means the deployed container noticed a turn that never completed, closed it, and settled the reader's standing ask rather than leaving it open — the behaviour #497 was built to produce. What it reports is the model, not the release. The gate read it as a release defect, which puts every push to `main` behind one live hosted turn generating successfully. That tail is not rare: the three earlier `agent published but did not reply` failures on this step were the same event before #497 gave it a settlement to land in. ## The change The pass now sends the new message that reply asks for, once, and requires that turn to answer. A release that cannot run a hosted turn at all settles the same way twice and still reddens `main`; a single model-side failure does not. Every other ending is still reported on the first ask — a turn that completes without posting a reply settles as `MISSING_REPLY` instead, and a reply that says something else is the deployed agent breaking its own instructions. Both are the agent failing its contract rather than the model failing to run. Two smaller readings follow from that split: - A settled generation failure ends its own wait where it lands. It is posted from where the container closes the turn, so nothing further is coming on that comment — unlike every other reading the wait takes, each of which a live turn can still be passing through. The red run spent five minutes past that reply waiting out `TURN_PATIENCE`. - `TURN_LIMIT` now bounds the pass rather than one ask, and a second ask is only posted while a healthy turn's `TURN_PATIENCE` still fits inside it. The job's budget in `.github/workflows/publish-site.yaml` is unchanged, and the comment stating it stays true. `ask_until_answered` holds the pass so it can be driven without a browser; `ask_for_the_heading` and `await_turn` are the two halves of one ask lifted out of the old body unchanged apart from taking their revision and deadline as arguments. ## Verification - `uv run pytest tests/test_website_server.py` — 29 passed. The three new cases drive both sides of this: the container settling a failed turn, the wait ending on that settlement instead of the budget, and the whole two-ask pass against a page whose first turn stops without replying. Each was checked against a mutation of the code it covers — dropping the retry, reusing the first ask's attempt id, and drifting the settlement text all fail it. - `uv run pre-commit run --files scripts/verify-site.py tests/test_website_server.py scripts/CLAUDE.md` — passed, ruff included. The live path is not reachable from here: Chrome will not launch in this sandbox (`process_singleton_posix.cc:297] Check failed: . socket() failed: Operation not permitted`), so the run above is the evidence for the diagnosis and the unit coverage is the evidence for the change. The step itself only runs on pushes to `main`, and `scripts/verify-site.py` is not in `publish-site`'s trigger paths, so the next push that touches the site payload is what exercises it. ## Relation to #487 and #507 Both are open against other red shapes on this step and neither covers this one: #487 changes `main()` so the agent pass stops re-verifying the release, and #507 changes `await_presentation`'s bound for the reload after the turn. This branch changes what happens between those two — the ask and the wait on it — so the three are independent. Co-authored-by: leaf-agent <[email protected]>
… meet (#507) `publish-site` deployed release `4ef93dd9…` to leaf.page and verified it, then failed the agent pass on the reload that follows the turn ([run 34337785873](https://github.com/max-sixty/leaf/actions/runs/34337785873)): `RuntimeError: https://leaf.page/examples/design-decision/ never presented, reaching no startup milestone`. The turn itself was fine — every check ahead of the reload had passed, so the hosted agent had published the requested revision and replied for it. What ran out was `await_presentation`'s fixed 30 seconds. ## The bound was inside the distribution it was judging `await_presentation` is calibrated for the three pages the release pass walks. Those are served from the edge, and the same run's own profile prints them presenting in 618, 918 and 2267 ms. The reload at the end of `verify_agent_turn` is a different page: it is answered by the private container that has just run a hosted model turn, and its first `/api/state` read is measured in seconds rather than milliseconds. I measured that against the live deployment of the very release that failed, on one session and one page, before and after a turn: | reading | `/api/state` | presented | | --- | --- | --- | | reload before the turn | 123 ms | 0.8 s | | reload after the turn | 3275 ms | 4.7 s | | second reload after the turn | 3918 ms | 5.4 s | | third reload after the turn | 2252 ms | 3.6 s | The cost is ~25× and it does not decay across reloads, so it is what serving a page a turn has written to costs, not a warm-up. It also varies widely with what the turn did: separate turns against the same release presented in 12.4 s and, running this branch's `verify_agent_turn` end to end, **28.4 s** — 1.5 seconds inside the bound that had just failed. A gate whose limit sits inside the distribution of the healthy readings it takes reddens `main` on the tail of that distribution, which is what happened here. So the reload now gets the same patience as every other read this pass makes of that container — the 120 s already used for `page.goto` and each `context.request` call — while the release pass keeps the 30 s that suits an edge-served page. `await_presentation` takes the bound from its caller instead of holding one for both. ## The gate could not say which of the two it was The message was `reaching no startup milestone` whatever had stalled, because `reader_session` never installed `PROFILE_SCRIPT` — the two other page openers do. `unpresented`'s whole purpose is to separate an upgrade that never settled from a first state read that never answered, and on the one page it matters for it was reporting an empty `window.__leafStartup`. That is why the red run's log cannot distinguish the slow read above from a page whose modules never arrived. The agent session records the stamps now, and the reload's response is checked the way every other navigation in this script checks its own. A green deployment now also prints what the reload cost — `✓ hosted agent published revision 2 and replied: deployment verified; the reloaded page presented in 28444 ms` — so this path's drift is visible on every run instead of arriving as the next timeout. ## What this deliberately does not do The seconds-long post-turn `/api/state` read is a real cost that a reader reloading after their own agent turn pays too, and it is worth its own look. It is not a deployment fault, and this gate is explicitly not a startup budget — it prints its profile as "observed, not a pass/fail budget". Widening the gate here and reporting the number is the honest split; making the deploy gate the place that fails on it would redden `main` for a performance question it was not built to judge. I also tried and dropped a runtime change — bounding the first state read in `runtime/state-feed.js`, since a `fetch` that never settles leaves the page with no tick, no stream and no presented stamp. The measurements above rule it out as this failure's cause: the read answers, it is just slow, and aborting a healthy 3-second read would present an offline banner and then wait out an equally slow retry. A page wedged on a genuinely hung first read remains a real gap, but not one this run demonstrates. ## Verification - `verify_agent_turn`, run against the live deployment of release `4ef93dd9…` — the only place this code path exists. It passed: `✓ hosted agent published revision 2 and replied: deployment verified; the reloaded page presented in 28444 ms`. That run was made from this branch before it was rebased onto #508; the rebase changed the ask ahead of the reload, not the reload itself, and Chrome does not launch in the sandbox the rebase was done in, so it has not been repeated. - `uv run pytest tests/test_website_server.py` on the rebased branch — 30 passed, #508's three cases included. That module loads `scripts/verify-site.py`, and this branch's case drives `verify_agent_turn` itself against a container double, stubbing only `ask_until_answered`, so both waits are read at the call sites that set them. Each of the four product changes here fails it on its own: the reload's bound, the startup stamps the agent session installs, the reload-response check, and the presentation cost the green run prints. - `uv run pre-commit run --files scripts/verify-site.py tests/test_website_server.py .github/workflows/publish-site.yaml` on the rebased branch — passed, ruff and actionlint included. The changed step runs only on pushes to `main`, so this branch's own CI cannot exercise it; merging re-runs `publish-site`, since all three changed files are in its trigger paths. ## Relation to #508 and #487 #508 has merged, and this branch is rebased onto it. The two met in `verify_agent_turn`, where #508 lifted the single ask into `ask_until_answered`'s bounded two-ask flow and rewrote the reply checks that precede the reload. That flow is preserved as it landed — the resolution drops this branch's copy of the old single-ask `answer is not None` check, which #508 had already replaced with the version that reports how many asks it took — and this branch's `TURN_PRESENTATION` bound, startup instrumentation, reload-response check and presentation timing sit on top of it, all after the ask has been answered. #487 is still open against the third red shape on this step — the agent pass re-sampling release readings the retry loop had just satisfied, which raises before `verify_agent_turn` is ever reached. It does not overlap this branch either. --------- Co-authored-by: leaf-agent <[email protected]>
publish-sitedeployed releasec7531bac…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):RuntimeError: https://leaf.page/api/state reached a different container release. The deployment was fine; the gate contradicted itself.This shape has now reddened
mainsix times, most recently at run 34368424112 (52fab476, release7468df4d…): the wait ended green at 15:15:19 with✓ leaf.page serves release 7468df4d… in /usr/bin/google-chrome, and theLEAF_VERIFY_AGENT=1pass raisedhttps://leaf.page/api/state reached a different container releaseeight seconds later, at the container-release checkmain()re-runs throughverify_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 beforeverify_agent_turnis 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): auntilloop that re-runs the release verification until it holds, then oneLEAF_VERIFY_AGENT=1run for the deployed agent turn. The second run is a superset of the first —main()ran every page check before reachingverify_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), 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 atverify-site.py:224. 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 loadsscripts/verify-site.pyand covers its helpers.uv run pre-commit run --files scripts/verify-site.py .github/workflows/publish-site.yaml— passed, actionlint and ruff included.main, so this branch's CI cannot exercise it; merging re-runspublish-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 rewritesverify_agent_turn's waits. This branch touchesmain()and the workflow comment only — the two do not overlap, and run 34312209085 hit both shapes, so both are needed to keep this step green.