Repository navigation
Commit 2dd0e06
ci(fleet-patrols): weekly governed-merges audit job (#33766)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XBbeqTDBizjSe5fUrtDQ4Kj)_
Fixes #33717
domain:skills#1 · os-project-manager · session_01FEkQ5mSZZN2eYXjy9RHmAu
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:`fleet-patrols.yml` 加第五个任务 `governed-merges-audit`,每周日 23:31
UTC(周一 07:31 北京时间)对过去一周的 `main`
跑合并后受管面审计(`check-governed-merges.mjs`,不改脚本)。干净的一周什么都不写;出现低风险技能臂的 ⛔
BREACH,或这一周有读不到的部分(NOT MEASURED),就开或更新同一张给你的卡。
- **为什么改**:你在 #33717 选了「每周定时工作流」:#33711
合并后加一个每周任务,只在发现违规或读不到时开一张卡给你。在此之前审计只靠被审计的 skills 席位自己手跑。
- **风险与回滚**:不进必过检查、不挡任何 PR、任何席位的开工都不以它为前提(避开 #208
的坑)。读不全的那周会让本任务变红并开卡;BREACH 开卡但任务保持绿。卡挂 `governed-merges-audit` 身份标签加
`pm:awaiting-maintainer`,正文带 `Maintainer-action:`
行,席位不会派发它。卡开着时,之后的坏周会把卡上尚未处理的 BREACH 行原样带进新正文,并在卡上留一条评论通知;BREACH
行靠你在卡上记下的裁定了结(重跑永远读不成干净),只有 NOT MEASURED
行靠手动重跑读干净了结;全部了结后由你关卡。关卡即视为卡上各行已裁定:之后窗口内再读到同一行,只列在「Already ruled on card
#N」下,不再当新违规报给你;若只剩已裁定的行且没有读不到的部分,就不开卡。回滚即 revert 本 PR。
- **先看**:`.github/workflows/fleet-patrols.yml` 文件末尾新任务的头注释与 `File or
refresh the audit card` 一步(写卡的唯一一步,PR 运行与非 main 分支都不写);其次 `on.schedule`
里新加的 cron。
- **两分钟验证**:看本 PR 上 Fleet Patrols 的 `Weekly governed-merges audit` 检查:它在
PR 上只扫 24 小时、不写卡,摘要里应写 `verdict clean` 并列出条目数。
- **需要你做的**:审阅后合并(Tier H,工作流面)。合并后席位会请你在 Actions 里手动触发一次 `patrol =
governed-merges-audit` 读首个整周结果;首个定时运行转绿前,skills 席位照旧每周手跑。
## What changes
One file, `.github/workflows/fleet-patrols.yml`: a fifth job,
`governed-merges-audit`, beside the four daily patrols, plus the shared
parts a fifth job needs (header table, the `schedule:` cron, the
`workflow_dispatch` `patrol` option, the count words "four clocks" /
"all four").
- **Clock.** `31 23 * * 0` (Sunday 23:31 UTC), twinned in the job's
`if:` and in `PATROL_SCHEDULE`. Hour 23 UTC carries no other scheduled
workflow in this repository (inventory of every `cron:` under
`.github/workflows/` at bd96ec9); board-snapshot spends the shared
`GITHUB_TOKEN` budget at 2/8/14/20 and `stale.yml` runs at 01:00.
- **What it reads.** `node scripts/pm/check-governed-merges.mjs --since
7d --repos objectstack --repo-root objectstack=$RUNNER_TEMP/audit-main
--json`, over a fresh `--shallow-since` clone (10 days) of `main`, not
the job's own checkout: a `pull_request` checkout is a merge ref, and
the sweep refuses a window its history does not cover. The script itself
runs from the job's checkout, so a PR runs the version it carries.
`--repos objectstack` because the runner holds no sibling checkout (an
absent checkout reads UNAUDITED by design). `GITHUB_TOKEN` is the
script's env channel; no `pnpm install` (the sweep and the queue-guard
readers load on builtins and repo-local modules only).
- **One retry, for one refusal.** If `main` moves between the clone and
the script's own `ls-remote` probe, the sweep refuses the mirror as
stale (exit 1, `[stale-mirror]`, before any API read). The step
re-fetches and re-runs, at most twice. Every other refusal stands.
- **Verdict.** A github-script step reads the JSON: `breach` (an entry
whose `arm.state` is `breach`), `unread` (an UNAUDITED repo, a WINDOW
EDGE, an attribution error, an arm `not-measured`, exit 1, no or
unparseable JSON, or exit and `complete` disagreeing),
`breach-and-unread`, or `clean`. It writes the run summary on every
trigger.
- **Card.** Only on a non-clean verdict, only on `schedule` /
`workflow_dispatch`, only on `refs/heads/main` (the card step's `if:`
carries the `pull_request` guard the watchdog pin requires). Identity
and de-dup copy the platform-checklist watchdog: identity label
`governed-merges-audit`, plain-text marker `os-governed-merges-audit`,
stable title `governed-merges audit: a BREACH or an unread week on
main`. An open card is refreshed in place (body only, labels untouched);
a closed one is not reopened, and a new card names it. Labels on create:
`governed-merges-audit`, `pm:awaiting-maintainer`; the body's
`Maintainer-action: … — done when …` line is the one that state owes
(H55).
- **Refresh keeps what is unhandled, and says so.** On refresh, every
keyed BREACH row (`PR #N` or `commit SHA12`) already on the open card
that this run did not read again is carried into the new body, marked as
carried; a row leaves only when the card is closed (deleting a row by
hand does not retire it: a row still inside the window is read again and
returns, and the body says so). NOT MEASURED rows are one run's reading
and are not carried. Each refresh also posts one comment: the run link,
the BREACH rows new to the card, the counts read again, carried and
already ruled, the NOT MEASURED count, and how many lines under the
BREACH heading carry no row key (a hand-edited row the carry-forward
cannot see). A section is read from its heading to the next heading or
the footer's first line, blank lines included, so a row set apart by a
blank line is still carried; blank and footer lines are never counted.
`issues.createComment` sits in the same guarded step.
- **A ruled row is not announced again.** Closing the card is the
maintainer's word that every row on it is ruled, so the keys on the
newest closed card (closed within `AUDIT_HISTORY_DAYS`, 10, and not as a
duplicate; both its BREACH and its already-ruled sections) are read as
ruled. The day bound means an old ruling can never hide a reused key. A
later run that reads one again inside the 7-day window (a dispatch with
`patrol=all`, or the scheduled run's skew overlap) lists it under
"Already ruled on card #N", not as a new BREACH; a run whose every
BREACH row is ruled and that reads nothing unread files nothing.
- **What closes the card.** The `Maintainer-action:` line: rule on each
BREACH row (kept, or rolled back) and record the ruling as a comment on
the card; re-run the job by hand for any NOT MEASURED row; done when
every BREACH row has the ruling recorded on the card and a manual run
reads no NOT MEASURED row, then close the card. A BREACH never reads
clean on a re-run (the arm reads only evidence that existed before the
landing, so the entry reads breach until it leaves the 7-day window), so
a clean re-run is asked only of NOT MEASURED rows.
- **Colour.** The job goes red when the sweep exit is not 0 (the week
was not read in full), after the card is filed. A BREACH files the card
and stays green. The sweep step has its own 12-minute timeout (the 7-day
sweep measured 222 s), under the job's 20: a timed-out sweep records no
exit code and leaves no complete JSON, so it reads NOT MEASURED, files
or refreshes the card on `main`, and the run goes red.
- **Artifact.** The sweep's JSON and stderr are uploaded as
`governed-merges-audit` (30 days), so the card's run link carries the
whole reading.
- **`pull_request` run.** `AUDIT_SINCE` is `24h` on a pull request: it
proves the clone, the token's reads, the JSON contract and the rendering
at a few dozen API reads, and writes nothing.
## Why
Ruling-ref: Leehom, option 0 「每周定时工作流」 on #33717 (record comment
6891841310), consequence line 「#33711 合并后加一个每周任务,只在发现违规或读不到时开一张卡给你。工作流
PR 是 Tier H,由你合并。」. PR #33711 (card #33603) gave the sweep its low-risk
arm leg (`pass` / `breach` / `cleared` / `tier-h` / `not-measured`);
this job is its standing caller.
## Acceptance notes
- **Routing of the card (a choice inside the ruling, named for the
maintainer).** The ruling says "a card for you". The board's two
maintainer-facing states were read: `needs-user-decision` owes a
four-facet analysis on the card face (`check-half-states` H62), which a
machine cannot write, and its inbox counts rulings owed;
`pm:awaiting-maintainer` is "decided, one act of the maintainer's
remains" and owes a `Maintainer-action:` line (H55), which this card
carries. AGENTS.md Prime Directive 14 already decides a seat landing
without its record ("a seat violation, filed and rolled back. No seat
judges this"), so the act is the maintainer's. Without `pm:queue` the
card is outside H74's population. If the maintainer prefers another
route, it is one env value (`ANCHOR_STATE_LABEL`).
- **`pull_request` paths filter not widened.** The job names no path
beyond this workflow file, the same posture as the watchdog:
`check-governed-merges.mjs` and the queue-guard readers change several
times a week, `check:pm-governed-merges` already runs their self-test
per PR, and a live sweep on each would spend the shared token budget.
Widening it would also be an edit to the frozen
`PR_TRIGGER_ALLOWED_PATHS` pin, outside this card's surface. Because a
`pull_request` run exercises every job, a PR that matches a sibling
patrol's path (`scripts/pm/check-half-states.mjs` among them) also runs
this job's 24h sweep, writing nothing; the paths comment says so.
Consequence: a PR that changes the sweep's `--json` shape does not run
this job; the verdict step reads a shape it does not recognise as NOT
MEASURED (a card and a red run), never as clean.
- **Known gap, stated in the job header.** `--since 7d` on a weekly
clock overlaps consecutive runs by the script's 1 h skew budget; a run
that does not fire leaves its week unread and nothing here sees it (the
Actions run list does). A missed week is re-read by hand with a wider
`--since`.
- **Token budget, not measured on a runner.** A 7-day sweep measured
from a cloud container on 2026-11-15 (base bd96ec9): 1044 mainline
commits, 191 governed entries, 71 read on the low-risk arm (16 pass, 28
cleared, 27 tier-h, 0 breach, 0 not-measured), complete, exit 0, 222 s.
That is roughly 400 to 550 API reads against `GITHUB_TOKEN`'s
per-repository hourly budget. Whether a repository-wide budget leaves
room at 23:31 UTC on a Sunday is read by the first full run, and a
shortfall surfaces as attribution errors, i.e. NOT MEASURED, never as
clean.
- **Out of scope, noted.** The sweep judges BREACH only on the low-risk
skills arm; the other Tier S legs (`.claude/**`, the workflows split)
are listed as governed merges without a record verdict. This job reports
what the script reads and does not change it.
## Verification
Head `0f23dcd2` (review fixes `a41dcd29`, `86d72352` and `0f23dcd2` on
top of `fdffef2a`), base bd96ec9.
<details><summary>Live sweep, same flags the job runs (container,
2026-11-15)</summary>
- `--since 7d --repos objectstack --json` on a 10-day shallow checkout:
exit 0, `complete: true`, 191 entries, arm states `{none: 120, pass: 16,
tier-h: 27, cleared: 28}`, 222 s.
- `--since 24h --repos objectstack --repo-root objectstack=PATH --json`
on a fresh `git clone --no-checkout --single-branch
--shallow-since=DATE` (DATE nine days back) of main (187 MB, 31 s): exit
0, complete, 43 entries, horizon "shallow, oldest visible 2026-11-06
(predates the window)".
- The sweep and `check-governed-queue-guard.mjs` (with
`loadRecordRecognisers`) load from a tree with no `node_modules`.
</details>
<details><summary>The two github-script bodies, run offline against
fixtures</summary>
A harness (scratch, not committed) parsed this workflow, ran the verdict
step and the card step with stub `core` / `context` / `github`:
- the real 7-day JSON: verdict `clean`, no write;
- the same JSON with one entry set to `breach` (subject carrying a
less-than fragment and an at-sign) and one `not-measured`, exit 2:
verdict `breach-and-unread`, one `create` with labels
`governed-merges-audit,pm:awaiting-maintainer`, the subject's angle
brackets replaced and the at-sign defused, `Maintainer-action:` line
present, next deadline computed weekly;
- exit 1 with stderr and an open card: `unread`, one `update` of that
card, stderr fenced in the body;
- unparseable JSON and a closed prior card: `unread`, one `create`
naming the prior card;
- a four-week chain on one open card (round 1 fixes): week 1 files the
card with a BREACH row; week 2 reads only a NOT MEASURED row, and the
refresh carries the week-1 row (marked carried) and comments "new to
this card: none … carried from earlier runs: 1"; week 3 reads a new
BREACH on a body with CRLF line ends, and the body lists the new row
plus the carried row with the carried mark exactly once, drops week 2's
NOT MEASURED rows, and the comment names the new row; week 4 re-reads
the week-1 row, which is listed once and counted as read again, not
carried. Every body carries a `Maintainer-action:` line with `done when`
and no HTML comment;
- ruled rows (round 2 fix): with the week-4 card closed, a run
re-reading its row plus a NOT MEASURED row files a card that lists the
row only under "Already ruled on card #41" and keeps the NOT MEASURED
section; a run reading only that ruled row files nothing; a row named
only in a closed card's already-ruled section still counts as ruled; a
card closed as a duplicate is not a ruling (the row files as BREACH);
with an open card and a closed one, a row ruled on the closed card is
listed as already ruled, not new, and the refresh comment counts one
hand-edited line under the BREACH heading.
- round 3 fix: two BREACH rows separated by a blank line on an open card
are both carried, and the comment counts 0 unkeyed lines (blank and
footer lines never count); a card closed 30 days ago, or with no
`closed_at`, is not a ruling, so the row files as BREACH. All 27
assertions pass.
</details>
<details><summary>Governed verdict and tier</summary>
- `node scripts/pm/check-governed-merges.mjs --branch HEAD`: exit 3,
GOVERNED, landing tier H at `0f23dcd2` (`.github/workflows/**` split by
content: a `permissions:` block added, a `secrets.*` reference at
`job:governed-merges-audit/step:sweep`, an added `set +e` and `||
true`). The maintainer merges.
- `node scripts/pm/dispatch-gates.mjs --tier`: no path-derived model
mandate; 578 changed lines (+560 / -18), under the 3000 human-merge
line.
</details>
<details><summary>Derived gates: 42 derived, 42 run, all exit
0</summary>
Head `0f23dcd2` (re-run after the review round 3 fix; the derived list
is unchanged from `fdffef2a`): `node scripts/pm/dispatch-gates.mjs
--commands --repo objectstack-ai/objectstack` derived 42 commands; all
42 ran, all exit 0. `--ran`: "42 derived famil(ies) accounted for — 42
run, 0 NOT-MEASURED". No package is touched, so no build closure is owed
and no package test runs (`skip-changeset`: a workflow file publishes
nothing).
```
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-platform-checklist-watchdog.mjs :: exit 0
node scripts/check-platform-checklist-watchdog.mjs --self-test :: exit 0
node scripts/check-release-section-coverage.mjs :: exit 0
node scripts/check-release-section-coverage.mjs --strict :: exit 0
node scripts/check-self-test-wired.mjs :: exit 0
node scripts/check-self-test-wired.mjs --self-test :: exit 0
node scripts/check-self-test-workflow-commands.mjs :: exit 0
node scripts/check-self-test-workflow-commands.mjs --self-test :: exit 0
node scripts/check-step-collectors.mjs :: exit 0
node scripts/check-step-collectors.mjs --self-test :: exit 0
node scripts/check-whole-set-label-write.mjs :: exit 0
node scripts/check-whole-set-label-write.mjs --self-test :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/pm/board-snapshot.mjs --self-test :: exit 0
node scripts/render-release-coverage-anchor.mjs --self-test :: exit 0
pnpm check:agent-test-spelling :: exit 0
pnpm check:aggregator-roster :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:declared-population-live :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:node-version :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:platform-checklist :: exit 0
pnpm check:pm-dispatch-gates :: exit 0
pnpm check:pm-expected-skips :: exit 0
pnpm check:pm-governed-merges :: exit 0
pnpm check:pm-post-stamped :: exit 0
pnpm check:pm-record-recognisers :: exit 0
pnpm check:pnpm-acquisition :: exit 0
pnpm check:pnpm-filter-targets :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:required-contexts :: exit 0
pnpm check:shard-attestation :: exit 0
pnpm check:stall-guard-budget :: exit 0
pnpm check:stall-guard-headroom :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:workflow-status-functions :: exit 0
pnpm check:workflow-step-name-quoting :: exit 0
```
</details>
- Every family CI runs beyond the derived list: read off this PR's
check-runs.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5mSZZN2eYXjy9RHmAu)_
<!-- signed: domain:skills#1 · os-project-manager ·
session_01FEkQ5mSZZN2eYXjy9RHmAu -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent a84bcd8 commit 2dd0e06
1 file changed
Lines changed: 560 additions & 18 deletions
0 commit comments