Repository navigation
Give the runtime's state, delivery and traffic facts one owner each - #2332
Merged
Merged
Conversation
…ead promise
startPost returned {answer, presentation}, but every caller read only the
answer, so afterEnqueue's whenDocumentPresented() promise went nowhere. It now
returns void and startPost returns the answer.
The `pending` field of data-lf-traffic had two writers, afterEnqueue and the
delivery drain, both writing the published effective.sending. traffic.js now
watches that selection from mountApplication, painting only when the attempts
change and nothing before the first send. Behaviour change: `pending` clears
with the publication that accepts or refuses an attempt, slightly before the
drain finishes settling it, rather than after.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ture's target
nameParent and nameUndo took the receipts as an argument, which delivery
fetched from the same publisher through a currentReceipts callback that
application.js threaded in. They now read the publisher themselves, and one
admittedId helper states the rule ("the ledger entry's admitted id while it
stands, its receipt's once released") that derive's undo projection,
nameParent and nameUndo each wrote out. No behaviour change.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…light withdraw() raised runtime.undoing around its post, and unaccountedGesture read it beside hasPending(). The post enqueues the undo synchronously and the entry stays in the ledger at least until its answer, so hasPending() already covers that window; the flag only held z back for a few microtasks after the undo was accepted and presented. Its two paintKeys calls go too: afterEnqueue paints on enqueue, and a render probe holding an undo's POST while a read presented it showed z return when the POST answered without the trailing paint. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
page-geometry.js's resize door already answers every window resize with invalidate() and pageShifted(); chrome-layout's own handler ran pageShifted again on the same event, before the body observer's repaint frame ran it a third time. The handler keeps its synchronous edge, modality and layout restatement, now documented in the module header, because moving it to the frame would let an edge or a beside surface lag a live window drag by one frame. The body observer's layoutChanged flag, which was exactly widthChanged || chromeMoved, goes. No behaviour change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
questions/view.js filtered to widget Questions before calling questionHolding, which filters the same predicate itself for its unfiltered callers, and the annotation inventory filtered before questionPlace, which already gives a non-widget Question no node. queues.js's questionItem chose its subject and its `ends` from the source kind in two parallel ternaries; one switch now returns both. No behaviour change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
other_leaves documented "live neighboring pages" but returned every running server's row, closed ones included, and the Leaves drawer filtered them out itself. The rule now lives in other_leaves, so closed rows stop travelling in /api/state, stop feeding presence_fingerprint and activityTransitionAt, and live-leaves.js draws the list as given. Behaviour change: state.others no longer carries closed pages. The Python neighbour fixture becomes a waiting page, and the drawer tests wait for a closed page's row to leave the list. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
banner.js's activityFacts and live-leaves.js's activityAccount each wrote the queued and pending phrases, and a neighbour row's hover joined the row line, which already ends with them, to the account, which said them again. One phrase table in banner.js now words every count: `waiting` keeps the queued and pending ones for the line and the banner, and a new `owed` carries the rest for the row's hover. Behaviour change: the hover no longer repeats the queued and pending counts; every phrase reads as before. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The served runtime script was selected four ways for four facts: layer-client read the layer, release and probe, banner-status-view tested for a release to mean "the website", storage.js read the share address, and context.js and version.js each derived the layer root from the probe, one by URL resolution and one by regex. storage.js, which imports nothing, now reads the script once and exports DELIVERY, WEBSITE_DELIVERY and layerRoot(doc); every reader uses them, and version.js's artifactRoot is layerRoot. The `script[data-lf-entry]` seam leaf.js, sample.js and outside harnesses use is unchanged. No behaviour change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
file-api, data.js's deferred values, uploadMedia and sample.js each wrote "fetch with layerHeaders, admit, parse, throw the server's error" differently. requestJson(url, init, what) now does it once, with sample.js's tested error shape: the JSON is read off the text, and a failure throws the server's `error` or "<what>: HTTP <status>" carrying the status, raw body and the answer's fields. A refused admission throws LayerRefused, which each caller maps to its own contract. Behaviour changes: sample allocation and release are now layer-admitted, so a stale-layer allocation reloads through the delivery probe instead of failing as "The sample document did not start Leaf", and their responses report a refused key and session activation like every other page call. A non-JSON error body from the file API fails as its status rather than a SyntaxError. The upload and deferred-value fallback messages read "image upload: HTTP n" and "deferred value: HTTP n". Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
deliver() and deliverBookkeeping() each decided whether an answer accepted the event, refused it finally, or said too little, and each wrapped applying its state in the same catch. readEventAnswer and applyAnswerState now do that for both; deliver() keeps its receipt match and attempt check on top, and its four "notice once, pause, try again" tails are one local retry(). No behaviour change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
readAndPresent and ask() each released the read slot and started the queued trailing read with the same five lines; releaseSlot() now does it for both. The news look's "nothing read or applying" guard, checked before and again after presenting, is feedQuiet(). The reading completions keep their narrower guards, which ignore a read still in flight so it cannot hold a return open, and the feedQuiet comment says so. No behaviour change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
paintReading raised the flag while a refused projection entry stood, and motion() returned null under it, so a restore after a refusal would not animate (#354). Since widget rendering moved into its own presenters, nothing inside paintReading's scope calls motion(): the board's FLIP, suggestion folds and thread folds all run in other presentation regions. The guarantee was already lost; this removes the global that implied it. No behaviour change. Whether a refusal's restore should animate is left as an open product question. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
readState set Leaf-View-Revision itself from the same runtime.currentRevision layerHeaders already sends; it guarded a Response an awaited fetch always returns; state-application checked `overtaken` immediately before canAdopt, whose first test is the same; and selectQueues/selectDone defaulted a `questions` their one caller always passes. No behaviour change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Only a held drag defers the projection, and its release already calls onDeferredReady. The 2-second tick also retried it, re-claiming every document region each tick while the drag stayed held, only for presentCurrent to defer again. The tick retry goes, and with it state-feed's projectionDeferred, retryProjection, releasePending and notifyDataSubscribers dependencies; onDeferredReady presents the held reading and releases pending entries directly, with invalidateDom queuing the pass behind a state application as retryProjection did. No behaviour change beyond the idle passes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
widget-api.js is the documented behavior-module API, yet thirteen of its re-exports were read only by the render gate's probes and the browser tests: ADDRESSABLE, USER_VIEW_RESTORE_CASES, quoteFrom, readingRegions, renderedParent, shallowSigs, shownBand, shownBox, shownRegionBounds, uiInside, upFrom and the two verbatim identity maps. check-api.js, the diagnostic entry layer.py already refuses to packages, now carries them; the probes and tests import them from there. TEXT_BOX stays, since module-authoring.md documents it. check-api takes shallowSigs from its owner, projection/presentation.js, so application.js's shallowSigs trampoline goes. ESLint let three named probes use check-api.js; every render-check probe may now, which also retires the widgets.js-only rule that the later block already overrode. No behaviour change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/assets/runtime/sample.js
…n-JSON answer as its status Review follow-ups. With runtime.undoing gone, an undo a read presented before its POST answered leaves the ledger on accept, and if the answer's own state is overtaken nothing repaints z; settlementChanged now repaints keys on that edge as accountPending does for an entry leaving on presentation. requestJson now fails an OK response whose body is not JSON as "<what>: HTTP <status>" too, and copies only `current` from an error answer rather than every field, so a server field cannot replace the Error's own. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 11, 2026
# Conflicts: # skills/leaf/scripts/leaf/render-checks/widgets.js
leaf-agent
previously approved these changes
Oct 11, 2026
# Conflicts: # skills/leaf/assets/runtime/widget-api.js
leaf-agent
previously approved these changes
Oct 11, 2026
# Conflicts: # skills/leaf/assets/runtime/banner.js # skills/leaf/assets/runtime/delivery.js # skills/leaf/assets/runtime/state-feed.js
leaf-agent
approved these changes
Oct 11, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
…, and correct the claims the code contradicts (#2612) `module-authoring.md` is the package author's reference for the helpers `widget-api.js` exports. #2538 documented every authoring export, adding each to the section that owned its topic, so the reference had grown piecemeal. It now follows the task a package author is doing rather than `widget-api.js`'s order, which groups exports by owning file and scatters one task across the list. Each helper is documented once, with its signature and return value where it was only named before, and other sections point at it by name. Mechanism a package author doesn't act on is cut. The file goes from 1657 to about 1770 lines. Every behavioral claim was checked against the runtime, and a second pass tried to refute about 110 of them. Claims the code contradicted are corrected, among them: - `readingRegion(id)` was documented but is not exported. - `motion()` returns null only under reduced motion or before presentation; the restored-state case went in #2332. - `quietWord`: Leaf writes quiet words on elements it marks rewritten, changed by the user, or reported. `x-paints` went in #2555. - `renderState` runs only while the widget has a subscriber, and a throwing `renderState` or subscriber replaces the widget with its fail-soft box. - Only subscriptions built on the owner lifetime pause while the owner is away; `watchDraft`, `onUserInput`, `watchReadingRegionTransitions`, `claimTraversals` and `boundFile.watch` do not. - `afterScript` coalesces by function identity, so a new arrow each call runs each time. - `watchDraft` takes `{input}`, which the restructure first dropped: it hands the user's caret to the replacement box across a live revision. Its callback also fires with `null` when the box's own send goes. - `threadActions.open` tries the registered primary reader, then the open Threads panel, then inline, then Threads. - `reach` is read from a row only; `readWork().done` is a count; `compareImages` also returns `width` and `height`; `alignedNodes` renders `same` runs as spans; the contribution kind is `ask`. `tabStore` has its own section, "Tab-local working state", and "Sticky headers" is its own section, which the glossary now cites. `assets/AGENTS.md` cites "Retained nodes" for the placement guarantees. `motion.js`'s header loses the same stale restored-state clause. `tests/runtime/widget-api.test.mjs` let `readingRegion(id)` through: when a following code span opened with a brace, it read the call as a method an example defines. A method head must now sit on one line; the test fails on the old reference and passes on the new one. Tests: `node --test tests/runtime/widget-api.test.mjs` and `pnpm run test:runtime` pass; pre-commit passes. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Small cleanups from the code-quality survey of the browser runtime's state, delivery and traffic code. Each removes a second writer, reader or check of something the runtime already states once.
State and delivery
data-lf-traffic'spendinghas one writer: traffic.js watches the publishedeffective.sendingfrommountApplication, painting only when the attempts change.afterEnqueueloses the presentation promise no caller read.pendingnow clears with the publication that accepts or refuses an attempt, slightly before the drain finishes settling it.admittedIdhelper states that rule forderive,nameParentandnameUndo.runtime.undoingandruntime.restoringStatego. The pending ledger already covers an undo in flight, and a gesture that leaves the ledger on accept now repaints keys on that edge. Nothing insidepaintReading's scope plays motion any more, so Expand and contain the interaction gallery #354's "a refusal's restore does not animate" was already lost; whether it should animate stays open.delivery.jsclassifies an/api/eventanswer once (readEventAnswer) for both senders, and its four retry tails are oneretry().state-feed.jsreleases its read slot in one place and names the quiet-feed guard; the reading's own completions keep their narrower guards.onDeferredReadypresents and releases directly, including when the release lands during a state application (the pass queues behind it).Leaf-View-Revisionheader, guards on aResponsean awaited fetch always returns, anovertakencheckcanAdoptrepeats, andquestionsdefaults inqueues.js.Requests
layer-client.jshas one JSON request primitive,requestJson, used by the file API, deferred data values, media upload and samples. Behaviour changes: sample allocation and release are now layer-admitted (a stale-layer allocation reloads instead of failing as "The sample document did not start Leaf", and a refused key there is observed); a non-JSON body fails as<what>: HTTP <status>rather than aSyntaxError; upload and deferred-value fallbacks read "image upload: HTTP n" and "deferred value: HTTP n", and a deferred value refused for another layer says "Leaf's layer changed while requesting deferred value".storage.jsreads the served delivery script once (DELIVERY,WEBSITE_DELIVERY,layerRoot), replacing four selectors and two derivations of the layer root. Thescript[data-lf-entry]seam harnesses use is unchanged.Presentation
other_leavesdrops closed neighbours, so they stop travelling in/api/stateand the Leaves drawer no longer filters them. The Python neighbour fixture becomes a waiting page.questionItempicks its subject andendsin one switch.pageShifteda second time; its synchronous layout pass stays and is documented.API surface
widget-api.jstocheck-api.js, which every probe may now import;application.js'sshallowSigstrampoline goes.Not done: the probes' JSON-body fallback for a probe without
Leaf-Layerstays.live_shell.pysays a static host may serve the derived tree, andtest_a_failed_bootstrap_hears_a_static_registry_generationholds that a headerless static host can supervise startup, so removing it would drop that support.