Skip to content

ci-fix: publish-site failing — an unbound hosted turn follower never reaches a receipt #772

Closed as not planned

Description

@leaf-agent

publish-site on main at 8baf6c47 — run 35276339548, "Message a Claude Code session when input reaches a page it left unwatched (#765)". The deploy succeeded and the release pass verified leaf.page in Chrome at 21:30:28. The job then failed in Verify the exact public release in Chrome on the hosted-agent pass, ten and a half minutes later:

RuntimeError: https://leaf.page/examples/triage-board/ agent published but did not reply; the page read working

This is the shape #705 recorded on 2026-09-14 and #729 fixed on 2026-09-15. Both of #729's guards were live in this run. Neither covers the arm this run took.

The follower never bound the delivery to a turn

Hosted agent profile (observed from the first request):
  session reference 769868315596
  event f09f51e14c9977d9a6b0bfcb05626eb6
  request acknowledged 167 ms
  activity closed at 343 ms
  activity working: Starting at 2.7 s
  published at 13.8 s

The agent ran: publishing a revision carrying Deployment 6c0f4376 verified at 13.8 s takes $LEAF commands executing inside the container, so it claimed its delivery, read the page and wrote the file. What the page never showed is any sign that the follower saw it happen.

working: Starting is the reading _start_turn writes at dispatch, under the synthetic turn key delivery:<payload id>, before any notification. _start_turn returns no turn id even when App Server acknowledges the start, so every fresh dispatch enters _follow_turn with awaiting_delivery_start true and binds its turn id from a later turn/started whose items name the delivery. Only after that binding does anything replace the dispatch reading.

The next deploy, run 35277179764 on 388da779, shows the healthy sequence on the same container code:

  activity working: Starting at 549 ms
  activity handling at 2.7 s
  activity working: Running /bin/bash -lc '$LEAF delivery claim 88e341ae-… at 5.3 s
  activity working: Editing /app/site/examples/triage-board/index.html at 9.7 s
  activity listening at 24.6 s

Here Starting gives way 2.1 s later. In the failed run it was still the page's only stream reading 600 s later, while the gate polled /api/state every two seconds and the container answered every read. The follower stayed in its unbound wait for the whole turn.

Why neither of #729's guards ends it

#729 gives the follower an outcome for a fault and for a stream that stops delivering. The unbound wait reaches neither.

  • The except Exception guard needs a fault that escapes the loop. The one fault this arm produces — the silence TimeoutError — is caught by the reconnect handler inside the loop and never reaches the guard.
  • The silence bound routes into a resume that cannot bind a picked-up delivery. recv_notification raises past STREAM_SILENCE, _resume_turn_stream reconnects, and the unbound arm looks for a turn whose items name the delivery. If it finds none, the restart arm below it is gated on the delivery still being offering — and this delivery was claimed inside the container seconds after dispatch. So recovered stays None, the loop continues, and the next silence repeats it. Nothing bounds the repetition.

There is a second gap behind the first: the unbound path has no outcome even when a fault does reach the guard. _clear_stream_activity is only called on the bound branch, and the terminal commit is gated on leaf_turn is not None, which an unbound follower never holds. So the delivery: activity stands and the claim's turn is never closed — the page the gate read for its full TURN_LIMIT. tests/test_website_server.py states the contract in test_a_follower_fault_of_any_shape_still_releases_its_website_turn, but every _follow_turn case in it passes a bound turn_id; the unbound entry _start_turn actually produces has no case.

The consequence is wider than the gate. Any leaf.page reader whose turn lands here sees a page that reads working indefinitely, with neither an answer nor a failure, against a page contract that says exactly one terminal receipt names each accepted request.

Which sub-mechanism, and what would settle it

Two readings fit the frozen activity equally, and they want different repairs:

  • turn/started never reached the follower. Then the silence bound fired repeatedly and each resume found nothing to bind — the loop above.
  • It reached the follower and app_server_delivery_id did not match it. That function reads the delivery id out of the turn's own items; a turn/started whose items do not carry the leaf_delivery output in that shape is skipped as another turn's. Notifications would keep arriving, so the silence bound would never fire at all.

The Workers logs separate them in one read. For session reference 769868315596: whether turn_stream_reconnected was logged (and how many times), whether turn_delivery_bound is simply absent, and whether turn_stream_reconnect_failed appears. This account has no Cloudflare credentials, so it cannot fetch them.

Why no fix is proposed

The repair both readings share is a bound on the unbound wait, ending it with a terminal receipt. Choosing what that receipt does is the part CI should not decide alone: at the moment it would fire, the agent is demonstrably still working — it published — and the host is streaming a reply into a destination the follower reserved before the turn. Closing the claim there discards that reply, and the follower does not own the Leaf turn to close: leaf_turn is None precisely because it never bound, and the open turn belongs to the in-container $LEAF delivery claim. That is a live turn-lifecycle change for every reader, resting on which of the two readings above is true.

Reproducing it here is not available either: codex is not on this runner, so there is no App Server to drive a hosted turn against, and the condition is a provider-notification timing one rather than something a fixture induces. What is reachable from tests/test_website_server.py is the second gap — an unbound follower that faults should still clear its dispatch activity and reach a receipt — and a fix for the first should land with a case for the unbound entry alongside it.

Not this commit

8baf6c47 leaves worker/ untouched. Its one runtime change is a browser-admission block gated on claim["host"] == "claude-code", and every hosted page claim records codex; the comment it admitted reached the container normally, acknowledged in 167 ms. The next deploy carried the same code and passed the same gate.

Activity

  1. added
    tend-outage
    on Sep 17, 2026
  2. leaf-agent commented on Sep 18, 2026

    @leaf-agent
    CollaboratorAuthor

    Run 35276339548

    log tail

      session reference 769868315596
      event f09f51e14c9977d9a6b0bfcb05626eb6
        main()
      request acknowledged 167 ms
      File "/home/runner/work/leaf/leaf/.venv/lib/python3.12/site-packages/click/core.py", line 1631, in __call__
      activity closed at 343 ms
      activity working: Starting at 2.7 s
        return self.main(*args, **kwargs)
      published at 13.8 s
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runner/work/leaf/leaf/.venv/lib/python3.12/site-packages/click/core.py", line 1552, in main
        rv = self.invoke(ctx)
             ^^^^^^^^^^^^^^^^
      File "/home/runner/work/leaf/leaf/.venv/lib/python3.12/site-packages/click/core.py", line 1415, in invoke
        return ctx.invoke(self.callback, **ctx.params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runner/work/leaf/leaf/.venv/lib/python3.12/site-packages/click/core.py", line 910, in invoke
        return callback(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/runner/work/leaf/leaf/scripts/verify_site.py", line 1118, in main
        run_verification(origin, release or built, agent=agent)
      File "/home/runner/work/leaf/leaf/scripts/verify_site.py", line 1129, in run_verification
        verify_agent_turn(
      File "/home/runner/work/leaf/leaf/scripts/verify_site.py", line 871, in verify_agent_turn
        check_turn_answered(url, heading, turn, asks, revision)
      File "/home/runner/work/leaf/leaf/scripts/verify_site.py", line 574, in check_turn_answered
        check(
      File "/home/runner/work/leaf/leaf/scripts/verify_site.py", line 75, in check
        raise RuntimeError(message)
    RuntimeError: https://leaf.page/examples/triage-board/ agent published but did not reply; the page read working
    ##[error]Process completed with exit code 1.
    
  3. leaf-agent commented on Sep 18, 2026

    @leaf-agent
    CollaboratorAuthor

    #779 and #783 landed the receipt this issue asked for, but not the bound that reaches it. The arm described above still runs forever at 9bbd2503.

    What the two PRs did fix. #779 made the delivery the turn's identity, so an unbound follower now has an outcome when a fault escapes the loop: HostedTurn.failed clears the delivery: activity under starting_turn_key, and commit routes leaf_turn is None into _report_failure, which settles each move with a turn_failed receipt. That closes the second gap this issue named — "the unbound path has no outcome even when a fault does reach the guard". #783 then gave that receipt a reader-facing mark. So the receipt, its wording, and the release of the reserved reply address all exist now.

    What is still open is the first gap: the silence loop never produces a fault for that guard to catch. Trace it at the current head, for a delivery the container has already claimed:

    1. stream.next() returns None while the stream is quiet until the silence outlasts STREAM_SILENCE, at which point recv_notification re-raises the TimeoutError, which TurnStream.next converts to StreamLost.
    2. _follow_turn catches it and calls turn.reconcile(stream, stream.resume()).
    3. In reconcile's awaiting arm, _delivered_turn finds no turn naming the delivery, and _restart_turn is gated on the delivery still being offering — which a claimed delivery is not. recovered stays None.
    4. _follow_turn continues. resume() reset quiet_since, so the next silence is another 120 s away, and step 1 repeats.

    Nothing in that cycle raises, so the except Exception guard never runs, failed() never runs, and the Starting activity that _start_turn writes at dispatch stands for the container's life. That is the page the deploy gate read for its full TURN_LIMIT, and it is what any leaf.page reader whose turn lands here still sees. should_resubscribe is not a second exit: it spends its one resubscribe_once on a delivery that is still offering, which this one is not by the time the silence fires.

    tests/test_website_server.py has no case for it either — test_a_follower_fault_of_any_shape_still_releases_its_website_turn remains the nearest, and it passes a bound turn_id.

    Why this is still not a PR from here. The repair is unchanged from what the body above describes: bound the unbound wait so it ends in the receipt that now exists. What #779 settled is what the receipt says; what it did not settle is when a follower is entitled to write one while the container may still be working — at the moment it would fire, the agent has demonstrably published. That is a turn-lifecycle choice for every reader, not a CI one.

    The Workers-log read that separates the two sub-mechanisms is also unchanged, and this account still has no Cloudflare credentials for it.

  4. leaf-agent commented on Sep 18, 2026

    @leaf-agent
    CollaboratorAuthor

    A second occurrence, and the first one that produced a receipt: publish-site on f249da60, run 35327552033. The deploy succeeded and the release pass verified leaf.page in Chrome at 09:13:25; the agent pass then failed 2.3 s into its only ask:

      request acknowledged 126 ms
      activity closed at 214 ms
      activity listening at 2.4 s
      replied at 2.4 s
    
    RuntimeError: https://leaf.page/examples/triage-board/ agent did not publish 'Deployment 83204c73 verified'; it reached revision 1 from 1 with the page reading listening; it replied: The agent's turn ended without an answer to this message. Send it again to retry.
    

    That receipt is this issue's condition, proved

    turn_failed has one writer — _report_failure — reached only when commit finds leaf_turn is None. leaf_turn is assigned in one place, bind, whose writer open_app_server_delivery returns a turn id or raises and never None. The Worker's door refuses the code, so no other boundary can write it. A turn_failed receipt is therefore proof that the follower held no Leaf turn for its delivery when it stopped: the unbound state this issue is open for.

    So the two endings of that state are now both observed. This run took the bounded one — a fault escaped the loop, HostedTurn.failed cleared the dispatch activity and _report_failure settled the move — which is exactly the second gap #779 and #783 closed, working as intended. The page went back to listening rather than standing on working. The unbounded ending this issue's open half describes is unchanged.

    A candidate mechanism, from the source rather than the logs

    The Workers-log read this issue asks for is still the thing that would settle it, and still out of reach here. What reading the current head does suggest is a race that a slow container widens, and this turn was dispatched into a container the image rollout had only just reached — the release pass ahead of it absorbed seven rounds of the rollout 503 between 09:11:19 and 09:12:56.

    _start_turn discards the turn id from an acknowledged turn/start by design: "the follower learns which App Server turn took this delivery from the notification stream, which is the one reading that survives a lost acknowledgement." awaiting therefore stays true, which arms should_resubscribe on the first loop iteration. Its only test for "App Server has not started this delivery" is delivery_queue_state(...) == "offering", and what clears offering is $LEAF delivery claim running inside the container, seconds after the turn starts. Between an acknowledged start and the model's first command, a follower whose turn/started did not arrive buffered will drop a live subscription for a turn it has already been told exists — and the resume that follows searches for a turn whose items name the delivery, which a turn that has not yet emitted its leaf_delivery output does not have.

    If that is the path, the repair does not touch the binding rule this issue's open half is about: _start_turn knows App Server acknowledged a start, and should_resubscribe could be told that without binding to an id that may be stale.

    Not the deploy gate

    #791 proposed asking again on this receipt, since startup_failed and turn_failed both end in "Send it again to retry" and the gate only retries the first. It was closed on maintainer direction — the retry is at the gate, and the fault is here.

  5. max-sixty commented on Sep 19, 2026

    @max-sixty
    Owner

    Closing this. The failure was one intermittent publish-site run, and nothing has reproduced it since. #825 scoped Leaf's Cloudflare tokens so an agent can read the Worker logs, so the next occurrence is diagnosable rather than inferred from the job output — open a fresh report if it breaks again.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tend-outage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions