Skip to content

refactor: 近一周 PR 技术债清扫(行为保持) - #125

Merged
randypanding merged 1 commit into
mainfrom
refactor/tech-debt-2026-08-26
Aug 26, 2026
Merged

refactor: 近一周 PR 技术债清扫(行为保持)#125
randypanding merged 1 commit into
mainfrom
refactor/tech-debt-2026-08-26

Conversation

@randypanding

@randypanding randypanding commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

范围与结论

对 2026-08-19 之后本仓全部 99 个 PR(#21..#124 逐一复盘(title/body/files/diff)。本仓创建于上周内,故「近一周」即全量 PR 史。结论:代码面整体紧致——无死文件、无 bare except、shell 均有 set -euo pipefail。仅清理 12 处 AST 级验证全仓零引用的未用导入/未用名(10 文件,+2/−11)。门语义零改动:不触碰关卡 workflow 求值逻辑、verdict 语义、抑制基线数据、action SHA。

全部 PR 一览(处置)

ISSUE-263 前期质量工具波(均落地,未动):

trust-gate(#63)— 本 PR 重构对象之一:

adversary ISSUE-263 波:

质量仪器波(IR-0004):

运营/配置/策略类(不可动或纯数据):

#95#111#114#120 为 issue 编号,仓库中不存在对应 PR。

重构明细(行为保持论证)

文件 移除 出处 PR 论证
pipeline/adversary/cnb_bridge.py from typing import Any #73 #74 AST 全仓扫描零引用
pipeline/adversary/golden_set.py from typing import Any #80 #82 #83 同上
pipeline/adversary/holdout_registry.py from typing import Any #81 #82 同上
pipeline/adversary/e2e/e2e-runner.py from typing import Any #89 同上
pipeline/adversary/llm_verifier.py import math;可选导入行去 extract_score #72 #76 math 全文零出现;call_verifier/create_openai_client 各处在用
pipeline/entropy/tests/test_e2e.py import sys #56 同上(测试断言零增减)
pipeline/selftest-c/tests/test_registry.py import copy #103 同上
pipeline/trust-gate/tests/test_adjudicate.py import copy #63 同上
pipeline/trust-gate/tests/test_cli.py from-import 去掉 PREDICATES/UNLOCK_STATE #63 仅名字绑定,_helpers 模块仍完整导入
scripts/dep-supply-chain-check.py import copy #36 #43 AST 零引用

验证证据(本地实跑)

  • python -m py_compile(触达 10 文件 + 全仓 scripts/pipeline *.py)— 通过
  • bash -n 全部 scripts/pipeline *.sh — 通过
  • YAML 解析 62 个(workflows/policy/pipeline)— 通过
  • bash scripts/test-integrity-fixtures/run.sh — 通过(与 ci.yml 同款自测)
  • bash scripts/suppression-budget-selftest.sh — 通过(同款)
  • python -m unittest:trust-gate test_adjudicate+test_cli 17 例 OK;selftest-c test_registry 14 例 OK;entropy test_e2e 10 例 OK(共 41 例全绿)
  • actionlint 本机未安装(未改动任何 workflow YAML,风险面为零);diff 无 CRLF 整文件抖动(+2/−11)

门语义声明

本 PR 不修改:org-gate / suppression-gate / adversary-gate / diff-coverage / dep-review 的判定与求值逻辑;任何 verdict/threshold/EXPECTED_SKIP/exemption 语义;policy/suppressions.yaml 及一切基线数据;任何 pinned action SHA。所有变更均为导入语句级的机械删除。

Summary by CodeRabbit

  • 重构

    • 清理多处未使用的导入,减少代码冗余。
    • 未改变现有运行逻辑、公共接口或验证流程。
  • 测试

    • 移除测试代码中的无用依赖,测试行为保持不变。

对近一周(#21..#124)全部 PR 复盘后的机械债清理:仅删除 AST 级验证
「全仓零引用」的未用导入/未用名,不改任何判定逻辑、阈值、白名单或
policy 数据。逐文件出处:

- pipeline/adversary/cnb_bridge.py:删未用 `from typing import Any`(#73/#74)
- pipeline/adversary/golden_set.py:删未用 `from typing import Any`(#80/#82/#83)
- pipeline/adversary/holdout_registry.py:删未用 `from typing import Any`(#81/#82)
- pipeline/adversary/e2e/e2e-runner.py:删未用 `from typing import Any`(#89)
- pipeline/adversary/llm_verifier.py:删未用 `import math`;可选库导入行去掉
  未用名 extract_score(call_verifier/create_openai_client 均在用,保留)(#72/#76)
- pipeline/entropy/tests/test_e2e.py:删未用 `import sys`(#56)
- pipeline/selftest-c/tests/test_registry.py:删未用 `import copy`(#103)
- pipeline/trust-gate/tests/test_adjudicate.py:删未用 `import copy`(#63)
- pipeline/trust-gate/tests/test_cli.py:from-import 去掉未用名
  PREDICATES/UNLOCK_STATE(保留 trust_gate 可导入性冒烟导入与 noqa 惯例)(#63)
- scripts/dep-supply-chain-check.py:删未用 `import copy`(#36/#43)

刻意不动(已核验非死代码):各模块 `from __future__ import annotations`;
fuzz/sast/symbolic 的 `_yamlmini` 双模式导入守卫(noqa F401,保证包路径);
golden_set 等 try-import yaml 的环境 fail-closed 守卫;org-gate /
suppression-gate / adversary-gate 等关卡 workflow 与 policy/suppressions.yaml
基线数据——门语义一概不变。

验证:
- py_compile 全部 scripts/pipeline *.py 通过;bash -n 全部 *.sh 通过
- workflows/policy/pipeline 共 62 个 YAML 解析通过
- scripts/test-integrity-fixtures/run.sh、scripts/suppression-budget-selftest.sh 通过
- python -m unittest:trust-gate test_adjudicate+test_cli 17 例、
  selftest-c tests.test_registry 14 例、entropy tests.test_e2e 10 例——全绿
Copilot AI lite review requested due to automatic review settings August 26, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Remove unused imports across pipeline and gate tooling

✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Removes twelve unreferenced imports and names across ten Python files.
• Preserves verifier, gate, test, and supply-chain behavior unchanged.
Diagram

graph TD
  A["AST audit"] --> B["Import cleanup"] --> C["Adversary modules"] --> F["Runtime behavior"]
  B --> D["Pipeline tests"] --> G["Test behavior"]
  B --> E["Supply check"] --> H["Check behavior"]
Loading
High-Level Assessment

Directly removing statically confirmed unused imports is the optimal approach. Retaining them with lint suppressions or broadening this PR into automated lint enforcement would add noise or scope without improving this behavior-preserving cleanup.

Files changed (10) +2 / -11

Refactor (6) +1 / -7
cnb_bridge.pyRemove unused Any import from CNB bridge +0/-1

Remove unused Any import from CNB bridge

• Removes the unreferenced 'typing.Any' import. CNB API and canary execution behavior are unchanged.

pipeline/adversary/cnb_bridge.py

e2e-runner.pyRemove unused Any import from E2E runner +0/-1

Remove unused Any import from E2E runner

• Drops the unused 'typing.Any' import from the adversary E2E entrypoint. Runner behavior and path handling remain unchanged.

pipeline/adversary/e2e/e2e-runner.py

golden_set.pyRemove unused Any import from golden-set tooling +0/-1

Remove unused Any import from golden-set tooling

• Removes the unused 'typing.Any' dependency while retaining YAML import guards and golden-set behavior.

pipeline/adversary/golden_set.py

holdout_registry.pyRemove unused Any import from holdout registry +0/-1

Remove unused Any import from holdout registry

• Deletes the unreferenced 'typing.Any' import. Registry validation and fail-closed YAML handling remain intact.

pipeline/adversary/holdout_registry.py

llm_verifier.pyTrim unused verifier imports +1/-2

Trim unused verifier imports

• Removes the unused standard-library 'math' import and optional-package 'extract_score' symbol. The active verifier client and call integrations remain imported and unchanged.

pipeline/adversary/llm_verifier.py

dep-supply-chain-check.pyRemove unused copy import from supply-chain check +0/-1

Remove unused copy import from supply-chain check

• Deletes the unused 'copy' import. Dependency validation and supply-chain policy behavior remain unchanged.

scripts/dep-supply-chain-check.py

Tests (4) +1 / -4
test_e2e.pyRemove unused sys import from entropy test +0/-1

Remove unused sys import from entropy test

• Deletes an unused 'sys' import from the entropy E2E test without changing test setup or assertions.

pipeline/entropy/tests/test_e2e.py

test_registry.pyRemove unused copy import from registry tests +0/-1

Remove unused copy import from registry tests

• Removes the unused 'copy' import. Registry validation, idempotency, and retirement test coverage remain unchanged.

pipeline/selftest-c/tests/test_registry.py

test_adjudicate.pyRemove unused copy import from adjudication tests +0/-1

Remove unused copy import from adjudication tests

• Drops the unused 'copy' import without altering trust-gate adjudication scenarios or assertions.

pipeline/trust-gate/tests/test_adjudicate.py

test_cli.pyNarrow trust-gate helper imports +1/-1

Narrow trust-gate helper imports

• Removes unused 'PREDICATES' and 'UNLOCK_STATE' helper imports while retaining the explicit 'trust_gate' smoke import and all used CLI fixtures.

pipeline/trust-gate/tests/test_cli.py

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can start a comment with 'qodo' or '@qodo' to chat about any finding

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: adf870bc-22c7-413f-a63c-ac4d4ffaad25

📥 Commits

Reviewing files that changed from the base of the PR and between bb00053 and 1c89a44.

📒 Files selected for processing (10)
  • pipeline/adversary/cnb_bridge.py
  • pipeline/adversary/e2e/e2e-runner.py
  • pipeline/adversary/golden_set.py
  • pipeline/adversary/holdout_registry.py
  • pipeline/adversary/llm_verifier.py
  • pipeline/entropy/tests/test_e2e.py
  • pipeline/selftest-c/tests/test_registry.py
  • pipeline/trust-gate/tests/test_adjudicate.py
  • pipeline/trust-gate/tests/test_cli.py
  • scripts/dep-supply-chain-check.py
💤 Files with no reviewable changes (8)
  • pipeline/adversary/cnb_bridge.py
  • scripts/dep-supply-chain-check.py
  • pipeline/adversary/golden_set.py
  • pipeline/adversary/e2e/e2e-runner.py
  • pipeline/entropy/tests/test_e2e.py
  • pipeline/selftest-c/tests/test_registry.py
  • pipeline/adversary/holdout_registry.py
  • pipeline/trust-gate/tests/test_adjudicate.py

Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

本次变更删除多个生产代码和测试文件中的未使用导入。运行逻辑、公共接口和测试行为未改变。

Changes

导入清理

Layer / File(s) Summary
移除未使用导入
pipeline/adversary/*, pipeline/entropy/tests/test_e2e.py, pipeline/selftest-c/tests/test_registry.py, pipeline/trust-gate/tests/*, scripts/dep-supply-chain-check.py
删除未使用的 typing.Anymathextract_scoresyscopyPREDICATESUNLOCK_STATE 导入。

Suggested labels: tech-debt

Merge Risk: ⚪ Minimal · up to 1c89a

This PR removes unused imports and names without changing workflow gates or runtime behavior; the localized cleanup is merge-ready after normal checks, with no actionable merge-blocking risk remaining.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题使用有效的 Conventional Commits 前缀 refactor,长度为 28 个字符,且准确概括了本次未使用导入清理变更。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/tech-debt-2026-08-26

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

@randypanding
randypanding merged commit 7474018 into main Aug 26, 2026
33 checks passed
@randypanding
randypanding deleted the refactor/tech-debt-2026-08-26 branch August 26, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants