Skip to content

Let each feature owner declare its own keys at boot - #815

Merged
max-sixty merged 5 commits into
mainfrom
agent-a30100eb8d220c8a4
Sep 19, 2026
Merged

max-sixty merged 5 commits into
mainfrom
agent-a30100eb8d220c8a4

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

createPageKeys took 53 named capabilities and leaf.js mirrored all 53, so a core command cost one line in each of three files while a package widget, registering through keys(), cost none. Eleven of the 53 were scopes or rows a feature had already declared locally and page.js named a second time.

The owner that implements a command's result now declares it where that code is, through three doors in register.js: pageScope(name, …) for a scope of the feature's own — a mode, a surface, an interaction holding the keyboard — pageCommand(row) for a row of the page's own scope, and pageRung(name, …) for a step of Escape's fallback ladder. Twenty modules contribute as they are constructed, so a row closes over its owner's state and the register holds no capability. What stays there is the part no single owner can state: STACK, the order the dispatcher walks; PAGE_COMMANDS, the rank the shortcut line gives the page's own commands; and RUNG_LADDER, the order Escape unwinds in.

What this deletes

createPageKeys with its 53-parameter destructure, the mirror in leaf.js, and the hand-written rung() ladder. Each step of that ladder is now contributed by the owner of the state it takes off — the selection's in composing/surface.js, the tray's in trays.js, the narrowing's and the panel's in thread-panel.js, letting go and backing out to the page in keyboard/page.js — and the register resolves the innermost live step into the one navigation.back row every surface reads, rooted at the surface that step is inside so it survives a covering panel or tray.

COVERING_WORKSPACE goes too. A page command marks itself covering: true and the register builds that scope from the rows carrying it.

keyboard/page.js falls from 1,398 lines to 124 — the document's own parts, a link, a disclosure and caret browsing, plus the two ends of the Escape ladder — and leaf.js by 47. About 900 lines move to their owners; assets/ ends up around 90 lines longer overall, the register having gained the contracts the parameter list never stated and each contribution the paragraph explaining it where its owner will read it.

Adding a command afterwards

A command on a surface a feature already declares is one row in that feature's pageScope and touches nothing else. A new page-level letter is a pageCommand beside its implementation plus its id in PAGE_COMMANDS, which is where the shortcut line's priority is stated; a new scope is a pageScope plus its name in STACK.

Evidence

Three keyboard journeys — the ask and thread walks, the reply box, draw and design modes, page search, the go-to sequence, both trays, the versions menu, the Threads panel's own keys, the covering panel at 700px, and the Escape ladder reached by pointer — recorded press by press through review-a-plan and triage-board, against bdf581c9 and against this branch: identical, with no console output on either side. The complete command reference, 100 commands across 23 sections, is byte-identical to bdf581c9 as well.

test_the_key_line_says_what_a_press_will_do now covers the ladder from the reference's side. Standing on a mark out on the page, where letting go and backing out both hold, it requires exactly one navigation.back row reading "Let go of what you are standing on"; run against the commit that gave each step its own scope, that state carried two. Its existing assertion that navigation.back is absent while a return frame stands is live again too — removing the !current() guard fails it.

uv run pytest tests --run-nightly: 2728 passed, 4 failed. All four — test_a_single_space_is_message_content_in_every_composer[general|reply|composer] and test_the_add_field_previews_the_option_it_will_make — fail the same way on bdf581c9 under the same selection on this machine, over a ::before fill colour on the Add and Send buttons. Also run: uv run pre-commit run --all-files, npm run check:browser, npm run test:browser.

Closes TODO #8.

This was written by Claude Code on behalf of @max-sixty

max-sixty and others added 3 commits September 18, 2026 16:17
`createPageKeys` took 53 named capabilities and `leaf.js` mirrored all 53, so a
core command cost one line in each of three files while a package widget,
registering through `keys()`, cost none. The owner that implements a command's
result now declares it where that code is, through two doors in `register.js`:
`pageScope` for a scope of the feature's own and `pageCommand` for a row of the
page's own scope. Twenty modules contribute as they are constructed; the
register holds names, rows, and the two orders no single owner can state.

`rung()` goes with it. Each Escape rung is now an ordinary row in a scope of its
owner's, rooted at the surface it takes off, so the dispatcher's own walk picks
the innermost live one and `BACK_OUT`'s `!current()` guard is unnecessary:
`escapeOrder` already ranks a return frame ahead of every unmarked fallback.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ladder's mutual exclusion now lives only in the dispatcher's stack walk, and the command reference does not consult that walk — so where rung() returned exactly one branch, the reference lists every rung whose own when happens to hold.

captureCommandReferenceCatalog (in runtime/keyboard/command-reference.js) filters a scope's rows with inScope = readerIn(scope) || scope.liveInCommandReference and then live(row). readerIn is !scope.at || scope.at(), and none of the six rung scopes declares an at, so each rung's own when is the whole filter. Two states where more than one holds:

  • Standing on a page element outside the chrome. navigation.let-go (when: () => holding() && !inChrome(documentFocused())) and navigation.back-to-page (when: holding) are both live, so "On this page" carries two Escape entries that both run letGo — one available, one not.
  • g T into Threads, with the return frame standing. navigation.panel.close (when: () => panelIsOpen()) is live, so "Close the thread panel" is listed beside "Return from Threads panel". This is the case BACK_OUT's !current() guard was holding. Dispatch is still right — escapeOrder does rank RETURN ahead of the unmarked fallbacks, as the description says — but the catalog reads liveness, not that order, so removing the guard withdrew the only statement the reference was reading.

That second state is the one the suite used to pin, and the assertion is now vacuous: in tests/test_render_navigation.py, immediately after the g T then ? ? step, expect(help_el.locator('[data-lf-command="navigation.back"]')).to_have_count(0) — navigation.back no longer exists, so the locator is empty whatever the reference lists. Nothing holds it in either direction now.

It also bounds the byte-identical reference capture: at rest with focus on the body, holding() is false and no rung is live, so a resting capture agrees with bdf581c9 while these two states do not.

The fix I'd reach for is the catalog deriving its Escape rows from the same order dispatch walks, rather than each rung growing a guard against the rungs behind it — one statement of the ladder was the point of the change, and a per-rung exclusion would put six copies of it back. Either way the navigation test wants re-pointing at a command id that still exists.

Also noticed

createPanelComposer still returns PANEL_SAY and generalHint; with page.js no longer taking either, nothing outside conversation/panel.js reads them.

Everything else I traced held: the COVERING_WORKSPACE rows are covered by covering: true plus the tray and panel rungs rooting at the surfaces registerAuxiliarySurface actually registers; lineOwner returns a single Escape owner so lineWhen on the panel and narrowing rungs still suppresses the chip during a thread search without falling through; and no reference to a removed export (createPageKeys, registerPageScopes, activeRowLabel, reactions.REACT, version.NEWEST/VERSIONS, targets.PAGE_SEARCH, goToSequence.GO_TO_SCOPE) survives anywhere in assets/, tests/, or scripts/.

The reference behaviour above is read off the catalog path rather than observed in a browser — this environment cannot launch one.

The reference reads each row's own liveness, not the dispatcher's Escape order,
so six independent rung scopes listed every rung whose condition held where
`rung()` had named exactly one. The rungs are still contributed by the owners of
the state they take off, through `pageRung`; the register orders them and
resolves the innermost into one `navigation.back` row, whose `when` says what
being the fallback means — no step answers while a commanded entry stands.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner Author

Both findings were real. The ladder is one command again, assembled from the steps their owners contribute rather than hand-written: pageRung(name, reading) takes a function answering what the press would take off now, RUNG_LADDER orders them, and register.js resolves the innermost into the one navigation.back row. So the reference lists one way out however many steps could act, and !current() is back on that row — not as one mechanism standing down for another, but as what being the fallback means.

test_the_key_line_says_what_a_press_will_do now reads the reference while standing on a card, where letting go and backing onto the page both hold, and requires exactly one navigation.back row saying the innermost step. Its existing to_have_count(0) after g T is live again: removing !current() fails it, checked.

generalHint and PANEL_SAY are off createPanelComposer's return.

This was written by Claude Code on behalf of @max-sixty

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test does not stand where its comment says, so the regression it is advertised to pin is still unpinned.

At that block the reader is on .lf-margin-preview .lf-conversation-thread, and margin-projection.js appends the preview to the chrome root (chromeRoot.append(nav, preview)). So inChrome(documentFocused()) holds there, the standing step — holding() && !inChrome(documentFocused()) — is null, and only the page step is live. The assertion says as much: rung() returns the innermost live step, standing precedes page in RUNG_LADDER, and the row reads "Back out onto the page" rather than "Let go of what you are standing on". With one step live, to_have_count(1) is satisfied by the ladder having one live rung — not by six rungs resolving to one row, which is the change. The state the last review raised, a page element outside the chrome where let-go and back-to-page both hold, stays untested, and the Evidence section carries the same claim into main's commit message on merge.

Two Tabs past the block's last line the reader is standing on .lf-mark-note, out on the page, and both steps hold there: the reference lists exactly one navigation.back row, reading "Let go of what you are standing on". The inline suggestion adds that probe; I ran it and the test passes.

The block's closing comment is off the same way — "the reader is back on the card with the ladder's own press still ahead of them", but after the reference round-trip the line reads esc → dismiss conversation, so the next press is the preview's own command and the ladder never answers it.

How this was checked

Against the merged tree with a real browser, by temporarily instrumenting test_the_key_line_says_what_a_press_will_do and reverting after each run:

  • At the point of the new assertion, document.activeElement is lf-conversation-thread lf-ui and activeElement.closest('.lf-chrome') is non-null — so inChrome holds and the standing step is null.
  • Tabbing twice after the block's last assertion lands on .lf-mark-note, whose closest('.lf-chrome') is null. Opening the reference there gives one navigation.back row: esc / Let go of what you are standing on.
  • Just before the block's final Escape, .lf-shortcut-bar reads esc / dismiss conversation.

Review selection run locally, all green: tests/test_render_navigation.py (140), tests/test_render_margin.py (111), tests/test_render_projection.py::test_escape_lets_go_of_the_ask_the_reader_is_standing_on, and tests/test_render_conversations.py -k "panel or narrow or search or escape or thread_panel" (21).

Comment thread tests/test_render_navigation.py Resolved
Comment thread tests/test_render_navigation.py Resolved
Inside the margin preview the reader is in the chrome, so only backing out onto
the page was ever live there and the count proved nothing about resolution. Two
Tabs further on the reader is standing on a mark, where letting go and backing
out both hold; on the six-scope commit the reference carried both rows there,
and it carries one now.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@max-sixty

Copy link
Copy Markdown
Owner Author

Right on all three, and thanks for the probe — I ran it as a control as well as a check. Two Tabs on, standing on .lf-mark-note, the reference carries one navigation.back reading "Let go of what you are standing on"; the same assertion against the commit that gave each step its own scope reports 2. So the state that was untested now has a control behind it.

The preview block's comment says what it actually covers now, and its closing assertion reads the line to show the next press is the preview's own dismissal rather than the ladder's.

pageRungs was a name for something that isn't there — the resolver is rung, and the header says so. The counts are gone from the header and from keyboard/CLAUDE.md rather than corrected, since the next door would have put them out of date again.

This was written by Claude Code on behalf of @max-sixty

@max-sixty
max-sixty merged commit 5d4626c into main Sep 19, 2026
5 checks passed
@max-sixty
max-sixty deleted the agent-a30100eb8d220c8a4 branch September 19, 2026 01:34
max-sixty added a commit that referenced this pull request Sep 19, 2026
…832)

Escape had three unrelated answers: a command's return frame, the
scene-read rung ladder, and a popover's own dismissal. None knew about
standing on a destination, and a layer opened by pointer had no record
of where the reader came from. So `t` from the page left the reader on a
rail control they never stood on, a card in the Threads panel could not
be let go of without closing the panel, a click on Threads cost an extra
Escape and ended on a ringed toggle whose Space reopened the panel, and
a clicked margin marker followed by `t` closed onto the marker of
whichever thread the walk reached.

One rule now: the way out is as deep as the way in, counted in presses,
whether the way in was a key or a click.

## What changed

**Standing is a rung of its own.** A card in the panel, an Ask or a
heading on the page: a STANDING scope lets go of it onto the layer's
floor, the list or the body, ahead of the return frames. A press that
stood the reader somewhere records a frame that holds the standing (`t`,
`a`, `g T` carrying an inline thread); a frame whose press stood nobody
says `standing: false`. The scope sits right after the return frames, so
a narrow shortcut bar promotes its Escape chip the way it promotes a
frame's. The walked-to card wears the same inset ring every other
keyboard target does; `TODO.md` records that the ring's weight is tuned
once for all of them.

**A pointer press that opens a layer is a stack entry.** `pressOrigin()`
in `keyboard/layer-stack.js` hands out the place focus held at the last
pointerdown, before the press moved it. The Threads toggle, a margin
marker or option, a page mark and its note all open through `invoke`
with that origin, so a clicked-open panel or conversation view closes to
the page the reader was reading, and the same control reached by
keyboard and pressed with Enter comes back to that control. A keyboard
or scripted activation is told apart by the click's own `detail === 0`,
read in the capture phase. A timer at pointerup lost to a key pressed
straight after a click, and a key listener is what the register's own
test forbids.

**What the reader put on since the press comes off first.** A frame that
stood the reader nowhere names the `surface` its press entered.
`outsideCurrentFrame` is the one reading of what follows: an Escape step
rooted outside that surface, and not already answering when the press
was made, unwinds ahead of the frame. Unframed state records no time, so
the stack takes a census of the steps answering Escape as each such
press is made; the dispatcher installs the census, and the fallback
ladder's one command names the rung it stands for. That covers a
selection, a comment box, a clicked reply box, or an unfolded margin
cluster made after the panel opened, while a target captured before `g
T` stays behind the panel's Escape.

**The panel has one frame.** It had been built by hand at three doors
and had drifted: the words promised a close while the press showed every
thread. `panelFrame` in `thread-panel.js` serves the toggle, `g T`, and
the page-thread door's panel half. Its close takes off a narrowing put
on since the press before it closes the panel, its words follow that
("show all", then "close threads"), and its standing reads live. `g T`
over an open panel closes it outright.

**Ported onto #815.** The standing floor lives in `keyboard/page.js`
behind `declareStanding`, the ladder drops its "standing" rung, and the
`t` and `a` walks carry their frames in `navigation.js` and
`asks/view.js`. The deferred half of `restoreReturnPlace` asks
`retainReaderIntent` before it moves anyone, so `reader-intent.js` joins
the dispatcher's declared closure. `skills/leaf/assets/CLAUDE.md`'s
runtime-ownership entries for the panel and for keyboard meaning say the
same order.

## Behaviour that moved in the suite

The panel's Escape after a pointer open lands on the page rather than
ringing the toggle, which the rung test had recorded as the old design's
cost. A margin option pressed from inside a keyboard-unfolded cluster
returns to the control the reader stood on. The card-ownership test
reads ownership off the control's aria state instead of off where focus
lands. The facets test reads the frame's words before and after its
narrowing comes off. New cases cover the press journeys, the mark and
carry-in doors, and state put on after the panel; each fails with its
fix disabled.

## Known limits

The census compares steps by name, so a selection that replaces an older
one still counts as the older one. A pointer close through the view's ×
or the panel's Close button still lands on the marker or the toggle,
since the hand is there. Clicking Threads from inside a marker's view
and pressing Escape reaches the page one frame after the panel closes.
Browser tests ran in Chromium only. The reviewer ran the nightly
selection on the merged tree and it was green.

## Verification

The everyday suite: 1148 passed. `test_render_margin` 113,
`test_render_projection` 152, and the targeted navigation, conversations
and controls cases passed after the last merge from main.
dependency-cruiser and eslint clean.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
max-sixty added a commit that referenced this pull request Sep 19, 2026
The merge's #8/#27 hunk had each side removing one item, and taking this
branch's side put #8 back. Every side's removal stands: main closed #8 in #815,
and this branch closes #27.
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]>
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