Repository navigation
Move the leaf task commands into tasks and the forks lane into leases, so todos, plans and forks import only downward - #7121
Merged
Conversation
`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.
…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.
`todos` and `plans` each held two levels of code: the readings of the log that admission (`event_contracts`), `activity` and the served state build on, and the `leaf task` commands, which write through admission. So each command imported `event_contracts`, `thread`, `service`, `revisioning` and `leases` inside its body, and wrapped its work in a nested `write` function only because `contract_writer` couldn't be imported where the module could apply it. The new `tasks` module holds `cmd_create`, `take_in_hand`, `cmd_start`, `cmd_end` and `cmd_plan`, with plain module-level imports and `@contract_writer` on each command, as `thread`'s commands have it. `todos` and `plans` now import only readings below them, so `activity` imports `todos` once at module level instead of in three functions, and the import order places `activity` and `todos` above `obligations`. Allowances removed (77 -> 71): todos -> event_contracts, todos -> thread, plans -> event_contracts, plans -> thread, activity -> todos, and activity -> obligations, which the same reordering turns forward. Behavior is unchanged. `cli` and the tests that called the commands import them from `tasks`.
…rites The forks lane is a lease: its file, the follower's taking of it and whether a follower holds it (`lane_path`, `take_lane`, `lane_up`). It lived in `forks`, the line fork's module, so `delivery` imported the line fork to ask one lease question. That import held `forks`, and `summary_fork` with it, below `delivery` and so below `thread`, though both post through `thread`'s writes (`post_reply`, `cmd_summarize`). `clerk`, which posts through `open_thread` and `ask_again`, sat just below `thread` by the order alone. The lane now sits in `leases` beside the session leases of the same shape, the adapter's and the watch's (`adapter_is_live`, `wait_is_live`), whose `take_wait_lease` already named it. `delivery` and `hooks` import it from there, and the import order places `clerk`, `forks` and `summary_fork` above `thread`, so the modules that write through a thread now import it forward. Allowances removed (71 -> 67): clerk -> thread, forks -> thread, forks -> delivery, summary_fork -> thread. Behavior is unchanged. The lane's prose references in `hooks`, `thread_context`, `events.md`, `summary_fork` and `fork_eval` name `leases`.
`thread_titles` names a thread by asking the harness's model and writing the answer through `thread`'s writes (`fit_title`, `name_untitled`), so it belongs above `thread`. It sat below because `harness` imports its prompt (`title_generator`), which left two backward edges in one cycle, `thread -> harness -> thread_titles -> thread`: `harness -> thread_titles` and `thread_titles -> thread`. Above `thread`, only the first stays backward. That is the edge where the harness reaches up for the title prompt. Allowance removed (67 -> 66): thread_titles -> thread. Only the import order changes.
unlined now lives in events and the lane in leases, so forks holds neither, and no module imports forks at load. summary_fork's page readings therefore import at module level; only its imports from forks, which imports it, wait until called.
leaf-agent
previously approved these changes
Nov 25, 2026
# Conflicts: # .config/importlinter.ini # src/leaf/events.md # src/leaf/forks.py # src/leaf/summary_fork.py
max-sixty
dismissed
leaf-agent’s stale review
November 25, 2026 05:57
The merge-base changed after approval.
leaf-agent
approved these changes
Nov 25, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The description becomes main's commit message on merge, and two of its claims are now out of date: #7118 has landed (it is no longer "still in CI"), and so this PR's own diff against main is what takes src/leaf's allowed backward imports to 64. Worth dropping the "This branch merges #7118" sentence before landing.
leaf-agent
added a commit
that referenced
this pull request
Nov 25, 2026
…tion or a false reason, or tell history (#7131) Four comments the nightly survey found wrong or out of place. Comments only; no behavior changes. - **`lf-activity.js` header** said a row names the user "You". `actorOf` writes "Me", the glossary's author word. - **`findings.py`** pointed the `not-a-widget` and `not-an-element` refusals at `tasks.task_error`, which doesn't exist; #7121's new `tasks.py` made that pointer actively misleading. The to-do check is `todos.todo_error`. - **`http.py` `body_unread`** said an undrained body "would be read as the next request line on a reused connection". uvicorn's h11 protocol discards a request's body data once the response is done (`h11_impl.py`, the `h11.Data` branch checks `our_state is h11.DONE`), as `PageEndpoint`'s docstring already says. What the flag does is close the connection so the transport doesn't drain a body the peer may never finish sending, which `test_a_user_without_the_key_reads_and_writes_nothing` exercises with a keyless POST declaring 1 GiB. Both comments now give that reason, so a later reader neither removes the flag as redundant nor copies it for the wrong reason. - **`packages/diagram/defaults.css`** told how its rules left the default theme and the incident behind the fade's 30% stop. Root `AGENTS.md`, "Where instructions live", puts that in commit history; the comments keep the rule and its reason. Verified with pre-commit on the four files (ruff, oxfmt, eslint, typos). Co-authored-by: leaf-agent <[email protected]>
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.
todos.pyandplans.pyeach held two levels: readings that admission,activityand the served state build on, and theleaf taskcommands, which write through admission. Each command importedevent_contracts,thread,service,revisioningandleasesinside its body, and wrapped its work in a nesteddef writeonly becausecontract_writercouldn't be imported at load. The commands now live in a newtasks.py, which mirrors theleaf taskCLI group and sits besidethread, the other write-command module. Its imports are module-level, and each command carries@contract_writerasthread's commands do.todosandplansbecome readings, soactivityimportstodosonce at load instead of in three functions.lane_path,take_laneandlane_upare a session lease, so they move fromforksintoleases, beside the adapter and watch leases of the same shape.deliveryhad imported the whole line-fork module for that one question, which heldforksandsummary_forkbelowthread, although both post throughthread's writes. Nowclerk,forks,summary_forkandthread_titlesstand abovethreadin.config/importlinter.ini. No module importsforksat load any more, sosummary_fork's page readings import at module level, and only its imports fromforks, which imports it, wait until called.This branch merges #7118, still in CI. On top of it,
src/leaf's allowed backward imports go from 74 to 64. Behavior is unchanged: the moved bodies differ from the originals only in imports, decorators and docstring pointers.Two further cuts in this group wait on open PRs. Once #7061 lands, the reply reservations can move from
threadintodelivery, whose header already describes them. Once #7114 lands, the fork helpers split betweenclerkandforkscan move into one module below both.max-sixty asked for refactoring to continue while each change improves the code. The branch merges cleanly with #7061; its only conflicts with #7114 are ones #7114 already has with
main.Tests:
lint-importsand pre-commit pass. The model tests for forks, hook registration, responses, clerk, activity, to-dos, thread readings and the suite's source checks pass (1847), as do the fork, pages and follower tests intest_hooks,dev/tests/test_evals.pyand the browser test that ends a to-do.