Skip to content

Move a page's inputs out of served_state, below the modules that watch and stamp them - #7122

Merged
max-sixty merged 9 commits into
mainfrom
agent-a778eb6fd3206ecd7
Nov 25, 2026
Merged

max-sixty merged 9 commits into
mainfrom
agent-a778eb6fd3206ecd7

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

served_state/reading.py declared which writes count as a page's inputs (page_input, page_roots, outside_inputs) and took the stamps over them (page_reading, source_readings, record_reading, join_reading). Its callers are the file watchers, activation, publishing, the row publisher and the hooks, none of which projects state, and it imported nothing from the projection. It becomes the top-level module page_inputs, below its callers, and served_state holds only the served state: the page read, its projection, and the patch sent to a tab holding an earlier reading. version_written, which names when the files a version is built from last changed, moves to revision_artifact beside CAPTURED_TREES, ending its deferred import.

session, hosting, server_rows, http and agent_state now stand just above served_state in .config/importlinter.ini, since each reads the served state and served_state imports none of them. Only the order changes for those, in a commit of its own.

src/leaf's allowed backward imports go from 64 to 51. Behavior is unchanged.

.config/importlinter.ini will conflict with #7061 and #7114 on one hunk: this branch deletes the leaf.session -> leaf.served_state.* allowances, and both PRs delete the adjacent leaf.session_runtime -> leaf.harness. Deleting all three lines resolves it, and lint-imports checks the result. Every other file merges cleanly with both. From their files, this touches import lines in hooks.py, session.py, render_gate/handover_pass.py and worker/leaf_website/storage.py, and one docstring line in presence.py.

max-sixty asked for refactoring to continue while each change improves the code.

Tests: lint-imports and pre-commit pass, as do the model tests for file bindings, native watches, the handover pass, seen, hook registration, model folds, the render gate and render export, the website's saved records and the revendoring contract (163).

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

`unlined`, the user's turns in a thread that no word of the agent's has
reached since the oldest of them, is a pure fold over a built thread: it
reads only `events.unanswered_turns` and `events.spoken_turns`, which it
imported inside its body. Two modules read it, the line fork's follower
(`forks.look`, `forks._awaits_line`) and the delivery envelope
(`thread_context.batch_threads`). Defined in `forks`, it made
`thread_context` reach up past `forks`' imports of the service, leases and
state through a deferred import. In `events` it sits beside
`unanswered_turns` and `owed_turns`, and both readers import it downward.

Behavior is unchanged. The import-linter allowance
`leaf.thread_context -> leaf.forks` goes with the import.
`activity` decides where the agent's work stands from the obligation
records `obligations` produces, so it belongs above that module. The order
had it below, because `obligations` reached `activity` back through
`thread_context`'s deferred import of `forks`; with `unlined` moved into
`events`, no path from `obligations` leads back to `activity`, and the
allowance `leaf.activity -> leaf.obligations` goes.

Only `.config/importlinter.ini` changes; no code or behavior does.
…llers

`served_state/reading.py` declared which writes count as a page's inputs and
took the stamps that say whether they moved. Its callers are the watchers
(`file_changes`, `session.Watch`), activation (`revisioning`), publishing, the
row publisher and the hooks, none of which project state, and it imported
nothing of the projection. Inside `served_state` it stood at the projection's
level, so each of those callers imported upward. As the top-level
`page_inputs`, below `file_changes`, they import downward, and `served_state`
holds only the served state: the page read it folds, its projection, and the
patch a tab holding an earlier reading is sent.

`version_written` moves to `revision_artifact`, beside `CAPTURED_TREES`: it
says when a file a version is built from was last written, and that set of
files is the revision's inputs. Its deferred import of `CAPTURED_TREES` goes
with it. It reads the stamps through `page_inputs.page_stamps`, formerly
`_page_stamps`.

`file_bindings` moves down the import order to stand below `page_inputs`,
which imports it. Five allowances end (`file_changes`, `publishing`,
`revisioning`, `server_rows` and `session` -> `served_state.reading`), leaving
72. Behavior is unchanged.
…ve its checks

`package_layer_inputs` gives the layer inputs a page selecting one package
composes: `layer_inputs()` with the package appended once. That is layer
input resolution, the subject of `layer`, beside `layer_inputs` and
`checked_layer_inputs`. Kept in `packages`, the module of the `package`
commands, it made `render_gate.widget_quality` import the command module,
so `packages` stood below `render_gate` and `cmd_package_check` reached up
to `render_gate.command` against the order.

With the function in `layer`, `render_gate` no longer imports `packages`,
and `packages` stands above `render_gate`, as `validation` (the `page check`
command) stands above the checks it runs. The allowance
`leaf.packages -> leaf.render_gate.command` goes. Behavior is unchanged.
The session commands (`session`), the page host (`hosting`), its row publisher
(`server_rows`), the page server (`http`) and `leaf page state`
(`agent_state`) each read the served state, and nothing in `served_state`
imports any of them directly. The greedy order had placed them below it, so
each of those reads was allowed as a backward import. Standing the five
modules just above `served_state`, in the order they import each other, makes
those reads point down. Every import cycle they sit on keeps a backward edge
elsewhere (`presence -> session`, `clerk -> agent_state`, `vendoring ->
hosting`), so no allowance is added.

Eight allowances end: `http` -> `served_state.service` and
`served_state.tail`, `agent_state` -> `served_state.context` and
`served_state.page`, `session` -> `served_state.context`, `server_rows` ->
`served_state.service`, and, from `hosting` now standing above them, `hosting`
-> `clerk` and `http`. 64 remain. Only the order changes; no code does.
# Conflicts:
#	src/leaf/render_gate/handover_pass.py
# Conflicts:
#	.config/importlinter.ini
leaf-agent
leaf-agent previously approved these changes Nov 25, 2026
@max-sixty
max-sixty merged commit b73db59 into main Nov 25, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-a778eb6fd3206ecd7 branch November 25, 2026 06:30
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