Repository navigation
Drop a claim this version cannot read instead of dying on it - #846
Conversation
The survey note cited "item #24 in `TODO.md`" for the layer inference behind ten of the keyboard's 24 fixes. That item was `Give the keyboard an explicit layer stack`, and #780 did it, so the note pointed at an id `b7e1efd0` had already removed. It now names the change instead, which is what a reader asking whether the inference is still there needs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#811, #813 and #834 dissolved what #25 named: codex.py now 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. What survived it — two turn supervisors over that one protocol — moves under #6, which already carried the product condition that decides it. Re-measure #5 and #7 against main at 7625290, and record that #4, #8 and #27 landed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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 the shared state home makes false. Found in the wild an hour ago: this 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 user was reading. The reader had no way to see why, and the stale record belonged to a page nobody was on. Stage still owes nothing to what an older version wrote, so nothing here migrates a record or reads its old shape. `readable_claim` is the one place that decides it, on the two file readers every other reader goes through: a record carrying the fields those readings name 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. Stage says so too, since the rule said stale state is thrown away without saying who throws it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
readable_claim decides readability by which fields a record carries, but harness is the one field whose value this version dispatches on. claim_harness in skills/leaf/scripts/leaf/host.py is return HARNESSES[claim["harness"]].from_claim(claim) — so a record naming a harness outside this version's table passes the predicate and raises KeyError there, which is the failure the PR is removing, one level in from the field name.
The Stop hook is the sharpest path, and it is the reported journey with the harness's value moving rather than its key: unattended_pages walks owned_pages(session_id), page_claim now admits the record, and claim_harness(discovered) on the next line takes the hook down on a page the reader is not on. event_endpoint's nudge reaches it the same way, under the append lock.
Not reachable today — no Leaf has written a name outside claude-code, codex, embedded. But #811 created that table three PRs ago, and its rename of this very field is what produced the outage this PR is fixing, so the harness vocabulary is the surface the predicate exists to absorb. tests/interact_support.py's record_claim already guards it at the fixture boundary — "harness is checked against Leaf's own table, so a fixture cannot record a name take_claim would never write" — and the production reader is the side that doesn't. The inline suggestion adds the check; it needs HARNESSES on the existing from leaf.host import (...). Happy to push it as a commit instead if you'd rather.
The reason to close it here rather than leave it: the docstring's "this is the only place that decides it, and a session is never taken down by a record it does not own" is what makes the abstraction worth having, and HARNESSES is a second place that decides it.
One more instance of the same seam, for what it says about the set rather than as a separate ask — event_endpoint.py's nudge brackets claim["turn_closed"], and CLAIM_IDENTITY does not carry it. That one is safe only by accident of history: turn_closed is already in service.py at 81653d35, and turn arrives with #322 at 634ec14d, so every record carrying turn carries turn_closed too. The set is a hand-maintained mirror of what the readers name, and it is already one field and one value-domain behind them.
What I verified
Bug-back reproduced: with the predicate body replaced by return claim, test_a_claim_an_older_leaf_wrote_is_dropped_rather_than_read_or_raised_on fails with KeyError('harness') out of leaf wait, matching the PR's claim exactly rather than a weaker assertion failure.
Claim readers swept for fields outside CLAIM_IDENTITY | CLAIM_LIFETIMES: cwd, messaged_turn and turn are read with .get everywhere they appear outside take_claim; turn_closed is the only bracketed one. claim_is_active's job/activity/pid cascade matches the & on CLAIM_LIFETIMES, and EmbeddedHarness.from_claim's claim["pid"] is safe because that harness's lifetime() writes only pid. scripts/preview.py's claim_lifetime record never reaches the claims directory, so the narrowed reading does not touch it.
Test selection, all on the merge tree: tests/test_interact_session.py 189 passed and tests/test_website_server.py 85 passed. The four non-passes across both are OSError: [Errno 30] Read-only file system: '/tmp/lf…' from this sandbox's read-only /tmp, not from the change.
Spot-checked the re-measured figures: margin-projection.js 3,133 and test_render_margin.py 6,802 match, margin-projection.js is the largest runtime module by 1,092 lines over version.js, and worker/server.py imports 17 public names from leaf.codex with no private one.
Review on #846: the predicate checked that a record carries `harness`, but that is the one field this version dispatches on by value — `host.claim_harness` does `HARNESSES[claim["harness"]]` — so a record naming a harness outside the table passed the door 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 what renaming the field around it already proved reachable, so the name is decided here with the rest. `turn_closed` joins `CLAIM_IDENTITY` for the same reason: `event_endpoint` brackets it, and it was covered only by the accident that it predates `turn` in the schema. Without it the stale record reads as a live claim and puts its page back in front of the Stop hook. Both cases go into the existing test through that hook, which is where their consequence is: the bug-back on the harness guard raises `KeyError('some-host-a-later-leaf-named')` out of the hook, and the one on `turn_closed` has the hook name a page nothing owns. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.mdids, 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 waitafterwards died inowned_byonclaim["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_claimis 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_harnessdoesHARNESSES[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_closedjoins the field set for the same reason:event_endpointbrackets it, and it was covered only by the accident that it predatesturnin 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_onruns the reported journey: two pages held by one session, the first claimed in the shape written before #811, andleaf waiton the second. Bug-back withreadable_claimremoved reproduces the exact production error,KeyError('harness')out ofleaf 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 onturn_closedhas 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-measuredItem 25 asked for one App Server client instead of two. #811, #813 and #834 dissolved what it named:
codex.pyexportsapp_server_connect,app_server_handshakeandapp_server_request, both callers use them,AppServerClientmoved out tocodex_adapter.py, andworker/server.pyimports 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 —
HostedTurnandWebsiteCodexHostinworker/server.pyat about 900 lines, againstTaskObserverandDeliveryTurnincodex_adapter.pyat 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
mainat76252900and dated.notes/dependency-survey.mdOne line pointed at a
TODO.mditemb7e1efd0had already removed. It now points at the work that landed.🤖 Generated with Claude Code