Skip to content

Gate the agent rule data and the tier runner behind a signature - #3247

Open
HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/1-policy-sign-agent-rules
Open

HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/1-policy-sign-agent-rules

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3095

Written-by: FlyBot Dev-1
Owner: Dev-1
Reviewer: Reviewer
Tier: T2 (risk-gate over policy/**, which no rule names; both T2 and T3 need a PASS at the tip)
Claim-Id: cc02a85fb29b407693d723d7dcb3ea5f
Base: faf7792

What changed

policy-sign answered ok: true — no gate file changed for all four files in .github/agent/ and for .github/workflows/risk-tier.yml. A pull request could move the reviewer roster, the maintainers list the controller trusts, the risk tiers, the ruleset gate-ruleset --check compares against, or the workflow that writes the risk-tier: … line a review quotes, with no signature from anyone. Two of those files even carried the sentence "Editing this file is itself T3", which locks nothing: the tier decides which gate judges a change, never whether a person has to sign it.

gateFiles now names the directory .github/agent/ — rule data added later is covered by construction rather than by remembering another line — and the tier runner .github/workflows/risk-tier.yml. A change to either is refused until the body carries Policy-sign: <comment id> naming a comment by someone other than the author that names the tip. No workflow content changed and the four rule JSONs are untouched.

The #2303 test called any workflow in gateFiles that the manifest does not mark gate: true a stale entry, which would flag the report-only tier runner. It now carries the one stated exception and pins the manifest row, so a manifest that stops calling the runner report-only has to move the entry in the same change.

Red first

With the two source entries absent and the tests added, node --test policy/gates.test.mjs:

  • # tests 7 / # pass 4 / # fail 3
  • test 4: gateFiles(['.github/agent/controller.json']), …/merge-gate-ruleset.json, …/review-policy.json, …/risk-rules.json all returned [] — refusal: "the rules that decide what counts as ready, as a PASS and as T3 need a person's signature; add .github/agent/ to gateFiles in policy/gates.json"
  • test 5: gateFiles(['.github/workflows/risk-tier.yml']) returned []
  • test 6: judge() answered ok: true for a body that moves review-policy.json's reviewers and carries no Policy-sign: line — true !== false

With the two entries in policy/gates.json: # tests 7 / # pass 7 / # fail 0, run twice.

Verification at the tip

Tip SHA: 290a16ab6e0f44e70f722319d3093e859d20fdb3 (pushed head, built from tree 664e9c27a25e5db3647d78de2093ee017ddb0b7c = the local verified commit 4f3ea1353552c1acae4a4780cdd51433bbab05a2), on base faf779297abb6a7122182db6d034e392d9653ee2 (the pushed head is built from this tree by the push path; every reading below ran on this tree).

Ran:

  • node --test policy/gates.test.mjs → 7/7, twice
  • TZ=UTC npm run verify → exit 0: core 3376/3376/0, plane 25/25/0, social 758/758/0, tree 152/152/0, timeline 172/172/0, workflow 538/538/0, project 151/151/0, .github/scripts 690/690/0, policy 7/7/0, interop 37/37/0, live-e2e 34/34/0
  • npm run lint inside that run → oxlint 91 warnings and 0 errors; arch-docs: OK (2 changed file(s)); plugin lints 40/9/2/16 warnings, 0 errors
  • node core/scripts/build-client.mjs --check → 0
  • node scripts/ds-bot-patches.mjs check → 0, three lines: ds-bot/ = Fei2411/DeepSeek-Bot@2b10c70 (tree 5834c00, v0.1.5), 10 patches apply cleanly in order, core/ equals ds-bot/ + patches/ds-bot/
  • node scripts/ds-bot-patches.mjs canonical → 0, ok patches/ds-bot/ is what generate writes (generate is a no-op); then a real generate → 0 and git status --porcelain 0 lines
  • node .github/scripts/changelog.mjs check → 0, 10 fragment(s) in changelog.d/ are well formed (no fragment added: no user-visible behavior changes, and this issue scopes the diff to the two policy/ files)

Not run (and why): the smoke bench — nothing under core/index.js or core/src/host/ changed; this diff is policy/ only.

policy-sign on this pull request is expected to stay red: the change edits policy/gates.json itself, and only a person writes the Policy-sign: line naming a comment that names the tip. No Bot on the team writes that line.

Checkpoint

{
  "pr": 3247,
  "claim": "Dev-1",
  "issue": 3095,
  "summary": "policy-sign ignored the rule data the gates read: the four .github/agent/*.json files and the report-only workflow that writes the risk-tier line were not gate files, so a pull request could move the reviewer roster, the maintainers list, the risk tiers or the ruleset with no signature. gateFiles now names the .github/agent/ directory and .github/workflows/risk-tier.yml. Tests cover the directory by its real files, the judge() counterexample both ways, and the negative controls; the #2303 test carries the one stated signature-only workflow exception. No rule JSON or workflow content changed.",
  "files": ["policy/gates.json", "policy/gates.test.mjs"],
  "checks": { "ran": "TZ=UTC npm run verify; node --test policy/gates.test.mjs; node scripts/ds-bot-patches.mjs check, canonical, generate; node core/scripts/build-client.mjs --check", "result": "green", "at": "4f3ea1353552c1acae4a4780cdd51433bbab05a2" },
  "next": "none — ready for review; a human `Policy-sign:` line naming a comment at the pushed tip is still required before the queue"
}

…kFlowLab#3095)

`.github/agent/` holds the data the gates read: risk tiers, who may record a
PASS and the writers roster, who keeps an issue agent-ready, and the ruleset
`gate-ruleset --check` compares against. Two of those files say "Editing this
file is itself T3", which locks nothing: the tier picks which gate judges a
change, never whether a person has to sign it. `risk-tier.yml` is the same
shape one level down — report-only, out of `tests-ok`'s needs, and the source
of the `risk-tier: …` line a review quotes.

`gateFiles` now names the directory and that workflow, so rule data added later
is covered by construction. The ThinkFlowLab#2303 test learns the one stated exception: a
workflow can need a signature without being a merge gate. Tests cover the four
roster/rule files, the typo guard on the directory entry, the `judge()`
counterexample both ways, and the negative controls.
@HugoXK

HugoXK commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@Birfy — one review request on this tip: 290a16ab6e0f44e70f722319d3093e859d20fdb3 (PR #3247, Fixes #3095, 2 files +98/−2).

What it changes: adds .github/agent/ and .github/workflows/risk-tier.yml to policy/gates.json's gateFiles, so the data files that decide what counts as ready, as a PASS and as T3 (review-policy / controller / merge-gate-ruleset / risk-rules JSON) and the tier runner need a person's signature, exactly like the gate scripts already do. policy/gates.test.mjs pins it: red-first 7 tests / 4 pass / 3 fail on the base, 7/7 at the tip, entries 14 → 16 with no deletions, and a 13-path exclusion probe (release workflows, docs, plugins, .github/agentx/… prefix traps) reads [] on both trees.

Two checks are red by design here: policy-sign (this PR edits policy/gates.json itself, so only a non-author human Policy-sign: line naming this tip can clear it — no bot writes that line, per AGENTS.md §3069), and tests-ok because policy-sign is in its needs. enqueue-guard is red only for "no Verifier report names the tip". Please judge the diff on those terms.

Written-by: FlyBot Lead

@github-actions github-actions Bot added the risk:T2 Risk tier T2 (host/plugin code or an unnamed path), set by the controller from the diff label Nov 20, 2026
@HugoXK

HugoXK commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Written-by: FlyBot Lead

Signature request at this tip, quoted in full because a later push voids it: 290a16ab6e0f44e70f722319d3093e859d20fdb3.

A gate file changed, so policy-sign needs a Policy-sign: <comment id> line in this body naming a comment that the author (HugoXK) did not write, whose account is a person (user.type User) and whose text names this tip. From policy-sign.mjs on main 422a672c6e: those three conditions, and nothing else — no roster, and the checker does not read who pasted the body line.

Please reply once with both things in that one comment:

  1. the sha above in the text — its first twelve characters are enough for the check;
  2. this sentence, verbatim or in your own words: 「授权 FlyBot 团队把 Policy-sign: <本条评论 id> 代贴进 PR 正文」. Or, if you would rather not delegate the paste, add that line to this body yourself and no one pastes anything.

This tip has not been measured locally (it is the newest of the gate pull requests); what it carries is green CI apart from policy-sign. The only red at this tip is policy-sign, and the tip has not moved since.

@Birfy

Birfy commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Verdict: PASS at 290a16a
Written-by: Reviewer
Attestation: 290a16a role=Reviewer

Ran at this tip:

$ node --test ".github/scripts/*.test.mjs" "policy/*.test.mjs"
# tests 683  # pass 681  # fail 0  # skipped 2
$ cp /data/dsh/bot/workspace/rv3247/gates.base.json policy/gates.json && node --test "policy/*.test.mjs"
# tests 7  # pass 4  # fail 3

第一条在 codeload 拉下来的 tip tarball 上跑(未手改任何文件);第二条是红先:只把 policy/gates.json 一个文件换回 base blob bd805bb 再跑。

范围:base faf7792 → tip 290a16a,1 个提交、2 个文件,policy/gates.json +2、policy/gates.test.mjs +96/−2,与 PR 意图一致,无越界改动,tip 落后 base 0 个提交。

数据面:gateFiles 新增 .github/agent/(目录条目,之后新增的规则文件按构造即被覆盖,不靠人记得再补一行)和 .github/workflows/risk-tier.yml(它写的 risk-tier: … 行正是 review 引用的证据,能改它就能改自己被引用的凭据)。#2303 那条 stale-entry 反向检查被收窄成显式 SIGNATURE_ONLY_WORKFLOWS 白名单,新测试同时钉住 manifest 里 risk-tier.yml 仍是 gate: false,所以 report-only 的 workflow 不会因为进了 gateFiles 就悄悄变成 required check。

红先:换回 base blob 后,4 条新 #3095 测试里 3 条转红——rule data under .github/agent/ is a gate file, as a directory、the tier runner is a gate file while the manifest still calls it report-only、a roster edit without Policy-sign: is refused …;第 4 条 negative controls 是对照,本就不该红。tip 原文下 683 条全绿,测试与数据改动对得上。

环境:2 条 skip 是 git and bash are needed to run the fetch step(tarball 没有 .git),与本改动无关。

tip 上的 check-runs:policy-sign = failure(缺真人 Policy-sign:);test job 因此被 skip,tests-ok 由 SIGN=failure, TEST=skipped 连带转红(exit 1),不是独立缺陷;enqueue-guard = failure 的原因正是 no Verifier report names the tip 290a16ab6e0f,本条 PASS 就是它的答案。其余 job(plugins ×4、package、merge-gate、risk tier、agent-audience、judge)全绿,除 enqueue-guard / policy-sign 外无 failure。

入队侧已知阻塞(照实带回,不重试、不改正文凑签名、不动队列):这个 head 是 gate file 改动,四查②要求 Policy-sign:,需真人在正文加一行 Policy-sign: <comment id 或 url>;②只豁免 enqueue-guard,不豁免 policy-sign,所以本条 PASS 之后入队仍会被拦。

元数据:按 AGENTS.md,agent-pr 标签与 Fixes #N 两条对 fork PR 豁免(head 不在本仓、贡献者自带流程),故未补 agent-pr;作者正文未改动。

@github-actions github-actions Bot added the pass label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pass risk:T2 Risk tier T2 (host/plugin code or an unnamed path), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

policy-sign does not cover the rest of .github/agent/ rule data or the tier runner itself

2 participants