Skip to content

test(arch): close two nits from #1589 review (pub-use prefix + symmetry) - #1590

Merged
joelteply merged 2 commits into
canaryfrom
chore/arch-test-layering-nits
Jun 10, 2026
Merged

joelteply merged 2 commits into
canaryfrom
chore/arch-test-layering-nits

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Two adversarial-review nits from PR #1589's APPROVE-WITH-NITS verdict, shipped as their own tiny ratchet PR.

  • Nit 1 — pub use prefix bypass. Scanner missed pub use crate::runtime::<sub>::* re-exports from intermediate modules. Fix: strip a leading pub after trim_start().
  • Nit 3 — symmetric closure. New test every_runtime_submodule_is_tracked parses pub mod X; from runtime/mod.rs and asserts each name is in FORBIDDEN_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>::Item references) 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/2
  • Manual sanity: every pub mod X; in runtime/mod.rs is tracked

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]] — recipe ships with literal first state of 29 grandfathered; every PR ratchets down

Related

🤖 Generated with Claude Code

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]>
@joelteply
joelteply merged commit af241be into canary Jun 10, 2026
2 checks passed
@joelteply
joelteply deleted the chore/arch-test-layering-nits branch June 10, 2026 00:13
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