Skip to content

Keep App Server keepalive pongs readable behind a notification backlog - #5413

Merged
max-sixty merged 1 commit into
mainfrom
fix/app-server-unbounded-receive-queue
Nov 5, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/app-server-unbounded-receive-queue

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Lifts the websockets receive-queue bound on the App Server connection (app_server_connect in src/leaf/codex.py), the candidate repair for the hosted 1011 keepalive ping timeout failures in #3895, shipped on the maintainer's decision there to judge it by the next two days of publish runs.

The follower folds each notification before receiving the next, so a burst of them waits in the client's receive queue. At websockets' default max_queue of 16 frames the library pauses socket reads once the queue fills, so the pongs behind the burst go unread and the ping timeout closes a connection whose server did answer. With max_queue=None reads never pause, and the backlog is held in memory instead. The App Server is a local, trusted process, so unbounded buffering costs nothing a user relies on. This removes one way the keepalive can fail; it does not explain the 33–85 second delayed observations recorded on the issue, which stay open there until the publish lane shows whether they stop.

The new test test_a_backlog_of_notifications_leaves_keepalive_pongs_readable sends 64 notifications before the client reads any, then pings. It failed on the old default (the ping went unacknowledged for 30 s) and passes with the change. The rest of tests/model/test_codex_app_server.py and tests/process/website_server/test_turn_follower.py pass, apart from four Unix-socket tests that fail the same way without this change: this sandbox can't create AF_UNIX sockets.

Refs #3895

The hosted follower folds each App Server notification before receiving the
next, so a burst waits in the websockets receive queue. At its default bound of
16 frames the library pauses socket reads, so pongs queued behind the burst go
unread and the keepalive closes the connection with "1011 keepalive ping
timeout" though the App Server answered. Lift the bound on the connection
`app_server_connect` opens; the server is local and trusted.

The new test fails on the old default (the ping is never acknowledged before
the application drains the queue) and passes with the bound lifted.

Refs #3895
@max-sixty
max-sixty merged commit 16e61b5 into main Nov 5, 2026
5 checks passed
@max-sixty
max-sixty deleted the fix/app-server-unbounded-receive-queue branch November 5, 2026 06:44
max-sixty added a commit to max-sixty/tend that referenced this pull request Nov 5, 2026
…other bots' heads for landing (#1652)

Leaf, the only consumer that sets `workflows.review.await_ci: false`,
has landed reviewed heads a median 2.4 minutes after their CI settles
over tend-land's first 20 days (p95 6.5 min, n=533). The shortfalls were
in the sessions around tend-land. This PR fixes four of them, building
on #1648's **Which heads to poll** rule.

## Every session is told the wait is off

Only the review, triage and land prompts carried the sentence "The
review's CI wait is off". Mention, notifications, nightly, weekly and
review-runs sessions never saw it, so they kept owning a bot PR's CI as
`run-tend` says. On Leaf's first 50 hours on Claude, 16 of 60 mention
sessions polled, 13 of them on bot PRs. 31 of 115 repair sessions found
that the pushing session, still polling, had already fixed the red.

The generator now passes the fact to each agent step as an `await_ci`
action input. `_prompt.render` states it once in the shared system
prompt, beside the merge mode, and the appended prompt sentences go.
`nightly`'s hard-coded poll now defers to `monitor-ci`. A focused eval
states the fact per situation, so `evals/prepare.py` renders it empty
there.

## A push to a human's PR stays with the session that made it

Once told, sessions read `run-tend`'s handoff as covering any push and
stopped polling on a maintainer's PR, where tend-land repairs nothing.
`run-tend` now says tend-land repairs only a PR with no human author,
and that a push to a human's PR stays with the session to poll, except a
review's own fix, which **Without the CI wait** in `approving.md`
already hands to the review queued behind it.

Replays of real Leaf mention sessions on Opus 5.5, each cut just after
its push and resumed with `gh` and `tend` stubbed offline, three runs
per session. Runs that polled CI afterwards:

| | Bot PRs (max-sixty/leaf#5374, max-sixty/leaf#5413) | Human PR
(max-sixty/leaf#5370) |
|---|---|---|
| #1648's rule, no sentence | 5 of 6 | 3 of 3 |
| The rule and the sentence | 0 of 6 | 0 of 3 |
| Both, with the `run-tend` clause | 0 of 6 | 2 of 3 |

The run that still stopped on the human PR took recording the push to
mean tend-land owned it. A red head there still reaches its author.
Three runs show a difference, not a rate.

## A head on another bot's PR can be recorded for landing

`land-pr intend` required this bot's push record, which a Dependabot or
Renovate head never carries. When CI outlasted the review, nothing
landed the PR until the daily sweep or a maintainer: 4 of 13 Dependabot
PRs on Leaf waited between 2 and 58 hours. `intend` now accepts a head
on a PR GitHub marks as authored by a bot. A waiting review already
merged these heads once green, so this changes when they land, not
whether. A head a person pushed to this bot's own PR, and a PR from an
automation account GitHub types as a user, still stay with a maintainer.

`review-without-ci-wait` gains a Dependabot session. On Claude, main
records nothing in 0 of 3 runs, each reasoning that the head has no push
record. This branch records it in 3 of 3, passing the case's other
sessions in the same runs.

## The landing session's reads

`merge-pr` told a landing session to leave the PR open "if the base has
changed since". The record holds a branch name, but 23 of 462 Codex land
sessions took it to mean the commit and refused because `main` had
advanced. Nothing wakes tend-land again for that head, so those PRs
waited for something else to merge them. The skill now says the record
names a branch, and that commits landing on it don't count.

max-sixty/leaf#5336 merged past a maintainer's comment: the session read
the thread, met GitHub 502s, and retried for 11 minutes on that read.
The skill now says a 5xx is no verdict, and to re-read the PR before
trying again. Neither wording change has an eval.

## Validation

- `uv run pytest` (all but the two network-bound tests) and `pre-commit`
pass.
- The replays and eval above, on Claude only. Nothing has run live on
Leaf.

> _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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants