Skip to content

Flatten a declaration's facts, recognise a conditional fact by its shape, and give $marks.paint and $state names of their own - #6257

Merged
max-sixty merged 9 commits into
mainfrom
agent-ab7551a1997b1db38
Nov 17, 2026
Merged

max-sixty merged 9 commits into
mainfrom
agent-ab7551a1997b1db38

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

A widget's registry entry now holds every fact beside description, attributes and content, with no group objects, as Max chose after a design review of #6234. The PR also carries four smaller fixes from that review.

The flat declaration

Each fact keeps its own shape and loses only its group: state.verbs is verbs, data.inputs is inputs, author.example is example, words.word is word. lf-options on main and here:

"lf-options": { "description": …, "attributes": …, "content": "members",
  "state": { "awaits": …, "verbs": … }, "author": { "instructions": …, "example": … } }

"lf-options": { "description": …, "attributes": …, "content": "members",
  "awaits": …, "verbs": …, "instructions": …, "example": … }

The 29 fact names are all distinct (encloses left with lf-ask in #6256), and none is description, attributes or content. Readers use plain property access (entry.get("verbs"), entry.verbs), so declared_fact, declaredFact, FACT_GROUPS, the group-path joins in DECLARATION_KEYS and the _facts helper are gone. $marks is keyed by fact name. The {when} form, and the import-time refusal of it on a fact that isn't a mark, read flat names.

The needs table and its needs-fact finding are gone too. The declaration schema now says it with dependentRequired: retired-when needs owners, and shows needs owners and refers. The refusal reads:

main:  registry.json: <lf-old> state.retired-when needs markup.owners
here:  registry.json: <lf-old> is not a valid declaration ($keys): 'owners' is a dependency of 'retired-when'

A declaration refusal names where it points. invalid-declaration adds the path the schema's words leave out, and findings that name a fact by its key mark it as code:

main:  <lf-activity> is not a valid declaration ($keys): 'top' is not one of ['start', 'end']
here:  <lf-activity> is not a valid declaration ($keys) at `bound`: 'top' is not one of ['start', 'end']
main:  <lf-log> is not a valid declaration ($keys): Additional properties are not allowed ('bound' was unexpected)
here:  <lf-log> is not a valid declaration ($keys) at `views`: Additional properties are not allowed ('bound' was unexpected)

A fact left in its old group, a misplacement at the top, reads the same on both: Additional properties are not allowed ('paint' was unexpected).

Smaller shape fixes. Every flag fact is const: true (exhibit, verbatim, shadow and inline were booleans no declaration wrote false to), and exhibit keeps its {when} form. shows names the attribute naming its widget reference, as an input's reference does; both are an attribute refers declares.

What {when} conditions. A reader asking of one occurrence reads a fact through holds_for: delivery's paint, and for exhibit the quoting (input, admission, compound membership). A reader asking whether the tag declares the fact reads the declaration: for exhibit, whether widgets inside put anything on On Me (obligations.shown_in). An interactive sample needs the two apart, since its widgets take input and ask nothing, so exhibit stays one fact and $keys.exhibit, holds_for and the schema now say which reader asks which.

$keys is flat and carries no layout. It is keyed by fact name, and its members run in the site reference's order. The reference's section headings (State, Structure, Words, Paint, Data, Authoring, and Element over attributes and content) live in dev/leaf_dev/docs.py (KEY_SECTIONS), each placed before the key it opens on with one line on who needs its keys declared; docs.py refuses a section that opens on a key $keys doesn't document. Sections are h3 headings over h4 key entries. Each entry's anchor is the fact's name (/extending/#verbs), each section's keys-<title>.

Every registry in the tree is flattened: the bundled packages, the examples' page-owned registries, the fixtures, and the JSON in the references, site pages and eval cases. No dotted fact path is left anywhere. Bare paths in prose became the fact's name in code formatting, and a parenthetical that only repeated its word ("verbs (state.verbs)") became the name alone. No page protocol bump, as with #6234: a page's own page/registry.json in the grouped shape fails page check with invalid-declaration.

The four earlier fixes

  • A conditional fact is recognised by its shape, {when: {attribute: [values]}}, in holds_for and holdsFor. Delivery, the browser's message paint and the condition check apply it to every mark, so the three lists naming exhibit and flow are gone. Only a mark may take the form, and leaf.schema fails at import when a fact $marks doesn't name takes it.
  • Two renames. The $marks member naming each mark's DOM attribute is attribute (was paint), and the layer fact documenting a verb's fields is $verbs (was $state), as $awaits documents awaits.
  • Two lists. The key table in src/leaf/passages.py's header and the bullets in aimableAt's comment are lists again.
  • The option guard. The 21 live-group guards in packages/default/styles/options.css are weightless, :not(:where([data-lf-exhibit]) *), as board.css and draft.css write them. The two competitions their weight decided now say so where they happen: a picked card's caption room takes the card rule's weight (:where([selected])), and a top: 8px the live seat always overrode is deleted. Every computed property of every option group and each element and pseudo-element in it matches base on feature-gallery, alert-review and ship-review, at rest and in nine other states, except top on the key-badge spans paper hides.

Calls to reverse

  • The reference's sections are placed by the key each opens on, so a key added to $keys falls in the section before it; an Element heading covers attributes and content, which no section held.
  • exhibit keeps both meanings in one fact; splitting asking from quoting would add a fact for the interactive sample alone.
  • $states, composition's stamp of each verb's writer and definition, keeps its name: it belongs with state_definition, stampedState and sameStateDefinition.
  • The schema of the verbs map is VERBS_SCHEMA (was STATE_SCHEMA).
  • The schema names each fact that takes {when} rather than letting any boolean mark take it, since verbatim and inline have readers outside delivery that would each need holds_for first.

Checks

  • pnpm run check: pass (1,006 runtime tests).

  • uv run pytest tests/model -n 4: 3,612 passed.

  • Browser, by file or node id: the three option files, obligations, tabs, sample delivery, live samples, render gate, revision delivery, workspaces and bounds, the message-mark, bounded-reply and inline-suggestion tests, and the 78 browser tests whose body or fixture the flattening changed: 373 passed, 4 xpassed. Two fail, and fail the same way on a snapshot of main: test_the_state_wait_covers_a_status_that_moves_neither_log_nor_data (the leaf reads "Claude awaits" where the test expects "Ready") and test_a_tab_strip_is_named_as_the_chrome_names_its_set.

  • tests/journeys/widgets/test_pressed_controls.py, all 16 packages' params: pass. Its page script had read ?.state?.verbs, which the optional chain hid; it reads ?.verbs now.

  • page check on all 55 authored sources and product documents, built as pages: pass.

  • leaf package check --render on the 13 bundled packages with a registry: status 0; the 12 keeps-first-box advice findings (diff, playground, timeline) are the same on base.

  • A tree-wide search finds no dotted fact path. Its three matches name other things: CodeMirror's markup.inline scope, a message event's event.data.height, and the Python call words.says(event).

  • Evals, Claude Code, head beside main, two runs each: package-text-widget-keeps-the-measure, recorded-effect-payloads and widget-checked-before-handoff pass 6 of 6 on each arm, $3.06 for the authors. In the two cases whose answers write declarations, every head answer writes the flat shape (verbatim and verbs beside attributes, no group object) and every base answer the grouped one; widget-checked-before-handoff answers write none.

  • Independent Codex reviews of each round found no issues; the schema and independent reviews' findings are folded in.

  • After the review fixes: tests/model 3,614 passed, pnpm run check passed, page check on seven sources with their own registries or the reference passed, package check --render on default, playground, diff and reading unchanged, and the board, sample and message-mark browser tests passed.

  • The option-guard proof, the {when} import check and the earlier rounds' checks are in the commits.

  • After merging main through Keep "group" for a question's group, check each group once, and keep a page tab's end room #6284 (Name a question by the group its author declares, and retire lf-ask #6256 retired lf-ask and encloses): pnpm run check passed (1,007 runtime tests), tests/model 3,615 passed, the obligation, option, sample, pressed-controls and message-mark browser tests and the browser tests Keep "group" for a question's group, check each group once, and keep a page tab's end room #6284 changed passed, and page check on seven sources and package check --render packages/default passed. Everything main added is flat, including a new runtime test's fixture, and no dotted fact path is left.

Not run: the rest of tests/browser, the journeys tier, Codex evals, Firefox.

This was written by Claude Code on behalf of max-sixty

…e and the verb fields for what they hold

Four follow-ups to #6234's grouped registry.

A fact declared `{when: {attribute: [values]}}` is now recognised by that
shape in one place per runtime: `registry.contract.holds_for` (with
`fact_condition` for the condition) and `holdsFor` in `registry.js`.
Delivery's `mark_declared`, the browser's `markDeclared` and the predicate
validator apply it to every mark in `$marks`, so the lists naming
`state.exhibit` and `paint.flow` are gone, and the browser's message paint
no longer knows only `state.exhibit`. The declaration schema still says
which facts may take the form: `_conditional` wraps `paint.flow` and
`state.exhibit`, and only a mark may take it, since its non-mark readers
would read the condition as true.

`$marks` names each mark's painted DOM attribute `attribute`, not `paint`,
since 7 of its 13 marks are facts outside the `paint` group. The layer fact
documenting a verb's fields is `$verbs`, as `$awaits` documents
`state.awaits`. `$states`, composition's stamp of each verb's writer and
definition, keeps its name: it belongs with `state_definition`,
`stampedState` and `sameStateDefinition`, the verb's state definition an
admitted event records.

The key table in `passages.py`'s header and the bullets in `aimableAt`'s
comment are lists again.

`options.css`'s 21 live-group guards are weightless again,
`:not(:where([data-lf-exhibit]) *)` as `board.css` and `draft.css` write
it, rather than carrying the weight `[choose]` used to give. The two
competitions that weight decided now say so where they happen: a picked
card's caption room takes the card rule's weight (`:where([selected])`), so
a live card's padding replaces it, and the titled card's `top: 8px` on its
key badge, which the live seat's `top` always overrode, is gone. Every
computed property of every option group and each element and
pseudo-element in it matches base on feature-gallery, alert-review and
ship-review at rest, and on feature-gallery picked (titled and bare),
opened settled, under keyboard focus, touch, dark, with a picked quoted
card and on paper, except `top` on the key-badge spans paper hides
(`display: none`).
Only a mark has its `{when}` painted where it holds and its condition held
to the declared attributes, since the condition check loops over `$marks`.
A non-mark fact wrapped in `_conditional` would have gone unchecked and
reached its readers as an object that reads as true. `leaf.schema` now
fails at import when a fact in `FACT_GROUPS` takes the form and `$marks`
doesn't name it, so the rule is structural rather than a docstring's.
Wrapping `state.encloses` raises "only a mark ($marks) may take the {when}
form: ['state.encloses']".
…d content

A widget's registry entry holds every fact beside `description`,
`attributes` and `content`, with no group objects, as Max chose after
the design review of #6234. Each fact keeps its own shape and loses only
its group: `state.verbs` is `verbs`, `data.inputs` is `inputs`,
`author.example` is `example`, `words.word` is `word`. The 30 names are
distinct, and none is `description`, `attributes` or `content`.

Readers use plain property access, so `declared_fact`, `declaredFact`,
`FACT_GROUPS`, the path joins in `DECLARATION_KEYS` and `_facts` go. The
needs table and its `needs-fact` finding go too: the declaration schema
says it with `dependentRequired` (`retired-when` needs `owners`, `shows`
needs `owners` and `refers`), refused as `invalid-declaration` with
"'owners' is a dependency of 'retired-when'". `$marks` is keyed by fact
name, and the `{when}` form and its import-time rule read flat names.

`$keys` is flat and keyed by fact name, in the site reference's order. A
`sections` member, documentation only, gives each section's title, the
key it opens on and the description its group entry carried; the lint
skips it as it skips `description`, and `docs.py` renders a section entry
before each one's first key. Reference anchors are the facts' names.

Every registry, fixture and JSON example in the tree is flattened, and no
dotted fact path is left: in prose each became the fact's name in code
formatting. `STATE_SCHEMA` is `VERBS_SCHEMA`, after its fact. No page
protocol bump: a page-owned registry in the grouped shape fails `page
check` with `invalid-declaration`.
@max-sixty max-sixty changed the title Recognise a conditional fact by its shape, and give $marks.paint and $state names of their own Flatten a declaration's facts, recognise a conditional fact by its shape, and give $marks.paint and $state names of their own Nov 17, 2026
…ntrols journey

The journey's page script asked `declarationFor(…)?.state?.verbs`, which
the flat declaration never holds, so the optional chain read every press as
sent and the playground's second press failed as sending nothing. It reads
`?.verbs` now. A search of tests, dev, hooks, packages and browser for other
optional- or get-chained group reads found none.
…s sections in the docs

Fixes from the schema and independent reviews of the flat declaration.

An `invalid-declaration` refusal now says where in the declaration the
value it refused stands, which the schema's own words leave out:
`<lf-activity> is not a valid declaration ($keys) at `bound`: 'top' is not
one of ['start', 'end']`, and `at `verbs.pick.detail`` for a verb detail
missing `additionalProperties`. A misplaced fact at the top, such as one
left in its old group, keeps the schema's words, which name it. Findings
that name a fact by its key mark it as code, since a flat name such as
`says` read as English.

The reference's six section headings move out of the registry into
`dev/leaf_dev/docs.py` (`KEY_SECTIONS`), each placed before the key it
opens on with one line on who needs its keys declared, plus an Element
heading over `attributes` and `content` so no key sits under no heading.
`$keys` carries no layout again: the lint's `sections` skip and the
reserved name go, so `$verbs.sections` and a section naming an unknown key
can no longer pass. Sections are h3 headings with the keys as h4 entries
beneath them, rather than rows beside the keys.

Every flag fact is `const: true`: `exhibit`, `verbatim`, `shadow` and
`inline` were booleans, though no declaration wrote `false` and readers
test truthiness. `exhibit` keeps its `{when}` form.

`{when}` is now described as it behaves. A reader asking of one occurrence
reads a fact through `holds_for`: delivery's paint, and for `exhibit` the
quoting (input, admission, compound membership). A reader asking whether
the tag declares it reads the declaration: for `exhibit`, whether widgets
inside put anything on On Me (`obligations.shown_in`). The interactive
sample needs the two apart (its widgets take input and ask nothing), so
the fact stays one; `$keys.exhibit` says which reader asks which.

`shows` names the attribute that names its widget `reference`, as an
input's `reference` names the element it reads; both are an attribute
`refers` declares.
# Conflicts:
#	browser/registry.json
#	browser/runtime/declared-words.js
#	browser/runtime/obligations/view.js
#	browser/runtime/thread/messages.js
#	browser/runtime/widget-elements.js
#	browser/types/contract.d.ts
#	packages/deck/registry.json
#	packages/default/registry.json
#	packages/default/styles/ask.css
#	packages/playground/registry.json
#	skills/leaf/references/module-reading.md
#	skills/leaf/references/package-data.md
#	src/leaf/findings.py
#	src/leaf/obligations.py
#	src/leaf/registry/widgets.py
#	src/leaf/schema.py
#	src/leaf/validation/admission.py
#	src/leaf/validation/instances.py
#	tests/browser/test_render_anchors.py
#	tests/browser/widgets/test_obligations.py
#	tests/model/test_interact_product.py
# Conflicts:
#	browser/registry.json
#	browser/runtime/thread/messages.js
#	packages/default/registry.json
#	skills/leaf/references/package-data.md
#	src/leaf/gesture_words.py
#	src/leaf/validation/instances.py
@max-sixty
max-sixty marked this pull request as ready for review November 17, 2026 09:36
@max-sixty
max-sixty merged commit f17c5f6 into main Nov 17, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-ab7551a1997b1db38 branch November 17, 2026 10:00
max-sixty added a commit that referenced this pull request Nov 21, 2026
Main dropped the `x-` prefix and flattened a widget declaration (#6234,
#6257), so the branch's keys move with it: an input lives under `inputs`,
an output under `outputs`, a relation under `refers`.

Two of the branch's additions go in the port, to keep the declared
interface as small as #6134 left it:

- `x-commands` and its check are gone. A widget names the custom
  commands it handles in its `instructions`; `page check` no longer
  refuses a `commandfor` with no target or an undeclared `--` command.
  The wt-merge film still takes `--seek` from its steps' buttons.
- The `body` flag on an input is gone. A `content: data` widget's `<pre>`
  stands in for its input that names a `source`, since that is the input
  an authored value could replace; an input bound only by reference, as
  lf-code's `playhead` is, leaves the `<pre>` alone. Python's registry and
  markup checks and the browser's first read follow the same rule.

Main's new output readers, lf-text-document and lf-file-tree, drop their
`output` name and bind their producer's one output of the contract, as
the branch does for every reader. lf-code keeps main's wrapping and notes
toolbar, and the playhead mark takes the theme's prefixed accent tokens.
`notes/named-widget-interfaces.md` stays as main has it, since #4065 was
closed as postponed with that note as its plan.
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