Repository navigation
Store only derived meaning, fold fragments into records, and move patch parsing to the diff package - #1082
Merged
Conversation
An action's or report's meaning repeated the event's own widget and verb in
`coordinate` and its revision in `document`, and `stored_meaning_error`
recomputed the whole meaning at every re-vendor to check the copies still
agreed. Meaning now holds `document` ("page" or "thread"), `unit`, `depends`,
and `creates`/`answer` where they apply; `events.event_coordinate` and
`events.event_document` rebuild the coordinate and seat document from the
event. Requests store the same `document` string beside their `unit`.
The stored meaning is the one mechanism that fixes admitted identities, so the
recompute check goes. What a re-vendor could still change is the declaration
folds read a standing command through, and `admitted_contract_error` keeps
that check (record form, creates, update field, request binding). Seed logs,
the how-it-works delivery sample, the `$events` schemas, and their snapshots
move to the new shape; thread seeding no longer rewrites a copied revision.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`fragments` was `records` plus one payload field, declared beside it with a
rule that the two agree and a `records or fragments` fallback at each reader.
A contract now declares `records: {items, key, deferred?}`; `deferred` names
the row field `/api/state` omits and `loadDataFragment` fetches on demand.
The registry door, source validation, contract-lifetime check, request rows,
and the browser loader read the one declaration. The construction reading of
such an input moves from `fragments` to `deferred`, and value errors say
"record" rather than "fragment item".
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Core data.py carried about 250 lines of Git patch parsing for one package's contract, and `data capture --lines` sliced text for another. Both are producer work, so core keeps one write, `leaf data set`. The patch parser is now `packages/diff/scripts/patch_manifest.py`, a uv script that declares unidiff inline, reads a patch on stdin, and writes the `unified-diff` manifest for `leaf data set`, refusing unsupported entries on stderr with exit 1. The contract's producer guidance names it, a package's `scripts/` directory is documented as never vendored, and unidiff leaves the plugin's own dependencies. Text excerpts are `sed -n | jq -Rs .` piped into `data set`; the references and the CallDiff guidance say so. Example companions keep `$captures`; the fixture reader now resolves each one to a value (running the package script for a patch) and every builder sets it with `data set`. The capture CLI tests become tests of the script and of setting its output. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`files.revision_name`, its only caller of `revision_digest`, and `files.latest_published` had no callers. `files.write_revision` and `render_gate.scheme.recurring_resize_observer_error` were called only by the suite, which now owns them: the revision shortcut lives in interact_support and the recurring-notice message is render_harness's own constant, since the harness both writes and asserts it. No product behavior moves. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Stored meaning, records.deferred, and the diff package's patch script landed in the commits before this one; the note keeps the undo/restated/settles relation and the row, position, staleness, and read-cost findings. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/scripts/leaf/gesture_words.py
# Conflicts: # examples/developer/feature-gallery.jsonl
A re-vendor that changed a verb's x-state `unit` passed the admitted-contract check once the recompute went, yet the unit decides the shape the browser and history folds give that verb's state. `admitted_contract_error` now compares it beside the record form, and the dependency test flips it. Producer guidance named the diff script under `<skill-dir>`, which only an agent that loaded the Leaf skill can resolve. Guidance now writes `<leaf-packages>`, and `leaf page guidance` prints it as this install's bundled packages directory, so a worker can run the command as printed. packages.md says `scripts/` exists only in bundled packages, since neither a page nor `package install` copies it. authoring-evidence.md drops its copy of the patch pipeline and points at the producer guidance that owns it. `@cache` returns to `model_layer` in interact_support, where the previous commit's `write_revision` insertion had displaced it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 24, 2026
This was referenced Sep 24, 2026
max-sixty
added a commit
that referenced
this pull request
Sep 24, 2026
…rb's writer once (#1101) This finishes cut-overs that #1076, #1082 and #1091 left half done, as found in a review of those PRs. **`meaning.scope` replaces `meaning.document`.** - Before, "document" named two shapes: the stored `"page" | "thread"` and the `{kind, revision}` identity that requests, lifecycle seats and the runtime use. - Admission now stores `meaning.scope`. - One helper, `events.document_identity(scope, revision)`, builds the identity. `event_document`, admission's request check and the served request readings all use it. The two direct reads of `meaning["document"]` now go through it too. - *Contract:* the `$events` meaning schemas and `handling` `when` clauses, `events.md`, the seed logs, three snapshots and the delivery sample in `how-it-works.html` are updated. Each snapshot diff is only the rename. **One word for deferred payloads.** The contract already said `records.deferred`. The door and the API now say it too: - `data_fragment` → `deferred_value`; - `/api/data` → `/api/deferred`; - `loadDataFragment` → `loadDeferred`; - the error strings; - `packages.md` and `page-storage.md`. **The writer is resolved once.** - In Python, `state_specs(entry, writer=…)` filters by writer, and `verb_writer(spec)` answers for one verb. The five call sites that restated "absent means user" use them. - In the browser, `registry.adoptRegistry()` sets `writer` on every `x-state` verb when the vocabulary arrives, so `stateSpecs`, widgets and the command hub read one value. **Created children.** - `gesture_words` and the version gate take a created child's tag from `meaning.creates` rather than re-deriving it. - `passages.shown_words` is now the one reading of a created child's `x-text-format`, used by passage capture, the gate and gesture wording. **`example_data.captured_value`** refuses a `lines` range on a `unified-diff` capture instead of silently ignoring it. **The event-log page.** Its captured records are regenerated for `scope`, the note anchors follow them, and the note on `meaning` names `scope`. **Tests.** Everyday suite on the merge with main: 1364 passed, and one failure under parallel load that passed alone. `npm run test:runtime`: 91. `check:browser` clean; `test:browser` 64. A nightly subset over diff, data, deferred, request, receipt, create, writer and report passed 303. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > _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
Sep 24, 2026
…line (#1097) Fixes from a review of #1082, which moved git patch parsing into a script the diff package ships. **`leaf package run PACKAGE SCRIPT [ARGS]...` replaces the `<leaf-packages>` placeholder.** - **The problem:** #1082 had `leaf page guidance` globally replace `<leaf-packages>` with the bundled packages directory. That worked only for bundled packages, hard-coded the package's own directory in its guidance, and printed an unquoted machine path. - **The door:** it finds the package with `named_package`, the same lookup `page init --package` uses, so installed packages work too. It then execs `uv run --quiet --script <package>/scripts/SCRIPT ARGS`, which leaves stdin, stdout, stderr and the exit status to the script. - **Guidance:** it now reads `git diff … | leaf package run diff patch_manifest.py | leaf data set "$PAGE" <source-id>`. It names a package and a script and prints no path, so there is nothing to substitute or quote. - **Install:** `package install` copies a package's `scripts/`, so a third-party package can ship producer tools. Pages never vendor `scripts/`. - **Script check:** `package check`, and therefore `install`, refuses a script without a PEP 723 header, whose script would otherwise run in the caller's project environment, and a dependency or `requires-python` that is anything but a floor. Reading the header adds `packaging` (and `tomli` before Python 3.11) to Leaf's runtime dependencies. `uv run --no-project` does not isolate a headerless script, so the check is the one mechanism. **The everyday suite runs offline again.** - **What broke:** since #1082 the patch tests ran `uv run patch_manifest.py`, which needed the network on a cold cache, while `tests/AGENTS.md` promises the suite needs none after setup. - **The fix:** `unidiff` joins the dev group, so `uv.lock` pins what the suite runs, and the tests run the script under the project's Python. - **A guard test** requires every dependency a bundled script declares to be in the dev group. - **Hosts:** package scripts declare floors with no cap and ship no lock, so a host resolves them on its first `package run`. Root `AGENTS.md` states this. **`leaf data set` refuses empty input.** When `patch_manifest` refused a patch, `data set` then printed `invalid JSON (Expecting value…)` for its empty stdin. It now says no value arrived on stdin and that the command piped into it likely failed. **Tests.** - New tests cover: - the door, run against an installed package: stdin, arguments, stdout, exit-status pass-through, and the unknown-package and unknown-script refusals; - the empty-stdin refusal; - the dev-group guard; - six malformed scripts that `package check` and `install` refuse. - The patch tests pass with `UV_OFFLINE=1` and an empty uv cache. - Everyday suite, on the merge with main: 1373 passed. - `npm run test:runtime`: 91 passed. The nightly diff tests (12) and `test_site.py` (49) passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > _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 11, 2026
lf-diff had two render pipelines: `render` for a patch text (inline or bound) and `renderManifest` for a file manifest. Each built its own entries, controls, staging and projection, so every fix had to land twice (#2125 brought the text path level with the manifest path). Now every source form becomes one list of per-file records shaped like the contract's manifest, and one plan/prepare/apply path renders them all. - **One pipeline.** `sourceRecords` parses a patch text once and gives each record its parsed file; a manifest is already that list. `prepareEntry` reads an in-memory record's file and fetches a manifest record's patch with `loadDeferred`. A single `fileEntry(row)` replaces the three entry literals. One `projectFiles` takes its origin from the source form: `files[i].path`/`files[i].patch` for a manifest, the whole delivery for a bound patch text, and none for an inline patch. The record now paints each file's summary, so `renderFile` returns only the evidence that goes under it. - **Behavior change: collapsed files render lazily in every form.** A closed file in an inline or bound patch text now renders when it opens, as a manifest's file already did. Until then, `lfDataDatum` resolves its lines to the file row, and a reveal or hunk walk opens and loads the file. A render failure inside one file shows that file's error box, as a manifest file's load failure already did, instead of failing the whole widget. - **The contract states the manifest's rules.** `records.key` is now `path`, and the redundant `key` field is gone from the schema and from `patch_manifest.py`. `files` requires at least one record, and a rename record requires `previousPath`. `data set` therefore refuses `{"files": []}`, duplicate paths and a rename with no source path, and the widget's own shape checks are deleted. A patch text that repeats a path is refused the same way, with "unified diff repeats file path". - **Failure box.** `failSoft` receives the source only when it is patch text, so a manifest failure no longer prints `[object Object]`. - **Inline lazy loads survive a reconnection.** An inline diff keeps its entries when it reconnects. A load abandoned by a disconnect is tied to its render, so opening the file again starts a fresh load. The JavaScript patch validator stays in the widget; #1082 deliberately took patch parsing out of core. This change touches none of the runtime files that #2287 edits, and `test_a_scroll_box_inside_a_widgets_shadow_tree_takes_the_keyboard` fails on main until #2287 lands. Tests: the lf-diff selections in the widgets, anchors, projection and threads render files pass (88), and so do the other 155 tests that mention lf-diff or the manifest, apart from the reach test above. The test changes: manifest fixtures drop `key`, a new test covers the three contract refusals, a repeated-path refusal joins the rejection cases, and the collapsed-diff test asserts that lines render only on open. > _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
…d input to the agent (#2487) Some widgets enforced rules their data contracts did not state, so `leaf data set` stored values the page then failed on. Each such rule now lives in the contract, checked at the boundary, and producers stop diagnosing malformed input the consuming agent can see fail on its own. **Rules moved into contracts** - **visual-review:** the `visual-run` contract declares `records: {items: "cases", key: "id"}`, so `data set` refuses a run that repeats a case id. The widget's own "visual run repeats a case id" throw is gone, and with it `test_visual_review_recovers_from_rejected_cases`, which reached the failure view only through that guard. - **`format: uri` was never checked.** jsonschema checks `uri` only with the optional rfc3987 package, so the `uri` fields in `visual-run` and `playwright-trace` accepted anything; `http://a.test:99999/` reached lf-visual-review's `new URL` and threw. `registry/schema.py` now checks `uri` with the new runtime dependency `ada-url` (Ada, the WHATWG URL parser Node uses), so `data set` accepts exactly the URLs the browser parses. A new `check_schema` refuses any `format` Leaf has no checker for, at every registry schema check. - **Which language a filename means:** the file editor reads `langForPath` instead of its own `/\.(md|markdown)$/` regex, and `$languages.paths` maps `markdown`, so lf-diff and lf-code colour `.markdown` too. - `references/packages.md` tells package authors to state such rules in the contract. **One table for lf-diff's two readers.** The widget (Pierre) and `patch_manifest.py` (unidiff) both decide what lf-diff can present; #1082 keeps patch parsing out of core, so both stay. `tests/diff_patch_cases.json` is the table both are tested against, replacing each reader's own refusal list. The browser test draws every accepted row as text and as its manifest and compares file names. **Malformed input is left to the agent.** A new `/developing-leaf` section, "Let the agent correct its own input": code reads the input its contract describes and lets anything else fail where it fails, handling a malformed case only where it would otherwise pass silently into state the user relies on. Applied here: - `patch_manifest.py` goes from 302 to about 100 lines. unidiff supplies paths and counts; the script keeps only the contract's exclusions (copies, and hunkless entries other than Git's exact path-only rename, binary renames included). - lf-diff's path-only rename check now counts exact rename blocks against Pierre's hunkless renames, so a rename with missing hunk headers still fails rather than showing as a clean rename; its path decoding and header comparison are gone. - `import_trace.py` drops the type and shape checks the `playwright-trace` contract repeats at `data set`, and the archive-name, duplicate-call, parent-agreement, image-format and capture-consistency refusals. It keeps the format-9 refusal and the parentId cycle guard, which would otherwise loop forever. **Behavior changes:** `data set` refuses repeated visual-run case ids and URLs the browser cannot parse; `package check` and `page init` refuse a schema naming an unchecked format; the diff and playwright producers no longer diagnose malformed patches or traces. The ~45 registry entries restating the element-id pattern are left alone: each tag entry is one complete schema (AGENTS.md), and the creates-child check pins the canonical form where it is a cross-widget contract. > _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.
This removes four redundancies from the datastore review (
notes/datastore-review.md, "Redundancy"). Net −180 lines.Stored
meaningkeeps only what admission derived.widget,revision,generatedand the full coordinate. The coordinate is now[widget, unit, action], andwidgetandactionare top-level fields, someaningstores onlyunit, as requests already did.documentis now"page"or"thread". A page event's revision is its ownrevisionfield.events.event_coordinate()andevents.event_document()rebuild both, and every Python reader goes through them. A registry-free reader, such as aleaf events --followconsumer, still gets the coordinate from the stored record alone.stored_meaning_erroris gone. Stored meaning is itself the record of what admission derived.admitted_contract_errorkeeps the separate guarantee: a re-vendor cannot change the declaration that folds read old commands through. That declaration is the fold unit, record form,creates,updateand request binding.fragmentsfolds intorecords. A data contract declaresrecords: {items, key, deferred?}.deferrednames the row field/api/stateleaves out andloadDataFragmentfetches. Removed:fragments, its agreement rule and the fourrecords or fragmentsfallbacks. The page-state reading'sfragmentskey is nowdeferred.Patch parsing leaves core. About 250 lines of Git patch parsing and
leaf data capture,--linesincluded, are deleted from core, andunidiffis no longer a Leaf dependency.packages/diff/scripts/patch_manifest.py, a uv script with its own inlineunidiffdependency. It reads a patch on stdin and writes the manifest on stdout.git diff … | uv run <path>/patch_manifest.py | leaf data set PAGE SRC.leaf page guidancereplaces a<leaf-packages>placeholder with this install's absolute packages path, so a worker that never loaded/leafcan run it as printed.sed -n … | jq -Rs . | leaf data set.unidiffhas a floor and no cap, like the project's other dependencies. The first run resolves it through the host's index, and later runs use uv's cache and work offline.leaf data captureis gone.Dead code.
files.revision_name,revision_digestandfiles.latest_publishedare deleted. Two functions only the suite called moved into the tests.The implemented items leave
notes/datastore-review.md.Tests. Everyday suite: 1354 passed.
npm run test:runtime: 91.check:browserclean;test:browser64. A nightly subset over the diff, data, fragment, export and example tests passed 125. The documented pipeline was also run end to end on a throwaway page.An independent review found no correctness bugs in the product code. Its findings are fixed here:
🤖 Generated with Claude Code