fix(sentrux): coupling 口径只算建模语言,解开 PS1 退役与结构闸门的对立 (#78) - #81
Conversation
…ree (#78) `coupling_score` is import lines per file. The scanner reads import/from/use/mod/require(/#include/using, none of which is how PowerShell declares a dependency — it dot-sources and calls Import-Module. Counting .ps1/.psm1 in the denominator therefore made the score fall whenever PowerShell grew and rise whenever it shrank. Under the PS1 retirement campaign that inverts the gate. PR #80 deleted one PowerShell test, added the Rust test that replaces it, raised quality_signal by 60, and still failed `coupling_increased` 45.64 -> 45.73. Every one of the ~43 remaining call points would have failed the same way, so the ratchet was measuring the campaign rather than regression. Numerator and denominator now both cover only languages whose imports the scanner models. A tree with none of the unmodelled languages scores exactly as before; this one measures 74.41 (1064 edges over 143 modelled files) where dilution reported 45.48. Everything else — size, functions, complexity, god files — still covers every collected extension. Consequences, all in this commit: - baseline re-saved; schema -> code-intel-sentrux-baseline.v3, so a v2 baseline fails closed as `baseline_engine_mismatch` with the re-baseline instruction instead of reporting a fabricated ~30-point coupling regression on first run after upgrade. - max_coupling accepts a bare number as well as an A..D grade. The ladder tops out at D = 6 imports per file, which no idiomatic Rust tree stays under, so keeping "D" would mean a permanently red rule. .sentrux/rules.toml records the measured 76.0 as a ratchet; tightening is tracked with the other threshold debt in #14. - the PowerShell shim mirrors both changes, so a shim injected through options.toolPathPrefix cannot compare an old-formula score against a new-formula baseline. - [coupling_basis] and metrics.import_modeled_files report the denominator rather than leaving it to be derived from the ratio. Verified: cargo test 2633 passed / 46 suites; cargo fmt clean; retirement packet suite 8 packets + 2 audits PASS; authoritative self-scan puts diagnosis.hospital back to succeeded/pass on this tree. With #80's diff applied on top, the gate reads 74.41 -> 74.31 and passes. Refs #78
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
🔒 Repowise is not analyzing this repository The PR bot is free on public repositories. This one is private, which needs a Pro plan. |
|
Important Review skippedToo many files! This PR contains 119 files, which is 19 over the limit of 100. To get a review, narrow the scope: Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (119)
You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
`provider.sentrux-adapt` carries the gate source digest in two places: the internalization record and `orchestration/integrations.json`'s toolchainDigests. The first commit updated only the record, so test-atomic-capability-contract.ps1 failed on all four CI lanes with "provider.sentrux-adapt toolchain digest is stale for crates/code-intel-cli/src/sentrux_gate.rs". test-atomic-capability-contract.ps1 now passes locally; the gate still reports no degradation. Refs #78
…ntegrations.json E02, E03, E04, E07, E08 and E10 all carry integrations.json in their frozen source set, so re-pinning the sentrux_gate.rs toolchain digest made every one of them stale. Same mechanism the E10 verifier documents for #48's edit to the same file. Regenerated with each packet's own generator at its recorded EvaluatedAt (1785441780), so the only fields that move are snapshotIdentity, artifact ref sha256s and the request/approval digest payloads that carry them. Blockers, decisions, evidence classes, window timestamps and file sets are byte-identical — verified field by field before installing. Also removes the generators' rollback scratch under legacy/work/ — it is gitignored but not invisible to the scanner, and three copies of run-code-intel.ps1 left there pushed the tree to 242 files / 36 god files and failed the gate on quality. Refs #78
1427647 to
c22126c
Compare
口径修正,不是放水。
coupling_score现在只按「扫描器认得其 import 语法的语言」计数,分子分母同时收口。病灶
coupling_score = import 行数 / 文件数 * 10。扫描器认的是import/from/use/mod/require(/#include/using——PowerShell 一条都不用,它靠 dot-source 和Import-Module。本树 239 个代码文件里 96 个是.ps1,它们只贡献 23 条(还多半是误匹配)import 行,却整整占了 40% 的分母。结果是这个指标实际在量「PowerShell 占比」:PowerShell 变多它就降,PowerShell 变少它就升。
放进 #78 的语境,闸门就是反的。#80 删掉一个 PowerShell 测试、加进取代它的 Rust 测试、
quality_signal涨了 60,然后照样挂在coupling_increased45.64 → 45.73 上。剩下 ~43 个调用点会一个不落地撞同一堵墙——闸门量的是这场战役本身,不是退化。改法
分子分母都只覆盖建模语言。没有未建模语言的仓库,分数一个数都不变。本树的诚实耦合是 74.41(1064 条边 / 143 个建模文件),稀释口径报的 45.48。
其余指标——体积、函数数、复杂度、god file——仍然覆盖全部采集扩展名。PowerShell god file 仍然是 god file。
连带处理,都在同一个提交里
baseline_engine_mismatch,附带重存指令。任何持有 v2 baseline 的仓库都必须重存。max_coupling除字母档外接受纯数字。A..D 阶梯顶格 D = 每文件 6 条 import,没有哪棵符合习惯的 Rust 树待得住——继续写"D"就是一条永久红的规则,跟当年 B/70/no-god 一个死法。.sentrux/rules.toml按既有先例记下实测棘轮 76.0,收紧作为债务挂在 roadmap: enforce self-dogfood release gates and add session intelligence #14。legacy/tools/sentrux-shim/sentrux-lite-core.ps1),否则经options.toolPathPrefix注入的 shim 会拿旧口径的分数去比新口径的 baseline。改完实测两侧同为 74.41 / 143 / 1064。[coupling_basis]输出行 +metrics.import_modeled_files,把分母直接写出来,不留给读者从比值反推。验证
cargo test:2633 passed / 46 suitescargo fmt --all -- --check:干净test-retirement-packets.ps1:8 packets + 2 audits 全 PASSdiagnosis.hospital从domain_failed回到succeeded/passCoupling: 74.41 -> 74.31、Quality: 3254 -> 3315、No degradation detected,exit 0新增测试:
coupling_ignores_files_whose_language_has_no_modeled_imports—— 加 10 个带 dot-source 的.ps1不动分数,删掉一个也不动every_code_extension_is_classified_as_import_modeled_or_not—— 新扩展名若没显式归类就红,防止再有语言悄悄混进分母coupling_limit_reads_ladder_grades_and_bare_numbers遗留
本树 74.41 超出 A..D 阶梯这件事本身是实情,不是这个 PR 造成的——旧口径一直在替它遮着。收紧到 D(60) 记在 #14。
Refs #78