Repository navigation
fix: stop retaining native watchers for server maintenance - #4813
Merged
Merged
Conversation
Use the existing liveness timers for row publication, server retirement and the harness page list. A retained page server consumes no native subscription; between-turn delivery and explicit event followers keep theirs. Neighbor rows and the prompt band now notice file writes on their two-second presence intervals, while activity deadlines still shorten row waits. Regression checks prohibit watcher allocation while exercising row updates, service withdrawal and claim retirement. Both failed before the change. Update the reaper fixture to advance its timer rather than a subscription wait. Closes #4812
Collaborator
Author
|
Fixed the The pushed head is recorded for the queued review and landing workflows; this continuation leaves CI waiting to them under |
max-sixty
added a commit
that referenced
this pull request
Nov 14, 2026
…ude -p` (#5835) Thread titles and widget `generate` on a Claude Code page no longer shell out to `claude -p` from the page server. The page server writes the request into the claimant session's files in the state home (`src/leaf/completions.py`). The session's pages follower lists it, Leaf's hooks module runs `$.model.complete` with the session's own client, and the reply comes back through `leaf hook --fork`. Titles get faster. On the same 60 real thread requests, sent four at a time in one window: | | median | p90 | input tokens | |---|---|---|---| | `claude -p --json-schema` (main) | 3.1 s | 4.8 s | ~2,000 | | `claude -p`, schema in the prompt | 2.1 s | 3.5 s | ~1,600 | | `$.model.complete` through the module | 1.3 s | 1.4 s | ~300 | The module row leaves out the relay through the follower. End to end, the claude-code journey titled each thread in 1.2–2.6 s. `$.model.complete` takes no answer schema, so the schema goes at the end of the system prompt, and Python validates the answer. Haiku returned valid JSON for every one of 452 title requests. On the widget builder, every completed answer in the HTML arm parsed: 14 of 14, plus 1 request that hit the time limit. The Leaf-catalog arm uses a nested `$defs` schema, and there 57 of 60 parsed. The three failures dropped a key, left a bracket unclosed, and repeated the whole object. Each of these rejects `generate` rather than reaching the widget. Things to weigh: - **The follower's output is now `{"pages": [...], "completions": [...]}`.** A running session's module stays at the version it loaded, while its follower moves to the new Leaf. So after this lands, each live session shows an error at every follower start, and its band and forks stop, until `/reload-plugins`. A new session that selects a pre-change checkout hits the same error the other way round. Listing completions per page avoids that, but loses titles on a page the agent closed. Leaf's Stage rule chose the new shape. Any session that doesn't reload also loses its titles, since its module makes no completions. - **A Claude Code title or `generate` now needs the claimant's Claude Code process running.** Without one, the request fails after 60 s. An active claim doesn't guarantee a process. The desktop app stops its sessions to install an update after ten unfocused minutes, so those sessions get no titles until the user reopens them; meanwhile each thread shows its opening words, and `generate` rejects. A background job retires its worker after an hour idle. The comment's wake probably brings the job back inside the 60 s, but I haven't measured that. Max kept the module and accepted this gap. The alternative was `claude -p` alone with the schema in the prompt (the table's middle row), which keeps working while a session is stopped and needs no relay. A fallback that keeps both transports would cost more than either. - A follower without forks now holds one native subscription, on `sessions/`. It still holds none per page (#4813). Two follow-ups are filed: #5954 asks whether a fork of the session should title threads, and #5955 constrains the reply to the schema once `$.model.complete` takes one. Max asked for this. An independent reviewer read it twice, and its findings are fixed in this branch. Focused tests pass, including the module end to end through a 429 and a retry, and so does the real `leaf-dev journey claude-code`. > _This was written by Claude Code on behalf of max-sixty_
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Page servers held one or two native filesystem subscriptions for their whole lifetime, including after a background job finished. Server retirement, neighbor-row publication and the Claude Code prompt's page-list follower now use their existing liveness timers alone. A live Linux probe of a server with
data/found zero inotify instances; applying this change to the process mix in #4812 would remove the 50 server instances and 16 page-list instances reported there.The tradeoff is update latency: neighbor rows and the prompt list now notice file changes on their two-second presence intervals (a row change reaching the prompt can cross both intervals). Server retirement still checks session ownership every second, and activity deadlines still shorten row waits. Between-turn delivery and explicit event followers retain native subscriptions. Background-job pages remain served and resumable.
Validation: both new regression tests failed before the fix and pass afterward, covering row updates, service withdrawal and claim retirement without allocating a native watcher. The 39 focused tests covering native delivery, server lifetimes, row publication and the Claude Code prompt band pass. Ruff and Python compilation pass. The live Pi journey passed setup, release/reply, mid-turn delivery, Escape, held Escape and quit. The live Claude Code journey could not run because its executable is absent, and both Codex journeys report that
codexis absent from PATH.Closes #4812 — automated triage