Repository navigation
Fail a change that adds a backward import in src/leaf - #6923
Merged
Merged
Conversation
src/leaf's modules and browser/runtime's children each stand in one import order,
and each may import only what comes after it. A new import against the order fails
pre-commit; the backward imports already there are allowed by name and the lists only
shrink.
- src/leaf: an import-linter layers contract in .config/importlinter.ini lists all
101 children, `exhaustive` so a new module must be placed, with 98 allowances
(86 module pairs). An allowance that matches nothing is an error. A new pre-commit
hook runs it (0.3 s warm); import-linter joins the dev dependencies.
- browser/runtime: .config/dependency-cruiser.mjs gains the order of its 200
children, a `layering` rule per child and `layering-unplaced` for a child the
order doesn't name. The hook passes the 28 remaining backward imports (17 child
pairs) in .config/dependency-cruiser-known.json. A stale entry there passes
silently, unlike import-linter's.
The orders come from Eades, Lin and Smyth's greedy heuristic for a minimum feedback
arc set, run over each directory's import graph, which is what the checks guard. The
same heuristic over uses (the deslop-please survey's order) would allow 106 Python
and 168 JS backward imports. Each config's header says what to do when the check
fails: place a new module, point the import down, move a module whose place is
wrong, delete a stale allowance.
Probed on this tree: each check passes as committed, fails with the import named
when one allowance is dropped (harness -> delivery; current-target ->
keyboard/bindings), fails on a stale import-linter allowance, and fails on an
unplaced module (codex_tool; anchor-controls).
max-sixty chose this on the deslop-please page ("Fail changes that add a backward
import").
leaf-agent
previously approved these changes
Nov 24, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
This conflicts with #6924 at landing even though they share no file. #6924 moves canvas.js, exception.js and time-axis.js into browser/runtime/lib/. Once both are on main, the existence check in .config/dependency-cruiser.mjs throws names a missing runtime module: canvas, and lib has no place in layers. GitHub will merge whichever lands second without complaint, and ci's pre-commit run on main then goes red. The second to land needs to replace those three entries with lib, placed after every child that imports it.
The runtime half of the check named every child of browser/runtime in its order, so each refactor that adds, moves or removes a runtime file had to edit that order too. #6924's move of three files into browser/runtime/lib/ was the first such collision. While the package-interface refactors move runtime files, the dependency-cruiser config, its hook and browser/AGENTS.md go back to main's, and .config/dependency-cruiser-known.json goes. The runtime's order gets rebuilt from main once those refactors land. max-sixty chose this on the deslop-please page ("Merge the src/leaf half now").
leaf-agent
approved these changes
Nov 24, 2026
This was referenced Nov 24, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 25, 2026
A commit that adds an import against `browser/runtime`'s order now fails pre-commit and names the import, as `src/leaf` has since #6923. This is the runtime half #6923 left out until the package-interface refactor stopped moving runtime files. `.config/dependency-cruiser.mjs` lists the runtime's 187 children in one order, a `layering` rule per child forbids importing a child before it, and `layering-unplaced` fails a child the order doesn't name. The order is Eades, Lin and Smyth's greedy feedback-arc-set heuristic over the children's imports, run on current `main` after the keyboard split (#7115). The 15 backward imports it leaves (10 child pairs) are in `.config/dependency-cruiser-known.json`, which the hook passes over and which only shrinks. Unlike import-linter, dependency-cruiser passes a stale entry silently, so the config's header asks for each entry to go with its import. To weigh: the order is the one the code already mostly takes, not a design. max-sixty chose to move the runtime's children into named layer directories once the modules that cross layers are split; that move rewrites this list to name layers. Probed: passes as committed (1.8 s); fails naming `carry.js → thread/selectors.js` when that known entry is dropped; fails `layering-unplaced` when `age` is left out of the order. Pre-commit passes on the changed files. > _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.
Holds
src/leaf's modules to one import order, so a change that adds an import against it fails pre-commit. An import-linter layers contract in.config/importlinter.inilists all 101 modules. A new hook runs it, and import-linter becomes a dev dependency. The 98 backward imports already there are allowed by name. An allowance that no longer matches is an error, so that list only shrinks, andexhaustivefails a module the order doesn't name.To weigh: the order is a greedy heuristic's over the import graph, not a design, so the config's header says how to get past a failure, including moving a module in the order. Open PRs that add a backward import in
src/leafwill fail once this lands.browser/runtimegets the same check after the package-interface refactors land; until then each runtime file move would have to edit its order.max-sixty chose this on the deslop-please Leaf page; he hasn't read the diff.
The hook passes on the tree. It fails when one allowance is dropped, on a stale allowance, and on an unplaced module.