Skip to content

Report each binding conflict once, from the gate of the document that holds it - #7235

Merged
max-sixty merged 5 commits into
mainfrom
agent-ac685bd2a2f129282
Nov 26, 2026
Merged

max-sixty merged 5 commits into
mainfrom
agent-ac685bd2a2f129282

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

leaf page check reported one data-binding conflict inside a sample twice, and the same cause misreported three other cases. A conflict exists within one document, so each document's gate now checks only the document it reads: the conflict check moves into instance_errors (markup_checks/instances.py), which every gate already runs on exactly one document: the page's source, a sample's child, a message's HTML, a fixture message, a registry example. The page's reading still descends into samples, for the data inventory only.

What an author sees now:

  • A conflict in a sample's template gives one finding, on the sample (samples=("practice",)), where it gave two (three for a sample nested in a sample). It no longer also refuses every fixture message in the template's data-sample-events as "event 2 … doesn't validate".
  • An agent's message is refused only for its own bindings, not because the saved index.html holds a conflict, which check_source checks first when a message publishes saved edits.
  • A conflict inside a message's sample names that sample.
  • A message a sample copies from a thread (data-sample-threads) is checked once more under the child's registry, at page check and at allocation alike, so a contract that changed since the message was posted refuses the sample, naming it and the copied message, rather than creating a child whose page state fails.
  • Each side of a conflict names its widget's id (<lf-text-document id=more>), so two consumers on one line are two findings an author can tell apart. A conflict's location no longer repeats the document's name, which the gate's sample '…': prefix already gives.
  • A registry example now checks the children of the samples it declares, so a widget pair that invalid-example refused written directly is refused wrapped in a named sample template too.

Codex found the double report while reviewing #7218 and reviewed this fix; its findings, among them the copied-thread case, are folded in.

Tests: new regression tests for the root, template and fixture cases on one page, for a message's own bindings, for copied messages under the child's registry, for the widget ids, and for the example's samples, each failing before its fix; lint-imports, pre-commit, and 679 covering model tests, the bundled-examples check among them.

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

…ing it

A widget pair that binds one data source under two contracts, such as
an `lf-num` and an `lf-text-document` both on `source="shared"`, is a
conflict within one document. Several gates read documents that were
not theirs, so an author saw the same conflict more than once, or saw it
blamed on something else:

- `page check` on a page whose sample template held the pair reported
  two `contract-conflict` findings: one from the page's own reading,
  which descends into samples for the data inventory, and one from the
  sample child's gate. A sample nested in a sample gave three.
- A template holding the pair also refused each fixture message in its
  `data-sample-events` history with `fixture-markup`, since a fixture's
  check read the child's whole document, so the author was told event 2
  of the fixture didn't validate when the fault was in the template.
- An agent's message holding any HTML was refused while `index.html` on
  disk bound a source twice, since the message's check read the current
  source as well as the message.
- A message whose sample held the pair was refused with the finding on
  the message itself (`samples` empty) rather than on the sample.

Now every gate reads its own document's bindings and no other's: the
conflict check runs in `instance_errors`, which every gate already runs
on the one document it reads (a page's source, a sample's child, a
message's HTML, a fixture message's HTML, a registry example). A sample
child is a document of its own, so its conflict is reported once, by its
gate, marked with its sample like the child's other findings
(`sample 'practice': source 'shared' is bound to both ...`). A fixture
message is refused only for its own bindings, and an agent's message
only for its own. The page's data inventory still reads its samples'
consumers, which is what `data_document_readings` recurses for.

A gate's finding no longer names its document in each seat ("at
index.html <lf-num> ..." becomes "at <lf-num> ..."), since the gate says
which document it read; the readings of a page's history, which hold
many documents, still name each one, as `leaf data set` reports them.

This removes the readings that existed only to look for conflicts:
`data_binding_errors`, `data_document_errors`,
`initial_data_document_readings`, the `readings` argument of
`authored_document_checks` and the `extra_errors` argument of
`message_markup_findings`. A message's check no longer parses
`index.html` from disk.

A sample child built from `data-sample-threads` no longer rereads the
imported messages' bindings under the page's current registry; each was
checked under the registry it is stored with as it entered, as every
message in a page's own log is.
# Conflicts:
#	src/leaf/records/authored_checks/admission.py
#	src/leaf/records/markup_checks/instances.py
…nflicting widget

A sample whose template imports a thread (`data-sample-threads`) copies
the thread's messages into its child, which reads them under its own
registry, the page's current one, whatever registry each was posted
under. Two widgets that shared a contract when a message was posted, and
no longer did after a registry change, passed `page check` and
allocated, and then `page state` on the child raised `DataError` reading
its bindings. The previous commit dropped the child gate's reread of its
log, which had caught this. Now `initial_sample_events`, which both the
check and allocation run, checks each copied message's bindings under
the child's registry as it copies them, and refuses the sample with a
`contract-conflict` naming the sample and the copied message ("sample
'practice': source 'shared' is bound to both contract 'rows' at copied
message 'aabb0011' <lf-test-data id=rows-view> ...").

A conflict's seats now carry the widget's id, so an author sees which
widgets read the source. One `lf-num` and two `lf-text-document`s on
one line, all bound to `shared`, had given two byte-identical findings
since the previous commit; now each names its `lf-text-document`.
Widgets of one tag without ids on one line still read as one seat, and
give one finding.

The docstrings of `declared_data_bindings` and `check_markup` now say
which registry each reader of a message's bindings uses: its gate and
the page's data inventory use the one it is stored with, and a sample's
child its own.

`test_a_message_is_refused_only_for_its_own_bindings` now requires the
command to succeed and the comment to be in the log, since an empty list
of findings also held for a refusal that carried none.
An element declaration's `example` is checked as markup a page could
hold, and `invalid-example` tells its author when a page copying it
would be refused. The check read only the example's own document, so an
example binding one source under two contracts gave `invalid-example`,
and the same widgets wrapped in a named sample template
(`<template id="practice" data-sample>`) gave nothing, though a page
holding it is refused for the sample's child.

Now `_example_advice` runs `markup_findings` on each sample's child too,
recursively, as `uncaptured_sample_errors` walks a message's, and the
refusal it reports carries the sample it was found in.
@max-sixty
max-sixty merged commit 130d9f5 into main Nov 26, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-ac685bd2a2f129282 branch November 26, 2026 05:28
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