Skip to content

Paint the line on both edges of a pointer drag - #22

Merged
max-sixty merged 4 commits into
mainfrom
fix/dragging-key-line
Aug 24, 2026
Merged

max-sixty merged 4 commits into
mainfrom
fix/dragging-key-line

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

.lf-dragging is half of unaccountedGesture(), so a widget wearing it moves core's z row — and lf-board wrote the class from four places, of which only the two on the keyboard path painted. #grab added it and called paintKeys() on the next line, under the comment that says why; #release removed it and called paintKeys(). The pointer path did neither: Sortable's onStart ended on a bare classList.add, and onEnd opened on the matching remove and could leave at its from === to && oldIndex === newIndex early return before #send was ever reached.

The window on the first edge is a whole gesture rather than a frame, and nothing else covers it: the focus paint lands on the mousedown and fallbackTolerance: 4 fires onStart after it, reconcileState() returns at its own .lf-dragging gate so a poll's replay is not a paint, and syncAsks() is not in the poll loop. So on a quiet board the line went on offering undo for as long as the reader held the card, over a press the dispatcher was already refusing. onEnd is the same gap read backwards: a card dropped where it was picked up takes the class off with nothing following it, so the offer stayed withheld from a press that was live.

Solution

The paint moves to the class, in core: dragging(el, on) toggles .lf-dragging and calls paintKeys(), and lf-board's four sites become dragging(this, true/false) — the two that already painted along with the two that didn't.

Core owning the writer is what closes the gap for the widget after this one. The class is core's own vocabulary and core is its only reader (unaccountedGesture, and the replay gate in reconcileState), so a duty stated in prose — "whoever moves the state paints" — would leave the twelfth widget to learn it from a docblock or not at all, with a paint that never happened as the symptom: invisible to the file lint, which doesn't read modules, and to version check --render, which has no wrong artifact to compare against. That is the shape CLAUDE.md names under The widget list is never closed ("Before gating an obligation every adopter must remember, ask whether the declaration already states enough for the layer to do it once"), and the resolution the data-lf-state mark already took. Here it needs no declaration at all, because the class is already the layer's.

The paint coalesces to a frame, which is what lets one call stand for everything else the same gesture moved: the widget's own rows in #grab, where the grab is a press on an already-focused grip and no focus event fires, and — on the drop that does send — a frame landing after #send has stated what is in flight, so it still reads as a gesture the log has not taken. onEnd keeps the call ahead of its branches, because the branch that returns early is the one with no send behind it.

Testing

test_a_pointer_drag_stops_the_line_offering_the_press_it_refuses stages a keyboard move so there is a gesture to take back, then pointer-drags that same card by the grip the move left focused — so the mousedown lands on an already-focused control and fires no focusin, leaving the paint under test as the only one that could clear the offer. It reads the line once at each edge, and each read fails on its own edge with that edge's paint removed.

Two ways this test passed while proving nothing, and what fixed each

The read has to be once, not expect. Written as expect(...).not_to_contain_text("undo"), the mid-drag assertion passed with the fix removed — and so did the assertion after the drop. A probe against unmodified main shows why: mid-drag the class is on and the line still says z undo, for the whole 0.9s the probe watched, so the defect is real — but expect re-asks for five seconds, and a version poll two seconds out repaints the line whatever the drag did. That is tests/CLAUDE.md's "a state the page passes through is not a state to poll for", read the other way round: the page passes through the asserted state on its way back from a paint nobody asked for. _painted_line consumes the frame paintHere coalesces to and reads once.

main, mid-drag:  ['lf-dragging', '⏎ / space grab the card … z undo … esc let go …']
main, after drop: ['',           '⏎ / space press it … esc let go …']   ← no undo row

A box measured across the FLIP is a box the card has left. The keyboard move animates the card into its new column, and bounding_box() taken across that read x=737 where the settled answer was x=1092. The press lands on the grip at that instant and the pointer is somewhere else by the mousemove after it, so Sortable never starts the drag — and the failure arrives as wait_for_selector("lf-board.lf-dragging") timing out on a page nobody dragged, thirty seconds later and nowhere near the cause. The test waits for the card's own animations to empty first.

Bug-back. Each edge on its own at dbb520f, when the paint sat in lf-board:

onStart paint removed:
  AssertionError: the line offered a press the dispatcher refuses for the length of a drag
onEnd paint removed:
  AssertionError: the drop that sent nothing left the line refusing a press that is live

And with the paint now in one place, dropping paintKeys() from dragging takes out the same assertion (1 failed, 24 passed over -k "board or dragging or pointer_drag").

The suite, run the way CI runs it on this Linux runner: 869 passed, 6 skipped in 590.59s. pre-commit is clean on both changed files. One run in between failed test_a_withdrawn_decision_is_still_withdrawn_after_a_reload, which passes alone and passed on the unmodified branch head under the same load — a contention failure on a page this branch does not touch.

Found reviewing #21, which closes the same shape of gap for sending — the other term of the same predicate. This one reverts independently of that, so it is on its own branch off main; the two touch leaf.js in different places.

Merged with main at #21, which renamed unrecordedGesture to unaccountedGesture and moved the .lf-dragging replay gate into reconcileState — the names above are the post-#21 ones, and the mechanism is unchanged under them.

.lf-dragging is half of unrecordedGesture(), so a widget wearing it moves
core's z row — and the pointer path wrote the class from two places that
paint nothing. The keyboard path already paints on both edges (#grab,
#release); the drag did not, and the window there is a whole gesture rather
than a frame: the focus paint lands on the mousedown and fallbackTolerance
fires onStart after it, so on a quiet board nothing repaints until the drop.
The line therefore offered undo for as long as the reader held the card, over
a press the dispatcher was already refusing. onEnd is the same gap backwards:
a card dropped where it was picked up takes the class off and returns before
#send, leaving the offer withheld from a press that is live.

keys()'s docblock stated the paint duty for a widget's own rows; it now states
it for state a widget writes that moves a row it never declared.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review. The fix reads correct on both edges: onStart paints after the class lands, and onEnd paints before the branch that returns without a send — and where a send does follow, sendAction records it synchronously before its first await, so the coalesced frame sees sending non-empty and z stays withheld, as the comment claims. The test is the shape tests/CLAUDE.md asks for under A state the page passes through is not a state to poll for — consume the step, then read once — rather than an expect that would report whichever later paint the page happened to make.

One observation, on where the fix sits rather than on whether it works.

Comment thread plugins/leaf/skills/leaf/assets/leaf.js Resolved
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

test is red on dbb520f — test_a_rebuild_keeps_what_the_reader_did_inside_the_change, 868 passed, 1 failed (run). It is the refused-z flake, not this branch.

The assertion reads the accept pill after the undo and finds ✓ Accepted where it wants ✓ Accept — the settlement still standing, which is what a z the dispatcher refused leaves behind. The test presses z on the turn after round_trip returns, and the accept's own trip is still in sending at that moment, so unrecordedGesture() holds the press dead and the page an assertion on the un-undone state would find is exactly the page it finds. #21 is the fix, and this is one of the tests it converts: page.keyboard.press("z"); round_trip(page) becomes undo(page), which waits for the line to offer the press before making it. Its tests/CLAUDE.md addition names the shape — "the suite's undo tests were failing that way one at a time, a different one per run".

Nothing in this diff reaches it: the two added paintKeys() calls fire only inside SortableJS's onStart/onEnd, and this test drives a suggestion page with no drag on it. The suite ran 640s here against 336s locally, which is the loaded-runner window the race needs.

So this branch stays red until #21 lands. Re-running the failed job to see whether it clears on its own; if the maintainer takes #21 first, a rebase would settle it for good rather than by luck.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Green on the third attempt of test at dbb520f, so the branch is not red after all — and the two red attempts name the diagnosis above rather than a second fault. Attempt 1 failed test_a_rebuild_keeps_what_the_reader_did_inside_the_change; attempt 2 failed test_a_decision_travels_between_tabs_and_the_log_has_the_last_word at expect(tab.locator("#sug-thistle lf-new")).to_be_hidden(); attempt 3 passed the whole suite. A failure that moves between attempts on one commit is the loaded-runner shape, not this diff — which is also what the local run said: 869 passed, 6 skipped in 335.57s against the runner's 640s.

The second one is not a z press at all, so #21 does not cover it: it is a suggestion decision racing between three tabs, one of them with /api/state refused. Worth naming here so the next red run on it has somewhere to start.

The paint duty for .lf-dragging was stated in prose on keys()'s docblock, which leaves it to whichever module remembers — the shape CLAUDE.md names under "The widget list is never closed", and the same one the data-lf-state mark was moved out of. No declaration is needed here: the class is core's own vocabulary, with core its only reader, so core can own the writer. dragging(el, on) toggles it and paints, and lf-board's four sites say the reader's hand is on it rather than writing the class and remembering the paint.
# Conflicts:
#	plugins/leaf/skills/leaf/bundled/widgets/lf-board.js

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review of the increment since the last one (5920c34, plus the merge of main at 9205da8). No new findings in the code: dragging(el, on) is the shape the earlier thread argued for, .lf-dragging now has exactly one writer, and the four call sites in lf-board.js are the only ones. The net diff of 002d502..9205da8 over the two runtime files is exactly that change, and the merge took main's #grab refactor (const index = cards.indexOf(card)) rather than reinstating the branch's form — so nothing semantic was resolved in either direction.

What is worth flagging is a signal gap rather than a defect: ci is green on 5920c34 but has never registered on 9205da8, the merge commit that is now the head. Since main picked up several runtime refactors between the two (Refactor state coordination to use semantic facets, Hold the page still while it is arriving), the merged tree the branch would land as had no gate on it. I ran the covering subset against 9205da8 itself on this runner rather than leave that unstated.

What I ran, and the bug-backs

Checked out 9205da8 detached (the review checkout's refs/pull/22/merge was stale — it merged 5920c34 into an older base):

uv run pytest tests/test_render.py -q -n0 --run-nightly -k "pointer_drag or dragging or live_drag"
  2 passed, 483 deselected in 9.11s

uv run pytest tests/test_render.py -q -n0 --run-nightly -k "board or grab or card or undo or keyline or z_"
  37 passed, 448 deselected in 57.33s

Both edges bug-backed separately, because one assertion carrying both would not have shown it:

  • Dropping paintKeys() from dragging in leaf.js — the drag-edge assertion fails, undo still on the line under a live drag.
  • Swapping onEnd's dragging(this, false) for a bare this.classList.remove("lf-dragging") in lf-board.js, so the class comes off but nothing paints — the drop-edge assertion fails (the drop that sent nothing left the line refusing a press that is live), while the drag-edge one still passes.

So test_a_pointer_drag_stops_the_line_offering_the_press_it_refuses is not resting on one paint standing in for the other. The quiet-window premise its docstring rests on also holds in the code: poll() only reaches renderPanel() (and so paintHere) when eventSeq > lastEventSeq, and renderStatus/renderVersions/renderOthers call neither — so a routine poll landing inside the drag cannot repaint the line and mask a missing edge.

The full suite is still the maintainer's to run; this is the subset that covers the change, not --run-nightly over everything.

@leaf-agent leaf-agent closed this Aug 22, 2026
@leaf-agent leaf-agent reopened this Aug 22, 2026
# Conflicts:
#	plugins/leaf/skills/leaf/assets/leaf.js
#	tests/test_render.py

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review of the new base. The increment since the last review is the merge of main at #21 and nothing else: git diff 85631b3..5044bb6 over the two runtime files is exactly this branch's change, so the merge neither dropped anything from main nor reinstated the branch's form of anything main had refactored. No new findings in the code.

What the merge moves is the ground under the fix rather than the fix. #21 replaced sending with outbox and added watchProjectionDrag, a .lf-dragging observer that paints on the drag's far edge — and that second one is worth checking rather than assuming, because it is a paint on the drop edge that did not exist when this test was bug-backed. A test that no longer fails without the fix would be green for the wrong reason, and green is exactly what it is. It doesn't reach here: the observer is armed only from reconcileState, which returns at its own .lf-dragging gate during a drag, so on the quiet board this test drives it is never installed. I re-ran both bug-backs on the merged tree to confirm that rather than resting on the reading.

The other term survives the rename intact. unaccountedGesture() is undoing || outbox.length > 0 || .lf-dragging, and the outbox push is synchronous inside the new Promise executor, ahead of drainOutbox's first await — so the frame onEnd's paint coalesces to still lands after #send has stated what is in flight, which is what the PR body claims of the drop that does send.

ci is green on 5044bb6 itself, which closes the signal gap the last review flagged — that review ran the covering subset by hand because ci had never registered on the merge head. It has now, on a base that includes #21.

I also updated the description: it named unrecordedGesture() and applyActions(), neither of which exists on the current base, so a reader grepping the merged tree for either would have found nothing.

The two bug-backs, on the merged tree

Against the review checkout (refs/pull/22/merge, 85631b3 + 5044bb6), which is current here rather than stale:

uv run pytest tests/test_render.py -q -n0 --run-nightly -k "pointer_drag or dragging"
  1 passed, 510 deselected in 4.07s

Each edge removed on its own, since one assertion carrying both would not show it:

  • paintKeys() dropped from dragging in leaf.js — fails on the drag edge, the line still offering undo under a live drag.
  • onEnd's dragging(this, false) swapped for a bare this.classList.remove("lf-dragging"), so the class comes off with nothing painting — fails on the drop edge: AssertionError: the drop that sent nothing left the line refusing a press that is live.

So the test still proves both edges on the post-#21 base, and the new drag-end paint is not standing in for either. Tree restored after each.

The quiet-window premise the docstring rests on also still holds under #21's poll: the syncAsks calls added around it are in presentPage/startPage, page startup rather than the poll loop, and syncAsks otherwise reaches the page through the lf-actions event, which watchProjectionDrag dispatches only after the drag has ended.

@max-sixty
max-sixty merged commit 141a430 into main Aug 24, 2026
7 checks passed
@max-sixty
max-sixty deleted the fix/dragging-key-line branch August 24, 2026 21:53
max-sixty added a commit that referenced this pull request Aug 24, 2026
…ter (#39)

Two test reads are holding `ci` red on `main`, one per commit, and
neither can show a green `test` while the other stands — so they are
here together rather than in two PRs that would each stay red. They
revert independently; nothing in one depends on the other.

## The standing mark's pointer

`test_the_page_marks_the_comment_the_reader_is_standing_in` —
`Page.wait_for_function: Timeout 30000ms exceeded` waiting for
`lf-mark-hover` after the pointer is put on the standing mark. First
seen on [run
32779874922](https://github.com/max-sixty/leaf/actions/runs/32779874922);
the run that opened this session,
[32778837094](https://github.com/max-sixty/leaf/actions/runs/32778837094),
failed instead on the note-set axis, which
[90ba2a7](90ba2a7)
had already fixed four minutes after that run was queued.

The walk that puts the reader in a comment opens the panel, and the
document slides into its new width over the fifth of a second that
follows (`syncLayout`, the slide `panel_settled` was written for). The
point handed to `page.mouse.move` is taken on that flight, against a
column that is still moving, so the pointer goes where the mark was and
the slide carries the mark out from under it. The runtime is right to
drop the hover — `pageShifted` recomputes `markAt(pointer.x, pointer.y)`
after the reflow, and by then the pointer is over ordinary prose.
Measured at the read, on Linux:

```
at the move:  body animations ["margin-right"], margin-right 35.3px, point x=358
600ms later:  body animations [],               margin-right 420px,  mark spans x=172.7..236.4
```

Nothing retries, because a highlight is not an element — so it surfaces
30s later at the hover wait, reading as though the page had stopped
lighting what the pointer is on. `panel_settled(page)` before the point
is read; it consumes the transition through `getAnimations()`, so it
returns on the frame the slide ends rather than encoding the
stylesheet's duration. It goes at the geometry read rather than up at
the walk, because the three readings in between are about the arrival's
lift and are green as they stand.

## The key line's rows

`test_a_pointer_drag_stops_the_line_offering_the_press_it_refuses` —
`assert 'undo' in '⏎ / space\ngrab the card\nesc\nlet go\n?\nmore'`. New
with
[141a430](141a430)
(#22), which was verified against a base that predates
[ee4d444](ee4d444).

`renderLine` now paints two chips — the first row and the way out — and
hides the rest behind More, whatever the page is offering. So
`inner_text` no longer answers what a row's `when` decided: on a board
page the widget's own `⏎ / space grab the card` and `esc let go` take
both seats, and `z undo` is invisible whether it is live or not. The
read after the drop asked for a chip that page can never paint, and the
read mid-drag passed on that same permanent absence — proving nothing
about the edge it was written for. What `when` decides is whether the
row is in the line at all:

```
mid-drag:   ⏎/space press it · c comment on the page · d/u half a page · esc let go · g go to · v versions · i design mode · ? more
after drop: ⏎/space grab the card · c comment on the page · d/u half a page · z undo · esc let go · g go to · v versions · i design mode · ? more
```

`_painted_line` returns those rows instead of the visible text. A
repaint that never came still leaves the rows the previous state put
there, so the reading stays once-only and both edges keep their
bug-backs.

## Testing

Each fix reproduced at its own failure before the change and green
after, at `-n0 --run-nightly` on Linux, then again together on the
rebase onto current `main` (d3151de): `8 passed` over the two tests and
the key-line tests around them.

Bug-backs, since a wait added to a timing failure and a widened read are
both shapes that can green a test by removing what it proves:

| edit | result |
| --- | --- |
| `paintHover(id)` → `paintHover(null)` in `leaf.js` | standing-mark
test fails at the same hover wait, with `panel_settled` in place |
| drop `paintKeys()` from `dragging` | `the line offered a press the
dispatcher refuses for the length of a drag` |
| `onEnd`'s `dragging(this, false)` → bare `classList.remove` | `the
drop that sent nothing left the line refusing a press that is live` |

`uv run pytest tests -n2` — 494 passed, 6 skipped. `pre-commit` clean on
the changed file. The full `--run-nightly` module is left to this PR's
own `ci`.

---
Automated fix for [failed
run](https://github.com/max-sixty/leaf/actions/runs/32778837094)

---------

Co-authored-by: leaf-agent <[email protected]>
Co-authored-by: Maximilian Roos <[email protected]>
max-sixty pushed a commit that referenced this pull request Sep 18, 2026
`notes/workspace-followups.md` has been presenting finished work as the
plan since 9 September. It opens with "Start #2, #3 and #4 as one
coordinated contract batch; run the review-queue simplification #8
alongside it" — all four of those shipped that week — and carries
thirteen briefs, each with a live "Next task" and "Done when", for work
`TODO.md` dropped as complete. This removes them and leaves the six
`TODO.md` still links: #11, #14, #19, #20, #22 and #23.

The trim follows the convention #666 set and the reason `CLAUDE.md`
gives for it: a note is never a second specification for shipped
behavior. #666 removed #6, #7, #16 and #17 the same way, rewriting the
two `Owner / dependencies` lines in surviving briefs that named them; it
simply did not reach the rest.

Each removal is evidenced by the commit that took the item out of
`TODO.md`, not by a reading of the current code:

| Brief | Removed from `TODO.md` by |
| --- | --- |
| #1, #3, #5 |
[`0f7f06a6`](0f7f06a)
— "Completed workspace items #1, #3, and #5 are removed from `TODO.md`"
|
| #2, #4, #8, #9 |
[`28b5da99`](28b5da9)
— "the completed #2, #4, #6, #8, #9, and #17 backlog entries are removed
while preserving the deferred evaluation work" |
| #13, #15 |
[`6df40353`](6df4035)
— "closes three bounded workspace follow-ups" |
| #10, #12 |
[`c9eaa2c6`](c9eaa2c)
— the continuation cue and the adaptive Threads placement |
| #18, #21 |
[`e46c8b93`](e46c8b9)
— the monitoring workspace and its package-owned root |

Alongside the briefs, three group headings are now empty and go; the
`Suggested work packages` table loses the rows whose whole scope landed;
and four cross-references that named a removed ID are rewritten — #14's
dependency on the Threads-placement experiment, #20's ordering behind
#8, and the two sentences in `Reproduction record` and `Browser
evidence` that pointed at briefs no longer here.

#14 needed more than a rewritten pointer. The experiment it waited on
was settled in two steps, and only the first removed an ID: [PR
#520](#520) kept the adaptive
placement and deferred the modal-focus work to #24, which landed in [PR
#536](#536) as inertness, dialog
semantics and focus containment for a covering workspace. That is the
surface #14 exists to verify, so its `Done when` — "Avoid imposing a
modal focus trap on a nonmodal panel" — described the containment #536
shipped as the defect to avoid. It now states the containment the
shipped modality requires, and the dependency line names both
settlements.

The dated evidence sections themselves stay. They are the record of what
was read in a browser on 8 September, not a plan, and the note's own
header scopes them to that date.

No test covers `notes/`, and this changes no behavior, so there is
nothing to regress. `pre-commit` passes on the file; the `TODO.md` →
note anchors all still resolve, and no surviving text references a
removed ID.

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 11, 2026
Leaf and Sortable currently call moveBefore unconditionally, so their
retained-node reorder fails when that API is absent. Group A, survey
item 1 now gives those moves one runtime primitive: native moveBefore
inside a shared composed root when available, insertBefore otherwise.
Authored revisions, renderer child reconciliation, board placement, and
Sortable use it. The Sortable adaptation fails if its pinned upstream
seams change.

The requested lit-html adaptation is **skipped** in this PR. Its Chrome
experiment preserved focus and iframe documents, but the full CI run
exposed four rollback-journey stability failures. Frame traces with both
patched and original Lit show the same pre-existing 34px jump: passive
withdrawal of an open thread removes its title allocation, opens the
fallback, and moves a surviving closed card while the list is already at
scroll zero. Ordinary insertion hides that jump from Chrome's
layout-shift reporting. Preserving nodes makes it observable. A coherent
policy for departed thread allocations is needed before adopting native
Lit moves; a fold, negative-scroll compensation, or a weaker stability
check would not fix the reading. The browser-support review #22 entry
records the evidence and the remaining limit.

The focus-holding render wrapper stays because Lit still uses ordinary
insertion. The retained-move browser test exercises named form controls,
retained-node ordering, and direct placement. Native moves preserve
focus, backward caret, typed text, and iframe document identity without
a blur. The fallback demonstrates a real blur followed by explicit
focus/caret restoration. WebKit 26.6 reorders through the fallback.
Platform methods are read through prototypes so form controls named
moveBefore, getRootNode and insertBefore cannot shadow them; startup,
focus retention, traversal and text selection use native root lookups as
well. A shadow-form regression also covers native scroll delivery and
standing/selection readings after integrating the landed lifecycle
changes.

Measured handwritten production/build source (ten changed source files,
including the new primitive, excluding generated bundles, tests and
documentation): 6,596 → 6,630 lines (+34). This foundation consolidates
eligibility and fallback rules rather than reducing total source lines.
The served triage-board comparison adds one JavaScript request and 1,070
JavaScript bytes before upgrade/presentation. This synchronous
dependency provides state-preserving placement during initial renders.

Validation: Chrome native/fallback editor and frame tests; all four
complete-list rollback variants; board keyboard/drag/undo and authored
iframe revision tests; WebKit fallback probe; all 327 runtime tests; all
95 framework/build tests; prepared-install and offline-export
integration; scoped pre-commit checks. Required PR jobs run the full
suite and delivery builds.

> _This was written by Codex on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Oct 12, 2026
… a reply to a withdrawn message (#2507)

Python code that restated a rule a stronger mechanism already enforces,
explained malformed agent input the agent would fix from a plain
refusal, or recovered from states no Leaf writer produces. It goes; what
stops bad input passing silently into admitted events, stored decisions
or anchors stays. One confirmed bug is fixed on the way. Part of the
complication-weight sweep (#19–#24 and #30 there).

**Bug: a reply to a withdrawn message opened a phantom thread.**
Admission checked a reply's `parent` against every message in the log,
withdrawn ones included, while the thread fold drops withdrawn ones; so
a reply to a reaction the user took back was admitted and landed in a
second thread named after the withdrawn reaction. `_parent_error` now
refuses a withdrawn parent, and `UndoReading` counts any child, a
reaction included, as standing on a reaction, so every standing
message's parent stands. The fold reached the phantom through recovery
written for a torn opening line, which the writer cannot produce (it
fsyncs before returning an id and repairs a torn tail before the next
append); that recovery goes from `build_threads`, `seat_root`,
`thread_context` and `logged_id`, with its two tests.

**Restated rules (#19):** the start line's one-line rule now lives once
in the kernel registry, including a progress reply's `start`;
`record_pickup`'s phase, `cmd_wait`'s argument pair, `deferred_value`'s
re-checks, the `Unresolvable` catch, the JSX refusal (the browser check
reports it), the `check_app_server_endpoint` alias, the
entries-are-dicts check and the `user_views` JSON round trip (now
`deepcopy`) go.

**#20:** the `fcntl` ImportError fallback goes; Leaf runs only on POSIX
and a plain import fails as early.

**#21:** `capture_anchor` refuses a missing quote with one message
instead of diagnosing fences, removed words and data bodies (the
retired- and gone-section refusals stay); `leaf data set` no longer
explains empty stdin; `task open` no longer explains a thread subject
the schema refuses.

**#22, #24:** `activity._moment` stops tolerating timestamps no Leaf
writer produces; the interaction log stops re-validating on read what it
validated on write: it skips a torn line, and marks a split record whose
parts don't join into the entry they name as `interaction_unreadable`
(ingress checks each part, not the whole).

**Rules moved to their owners (#30):** the layer's `$` fact shapes are
one `LAYER_FACTS_SCHEMA`, leaving only cross-references and what a
schema can't say in code; `delivery.pending_batches` is gone for
`hook_transport.read_plans`; `codex run --handshake` is required; the
`RANK` pattern and identity fields' non-emptiness are in
`detail_schema`. Patterns that replaced a `fullmatch` end with
`(?![\s\S])`, because Python's `re` lets `$` match before a final
newline. `lf-suggestion`'s rules stay in Python: no existing declaration
can say how many slots it holds or that it can't nest.

**Behavior changes:** a reply or reaction to a withdrawn message is
refused; a reaction to a reaction blocks undoing the parent reaction;
refusals read as the schema's or parser's message; a log that already
holds an orphaned message (possible only from the bug above) now fails
to read instead of showing a phantom thread.

The browser runtime's half of #23 is in the runtime cuts PR, which
follows this one.

> _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
…nd argument type guards, and the unused x-paints key (#2555)

Browser-runtime and package code that re-checked what Leaf's own server,
composer or producers already guarantee, retried or rolled back faults
nothing records, or type-checked arguments the next line would reject
anyway. It goes; checks that stop bad input passing silently into
admitted events, stored decisions or anchors, guards against hangs, and
`current()` race checks stay. Part of the complication-weight sweep
(#18, #22, #23, #25 and #27 there); follows #2507.

**#18 Re-checks of Leaf's own output**
- `validDrawing` re-validated every drawing against the full comment
schema on each paint, though admitted drawings passed it at the append
door, `drawing.js` clamps every bound, and the versioned `format`
separates old drafts. It is now the format check; the generated bound
constants stay. `drawing-record.test.mjs` goes; the malformed-draft
browser test now uses a `leaf-drawing/2` draft.
- Spot checks of `$layer` facts, four `/api/state` fields, the
deferred-data reply echoing its request, the export payload and "a
single main" (which `page check` refuses) go from `widget-loader.js`,
`state-application.js`, `data.js`, `context.js`, `version.js` and
`layer-client.js`. `loadDeferred` keeps its two `current()` checks. The
two deferred-load tests now inject an HTTP 500 instead of a bad echo.
- `summary-ranges.js` stops re-checking the contiguity `events.py`
builds.

**#22 Retry and rollback for faults nothing records**
- The thread list's one-shot retry of a failed render (with
`RetainedThreadListError` and its `recovered` plumbing) goes; a failure
restores the committed list once and is reported, and the next reading
paints. The sibling-cohort rollback stays.
- The Questions banner rolled back twice on one failure, and its inner
rollback ran before `view.js`'s rule that an obsolete attempt must not
roll a newer reading back; `view.js` is now the one owner.
- The file editor's merge `Compartment` could never switch; the merge
view is built once.
- lf-diff's four assertions on its vendored Pierre's output shape go;
`renderedLines`' row check, which keeps a datum key off the wrong row,
stays.

**#23 (runtime half)** The torn-opening-line thread recovery, which
#2507 made unreachable by refusing a reply to a withdrawn message, goes
from `thread/model.js`'s contract, `module-authoring.md` and
`application.ts`, with its runtime test.

**#25 Argument type guards** About sixty `typeof`/`instanceof` checks on
module-API arguments, including bundles only the runtime passes, go
across `projection/`, `thread/`, `keyboard/` and the top-level runtime,
and in lf-visual-review, lf-playground and lf-diff. Kept because they
guard a rule rather than a type: `projectData`'s non-empty key and
identity (a package passing an object would otherwise anchor a stored
comment to an unrelated datum; new `project-data.test.mjs`),
`setReaction`'s boolean, `declaredScope`'s Escape enum, double
registration, visual-part uniqueness and `requireReference`.

**#27** The `x-paints` registry key, which no tag in the tree declares
since lf-task left, goes with its runtime reader, render-check half,
schema, docs and tests.

**Not cut:** `canonicalBinding`'s `"Space"` alias, which is what makes
the non-canonical check refuse a binding that would otherwise never
fire.

**Tests:** with the retry gone, the `choose-earlier` boundary variant
holds each failing reading at a gate before it paints, so the user's
choice happens on the committed list and one release fails all three
readings; the shift watch stays on and the test asserts both the
retained reading and its stability.

> _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 Nov 6, 2026
…'s words; a slot outside a shadow tree reads its children

Shipped markup (#22). Both readings run two elements' words together where nothing
stands between them, and the shipped markup still had such pairs that the theme
draws apart: the default package's lf-ask example read "recommendedDrop" and
"pausedPause", its lf-sample example "lowPaper" and "recommendedDedicated", so search
for "recommended Drop" found the example on main and not here. Every place in
examples/, docs/, the registries' `x-example`s and skills/ where a closing `</small>`,
`</span>`, `</code>` or `</em>` meets the next element's text with nothing between
them now has whitespace there: 19 places in 7 files. Most were hidden from a line
search by prettier splitting the closing tag across a line (`</small⏎><strong>`), so
the search parsed each file and each JSON string. They are the lf-ask and lf-sample
examples (4), the session-store sample in skills/leaf/references/threads.md (1), the
feature gallery's two chip pairs in its page and both earlier versions (6),
docs/ui.html's rollout chip and four layout names beside their scope (5), and
docs/extending.html's three layer rows (3). The feature gallery's chips sit in a line
of prose, so each pair now has a word space between its chips; every other place is a
grid, a block or the end of a line, where the whitespace draws nothing. The gallery's
empty `bg-code-target` span, which holds no words, stays as it is.

Slots outside a shadow tree (#24). The reading walk read every `<slot>` through
`assignedNodes()`, which answers nothing for a slot in no shadow tree, though the
browser draws that slot's children as any element's: `<p>alpha<slot>beta</slot>gamma</p>`
read "alphagamma" in the browser and "alphabetagamma" in the file. A slot stands for
what is assigned to it only in a shadow tree now; anywhere else the walk reads its
children.

tests/quote_cases.json gains the light-DOM slot; both runtimes answer all 28.

Tests, each failing on 32db1b6 in Chromium and Firefox:
- test_page_search_finds_a_shipped_options_chip_and_title_apart (#22), which reads the
  lf-ask example from the shipped registry;
- test_page_search_finds_the_words_a_slot_outside_a_shadow_tree_holds (#24).
max-sixty added a commit that referenced this pull request Nov 6, 2026
The same pairs as #22's, written in the widget modules rather than in shipped
markup: a closing `</span>` running straight into the next element's text. Each of the
seven now has whitespace there: lf-call-diff's marker and body, the worktree view's
label and path, lf-trace's moment number, label and time and its node's name and
path, and lf-visual-review's case number, title and status. Each pair sits in a grid
row, or before a block, where the whitespace draws nothing.

Read on the shipped pages that render them, in Chromium and Firefox: the worktree view
read "Worktree/Users/…" and a trace node "heading · Release reviewpath 0", and both
now read apart. All 17 of pr-walkthrough's call-diff lines already read apart, since
each body starts with its tree's indentation; the space keeps a line whose body
doesn't apart too. The trace's moment rows and the visual review's case buttons are
controls the page reading never reads, so their space changes no reading.
max-sixty added a commit that referenced this pull request Nov 19, 2026
…#6502)

The turn-end check's fork often posts an ask with its question inside a
paragraph of status and advice, copying the shape of the agent's chat
reply. On real pages, 9 of the 29 asks it posted on 17–18 Nov kept the
question in a paragraph with other sentences. The guidance it reads
already says to give a question a line of its own (`threads.md`), so
this states it beside the field the fork writes: `turn-end-check.md`'s
`text` now says the question stands in a paragraph of its own.
`threads.md` says "paragraph" in place of "line" too, since a Markdown
line joins its paragraph.

On `ask-choice` and `ask-permission`, the two cases the judge failed on
this, base passed 15/24 runs and head 16/16. The seven other cases on
asks, four of which should post none, passed 21/21 on base and 20/21 on
head. The `threads.md` wording alone didn't help: 13/20 against 16/20 on
base, across the five cases that post an ask.

**To weigh:** this puts a second statement of the rule in the turn-end
check's reference, beside the field it governs. The fork already reads
the `threads.md` paragraph among its guidance excerpts
(`clerk.GUIDANCE`), and that alone didn't change what it wrote. The runs
used the fork eval's replay from #6477, now on `main`.

From open item #22 on the fork-messages page. Max asked to merge the
pull requests we're confident in. Tests: `test_clerk.py`, both
`test_product_page.py` files.

> _This was written by Claude Code on behalf of max-sixty_
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