Skip to content

Move the runtime's children into a directory per import layer, and check the layers - #7119

Merged
max-sixty merged 9 commits into
mainfrom
agent-a6d00394971a9dfd9
Nov 25, 2026
Merged

max-sixty merged 9 commits into
mainfrom
agent-a6d00394971a9dfd9

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Moves each top-level child of browser/runtime/ into a directory for its import layer, and rewrites the dependency-cruiser layering check (#7113) to name 11 layers in place of an order of 187 children. A module imports only its own layer and the layers below it. The layering, drawn from today's imports, leaves 2 imports pointing up, against 15 for the best flat order, so the known list drops from 15 entries to 2. No behaviour changes.

# Layer Directory
0 Entry points and diagnostics top level of runtime/
1 Floating panel, page dialogs and page keys panel/
2 Annotation presentation, composing and undo annotations/
3 Application and widget host host/
4 Page features: annotation inventory, contributions, version travel features/
5 Records and history records/
6 Page readings, places and paint readings/
7 Transport, errors and notices transport/
8 DOM, geometry, focus and the key register dom/
9 State and registry state/
10 Primitives and the library base/, and lib/ where it was

What stays put. The entry points (bootstrap, prepaint, check-api, validation, widget-api, portable-api, stage-integration, age) and lib/ keep their paths, since pages, packages, the server and the render checks load them by served path. So do the files that aren't modules: chrome.css, marks.css, panel-row.html and kernel-registry.json, which the server and Python read at their served paths. A child directory keeps its name inside its layer, as in dom/keyboard/.

How the paths moved. The first commit is the move with git mv (all 271 renames detected) and the path rewrites. A script resolved every relative and served-path specifier in the old tree and wrote the target's new path; other references in Python, configs, the build, tests and guidance followed. The primitives' eslint rule now names each primitive's neighbours by the relative path from its own place. Eval fixtures, pinned GitHub permalinks and the example diff in worktree-diffs.html keep the paths they recorded. The second commit rewrites the check and adds "Import layers" to browser/AGENTS.md. A later commit gives the new path wherever guidance, comments or tests named a moved top-level module by its bare filename (focus.js → dom/focus.js), which had also been its path under runtime/; a sibling in the same directory keeps its bare name, and a basename code compares keeps it too.

The two upward imports in .config/dependency-cruiser-known.json: host/application.js → annotations/undo.js, and host/sample-child.js → annotations/composing/page-image.js (a lazy import).

What to check.

Tests: pnpm run check (type checks, test:runtime 1130 pass, build and worker tests), pnpm run build:browser (no generated file changed), the prepared kernel build (same 68 outputs as base), pre-commit on every changed file, tests/smoke, the model tests for served runtime modules and public modules (test_module_url_delivery, test_revision_delivery, test_distribution, test_interact_layer: 318 pass), test_owner_index, the prepared-install journey in tests/journeys/test_distribution.py, and leaf-dev probe alert-review --base: the page boots, the panel draws the same label, with the same 317 requests and no console output on either arm.

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

Each top-level child of browser/runtime moves into the directory of its
layer: panel/, annotations/, host/, features/, records/, readings/,
transport/, dom/, state/ and base/. The entry points (bootstrap, prepaint,
check-api, validation, widget-api, portable-api, stage-integration, age),
lib/ and the served sheets, panel row and kernel registry keep their
paths, since pages, packages and the server name them by served path.

Every relative and served-path specifier was rewritten by resolving it in
the old tree and writing the target's new path, and every other reference
to a moved path follows it: the eslint, knip and dependency-cruiser
configs, the build, the website verifier, Python, tests and guidance.
The primitives' import rule now names each primitive's neighbours by the
relative path from its own place, and the record folds' rule names their
new paths. Eval fixtures and pinned permalinks keep the paths they
recorded. No behaviour changes.
# Conflicts:
#	browser/runtime/check-api.js
#	src/leaf/state.py
…ldren

The layering check names the runtime's eleven layers, top first, in place
of an order of its 187 children. The entry points at the runtime's top
level are the top layer, each directory is a layer, and lib/ belongs to
the bottom layer beside base/. A module of a layer imports only its own
layer and the layers after it, and a module anywhere else at the top
level fails `layering-unplaced`.

The known list drops from 15 upward imports to the 2 the layering keeps:
host/application.js imports annotations/undo.js, and
host/sample-child.js imports annotations/composing/page-image.js lazily.
browser/AGENTS.md gains "Import layers", which states the rule and points
at the config for the list.
leaf-agent
leaf-agent previously approved these changes Nov 25, 2026

@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 "Import layers" section says every module imports only its own layer and the layers below it, but the framework's facade now sits in records/ (layer 5) while modules in state/, transport/, dom/ and base/ import it by served path. For example, base/page-controls.js imports signal from /runtime/records/framework.js. Because the dependency-cruiser config excludes that path, the check never sees those imports. It also misses the cycle through the facade: state/semantic-state.js → records/framework/application.js → state/kept.js. This isn't new, since base already excluded /runtime/framework.js, but the directory names now make those imports read as upward, and a reader who trusts the prose will be misled. The suggestion below states the exception where the rule is stated. The underlying fix is to split the facade: the primitives (signal, share, untracked, the Lit glue) would move into base/ or state/, and createSemanticApplication would stay with the record folds in records/. This PR leaves that split as easy to make as before.

Comment thread browser/AGENTS.md Resolved
Guidance, comments and tests named a top-level runtime module by its bare
filename, such as `focus.js`, which was also its path under `runtime/`.
Each such name of a moved module now gives its new path (`dom/focus.js`),
except where the module stands beside the file that names it, or where a
file inside a runtime directory may mean a sibling of the same name. A
string that code compares with a basename keeps the basename. So the
question index in browser/AGENTS.md names owners that
test_owner_index.py finds again.

The prepared-install test now makes `runtime/state/` in its custom
package before writing the private override there.
The facade sits in records/ while every layer imports it by served path, which the check excludes, so the rule names it as the exception.
leaf-agent
leaf-agent previously approved these changes Nov 25, 2026
# Conflicts:
#	tests/browser/threads/__init__.py
leaf-agent added a commit that referenced this pull request Nov 25, 2026
…ontrols with the library's offered (#7130)

Two cleanups from the nightly survey. Neither changes what a page draws.

- **`repaint.js`'s `paintVersionShortcuts` slot was dead.** The
`Painters` typedef declared it and each frame called
`p.paintVersionShortcuts?.()`, but neither `mountRepaint` call in
`browser/leaf.js` (live page or export) passes such a painter, and
nothing else in `browser/` names it. The slot and the call are removed.
- **`shot-view.js` had its own copy of `offered`.** Its `render()`
defined `offered(cls, pressable)` as a `ref` around `offerElement`,
which is what `offered` in `runtime/lib/controls.js` already is
(`elementDirective("offered", offerElement)`). The screenshot now
imports the library's directive, and its caption uses it too. Lit's
`ref` re-runs a callback that changed, and an inline arrow is new each
render, so the copy already wrote on every render, as the directive
does; both write through `keeps`. With the screenshot gone as its only
outside importer, `offerElement` is no longer exported (knip flags it
otherwise), and the library header names `offer` and `offered` as the
forms that mark a field or a box.

The survey also flagged `drafts.js` importing the framework as
`./framework.js`, the one backward import #7113 recorded for it; #7119
moves `framework.js` beside `drafts.js` and drops that entry, so this PR
leaves it alone.

**Verified:** pre-commit on the changed files (eslint, oxfmt, knip,
dependency-cruiser) passes; `pnpm run check:browser` passes; `pnpm run
test:runtime` passes 1130 of 1130; the screenshot tests
`test_shot_controls_have_disjoint_targets_and_labels_stay_passive`,
`test_shot_inspects_either_original_without_flipping_or_moving`,
`test_a_shot_takes_a_view_pressed_as_the_page_shows_and_keeps_its_divider`
and `test_a_shot_opens_in_the_view_its_author_names` pass. No regression
test is added, since no behavior changes.

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

GitHub reports this branch as conflicting with main since #7130 landed (it edits browser/runtime/repaint.js, now dom/repaint.js). So no pull_request CI runs on this head, and it can't be approved or landed. A local git merge origin/main resolves cleanly through rename detection: #7130's removal of paintVersionShortcuts lands in dom/repaint.js, no module is left at its old top-level path, and the layer check still passes. Merging main in should clear it. Nothing in the code has changed since the last approval besides the earlier main merge.

@max-sixty
max-sixty merged commit ceec054 into main Nov 25, 2026
5 of 6 checks passed
@max-sixty
max-sixty deleted the agent-a6d00394971a9dfd9 branch November 25, 2026 08:14
max-sixty added a commit that referenced this pull request Nov 25, 2026
…port (#7137)

Removes `browser/runtime/records/framework.js`, the facade that every
layer imported. The layer check (#7113, #7119) had to exclude it, so it
couldn't see routes through it, such as `state/semantic-state.js`
reaching the record folds in `records/` through
`createSemanticApplication`. With the facade gone, dependency-cruiser
checks every runtime import and still finds only the 2 known crossings.
A Leaf page behaves as before. #7119's reviewer proposed this split.

Each piece now stands in the lowest layer its own imports allow:

- **Lit and signals.** Importers use `/vendor/lit.js` and
`/vendor/signals-core.js` directly, as `lib/` and several runtime
modules already did.
- **`base/snapshot.js` and `base/presentation.js`.** Both import only
signals.
- **`state/semantic-application.js`** (was
`records/framework/application.js`). The five folds it reads move from
`records/` to the same paths under `state/`: `thread/model`,
`thread/identity`, `pending/model`, `projection/model` and
`obligations/source`. `semantic-state.js` stays in `state/`, since
modules in `state/` and `readings/` import it.
- **A new dependency-cruiser rule.** `one-application-publisher` lets
only `state/semantic-state.js` import `semantic-application.js`. It
replaces the eslint rule `semantic-store-ownership` and its test, which
policed imports through the facade.

**What to check**

- `dom/move-focus.js` installs Leaf's focus accounting around DOM moves.
Any entry point that imported the facade used to install it,
`portable-api.js` on a plain HTML page included. Now `leaf.js` imports
it first, so only a Leaf page installs it, as the module's header says
("off Leaf the browser owns focus"). On a Leaf page it installs earlier
than before.
- `createApplicationPublisher` now sits in `base/snapshot.js` beside
`share` and `defineOwn`, so any module can import it, where before only
the framework's own modules could. The new rule fences
`createSemanticApplication`, which builds the page's one application
state.

Tests: pre-commit over the change (dependency-cruiser, knip, eslint),
`pnpm run test:runtime` (1126 pass), `pnpm run check`, `pnpm run
build:browser` (no generated file changed), the kernel bundle build,
`tests/smoke/test_plain_page.py`, and `leaf-dev probe alert-review
--base` (both arms boot with no console output).

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 25, 2026
… fails every upward import (#7145)

Ends the 2 imports in `browser/runtime` that pointed up a layer, so
dependency-cruiser's layer check (#7113, #7119, #7137) needs no list of
known crossings. `.config/dependency-cruiser-known.json` and the hook's
`--ignore-known` go, and any upward import now fails pre-commit.

- **Undo** moves from `annotations/` to `records/`, the lowest layer its
imports allow, so `host/application.js`, which creates it, imports
downward. It borrowed two things from `annotations/`. `commentDraft`,
the draft a comment was written in, moves to `records/drafts.js` beside
every other draft's key, with the composer's draft record
(`composerCtx`, `composerPayload`, `ComposerDraft`, `isComposerDraft`).
`reactionPlace`, whose only caller was undo, becomes private to it.
- **The page image** moves from `annotations/composing/` to `host/`,
beside `host/sample-child.js`, which loads it, and `host/sample.js`,
which it loads. `dom/` would put its import of `sample.js` upward.

No module re-exports an old path, and a page behaves as before.

**What to check:** `ComposerDraft` in `records/drafts.js` names
`DraftDrawing` from `annotations/composing/drawing-record.js` in a JSDoc
type, as drafts.js's other type references already point upward.
dependency-cruiser doesn't read JSDoc.

Tests: pre-commit over the change (dependency-cruiser finds 0
violations), `pnpm run check` (1127 runtime tests pass), `pnpm run
build:browser` (no generated file changed), and `leaf-dev probe
alert-review --base` with a ⌘Z press (no console output on either arm).

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

Co-authored-by: Claude Opus 5.5 <[email protected]>
max-sixty added a commit that referenced this pull request Nov 25, 2026
…eet the package-interface cut

Main moved the runtime's modules into a directory per import layer and dropped the framework facade (#7119, #7137, #7145, #7146); this branch cut the package interface and moved stateless code into lib/. Imports take main's layer paths with the branch's names. dom-move.js, dom-children.js and language-paths.js stay in lib/, where packages import them by served path, and main's dom/ and base/ copies are gone; dom/move-focus.js still installs the focus hooks into lib/dom-move.js. The branch's new readings.js joins host/, since it imports host/reports.js. views.js, work.js and the tests of them stay deleted. Imports of the dropped facade name /vendor/lit.js, /vendor/signals-core.js and base/presentation.js directly.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 25, 2026
… reach over a ring as no cover (#7129)

In an opened settled decision whose options are bare rows, with the
keyboard in the group so its digits show, the focus ring on an option's
mark stood the row's full height: a tall ring round the 11px circle,
reaching 5px above and below the row, with its bottom run under the next
row's ground. It hugs the mark again, as it did before #7091.

**Cause.** #7091 made a row's mark stand the row's height while the
digit shows, so that the mark's reach (the transparent `::after` #7075
added) covers the whole digit column. A ring follows the box it is drawn
on, so the mark's own ring grew with it. In a live group the row wears
the mark's ring and the mark's own is off, so nothing visible changed
there, and #7091's stills showed only live groups. An opened settled
group is the one place the mark wears its own ring, and no still covered
it with the digits showing.

**Fix.** The mark stands the row's height only in a live group. In a
settled group it keeps its 11px box, and its reach covers the digit's
height, as in #7075; one `inset-block: min(0px, (100% -
var(--lf-key-badge-size)) / 2)` serves both. A new stills state,
`settled-option-row-keyboard`, shows the surface.

To weigh: in an opened settled group, a press in the digit column above
or below the digit (6px each side on a one-line row) lands on the row
again. It picks the row, but focus leaves the group and the digits
disappear, which #7091 had fixed. Keeping both would need the ring off
the mark's box, for example by having the row wear the ring in a settled
group as it does in a live one. That changes how a settled group shows
focus, so it is left for you to decide.

**The ring check's other five faults.**
`test_each_sampled_focus_ring_is_shown_whole_in_its_surface` also
reported the left edge of a live row's ring in ship-review and
feature-gallery as "under" the row's own mark. That ring is whole: the
screenshot shows the ring's colour at each sampled point. The box over
the left band is the mark's reach, which takes hits and paints nothing.
The check counted a hit on a box inside the control as paint whenever
the box's own styles showed a fill or border, and a hit on a
pseudo-element is read through its host's styles. These covers now go
through the screenshot confirmation that a neighbour's cover already
goes through (#4836). The new
`test_the_ring_reading_passes_over_a_reach_inside_the_control_that_paints_nothing`
fails without that change.

The defect surfaced as a failure of that ring test in #7119, the
runtime's layer move, which doesn't cause it: the test fails the same
way on `main` at 109461e and f9ff587. A pull request runs it only
when it edits the test's file.

max-sixty asked for refactoring to continue while each change improves
the code.

Checks: the ring test passes (it failed with 6 faults before); the new
ring-reading test and two neighbours; 11 option tests by node id,
including the digit-column press test in Chromium and Firefox; `leaf-dev
stills --base` in Chromium and Firefox (the settled state changes,
`ship-option-row-keyboard` is identical); the stills model tests;
pre-commit; `pnpm run check:browser`.

> _This was written by Claude Code on behalf of max-sixty_
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