fix(review-gate): 审查前 checkout 到被审 head sha + 回读校验 - #18
Merged
Conversation
mimosa 扫描读的是 clone 工作区文件而非 git 对象库 — fetch 只更新对象、 不动工作区, 不 checkout 会扫在上一轮旧代码上 (误报已修复/漏报新引入)。 - checkout_review_head(): --force --detach 到被审 sha, rev-parse 回读校验, 不一致抛 GitError 拒绝继续 (防浅 clone 缺对象等静默失败) - process_pr 在 fetch_pr_refs 后、--call 前接线, 失败走 mark_failure 退避 - 评论表头 head 行标注扫描基线语义 - 单测 3 例 + 全链路 fake git 记账 checkout/rev-parse 回显
PR #18 用 zcode_pr_review 自审发现的跟进修复: - P1-1 实例互斥: checkout 发生在 bridge 侧文件锁之外, 双实例共享同一 state/clone_root 时, 第二实例 (守护进程跑长审查期间手工 --once 调试) 会在 mimosa 扫描中途换掉工作区 (TOCTOU) → 静默扫错代码。 修法: 启动时对 <state_file>.lock 非阻塞 flock, 拿不到锁 exit 2; 正常退出释放, 崩溃时 OS 自动回收。 - P2-1 checkout --force 只丢弃 tracked 改动, untracked 残留跨轮存活 (mimosa 扫工作区文件) → checkout 前补 git clean --force -d -x, clone 为 gate 专有目录, 清到严格基线。 P2-2 (README 三态 verdict) 是跨分支审查视角产物, #19 合入后自然消解。 测试: fake git 补 clean 处理; +2 例 (clean 先于 checkout / 实例锁退出码 2 且不跑审查, 释放后可续跑); 77 全绿。
Owner
Author
狗食审查(zcode_pr_review 自审)结论:可以合并(P0 × 0 / P1 × 1 / P2 × 3),P1/P2 已在 f20cdd0 闭环:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17
问题
mimosa 扫描读的是 clone 工作区文件而非 git 对象库——fetch 只更新对象、不动工作区。不 checkout 时,PR 推新 commit 后工作区仍停留在上一轮的旧代码上,扫描基于陈旧代码:误报已修复的问题、漏报新引入的问题。
修复
checkout_review_head():git checkout --force --detach <head_sha>+rev-parse HEAD回读校验,不一致抛 GitError 拒绝继续(防浅 clone 缺对象等静默失败让扫描基线名不副实)process_pr在fetch_pr_refs后、--call前接线,失败走mark_failure退避测试
--call的 head 一致python3 tests/test_review_gate.py75 全绿 + ruff 通过