Skip to content

Move a page's data bindings and data writes into records.page_data - #7207

Merged
leaf-agent merged 2 commits into
mainfrom
agent-a2237235931bf2a3a
Nov 26, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
agent-a2237235931bf2a3a

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

source/data.py and source/data_contracts.py each held a second concern that needs code above source. The leaf data set and leaf data clear writes take the page transaction in records. The bindings read across a page's history read each message's markup as it now reads, through log.thread_context. This PR moves both into a new records/page_data.py, beside the transaction and above the log. data.py keeps the publication file and its readers, and data_contracts.py keeps one document's bindings, contracts, inventory and lag. _authored_readings stays in data_contracts.py for data_binding_errors, and becomes public so that working_data_bindings can import it. No behaviour changes. main has two import-linter allowances fewer.

Every caller moves in the same change. A regex rewrote the tests' 325 calls of data_model.cmd_data_set and cmd_data_clear, across 47 files, to page_data_model. The tests also reached DataError through data and read_revision through data_contracts, which re-imported them, so those now go to each name's own module. For review, weigh the two module headers: page_data.py's says what it holds and why it sits in records, and data_contracts.py's now describes one document.

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

`source/data.py` held the publication file and its readers, and also
`leaf data set` and `leaf data clear`, which write under the page
transaction in `records`. `source/data_contracts.py` held one document's
bindings and contracts, and also the bindings across a page's history,
which read each message's markup as it now reads through
`log.thread_context`. Both pointed up from `source`, and
`.config/importlinter.ini` allowed the two imports by name.

The new `records/page_data.py` takes the writes (`cmd_data_set`,
`cmd_data_clear` and `_write_source`) and the history
(`page_data_document_readings`, `initial_data_document_readings`,
`working_data_bindings` and `page_data_binding_inventory`). It sits beside
the transaction and above the log. `data.py` keeps the publication file
and its readers, and `data_contracts.py` keeps one document's bindings,
contracts, inventory and lag. `_authored_readings` stays there for
`data_binding_errors` and becomes `authored_readings`, which
`working_data_bindings` now imports.

The allowances go from 13 to 11.

Every caller moves: `commands/cli.py`, `commands/agent_state.py`,
`records/authored_checks/source.py`, `records/sample_content.py`,
`dev/leaf_dev/commands/bench.py` and `dev/leaf_dev/page_fixtures.py`.
A regex rewrote the tests' 325 calls of `data_model.cmd_data_set` and
`cmd_data_clear` across 47 files to `page_data_model`, imported as
`from leaf.records import page_data as page_data_model`. It also sent the
tests' reach-throughs to each name's own module: `data_model.DataError` to
`data_contracts_model`, and `data_contracts_model.read_revision` to
`revision_artifact`. No behaviour changes.
@leaf-agent

Copy link
Copy Markdown
Collaborator

test's three failures on 5693e76 come from main, not from this change. They fail the same way on this PR's merge base 813d3262b and on current main c06f708f0, and pass on 14ba0041c, the commit before #7188. This PR only renames the cmd_data_set import in those test files. #7212 tracks the fix. By tests/AGENTS.md, "Run what the change needs", they don't block landing, so I'm merging this approved head.

@leaf-agent
leaf-agent merged commit dfde749 into main Nov 26, 2026
8 of 10 checks passed
@leaf-agent
leaf-agent deleted the agent-a2237235931bf2a3a branch November 26, 2026 03:13
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