Skip to content

Stamp verb writers and definitions into $states, and give passage constants one home - #2482

Merged
max-sixty merged 10 commits into
mainfrom
cq-browser-rederived-facts
Oct 12, 2026
Merged

max-sixty merged 10 commits into
mainfrom
cq-browser-rederived-facts

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Three facts the browser kept a second copy of now have one home each: a widget verb's writer and admitted operation definition, the passage constants, and (checked, left as is) the message and widget kinds.

Verb definitions and writers (F2)

The browser built each verb's operation definition itself (stateDefinition, semanticSchema, detailSchema) and defaulted each verb's writer at intake, both copies of Python rules held equal by parity fixtures. Composition now stamps $states (tag → verb → {writer, definition}) from verb_writer and state_definition (registry.contract.stamp_states, called from stamp_composition), and the browser reads it. The JS derivation, eventSpec, adoptRegistry's writer default and tests/verb_writer_cases.json are deleted. The browser's comparison (sameStateDefinition, sameStateOperation) is held to Python's verdicts on definitions Python records, served by tests/served_records.py.

The survey's other option was to delete the browser's filter of served entries instead. A browser run settled it. On the shown revision the filter drops nothing, because each revision serves its own registry. In a pinned earlier revision, though, the thread widgets are captured under that revision's registry while the server classifies thread decisions under the active revision's. When a later revision added a verb a thread decision used, the pinned page threw Missing authored state without the filter. So the filter stays, now comparing against the stamped definition. Node tests cover the left-out entry and the painter reading that threw.

A pending undo of a gesture the log has since admitted now draws while the server's reading still classifies the admitted action. Before, it was judged by the pending gesture's recorded definition, so a revision that only broadened the payload domain showed the decision again mid-undo.

Passage constants (F3)

The collapse characters, text-block tags and an anchor's initial context were written in Python and in runtime modules, with three regex tests parsing the JavaScript to hold them equal. registry.json declares them under $passages. Python reads them through registry/kernel.kernel_passages, and build/registry.mjs generates runtime/passage-facts.js, so check:bundles catches a stale copy. collapse.js and the regex tests are deleted. Values are unchanged. Anchor context in anchor_capture.py is now trimmed of the space alone, since Python's str.strip() also dropped characters such as U+0085 that the browser keeps, and a browser anchor whose context began with one never resolved.

Message and widget kinds (F7)

Left as is. The browser spells comment/reply in one predicate (pending/model.js) and in TypeScript type unions. Deriving them from a $events flag would need a Python reader, a generated runtime set and generated TS unions, which is more code than the four spellings it replaces, for kernel kinds no layer can change.

Compatibility

No $events.protocol bump. A page vendored at this protocol by an earlier Leaf runs its own runtime, which ignores $states, and Python reads $passages from the running Leaf with unchanged values. $passages' description says changing it is a bump.

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

max-sixty and others added 8 commits October 11, 2026 20:27
The browser filtered every served projection entry a second time, through
its own copy of the operation-identity rule (`sameStateOperation`) against the
shown document's descriptors. The server already classifies each entry under
the registry that read it (`served_state/wire.py`), so the copy had to change
in lockstep with Python's `same_state_operation`, as #2431 did.

A browser run settled what the second filter does. Each revision serves its
own registry, so on the shown revision's page entries it dropped nothing. In a
pinned earlier revision whose page declaration changed a verb's operation, it
dropped a thread decision the server holds standing (the thread is classified
under the active revision's registry), and the decided thread widget drew as
undecided. That widget now shows the decision the server serves.

Behavior changes:
- Normalizing a served view no longer filters entries; `sameStateOperation`
  and its test are deleted, and the tolerance for fields an earlier Leaf
  recorded lives only in Python.
- A pending action draws while the shown declaration defines the operation
  this tab recorded (JS against JS, full equality). A pending undo of a logged
  decision draws while the server's reading still classifies its target,
  replacing a comparison of a Python-written definition with a JS one.
- `eventSpec` drops its dead `?? "user"`: `adoptRegistry` resolves every
  verb's writer at intake. Fixtures now carry the writer a descriptor holds,
  including the shared gesture sequence's declaration.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The collapse characters, the text-block tags and an anchor's initial context
were each written twice, in Python and in a runtime module, and three tests
parsed the JavaScript with regexes to hold the copies equal.

registry.json now declares them under `$passages`. Python reads them through
the kernel loader (`registry/kernel.kernel_passages`), and build/registry.mjs
generates `runtime/passage-facts.js` from the same entry, so `check:bundles`
fails on a stale copy. The values are unchanged, and the module stays
synchronous for prepaint and the pure folds.

collapse.js is deleted, and its importers, the TEXT_BLOCK consumers and
anchor-resolution's CONTEXT read passage-facts.js. The three regex tests and
their parsing helpers are deleted.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The previous commit deleted the browser's filter of served entries. A
second browser run showed it is load-bearing. In a pinned earlier revision,
the page's thread widgets are captured under that revision's registry, while
the server classifies thread decisions under the active revision's. When a
later revision added a verb that a thread decision used, the pinned page
threw "Missing authored state" painting the projection. So the filter stays,
and what goes is the browser's own derivation of what it compares.

Composition now stamps `$states` (tag → verb → writer, admitted definition)
from `verb_writer` and `state_definition` (`registry.contract.stamp_states`).
The browser reads it:
- the filter compares an entry's recorded operation with the stamped
  definition (`sameStateOperation`, restored, holding #2431's tolerance);
- a pending action records the stamped definition and draws while it equals
  the shown one;
- a widget's user verbs and an event's writer come from `$states`.
JS `stateDefinition`, `semanticSchema`, `detailSchema`, `eventSpec` and
`adoptRegistry`'s writer default are deleted, with `verb_writer_cases.json`.
The browser's comparison is held to Python's verdicts on definitions Python
records (`served_records.state_definitions`).

A pending undo of a gesture the log has since admitted now draws while the
server's reading still classifies the admitted action, rather than by the
pending gesture's recorded definition, so a revision that only broadens the
payload domain no longer shows the decision again mid-undo.

The quotation sweep in test_render_anchors reads TEXT_BLOCK from
passage-facts.js, where it now lives.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The file's anchor context was trimmed with Python's str.strip(), which also
removes characters such as U+0085 that the browser keeps as words. A
browser-captured anchor whose context began with one never resolved in
`leaf thread open`. The text is already collapsed, so the context now trims
only the space, as the browser's reading does.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/scripts/leaf/registry/kernel.py
#	skills/leaf/scripts/leaf/registry/layer.py
# Conflicts:
#	skills/leaf/assets/runtime/widget-upgrade.js
#	tests/test_interact_document.py
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
# Conflicts:
#	build/browser/application.ts
#	skills/leaf/assets/runtime/passages.js
#	skills/leaf/assets/runtime/version.js
#	skills/leaf/assets/vendor/browser-runtime/application.js
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
# Conflicts:
#	skills/leaf/scripts/leaf/registry/kernel.py
@max-sixty
max-sixty merged commit 225e7ef into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the cq-browser-rederived-facts branch October 12, 2026 05:11
max-sixty added a commit that referenced this pull request Oct 12, 2026
Main's #2482 stamps each verb's writer and admitted definition into the
registry's `$states`, which the browser already holds. That is now the one
home: the per-view and thread `state_definitions` this branch served are
deleted, and the browser's pending-action and projection checks read the
stamped definition, keeping main's filter for a pinned revision's thread
entries. Served projection values stay as served (attribute records are
already sorted lists in both runtimes).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 12, 2026
…d overlay (#2480)

The browser used to work out several readings again from the served
state, each a second copy of a Python rule (the duplicate-logic sweep,
workstream #7). This PR moves those readings to Python. The browser now
draws what the server sends and adds only its own unsent updates on top.

Three of the copies were already wrong in ways a user could see:

- **T1, a stalled task:** a task whose start had gone quiet still drew a
live line in the Questions panel. Now `activity._canonical_tasks` clears
`running` once the start goes quiet, and queue items carry a served
`live` flag.
- **T4, held news:** accepting an `lf-suggestion` that resolves a thread
left that thread's news held. Held news now files each update under the
threads the log files it in (`thread_memberships`) from the reading that
logs it, which is the reading that resolves the thread. Before that, an
update concerns only the thread it stands in, so the browser no longer
restates which actions answer. `thread_memberships` also stops filing a
later action under a thread whose earlier answer at that widget was
undone or retracted by a newer version.
- **P1, Question names:** a heading containing an `lf-gloss` was named
with its tip text in some places. Both runtimes now name an element from
the author's own text (`gesture_words.element_name`, and
`addressableName` reading `wrote`).

### What the server now serves

- **Work queues:** `served_state/queues.py` builds the On you, On agent
and Done lists for each view, and `page state` prints the same lists.
`localQueues` in `application.ts` places the tab's unsent Done,
approval, undo, reply and refused-send updates against them. The browser
no longer selects queue items itself: `selectQueues` and `selectDone`
are deleted.
- **Smaller readings:** `approval_blocking`, `at_work` on each workflow,
`awaiting` on activity, and `content_version` on each message. Verb
definitions come from the registry's `$states`, which main's #2482
stamps.
- **Attribute values:** an attribute record's value is a sorted list in
both runtimes.
- **Exhibits:** a widget counts as quoted only strictly inside an
`x-exhibit`, in both runtimes; main had counted the exhibit itself in
the browser.

### Copies kept on purpose

Each one that stays has a case file that both runtimes run:

- `tests/name_cases.json` for element names. The browser names live
elements the server never parses.
- `tests/exhibit_cases.json` for exhibit containment.

### Contract changes

- `/api/state` gains the fields above.
- Queue items gain `live`.
- A task's `running` is null once its start goes quiet.
- `server_rows` activity needs `awaiting`, so a row written by an older
Leaf reads as absent.

### Testing

The T1, T4 and P1 tests each fail with their fix reverted. Most new
tests adopt states the server builds (`tests/served_records.py`) rather
than hand-built ones.

> _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 12, 2026
…wser's re-filter (#2623)

The server read every view's frozen threads under the active revision's
registry. A view pinned to an earlier revision therefore received thread
decisions its own widgets could not draw, and the browser filtered them
out again with a JavaScript copy of `same_state_operation` (kept for
that reason in #2482). Each view now carries its own thread reading, and
the filter and its copy are gone.

## Server

`WorkReading.viewing(page)` reads the log beside another revision's
document and registry, sharing the task log and the published page's
containment, so the threads themselves fold as before. `browser_state`
takes each view's reading from it: the thread projection, the asks, each
thread's `attention` and `after`, the view's queues and
`approval_blocking`, and its undo offers all derive from that one
reading. The active view reads exactly what it read before.

Wire shape: `browser.thread` becomes `browser.views[revision].thread`
(`threads`, `projection`, `asks`). `approval_history` moves to
`browser.approval_history`, since it reads no registry. `page state`
reads the active view's thread.

The page protocol moves to 3. A page vendored at protocol 2 runs a
runtime that reads `browser.thread`, so the server now refuses that page
and names `leaf page init` to re-vendor it (`layer-registry.md`, "Page
protocol"). `build/browser/protocol-contract.d.ts` restarts at 3.

## Browser

`normalizedProjection`, `normalizedQuestions`, `foldThreads`' input,
`projectView`, semantic news and frozen-message preparation read the
view's `thread`. `sameStateOperation` and its Node test are deleted.
Python's `same_state_operation` keeps the earlier-Leaf case, which
`test_interact_document.py` holds. The Node test of the left-out entry
also goes, since no entry can arrive that the view's registry does not
classify.

## Behaviour

On a pinned earlier revision, a frozen ask whose answer that revision's
registry defines differently now shows open, with its thread the user's
turn. Before, it showed answered while the decision itself was silently
missing. The active revision is unchanged.

## Tests

-
`test_questions.py::test_a_pinned_view_reads_its_frozen_threads_under_its_own_registry`
serves both views of a log whose frozen widget's verb changed operation
between registries. It checks each view's thread projection, ask status,
attention and queue. When `viewing` is made to return the active
reading, the test fails.
- `pnpm run check` passes, including `test:runtime` and the bundle
comparison.
- The touched model and process tests pass.
- Python tests that read the old shape use
`interact_support.served_thread`, which takes the only served view's
thread.

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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