chore: ratchet architecture debt metrics - #8134
Conversation
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
687d473 to
6d4b0ed
Compare
|
Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. 中文请勿对活跃的 PR 执行 rebase 或 force-push,因为这会使已有的评审评论失效。另外,供日后参考:作为集成流程的一部分,机器人始终会自动将所有改动压缩(squash)为单个提交。 |
|
Closing as superseded. #9689 merged the invariant-classification doc, which records the decision that line-count guards were considered and rejected — size is a symptom, and the invariant worth protecting is "don't add new responsibilities", which is review-only, not a lint threshold. This ratchet enforces that rejected line-count threshold, and its baseline has already drifted against main (the CI failure is stale-baseline drift, not a product regression). Reopen if you'd rather keep the ratchet as a separate mechanism. |
What this PR does
Adds one deterministic architecture-debt ratchet covering selected production source under
packages/core/srcandpackages/cli/src. The checked-in JSON baseline records per-path oversized-file line counts, an explicit@google/genaiimporting-file allowlist, and the exact core public-export declaration count.Why it's needed
This keeps the current architecture debt from growing while leaving hotspot refactors and specialized Config/ACP boundary guards to their dedicated lanes. Intentional baseline changes remain visible in one reviewed file.
Reviewer Test Plan
How to verify
Run
npx vitest run --config ./scripts/tests/vitest.config.ts scripts/tests/check-architecture-debt.test.jsandnode scripts/check-architecture-debt.js. The focused tests inject controlled source fixtures and assert actionable failures for an oversized-file growth/new-file case, a new production@google/genaiimport, and core public-export growth. The actual check passes the main-derived tree.Evidence (Before & After)
N/A — non-user-visible validation guard.
Tested on
Environment (optional)
Node 22.x, Vitest 3.2.4.
Risk & Scope
scripts/architecture-debt-baseline.json.Linked Issues
References #4063.
中文说明
本 PR 增加一个确定性的架构债务增长检查,覆盖
packages/core/src和packages/cli/src中选定的生产代码。基线文件逐路径记录超过 1000 行的生产文件及其行数,记录完整排序的生产@google/genai导入文件白名单,并记录 core 入口文件的精确公共导出声明数量。明确排除测试/规格文件、生成文件、schema 文件、fixtures、mocks 和文件名包含 adapter/schema 的适配器或 schema 文件。检查脚本通过现有 scripts + Vitest 模式实现,CI full 校验任务中增加 1 分钟超时的直接 Node 检查。聚焦测试使用注入的临时 fixture,分别证明超大文件增长/新增、生产@google/genai导入新增以及 core 公共导出增长会产生可操作的失败信息。当前 main 派生树验证通过:123 个超大生产文件、135 个@google/genai导入文件、258 个 core 公共导出声明。