Skip to content

build: crate paths that work at any directory depth (crates-layout PR 2) - #212

Merged
aRustyDev merged 3 commits into
mainfrom
chore/depth-independent-paths
Nov 16, 2026
Merged

aRustyDev merged 3 commits into
mainfrom
chore/depth-independent-paths

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

PR 2 of the crates-layout plan (.agents/plans/crates-layout/, ADR-0009). Nothing moves. After this PR, a crate's directory depth no longer matters, so the move itself (PR 3) is only renames and path edits.

What

Three commits:

  1. build: files outside a crate are read through THRUST_ROOT, and every internal dependency goes through the workspace.
    • .cargo/config.toml sets THRUST_ROOT = { value = "", relative = true, force = true }: the workspace root, as an absolute path.
    • The 12 sites that climbed out of their crate with CARGO_MANIFEST_DIR and ../.. now build their path from it. They are the TLS test's Origin CA root, the v1 oracle's schema, corpus and seed script, and target/spike-0006.
    • thrust-editor-doc and thrust-oracle-fixture join [workspace.dependencies]. Their five users inherit them, so the root Cargo.toml is now the only file that names a crate's directory.
    • docs/src/contributing/crates.md says both.
  2. ci: plan-ci.py gives a file to the longest crate directory that holds it, matched on a whole path segment. It no longer uses the first two path segments, which would have made every change to a moved crate run the whole of CI.
    • A group's README.md that no crate holds runs nothing. Any other file of crates/ outside a crate still runs everything.
  3. ci: check-deps.sh's proof-minting guard exempts each crate's own tests/ using the directories cargo metadata lists.
    • It used ^crates/[^/]+/tests/ before. A looser pattern would also have exempted src/tests/ modules.

Found while doing it

  • Cargo reads .cargo/config.toml from the directory it runs in, not from --manifest-path. So cargo must run inside the repository, as every script and CI job already does. From outside, the tests that use THRUST_ROOT fail to compile; they never read a wrong path. The config file says so.
  • Measured [env] behaviour:
    • "" gives the root with a trailing slash, and "." gives <root>/..
    • Without force, a THRUST_ROOT already in the environment wins.
    • Call sites add a leading /, so paths contain a harmless //.
  • Cargo ignores a member's own default-features = false on an inherited dependency. So the thrust-editor-doc workspace entry turns default features off.

Evidence

Every check below has a control that makes it fail (AGENTS.md rule 8).

Check Result Control
cargo tree -e features for the four crates that depend on the two moved entries identical before and after removing default-features = false from the workspace entry gives thrust-compat-plane the editor's default features, and yrs with them
cargo nextest run on the five changed crates 793 passed THRUST_ROOT pointed at crates/: Cargo rebuilds, and thrust-plane-types' two corpus parity tests fail on <root>/crates/tools/…
TLS tests (--features native), OpenAPI tests (--features openapi) 89 and 15 passed
cargo mutants -p thrust-plane-types the baseline builds and passes in cargo-mutants' copy of the tree (6 mutants: 4 caught, 2 unviable)
test_plan_ci.py, now with generated nested layouts, prefix siblings (v1/v1x), a crate inside a crate, and ADR-0009's layout planning exactly like the flat one 4,995 passed, 0 bad one-line broken copies: first-two-segments 2,379 bad; shortest prefix 123 bad; no segment boundary 2 bad
check-deps.sh under dash exit 0; the guard is ok with 142 test mints exempted cargo metadata broken: FAILED, the 142 mints reported as FORBIDDEN, exit 1

On the no-segment-boundary control: the test first passed it. Longest-prefix matching hid the bug whenever v1 and v1x were both crates. A case where a directory that is not a crate shares a prefix with one (crates/thrust-core-gone/) now catches it.

Not run: the four oracle_ tests of thrust-editor-doc need tools/spike-0006/gen-all.sh's output (Node), which isn't generated here. Without it they fail naming <root>//target/spike-0006/…, the same files ../.. reached.

.cargo/ and Cargo.toml changed, so CI runs everything.

🤖 Generated with Claude Code

aRustyDev and others added 3 commits November 16, 2026 00:57
…rnal dependency through the workspace

Two changes that make a crate's directory depth irrelevant, before ADR-0009
moves the crates (PR 2 of .agents/plans/crates-layout/).

.cargo/config.toml sets THRUST_ROOT, the workspace root as an absolute
path: { value = "", relative = true, force = true }. Measured: "" gives
the root with a trailing slash, "." gives <root>/., and without force a
THRUST_ROOT already in the environment wins. The 12 sites that climbed out
of their crate with CARGO_MANIFEST_DIR and ../.. build their path from it:
the Origin CA root in thrust-adapters-postgres's TLS test; the v1 oracle's
schema, corpus and seed script in thrust-api-v1, thrust-oracle-fixture and
thrust-plane-types; and target/spike-0006 in thrust-editor-doc.

Cargo reads .cargo/config.toml from the directory it runs in, not from
--manifest-path (measured), so cargo must run inside the repository, as
every script and CI job does. From outside, these tests fail to compile;
they never read a wrong path.

thrust-editor-doc and thrust-oracle-fixture join [workspace.dependencies],
and the five members that named them by a sibling path inherit them, so the
root Cargo.toml is the only file that names a crate's directory. The
thrust-editor-doc entry turns default features off, because Cargo ignores a
member's own default-features = false on an inherited dependency.

Evidence:
- cargo tree -e features for thrust-api-v1, thrust-compat-plane,
  thrust-editor-worker and thrust-adapters-selfhosted is identical before
  and after. Control: without default-features = false in the workspace
  entry, thrust-compat-plane gains thrust-editor-doc's default features,
  and yrs with them.
- cargo nextest run on the five crates: 793 passed. The TLS tests
  (--features native): 89 passed. The OpenAPI tests (--features openapi):
  15 passed.
- Control: THRUST_ROOT pointed at crates/ rebuilds thrust-plane-types and
  fails its two corpus parity tests on <root>/crates/tools/oracle-v1/...
- The four oracle_ tests of thrust-editor-doc need the output of
  tools/spike-0006/gen-all.sh, which is not generated here. They fail
  naming <root>//target/spike-0006/..., the same files ../.. reached.
- cargo mutants -p thrust-plane-types: the unmutated baseline builds and
  passes in cargo-mutants' copy of the tree (6 mutants: 4 caught,
  2 unviable).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s it

plan-ci.py named a file's crate by its first two path segments
(crates/<dir>). After ADR-0009 moves a crate a level deeper, every change
to it would have run the whole of CI. It now gives a path to the longest
member directory that holds it, matched on a whole path segment. A group's
README.md under crates/ that no member holds runs nothing; any other file
of crates/ outside a member still runs everything.

test_plan_ci.py lays out its 300 generated graphs flat, or grouped one or
two levels down, with directories that share a prefix (crates/api/v1 and
crates/api/v1x) and a member inside another member's directory. It checks
that ADR-0009's layout plans exactly as the flat one did, and it reads this
repository's member directories from cargo metadata instead of requiring
crates/<name>. passed=4995 bad=0.

Controls, each a one-line change to a copy of plan-ci.py:
- the old first-two-segments rule: bad=2379
- the shortest prefix instead of the longest: bad=123
- a prefix match without the segment boundary: bad=2. The test missed
  this one until a case was added where a directory that is no crate
  shares a prefix with one (crates/thrust-core-gone).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The proof-minting guard exempted only integration tests at
crates/<dir>/tests/. It now reads the member directories from cargo
metadata and exempts exactly <member directory>/tests/, matched as a
prefix (awk index(), no regex). A looser pattern such as
^crates/.*/tests/ would also have exempted a src/tests/ module. If cargo
metadata lists no member, the guard fails.

Evidence, under dash as on the runner:
- check-deps.sh exits 0 and the guard reports ok, with the 142 mint calls
  in members' integration tests exempted.
- On sample lines, the filter drops crates/thrust-core/tests/ and
  crates/testing/suites/api/tests/, and keeps a src/tests/ module,
  crates/testing/suites/api-gone/tests/ and library code.
- Control: with cargo metadata broken, the guard prints FAILED, reports
  the 142 test mints as FORBIDDEN, and exits 1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 3fdf141 into main Nov 16, 2026
37 checks passed
@aRustyDev
aRustyDev deleted the chore/depth-independent-paths branch November 16, 2026 06:12
This was referenced Nov 16, 2026
aRustyDev added a commit that referenced this pull request Nov 16, 2026
One conflict in .github/scripts/plan-ci.py: main added the docs job's check-book.sh rule beside the deps guards. Both kept;
check-edge-config.sh stays a deps guard. #212's crate-path rules need nothing here: the edge reads no file outside its
crate, and its fuzz crate is not a workspace member.

Refs: #195
Co-Authored-By: Claude Opus 5.5 <[email protected]>
aRustyDev added a commit that referenced this pull request Nov 16, 2026
… 3) (#221)

* chore: move every crate into its ADR-0009 directory, renames only

Each of the 19 workspace members moves with git mv, and nothing else
changes in this commit, so review and git log --follow see 359 renames
at 100 % similarity. Package names do not change.

  adapters/{cloudflare,memory,oidc,postgres,selfhosted}
  api/core (thrust-api), api/v1, api/compat-plane, api/plane-types
  core/ports, core/types (thrust-contracts), core/usecases (thrust-core)
  editor/doc, spikes/editor-worker
  testing/suites/api (thrust-contract-tests),
  testing/fixtures/oracle (thrust-oracle-fixture)
  edge, server, worker

thrust-edge (#211) arrived after the plan was written. ADR-0009 had
already reserved crates/edge/ for it.

The workspace does not build at this commit: the next one edits the
paths that name these directories.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore: point every path at the crates' ADR-0009 directories

The previous commit moved the crates; this one edits what names their
directories, so the workspace builds again.

- Root Cargo.toml: members and [workspace.dependencies]. Since PR 2
  (#212) it is the only manifest that names a crate's directory.
- crates/spikes/editor-worker/wrangler.toml calls ../../../scripts/rs: it
  is the one crate now three levels down that climbs out with a relative
  path. The worker's and the edge's configs stay at ../../ (depth 2).
- Every other file that wrote crates/thrust-<x>: CI actions and workflows,
  the deploy and check scripts, the probes, tools/compat-record,
  tools/spike-0006, the docs. Matched on a whole name, so thrust-api never
  matched inside thrust-api-v1. Also the comments and docs that wrote a
  crate path without crates/ (thrust-core/tests/operator.rs): they now
  name the real path.
- The ones that fail silently when missed: deploy.yml's paths filter
  (crates/worker/wrangler.deploy.toml), .cargo/mutants.toml's exclude
  globs (the contract suite, the edge's runtime.rs) and .gitignore.
- check-deps.sh: the proof-minting guard's literal paths, including the
  regex alternation that exempts the composition roots.
- tools/measure-zxcvbn/patches: regenerated (applied to the moved tree,
  diffed, reverted). Their hunks are unchanged; their headers name
  crates/core/usecases, at today's line numbers.
- test_plan_ci.py: ADR-0009's layout is now the default for the real
  graph and the flat one only the "before" of the check that moving a
  crate changes no plan. It also checks that this repository keeps
  REAL_GRAPH's crates where ADR_0009 says.
- docs/src/contributing/crates.md: "Adding a crate" starts by choosing
  the group (or the top level, for a program); "Not part of the product
  graph" puts the editor Worker in spikes/ and says thrust-editor-doc is
  product code now, and adds crates/testing/.
- ARCHITECTURE §2a redrawn from ADR-0009, with all 19 crates and the two
  planned ones (the M4 core API, the collab root).
- The plan: thrust-edge's row in the mapping, the recount, the status.

Not edited: .agents/plans/** other than the two above (dated records)
and CHANGELOG.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(crates): a README for crates/ and for each group

ADR-0009 rule 1: a directory under crates/ is a crate or a group, and a
group has a README.md that names its members and says what belongs in
it. One for crates/ (the groups, the programs and the names reserved for
programs), and one each for adapters/, api/, core/, editor/, spikes/
(when a spike goes here and when in probes/) and testing/ (what goes
there, and where each kind of test that is not a crate lives). The two
groups inside testing/, suites/ and fixtures/, get short ones too, so the
rule holds for every group and PR 4's guard can check it without an
exception.

plan-ci.py gives a group's README.md, inside no crate, no job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(editor-doc): describe the crate as what it is now, not as a spike

Its description began "Spike 0006". The crate is product code now:
thrust-api-v1 and thrust-compat-plane use its sanitiser, which is why
ADR-0009 puts it in editor/ and only the spike's measurement Worker in
spikes/. The description says that, and that it began as spike 0006.

This is the only change to package metadata in PR 3; the cargo metadata
comparison of the move ran before it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

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