Skip to content

Fail a change that adds a backward import in src/leaf - #6923

Merged
max-sixty merged 3 commits into
mainfrom
deslop-please
Nov 24, 2026
Merged

max-sixty merged 3 commits into
mainfrom
deslop-please

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

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.ini lists 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, and exhaustive fails 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/leaf will fail once this lands. browser/runtime gets 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.

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

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
leaf-agent previously approved these changes Nov 24, 2026

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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").
@max-sixty max-sixty changed the title Fail a change that adds a backward import in src/leaf or browser/runtime Fail a change that adds a backward import in src/leaf Nov 24, 2026
@max-sixty
max-sixty merged commit e4e1149 into main Nov 24, 2026
6 checks passed
@max-sixty
max-sixty deleted the deslop-please branch November 24, 2026 01:49
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_
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