Repository navigation
Admit every event through one door - #797
Conversation
Nine writers appended to a page's event log and six of them checked no contract at all: `cmd_comment`, `cmd_reply`, `cmd_edit`, `cmd_resolve`, the delivery carrier's `pickup`, and `version stamp`'s `note`. Of the three that checked, `cmd_report` reached `event_contracts` and `cmd_receipt` a validator `requests` defined for itself, so the rules had two homes while the gate had three — the browser endpoint, `service.append_event` for widget kinds, and the CLI reaching neither. `event_log` stamps an id and a timestamp and reads no schema, so whatever a caller handed it landed. The door is one function in the one module that states the rules. Every writer calls `event_contracts.append_admitted`, and `PageTransaction` keeps only the lease-scoped `_append_record` the door is the sole caller of. A function, because the guarantee wanted is that forgetting is impossible, and a module a writer may or may not delegate to cannot give that. In `event_contracts` rather than on the transaction, because admission is a contract concern while the transaction is a lease: the import cycle a method would have needed — `service` reaching `asks`, `projection`, `requests`, and `data` — is the layering saying which way the dependency runs. Admission runs in one order for every kind: an accepted retry short-circuits ahead of the gates, the revision the event names supplies the vocabulary that admits it, that vocabulary has to declare the kind, the kind's gates run against the page and the standing log, server-owned meaning is derived, and the finished record is checked against its stored-record contract. The gates stay with the domains that own them; what moved into one place is the statement of which gates each kind passes, so `_TransactionValidation` is gone and `event_endpoint` keeps only what a browser transport knows — postable kinds, sendable fields, retries, and HTTP answers. `event_record_error` loses its `browser` flag to `browser_command_error`, which is that transport's own assertion rather than a mode of the record contract. No shipped writer was producing a refused shape, but four fixtures were, because nothing between them and the log read the record. Two seeded an `lf-options` `choose` carrying `detail.resolves`, which that verb's declared detail forbids; they now declare the verb they need on the page they publish, the way `test_interact_server` already did, through a shared helper that says why no shipped verb both settles a thread and rests on an id inside its widget. One seeded an `lf-operations` request whose `target`, `worker`, and `worktree` named no element, and now carries the subjects it refers to. The fourth wrote a reply `attempt` of `retry-1`, which the record contract's key pattern refuses: a page holding one would have failed its next re-vendor rather than the write, since `page init` re-reads every stored record before it will replace a layer. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Conflicts were main's renames crossing this branch's rewrite: `leaf.host` split into `leaf.machine` and a harness (`claim_harness(...).nudge`, `wait_is_live(page_dir, claim["id"])`), and the agent author value moved from `claude` to `agent`. TODO.md kept #28 and dropped #27, which this branch closes.
TODO.md takes main's survey paragraph with the item this branch closes dropped, and `composed_theme` became `composed_sheets` beside this branch's rename of the transaction's raw append.
leaf-agent
left a comment
There was a problem hiding this comment.
One finding, and it is in TODO.md rather than in the admission work.
The merge of main resurrected item #8 — Decentralize keyboard feature knowledge into the slot #27 vacated. Those seven lines are byte-identical to the ones 5d4626cb deleted when #815 closed the item on 2026-09-18, and everything they describe has shipped: createPageKeys, its 53-parameter mirror in leaf.js, and the rung() ladder are all gone. 5d4626cb is an ancestor of this PR's merge base, and the merge base's TODO.md holds no #8 — so the block enters the file on this branch.
Since TODO.md is the ordered priority list, merging as-is puts finished work back near the top of Architecture simplification, where the next agent reading the list picks it up. #27's removal is the only TODO.md change the description claims, and the suggestion below leaves exactly that.
Superseded by the review on a later commit.
|
Right, and thank you — the resurrection was my conflict resolution. The merge's hunk had each side removing one item from the same block: main removed #8 when #815 closed it, this branch removed #27. I took this branch's side whole, which put #8 back.
|
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]>
…t a container move a part that records its own facets (#847) Main's `nightly` job has been red since #830 and #797. This repairs its seven failing cases, each at its cause. **The control face lost its place in the cascade (#830, five cases).** `.lf-ui` is the face `offer()` gives every control a widget builds, and it is a default: it stood early in `theme.css` so that a component naming the same property later would win on ordinary cascade order. #830 moved the components into `shadow.css`, which `layer.py` composes ahead of each root's `theme.css`, so the default ended up after them and beat them. `.lf-compose-submit` asked for the accent and drew near-black ink on Send and on Add option. The face now opens `shadow.css`, which puts it before every component rule in the layer, and a control a widget seats inside a declared shadow tree now gets the face, which it did not before. `test_the_injected_control_face_stands_before_every_rule_that_answers_it` pins that order from the files, and it fails on the sheets #830 left. `test_a_coined_class_cannot_reach_the_chromes_rules` pins the deliberate document-level class surface and asked to be widened: #830's aim floor names seven chrome-scoped presses at document level, and the chip and the margin entry leave the list because nothing inside the chrome's scope names them any more. The comments in `chrome.css` and `skills/leaf/assets/CLAUDE.md` that said the shared faces live in `theme.css` now name `shadow.css` too. **A container could not move a part that records facets of its own (#797, one case).** `position_record_error` finds the owner of a moved part by walking up to the nearest widget that records durable state. The walk started at the part itself, so a part with a recorded facet of its own counted as its own owner, and its container's `move` was refused. The browser's event endpoint already ran this check before #797; #797 sent the suite's seeding through the same door, which is how a nightly case found it. No shipped widget has such a part, so only a package's widget could reach the refusal. The walk now starts at the part's holder. **A seed the door now refuses (#797, one case).** `test_a_quoted_widget_exhibits_without_taking_input` seeded an accept on a quoted suggestion. The door refuses an action on quoted material from every sender, so the test now asserts that refusal, and that the quoted suggestion stands undecided. Locally, the complete suite with nightly passed on this branch except the preview-server cases in `test_render_export.py`. Those fail the same way on `origin/main` and on the commit before these changes under this machine's current load, with different parameters failing on each run. > _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]>
Nine writers appended to a page's event log and six of them checked no contract at all:
cmd_comment,cmd_reply,cmd_edit,cmd_resolve, the delivery carrier'spickup, andversion stamp'snote. Of the three that checked,cmd_reportreachedevent_contractsandcmd_receipta validatorrequestsdefined for itself, so the rules had two homes while the gate had three — the browser endpoint,service.append_eventfor widget kinds, and the CLI reaching neither.event_logstamps an id and a timestamp and reads no schema, so whatever a caller handed it landed.The door is one function in the one module that states the rules. Every writer calls
event_contracts.append_admitted, andPageTransactionkeeps only the lease-scoped_append_recordthe door is the sole caller of. A function, because the guarantee wanted is that forgetting is impossible, and a module a writer may or may not delegate to cannot give that. Inevent_contractsrather than on the transaction, because admission is a contract concern while the transaction is a lease: the import cycle a method would have needed —servicereachingasks,projection,requests, anddata— is the layering saying which way the dependency runs.Admission runs in one order for every kind: an accepted retry short-circuits ahead of the gates, the revision the event names supplies the vocabulary that admits it, that vocabulary has to declare the kind, the kind's gates run against the page and the standing log, server-owned meaning is derived, and the finished record is checked against its stored-record contract. The gates stay with the domains that own them; what moved into one place is the statement of which gates each kind passes, so
_TransactionValidationis gone andevent_endpointkeeps only what a browser transport knows — postable kinds, sendable fields, retries, and HTTP answers.event_record_errorloses itsbrowserflag tobrowser_command_error, which is that transport's own assertion rather than a mode of the record contract.No shipped writer was producing a refused shape, but four fixtures were, because nothing between them and the log read the record. Two seeded an
lf-optionschoosecarryingdetail.resolves, which that verb's declared detail forbids; they now declare the verb they need on the page they publish, the waytest_interact_serveralready did, through a shared helper that says why no shipped verb both settles a thread and rests on an id inside its widget. One seeded anlf-operationsrequest whosetarget,worker, andworktreenamed no element, and now carries the subjects it refers to. The fourth wrote a replyattemptofretry-1, which the record contract's key pattern refuses: a page holding one would have failed its next re-vendor rather than the write, sincepage initre-reads every stored record before it will replace a layer.Closes TODO item #27, which this removes from
TODO.mdalong with the sentence naming the survey's item range, since the range no longer holds and a count in durable prose only falls behind again.🤖 Generated with Claude Code