Repository navigation
Commit 472d3c5
fix(pm): the governed-merges audit reads the queue's own removal up to 1 s before merged_at as the merge's (#38896)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB1hPSUXVWWaX4kvGfBzBT7q)_
Fixes #38863
Refs #34178
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户无感:每周治理合并审计不再把维护者本人经合并队列落地的改动,误报成席位违规。
-
为治理审计这一车队工具消除误报:合并队列在合并前一秒记下“移出队列”,旧读法把它当成最新的队列事件,读不出是谁把改动放进队列;现在只对队列机器人在合并前一秒之内的那一次移出放行,一秒是十二条误报上全部实测到的间隔。
- 出错只会让审计报告漏报或继续误报,不影响任何合并;可直接撤回本次改动恢复旧读法。
- 要你做的:这是须由维护者批准的治理面改动,批准一次即可。
## What changes
`scripts/pm/check-governed-merges.mjs` only (Tier H: an always-H
instrument).
- New `timelineAsQueued(events, landed, { enqueueEvent, dequeueEvent })`
feeds the enqueue leg of `readLandingClearance`. It keeps the events
strictly before `merged_at`, as before. It also drops the merge's own
terminal `removed_from_merge_queue`, but only when all three hold: it is
the **last** queue event the cut keeps, its actor is
`github-merge-queue[bot]` (`MERGE_QUEUE_BOT`), and it is at most
`MERGE_QUEUE_REMOVAL_WINDOW_MS` before `merged_at`. The guard's
`enqueuerFromTimeline` then reads the actor of the
`added_to_merge_queue` before it. The guard is not edited.
- `MERGE_QUEUE_REMOVAL_WINDOW_MS = 1000`. Its docblock cites the
readings: 0 s on #33555, #33632 and #33616, and 1 s on all twelve BREACH
rows of #34178 (table below). GitHub stamps whole seconds, so 1 s is the
narrowest window the readings support. No gap over 1 s was measured.
- Unchanged readings: a removal by any other actor, a removal further
out (an ejection the queue made first), and an earlier removal followed
by a re-add (the newest queue event is then the add). If the guard's
event names stop being strings, nothing is dropped and the leg stays
undetermined. It never clears on that path.
- Both callers of the landing half pick this up: the low-risk arm leg
and the `.claude/**` split leg.
- The two docblocks (the `readArmLanding` header and the self-test
fixture comment) now state the measured window instead of "shares the
merge's instant".
## Tests
Self-test pins, under `node scripts/pm/check-governed-merges.mjs
--self-test` (1017 assertions, exit 0 on `062ea49f4`):
- #33603 battery, 71 → 77:
- the one-second shape clears on the enqueue leg;
- the equal-instant control still clears, and a fleet-bot enqueue on the
one-second shape does not;
- a removal 2 s or 60 s out stays undetermined;
- a removal inside the window by another actor stays undetermined;
- after an earlier ejection, the re-add's enqueuer decides (the #33355 /
#33394 shape);
- the pure reader, including a queue-bot removal that an add follows.
- #35612 split battery, 35 → 36: the one-second shape on the split leg,
with another actor's removal and the fleet bot as controls.
<details><summary>Ablation (fix committed first; every mutation via
scripts/ablation-replace.mjs, restored to the HEAD blob)</summary>
- Enqueue leg back to the plain cut: red on 3 pins (the one-second
shape, the re-add after an ejection, the split leg's one-second shape).
The controls stay green, as expected, because the old reading was
already undetermined for them.
- Actor binding removed: red on the another-actor pin and on the split
pin. A first attempt was a no-op: the tool refused because the
replacement text already existed elsewhere. It was re-run with a unique
replacement.
- Window widened to 60 s: red on the outside-the-window pin and the
pure-reader pin.
- Last-event binding removed: green at first, which exposed a gap. Added
the pin for a queue-bot removal that an add follows (commit
`062ea49f4`). Re-ablated: red.
</details>
## Re-run on #34178's rows
Enqueue leg, read on each PR's **live** timeline and `merged_at` through
the real guard, before (strict cut) and after (`timelineAsQueued`):
| PR | queue events (UTC) | gap | before | after |
|---|---|---|---|---|
| #37072 | add os-zhuang 19:16:14 · rem bot 19:34:41 | 1 s |
undetermined | authorized (os-zhuang) |
| #36775 | add os-zhuang 22:00:38 · rem bot 22:21:05 | 1 s |
undetermined | authorized (os-zhuang) |
| #36067 | add os-zhuang 17:33:58 · rem bot 18:06:13 | 1 s |
undetermined | authorized (os-zhuang) |
| #35673 | add os-zhuang 22:28:18 · rem bot 23:03:52 | 1 s |
undetermined | authorized (os-zhuang) |
| #35709 | add os-zhuang 04:52:39 · rem bot 05:21:36 | 1 s |
undetermined | authorized (os-zhuang) |
| #33355 | add · rem 09:52:16 · re-add os-zhuang 11:13:10 · rem bot
11:50:11 | 1 s | undetermined | authorized (os-zhuang) |
| #33577 | add os-zhuang 02:51:26 · rem bot 04:44:21 | 1 s |
undetermined | authorized (os-zhuang) |
| #33589 | add os-zhuang 02:50:20 · rem bot 04:44:21 | 1 s |
undetermined | authorized (os-zhuang) |
| #33394 | add · rem 21:48:10 · re-add os-zhuang 22:52:01 · rem bot
00:44:32 | 1 s | undetermined | authorized (os-zhuang) |
| #32841 | add os-zhuang 01:28:50 · rem bot 02:13:54 | 1 s |
undetermined | authorized (os-zhuang) |
| #32839 | add os-zhuang 23:39:46 · rem bot 00:33:14 | 1 s |
undetermined | authorized (os-zhuang) |
| #32313 | add os-zhuang 23:44:14 · rem bot 00:13:08 | 1 s |
undetermined | authorized (os-zhuang) |
| control #33555 | removal == merged_at | 0 s | authorized (os-zhuang) |
authorized (os-zhuang) |
| control #33632 | removal == merged_at | 0 s | authorized (os-zhuang) |
authorized (os-zhuang) |
| control #33616 | enqueued by objectstack-fleet[bot] | 0 s |
unauthorized | unauthorized |
End-to-end sweep, the real CLI on both trees with `--since
2026-11-24T19:30:00Z --repos objectstack --json`. Both runs complete,
228 entries each:
- #37072 goes from `breach` (stage) on `197e3ff3b` to `cleared` by
enqueue (os-zhuang) on `062ea49f4`.
- One more entry moved, outside the 12: **#38233**, from `pass` to
`cleared` by enqueue. Its timeline has the same shape: added by
os-zhuang 09:48:54, removed by the bot 10:20:32, merged 10:20:33. It was
listed as a seat landing on a record, but it was the maintainer's
enqueue.
- No other entry changed state.
NOT MEASURED: the end-to-end sweep row for the other eleven PRs. A
window back to 2026-11-10 timed out at 570 s, and a 7-day window already
takes about 8 minutes per tree, so this container's 10-minute foreground
limit cannot fit it. Their enqueue-leg reading is in the table above.
The weekly audit job will read them on its next run.
## Smaller finding: recommendation for the seat to route
Recommendation: **enforce the record template where the record is
written. Do not widen the reader.** This PR changes no recogniser
(`record-recognisers.mjs` is outside the claimed surface).
- Evidence: the template the reviewer is handed already spells both
forms the 8 rows missed (`scripts/pm/record-recognisers.mjs` lines
2555–2559 on `197e3ff3b`): a clean round is written `No must-fix, no
should-fix.`, and the delta record names what it closes as `S1: closed`.
The rows wrote `must-fix 0 · should-fix 0`, `S1 closed.` and `F1
(must-fix on SHA): fixed.`, which are off-template.
- Reason: the audit reads records through the queue guard's own reader,
so the audit and the queue agree on what a record says. Widening the
reader alone would make them disagree. Widening it for both changes what
the queue accepts, a contract we own on both ends (AGENTS.md Prime
Directive #12: reject off-spec input at authoring, never accept a
dialect). A check when the record is written tells the reviewer at once,
while the record can still be fixed.
- After this PR, those 12 rows clear on the enqueue leg, so the phrasing
gap no longer decides them. It matters only for seat landings, where the
queue already refuses the same phrasing.
## Acceptance notes
- `origin/main` moved one commit past the base (`3c617a28e`,
`packages/spec` and `ui/` only, nothing under `scripts/pm/`). It was not
merged in, because the diff does not overlap it.
- For the live sweep, this container's shallow clone was deepened with
`git fetch --shallow-since=2026-11-02 origin main` (additive).
## Verification
Read first:
1. `timelineAsQueued` and `MERGE_QUEUE_REMOVAL_WINDOW_MS` (the risk
hunk: the three conditions that drop an event).
2. The one-line change in `readLandingClearance`.
3. The `WINDOW` pins in the #33603 battery.
Two-minute check: run `node scripts/pm/check-governed-merges.mjs
--self-test`. Expected: `✓ check-governed-merges --self-test: 1017
assertions`, exit 0.
<details><summary>Local gates on 062ea49</summary>
- The derived set is `node scripts/pm/dispatch-gates.mjs --commands
--repo objectstack-ai/objectstack`, 63 commands. Reconciled with
`--ran`: `63 derived, 61 run, 2 NOT-MEASURED, 0 UNRUN`.
- NOT MEASURED, both left to CI:
- `pnpm check:i18n-coverage`: exit 3, PREREQUISITE NOT MET (no CLI or
examples build in this worktree).
- `pnpm check:pm-dispatch-gates`: killed by timeout at 200 s and again
at 280 s on the shared box, so it never reached a verdict.
- `node scripts/check-self-test-workflow-commands.mjs` first failed when
its spawn timed out (`spawnSync node ETIMEDOUT`) while the box was
loaded. Re-run alone: exit 0.
- Every other command: exit 0.
- No changeset: `scripts/pm/**` is not published (`skip-changeset`).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent e542b7b commit 472d3c5
1 file changed
Lines changed: 102 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1267 | 1267 | | |
1268 | 1268 | | |
1269 | 1269 | | |
1270 | | - | |
1271 | | - | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
1272 | 1274 | | |
1273 | 1275 | | |
1274 | 1276 | | |
1275 | 1277 | | |
1276 | | - | |
1277 | | - | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
1278 | 1281 | | |
1279 | 1282 | | |
1280 | 1283 | | |
| |||
5396 | 5399 | | |
5397 | 5400 | | |
5398 | 5401 | | |
5399 | | - | |
5400 | | - | |
| 5402 | + | |
| 5403 | + | |
| 5404 | + | |
| 5405 | + | |
5401 | 5406 | | |
5402 | 5407 | | |
5403 | 5408 | | |
| |||
5518 | 5523 | | |
5519 | 5524 | | |
5520 | 5525 | | |
| 5526 | + | |
| 5527 | + | |
| 5528 | + | |
| 5529 | + | |
| 5530 | + | |
| 5531 | + | |
| 5532 | + | |
| 5533 | + | |
| 5534 | + | |
| 5535 | + | |
| 5536 | + | |
| 5537 | + | |
| 5538 | + | |
| 5539 | + | |
| 5540 | + | |
| 5541 | + | |
| 5542 | + | |
| 5543 | + | |
| 5544 | + | |
| 5545 | + | |
| 5546 | + | |
| 5547 | + | |
| 5548 | + | |
| 5549 | + | |
| 5550 | + | |
| 5551 | + | |
| 5552 | + | |
| 5553 | + | |
| 5554 | + | |
| 5555 | + | |
| 5556 | + | |
| 5557 | + | |
| 5558 | + | |
5521 | 5559 | | |
5522 | 5560 | | |
5523 | 5561 | | |
| |||
5548 | 5586 | | |
5549 | 5587 | | |
5550 | 5588 | | |
5551 | | - | |
| 5589 | + | |
| 5590 | + | |
| 5591 | + | |
| 5592 | + | |
5552 | 5593 | | |
5553 | 5594 | | |
5554 | 5595 | | |
| |||
11533 | 11574 | | |
11534 | 11575 | | |
11535 | 11576 | | |
11536 | | - | |
| 11577 | + | |
| 11578 | + | |
11537 | 11579 | | |
11538 | 11580 | | |
11539 | 11581 | | |
| |||
11542 | 11584 | | |
11543 | 11585 | | |
11544 | 11586 | | |
| 11587 | + | |
| 11588 | + | |
| 11589 | + | |
| 11590 | + | |
| 11591 | + | |
| 11592 | + | |
| 11593 | + | |
| 11594 | + | |
| 11595 | + | |
| 11596 | + | |
| 11597 | + | |
| 11598 | + | |
| 11599 | + | |
| 11600 | + | |
| 11601 | + | |
| 11602 | + | |
| 11603 | + | |
| 11604 | + | |
| 11605 | + | |
| 11606 | + | |
| 11607 | + | |
| 11608 | + | |
| 11609 | + | |
| 11610 | + | |
| 11611 | + | |
| 11612 | + | |
| 11613 | + | |
| 11614 | + | |
| 11615 | + | |
| 11616 | + | |
| 11617 | + | |
| 11618 | + | |
| 11619 | + | |
| 11620 | + | |
| 11621 | + | |
| 11622 | + | |
| 11623 | + | |
| 11624 | + | |
| 11625 | + | |
| 11626 | + | |
| 11627 | + | |
| 11628 | + | |
| 11629 | + | |
| 11630 | + | |
| 11631 | + | |
| 11632 | + | |
11545 | 11633 | | |
11546 | 11634 | | |
11547 | 11635 | | |
| |||
11918 | 12006 | | |
11919 | 12007 | | |
11920 | 12008 | | |
| 12009 | + | |
| 12010 | + | |
| 12011 | + | |
| 12012 | + | |
| 12013 | + | |
| 12014 | + | |
11921 | 12015 | | |
11922 | 12016 | | |
11923 | 12017 | | |
| |||
0 commit comments