Skip to content

Production code may only name declared dependencies: a seconds-scale guard for the #5452 break (card d4868960) - #5460

Merged
joelteply merged 3 commits into
canaryfrom
d4868960/dev-only-deps
Oct 26, 2026
Merged

joelteply merged 3 commits into
canaryfrom
d4868960/dev-only-deps

Conversation

@joelteply

@joelteply joelteply commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Serves the build loop (plan line 1, edit-to-checked): a crate cut can no longer break canary's non-test build while its PR's checks pass.

Why

PR CI builds each selected crate as cargo test --lib --no-run. That is the only build that links [dev-dependencies]. #5452 moved hf into continuum-academy, and core named it from production code while academy was still only a dev-dependency of core. The PR went green, then every non-test core build failed until #5457. A cold non-test cargo check per crate would catch this, at minutes per crate. Reading the manifests catches the same class in milliseconds.

What

New source-hygiene::dev_only_deps. For every workspace crate under core/ and apps/, it reads the manifest. Normal dependencies come from [dependencies], [dependencies.x] and [target.'…'.dependencies]; dev dependencies from the same three forms of dev-dependencies; build dependencies count as neither. It takes the dev-only crates and fails on any production line that names one: krate::, use krate; or extern crate krate. A module path that happens to end in the same word does not count.

Test code is recognised the way cargo gates it:

  • files that declare #![cfg(test)];
  • any #[cfg(…)] naming test, at any indent (test, all(test, …), any(test, feature = "test-fixtures")), excluding not(test);
  • a gated field, statement or mod x; covers one line; a gated block covers the whole block;
  • whole modules declared behind such a gate (#[cfg(test)] mod tests;, #[cfg(all(test, feature = "stress-tests"))] mod load_harness;).

gated_item_end becomes pub(crate) so it is reused, not copied. The crate stays std-only with zero dependencies.

Measured (IntelMac, base 9cf91c6, 2026-10-26)

  • Mutation: removed core's normal continuum-academy dependency (undoing Hotfix: core's non-test build resolves continuum_academy (card a581f5d1) #5457). The guard failed with continuum-core/src/commands/mod.rs:45 pub use continuum_academy::hf; in 2.53 s. Restored: cargo test -p source-hygiene --lib gives 59 passed, 0 failed (14.9 s for the whole suite).
  • Before the test-region reader, the first cut flagged 10 lines, all test code: gated fields in genome.rs and job_create.rs, load_harness.rs, and tests.rs files gated by their parent. Each of those shapes is now pinned in the fixture test.
  • CI time: no new job. The guard runs inside the existing ratchets job's head test run.

Added 1 file (~300 lines including 4 tests). Removed: nothing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…guard for the #5452 break (card d4868960)

PR CI builds each crate as `cargo test --lib --no-run`, the one build that links
dev-dependencies, so production code naming a dev-only crate passed and broke every
non-test build after merge (#5452 -> #5457). source-hygiene now reads every workspace
manifest under core/ and apps/, takes the dev-only crates, and fails on any production
line naming one. Test code is read the way cargo gates it: #![cfg(test)] files, any
cfg naming test (all(test, ...), any(test, test-fixtures)) at any indent, and whole
modules declared behind such a gate.

Proven by mutation: dropping core's normal academy dependency (undoing #5457) fails
the guard on commands/mod.rs:45 `pub use continuum_academy::hf;` in 2.5 s; restored,
source-hygiene 59/59 pass. Zero dependencies kept.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
joelteply and others added 2 commits October 26, 2026 03:30
…dex on #5460)

`any(test, unix)` compiles in every Unix build, so only a predicate that IMPLIES test
(test; all(.., test); any(..) whose every arm implies test; the fixtures feature) gates
code out; not(..) never does. A leading `::krate::` is an absolute path to the crate,
told from `a::krate::` and `<T as X>::krate`. The attribute's own end is parsed, so an
item on the gate's line (`#[cfg(test)] dir: T,`) is read as gated. Regressions for each;
source-hygiene 60/60; the #5457 mutation still fails on commands/mod.rs:45.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

Reviewed exact head 820cc89. Both reported false negatives are fixed with regressions: any(test, unix) is treated as production, and leading :: external-crate paths are detected. The final delta documents the parser's limits and the separate compiler-coverage follow-up. All selected exact-head CI checks are now green (skipped jobs are not counted as validation). No remaining blocker from this bounded guard review; this does not replace non-test compilation.

@joelteply
joelteply merged commit 87b0d4e into canary Oct 26, 2026
22 checks passed
@joelteply
joelteply deleted the d4868960/dev-only-deps branch October 26, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant