Skip to content

ci: guard ADR-0009's crate layout in the deps job (crates-layout PR 4) - #226

Merged
aRustyDev merged 2 commits into
mainfrom
ci/crates-layout-guard
Nov 16, 2026
Merged

aRustyDev merged 2 commits into
mainfrom
ci/crates-layout-guard

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

PR 4, the last of the crates-layout plan (.agents/plans/crates-layout/, ADR-0009). It adds a guard that keeps the layout #221 made.

What

scripts/check-layout.sh runs in CI's deps job, with its --self-test beside it. It reads the tracked files (git ls-files) and the workspace (cargo metadata --no-deps), and refuses:

  1. A workspace member outside crates/.
  2. A directory under crates/ that is neither a crate nor a group (ADR-0009 rule 1). This covers:
    • a crate inside another crate;
    • a group with no README.md;
    • a group that holds any file other than its README.md (a manifest there would make it a crate and a group at once);
    • a group whose README.md does not name a directory in it as `<name>/`.
  3. A normal or build dependency on a crate in testing/ or spikes/.
  4. A normal or build dependency of a crate in core/ on a crate outside core/.
  5. A stale path where nothing else would notice. These are the three silent traps found while planning the move:
    • a workflow paths:/paths-ignore: entry that names no tracked file, or a glob over a directory with none;
    • the same for .cargo/mutants.toml's exclude_globs and examine_globs;
    • a .gitignore line under crates/ that lies inside no crate.

With nothing to check it exits 2, not 0. Its success line counts what it read: on this tree, 19 crates, 9 groups, 23 workflow filter entries, 5 mutants.toml globs and 9 .gitignore lines.

One choice to look at. Rules 3 and 4 allow dev-dependencies. thrust-core's tests run against thrust-adapters-memory as a dev-dependency, so "nothing in core/ depends on a crate outside it", read literally, fails on today's tree. The guard checks core/'s normal and build edges, the same scope check-deps.sh already uses for core. crates/core/README.md and the plan say so.

plan-ci.py:

  • check-layout.sh is routed like the deps job's other guards.
  • A group's README.md ran no job, and .gitignore matched no rule. Both now run deps, because the guard reads them.

Docs:

Evidence

Check Result Control
scripts/check-layout.sh --self-test 23 cases pass It is the control. The consistent world passes, and each broken world must exit 1 with the message of the rule it breaks, not just fail. That requirement caught a first draft whose "stray directory" case failed for another rule's reason. An empty world must exit 2
scripts/check-layout.sh on this tree exit 0, with the counts above a tracked crates/stray.txt: exit 1. deploy.yml's filter put back to crates/thrust-worker/wrangler.deploy.toml: exit 1, naming it
every step of CI's deps and ci-scripts jobs, shell scripts under dash 46 of 46 exit 0; test_plan_ci.py passed=5,016, bad=0
the book builds with mdbook 0.5.4 (mdbook-mermaid is not installed here, so it was built with that preprocessor marked optional; CI's docs job runs the full check)

Not changed: ADR-0009 (accepted; the guard is its Confirmation).

🤖 Generated with Claude Code

aRustyDev and others added 2 commits November 16, 2026 15:06
…ut.sh)

The layout PR 3 (#221) made is kept by a check, run by CI's deps job with
its --self-test beside it. It reads the tracked files (git ls-files) and
the workspace (cargo metadata --no-deps) and refuses:

1. a workspace member outside crates/;
2. a directory under crates/ that is neither a crate nor a group; a crate
   inside another; a group with no README.md, with a file other than its
   README.md (a manifest beside it: a crate and a group at once), or whose
   README.md does not name a directory in it as `<name>/`;
3. a normal or build dependency on a crate in testing/ or spikes/;
4. a normal or build dependency of a crate in core/ on one outside core/.
   Dev-dependencies are allowed in 3 and 4: a test uses a fixture, and
   thrust-core's tests run against the memory adapters (the scope
   check-deps.sh already uses for core);
5. a stale path where nothing else would notice one: a workflow's
   paths:/paths-ignore: entry that names no tracked file (or a glob over
   a directory with none), a .cargo/mutants.toml exclude_globs or
   examine_globs entry likewise, and a .gitignore line under crates/
   that lies inside no crate. These are the three silent traps found
   while planning the move.

It exits 2, not 0, when there is nothing to check (no member, no tracked
file under crates/). Its success line counts what it read: on this tree,
19 crates, 9 groups, 23 workflow filter entries, 5 mutants.toml globs and
9 .gitignore lines.

plan-ci.py: the guard joins the deps job's guards. A group's README.md,
which ran nothing, and .gitignore, which matched no rule, now run deps,
because the guard reads them. test_plan_ci.py follows: passed=5016.

Controls: --self-test runs 23 cases on a small world. The consistent world
passes; each broken one must exit 1 with the message of the rule it breaks,
not merely fail, and an empty world must exit 2. On the real tree, a
tracked crates/stray.txt makes the check exit 1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- docs/src/testing/techniques/architecture-gates.md: check-layout.sh as
  the second architecture gate (what it reads, its rules, its control).
- docs/src/testing/running.md: the deps job's row named only check-deps
  and check-topology; it now names every guard the job runs.
- docs/src/contributing/crates.md, crates/README.md: the guard checks
  what "Adding a crate" asks for. crates/core/README.md: core/'s rule is
  on normal and build dependencies; thrust-core's dev-dependency on the
  memory adapters is allowed.
- The plan: PR 3 merged in #221, and how #220 was brought across the
  move; PR 4's choices as built.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 02c4d25 into main Nov 16, 2026
72 of 74 checks passed
@aRustyDev
aRustyDev deleted the ci/crates-layout-guard branch November 16, 2026 20:40
aRustyDev added a commit that referenced this pull request Nov 16, 2026
PR 4 merged in #226, so the status table says so, and the plan's status
reads done. What it left for later stays in PLAN.md's last section.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant