Repository navigation
fix(layering): 纠正门禁错位判据——探针留在 cli 是正确的 - #2
Conversation
PR #1 的门禁按「命名像领域模块就应下移到 adapters」判定,这是错的。 本仓 `crates/codeguard-cli/tests/crate_boundaries.rs` 早已用测试强制: codeguard-adapters 仅可依赖 core / serde / serde_json / roxmltree / toml / sha2 codeguard-runtime 承担进程执行 codeguard-cli 编排,可依赖以上三者 据此,`*_probe` 探针调用 `run_process_recorded`、需要 runtime,而 adapters 被 明确禁止依赖 runtime——**探针留在 cli 是正确的,把它们"下移"会被 crate_boundaries 直接判失败**。PR #1 的基线把 9 个探针登记为债务,等于在 引导后来者走一条注定被本仓测试拒绝的路。 实测 13 项登记项的真实依赖: - 10 项依赖 codeguard_runtime → 依边界不得进 adapters - module_graph / cargo_module_graph 虽不依赖 runtime,但依赖 cli 本地的 crate::discovery,不能单独下移 → 真正错位者为 0。 本 PR 改用「依赖」而非「命名」判定:只有既不需要 runtime、也不引用 cli 本地 类型的领域模块才算错位,并删除 layer-baseline.json(纠正后无已知债务)。 双向负向验证: - 新增自足领域模型 → 失败(正确捕获) - 新增依赖 runtime 的探针 → 放行(不再误报) crates/ 零改动;测试 997 通过 / 0 失败。
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f0f2d7a21e
ℹ️ 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".
| if "codeguard_runtime" in text or CLI_LOCAL.search(text): | ||
| continue |
There was a problem hiding this comment.
Parse Rust dependencies before exempting domain modules
When a standalone domain module merely mentions codeguard_runtime or crate::... in documentation, a string, or test-only code, this raw-text check treats that mention as a production dependency and skips the module entirely. I reproduced this by adding an otherwise self-contained _model.rs with codeguard_runtime only in its module documentation; the layering command used by .github/workflows/ci.yml still exited successfully. Consequently, the new gate can silently admit exactly the misplaced production logic it is intended to reject; inspect actual non-test imports or otherwise exclude comments, strings, and test-only sections before granting the exemption.
Useful? React with 👍 / 👎.
这是对 PR #1 的纠正
PR #1 的分层门禁按「命名像领域模块就应下移到 adapters」判定。这个判据是错的。
本仓
crates/codeguard-cli/tests/crate_boundaries.rs早已用测试强制依赖方向:codeguard-coreserdecodeguard-runtimecore/libc/ring(进程执行)codeguard-adapterscore/serde/serde_json/roxmltree/toml/sha2(纯解析与配置)codeguard-cliadapters不得依赖 runtime。而*_probe探针调用run_process_recorded、必须依赖 runtime——我是在实际执行搬迁、跑到
current_workspace_respects_dependency_direction失败时才发现的:codeguard-adapters: 禁止依赖 codeguard-runtime。PR #1 登记的 13 项债务,实测真实依赖:
codeguard_runtime→ 依边界不得进 adaptersmodule_graph/cargo_module_graph虽不依赖 runtime,但依赖 cli 本地的crate::discovery,不能单独下移→ 真正错位者为 0。 PR #1 等于在引导后来者走一条注定被本仓测试拒绝的路。
本 PR 的修改
codeguard_runtime、也不引用 cli 本地类型的领域模块才算错位。layer-baseline.json(纠正后无已知债务),不再留永不收紧的空额度。crate_boundaries是权威来源。双向负向验证
影响
crates/零改动——本 PR 只改门禁脚本与基线文件。测试 1003 通过 / 0 失败。PR #1 的 4 个
*_finding_identity迁移保持有效:它们只依赖codeguard_adapters的诊断类型与 serde/sha2,不碰 runtime,符合边界。下一步
若要继续治理 cli 的体量,方向不是把探针下移,而是:
discovery::DiscoveryReport先有独立归属,再连带module_graph/cargo_module_graph下移。两者都需要先改
crate_boundaries的既定边界,属于架构决策而非搬迁。