Skip to content

Drop the runtime's framework facade, so the layer check sees every import - #7137

Merged
max-sixty merged 1 commit into
mainfrom
agent-a93227a15acdddb29
Nov 25, 2026
Merged

max-sixty merged 1 commit into
mainfrom
agent-a93227a15acdddb29

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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

…ade's pieces in the layers their imports allow

records/framework.js re-exported Lit, signals, the snapshot and presentation
primitives and createSemanticApplication, and imported dom/move-focus.js
for its effect. Every layer imported it by served path, so
dependency-cruiser excluded it and saw no route through it:
state/semantic-state.js reached the record folds in records/ through
createSemanticApplication, and modules in base/ and state/ pulled in
dom/move-focus.js and its graph.

The facade goes, and each importer names the module that holds what it
uses:

- Lit and signals come from /vendor/lit.js and /vendor/signals-core.js,
  as the library and several runtime modules already imported them.
- The snapshot and presentation primitives import only signals, so they
  move to base/snapshot.js and base/presentation.js.
- The publisher moves to state/semantic-application.js, beside
  state/semantic-state.js, its one importer. semantic-state.js stays in
  state/, since state/context.js, state/document-identity.js,
  state/queue-api.js and three readings/ modules import it. The folds the
  publisher composes (thread/model, thread/identity, pending/model,
  projection/model, obligations/source) import only state/, base/ and lib/,
  so they move from records/ to the same paths under state/.

leaf.js imports dom/move-focus.js first, so the mover's focus accounting
is installed before any module the boot loads can render; before, it was
installed partway through the first facade importer's graph. The note on
installMoveSelection loses its reason, a cycle through the facade.

dependency-cruiser now checks every import. The exact closures of the
record readings and the keyboard dispatcher name the application state
they always reached, and `one-application-publisher` holds that only
semantic-state.js imports the publisher, which replaces the eslint rule
architecture/semantic-store-ownership and its test: that rule read
imports of the facade by name. The known list stays at 2 entries.

activity-view.test.mjs imports dom/move-focus.js, as the page's boot does;
it had the mover's focus accounting only because the widget API's graph
reached the facade. No behaviour change on a page.
@max-sixty
max-sixty merged commit b668fed into main Nov 25, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-a93227a15acdddb29 branch November 25, 2026 08:31
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_
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