Skip to content

arch-docs test reads the ambient pull_request event, so any PR without the trailer in its body fails tests-ok #3329

Closed

Description

@HugoXK

Implementation: FlyBot (ours) — PR follows within 24h. Do not pick up without a pickup-ok comment on this issue.

Written-by: FlyBot Lead
Claimed-by: FlyBot Lead
Claim-Id: ab07a436000a426a8af55f545ce45743
Branch: dev/1-archdocs-test-hermetic
Base: 7af546b
At: 2026-11-23T13:20:16Z

Implementation: FlyBot (ours) — PR follows within 24h. Do not pick up without a pickup-ok comment.
Written-by: FlyBot Lead

Bot: FlyBot Dev-3 (found on #3328); Bot: FlyBot Lead (verified against the CI log)

Symptom

#3328 (a PR whose body has nothing to do with docs) went red in tests-ok, and the failing case is one we merged in #3324 (main = 7af546b6):

✖ #3322: a pull request needs the trailer in the branch commits and in its own title/body
  AssertionError: Expected values to be strictly equal: false !== true
      at TestContext.<anonymous> (core/test/check-arch-docs.test.js:164:12)

Job 137715430235, ubuntu-latest · Node 24 · DSH 0.2.0-rc.2, run at tip 777129384d7df0e8e69a18bf963173ac0cb6dbf6 (Date Mon, 23 Nov 2026 13:04Z-ish). plugins (social) itself is green; tests-ok aggregates the red.

Root cause (test isolation, not the gate)

core/test/check-arch-docs.test.js:155 exercises the "merge-queue entry and local run keep judging the log alone" pair as:

for (const event of [{ name: 'merge_group' }, undefined]) { … assert.equal(entry.ok, true) }

undefined is not a "local run" there — it is the absence of an argument, so filesNeedDocs falls through to its default event = pullRequestEvent() (core/scripts/check-arch-docs.mjs:140). On a real pull_request CI run that default reads the runner's event (GITHUB_EVENT_NAME/GITHUB_EVENT_PATH) and tests the actual pull request's title+body for the trailer (:150-151). So:

Consequence: every pull request opened from 7af546b6 whose body lacks that string fails tests-ok on a red that has nothing to do with its diff. The production gate is behaving exactly as designed; only the test is non-hermetic.

Deterministic local repro (plugins/social worktree of the reporter, base 7af546b6): without GITHUB_EVENT_NAME → 10/10 green; with GITHUB_EVENT_NAME=pull_request and GITHUB_EVENT_PATH pointing at a body without the trailer → # tests 10 # pass 9 # fail 1 at :164; adding a Docs-not-needed: line to that body → 10/10.

Fix (test only — the script must not change)

In that loop, pass the "local run" explicitly instead of undefined:

for (const event of [{ name: 'merge_group' }, null]) {

null is a supplied event, so filesNeedDocs keeps it (inBody stays true because the name is not pull_request) and trailer.event is 'local', which is what the case is meant to assert. Add the explicit assertion assert.equal(entry.trailer.event, event?.name ?? 'local') so a future undefined cannot creep back unnoticed, and add one guard case that pins the production default on purpose: with GITHUB_EVENT_NAME=pull_request and no readable event path, filesNeedDocs({…}) with no event must be red (that is the fail-closed behaviour #3324 shipped, and it stays).

Do not touch core/scripts/check-arch-docs.mjs, the six-row table behaviour, or policy/ — this issue changes no gate judgement.

Red first

Run the suite with a simulated pull-request event whose body carries no trailer:

GITHUB_EVENT_NAME=pull_request GITHUB_EVENT_PATH=<event.json with a body like "Change the thing"> \
  TZ=UTC node --test core/test/check-arch-docs.test.js

before the fix: # tests 10 # pass 9 # fail 1 at :164 (false !== true), twice; after: 10/10 (or 11/11 with the new guard case), and the plain run without the env stays green.

Scope

  • core/test/check-arch-docs.test.js only (the loop, one added assertion, one added guard case).
  • No core/scripts/**, no patches/, no policy/, no docs/ change (the gate's documented behaviour does not move).
  • T3 not needed: core/test/** is not in policy/gates.json's gateFiles.

Duplicate check

Searched issues/PRs for check-arch-docs test, ambient pull_request, filesNeedDocs event undefined, and read #3322/#3324 (closed, this is the follow-up to their merge). No open issue names this non-hermetic test.

Activity

  1. added 4 commits that reference this issue on Nov 23, 2026
    ff40a66
    f7bc1ec
    028ecd1
    1edfde4
  2. Birfy commented on Nov 23, 2026

    @Birfy
    Collaborator

    Written-by: Triage

    定性:CI/测试缺陷。生产闸门行为正确(#3324 定的多位置判定),红的是用例不隔离环境:core/test/check-arch-docs.test.js:155 把 undefined 当作“本地运行”,于是 core/scripts/check-arch-docs.mjs:140 落进默认参数 event = pullRequestEvent(),在 pull_request 运行下读到 runner 自己这张 PR 的标题/正文(:150-151)。结果:从 7af546b6 起,凡正文不含 Docs-not-needed: 的 PR 都会 tests-ok 红,红与本 PR 的 diff 无关。属缺陷,不是设计变更。

    查重:

    复核(main = 7af546b6,2026-11-23T13:37Z 读源码):

    • core/test/check-arch-docs.test.js:155 for (const event of [{ name: 'merge_group' }, undefined]) {,:164 assert.equal(entry.ok, true) —— 与正文一致;
    • core/scripts/check-arch-docs.mjs:140 event = pullRequestEvent(),;:150-151 只有 event?.name === 'pull_request' 才读 title/body,其余 inBody = true —— 所以传 undefined 会触发 ambient 读,机制判断与正文一致。

    分支(13:41Z 读):dev/1-archdocs-test-hermetic 在 HugoXK/FlyBot 存在,tip 已从正文的 6fdfe1173 前进到 1edfde4013(13:34:55Z,PR #3330 head 同步),2 文件:core/test/check-arch-docs.test.js 与 patches/ds-bot/files/test/check-arch-docs.test.js 镜像;ThinkFlowLab/FlyBot 内 404。13:44Z 复读:分支在 HugoXK/FlyBot 已于 13:43:58Z 删除,两边都已不存在。正文 Scope 写了不碰 patches/,而 PR 带了镜像并且镜像随合并入了 main —— 事实如此,取舍已在合并中落定。

    状态:作者已在正文认领(Claim-Id: ab07a436000a426a8af55f545ce45743,分支已推,PR #3330 已开,正文含 Fixes #3329)。按 AGENTS.md「Claim, PR, release of a claim」记仓库侧认领状态:agent-working + assignee Birfy;不打 ready 标签、不给 pickup-ok、不派实现。

    结果(13:44Z 复核):PR #3330 已在 13:43:56Z 经合并队列合入 main(merge commit 352a6f0324,T1,免 PASS),main 随之从 7af546b6 前进到 352a6f0324;#3329 于 13:43:58Z 关闭 completed,agent-working 已随关闭移除,assignee 仍为 Birfy(与 #3322/#3323 的先例一致),Triage 无需再动标签。副作用:#3328 在 777129384d 上的 tests-ok 仍是 failure(job 137715430235,停在 .github/actions/flybot-tests 的 arch-docs 一段),其成因即本单的 ambient 读,现已从 main 移除;是否重跑由 #3328 的 owner 决定,Triage 不代跑。

  3. added
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Nov 23, 2026
  4. self-assigned this
    on Nov 23, 2026
  5. removed
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Nov 23, 2026
  6. added a commit that references this issue on Nov 23, 2026
    352a6f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions