Repository navigation
test(architecture): ratchet top-level layer direction and mutual imports - #10584
Conversation
Declare a layer for every top-level src/ directory and root source file (domain, contracts, foundation, providers, application, composition, adapters) in scripts/lib/module-layers.mjs. verify:module-boundaries now also builds the production import graph between those units and compares it with a counted baseline: 45 unit pairs import a higher layer (248 imports) and 23 unit pairs import each other. A new upward pair, more imports on a recorded pair, a new mutual import, or an undeclared unit fails; shrinkage is reported so the baseline can be lowered.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The update appears safe to merge; the previous finding is fixed and no new actionable issues were found. SummaryThe PR adds declared source layers and a baseline that prevents upward imports and mutual imports from growing.
Reviews (3) · Last reviewed commit: "fix(architecture): enforce layers for is..." · Reviewed by Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e617c2c40
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…rts (#10584) * test(architecture): ratchet top-level layer direction and mutual imports Declare a layer for every top-level src/ directory and root source file (domain, contracts, foundation, providers, application, composition, adapters) in scripts/lib/module-layers.mjs. verify:module-boundaries now also builds the production import graph between those units and compares it with a counted baseline: 45 unit pairs import a higher layer (248 imports) and 23 unit pairs import each other. A new upward pair, more imports on a recorded pair, a new mutual import, or an undeclared unit fails; shrinkage is reported so the baseline can be lowered. * fix(architecture): enforce layers for isolated units
Summary
Plan step 2.6 (structural audit W9, report 08 §3).
verify:module-boundarieschecked pure layers,application ↛ compositionand an allowlist of migrated provider roots, but not layer direction in general or cycles. A new directory was unconstrained by default. This extends the existing verifier (no parallel tool) with a declared layer for every top-levelsrc/unit and a counted, ratcheting baseline.Problem and expected behavior
Dependencies should flow inward (AGENTS.md;
docs/architecture/architecture.mermaid). On main, provider directories importapplication,processimportsartifacts, and 23 unit pairs import each other. Nothing stops these from growing. Expected: the counts cannot go up, and an undeclared directory fails.Change and scope
scripts/lib/module-layers.mjs:UNIT_LAYERSassigns every top-level directory and rootsrc/*.tsfile to one ofdomain,contracts,foundation(process, filesystem, windows, config, compression, identity, logger, package metadata),providers,application,composition,adapters(cli, server, main, root CLI/MCP/catalog files). An import may point to the same or a lower layer.scripts/lib/module-boundaries.mjs: import resolution is split intoresolveModuleImportsso the per-file checks and the graph share one resolver (package-map andfile:handling included).inspectModuleBoundariesbehaves as before.scripts/verify-module-boundaries.mjs: on a full run (not a file selection), it builds the production import graph between units (tests, specs, fixtures excluded; type imports included) and compares it withscripts/lib/module-layers.baseline.json:application(ports such asAnalysisProvider), plusprocess → artifacts20,domain → contracts4,composition → cliCommandNames.ts3,application → mcpStartupPolicy.ts3,windows → artifacts2,config → native/application.application ↔ artifacts/browser/config/desktop/dotnet/frida/providers,artifacts ↔ dotnet/firmware/gpu/javascript/native/process,contracts ↔ domain,config ↔ filesystem,main ↔ server,process ↔ windows,catalogIdentity.ts ↔ recordedCatalogDigests.ts, and fivecli ↔ root cli*.tspairs.--print-layer-baselineprints the current facts.cli*.tsfiles and fromartifacts↔ provider directories that the report did not list.src/ports/, or moving root CLI files intosrc/cli/(W9 moves).Contribution scope: not applicable (verification only).
Contract and boundary impact
Semantic owner and earliest changed stage:
scripts/lib/module-layers.mjsowns the layer table;module-boundaries.mjsowns import resolution.Contribution scope fit and linked maintainer decision: not applicable.
CLI and MCP/tool-catalog contract: none.
Provider, bridge, target-format, or platform compatibility: none.
Evidence, artifact, provenance, or reconstruction contract: none.
Target selection, authority, upstream behavior, and cleanup details: not applicable.
Generated metadata, package, or installation impact: none.
Documentation or usability only; no target interaction.
Evidence and regression coverage
tests/evaluation/moduleLayers.test.ts: every top-level unit is declared; unit mapping (root files,.jsspecifiers, tests ignored); upward counting and mutual pairs; undeclared unit refused; growth fails and shrinkage is reported.catalogIdentity.ts,serverIdentity.ts,mcpStartupPolicy.tsas adapters;identity.ts,logger.tsas foundation) follows report 08 and is open to maintainer adjustment.Validation performed
npm run test:local -- tests/evaluation/moduleLayers.test.ts tests/evaluation/moduleBoundaries.test.ts— 148 passednode scripts/verify-module-boundaries.mjs— "Checked resolved module boundaries in 4304 source files."npm run check:fast— passed (its lint step runs the verifier)Compatibility, safety, and release
UNIT_LAYERS.Author readiness
Human owner:
Before merge
type(scope): outcome.