Repository navigation
test(arch): close two nits from #1589 review (pub-use prefix + symmetry) - #1590
Merged
Merged
Conversation
Two adversarial-review nits from PR #1589's APPROVE-WITH-NITS verdict, shipped as their own tiny ratchet PR per the test-fixtures doctrine. ## Nit 1 — `pub use` prefix bypass The previous scanner matched `use crate::runtime::<sub>::*` but missed `pub use crate::runtime::<sub>::*` (re-export from an intermediate module). That shape leaks the same engine-internal path through the consumer's public surface — same hazard, different prefix. Fix: strip a leading `pub ` after the existing `trim_start()` so the ratchet catches both shapes. ## Nit 3 — symmetric closure: every submodule is tracked Reviewer flagged the silent-gap class: a future PR could add `pub mod new_thing;` to `runtime/mod.rs` without extending `FORBIDDEN_RUNTIME_SUBMODULES`, opening a path the ratchet wouldn't catch. Fix: a third test (`every_runtime_submodule_is_tracked`) parses every `pub mod X;` line out of `runtime/mod.rs` and asserts each name appears in the forbidden list. New submodule → test fails until the list is extended (and the ratchet count rebaselined if any callers already reached in). ## Why these were nits, not blocks Both are defense-in-depth on a ratchet that was already correct for today's tree (no `pub use` reaches exist; submodule list matches declarations). The grandfathered count stays at 29 — these patches don't fix existing violations, they close future-PR-shaped holes. ## Nit 2 (deferred — separate cleanup PR) Inline `crate::runtime::<sub>::Item` references (not at the top of a `use` block) aren't matched by the current line-prefix scan. That's a ~10-violation cleanup that wants its own ratchet field (`inline` vs `import`) — not in scope here. Tracked as follow-up under #240. ## Test plan - [x] `cargo test -p continuum-core --test architecture_engine_os_layering --features metal,accelerate` — 3/3 pass (was 2/2; +`every_runtime_submodule_is_tracked`) - [x] Manual sanity: `grep -n "^pub mod" runtime/mod.rs` produces exactly the 22 names in FORBIDDEN_RUNTIME_SUBMODULES (the 23rd, `"runtime"`, covers the inner lifecycle module per the existing sanity test's skip) ## Doctrine alignment - [[no-fallbacks-ever]] — the ratchet IS the engine-OS layering's no-fallback equivalent at the build-graph layer - [[abstract-into-literal-design-principle]] — shipping the recipe (test) AND the literal first state (29 grandfathered) together; every PR ratchets down ## Related - Closes nit 1 + nit 3 from PR #1589's adversarial review - Task #240 (architecture-test matrix — second proof rolling forward) - Nit 2 (inline references) deferred to a follow-up ratchet PR Co-Authored-By: Claude Opus 4.7 <[email protected]>
… inline-body holes) Reviewer on PR #1590 returned APPROVE-WITH-NITS with two trivial surface-hardening notes. Folding them in here keeps the ratchet PR self-complete instead of trailing a no-op-today follow-up. ## Hardening 1 — visibility-modifier coverage `trim_start_matches("pub ")` requires a literal space, so neither `pub(crate) use crate::runtime::<sub>::*` nor `pub(super) use ...` were caught. Both shapes leak the same engine-internal path through the consumer's re-export surface (the public-vs-pub(crate) distinction is about *who* sees the leak, not whether it exists). Fix: chain three `trim_start_matches` calls — longer forms first so they don't fall through to the shorter `pub ` matcher leaving a leftover `(crate) ` / `(super) ` prefix. ```rust let trimmed = trimmed .trim_start_matches("pub(crate) ") .trim_start_matches("pub(super) ") .trim_start_matches("pub "); ``` Zero hits in the tree today — this is pure forward-defense. ## Hardening 2 — `pub mod X { ... }` inline-body shape The symmetry parser used `rest.split(';').next()` to extract the module name. For the (rare) inline `pub mod X { ... }` shape, that yields `X { ... }` instead of `X`, which would then fail the `FORBIDDEN_RUNTIME_SUBMODULES.contains()` check spuriously OR (worse) silently grandfather a name that doesn't match anything real. Fix: `rest.split_whitespace().next()` + `trim_end_matches(';')`. Handles all three shapes uniformly: | Input | Extracted name | |--------------------------------|----------------| | `pub mod X;` | `X` | | `pub mod X; // comment` | `X` | | `pub mod X { ... }` | `X` | `runtime/mod.rs` is 100% file-declarations today, so no behavior change — same forward-defense pattern. ## Deferred to a separate follow-up — nit 3 Reviewer's third nit: if a `pub mod X;` is later demoted to `pub(crate) mod X;` while still in `FORBIDDEN_RUNTIME_SUBMODULES`, the ratchet would silently stop watching that name. Closing this needs a small design choice (warn-vs-fail? auto-remove from list?) that doesn't belong on this PR — tracked under #240. ## Test plan - [x] `cargo test -p continuum-core --test architecture_engine_os_layering --features metal,accelerate` — 3/3 pass - [x] Manually verified: zero `pub(crate) use crate::runtime::*` or `pub mod X { ... }` patterns in tree today, so no behavior change from these hardenings - [x] Ratchet count stays at 29 — these tighten the matcher; they don't fix existing violations Co-Authored-By: Claude Opus 4.7 <[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.
Summary
Two adversarial-review nits from PR #1589's APPROVE-WITH-NITS verdict, shipped as their own tiny ratchet PR.
pub useprefix bypass. Scanner missedpub use crate::runtime::<sub>::*re-exports from intermediate modules. Fix: strip a leadingpubaftertrim_start().every_runtime_submodule_is_trackedparsespub mod X;fromruntime/mod.rsand asserts each name is inFORBIDDEN_RUNTIME_SUBMODULES. Closes the "future PR adds new submodule, ratchet doesn't notice" silent gap.Both are defense-in-depth on a ratchet that was already correct for today's tree. Grandfathered count stays at 29 — these don't fix existing violations, they close future-shaped holes.
Nit 2 (inline
crate::runtime::<sub>::Itemreferences) deferred — wants its own ratchet field; tracked under task #240.Test plan
cargo test -p continuum-core --test architecture_engine_os_layering --features metal,accelerate— 3/3 pass; was 2/2pub mod X;inruntime/mod.rsis trackedDoctrine alignment
[[no-fallbacks-ever]]— the ratchet IS the engine-OS layering's no-fallback equivalent at the build-graph layer[[abstract-into-literal-design-principle]]— recipe ships with literal first state of 29 grandfathered; every PR ratchets downRelated
🤖 Generated with Claude Code