Repository navigation
Wait for the hosted agent's published heading before the deploy gate reads it - #483
Conversation
…reads it The deployed-site agent gate stopped at the first state carrying any newer revision and any reply, both of which a Codex turn can pass through before it publishes what the comment asked for, and then compared the rendered heading for equality against text the runtime may add its own words to. Wait for the outcome instead — a published document carrying the requested heading and a reply that answers for it — read the heading as a containment, report the revision the browser stands on, and print what the turn did.
|
The gate this PR rewrites failed again on main, so the failure is a recurrence rather than a one-off: run 34312209085 on It is the same shape and the same line: Two things it adds to the case for the change here:
No separate fix PR — this one covers the failure. Its own |
## Summary The hosted agent can publish the requested page edit yet omit an explicit `leaf reply`, leaving the reader with an empty-result receipt even though Codex produced a final response. - Consume the merged App Server event reader's completed response as the reply only when the agent left the accepted Leaf input unanswered. - Preserve exact-turn settlement and explicit Leaf reply precedence. - Keep every accepted input recoverable: failed turns use the failure receipt, empty completed turns use the empty-result receipt, and invalid model-authored media references fall back to that same receipt. The deployment gate's separate asynchronous-revision fix remains owned by #483. ## Validation - `uv run pytest tests` — 959 passed - `uv run pytest tests/test_interact_session.py tests/test_website_server.py` — 174 passed - `pre-commit run --all-files` > _This was written by Codex on behalf of max-sixty_
|
Third occurrence of this shape on The turn itself completed: the release verification printed Two things this adds. The heading shape is now three deployments across ninety minutes ( For the wider picture: |
`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 missing-reply case this PR's body left open — "if it recurs on a green deployment, the reply half of this gate is where it will show up" — recurred twice and has a cause that has since landed, so it is no longer a shape this PR has to account for. Run 34317965825 on The first deployment carrying it is the evidence: run 34318780160 on For scale: 11 of the 13 |
# Conflicts: # scripts/verify-site.py
…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 release41a8177c…successfully and then failed its own post-deploy agent gate (run 34309999064):RuntimeError: https://leaf.page/examples/design-decision/ did not render the agent's published heading; browser errors: []. Every check before it had passed, so the hosted turn had reached the model, published a revision, and replied withdeployment verified; only the rendered heading disagreed, and the message named neither the heading it found nor the revision the browser was standing on.What the gate was reading
verify_agent_turnpolled for the first state where any newer revision and any reply existed, and broke out there. A Codex turn is a process rather than a step: it may publish a checkpoint revision, say something about the work, and only then publish what the comment asked for. So the state the loop stopped at was not necessarily the turn's outcome — and the reload that followed assertedpage.locator("h1").inner_text() == heading, an equality over text that the agent may have quoted and that the runtime may add its own words to for anything a reader can point at.I ran the same turn against the same deployed release twice, out of band, to find out whether the deployment itself was at fault. It was not: in both, the browser followed the agent's revision (
meta[name="lf-revision"]moved1→2) and rendered the requested heading at presentation, with the published document served through the container fallthrough #478 added. The gate was reading the page too early and too strictly, not reporting a broken deployment — which also explains why the next commit's run (34311442765) passed the same gate unchanged.The change
The wait now names the turn's outcome — a published document that carries the requested heading, and a reply that answers for it — instead of the first revision and first reply to appear. The gate keeps every claim it made: one real agent edit, a published revision, the reply #478 asked for, and a rendered result. What changed is when it reads them and how tolerant each reading is:
Verification
verify_agent_turnrun against the live deployment (release66c2a28e…), which is the only place this code path exists: it passed, printing✓ hosted agent published revision 2 and replied: deployment verified.uv run pytest tests/test_website_server.py— 20 passed. That module loadsscripts/verify-site.pyand covers its helpers.ruff checkandruff format --checkat the pinned 0.16.1.The three production turns behind this, and one thing they raise
Three hosted turns were run against
leaf.pagewhile diagnosing, each in its own session and container. All three published a revision whose<h1>was exactlyDeployment <release[:8]> verified, which is what rules out both the model's wording of the heading and the render path.The first two, which overlapped the rollout of release
66c2a28e…, completed without the agent replying at all: the container settled the delivery withworker/server.py'sMISSING_REPLY— "I finished without posting a reply. Please send a new message to try again." Under this gate, as under the one it replaces, that is a failure, and deliberately so: #478's intent is a real reply, and a hosted session that edits a reader's page without answering for it is worth a red run. It is now reported as the reply text rather than as a bare mismatch. Whether that shape is rollout-specific or ordinary is not something three turns can say; if it recurs on a green deployment, the reply half of this gate is where it will show up.The failure on 34311996078 is a different one —
ERR_NETWORK_CHANGEDin the pre-deploy local check — and is untouched by this branch.