Repository navigation
Read the turn-end check's page facts in its caller, ending the clerk's backward import - #7223
Merged
Merged
Conversation
…import of agent_state `clerk._facts` imported `commands.agent_state.page_state` to show the turn-end check's fork each held page's On Me list, obligations and threads. `page_state` reads the served state, so the clerk in `agents` reached two packages up, under an import-linter allowance. The reading now happens where the turn-end check starts. `hooks.cmd_fork`'s turn-end branch calls `agent_state.turn_end_facts`, which opens each page the session holds in one transaction, reads its `page_state` there, and hands it to `clerk.page_facts`. The clerk builds the question from what it is given: `turn_ended(session_id, pages)`. - `clerk.page_facts(page_dir, state, events)` now also reads the page's words as the user reads them, which `_facts` added. Everything the fork is shown of a page is selected in this one function, beside the prompt that phrases it. - `clerk._facts` and `clerk.question` are gone. `question` had no caller but `turn_ended` and the clerk tests, whose helper now takes the question from `hooks.cmd_fork`, as the hooks module does. - The fork eval's `PAGE_TEXT` reads the session's page through `turn_end_facts`. - The `leaf.agents.clerk -> leaf.commands.agent_state` allowance is deleted from `.config/importlinter.ini`. This is a refactor, and behaviour is unchanged: the fork's prompt, the pages it leaves out, and the order of reads within each page's transaction are as before. Tests: both lint-imports runs, pre-commit, and test_clerk, test_forks, test_hooks, test_server_lifetime, dev/tests/test_evals.py (its stale-edit replay runs `PAGE_TEXT`), and the hooks-module process tests that drive the turn-end check. > _This was written by Claude Code on behalf of max-sixty_
leaf-agent
previously approved these changes
Nov 26, 2026
# Conflicts: # .config/importlinter.ini
leaf-agent
approved these changes
Nov 26, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 26, 2026
…a cycle (#7230) import-linter's layers contract checks only the imports between `src/leaf`'s eight packages, so the modules inside a package could import each other in a cycle, and six groups did. The cuts that ended them have landed (#7216, #7217, #7218, #7222, #7224). This adds import-linter's own `acyclic_siblings` contract over every package (`ancestors = leaf.*`). It recurses into subpackages such as `served_state` and `render_gate`, so a new cycle fails pre-commit as an upward import does, naming the import that closes it. A planted deferred import from `presence` into `delivery`, and one from `served_state.context` into `served_state.page`, each fail the contract; the tree as it stands passes. The config's header now says how to fix a cycle, and that a deferred import counts like any other, so deferring one ends no cycle; `src/AGENTS.md` states the rule beside the layering one. The maintainer asked for the cycles inside `agents` to be broken; this widens that to every package and keeps them broken. The two allowances the layers contract still lists are cut by #7223 and the PR after it. Tests: `lint-imports` (both contracts), pre-commit, and the two planted cycles above. > _This was written by Claude Code on behalf of max-sixty_
max-sixty
added a commit
that referenced
this pull request
Nov 26, 2026
…ing thread's backward import (#7233) Ends the backward import `agents.thread -> pages.render_gate.command`. The thread writes imported the render gate's `message_check`, which runs a message's widgets in a browser as a page of their own and refuses the message where one doesn't draw; it needs `pages.hosting` and the page snapshot, so it can't sit below `agents`. Now the writes take the check from whoever calls them, as #7149 passed the handover pass the check it runs and as `cmd_comment` already takes `drawn` from the command. `cmd_comment`, `post_reply`, `post_response` and `cmd_edit` each take `check: MessageCheck | None = None` and call it where the import was, on the same normalized markup and before the page lease. The command layer supplies it: the CLI's `thread create`, `reply` and `edit`; `leaf codex run`, through `TaskConnection` and each `TurnFold` to the App Server reply stream's opening and answer; and the website's hosted Codex turn. A caller that passes none runs no browser check, as on a host with no browser, where the message posts unrun and reports a failure when its thread draws. To weigh: - **Default none, not required.** Every production caller that ran the check still does; requiring it would put `check=None` on about 230 test call sites and break base-arm evals whose `post_response` lacks the keyword. The cost is that a future production caller that forgets it gets the no-browser behaviour. - **The line fork's working line passes none.** Its outcome can't change: an ephemeral line holding any `lf-` element is refused (`ephemeral-content`), and the check runs a browser only where markup places a widget. Only the refusal's wording in the page's diagnostics differs, for a line whose widget also failed to draw. This is the last of the cuts the maintainer asked for to end `src/leaf`'s backward imports. With #7223 landed, the layers contract now lists none, so its `ignore_imports` key goes and the config's header says neither contract takes exceptions. Tests: `lint-imports`, pre-commit, 684 focused tests after the final merge, and the check's own CLI test. A probe on `message_check` showed no model or process test relied on the check running implicitly. > _This was written by Claude Code on behalf of max-sixty_
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.
Ends the backward import
agents.clerk -> commands.agent_state. The turn-end check showed its fork each page's On Me list, obligations and threads by having the clerk read the agent-facing page state itself, which reads the served state two packages above it.Now the check's caller reads the pages and the clerk is given the result.
hooks.cmd_fork's turn-end branch callsturn_ended(sid, turn_end_facts(sid)). The newagent_state.turn_end_facts, besidepage_state, opens one transaction per page the session holds, readspage_statethere and hands it toclerk.page_facts, skipping the same pages as before. What the fork is shown of a page and how it is worded stay in the clerk:page_factsnow also takes the page's words, which_factsused to add, so one function chooses everything the fork sees, besidefork_prompt, which words it.clerk._factsgoes, andclerk.question, left a three-line wrapper, folds intoturn_ended.Behaviour is unchanged: the prompt, the pages skipped and the order of reads in each transaction are as before. A
leaf-dev eval … --baserun whose base predates this fails on thestale-editcase, whose script now callsturn_end_facts, until this lands.This is one of the cuts the maintainer asked for to end
src/leaf's backward imports.Tests:
lint-imports, pre-commit,test_clerk,test_forks,test_hooks,test_server_lifetime,dev/tests/test_evals.py, and the two hooks-module process tests that drive the turn-end check.