feat: drift-check §10 ADR 实体性校验——空壳 ADR 检出(红队 RB-D5,ADR-0016) - #50
Conversation
旧版仅查文件名存在:引用真实存在但 <100B 的空壳 ADR 可同时骗过 gate 格式检查与 §10 存在性检查,GM-2 '无 ADR 不合并' 形同虚设。 contents API 自带 size 字段,零额外请求完成实体性校验。
|
Warning Review limit reached
Next review available in: 20 minutes Limit details: You’ve used all 3 included reviews currently available. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Comment |
PR Summary by QodoDetect Empty ADR Stubs in Governance Drift Checks
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1.
|
回应 qodo 意见(High 落码,Medium 凭据项以设计依据回复): 1. 字节填充绕过(High):size>=100B 可被空白/注释/填充字符绕过——空壳 ADR 仍可骗过校验。改为拉取被引 ADR 全文做结构校验:H1 编号行、 status/状态 行、背景/决策章节齐备且决策节有正文,四者缺一即判 空壳;读取失败 fail-closed。同名多文件(ADR-0011 先例)任一满足 即通过;按编号缓存避免重复拉取。 2. 凭据项(Medium,不落码):与 §1-§9 一致使用 AGENTS.md 声明的 GOVERNANCE_TOKEN 接口("GH_TOKEN=<org admin> bash governance/drift-check.sh");agent-registry 私有仓 contents 读取 本就需要跨仓权限,工作流仅 schedule/dispatch 于可信 main 运行。 验证:单元测试 4 场景(真实结构 ok/空壳 shell/130 字节 # 填充 shell/ 缺失 missing)全过;真实 API 全量跑——既有 15 个 ADR 全部判 ok(含 中文"状态:"变体的 ADR-0010),仅 ADR-0016 正确报幽灵(PR #21 未合)。
ADR-0016(决策 6,解决 .github #45 RB-D5)
问题(复核属实):§10 后验仅
grep -q "^ADR-${num}-" <<<"$ADR_FILES"判文件名存在——红队演示:提交者引用一个真实存在但内容为空的 ADR 文件(或占位符),gate 的格式正则(\bADR-[0-9]{4}\b)放行、§10 判"存在"OK——"有 ADR"被解释为"文件存在",GM-2 决策背书无实质记录。修复:§10 从存在性升级为存在性+实体性:
size字段——零额外 API 请求完成校验<100B= 空壳 ADR → 计漂移(100B 是宽松下界:连标题+状态+一句话都装不下的文件不可能记录决策;真实 ADR 均 >1KB,现有 16 个 ADR 最小者远超此界).name | startswith("ADR-NNNN-")顺带消除旧 grep 前缀匹配的边缘误报可能本地实测(真实 org 数据):
OK adr-reference-existence(窗口内合并 PR 的 ADR 引用全部真实);bash -n通过。