Skip to content

Read markHere by name, not out of whichever module holds it today - #55

Closed
leaf-agent wants to merge 1 commit into
mainfrom
fix/read-markhere-by-name
Closed

leaf-agent wants to merge 1 commit into
mainfrom
fix/read-markhere-by-name

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

Problem

test_the_ancestor_exclusions_ask_for_a_marker_and_not_a_tag reads markHere out of a spelled path. 3b9ea44 repointed it at runtime/asks/view.js after the ask split moved the function there. That is the second path it has been pinned to and the second time a split reddened ci at this assertion — the function came out of leaf.js in 9664448, and changed no behaviour either time.

The test asks whether markHere still writes PAGE_PAINT_ATTRIBUTE.ask, because the theme's :not(:where([data-lf-ask]) *) exclusions answer for a mark nothing would otherwise leave on the page. Which module holds the writer is a separate fact, about the runtime's own composition. A path spelled here asserts both, so the reading breaks for the one thing it does not mean to hold still — and main is mid-way through a series of these splits (Split navigation runtime, Split ask model and view runtimes, Split version comparison runtime, Split presence and banner runtimes, Split selection comment runtime, all within the last few days).

Solution

_runtime_function(name) in interact_support.py walks leaf.js and runtime/**/*.js, requires exactly one module to define the name, and returns that function's source.

The bound is the other half, and it makes the reading stricter than the one it replaces. function markHere\(\)(?:.|\n)*?PAGE_PAINT_ATTRIBUTE\.ask has no end, so any later writer in the same file can answer for markHere. The walk stops at the closing brace standing at the declaration's own indentation — which prettier guarantees, and which a brace count over strings, comments, and ${} holes does not.

The walk reads a function declaration and no other form. runtime/asks/view.js already mixes both — readingBlock sits three lines under markHere as a const … = () => — so the failure message names what was actually looked for, which keeps that red self-diagnosing rather than sending the reader after a writer that left the layer.

Testing

uv run pytest tests -q — 585 passed, 6 skipped; the one error is this sandbox having no Chromium (test_smoke.py browser gate), unrelated to a file-side change. ruff check and ruff format --check pass. This touches no runtime, theme, or registry source, so the nightly test_render_* modules are unaffected.

Bug-backs, each reverted after
  • markHere moved to a sibling module. Relocated the function into runtime/asks/model.js. The new reading passes; the pinned regex returns no match on view.js — this is exactly the red the change removes, and the one that has now hit ci twice.
  • The paint leaves markHere, a later writer in the same file keeps it. Rewrote the body to PAGE_PAINT_ATTRIBUTE.exhibit and appended a decoyPaint writing PAGE_PAINT_ATTRIBUTE.ask after it. The new reading fails; the unbounded regex still matches, which is the vacuity the bound closes.
  • Two definitions. Added a second function markHere() to runtime/asks/model.js — fails with the runtime defines markHere() 2 times, rather than reporting on whichever file the walk reached first.
  • Rewritten into arrow form. const markHere = ( fails with none is no \function` declaration of that name under leaf.js or runtime/ — it left the layer, or it was rewritten into a form this walk does not read`.

Supersedes #51, which was opened against the red on run 33003757211 and closed once 3b9ea44 fixed that particular red. The premise it was closed on is right — ci is green — but the coupling that produced the red twice is still there, so this carries the path-independent reading onto main on its own.

3b9ea44 pointed the ask-marker assertion at runtime/asks/view.js after the split
moved markHere there. That is the second path this reading has been pinned to and
the second time a split reddened `ci` at it — the function came out of leaf.js in
9664448 and changed no behaviour either time. Which module holds a writer is a
fact about the runtime's own composition, and the test is asking whether markHere
still writes PAGE_PAINT_ATTRIBUTE.ask, because the theme's exclusions answer for a
mark nothing would otherwise leave on the page. Pinning the path asserts both, so
the reading breaks for the one thing it does not mean to hold still, and main is
mid-way through a series of these splits.

`_runtime_function(name)` walks leaf.js and runtime/**/*.js, requires exactly one
module to define the name, and returns that function's source. The bound is the
other half: the regex it replaces had no end, so any later writer in the same file
could answer for markHere. The walk stops at the closing brace standing at the
declaration's own indentation, which prettier guarantees and a brace count over
strings, comments, and template holes does not.

Bug-backs, each reverted after: markHere moved to runtime/asks/model.js — the new
reading passes where the pinned regex fails, which is the red this removes; the
paint moved out of markHere with a later writer in the same file keeping it — the
new reading fails where the unbounded regex still matches; a second definition —
reported as such rather than answered by whichever file the walk reached first.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Superseded — main landed both halves of this itself, minutes before this branch was pushed.

d07de1e ("A box that scrolls contains what it scrolls") carries the repair in its own message: the reading now walks whichever runtime file defines markHere rather than a spelled path, and bounds the body with _balanced from the brace that opens the function — "the old function markHere\(\)(?:.|\n)*? ran past the closing brace, so a writer elsewhere in the file answered for a line markHere no longer had." Both faults were planted and both are red there. That is the path independence and the bound this PR argued for, so there is no delta left worth re-proposing; mergeable is CONFLICTING in exactly that hunk, as it was for #51.

The run that dispatched me, 33007893779 on 8ba3077 ("Split presence and banner runtimes"), is one of the two reds predicted on #51 — a stale commit, now two behind main, failing for the coupling d07de1e removed. No fix PR for it.

Verified at main's head (d07de1e): uv run pytest tests/test_interact_document.py -q -n0 -k ancestor_exclusions is 1 passed.

Closing without deleting the branch, the way #51 was left, in case the _runtime_function helper is wanted by name later. The one thing it still holds over main's inline version is the bound mechanism — indentation of the closing brace rather than a brace count over strings, comments, and ${} holes — which is a separate question about _balanced, not about this assertion.

@leaf-agent leaf-agent closed this Aug 26, 2026
max-sixty added a commit that referenced this pull request Oct 12, 2026
…jection paint is reported once (#2552)

A widget fed by `watchQuestions`, `watchReports`, `watchHistory` or
`watchThreads` no longer reads its projection again each time it returns
to the page. Before this change, a paint that failed was reported once
more on every return. #2531 had already fixed this for `watchData`,
using its own copy of the rule. Both watchers now use one helper. This
is item #55 of the Lit survey follow-up review, numbered in that review
rather than as a GitHub issue.

## Behaviour that changed (#55)

- **One return rule, `readingPaint` (arrivals.js).** A paint is keyed by
its reading. It draws only when the key has changed, or when the promise
its last draw returned did not settle while the owner stood. That covers
a departure in the middle of a paint, and a paint that settled after
removal but before the departure reached the arrival batch. A finished
paint stays, failed or not. The helper also pauses and resumes the
paint's clock across a departure. A `refresh()` asked for while the
owner is away now runs on the return; before, the unconditional re-read
covered it, as when lf-activity's Markdown parser lands while the feed
is away. `watchData` and `watchProjection` both use it, and data.js
drops its `delivered`/`painting` bookkeeping.
- **What a projection reading depends on.** `watchProjection` builds
both its key and its subscriptions from one list of the three inputs it
already listened to: the semantic epoch, the projection deferral, and
the number of `PRESENTATION` announcements. The re-read on return came
from #1929, where it was the way to catch up on changes missed while the
widget was away. No reading depends on anything outside those three
inputs. A reading withheld by `watchReports`' readiness proof is still
owed. This replaces the separate `blocked` flag.
- **Thread mirrors.** `mountThreadViews` returns its reconcile promise
to the watcher, so a departure that cuts a reconcile short is owed on
return.
- **`HeldReading` takes its owner** (`new HeldReading(this, region,
changed)`) and keeps its wait for unseen growth across a departure. Five
widgets disposed it on departure and relied on the unconditional re-read
to re-arm it: lf-activity, the Atlas plan, worker and tree, and the
conversation workspace. With only the core change, a held reading in
that pattern never showed after a return. The test below failed that way
before this change. Those widgets no longer dispose or re-arm it, and
lf-atlas-tree's re-arm from #2531 is gone.
- **The lf-test-worker fixture** paints through its watcher's clock, not
through a per-connection `clocked` paint that only a re-read re-armed.
- **module-authoring.md** states the return rule once, under "Connection
lifetimes", for data and projection subscriptions. The
`widget-controller-lifetime` eval prompt no longer asks for a catch-up
when nothing changed.

## Measured

| Item | Hand-written source (excl. tests, Markdown, eval YAML,
generated corpus copies) | Tests |
|---|---|---|
| #55 | +171 / −115 (net +56) | +164 / −11 (net +153) |

The source total breaks down as the runtime (+167 / −103) and the
example widgets (+4 / −12). `readingPaint` itself is +64 / −1 in
arrivals.js, including its contract comment.

## Validation

-
`test_a_returning_projection_subscriber_reads_again_only_where_its_departure_cut_the_paint`
failed on `main`: each of the three watchers called its failing callback
twice and reported the failure twice. It passes here. It also checks
that a projection paint cut short by a departure is drawn again.
- `test_a_held_reading_shows_once_unseen_after_its_owner_returns`: with
the core change alone and the old dispose-on-departure pattern, the held
reading stayed on `first`. With `HeldReading` owning its lifetime, it
shows `second`.
- A Node runtime test covers `readingPaint`: a refusal stands, a
cut-short paint is owed, and a paint that settles after removal but
before departure delivery is owed. With the settle-while-detached line
removed, that test fails.
- The projection lifecycle test now expects no read on an unchanged
return, and a clock tick after the return.
- Focused browser runs pass: data and projection subscription
lifecycles, the activity feed's held and print tests, the Atlas report
hold, work roles, package thread mirrors, the PR brief clock, and the
report narration proof.
`test_primary_reader_revision_replaces_owner_without_losing_thread_draft`
fails ("The page already has a Thread presentation") with or without
this change.

## Not changed

`widget-controller.js` (around line 254) clears `renderedReading` on
departure, so a return re-runs `renderState` and the widget's
subscriptions on an unchanged reading. This is a third return rule, and
this PR does not test whether a `renderState` failure is shown again on
return. Moving the controller onto `readingPaint` would also mean
presenting its presentation ticket without a repaint, so it is left for
a follow-up.

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

1 participant