Skip to content

Say what a 503 means, in the deploy gate and in the page's own door - #835

Merged
max-sixty merged 3 commits into
mainfrom
publish-site-verify-503
Sep 19, 2026
Merged

max-sixty merged 3 commits into
mainfrom
publish-site-verify-503

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Two changes from re-tracing #658, which is closed: its live failure mode was fixed by #790 before its last comment was written, and that comment's account of the cause is wrong. The correction and its evidence are on the issue.

The deploy gate reads its activating request in one place

publish-site's release pass and its agent pass both GET api/view, the request that allocates a reader's container. While the container image is still propagating, the Worker's rollingOut answers it with 503 and a Retry-After. Since #790 the agent pass recognises that and waits; the release pass read the same answer as a bare status and raised … returned 503, which is the line run 35320758891 printed seven times — six inside the workflow's until loop, which reran the script and went green, then the seventh in the agent pass, which ended the deploy.

Workers Observability settles what those seven were. One request logs twice under a single traceId, once for the Durable Object and once for the stateless Worker; for the fatal api/view at 07:48:37 (traceId c3a65be546478da87775ae3682c42305) the Durable Object answered 200 and the Worker answered 503. rollingOut is the only Worker path that makes that conversion, and it sends the header.

activation_read now makes the request for both passes and returns None while the rollout is still landing, so the release pass reports it in the sentence the agent pass already uses. Neither wait moves: the agent pass keeps its 180 seconds, and the release pass keeps relying on the workflow rerunning it. A 503 without Retry-After — what @cloudflare/containers returns when no instance can be allocated — is still this release failing on the first read, which one of the two new cases pins.

A reader is told what a 503 means

The open question on the issue was whether a reader arriving at a cold page gets this too. They do, and their gesture has always landed: deliver retries every two seconds. But the notice it showed came from the JSON decode that rollingOut's plain-text body fails — "Couldn't read the answer — retrying your change…" — which reports the page failing to read an answer the server never sent.

deliver now reads the status before decoding. A 503 on the page's one door is the server saying it cannot take this yet, whatever the reason, so the browser needs no equivalent of the gate's header test: the gate has to separate the two 503s because it decides pass or fail, while both mean the same retry here. The reader is told "The server isn't ready yet — retrying your change…".

Verification

Both runtime claims were established by running the shape rather than reading it: a preview with rollingOut's exact answer replayed at /api/event refuses the attempt and the outbox retries it, landing the gesture when the refusal stops, under the old wording and the new. Each new case was verified paired — removing the branch it covers reds it, restoring greens it.

uv run pytest tests and uv run pytest tests/test_render_outbox.py are green, as is pre-commit over every changed file.

Ref #658

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

max-sixty and others added 3 commits September 18, 2026 21:02
…s name a rollout

`publish-site`'s release pass and its agent pass both `GET api/view`, the request
that allocates a reader's container. While the container image is still propagating
the Worker's `rollingOut` answers it with `503` and a `Retry-After`. Since #790 the
agent pass recognises that and waits; the release pass read the same answer as a bare
status and raised `… returned 503`.

Run 35320758891 printed that line seven times — six inside the workflow's `until`
loop, which reran the script and went green, then the seventh in the agent pass,
which ended the deploy. Workers Observability for that last request shows the Durable
Object answering 200 with the previous release and the Worker converting it through
`rollingOut`, so every one of the seven was the rollout contract. Read as a bare
status they looked like Cloudflare faults, and #658 collected them as such.

`activation_read` now makes the request for both passes and returns `None` while the
rollout is still landing, so the release pass reports it in the sentence the agent
pass already uses. Neither wait moves: the agent pass keeps its 180 seconds and the
release pass keeps relying on the workflow rerunning it. A `503` without `Retry-After`
is still this release failing on the first read, which the second new case pins.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ould not read

leaf.page's edge answers every event with `503` and a plain-text body for the minutes
a container image takes to reach a reader's allocation. `deliver` already retried
through that and the gesture always landed, but what it said meanwhile came from the
JSON decode a plain-text body fails — "Couldn't read the answer — retrying your
change…" — which reports the page failing to read an answer the server never sent.

`deliver` now reads the status first. A `503` on the page's one door is the server
saying it cannot take this yet, whatever the reason, so the browser needs no
equivalent of the deploy gate's `Retry-After` test: the gate has to separate a rollout
from a container that could not be allocated because it decides pass or fail, while
both mean the same retry here. The reader is told "The server isn't ready yet —
retrying your change…"; the retry itself is unchanged.

Established by running the shape rather than reading it. A preview with `rollingOut`'s
exact answer replayed at `/api/event` refused two attempts and landed the third, under
the old wording and the new, and the new case in `test_render_outbox.py` reds without
this branch.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit d21cd64 into main Sep 19, 2026
5 checks passed
@max-sixty
max-sixty deleted the publish-site-verify-503 branch September 19, 2026 05:13
max-sixty pushed a commit that referenced this pull request Sep 19, 2026
… event id off --section (#837)

`publish-site` on `main` failed at the deploy gate's hosted-agent pass.
The turn spent three commands failing to reach Leaf's reply interface,
and the revision that did reach the page never carried the heading the
ask named. This PR fixes the two dead ends those three commands hit: a
refusal that offers no recourse when `--section` is handed an id from
another namespace, and five printed command forms that omit their
required `PAGE` argument. It does not make the failed run green — what
the turn chose to publish is the model's, and the section below says why
I did not reach for the gate's retry instead.

## What the run did

The gate reported:

```
RuntimeError: https://leaf.page/examples/triage-board/ agent did not publish ‘Deployment de34a7d1 verified’; it reached revision 2 from 1 with the page reading listening; it replied: deployment verified
```

Workers Observability for that turn (event
`56f596b2765bf1b5f1a6f40bc4232ab6`, turn
`01a0b800-c8fd-7f72-a404-2316ffc1f704`) records the sequence: one
`commandExecution` at exit 0, one `fileChange`, then three
`commandExecution` items with status `failed` at exits 1, 2 and 1, then
the final model message the host published as the reply. No publish
command ran at all. The gate's own activity profile names the three that
failed:

```
$LEAF reply --section 56f596b2… --quote 'deployment verified' "deployment verified"
$LEAF reply . --section 56f596b2… "deployment verified"
$LEAF reply . --section 56f596b2… --text "deployment verified"
```

One wrong belief runs through all three: that `--section` takes the
delivered event id. It takes an element id. The first also drops the
`PAGE` argument entirely, so `"deployment verified"` landed as the page
directory.

Revision 2 was not one of those three. `_capture_anchor` exits before
`activate_checked_source` runs, so a reply refused on its section
activates nothing; the turn's only other write was the host-bound final
message, whose reply carries `validate_source=True` and so activated the
edited `index.html`. What that revision actually held is the one thing
the records do not say — no content is logged, by design — so whether
the model wrote a different heading or the gate's fetch of the private
revision never landed is not settled here. Either way the turn reached
its reply through a route that never confirmed the edit.

The 503s earlier in the same log are separate and already answered: the
image rollout draining, absorbed by the workflow's own `until` loop,
with #835 since landing the reading that names them. The commit under
test (#832) changed only browser runtime modules and their tests, so it
did not cause this.

## What changes

**The refusal names the namespace.** Reproduced at the CLI, `leaf reply
<page> --to <id> --section <that same id>` exits with `can't anchor in
revision r1: no element id '…' in this version` and nothing else,
sending an agent that holds a log id to look through the page's markup
for something that was never there. `_foreign_id_recourse` in
`conversation.py` reads the log, and when `--section`'s value is an
event there the refusal continues:

```
; <id> is a comment in this page's log — `leaf reply <page> --to <id>` answers a message and `--for <event-id>` addresses a delivered move, while `--section` takes an element id the page's markup declares
```

It sits at `_capture_anchor`, the one door both `leaf comment` and `leaf
reply` reach `--section` through, and it stays silent unless the log
actually holds the value, so the existing typo refusals are untouched.

`--for` is named for every kind the log holds, not only for a message. A
reader's press on a widget frozen into a reply is addressed through that
action event's own id and nothing else — `current_responses` returns a
reply obligation keyed on it, and `--to` names messages — so gating the
pointer on a message kind would have left the one case where a single
option is the only route without one. The article is derived rather than
fixed, so `action`, `undo`, `edit`, and `unresolve` do not read as "a
action".

**Every printed command form carries its page.** `leaf comment --section
<ask-id>` cannot run: `PAGE` is a required argument, so the next token
is eaten as the page directory. It was printed that way in five places —
`ANSWER_ASK_INSTRUCTION`, both `requires a page version` refusals in
`cmd_reply`, and the `comment` and `reply` handling sentences in the
layer registry, which is the vocabulary an agent reads for the exact
event it is answering. The public reference in
`references/conversation-threads.md` already writes every form with its
page; these now agree with it.

## Why not the gate's retry

The turn replied without doing the work, and `ask_until_answered`
re-asks only on a `startup_failed` receipt, so that shape gets one ask.
Widening it is where #791 went, and you closed that with "rather than
adding retries / conditional retries, can we fix the underlying issue
that's causing the need for retries?" — so I have left the gate alone
and fixed what the turn actually ran into. What remains unaddressed is
the model's own choice, which no change here reaches.

## Verification

Two new cases in `tests/test_interact_anchors.py` — one for a message id
handed to `--section`, one for a delivered widget press — each fail
against the refusal they replace with exactly its production message,
and pass with the fix. `uv run pytest tests/test_interact_anchors.py` is
green (53 passed), as are `tests/test_interact_product.py` and
`tests/test_interact_contract.py` (329 passed).

<details><summary>Wider selection and its environment failures</summary>

`uv run pytest tests/test_interact_session.py
tests/test_interact_layer.py tests/test_interact_contract.py` ran 627
passed, 3 skipped, with 2 failures and 2 errors that belong to this
sandbox rather than the change: three are `OSError: [Errno 30] Read-only
file system` on `/tmp`, which the agent sandbox mounts read-only, and
`test_staged_writes_honor_umask_without_copying_a_replaced_symlink_mode`
reads the sandbox user's umask. None touch the anchor or conversation
paths.

</details>

`publish-site` has since gone green on `main` twice, at `ce11d502` and
`d21cd640`, so nothing is currently red and this is not urgent.

Failed run:
[35422088941](https://github.com/max-sixty/leaf/actions/runs/35422088941).

---------

Co-authored-by: leaf-agent <[email protected]>
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