Skip to content

rust-sort's source lights the line its sort film runs - #6008

Merged
max-sixty merged 36 commits into
mainfrom
agent-adf6794758692f5f3
Nov 23, 2026
Merged

max-sixty merged 36 commits into
mainfrom
agent-adf6794758692f5f3

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

What it does. The sort film holds the slice.rs lines its step runs as its playhead output (contract source-lines, declared by the default package). Each lf-code names the film in for and marks those lines. for rather than the experiment's follows, since for is the rule's attribute for reading another widget's output.

What a reader sees. The running line gets an accent bar and number. When it leaves view, the code pane glides it to its middle; the page never moves. A single step elsewhere, such as insert_head's call site, moves nothing. Scrolling or clicking in the pane stops the following; pressing the film resumes it.

Measured on 21 November, the default film at 1440×900, one journey on this branch and on #6690, which lights the same line and follows every one. While the film plays its minute, the pane moves 42 times here against 116, travels about 42,600 px against about 99,000, and shows the lit line 76% of the time against 100%, never out of view for more than 0.7 s. The right line is lit at each of the 451 key steps that run one. Chromium, Firefox and WebKit agree on those counts. A page of 200 code blocks is presented about 750 ms after load here and on main: a median 6 ms slower over 12 paired runs, slower in 7.

Costs. lf-code is a LeafElement on every page. A data widget's <pre> feeds only its value input. scrollIntoView bounded within a box applies block and behavior there. scrollersOf, alreadyShown and onUserInput join portable-api; the block reads the reader's hand in its pane from onUserInput, with no listener of its own.

Instructions scored on 21 November against the base branch, three samples an arm on Claude Code. Asked to make an excerpt show the line a page-owned stepper is on, authors bound for to a declared source-lines output in 3/3 with the new lf-code instructions and 0/3 without, where each reached the excerpt from the stepper's module. The three passing replies run as real pages. The task's three other lf-code contexts passed 8/9 and 9/9; the one failure used no lf-code. The case is source-code-readable/lines-follow-a-widget.

Current with main as of 23 November, through #5981: the block stands on main's reworked lf-code (a language named by a class on <code>, the notes toolbar), main's declaration names (inputs, outputs, refers) and its reworked landing-scroll.js, and its colours use the prefixed tokens.

Asked for by Max, who picked lighting the line on 14 November and asked for this to land with #5981 on 23 November without having read the diff in full. The quieter follower costs 150 lines in lf-code against 73 for #6690's, which follows every line; that call is his to reverse.

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

# Conflicts:
#	browser/runtime/check-api.js
#	src/leaf/structure.py
Each bound reader read one page-wide signal, so every arriving producer made every
reader resolve its name again: producers times readers on load and on a revision.
The signal is now kept per name (an id, or a keyed member's unique attribute), and an
arrival or departure moves only the names the element answers to.
A reader copied and compared every output it reads on each change its producer said,
so a large value held beside one that changes often cost each reader its whole size
per change: 5.8 ms a drag step with 10,000 events beside a selection. A producer holds
a new value to change one, as the shipped text already asked, so the object it held
at the last reading is now taken as unchanged without reading into it (0.05 ms).
A value that cannot be copied names its producer and contract.
A reference typed by a package's role table went earlier on this branch; a plain
reference then accepted any element, so lf-call-diff's diff could name a heading and
its links went nowhere. A reference now says what kind of target it needs in the
vocabulary a reader's input already uses: {contract} names any widget holding a value
of that contract, whatever its tag or package. lf-call-diff declares file-list.
The shipped text says how a module sends a request no button makes, with its element
as the command's source, and how the target refuses one so the asker hears it. A
browser test holds the two-package pair reading the recorded pick in an exported file.
lf-call-diff never reads its target's file-list: it sends the user to patch lines by
keys only lf-diff answers, so a file tree holding a file-list passed the check and
every link would have failed. Every reference that crossed packages in the trials read
a value, which the reader's contract-bound input already types; the field had no other
consumer. A reference names any element again.
Ports experiment 93b7128 onto the output rule: the film holds the slice.rs lines
its step runs as its `playhead` property and says `change`; each lf-code names it in
`for` and reads it through an `x-data` input of the `source-lines` contract, which the
default package declares.

- lf-code becomes a LeafElement, since Leaf hands inputs only to LeafElements; its
  source draw is the update's completion, replacing the pending-task event. It marks
  the rows the playhead addresses (`data-lf-at`) and glides the first to the middle
  of the box scrolling it, never the page. A line the playhead leaves at the next
  value moves nothing unless the playhead returns within two values or rests 500 ms.
  A press, wheel, touch or key inside the box stops the following, and one on the
  followed widget starts it again. Over the film's minute at its default speed the
  pane moves 42 times, where bringing each line in at the nearest edge moved it 179.
- A data body's `<pre>` is now its `value`, as a `<textarea>`'s text is, rather than
  its one input's text: a data widget may take inputs besides `value`, which leave the
  `<pre>` alone (element-data.js, page check, registry check). lf-code could not take
  a playhead otherwise: page check refused its `<pre>` once `for` bound, and Leaf set
  the playhead to the code's text where nothing bound it.
- `scrollIntoView` bounded `within` a box now places the destination there at `block`
  with `behavior`, as a reading region does; every existing caller passes nearest with
  no smooth scrolling, so none moves differently. `scrollersOf` joins portable-api.js,
  and `alreadyShown` moves there from widget-api.js.
- The film's timeline cursor, which held the name `playhead`, is `timeHead`.

Behavior changes: lf-code is a LeafElement on every page; a data widget's `<pre>`
feeds only its `value` input.
…uctions

`leaf page instructions --use <tag>` added a contract's instructions only for
a tag that reads it (x-data), so an agent writing the widget that holds the
value never got what the contract asks of it. It now selects from x-output too.
The fixture pair's audience is `producer`, the name the diff, playwright and
visual-review contracts already use for whoever supplies a value.
…of inputs

Its own document keydown listener failed the register's pin on keydown
listeners, and was a second reading of what document-inputs.js already keeps.
It now observes that reading (onUserInput, which joins portable-api.js since
the clock starts with a plain host's first portable import) and keeps to its
four gestures.
max-sixty added a commit that referenced this pull request Nov 18, 2026
…ree opens, and keep a reveal inside a workspace from moving the page (#6019)

Adds `examples/deploy-config.html`, "Finish a worker's production
config", to the catalog. A file tree lists a service's six deploy files,
picking one opens it in the file editor, and each saves to disk as the
reader types. Max asked for an example that features the file editor and
suggested combining it with the file tree's; until now both packages
appeared only on developer pages. He then used it and reported two
defects, both fixed here, and approved two follow-ups, both built here.

What changes for a user and an author:

- `lf-file-editor` takes several bindings (`binding="a b c"`) and
publishes a `files` output on the `file-list` contract, so
`<lf-file-tree for="editor">` follows it with no change to the tree.
Switching files keeps each file's caret, undo history and scroll. A link
opens a file, and can name a line: `#dc-editor:alerts:22` puts the caret
there.
- YAML is highlighted, through CodeMirror's `@codemirror/lang-yaml`
built in Leaf's pipeline, in the theme's code colors. Its module is
39,619 bytes (14,368 gzipped) and loads only when a YAML file opens; the
CodeMirror core grows by 7,599 bytes.
- A write from outside to other lines merges into an unsaved edit (a
line-level three-way merge; adjacent lines conflict, as in git). The
lines it changed are marked until the next such write or until the
reader edits them, and a rule marks the gap where it took lines away.
Every version written elsewhere starts the file's undo history afresh,
so Undo never replays earlier keystrokes onto text they were not typed
into.
- `leaf page state` lists a page's bound files under `files`, the name
the browser's state uses, with each one's label and path.
- An example can carry its files: a `<stem>.files/` companion and
`<stem>.files.json`, which `prepare_page` copies into the page directory
and binds. A file inside the page directory is granted by its path
relative to the page, so on leaf.page a visitor gets their own copy to
edit.
- **A reveal inside a held workspace no longer moves the page**
(`browser/runtime/landing-scroll.js`). Every region of such a workspace
runs to the window's foot and keeps room there for the floating panel,
so a landing measured it as taller than the visible band and scrolled
the page to bring its top up. Max's click on a file moved his page 49
px. It showed only where something after `main` gave the document room
to scroll, which is why no test had caught it. A landing now takes off
such a region only the room the region itself reserved (`--lf-end-room`
plus the root's landing room), never more than the panel's current band,
so content under an expanded panel is still brought clear. Picking a
file, a link to a file, and a link to a pane each moved the page 31 to
49 px before and move it 0 now.

To weigh:

- The landing fix is in the runtime, in a file draft #6008 also changes
(a separate hunk). A plain fragment link to a pane-filling element
(`#dc-editor`, a tab set's panel) still moves the page about 20 to 40 px
where the document has room: that route copies the browser's own
fragment rule in `anchor-travel.js`, which #6010 is changing, so it is
left with a recommendation to ask "already shown?" there too.
- `files.json` takes the page protocol's number as its format, now 50.
Grants written before read as absent, so those files need binding again.
- CodeMirror's YAML grammar doesn't tell numbers and booleans from other
values, so they take the string color, where code blocks color them
apart.
- Two of the site's rules stop the example short of a local page, and
both are left for Max: a visitor's edits last only while their container
runs, and every visit starts a container because the editor's first read
goes to it (3.3 to 7.5 s cold). The site path was checked on one machine
and not deployed.
- After an outside version merges into an unsaved draft, Undo no longer
reaches the keystrokes made before the merge. That is the cost of the
undo fix.
- Where one change both rewrites and removes lines, only the rewritten
line is marked and the gap gets no rule.
- It is a large change for one example: 54 files, +2,173 −342, reaching
the file routes, served state, the landing rule, the site build and both
packages.

Reviews: the building agent's own found six defects in the first version
and fixed them or listed them; Codex looked hardest at the relative-path
grant, the file routes and the merge, and found no way to read or write
outside what was bound and two performance defects, both fixed. A second
Codex review of the later commits found three defects, two of them also
reported by the review bot, and all three are fixed with a failing test
first: stale undo history after a write to a file the reader had left,
which could garble its text; the landing change discounting the panel's
whole band; and a mark on the unchanged line after an inserted one.

Checked with `pnpm run check`, the file-binding model tests, the twelve
files browser tests and the file-editor journey test by node id, the
nearby landing tests, `page check --render`, and `pre-commit`. Two new
tests fail on `main`'s runtime: a link to a held workspace's region, and
picking a file, each with room given to the document. A third holds the
other direction: a file picked under an open panel is brought clear of
it. The broad suite is left to CI.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent added a commit that referenced this pull request Nov 18, 2026
…re-exports of them (#6366)

`browser/runtime/shadow.js` re-exported sixteen helpers that
`browser/runtime/shadow-tree.js` owns (`under`, `upFrom`,
`renderedUnder`, `renderedOrder`, `renderedOrdering`, `byRenderedOrder`,
`hostIn`, `composedParentNode`, `renderedParent`, `shadowHost`,
`excludedByInert`, `overIn`, `SAID`, `UI_MARKS`, `uiInside`, `inUi`).
This PR deletes those re-exports and points every import of them in
`browser/` and `tests/runtime/` at `shadow-tree.js`, including
`widget-api.js`'s public `under`. Now `shadow.js` keeps only its own
exports.

Why: `browser/AGENTS.md` ("One answer for each question") names
`shadow-tree.js` as the owner of these helpers, but callers were split
between the two import paths (for example, 23 imported `under` through
`shadow.js` and 7 imported it directly). Importing through `shadow.js`
also pulled `registry.js` and `arrivals.js` into modules that need
neither. No package imports `shadow.js`.

Verification: `pnpm run check` passes; it includes `test:runtime`,
1050/1050 on the head merged with current `main`. Pre-commit passes on
the changed files, including eslint, prettier, dependency-cruiser and
knip (unused exports and import cycles). A grep finds no import from
`shadow.js` that names a shadow-tree helper. Behavior is unchanged, so
no new test.

Open PRs #6008, #5981 and #5979 touch some of these files; each overlap
is a one-line import change.

---------

Co-authored-by: leaf-agent <[email protected]>
Co-authored-by: leaf-agent <[email protected]>
Main renamed every registry key (`x-data` to `inputs`, `x-output` to
`outputs`, `x-refers` to `refers`, a tag's attributes under `attributes`),
moved Lit's names to /vendor/lit.js, declared per finding whether it refuses,
and yielded message checks stage by stage. The composition rule is carried
onto that format:

- `refers` maps an attribute to `{}` and nothing else. Main had already
  dropped the keyed `{tag, key}` relation, so with `via`, `where` and `owns`
  gone the reference schema is the empty object, and the reader's keyed
  standing signal in data.js goes with it.
- An input reads the one output of its contract (`reference`, no `output`),
  and an output is a property of its element named by `outputs`.
- packages/file-editor, new on main, called `publishOutput`; it now holds its
  `files` and says `change`, as lf-diff does.
- `shows-reference` holds only that the attribute is one `refers` declares,
  since a reference has one shape.
- The work-role check reads `attributes` and `verbs`; its finding words name
  them. The command-hub test composes the example as a layer, since a verb now
  needs its module.
- module-input.md keeps main's text: it stands 13 characters under the
  30,000-character cap, so the pointer to invoker commands this branch added
  there is dropped; package-data.md, which owns the topic, keeps it.
- The typed-reference advice and its two tests, new on main, are removed with
  the relation they advised on.
The lit line is carried onto main's declaration format and main's reworked
code block:

- lf-code declares `inputs.playhead` and `refers.for`; the film declares
  `outputs.playhead`. The `<pre>` rule reads `inputs` and `content`.
- Main names a block's language by `<code class="language-…">` inside the
  `<pre>` and gave lf-code a notes toolbar; both stand with the block as a
  LeafElement, and rust-sort's three excerpts keep `for="sort-film"`.
- The lit line's colours use main's prefixed tokens (`--lf-accent`,
  `--lf-accent-tint`).
- module-input.md keeps main's text, 13 characters under the size cap;
  that `onUserInput` loads off Leaf is said in module-scroll-and-motion.md,
  beside the other helpers lf-code follows a playhead with.
The review bot found the sentence still naming only `inputs`, against
package-data.md and `instruction_selection`.
Six authors writing package pairs from the references found no route:
`package check` reads one package, and `page init` refuses a page inside one.
A page outside both that selects them by path takes the pair, and its render
check draws it; run on the two fixture packages.

@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.

lf-code's header and the REST comment record the measurements that tuned the following rules: 179 → 42 pane moves, rust-sort's 225 ms and 450 ms step lengths, and what the pane did before the rule. Root AGENTS.md, "Where instructions live", sends the measurements that settled a change to its commit message, where the PR body already carries them. Tied to one example page's numbers, a default-package widget's contract reads as if it were tuned only for that page. The suggestions below keep each rule and its reason. The "Rejected:" clause can stay, since a header may name an alternative a later change might reach for and say why it fails.

Comment thread packages/default/widgets/lf-code.js Resolved
Comment thread packages/default/widgets/lf-code.js Resolved
Comment thread packages/default/widgets/lf-code.js Resolved
…ents here

The review bot's finding: the header tied a default-package widget's rules to
one example's numbers. Brought in at the nearest edge at each line, rust-sort's
film moved its source pane 179 times in the minute its 453 steps play at the
default speed, and the three rules bring that to 42. A one-step visit lasts
225 ms at the film's default speed and 450 ms at 1x, which REST (500 ms)
outlasts; followed, each such visit took the pane away and straight back.
lf-code's instructions gained the `for` input on this branch, so
`source-code-readable/lines-follow-a-widget` asks an author to make an
excerpt show the line a page-owned stepper is on.

Scored on 21 November against `fable-composition`, three samples an arm on
Claude Code: 3/3 with the new instructions, 0/3 without. Every base author
gave the stepper a `for` naming the excerpt and reached it from the
stepper's module. The three other lf-code contexts of the task
(`source-code-readable`, `tool-output-json`, `markdown-syntax`) passed 8/9
on head and 9/9 on base; the one head failure filled values the report had
elided and used no lf-code. All 24 authors ran `leaf page instructions --use
lf-code`, and none of the 18 ordinary code blocks gained a `for`.

The three passing replies were installed as real pages: `page check` and
one `page check --render` exit 0, and stepping each in Chromium marks the
lines the stepper holds at every step.
# Conflicts:
#	browser/registry.json
#	browser/types/contract.d.ts
#	skills/leaf/references/package-data.md
#	src/leaf/findings.py
#	src/leaf/registry/widgets.py
#	src/leaf/validation/instances.py
#	tests/model/interact_contract/test_registry_door.py
# Conflicts:
#	browser/runtime/landing-scroll.js
@max-sixty
max-sixty marked this pull request as ready for review November 23, 2026 18:04
leaf-agent
leaf-agent previously approved these changes Nov 23, 2026
Base automatically changed from fable-composition to main November 23, 2026 18:17
@max-sixty
max-sixty dismissed leaf-agent’s stale review November 23, 2026 18:17

The base branch was changed.

# Conflicts:
#	browser/registry.json
#	browser/types/contract.d.ts
#	tests/model/test_interact_layer.py
@max-sixty
max-sixty merged commit 92a860b into main Nov 23, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-adf6794758692f5f3 branch November 23, 2026 18:32
max-sixty added a commit that referenced this pull request Nov 23, 2026
max-sixty added a commit that referenced this pull request Nov 23, 2026
…der's hand in the pane

A second trial for the same decision, on top of the first. The first swap
(191b58a) followed every line and stopped only once the reader had
scrolled the pane and the mark was out of their view. A journey of the
reader's hand (`.tmp/trial/hands.py`) showed what that takes: with the film
playing, a reader who wheeled the pane to its top had it taken back 429 ms
later, and one who clicked a line or pressed a key in it was followed on, 21
and 17 moves in the seconds after.

This variant keeps the first swap's placement: when the first marked line
stands outside 15% to 70% of the box that scrolls it, the block sets the
box's scroll at once so the line stands a third of the way down. It takes
#6008's rule for the reader's hand back in place of the first swap's own: a
press, wheel, touch or key inside the box stops the following there, and the
reader's hand on the widget `for` names starts it again. The header's
record of the rejected alternative, following again once a marked line came
into the reader's view, returns with it. The 500 ms rest, the glide and the
`block`/`behavior` handling for a `within` box in landing-scroll.js stay out.

The hand is read through `onUserInput` rather than listeners of the widget's
own. The boxes whose input matters are an ancestor pane and another widget's
element, neither of which lf-code owns, and three excerpts share one pane, so
listeners of its own would be capture listeners on other owners' elements,
kept per box and removed at disconnect. `onUserInput` is the document's one
reading of the reader's inputs (module-input.md names it for a surface that
must stop moving at a gesture). It hears each input on the window in
capture, before a handler in the page can stop the event, and on a plain
page too. It replaces the first swap's comparison of `scrollTop` with where
the block last put it, which read any other scroll of the box as the
reader's. So `onUserInput` stays a portable-api.js export, as on main, and
the widget's `followed` record goes.

Against main the core runtime differs by `alreadyShown` standing in
widget-api.js rather than portable-api.js, since only the resting follower
read it from a portable widget, and by landing-scroll.js without the
`within` placement (+8 -11).

The test keeps every assertion main's has, the press on the film that
brings the pane back included; its docstring and one comment say "into view
with room round it" where they said "to its middle".
max-sixty added a commit that referenced this pull request Nov 24, 2026
…current API

Main's follower is still the resting one #6008 landed; it moved its imports to
the library and landing-scroll.js gained a glide's aim (#6904). Three files
conflicted, each resolved to main's text with this branch's change made again:

- packages/default/widgets/lf-code.js: main's imports, with `alreadyShown` and
  `scrollIntoView` dropped. `setScroll` left the package API (#6951), so the
  follower writes the pane's scroll with the browser's own `scrollTo`, asking
  `scrollMoves` (lib/scroll-range.js) first, as module-scroll-and-motion.md
  asks of a writer that may name the position its box holds. A line out of the
  band at an end of the pane is such a write.
- browser/runtime/landing-scroll.js: `innerMoves` loses its `block` again and a
  `within` box lands at once, nearest. The glide's aim (`landingAim`) and the
  boxes a landing steers ask `innerMoves` without it.
- browser/runtime/widget-api.js: main's exports, plus `alreadyShown`, which
  portable-api.js no longer exports and lf-trace reads.

skills/leaf/references/module-scroll-and-motion.md merged clean and named
`setScroll`; it names `scrollTo` now.
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