Repository navigation
Carve host.py at its joint, and owe nothing to what an older version wrote - #813
Merged
Merged
Conversation
`host.py` held two unrelated things: the state home and process readings that describe this machine, and the harness declarations that describe the agent host a command runs under. Because `leases` reads the state home it imports `host`, so `host` could not import `leases` at module scope, and `CodexHarness.carrier_live` carried a local import of `adapter_is_live` to reach the adapter lease. `machine.py` now owns `state_home`, `package_store`, `pid_alive`, `process_info`, `ancestry`, and `process_argv`; `host.py` keeps the harnesses and the Claude Code messaging socket and imports `adapter_is_live` at module scope. Every caller imports each name from its new owner, with nothing re-exported from `host`. The one test that patched a moved reading now patches the binding the code under test reads: `test_a_codex_session_id_with_no_codex_above_it_is_refused` patches `machine.process_info`, which is what `ancestry` calls. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Stage already said leaf has no persisted state that constrains new code, and that stale state is deleted and regenerated. It did not say what follows for a change that strands some: yesterday's harness change shipped two shims for records written before it, each with a dated note promising its own removal, and its handoff told the user how to re-vendor standing pages. The section now rules all three out, so a change leaves no compatibility code and no migration steps in the reply. Both shims go with it. A claim written before claims named a harness reads as what it is again, and the event parser stops rewriting the old author token. Neither condition is reachable from code that runs: every claim and every event is written by the running version, and a page vendored against an older runtime is re-initialized rather than read around. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 18, 2026
This was referenced Sep 19, 2026
max-sixty
pushed a commit
that referenced
this pull request
Sep 19, 2026
A plugin update swaps the running Leaf under a standing page. #820 reports what that leaves: a live page that cannot be validated, replied to, or re-vendored, with readers still commenting on threads nobody can answer. Two refusals produced that, and this removes both. `$events.kinds` is Leaf's fixed kernel transport contract, and a page's vendored `registry.json` holds the one the Leaf that wrote it had. After an update the two cannot be equal, so `load_registry` refused every read of the page — `version check`, `version stamp`, `reply` — with a contract the reader had no way to meet. Re-vendoring is the only move that resolves it, so the refusal gains a one-line hint naming `leaf page init`, the shape `layer_metadata` already uses for a registry missing its `$layer.generation`. `page init` then has to take that move, and it refused too. `candidate_vocabulary_gaps` was checking each logged event against the incoming per-kind `record` schema, which is a gap a layer selection can never own: admission is the only reader of that schema, and an event already in the log replays identically whichever layer is vendored over it. That check is deleted rather than relaxed. The guard keeps what a selection does own: a dropped reaction token, a retired verb, a kind the contract no longer declares. No shim reads the old shape and no guidance explains one — the page's vocabulary is regenerated, and the refusal says so where the reader meets it. Re-vendoring does not undo what the update itself changed: #813 dropped the shim reading the old `claude` author token as `agent`, so the reported page's 13 replies read as user turns under the running Leaf, before and after the re-vendor alike. That was a deliberate call under **Stage**, and this PR leaves it there. ## Verification The new case in `tests/test_interact_layer.py` runs the reported journey against a page whose log and vendored layer spell the agent's role with the token #811 renamed: `version check` refuses and names the way out, `page init` takes it, the vendored kinds come back equal to the kernel's, `version check` passes, and the standing reply reads back through `leaf transcript`. Before this change it fails at the refusal, with the issue's two messages verbatim. `test_init_refuses_a_historical_event_record_outside_its_declared_schema` held the removed refusal and moved with it — it now asserts the re-vendor runs and that the event still replays afterwards, next to the sibling cases that pin the selection-owned gaps. `tests/test_interact_layer.py`, `test_interact_contract.py`, `test_interact_server.py` and `test_interact_document.py` pass together: 705 passed, with `test_staged_writes_honor_umask_without_copying_a_replaced_symlink_mode` failing identically on an unmodified checkout of its merge base in the same sandbox. <details><summary>One boundary this deliberately leaves open</summary> Removing the record check leaves the complete stored record with no validator. The browser door validates with `browser=True`, which drops `meaning` and `generated` from `required` and strips the fields the server stamps afterwards, so it only ever sees the client's half; `append_event`, which the CLI writers use, validates nothing. `page init` was the one place the full record was checked, several commands after the write, with an unremediable refusal as its only response — which is what this PR removes. Restoring the invariant belongs at the append boundary, where a violation is still the writer's to fix, and that is a change of its own. </details> Closes #820 — automated triage --------- Co-authored-by: leaf-agent <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Sep 19, 2026
Three changes from a survey session: one code fix found by hitting it, and the list and note edits that follow from the survey's own results. Item numbers below are `TODO.md` ids, written without a hash so they do not read as issue references. ## A claim this version cannot read is dropped, not raised on The claims directory is one per machine and every worktree, host and session on it writes there, each running the leaf it was built from — so a record older than the code reading it is ordinary rather than exceptional. #813 removed the last shim on the premise that "every claim is written by the running version", which a shared state home makes false. Found by hitting it an hour ago: a session held six preview pages claimed before #811 named a harness, merged a main that had landed it, and every `leaf wait` afterwards died in `owned_by` on `claim["harness"]` — taking the watcher off the unrelated page the reader was on. The page's own loop guard then fired on every turn, and nothing in the message said why. This is the third refusal in the family #822 named an hour earlier, from the same cause: an update swaps the running Leaf under standing state. #822 fixed the registry read and the re-vendor; the claim read was still crashing. Stage still owes nothing to what an older version wrote, so nothing here migrates a record or reads its old shape. `readable_claim` is one predicate on the two file readers every other reader goes through: a record the readings above can take their answers from is a claim, and any other record is not one this version can read, so its page reads as unclaimed until something claims it again. That is what deleting the stale state would have done, without the deletion, and no session is taken down by state it does not own. The harness *name* is decided at that same door, which review caught: `host.claim_harness` does `HARNESSES[claim["harness"]]`, so carrying the field was not enough — a record naming a harness outside this version's table passed the predicate and raised two calls further in, in the Stop hook and in the nudge the append door takes under its lock. Renaming a harness is reachable by exactly the mechanism that made the field rename reachable. `turn_closed` joins the field set for the same reason: `event_endpoint` brackets it, and it was covered only by the accident that it predates `turn` in the schema. `CLAUDE.md`'s Stage section gains the missing half of its own rule — it said stale state is thrown away without saying who throws it. ### Verification `test_a_claim_an_older_leaf_wrote_is_dropped_rather_than_read_or_raised_on` runs the reported journey: two pages held by one session, the first claimed in the shape written before #811, and `leaf wait` on the second. Bug-back with `readable_claim` removed reproduces the exact production error, `KeyError('harness')` out of `leaf wait`, rather than a weaker assertion failure — which needed the stale page to sort ahead of the reader's page in the watcher's walk, as it did in the wild. The two review cases go through the Stop hook, which is where their consequence is. Bug-back on the harness-name guard raises `KeyError('some-host-a-later-leaf-named')` out of the hook; bug-back on `turn_closed` has the hook name a page nothing owns, which is the flood this PR is fixing rather than a raise. Everyday suite green on the merged head: 1,172 passed. ## `TODO.md`: item 25 retired, items 5 and 7 re-measured Item 25 asked for one App Server client instead of two. #811, #813 and #834 dissolved what it named: `codex.py` exports `app_server_connect`, `app_server_handshake` and `app_server_request`, both callers use them, `AppServerClient` moved out to `codex_adapter.py`, and `worker/server.py` imports 17 public names and no private one. The reconnect backoff, written four ways when the item was raised, is written once. What survived it is two turn supervisors over that one protocol — `HostedTurn` and `WebsiteCodexHost` in `worker/server.py` at about 900 lines, against `TaskObserver` and `DeliveryTurn` in `codex_adapter.py` at about 1,000. They supervise different things, a local Codex process with a queue and a lease against a hosted per-reader container turn, so merging them is a restructure with no deletion. That is item 6's question, under the product condition item 6 already carries, so item 25 retires and item 6 states what is left of it. Items 5 and 7 carried figures from before #808, #815 and #797 landed; both are re-measured against `main` at `76252900` and dated. ## `notes/dependency-survey.md` One line pointed at a `TODO.md` item `b7e1efd0` had already removed. It now points at the work that landed. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
Two follow-ons from #811, which gave each agent harness one declaration.
host.pyheld four thingsIt carried this machine's state-home paths and its psutil process readings alongside the harness declarations and the Claude Code messaging socket. Because
leases.pyimportsstate_homefrom it, it could not importleasesat module scope, andCodexHarness.carrier_liveworked around that with a local import of the adapter lease.machine.pynow owns the state home and the process readings,host.pyowns the harnesses and the socket, and the local import is gone. Each moved function keeps its docstring, including the psutil rationale, which is now that module's header. One test patched a moved reading and was retargeted to the binding the code under test actually reads; a control run confirms it fails loudly when pointed at the old one.Nothing is owed to what an older version wrote
Stage already said leaf has no persisted state that constrains new code, and that stale state is deleted and regenerated. It did not say what follows for a change that strands some, so #811 shipped two shims for records written before it, each with a dated note promising its own removal, and its handoff told the user how to re-vendor standing pages.
Stage now rules out all three: no migration, no shim that reads the old shape, no dated note, and no revival steps in the reply. Both shims go with it. A claim written before claims named a harness reads as what it is again, and the event parser stops rewriting the old author token. Neither condition is reachable from code that runs, since every claim and every event is written by the running version.
🤖 Generated with Claude Code