Repository navigation
Cut Python rechecks a stronger mechanism already enforces, and refuse a reply to a withdrawn message - #2507
Merged
Conversation
… a reply to a withdrawn message Code now handles the input its contract describes and lets the schema, parser or producer already in the path refuse the rest: - The kernel schema owns a start's one-line text, now for a progress reply's `start` too; `start_line_error` and its call sites go. `task open` on a thread subject, a pickup phase, `leaf wait`'s PAGE/--ack, a deferred record's shape, an unresolvable data-contract $ref, JSX in a page module, the App Server endpoint alias, the interaction entries' dict check, and the user-view JSON round trip each restated a stronger check and go. - Position ranks and the identities an action depends on are `pattern` and `minLength` in `detail_schema`, and `RANK` lives beside it. - The layer's `$` facts are validated by one `LAYER_FACTS_SCHEMA`; code keeps only cross-references, `when`/contract schema checks, JMESPath, and refs. Error wording is now the schema's. - `fcntl` is imported plainly; Leaf runs only where it exists. - `anchor_capture` refuses a quote the version doesn't show with one message, keeping the retired/gone section refusals; `passages` drops the readings only those explanations used. - `leaf data set` lets `json.loads` refuse empty input. - `activity._moment` reads Leaf's own `now_iso` stamps without a fallback. - The interaction log reader trusts its two validated writers: it skips a torn line, dedupes retries, marks gaps and reassembles parts. - `delivery.pending_batches` goes; its callers read `hook_transport.read_plans`. - `leaf codex run` always takes `--handshake`; the foreground tests use it. Bug fixed: a reply to a withdrawn reaction was admitted and opened a phantom thread. The append door now refuses a parent that has been taken back, and undo refuses to withdraw a reaction any message (a reaction included) stands on, so every standing message's parent stands. With that, the fold's recovery for a thread whose opening line was torn is unreachable and goes, with its tests. Behavior changes users can see: refusal wording for start lines, anchors, data set, layer facts, ranks and task-open on a thread; a reaction to a reaction now blocks withdrawing the parent. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ction root The anchor test that moved a withdrawn reaction's thread pinned the phantom thread the door now refuses; it asserts the refusal instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The rank pattern moved into the detail schema, where jsonschema searches a pattern with Python's re, whose $ matches before a final newline; end it with a lookahead both runtimes read as end of string, and hold the schema to the shared rank cases. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… end layer names strictly - `detail_schema` puts a custom verb's nonempty-unit rule into the unit's own declaration instead of an `allOf` around the detail, which moved the base a `#/properties/…` reference in the detail resolves on (PointerToNowhere at the append door). - `LAYER_FACTS_SCHEMA` accepts `records: null`, as the hand check it replaced did and every consumer reads as absent, so a same-protocol page another Leaf vendored stays readable. The other optional fields refused null before too. - Token and contract names end with `(?![\s\S])` rather than `$`, which Python's `re` matches before a final newline: they replaced `fullmatch` checks, and "keep\n" passed into an admitted reaction. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
reviewed
Oct 12, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
A split interaction record can still be admitted with arbitrary json fragments. A one-part record whose fragment is not json passes client_records, but leaf page interactions now raises JSONDecodeError while reading the log, hiding its diagnostics. Reassembly needs to validate the completed record and keep a malformed group readable as an interaction_invalid diagnostic.
…ins into nothing - `detail_schema` reads a custom verb's unit declaration with `.get`, so a detail that declares no properties (a hand-built registry) still gets the nonempty unit rule rather than a KeyError. - The progress and task-open refusal tests assert the schema's refusal, not the explanations the commit before removed. - docs/event-log.html's captured log carries the door's records as they now stand: an admitted definition records `minLength: 1` on each identity field. Its notes move to the lines the test names. - The website timing fixture wrote progress whose parent its log never held, a state no admitted path produces; it now holds that other input's comment. - The browser test serving a log with a torn opening line pinned the recovery the fold no longer carries; with no writer able to produce that log, it goes. - The interaction reader marks a split record whose parts join into no valid entry as `interaction_unreadable` instead of raising: ingress checks each part, not what they join into, and one bad group took down every diagnostics read. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # docs/event-log.html # skills/leaf/scripts/leaf/tasks.py # tests/test_interact_server.py # tests/test_tasks.py
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…s new caller needs Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ne they name Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 12, 2026
This was referenced Oct 12, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
…is not input (#2556) Most of what the complication-weight sweep cut (#2500, #2507, #2555) was a reader re-checking a value another Leaf module produced, as if it came from outside: the browser re-validating the server's answers, the Worker the manifest its own build wrote, Python the rules admission already enforced. AGENTS.md's "Validate once and share readings" names the boundaries but not which seams aren't one. This adds that to "Let the agent correct its own input" in `/developing-leaf`, with the one exception (records an older Leaf left in the state home) and the matching rule for recovery from states no Leaf writer produces. **Scored before landing** (scratch A/B, the section with and without the paragraph, `claude -p` with no tools): both arms passed every case, so the paragraph shows no measurable change on cold prompts — a browser reader of a server answer (7/7 each arm, with and without the user's global instructions loaded), the same reader written beside a neighbour that over-validates (8/8 each), an unproducible-state recovery (3/3 each, "leave"), and a control where a package-supplied anchor identity should keep its check (3/3 each, "refuse"). The control shows the rule doesn't over-apply. It lands as the statement reviewers and later sweeps can cite; the defensive code it describes accumulated in incident fixes the cold cases don't reproduce. > _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
JSON Schema defines `pattern` as an ECMAScript regular expression, and the browser reads it that way, but jsonschema searches it with Python's `re`, whose `$` also matches before a final newline. So every `^…$` pattern at every Leaf boundary admitted a trailing newline: `"abc\n"` passed `^[a-z]+$` for element ids, reaction tokens, data-contract names and the rest. #2507 hit this and ended three patterns with a lookahead; this fixes it where every reader gets its validator. - jsonschema has no option for another regex engine; its keywords make one call, `re.search`, in two private modules (`_keywords`, `_utils`). `registry/schema.py` points that call at [regress](https://pypi.org/project/regress/), an ECMAScript engine (Rust, compiled), with the `u` flag JSON Schema recommends. That covers `pattern`, `patternProperties`, and the `additionalProperties`/`unevaluatedProperties` accounting built on them, in every validator, a nested `$schema` included. A call jsonschema later adds to those modules fails loudly rather than reading Python's dialect; `uv.lock` pins the version the suite passed on. - `check_schema` holds the metaschema's `regex` format to the same engine, so an ECMAScript pattern Python refuses (`\p{L}`, `(?<name>…)`) is admitted and a Python-only one (`(?P<name>…)`) refused. All 40 distinct patterns in the tree compile. - The three `(?![\s\S])` workarounds from #2507 are plain `$` again, and `registry/layer.py`'s one direct `Draft202012Validator` goes through `json_validator`. - New runtime dependency `regress>=2026.9`, documented in `pyproject.toml` beside `ada-url`. **Behavior change:** a string with a trailing newline no longer passes an anchored pattern, and a registry declaring a Python-only pattern is refused at `page check`/`package check`. > _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]>
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.
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
parentagainst 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_errornow refuses a withdrawn parent, andUndoReadingcounts 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 frombuild_threads,seat_root,thread_contextandlogged_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, theUnresolvablecatch, the JSX refusal (the browser check reports it), thecheck_app_server_endpointalias, the entries-are-dicts check and theuser_viewsJSON round trip (nowdeepcopy) go.#20: the
fcntlImportError fallback goes; Leaf runs only on POSIX and a plain import fails as early.#21:
capture_anchorrefuses a missing quote with one message instead of diagnosing fences, removed words and data bodies (the retired- and gone-section refusals stay);leaf data setno longer explains empty stdin;task openno longer explains a thread subject the schema refuses.#22, #24:
activity._momentstops 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 asinteraction_unreadable(ingress checks each part, not the whole).Rules moved to their owners (#30): the layer's
$fact shapes are oneLAYER_FACTS_SCHEMA, leaving only cross-references and what a schema can't say in code;delivery.pending_batchesis gone forhook_transport.read_plans;codex run --handshakeis required; theRANKpattern and identity fields' non-emptiness are indetail_schema. Patterns that replaced afullmatchend with(?![\s\S]), because Python'srelets$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.