Skip to content

feat(tools): 添加可审计的代码定位人工复核闭环#49

Open
Qiyuanqiii wants to merge 1 commit into
Tencent:mainfrom
Qiyuanqiii:codex/feat-issue-4-review-roundtrip
Open

feat(tools): 添加可审计的代码定位人工复核闭环#49
Qiyuanqiii wants to merge 1 commit into
Tencent:mainfrom
Qiyuanqiii:codex/feat-issue-4-review-roundtrip

Conversation

@Qiyuanqiii

@Qiyuanqiii Qiyuanqiii commented Jul 14, 2026

Copy link
Copy Markdown

关联 Issue:#4

背景与定位

Issue #4 的现有相关 PR 主要实现 current -> ±5 -> same file -> repo unique
自动搜索,但在无法唯一确认时都停留在导出 needs_human.csv

本 PR 不再实现另一套自动匹配器,而是补齐后续人工复核闭环:将审阅者
选择的位置重新对照固定 commit 源码验证,再安全写回 entries.jsonl
并生成完整审计记录。

实现内容

  • init 兼容现有队列中的 field_pathnode_path 两种格式。
  • 为每项决定生成稳定 review_idexpected_node_sha256
  • 节点内容变化后拒绝旧决定,避免静默套用过期复核结果。
  • 支持 applykeep 和 pending 状态,pending 默认阻止写回。
  • 从 URL 隔离的 bare Git cache 读取固定 commit 的精确 blob。
  • 校验路径大小写,拒绝路径穿越、symlink、submodule、二进制及超大文件。
  • 支持空白容忍的多行代码匹配和窄范围 CJK 注释投影。
  • verify=1 条目默认受保护,需显式 --include-verified 才能修改。
  • 原子生成完整 JSONL、applied diff 和 audit,不留下部分写入结果。
  • 在线 fetch 记录 commit 来源证明,--offline 会严格验证该来源记录。

与现有方案的边界

本 PR 不排名候选,也不自动选择歧义位置,因此不会扩大自动修复器的
误报范围。原始 data/entries.jsonl 永远不会被原地修改。

已对 #11#16#18#32#35#36#39 的七种人工队列格式进行
兼容烟测,初始化结果均与原队列行数严格一致。

审阅者复现命令

git fetch origin pull/<PR_NUMBER>/head:pr-<PR_NUMBER>
git switch pr-<PR_NUMBER>

python -m unittest discover -s tests -v
python -m py_compile tools/location_review.py tests/test_location_review.py
python examples/load_dataset.py
git diff --check

功能复现

python tools/location_review.py init \
  --input data/entries.jsonl \
  --queue reports/needs_human.csv \
  --decisions reports/location_review_decisions.csv

# 填写 decision/new_file/new_line/reviewer/rationale 后执行:
python tools/location_review.py apply \
  --input data/entries.jsonl \
  --decisions reports/location_review_decisions.csv \
  --output data/entries.reviewed.jsonl \
  --diff reports/location_review_diff.csv \
  --audit reports/location_review_audit.csv

验证结果

  • 单元测试:17/17 通过。
  • 数据集:184 reports、408 entries、393 human-audited entries。
  • 七个现有队列兼容结果:75/75、75/75、56/56、56/56、56/56、26/26、56/56。
  • 真实 GitHub online/offline 输出 SHA-256 完全一致。
  • py_compile 与 git diff --check 通过。

验证截图

image

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