Repository navigation
build: crate paths that work at any directory depth (crates-layout PR 2) - #212
Merged
Merged
Conversation
…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]>
This was referenced Nov 16, 2026
Closed
Merged
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]>
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.
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:
build:files outside a crate are read throughTHRUST_ROOT, and every internal dependency goes through the workspace..cargo/config.tomlsetsTHRUST_ROOT = { value = "", relative = true, force = true }: the workspace root, as an absolute path.CARGO_MANIFEST_DIRand../..now build their path from it. They are the TLS test's Origin CA root, the v1 oracle's schema, corpus and seed script, andtarget/spike-0006.thrust-editor-docandthrust-oracle-fixturejoin[workspace.dependencies]. Their five users inherit them, so the rootCargo.tomlis now the only file that names a crate's directory.docs/src/contributing/crates.mdsays both.ci:plan-ci.pygives 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.README.mdthat no crate holds runs nothing. Any other file ofcrates/outside a crate still runs everything.ci:check-deps.sh's proof-minting guard exempts each crate's owntests/using the directoriescargo metadatalists.^crates/[^/]+/tests/before. A looser pattern would also have exemptedsrc/tests/modules.Found while doing it
.cargo/config.tomlfrom 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 useTHRUST_ROOTfail to compile; they never read a wrong path. The config file says so.[env]behaviour:""gives the root with a trailing slash, and"."gives<root>/..force, aTHRUST_ROOTalready in the environment wins./, so paths contain a harmless//.default-features = falseon an inherited dependency. So thethrust-editor-docworkspace entry turns default features off.Evidence
Every check below has a control that makes it fail (AGENTS.md rule 8).
cargo tree -e featuresfor the four crates that depend on the two moved entriesdefault-features = falsefrom the workspace entry givesthrust-compat-planethe editor's default features, andyrswith themcargo nextest runon the five changed cratesTHRUST_ROOTpointed atcrates/: Cargo rebuilds, andthrust-plane-types' two corpus parity tests fail on<root>/crates/tools/…--features native), OpenAPI tests (--features openapi)cargo mutants -p thrust-plane-typestest_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 onecheck-deps.shunder dashcargo metadatabroken: FAILED, the 142 mints reported as FORBIDDEN, exit 1On the no-segment-boundary control: the test first passed it. Longest-prefix matching hid the bug whenever
v1andv1xwere 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 ofthrust-editor-docneedtools/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/andCargo.tomlchanged, so CI runs everything.🤖 Generated with Claude Code