Skip to content

Separate Leaf application resources from skill instructions - #3593

Merged
max-sixty merged 11 commits into
mainfrom
codex/plugin-layout
Oct 22, 2026
Merged

max-sixty merged 11 commits into
mainfrom
codex/plugin-layout

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Leaf's skill directory contained the Python application, browser runtime, bundled packages and compiled kernel. Move those resources to plugin-level directories so installation/execution and agent instructions have distinct owners.

  • src/leaf/ owns the Python application; browser/ owns browser assets and authored framework TypeScript; packages/ owns bundled capabilities; dist/kernel/ holds the generated delivery runtime. skills/leaf/ retains instructions and references, and build tools remain under build/.
  • Resolve application resources from the plugin root, and update launcher/cold cleanup, Codex MCP registration, prepared payloads, build inputs, CI/lint paths and documentation together. Prepared comparisons ask the selected runtime for its own resource paths, preserving older-layout comparisons without compatibility branches.
  • Preserve page URLs, kernel fallback and package composition. Most files are renames; remaining mechanical changes include path references, generated source provenance and import sorting after adopting src/.

Validation: full pnpm run check (132 framework/build, 519 runtime and 84 Worker tests), all pre-commit checks, 14 focused installed-payload/cold-cleanup/transport checks, 7 independently reviewed distribution checks, and both layer assertions corrected after CI exposed their old layout assumptions. The full real Claude Code 2.1.308 journey passed authoring, comment delivery, revisions, interruption recovery and cleanup. Served base/candidate comparison loaded the same 43 requests (38 JavaScript) with no console errors or layout shifts. The real sandboxed Codex queue journey passed setup, release, rich-choice, rich-question, mid-turn delivery and interrupted-turn resume. Its unload cleanup timed out; a native-plugin control on unmodified main reproduced the missing SessionEnd/marker retirement after acknowledged unsubscribe. This pre-existing lifecycle issue is recorded separately; the full Codex journey is not reported as passing.

This was written by Codex on behalf of max-sixty

leaf-agent
leaf-agent previously approved these changes Oct 22, 2026
leaf-agent
leaf-agent previously approved these changes Oct 22, 2026
@max-sixty
max-sixty merged commit 2c51c3a into main Oct 22, 2026
4 checks passed
@max-sixty
max-sixty deleted the codex/plugin-layout branch October 22, 2026 19:56
max-sixty added a commit that referenced this pull request Oct 24, 2026
Cuts the guidance Leaf ships to agents — the skill, its references,
package instructions, registry instruction strings and the text Leaf's
code prints — to the claims an agent acts on. This is the agent half of
the guidance cut; the maintainer half (groups A–E) lands separately.
Each group was cut on its own branch, reviewed side by side against
main, and is one commit here, merged onto current main with main's later
changes kept. Each commit message lists what its group cut, what it kept
and how each conflict with main was resolved.

## Groups

Word counts are `wc -w` on main (`79af4eb2f`) and on this branch.

**F — SKILL.md and the conversation loop** (11 files, 12,418 → 11,115,
−10%). Drops what command `--help` already says, what delivered
`handling` already says, mechanism no reader acts on (the surfaces
table, Sent/Queued/Delivered, the desktop wake, Codex's queue check, the
render check's JSON fields), duplicates and justification. Corrects
SKILL.md step 1: running `page init` again with `--package` replaces the
page's packages rather than adding one.

**G — page authoring and layout** (5 references, 8,120 → 6,868, −15%;
default registry x-instructions 1,810 → 1,533; kernel 116 → 104). Drops
each file's route restatement, copies of other references and of
registry entries, rules `page check` already reports, narration that
asks nothing of the author, and hedges with no failure behind them.
Moves the side-list tab summary rules and the tally rule from
`lf-tab`/`lf-tally` into `page-layout.md`, "A workspace", which agents
re-read when revising (queue-is-a-side-list went 0/2 → 2/2).

**H — module references** (6 files, 14,420 → 12,871, −11%). Keeps every
`widget-api.js` export's signature, return and usage rule; drops section
lists, runtime mechanism, refusals the runtime already throws into a
page error, restatements and maintainer-only build detail.
module-authoring's route to module-reading.md now names icons
(widget-interface-serves-the-task 1/4 → 4/4).

**I — packages** (3 references and the 10 instructions files, 10,324 →
9,572, −7%; package registry instruction strings 1,444 → 875). Removes
duplication between each package's instructions file and its registry
entries, which `page instructions --use` concatenates, so the registry
keeps markup and API facts and the instructions file keeps choice rules.
Drops `--help` restatements, refusals a check reports, and playground's
"Task-shaped recipes", whose shared rules now sit under "Stateful
previews" and in the handoff check. Corrects `lf-playground-preset`: a
control the preset doesn't set keeps its current value.

**J — text Leaf's code hands agents** (delivered handling/answering
clauses 1,490 → 1,237; every event case's delivery, per the snapshot,
9,076 → 7,317 words). Drops narration of what Leaf does by itself,
restatements, justifications and the `invalid-registry` finding, which
nothing produces. Moves the anchor-move rule from every reply clause to
the `relocated-anchor` finding, and corrects `page check --help`: a
plain check also runs the page's scripts and browser-judged widgets.

A sixth commit repoints four references at conversation-loop.md's "Page
availability and handoff", which main renamed from "Status and handoff"
without updating them, and fixes packages.md's pre-#3593 path to
`src/leaf/layer-registry.md`.

## Eval-backed passages kept

- Answer a question you can already settle before revising the page
(`parent-keeps-leaf-responsive/known-answer`, #3169).
- The `leaf task plan` paragraph and example (`0ae092c32`, 1/5 → 4/4 on
Claude Code).
- The second `thread summarize` example
(`thread-fold-without-summary-prose`).
- Progress and failure replies publish nothing.
- A bounded `<pre>` or table clips what runs past it, with the
`data-bound` and `<details>` routes (#3347).
- The touch route for hiding markers: the leaf's menu → Annotations →
Hide annotations (`pin-takes-no-page-room`).
- The route to a package's other audiences, such as a contract's
`producer`.
- A widget output's value must fit its contract, since nothing checks
it; `wireInput`'s keys; `failSoft`'s `source`; a `start` that throws not
running again.
- The progress line before any other command, "even a read"
(`first-command-says-what-comes`), and the reply's own check of the
saved edit.
- "An option the user added needs no writing in" on the markup clause
(#2632).

## Checks

- `pytest -n 3` over test_hooks, test_stop_guard, test_wait,
test_receipts, test_thread_reading, test_interact_layer,
interact_contract/, test_delivery, test_interact_product,
test_interact_anchors, test_activity and test_product_page: 848 passed,
1 failed. The failure,
`test_hooks.py::test_a_prompt_re_vendors_a_page_an_older_leaf_vendored_and_hands_over_its_input`,
received a pointer instead of an inline delivery on a host at load
average 30; it passes when run alone.
- The six snapshots group J's strings reach were regenerated with
`--regtest-reset` from the resolved code;
`tests/process/website_server/test_app_server.py` passes with its
snapshot unchanged.
- `node --test tests/runtime/widget-api.test.mjs`, which requires every
authoring export to be named in a module reference: 4 passed.
- `leaf package check` on all eleven bundled packages: no findings.
- `pre-commit run --files` over the 53 changed files: passed.
- Every `file.md, "Heading"` and `file.md#anchor` pointer in the changed
prose resolves on this tree, and pointers into files groups A–E change
resolve on those branches. No removed heading is cited anywhere.

- An independent review redid each group's merge file by file and
checked every conflict by hand against main's additions and the group's
reviewed diff. It found no lost claim; three reviewed cuts that main's
rewordings had brought back (a `--attempt` sentence in `thread reply
--help`, a second `module-state.md` pointer in `package-data.md`, and
the `lf-motion` registry string repeating `instructions/author.md`) are
reapplied in the last commit, with the command-help snapshot
regenerated.

Not run: the browser and journey tiers, and no evals were rerun after
assembly; each group's evals ran on its own branch against its merge
base.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
An overnight survey found plain git log undercounts a runtime file's
history about tenfold, since #3593 moved browser/runtime and the log
stops at the move.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
`test_a_pointer_press_on_a_playground_control_leaves_the_user_in_the_preview`
read the sample's focus once, right after a click and a drag on the Width
range. A range takes native focus to be dragged, and the playground hands
the user back to an opaque sample through its port, so the focus returns
after the sample answers. On the macOS runner the read landed before the
answer and failed with "slider". The test now waits for the sample's
button to hold focus again; a 500ms delay on that answer fails the old
read with the CI message and passes the wait.

The read has raced that answer since the hand-back went through the
port (older than #3593, which moved the package); the macOS job is the
first run to lose it. The behavior protected is unchanged: a press on a
playground control leaves the user in the preview.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
Add `/grinding-backlog`, the workflow for running unattended agents on
Leaf's backlog, and make `/developing-leaf`'s maintenance survey count a
file's patches across its moves.

- **`/grinding-backlog`** turns the backlog items that need no judgment
from the user into draft PRs, each reviewed and fixed before the user
returns. The 24 October overnight run used this workflow from a scratch
brief, and the skill keeps what that run measured. Its steps:
- choose issues labelled `backlog` and not `waits-on-user` that no PR
claims;
- check each premise by running it, since reading got 3 of 10 premises
wrong and running got all of them right;
- check for overlapping PRs and campaigns, since two campaigns on one
list duplicated four PRs;
- give each agent its own worktree and the shared brief
(`references/brief.md`), and have it open a draft PR that says `Closes
#N`;
- give every PR an independent reviewer that runs checks, and resume the
author with the findings (22 of 55 PRs had a substantive defect);
  - score instruction changes against paired `--base` arms;
- hand each decision to the user explained for someone who hasn't opened
the PR.
- **`/developing-leaf` asks for a picture of every UI option left to the
user**: a still pair, sketch, diagram or live sample, including calls a
PR body leaves open. Max found the overnight page's layout calls
impossible to review as text.
- **`/developing-leaf`'s maintenance survey** counts patches with `git
log --follow`. Without it a file's history stops at its last move, and
since #3593 moved `browser/runtime` a plain count reads about a tenth of
the real churn.

The skill selects from the backlog issues that #4090 introduces. The
issues and the `waits-on-user` label already exist; and #4090, which put
the query in `TODO.md`, has landed. This PR's earlier `TODO.md` and note
edits moved into the issues and #4090.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 27, 2026
…tep (#3899)

Second item of the phone-quality queue (#4023, "Improve maintained
examples through a phone-quality queue"), after `triage-board` (#3869).

## What changed

- `examples/security-boundary.html`: the "Before: workspace ownership
crossed phases" flow is drawn `flowchart TD` instead of `LR`, with
`data-height` set to the drawing's new 449px. Leaf's own `lf-diagram`
instruction asks for top-down on a chain longer than three steps; this
example predates the instruction (#438 vs #3593) and was the one shipped
page still drawing a long chain sideways.
- `tests/browser/test_render_gate.py`: the scrollbar-clearance test
reads this example for a drawing wider than a 678px viewport, so it now
turns the chain back to `LR` in the source it serves, beside the
`data-height` it already rewrote.
- `dev/leaf_dev/commands/stills.py`: four `security-flow*` states (1440
and 390, light and dark) so the drawing has a before/after pair.

## Why this example

Every catalogue example was opened at 390×844 under a coarse pointer and
its first two screens read, with a journey that lists elements wider
than the viewport, boxes that scroll sideways and controls under 32px
(`.tmp/phone/journey.py` in the worktree; `uv run leaf-dev probe
<example> --viewport 390x844 --touch --journey …`). Five examples had
content scrolling sideways:

| example | what scrolls sideways at 390 | verdict |
| --- | --- | --- |
| security-boundary | the five-step flow: 1150px drawing in a 342px box;
the three red boxes, the point of the figure, off the edge | **fixed
here** |
| data-explorer | result table 480px in a 336px frame; the Risk column,
the field the filters act on, cut off; sticky controls hold 27% of the
screen | next |
| alert-review | nine-tab strip of 2419px shows under two alert names;
`lf-tabs`' phone design, with Next on me and chevrons reaching the rest
| design, not a defect |
| code-comparison | code reader 761px wide (inherent to code); sticky
controls hold 36% of the screen | after data-explorer |
| dynamic-widgets | tab strip 458px in 340px | minor |
| github-discoveries | a `pre` 811px wide | minor |

Controls under 32px on touch, which the widgets own rather than the
examples: the code reader's Copy (17×17 bounding box; whether a
pseudo-element widens its hit area wasn't checked), `lf-option-control`
marks (11–19px, though the option card may be the target),
release-notes' `.handle` (30px), rust-sort's scrubber (16px tall).

## Why content, not the widget

`packages/diagram/theme.css` records that a drawing is never scaled or
re-laid out (labels would fall below legibility; comment coordinates sit
on the drawn boxes), and the registry's `x-instructions` already tell
authors to draw long chains top-down. A widget that re-rendered `LR` as
`TD` when its box is narrower than the drawing would reverse that record
and add a second render per resize for one case the instruction covers,
so the example follows the instruction instead. That is a call Max may
reverse.

## Evidence

Before and after, from `uv run leaf-dev stills --authored --state
security-flow --state security-flow-dark --state security-flow-phone
--state security-flow-phone-dark` (crops under
`.tmp/stills/run-uwteeakp/` in the worktree, gathered on a Leaf page at
`.tmp/phone/evidence/`, `page check` clean):

- 390×844, touch: before, `clientWidth` 342 / `scrollWidth` 1150, two of
five steps visible; after, 342 / 342, drawing 256×449, all five steps
and the three red ones in view. Same in dark.
- 1440×900: before, the `LR` chain grew into the margins and fit (1392px
wide, 77px tall); after, a 449px-tall column on the prose axis. Nothing
is clipped at 1440; a desktop reader scrolls about half a screen more
past the figure. Same in dark.
- Touch journey (`.tmp/phone/touch-journey.py`, recorded to
`.tmp/phone/touch/worktree/{recording.gif,trace.zip}`): panel menu →
Annotate → target picker → tap "Same tree handed to agent" → composer
quotes `§ diagram · Same tree handed to agent` → type → Comment → margin
preview with the box marked. Passes on both drawings; on main's `LR`
drawing the box's rectangle was outside the viewport before the tap
(`box_in_viewport: false`), on this one it is in view (`true`).

## What ran

- `uv run pytest tests/browser/test_render_gate.py -k
test_a_diagrams_reserved_box_includes_its_scrollbar_clearance` (3
passed)
- `uv run pytest tests/journeys/test_render_gate.py -k
"test_page_fixture_renders and security"` (1 passed: the corpus render
gate on this page, which reports an unreserved or wrong `data-height`)
- `uv run pytest dev/tests/model/test_stills.py` (3 passed)
- pre-commit on the changed files

Not verified: a real phone (emulation only), Firefox, and the public
catalogue still (`wt refresh-previews` is not run from a draft; the
example's first screen doesn't change, since the flow is below the
fold).

Part of #4023.

**On landing, update** #4023: `security-boundary` is done.

> _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 Oct 28, 2026
…ontrols by reaching them; probe with normal motion (#4623)

Two UI sessions (per-message Copy, the reply box's send arrow) kept
handing over defects you found within seconds. This branch adds what the
diagnosis showed was missing: an eval of whether a fresh reviewer
catches those defects, a corrected instruction about how to check
controls, and a probe default that matches what you see.

**Eval: three thread defects in `evals/ui-review-detection`.** Each
defect is reconstructed in a fixture and paired with a fixed control.
- `message-copy-placement`: Copy stands one track in from the card's
edge.
- `later-message-controls`: a head-row cell paints over a later
message's controls.
- `controls-after-a-press`: controls stay lit after a press, while the
pointer rests on another message.

The browser provider gains a `hover` operation, since a reviewer
couldn't reveal hover-only controls without it. The capture step checks
each fixture against its rubric target. Results from the 2026-10-28
calibration with Opus and Sol:
- **Screenshots supplied:** both models caught the covered controls 3/3.
Opus caught the controls left lit 3/3 and Sol 0/3. Neither flagged the
mid-card Copy, which both described as minor.
- **Browser from arrival:** both found the covered controls, and neither
found the lit controls, because every reviewer pressed Copy and then
clicked something else instead of resting the pointer.
- **False alarms:** none on any fixed control.

The README records the details. The branch also restores the stepping
fixture's dependency path. #3593 had rewritten it, and `--prepare-only`
failed until it was fixed.

**`developing-leaf`, "Prove and hand off a visible change".** The skill
told the author to check controls by "their computed geometry before and
after the input", and the Copy test did exactly that. It passed while a
cell painted over the button. The sentence now asks the author to check
that the user can see and reach each control, and to reach it with a
Playwright hover or click. Playwright's actionability check refuses a
covered control.

**`leaf-dev probe` defaults to normal motion.** The reduced-motion
default hid the reply box's newline animation in every probe of the
send-arrow session. `--motion reduce` remains for a reading that wants
transitions settled at once. After the probe's settle step, no animation
was still running under either setting.

`uv run leaf-dev eval-ui-review --prepare-only` passes on the merged
tree.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent added a commit that referenced this pull request Nov 22, 2026
This week's duplicate sweep of `dev/`, `build/`, `tests/` and `worker/`
(week 47) moves six duplicated helpers onto one home each and moves
every caller. Behavior stays the same. The touched model tests, the dev
js_facts tests and the Worker's routing, storage and index tests pass. A
script compared the old and new outputs of the consolidated `leaf_dev`
functions and the seeded-log reads across the corpus, and they match.

| Question | Home | Copies removed (introducing PR) |
|---|---|---|
| Which stylesheets do the core and the bundled packages ship, leaving
out vendored files? | new `interact_support.shipped_sheets` | `sheets()`
in `test_interface_fonts.py` (#4804) and `test_theme_tokens.py` (#6025).
Five inline loops in `test_interact_layer.py` (#3138, #3886) |
| Run `tests/js_facts.mjs` | `interact_support.js_facts` (#2666) | its
own subprocess call in `dev/tests/test_js_facts.py` (#5118) |
| Lowercase hex of bytes in the Worker | `routing.hex`, which is
`newSessionId` (#313) renamed, plus a `sha256Hex` in `storage.ts` | the
publication-identity and chunk-digest copies in `storage.ts` (#2652) |
| Is this pid alive? | `leaf.machine.pid_alive` | `_alive` in
`tests/process/test_codex_tool.py` (#3331). `running()` in
`test_interact_layer.py` (#1774) |
| Read an example's seeded log | `read_event_lines(seed_log(source))`
(#4484) | inline parsers in `test_render_pages.py`,
`test_interact_product.py` (#924) and `test_render_gate.py` (#509). The
last one split lines with `splitlines()`, which also breaks at U+2028 |
| Paths of the bundled registries and packages; which registry keys name
elements | `leaf.schema.ASSETS` / `BUNDLED_PACKAGES` /
`DEFAULT_PACKAGE`, `leaf.registry.contract.is_element_name`,
`docs.registries()` | `docs.py`'s own `ASSETS`/`PACKAGES` (#3593) and
its `startswith("lf-")` checks (#2660). `logs usage`'s hand-written
regex and registry list (#5970). `ROOT / "packages" / "default"` in
`stills.py` (#3927) and `test_product_page.py` (#3593) |

`is_element_name` and the two checks it replaces give the same answer
for every key in the bundled registries today. A selector key such as
`lf-options.selected` would have passed the `lf-` prefix test.

<details><summary>Sets found and left alone</summary>

- **Sets an open PR is changing.** Nothing in this diff overlaps another
open PR's hunks. #6732 moves tests out of `test_render_gate.py`,
`test_render_pages.py` and `test_interact_layer.py`, but none of the
tests changed here.
- **Changes to browser tests with nothing run to check them.** The WCAG
contrast computation exists as about 11 copies across browser, journey
and model tests. Other copies: about 9 `EDITOR_ROOTS` shadow-root
keepers, the `/api/interaction` batch predicates, CDP `touch()`
closures, one-line patch templates, reply-holding route handlers, and
the `data-lf-entry` runtime-module import snippet in
`dev/leaf_dev/states.py` and in tests. Each would mean editing browser
tests that this sweep can't run on a shared host. They suit a sweep that
can run those tests.
- **Vendor bundling.** `build/browser/build.mjs` builds signals-core and
Lit with esbuild calls that repeat `build/vendor.mjs`'s `bundle()`.
Merging them changes build options and needs a full `check:browser` byte
comparison, so it was left for a change that runs that.
- **Copies that are near but not the same.** `_build.py`'s `check_links`
repeats `leaf_website.released_path`, but it also needs the matched
page's root and kind. The list of API-key variables an eval drops is
repeated across Python and the Promptfoo configs, as subsets and
supersets of one another. The Codex token-expiry check has different
thresholds, 1 h and 60 s.
- **Too small to be worth it.** Picking a free loopback port
(`eval_user.py`, `interact_support.available_loopback_port`). The XDG
state root in `leaf_dev.state_home` and `leaf.state.state_home`. The
`settled` helper in two `tests/runtime` files.

</details>

Co-authored-by: leaf-agent <[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