Skip to content

Give state readings and revision rules one owner each - #2484

Merged
max-sixty merged 5 commits into
mainfrom
state-readings-one-owner
Oct 12, 2026
Merged

max-sixty merged 5 commits into
mainfrom
state-readings-one-owner

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Workstream #14 of the duplicate-logic sweep. Two readers took browser state back from the rendering, which skills/leaf/assets/AGENTS.md forbids, and several rules were written more than once. Each now has one owner, and every caller uses it.

Behavior changes

  • A thread on a line of a diff file not yet loaded is named by its line. It read "§ diff"; it now reads "§ app.py · new line 1". The datum label is looked up in anchor-resolution.js (datumLabel), the same way resolution finds datums, and a lazy widget names a datum it has not drawn through a new lfDatumLabel(key) hook, which lf-diff implements (module-authoring.md). test_a_manifest_diff_can_comment_on_one_unloaded_file gains that leg, which fails on the base.
  • The page's reading takes retired slots from the publisher, not from paint. passages.js reads each holder's standing outcome from the published widget state instead of reading data-lf-retired back, and forgets the page reading when those outcomes change. A slot painted retired where the log decided nothing keeps its words in the reading, and slots in a holder's shadow root count too (the old selector missed them).
  • Version comparison compares widget state, not the DOM. The base revision's authored values are folded under its projection with foldWidgetStates and compared with the publisher's current widget state. An event admitted under a different declaration of its verb is left out of the base fold rather than throwing. A card the author moved within its column is now marked, the fewest cards whose moves explain the new order (test_the_diff_marks_the_card_the_author_reordered_and_no_other fails on the base's column-only rule).
  • quoted() has one answer. widget-descriptors.js owns it: the descriptor's authored-ancestry reading, which a widget's actions already used, rather than a live closest().
  • A malformed fragment escape keeps its literal characters at first paint, as followed links already did.

One home each, no behavior change

  • "The page shows the active revision" is runtime.showsActive (context.js), replacing !== and > comparisons in version.js, context.js and state-feed.js.
  • Fragment decoding lives in prepaint.js (lfInitial.fragmentId), which initial-render.js exports to modules.
  • The state coordinate key is stateCoordinate/coordinateOf in projection/model.js, used by the publisher and annotation-inventory.js.
  • A local action's meaning reads its widget's captured declaration, as its reading does, rather than the document registry.
  • projectData clears stale datums in the declared shadow roots that resolution reads (shadowRootsIn).

test_a_settled_third_party_holder_wears_the_layers_mark fails on main as well as here.

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

max-sixty and others added 5 commits October 10, 2026 21:25
Readers that took state back from the rendering now read the application
publisher, and rules written twice now have one home.

Behavior changes:

- A thread on a line of a diff file not yet loaded is titled by its line
  ("§ app.py · new line 1") rather than "§ diff". The datum label is
  read where resolution finds datums (`anchor-resolution.js`,
  `datumLabel`), and a lazy widget names a datum it has not drawn
  through a new `lfDatumLabel(key)` hook, which `lf-diff` implements.
  `test_a_manifest_diff_can_comment_on_one_unloaded_file` gains that leg,
  which fails on the base.
- The page's reading takes a retired slot from the publisher's widget
  state rather than reading `data-lf-retired` back, so a slot painted
  retired where the log decided nothing keeps its words in the reading.
  Slots inside a holder's shadow root are covered too; the old selector
  missed them. The page reading is
  forgotten when the settlements change.
- Version comparison folds the base revision's authored values under
  its projection and compares that with the publisher's current widget
  state, instead of reading current state back from the DOM. An event
  admitted under a different declaration of its verb is left out of the
  base fold rather than throwing.
- `quoted()` has one answer, the widget descriptor's authored-ancestry
  reading, which the controller's actions already use;
  `widget-descriptors.js` owns it.
- A malformed fragment escape keeps its literal characters at first
  paint and in `lf-tabs`, as followed links already did.

One home each, no behavior change:

- "The page shows the active revision" is `runtime.showsActive`,
  replacing `!==` and `>` comparisons in version.js, context.js and
  state-feed.js.
- Fragment decoding lives in prepaint.js (`lfInitial.fragmentId`);
  `lf-tabs` finds a fragment's panel through `fragmentTarget`, now on
  widget-api.
- The state coordinate key is `stateCoordinate`/`coordinateOf` in
  projection/model.js, used by the publisher and annotation-inventory.
- A local action's meaning reads its widget's captured declaration, as
  its reading does, rather than the document registry.
- `projectData` clears stale datums in the declared shadow roots
  resolution reads (`shadowRootsIn`).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The state half of a comparison marked a card only when its column changed,
so a card the author moved within a column read as unchanged. It now also
marks the cards outside the longest run that keeps the base order, the
fewest cards whose moving explains the new order.
`test_the_diff_marks_the_card_the_author_reordered_and_no_other` fails on
the container-only rule.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/assets/runtime/anchor-resolution.js
#	skills/leaf/assets/runtime/context.js
#	skills/leaf/assets/runtime/initial-render.js
#	skills/leaf/assets/runtime/thread/messages.js
#	skills/leaf/assets/runtime/version.js
#	skills/leaf/assets/runtime/widget-api.js
#	skills/leaf/assets/runtime/work.js
#	skills/leaf/packages/default/widgets/lf-tabs.js
#	skills/leaf/references/module-authoring.md
@max-sixty
max-sixty merged commit 730fa18 into main Oct 12, 2026
4 checks passed
@max-sixty
max-sixty deleted the state-readings-one-owner branch October 12, 2026 04:42
max-sixty added a commit that referenced this pull request Oct 12, 2026
Main's #2484 folded the browser's exhibit reading into the widget descriptor
(`quoted` in widget-descriptors.js) and counted the exhibit itself as quoted;
the merge keeps that one home and this branch's strict rule, which
`questions.quoted_in` and tests/exhibit_cases.json hold. The version
comparison's state half takes main's publisher-based reading, and the served
projection entries key their coordinate with `stateCoordinate`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 12, 2026
…2550)

The [main CI
run](https://github.com/max-sixty/leaf/actions/runs/38204537786) found
that `test_a_settled_third_party_holder_wears_the_layers_mark` could
restore a retired passage but its thread quote stayed detached. Reading
the unchanged page after the first widget decision appended a permanent
`reanchor` with a null anchor. The later decision restored the passage,
but could not undo that recorded relocation.

`revision_reanchors` now records relocation only when authored source
becomes a new revision. A widget decision within the current revision
may hide or restore the passage; the browser resolves the thread against
that current state without making the temporary detachment durable. This
preserves the intended revision behavior introduced in
[#2484](#2484).

The focused browser test failed before this change and passes afterward.
The existing file-side test for a passage removed by a real revision
also passes (`uv run pytest
tests/test_render_projection.py::test_a_settled_third_party_holder_wears_the_layers_mark
tests/test_interact_anchors.py::test_a_quote_without_a_section_detaches_when_its_words_disappear
-q -n0`).

---------

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