GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: drift-check §10 ADR 实体性校验——空壳 ADR 检出(红队 RB-D5,ADR-0016) by randypanding · Pull Request #50 · Cloudbird-Software/.github

Conversation

@randypanding

@randypanding randypanding commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

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 从存在性升级为存在性+实体性:

  • contents API 响应自带 size 字段——零额外 API 请求完成校验
  • 文件存在但 <100B = 空壳 ADR → 计漂移(100B 是宽松下界:连标题+状态+一句话都装不下的文件不可能记录决策;真实 ADR 均 >1KB,现有 16 个 ADR 最小者远超此界)
  • 精确前缀匹配 .name | startswith("ADR-NNNN-") 顺带消除旧 grep 前缀匹配的边缘误报可能

本地实测(真实 org 数据):OK adr-reference-existence(窗口内合并 PR 的 ADR 引用全部真实);bash -n 通过。

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@randypanding
feat: drift-check §10 ADR 实体性校验——空壳 ADR 从存在性放行变为漂移(红队 RB-D5,ADR-0016)
1a3040d
旧版仅查文件名存在:引用真实存在但 <100B 的空壳 ADR 可同时骗过
gate 格式检查与 §10 存在性检查,GM-2 '无 ADR 不合并' 形同虚设。
contents API 自带 size 字段,零额外请求完成实体性校验。
@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Warning

Review limit reached

@randypanding, you've reached your PR review limit, so we couldn't start this review.

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.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5632e3f1-3476-4746-9d95-d22602417160

📥 Commits

Reviewing files that changed from the base of the PR and between 0ffe714 and 87435b4.

📒 Files selected for processing (1)
  • governance/drift-check.sh

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@qodo-code-review

qodo-code-review Bot commented Aug 19, 2026

Copy link
Copy Markdown

PR Summary by Qodo

Detect Empty ADR Stubs in Governance Drift Checks

🐞 Bug fix ✨ Enhancement 🕐 Less than 10 minutes

Grey Divider

AI Description

• Validates referenced ADRs as files using exact filename-prefix matching.
• Flags ADR files below 100 bytes as non-substantive governance drift.
• Reuses Contents API metadata without additional network requests.
Diagram

graph TD
  A["Merged PRs"] --> B["Extract ADR refs"] --> D{"Matching file?"}
  C["Contents listing"] --> D
  D -- "No" --> F["Ghost ADR drift"]
  D -- "Yes" --> E{"At least 100B?"}
  E -- "No" --> G["Stub ADR drift"]
  E -- "Yes" --> H["Valid reference"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Fetch and parse ADR contents
  • ➕ Can validate required sections and meaningful decision text
  • ➕ Provides stronger assurance than a byte threshold
  • ➖ Requires additional API requests or repository checkout
  • ➖ Adds parsing rules, failure modes, and maintenance overhead
2. Validate ADRs at source
  • ➕ Rejects empty ADRs when they enter agent-registry
  • ➕ Centralizes substantive validation around the ADR source of truth
  • ➖ Does not independently protect consumers from historical placeholders
  • ➖ Cannot replace the cross-repository post-hoc check under current token constraints

Recommendation: Keep the proposed metadata-size check as the immediate defense: it closes the empty-file bypass with no extra API calls and minimal complexity. Source-repository schema validation can later complement it if stronger structural guarantees are required.

Files changed (1) +8 / -2

Bug fix (1) +8 / -2
drift-check.shReject missing and undersized referenced ADR files +8/-2

Reject missing and undersized referenced ADR files

• Replaces grep-based filename existence checks with a jq lookup requiring a matching file entry. References to files smaller than 100 bytes now produce drift, using size metadata already returned by the Contents API.

governance/drift-check.sh

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@qodo-code-review

qodo-code-review Bot commented Aug 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Byte padding bypasses validation ✓ Resolved 🐞 Bug ⛨ Security
Description
The new check treats every matching file of at least 100 bytes as substantive, so an empty
placeholder containing 100 bytes of whitespace, comments, or filler passes without recording any
decision. This preserves the RB-D5 bypass the PR is intended to close and can incorrectly report the
ADR reference as valid.
Code

governance/drift-check.sh[R295-298]

+        elif [[ "$(jq -r .size <<<"$ROW")" -lt 100 ]]; then
+          # 实体性校验(红队 RB-D5,ADR-0016 决策 6):文件存在但 <100B = 空壳 ADR
+          # ——同时骗过 gate 格式检查与旧版 §10 存在性检查;"有 ADR"须=有实质决策记录
+          drift "repo '$r' PR#$pnum 引用空壳 ADR ${ref}(文件存在但 $(jq -r .size <<<"$ROW")B < 100B——无实质决策记录,GM-2 形同虚设)"
Relevance

●●● Strong

The PR explicitly targets RB-D5 substantive validation; recent governance bypass findings were
accepted as security fixes.

PR-#19

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The lookup selects only directory metadata for a matching file, and the sole substantive rejection
condition is .size < 100; therefore every matching file with size >= 100 is accepted regardless
of its contents.

governance/drift-check.sh[291-299]
governance/drift-check.sh[273-277]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The substantive ADR check uses only the Contents API `size` metadata. A contributor can pad an otherwise empty placeholder to 100 bytes, causing it to pass without containing a decision.

## Issue Context
Inspect the referenced document content rather than equating byte length with substance. Validate required ADR structure and meaningful non-whitespace content, such as a title, accepted status, context, and decision section; malformed or unavailable content must fail closed.

## Fix Focus Areas
- governance/drift-check.sh[273-299]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. ROW uses broad token ✗ Dismissed 📘 Rule violation ⛨ Security
Description
The added ADR validation consumes GitHub API data fetched with the long-lived GOVERNANCE_TOKEN
rather than a single-repository cloudbrid-agent token from scripts/gh-app-token.sh. This bypasses
the required App identity, least-privilege scope, and associated audit trail.
Code

governance/drift-check.sh[291]

+        ROW=$(jq -c --arg p "ADR-${num}-" '[.[] | select((.name | startswith($p)) and (.type == "file"))] | first // empty' <<<"$ADR_DIR_LISTING")
Relevance

●●● Strong

Recent PR #19 accepted closely related App-identity and single-repository token hardening in this
governance automation.

PR-#19

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 2778539 requires GitHub API automation to obtain credentials exclusively through
scripts/gh-app-token.sh with single-repository scope. The changed ROW logic reads
ADR_DIR_LISTING, which is fetched through api; that helper uses externally supplied GH_TOKEN,
and the workflow populates it directly from secrets.GOVERNANCE_TOKEN instead of invoking the
required App-token script.

Rule 2778539: Agent operations must use the cloudbrid-agent GitHub App identity via scripts/gh-app-token.sh with single-repo tokens
governance/drift-check.sh[19-22]
governance/drift-check.sh[273-291]
.github/workflows/governance-drift.yml[20-28]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new ADR substantive check relies on API responses authenticated using `GOVERNANCE_TOKEN`, contrary to the required cloudbrid-agent GitHub App authentication mechanism.

## Issue Context
Generate tokens through `scripts/gh-app-token.sh` with an explicit repository scope. Use an `agent-registry`-scoped token for the decisions listing and an appropriate single-repository token for each repository's pull-request query; remove reliance on the generic governance token.

## Fix Focus Areas
- governance/drift-check.sh[19-22]
- governance/drift-check.sh[273-291]
- .github/workflows/governance-drift.yml[20-28]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 7 rules
✅ Web pages:
  🌐 contents#get-a-repository-readme
  🌐 contents?apiVersion=2026-03-10
  🌐 Pagination for the get_contents function? · Issue #1626 · PyGithub/PyGithub
  +2 more
Review mode: ⚖️ Balanced: This is a runtime governance shell change that alters ADR validation behavior and depends on API JSON semantics and jq handling; the logic is localized, but the gate impact warrants a complete single-pass review.

Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

qodo-code-review[bot]
qodo-code-review Bot reviewed Aug 19, 2026
View reviewed changes
Comment thread governance/drift-check.sh Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread governance/drift-check.sh Resolved

Uh oh!

There was an error while loading. Please reload this page.

randypanding and others added 2 commits August 19, 2026 11:54
@randypanding
Merge branch 'main' into adr-substantive-check
1a51761
randypanding
fix: §10 实体性校验从字节阈值升级为内容结构校验(review 修复)
87435b4
回应 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 未合)。
@randypanding
randypanding merged commit 813e43b into main Aug 19, 2026
6 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@randypanding
randypanding deleted the adr-substantive-check branch August 19, 2026 04:15
This was referenced Aug 19, 2026
治理体系红队测试问题总报告(客观证据,79 项,不含处置建议) #45
Closed
[治理体检] Cloudbird 治理体系红队演练问题报告(流程断点/角色不可触发/任务无人认领/反馈死循环) #46
Closed
This was referenced Aug 19, 2026
fix: 治理层对齐——ruleset 合并解锁+GOVERNANCE 口径+组织地图+gate 存在性(ADR-0021) #73
Merged
fix: drift 清零——apply §2 必填字段+§7b 补申报+§8 bootstrap 豁免(ADR-0021) #75
Merged
ADR-0025: agent-platform 申报入图 + bootstrap 豁免登记 + Python 语言准入 #78
Merged
governance: 登记 agent-registry 破玻璃直推豁免(ADR-0030) #99
Merged
governance: allow_auto_merge 纳入期望状态对账(P1-1,ADR-0029) #100
Merged
testing.yaml: test_integrity 规则/阈值声明(ADR-0035 / #86,P2-1) #115
Merged
governance: auto-fix 上限执法 + 额度/成本熔断(P2-8,ADR-0040) #116
Merged
spec(IR-0001): agent 自治生产系统 条款级规格 v1 #129
Merged
This was referenced Aug 21, 2026
[自动合并 P2-1] 测试篡改检测门 #86
Closed
自动合并计划 #81
Closed
[自动合并 P2-2] 抑制标记预算门 #87
Closed
This was referenced Aug 21, 2026
feat(governance): adr-required/§10 索引感知 + archive 申报(W1-C1 #164,ADR-0053) #174
Merged
feat(governance): holdout 隔离断言 + 泄漏诱饵巡检(W1-C4 #167,ADR-0056) #176
Merged
feat(entry): 统一入口协议块+conductor 仲裁转介+factory-floor 板+dashboard 账本(W1-C3 #166,ADR-0055) #195
Merged
feat(governance): patrol 政策文件(W3-C2 .github#219,ADR-0065) #241
Merged
feat(drill): 缺陷样本库+选样引擎(W4-C4 .github#223,ADR-0069) #244
Merged
feat(dashboard): 北极星对互锁核心 metrics.py(W5-C4 .github#227,ADR-0073) #250
Merged
feat(dashboard): 度量 policy 阈值真源 metrics.yaml(W5-C4 .github#227,ADR-0073) #249
Merged
fix(governance): drift §15 分支钉点解引用 + §12 adversary 生效锚点(ADR-0083 关联补全) #370
Merged
This was referenced Aug 25, 2026
governance: REPOS.yaml 申报 Viral_Radar 入图(GM-4,ADR-0091) #374
Closed
providers: 云内网入图——self-cloud-pool/vault 条目 + 资产登记簿(W1-C1) #427
Merged
feat: butler/drill 影子双写 + 三源统一查询(W1-B2 后半,IR-0006) #430
Merged
feat: 轨迹层指针协议 pointer@1 + 内网 blob 最小实现(W1-B3,IR-0006) #431
Merged
feat: 波次 schema v1——卡模板扩展 + 解析器(W2-C3 前半,IR-0006) #432
Merged
fix: evidence-query 源缺席判定兼容 "No ref found" 404 报文形态(W2-C3 实测缺陷) #436
Merged
fix: elevation sweep revoke payload 序列化(W2-C4 实测缺陷) #443
Merged
feat: W4-R2 SLO 骨架进 sli-weekly+责任边界文件落盘(IR-0006) #454
Merged
fix: attest-drill 回溯步补 RUN_ID step env(run 33261139414 实测红) #457
Merged
feat: 非劣性 eval gate 家族+eval registry 绑定(IR-0006 W5-E1) #458
Merged
feat: conformance 语料库种子+门禁元治理四列+晋级账本(IR-0006 W6-M1) #461
Merged
docs: IR-0006 acceptance.md——T-15 十条回探+六问复测+T9 收口(W6-M3) #466
Merged
fix: butler-reconcile 落盘 git add 补 -f——butler 源账本不可用(#475/#476,ADR-0103) #477
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@qodo-code-review qodo-code-review[bot] qodo-code-review[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@randypanding
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.