Skip to content

Use a valid website deployment probe - #432

Merged
max-sixty merged 2 commits into
mainfrom
codex/web-release-simplify
Sep 8, 2026
Merged

max-sixty merged 2 commits into
mainfrom
codex/web-release-simplify

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 8, 2026 •

Copy link
Copy Markdown
Owner

The previous website publish deployed successfully, but its Chrome verifier retried an invalid /api/data request until the workflow timed out. That endpoint requires a source and key, so it cannot serve as a generic session-activation probe.

Read the passive edge state first, assert that it remains passive, then use its revision and event boundary with the canonical read-only /api/view route. The rebuilt site passes the full exact-release Chrome verifier against the deployed release.

The website-server integration test exercises the exact projection request against the real Python adapter. A Worker test also pins the routing boundary: a private API read leaves the edge, reaches a container, and returns the active-session header and cookie.

This was written by Codex on behalf of @max-sixty

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#430 fixes the same failure in the same two files — it also replaces the /api/data activation probe with /api/view, carrying the revision and a log boundary. It was opened six minutes before this one, so the two will conflict and one should be closed.

If this one is the one that lands, two things #430 pins are worth carrying over, because both sit on the mechanism this probe depends on and neither is exercised here:

  • worker/test/index.test.ts covers the Worker branch the probe relies on — a passive reader's non-api/state API GET reaching a container and coming back Leaf-Session: active with the active cookie. The Worker has no api/view-specific code; it routes on isPageApiRequest, with api/state carved out to the edge in staticState. So a future carve-out that added api/view to that edge-answered branch would put the gate back to failing on every deploy, with nothing red before production — the same shape as the bug being fixed.
  • The pre-activation /api/state read asserts Leaf-Session: passive, which is currently only checked indirectly, through the absence of activation cookies.

@max-sixty
max-sixty merged commit 57a843c into main Sep 8, 2026
13 checks passed
@max-sixty
max-sixty deleted the codex/web-release-simplify branch September 8, 2026 03:43
max-sixty pushed a commit that referenced this pull request Sep 9, 2026
`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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants