Skip to content

Keep the publication's records and the memos written by hand as kept readings, and drop keptReadings - #6423

Merged
max-sixty merged 5 commits into
mainfrom
kept-fold
Nov 18, 2026
Merged

max-sixty merged 5 commits into
mainfrom
kept-fold

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The second of the pull requests that bring Leaf's derived data onto one keeping primitive, which max-sixty asked for. It moves the publication fold and the memos written by hand onto kept/keptEach from #6413, and deletes keptReadings, the reader that kept each record beside an input list written by hand.

Each thread, message, reaction, widget, obligation and queue row is now kept by the served record it is made from and the arguments it is given; each step and index of the fold by its arguments; and the whole fold by the seven values it reads, so a publication of a widget's output or new data folds nothing. A make sits at module scope and reads only its arguments, so a record can't read more than it is kept by: the message reading that read messageBodies without listing it now takes its body as an argument. The memos keyed by a list, and the vocabulary's readings, are kept readings too.

To weigh:

  • Adoption captures message bodies by thread, and keeps a thread's together while its messages' read the same, so the fold's per-thread arguments stay one value each.
  • Admitted projection entries are kept by the served entry, so a widget's fold compares the entries in force by identity; a new wrapper around the same parts now counts as a change (the board test passes the same entry again).
  • A message's workflows are read from its thread's workflows, which the code already relied on holding every message's.
  • The page's version now moves where its reading changes rather than being compared on every catch-up.

How it works replaces State → Shared readings with Derived data.

Cost, on leaf-dev bench --base (Chromium, lowest of 3 rounds): on the threads page at 512 threads a click takes 32.0 ms of main thread against 34.5 and a reply 53.5 against 58.9; a keystroke and a wheel step measure as on main. On the asks page a click, keystroke, m press, wheel step and reply measure as on main within round-to-round noise.

Tests: pnpm run test:runtime (1,044 pass), pnpm run check:browser, tests/model/test_product_page.py.

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

…y one moved

A fact no signal carries, such as the page's reading, the threads' placement, a
widget's layout, a visual's parts or a stored choice, now has a `version` its owner
moves, in place of a function each reading asked again on every read (`reads`). A
version whose owner moves it only as it catches up, as the page's watcher and
placement do, names its catch-up, which a reading runs as it first reads the version
and before it is checked. Every move of any version moves one count, so a reading
checked since the last move stands without asking anything.

`keptEach` keeps each key's reading on its own, so a version one key read makes
that key again and no other: the assertion that an input any item read makes all
again now asserts the opposite. A reading takes arguments, compared by identity and
two lists by their items, and is read as `read(key, ...args)` rather than
`read()(key)`. A reading around a make that threw is made again, as before.

Outside any reading, `elementById` no longer catches the page's reading up, since
it reads the document directly.
…ptReadings

The fold's records and steps are now kept readings (`kept.js`): each thread,
message, reaction, widget, obligation and queue row by the served record it is made
from and the arguments it is given, each step and index by its arguments, and the
whole fold by the seven it reads, so a publication that moves none of them, such as
a widget's output or new data, folds nothing. A make sits at module scope and reads
only its arguments, so no input list is written by hand: `keptReadings`, `BETWEEN`,
`done()` and the readings a thread handed its next reading are gone.

Adoption captures message bodies by thread, each thread's kept while its messages'
read the same, and a message's plain words are kept while they read the same, so a
thread's record stands while its messages do. Admitted projection entries, and a
pending undo with its target's id, are kept by what they are made from, so a
widget's fold can tell the entries in force on it unchanged by identity: the board
test now passes the same entry again, where a new wrapper around the same parts
counted as unchanged before. A thread's messages read the workflows serving them
from the thread's own workflows, which hold every message's.

How it works replaces State → Shared readings with Derived data: the sources, how a
change is heard, kept readings, the server's kept readings and the views, and
Drawing current state points to it.
…version where it changes

The memos keyed by a list (each obligation context's ids, the widgets that ask, the
names an obligation's place goes by, a walk list's obligation stops) are `keptEach`
readers, and a reading of the vocabulary (`perVocabulary`, the state index) is a
`kept` reading of the vocabulary's version, which moves when a reader finds the
layer's generation changed and on every reading before the vocabulary loads, as
nothing was kept of it then before.

The page's version moves where its reading changes: as the page's reading is
forgotten, as an id or a part's name changes, and as the vocabulary or a settlement
resets the reading, rather than being compared on every catch-up, which every
reader of the page runs. A read of a kept reading reuses one list of the catch-ups
it has run rather than making one.
# Conflicts:
#	browser/runtime/anchor-placement.js
#	browser/runtime/kept.js
#	browser/runtime/passages.js
leaf-agent
leaf-agent previously approved these changes Nov 18, 2026
# Conflicts:
#	browser/runtime/state-application.js
@max-sixty
max-sixty merged commit 824db10 into main Nov 18, 2026
5 checks passed
@max-sixty
max-sixty deleted the kept-fold branch November 18, 2026 22:43
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