Skip to content

fix(sentrux): coupling 口径只算建模语言,解开 PS1 退役与结构闸门的对立 (#78) - #81

Open
2233admin wants to merge 3 commits into
mainfrom
fix/sentrux-coupling-denominator
Open

fix(sentrux): coupling 口径只算建模语言,解开 PS1 退役与结构闸门的对立 (#78)#81
2233admin wants to merge 3 commits into
mainfrom
fix/sentrux-coupling-denominator

Conversation

@2233admin

Copy link
Copy Markdown
Owner

口径修正,不是放水。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_increased 45.64 → 45.73 上。剩下 ~43 个调用点会一个不落地撞同一堵墙——闸门量的是这场战役本身,不是退化。

改法

分子分母都只覆盖建模语言。没有未建模语言的仓库,分数一个数都不变。本树的诚实耦合是 74.41(1064 条边 / 143 个建模文件),稀释口径报的 45.48。

其余指标——体积、函数数、复杂度、god file——仍然覆盖全部采集扩展名。PowerShell god file 仍然是 god file。

连带处理,都在同一个提交里

  • baseline 重存,schema 升 v3。v2 baseline 存的是本引擎再也算不出来的数;不升 schema,升级后第一次跑就会报一个凭空捏造的 ~30 分耦合退化。现在它 fail closed 成 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
  • PS1 shim 同步改legacy/tools/sentrux-shim/sentrux-lite-core.ps1),否则经 options.toolPathPrefix 注入的 shim 会拿旧口径的分数去比新口径的 baseline。改完实测两侧同为 74.41 / 143 / 1064。
  • [coupling_basis] 输出行 + metrics.import_modeled_files,把分母直接写出来,不留给读者从比值反推。

验证

新增测试:

  • 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

…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
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@repowise-bot

repowise-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

🔒 Repowise is not analyzing this repository

The PR bot is free on public repositories. This one is private, which needs a Pro plan.

See plans · Manage this repository

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 119 files, which is 19 over the limit of 100.

To get a review, narrow the scope:
• coderabbit review --committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0cb727cb-25b0-44da-9c14-88387b40f5dd

📥 Commits

Reviewing files that changed from the base of the PR and between 6b226e9 and c22126c.

📒 Files selected for processing (119)
  • .sentrux/baseline.json
  • .sentrux/rules.toml
  • CHANGELOG.md
  • crates/code-intel-cli/src/sentrux_gate.rs
  • legacy/tools/sentrux-shim/sentrux-lite-core.ps1
  • orchestration/integrations.json
  • orchestration/internalization/sentrux.json
  • orchestration/retirements/e02-recommender/compatibility-retirement-deletion-diff.json
  • orchestration/retirements/e02-recommender/compatibility-retirement-manifest.json
  • orchestration/retirements/e02-recommender/compatibility-retirement-ticket.json
  • orchestration/retirements/e02-recommender/e00-request.json
  • orchestration/retirements/e02-recommender/e01-request.json
  • orchestration/retirements/e02-recommender/e01-stderr.txt
  • orchestration/retirements/e02-recommender/evidence/c00-necessity.json
  • orchestration/retirements/e02-recommender/evidence/compatibility-window.json
  • orchestration/retirements/e02-recommender/evidence/contract-parity.json
  • orchestration/retirements/e02-recommender/evidence/dependency-d02-clean-machine.json
  • orchestration/retirements/e02-recommender/evidence/dependency-repo-snapshot.json
  • orchestration/retirements/e02-recommender/evidence/effect-parity.json
  • orchestration/retirements/e02-recommender/evidence/golden-parity.json
  • orchestration/retirements/e02-recommender/evidence/independent-approval.json
  • orchestration/retirements/e02-recommender/evidence/registry-reconciliation.json
  • orchestration/retirements/e02-recommender/evidence/replacement-atom.json
  • orchestration/retirements/e02-recommender/evidence/rollback-execution.json
  • orchestration/retirements/e02-recommender/evidence/usage-observation.json
  • orchestration/retirements/e02-recommender/gate-out/compatibility-retirement-decision.json
  • orchestration/retirements/e03-provider-preflight/compatibility-retirement-deletion-diff.json
  • orchestration/retirements/e03-provider-preflight/compatibility-retirement-manifest.json
  • orchestration/retirements/e03-provider-preflight/compatibility-retirement-ticket.json
  • orchestration/retirements/e03-provider-preflight/e00-request.json
  • orchestration/retirements/e03-provider-preflight/e01-request.json
  • orchestration/retirements/e03-provider-preflight/e01-stderr.txt
  • orchestration/retirements/e03-provider-preflight/evidence/c00-necessity.json
  • orchestration/retirements/e03-provider-preflight/evidence/compatibility-window.json
  • orchestration/retirements/e03-provider-preflight/evidence/contract-parity.json
  • orchestration/retirements/e03-provider-preflight/evidence/dependency-a04-admissibility.json
  • orchestration/retirements/e03-provider-preflight/evidence/dependency-repo-snapshot.json
  • orchestration/retirements/e03-provider-preflight/evidence/effect-parity.json
  • orchestration/retirements/e03-provider-preflight/evidence/golden-parity.json
  • orchestration/retirements/e03-provider-preflight/evidence/independent-approval.json
  • orchestration/retirements/e03-provider-preflight/evidence/registry-reconciliation.json
  • orchestration/retirements/e03-provider-preflight/evidence/replacement-atom.json
  • orchestration/retirements/e03-provider-preflight/evidence/rollback-execution.json
  • orchestration/retirements/e03-provider-preflight/evidence/usage-observation.json
  • orchestration/retirements/e03-provider-preflight/gate-out/compatibility-retirement-decision.json
  • orchestration/retirements/e04-codenexus-direct/compatibility-retirement-deletion-diff.json
  • orchestration/retirements/e04-codenexus-direct/compatibility-retirement-manifest.json
  • orchestration/retirements/e04-codenexus-direct/compatibility-retirement-ticket.json
  • orchestration/retirements/e04-codenexus-direct/e00-request.json
  • orchestration/retirements/e04-codenexus-direct/e01-request.json
  • orchestration/retirements/e04-codenexus-direct/e01-stderr.txt
  • orchestration/retirements/e04-codenexus-direct/evidence/c00-necessity.json
  • orchestration/retirements/e04-codenexus-direct/evidence/compatibility-window.json
  • orchestration/retirements/e04-codenexus-direct/evidence/contract-parity.json
  • orchestration/retirements/e04-codenexus-direct/evidence/dependency-b05.json
  • orchestration/retirements/e04-codenexus-direct/evidence/effect-parity.json
  • orchestration/retirements/e04-codenexus-direct/evidence/golden-parity.json
  • orchestration/retirements/e04-codenexus-direct/evidence/independent-approval.json
  • orchestration/retirements/e04-codenexus-direct/evidence/registry-reconciliation.json
  • orchestration/retirements/e04-codenexus-direct/evidence/replacement-atom.json
  • orchestration/retirements/e04-codenexus-direct/evidence/rollback-execution.json
  • orchestration/retirements/e04-codenexus-direct/evidence/usage-observation.json
  • orchestration/retirements/e04-codenexus-direct/gate-out/compatibility-retirement-decision.json
  • orchestration/retirements/e07-native-code/compatibility-retirement-deletion-diff.json
  • orchestration/retirements/e07-native-code/compatibility-retirement-manifest.json
  • orchestration/retirements/e07-native-code/compatibility-retirement-ticket.json
  • orchestration/retirements/e07-native-code/e00-request.json
  • orchestration/retirements/e07-native-code/e01-request.json
  • orchestration/retirements/e07-native-code/e01-stderr.txt
  • orchestration/retirements/e07-native-code/evidence/c00-necessity.json
  • orchestration/retirements/e07-native-code/evidence/compatibility-window.json
  • orchestration/retirements/e07-native-code/evidence/contract-parity.json
  • orchestration/retirements/e07-native-code/evidence/dependency-inventory.json
  • orchestration/retirements/e07-native-code/evidence/dependency-snapshot.json
  • orchestration/retirements/e07-native-code/evidence/effect-parity.json
  • orchestration/retirements/e07-native-code/evidence/golden-parity.json
  • orchestration/retirements/e07-native-code/evidence/independent-approval.json
  • orchestration/retirements/e07-native-code/evidence/registry-reconciliation.json
  • orchestration/retirements/e07-native-code/evidence/replacement-atom.json
  • orchestration/retirements/e07-native-code/evidence/rollback-execution.json
  • orchestration/retirements/e07-native-code/evidence/usage-observation.json
  • orchestration/retirements/e07-native-code/gate-out/compatibility-retirement-decision.json
  • orchestration/retirements/e08-hospital/compatibility-retirement-deletion-diff.json
  • orchestration/retirements/e08-hospital/compatibility-retirement-manifest.json
  • orchestration/retirements/e08-hospital/compatibility-retirement-ticket.json
  • orchestration/retirements/e08-hospital/e00-request.json
  • orchestration/retirements/e08-hospital/e01-request.json
  • orchestration/retirements/e08-hospital/e01-stderr.txt
  • orchestration/retirements/e08-hospital/evidence/c00-necessity.json
  • orchestration/retirements/e08-hospital/evidence/compatibility-window.json
  • orchestration/retirements/e08-hospital/evidence/contract-parity.json
  • orchestration/retirements/e08-hospital/evidence/dependency-a04.json
  • orchestration/retirements/e08-hospital/evidence/dependency-b07.json
  • orchestration/retirements/e08-hospital/evidence/effect-parity.json
  • orchestration/retirements/e08-hospital/evidence/golden-parity.json
  • orchestration/retirements/e08-hospital/evidence/independent-approval.json
  • orchestration/retirements/e08-hospital/evidence/registry-reconciliation.json
  • orchestration/retirements/e08-hospital/evidence/replacement-atom.json
  • orchestration/retirements/e08-hospital/evidence/rollback-execution.json
  • orchestration/retirements/e08-hospital/evidence/usage-observation.json
  • orchestration/retirements/e08-hospital/gate-out/compatibility-retirement-decision.json
  • orchestration/retirements/e10-index/compatibility-retirement-deletion-diff.json
  • orchestration/retirements/e10-index/compatibility-retirement-manifest.json
  • orchestration/retirements/e10-index/compatibility-retirement-ticket.json
  • orchestration/retirements/e10-index/e00-request.json
  • orchestration/retirements/e10-index/e01-request.json
  • orchestration/retirements/e10-index/e01-stderr.txt
  • orchestration/retirements/e10-index/evidence/c00-necessity.json
  • orchestration/retirements/e10-index/evidence/compatibility-window.json
  • orchestration/retirements/e10-index/evidence/contract-parity.json
  • orchestration/retirements/e10-index/evidence/dependency-e05.json
  • orchestration/retirements/e10-index/evidence/effect-parity.json
  • orchestration/retirements/e10-index/evidence/golden-parity.json
  • orchestration/retirements/e10-index/evidence/independent-approval.json
  • orchestration/retirements/e10-index/evidence/registry-reconciliation.json
  • orchestration/retirements/e10-index/evidence/replacement-atom.json
  • orchestration/retirements/e10-index/evidence/rollback-execution.json
  • orchestration/retirements/e10-index/evidence/usage-observation.json
  • orchestration/retirements/e10-index/gate-out/compatibility-retirement-decision.json

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

`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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant