Skip to content

Commit 472d3c5

Browse files
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

File tree

‎scripts/pm/check-governed-merges.mjs‎

Lines changed: 102 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,14 +1267,17 @@ const SELF_TEST_BATTERIES = Object.freeze({
12671267
// 100 → 103 (#35612): the record must stand on the queue's record leg, its control (the queue leg defers), and `--pr`.
12681268
'⚖️ the low-risk skills arm: skills wording on Clause-② no lands Tier S, everything else stays H (#33501)': 103,
12691269
// 51 → 66 with the record stage as the sweep reads it at the landing: ten pins, and five on which landings it binds;
1270-
// 66 → 71 with the other cards as they stood at the landing (four pins) and the stage's two NOT MEASURED reads.
1271-
'⚖️ #33603: the sweep lists a low-risk arm landing APART and judges it on a same-head at-tier PASS record': 71,
1270+
// 66 → 71 with the other cards as they stood at the landing (four pins) and the stage's two NOT MEASURED reads;
1271+
// 71 → 77 (#38863) with the queue's own removal up to `MERGE_QUEUE_REMOVAL_WINDOW_MS` before `merged_at`: the
1272+
// one-second shape, its controls, outside the window, another actor, the re-add after an ejection, the pure reader.
1273+
'⚖️ #33603: the sweep lists a low-risk arm landing APART and judges it on a same-head at-tier PASS record': 77,
12721274
'⭐ the weekly audit card: every reading the job files on, both ways (#33814)': 54,
12731275
// #35612: the split leg — every state with its control, the report, the audit card and the INCOMPLETE banner;
12741276
// 24 → 30 with the review of record 7238665187: S1 (each BREACH row names its leg, both headings name both), N1
12751277
// (`sweepComplete` and the loop's count), N2 (an unread workflow diff beside the split is NOT MEASURED, and its control);
1276-
// 30 → 35 with S2 of record 7239017248 (an approval or enqueue clears it first: two cases, two controls, one landing half that does not clear).
1277-
'⚖️ #35612: the sweep lists a `.claude/**` declaration-split landing APART and judges it on the record that verifies it': 35,
1278+
// 30 → 35 with S2 of record 7239017248 (an approval or enqueue clears it first: two cases, two controls, one landing half that does not clear);
1279+
// 35 → 36 (#38863): the queue's own removal one second before the merge, on the split leg's landing half.
1280+
'⚖️ #35612: the sweep lists a `.claude/**` declaration-split landing APART and judges it on the record that verifies it': 36,
12781281
'⚖️ #33539: the ADR leg of the low-risk arm — an add-only note lands Tier S, any other ADR change stays H': 52,
12791282
// 40 → 44 (#35612, N1 of #35610): a record the queue's record leg refuses — a FAIL, below its tier, or a leg not
12801283
// read — keeps the split at Tier H however its `Rule-change-verified:` line reads; one case pins the words.
@@ -5396,8 +5399,10 @@ export async function loadArmReaders(load = (specifier) => import(specifier)) {
53965399
* readers); `attribution` is the row's pull read (`mergedAt`, `mergeCommitSha`), or null when it failed.
53975400
* ⭐ The legs run in the guard's own order (`entrySatisfied`): an authorized approval, then an authorized enqueue,
53985401
* then the record — so an entry the maintainer cleared is the maintainer's merge, never a seat's BREACH (#33711 S1).
5399-
* Each leg reads only what existed before the landing: reviews and timeline events strictly before `merged_at`
5400-
* (the queue's `removed_from_merge_queue` shares the merge's instant, measured on #33555, #33632 and #33616), and
5402+
* Each leg reads only what existed before the landing: reviews and timeline events strictly before `merged_at`, less
5403+
* the queue's own terminal `removed_from_merge_queue`, which `github-merge-queue[bot]` stamps at the merge's instant
5404+
* or up to `MERGE_QUEUE_REMOVAL_WINDOW_MS` (1 s) before it (`timelineAsQueued`: 0 s on #33555, #33632 and #33616,
5405+
* 1 s on all twelve BREACH rows of #34178), and
54015406
* comments by an author the guard trusts (`recordAuthorTrusted`, #33711 S3), created AND last edited at or before
54025407
* it (#33711 N4). The record's head is the landed commit's only
54035408
* when GitHub's `merge_commit_sha` is that commit (#33711 S2).
@@ -5518,6 +5523,39 @@ export async function readArmLanding(entry, { paths, repo, readers, fetchers, ru
55185523
return landingBreach({ guard, recognisers, record, unedited, editedAfter, cardNote, headSha, found, ignored });
55195524
}
55205525

5526+
/** The account that stamps a queue merge's own terminal `removed_from_merge_queue` (measured on the rows below). */
5527+
export const MERGE_QUEUE_BOT = 'github-merge-queue[bot]';
5528+
5529+
/**
5530+
* How long before `merged_at` the queue's OWN terminal removal may be stamped and still be read as the merge's, not
5531+
* as a removal the queue made first. Measured on this repository's queue merges: 0 s on #33555, #33632 and #33616
5532+
* (removal == `merged_at`, which the strict `< merged_at` cut already drops); 1 s on every one of the twelve BREACH
5533+
* rows of #34178 — #37072 (added 2026-11-24T19:16:14Z by os-zhuang, removed 19:34:41Z, merged 19:34:42Z), #36775,
5534+
* #36067, #35673, #35709, #33355, #33577, #33589, #33394, #32841, #32839 and #32313. GitHub stamps whole seconds, so
5535+
* 1 s is the narrowest window the readings support; no gap over 1 s was measured. ⛔ Widen it only on a measured
5536+
* queue merge whose removal sits further out — an ejection the queue makes earlier is a removal of its own.
5537+
*/
5538+
export const MERGE_QUEUE_REMOVAL_WINDOW_MS = 1000;
5539+
5540+
/**
5541+
* The timeline as the queue read it before the merge, for the enqueue leg: every event strictly before `landed`
5542+
* (`merged_at` in ms), less the merge's own terminal removal. That removal is dropped only when all three hold — it
5543+
* is the LAST queue event (`enqueueEvent` / `dequeueEvent`, the guard's names) the cut keeps, its actor is
5544+
* `MERGE_QUEUE_BOT`, and it sits at most `MERGE_QUEUE_REMOVAL_WINDOW_MS` before `landed` — so the guard's
5545+
* `enqueuerFromTimeline` reads the actor of the `added_to_merge_queue` before it. Every other shape is the plain cut,
5546+
* read as it was: a removal by any other actor, one further out (an ejection the queue made first), or an earlier
5547+
* removal a re-add follows (the newest queue event is then the add). Names that are not strings drop nothing, so a
5548+
* guard rename leaves the leg undetermined, never cleared. Pure.
5549+
*/
5550+
export function timelineAsQueued(events, landed, { enqueueEvent, dequeueEvent } = {}) {
5551+
const kept = (Array.isArray(events) ? events : []).filter((e) => Date.parse(e?.created_at ?? '') < landed);
5552+
if (typeof enqueueEvent !== 'string' || typeof dequeueEvent !== 'string') return kept;
5553+
const last = kept.findLastIndex((e) => e?.event === enqueueEvent || e?.event === dequeueEvent);
5554+
const removal = kept[last];
5555+
if (last < 0 || removal.event !== dequeueEvent || removal.actor?.login !== MERGE_QUEUE_BOT) return kept;
5556+
return landed - Date.parse(removal.created_at) <= MERGE_QUEUE_REMOVAL_WINDOW_MS ? kept.filter((_, i) => i !== last) : kept;
5557+
}
5558+
55215559
/**
55225560
* The first half of `readLandingThreads`, which the split leg's unread-input answer also reads (S2 of record
55235561
* 7239017248): the merge that ties the pull to THIS commit (S2 of #33603), then the approval leg and the enqueue leg
@@ -5548,7 +5586,10 @@ async function readLandingClearance({ entry, headSha, events, guard, fetchers, a
55485586
}
55495587
const approval = guard.authorizedApprovalVerdict(reviewsAsLanded(reviews.filter((r) => before(r?.submitted_at)), events, landed), headSha);
55505588
if (approval.state === 'approved') return { settled: { state: 'cleared', by: 'review', who: approval.approvers, headSha } };
5551-
const enqueue = guard.authorizedEnqueueVerdict(guard.enqueuerFromTimeline(events.filter((e) => before(e?.created_at))));
5589+
// The merge's own terminal removal, up to `MERGE_QUEUE_REMOVAL_WINDOW_MS` before `merged_at`, is not the newest
5590+
// queue event the queue read (`timelineAsQueued`).
5591+
const queued = timelineAsQueued(events, landed, { enqueueEvent: guard.ENQUEUE_EVENT, dequeueEvent: guard.DEQUEUE_EVENT });
5592+
const enqueue = guard.authorizedEnqueueVerdict(guard.enqueuerFromTimeline(queued));
55525593
if (enqueue.state === 'authorized') return { settled: { state: 'cleared', by: 'enqueue', who: [enqueue.login], headSha } };
55535594
return { landed };
55545595
}
@@ -11533,7 +11574,8 @@ async function selfTest() {
1153311574
const APPROVED = (login, at = '2026-11-15T04:10:00Z') => ({ id: 1, state: 'APPROVED', user: { login }, commit_id: HEAD, submitted_at: at });
1153411575
const cleared = async (over, by) => { const v = await run(over); return v?.state === 'cleared' && v.by === by ? true : JSON.stringify(v); };
1153511576
assert('⭐ an-authorized-APPROVAL-before-the-landing-clears-it-the-maintainers-merge-not-a-BREACH', await cleared({ prRows: [], reviews: [APPROVED('os-zhuang')] }, 'review') === true);
11536-
// The timeline a queue merge leaves, measured on #33555, #33632 and #33616: the removal shares the merge's instant.
11577+
// The timeline a queue merge leaves: the removal shares the merge's instant (measured on #33555, #33632 and
11578+
// #33616) or sits `MERGE_QUEUE_REMOVAL_WINDOW_MS` (1 s) before it (all twelve BREACH rows of #34178; `QUEUED_EARLY`).
1153711579
const QUEUED = (login) => [
1153811580
{ event: 'added_to_merge_queue', actor: { login }, created_at: '2026-11-15T04:40:00Z' },
1153911581
{ event: 'merged', actor: { login }, created_at: MERGED_AT },
@@ -11542,6 +11584,52 @@ async function selfTest() {
1154211584
assert('⭐ an-authorized-ENQUEUE-clears-it-read-on-the-timeline-as-the-queue-saw-it-before-the-merge', await cleared({ prRows: [], events: QUEUED('os-zhuang') }, 'enqueue') === true);
1154311585
assert('control-a-seat-account-enqueue-clears-nothing-the-record-decides', (await run({ events: QUEUED('objectstack-fleet[bot]') }))?.state === 'pass' &&
1154411586
await breach({ prRows: [], events: QUEUED('objectstack-fleet[bot]') }, /no `## Contract review` record/) === true);
11587+
// The #37072 shape: removed by the queue one second BEFORE `merged_at`, the merge event at it. `gap` is seconds
11588+
// before `merged_at`, `by` the removal's actor; `before` puts queue events ahead of the add (an earlier entry).
11589+
const QUEUED_EARLY = (login, { gap = 1, by = MERGE_QUEUE_BOT, before = [] } = {}) => [
11590+
...before,
11591+
{ event: 'added_to_merge_queue', actor: { login }, created_at: '2026-11-15T04:40:00Z' },
11592+
{ event: 'removed_from_merge_queue', actor: { login: by }, created_at: new Date(Date.parse(MERGED_AT) - gap * 1000).toISOString().replace('.000Z', 'Z') },
11593+
{ event: 'merged', actor: { login }, created_at: MERGED_AT },
11594+
];
11595+
assert('⭐ WINDOW the-queues-own-removal-ONE-SECOND-before-merged_at-is-not-the-newest-queue-event-an-authorized-ENQUEUE-clears-it',
11596+
MERGE_QUEUE_REMOVAL_WINDOW_MS === 1000 && await cleared({ prRows: [], events: QUEUED_EARLY('os-zhuang') }, 'enqueue') === true);
11597+
assert('control-WINDOW the-equal-instant-removal-still-clears-and-a-seat-enqueue-on-the-one-second-shape-clears-nothing',
11598+
await cleared({ prRows: [], events: QUEUED('os-zhuang') }, 'enqueue') === true &&
11599+
await breach({ prRows: [], events: QUEUED_EARLY('objectstack-fleet[bot]') }, /no `## Contract review` record/) === true &&
11600+
(await run({ events: QUEUED_EARLY('objectstack-fleet[bot]') }))?.state === 'pass');
11601+
assert('⛔ WINDOW a-queue-removal-OUTSIDE-the-window-stays-undetermined-the-record-decides',
11602+
await breach({ prRows: [], events: QUEUED_EARLY('os-zhuang', { gap: 2 }) }, /no `## Contract review` record/) === true &&
11603+
await breach({ prRows: [], events: QUEUED_EARLY('os-zhuang', { gap: 60 }) }, /no `## Contract review` record/) === true);
11604+
assert('⛔ WINDOW a-removal-inside-the-window-by-ANOTHER-actor-stays-undetermined-the-record-decides',
11605+
await breach({ prRows: [], events: QUEUED_EARLY('os-zhuang', { by: 'os-zhuang' }) }, /no `## Contract review` record/) === true &&
11606+
await breach({ prRows: [], events: QUEUED_EARLY('os-zhuang', { by: 'objectstack-fleet[bot]' }) }, /no `## Contract review` record/) === true);
11607+
// The #33355 and #33394 shape: an earlier entry the queue ejected, then a re-add, then the merge's own removal.
11608+
const EJECTED = (login) => [
11609+
{ event: 'added_to_merge_queue', actor: { login }, created_at: '2026-11-15T03:00:00Z' },
11610+
{ event: 'removed_from_merge_queue', actor: { login: MERGE_QUEUE_BOT }, created_at: '2026-11-15T03:30:00Z' },
11611+
];
11612+
assert('⭐ WINDOW after-an-earlier-ejection-the-RE-ADD-is-read-its-enqueuer-decides-never-the-first-add',
11613+
await cleared({ prRows: [], events: QUEUED_EARLY('os-zhuang', { before: EJECTED('objectstack-fleet[bot]') }) }, 'enqueue') === true &&
11614+
await breach({ prRows: [], events: QUEUED_EARLY('objectstack-fleet[bot]', { before: EJECTED('os-zhuang') }) }, /no `## Contract review` record/) === true);
11615+
assert('⛔ WINDOW timelineAsQueued-drops-only-the-terminal-queue-bot-removal-in-the-window-and-names-that-are-not-strings-drop-nothing', (() => {
11616+
const names = { enqueueEvent: readers.guard.ENQUEUE_EVENT, dequeueEvent: readers.guard.DEQUEUE_EVENT };
11617+
const landed = Date.parse(MERGED_AT);
11618+
const kinds = (evs) => evs.map((e) => e.event).join(',');
11619+
const early = timelineAsQueued(QUEUED_EARLY('os-zhuang'), landed, names);
11620+
const reAddLast = [...EJECTED('os-zhuang'), { event: 'added_to_merge_queue', actor: { login: 'os-zhuang' }, created_at: '2026-11-15T04:59:59Z' }];
11621+
// A queue-bot removal inside the window that an add FOLLOWS is not the terminal queue event: nothing is dropped.
11622+
const addAfter = [...QUEUED_EARLY('os-zhuang').slice(0, 2), { event: 'added_to_merge_queue', actor: { login: 'objectstack-fleet[bot]' }, created_at: '2026-11-15T04:59:59Z' }];
11623+
const unnamed = timelineAsQueued(QUEUED_EARLY('os-zhuang'), landed, {});
11624+
return typeof names.enqueueEvent === 'string' && typeof names.dequeueEvent === 'string' &&
11625+
kinds(early) === 'added_to_merge_queue' &&
11626+
kinds(timelineAsQueued(reAddLast, landed, names)) === kinds(reAddLast) &&
11627+
kinds(timelineAsQueued(addAfter, landed, names)) === kinds(addAfter) &&
11628+
kinds(timelineAsQueued(QUEUED_EARLY('os-zhuang', { gap: 2 }), landed, names)) === 'added_to_merge_queue,removed_from_merge_queue' &&
11629+
kinds(unnamed) === 'added_to_merge_queue,removed_from_merge_queue' &&
11630+
timelineAsQueued(null, landed, names).length === 0
11631+
? true : JSON.stringify({ names, early: kinds(early), unnamed: kinds(unnamed) });
11632+
})() === true);
1154511633
assert('⛔ an-approval-AFTER-the-landing-or-by-an-unauthorized-account-clears-nothing',
1154611634
await breach({ prRows: [], reviews: [APPROVED('os-zhuang', '2026-11-15T06:00:00Z')] }, /no `## Contract review` record/) === true &&
1154711635
await breach({ prRows: [], reviews: [APPROVED('os-someone')] }, /no `## Contract review` record/) === true);
@@ -11918,6 +12006,12 @@ async function selfTest() {
1191812006
assert('control-a-seat-enqueue-or-a-late-approval-clears-nothing-the-record-decides',
1191912007
await state({ events: QUEUED('objectstack-fleet[bot]') }, 'pass') === true &&
1192012008
await state({ prRows: [], reviews: [APPROVED('os-zhuang', '2026-11-25T06:00:00Z')] }, 'breach', /no `## Contract review` record/) === true);
12009+
// The split leg reads the same landing half: the queue's own removal one second before `merged_at` (#34178).
12010+
const QUEUED_EARLY = (login, by = MERGE_QUEUE_BOT) => [QUEUED(login)[0], { event: 'removed_from_merge_queue', actor: { login: by }, created_at: '2026-11-25T04:59:59Z' }, QUEUED(login)[1]];
12011+
assert('⭐ WINDOW the-queues-own-removal-one-second-before-the-merge-leaves-an-authorized-enqueue-CLEARING-the-split-and-another-actors-does-not',
12012+
(await run({ prRows: [], events: QUEUED_EARLY('os-zhuang') }))?.by === 'enqueue' &&
12013+
await state({ prRows: [], events: QUEUED_EARLY('os-zhuang', 'os-zhuang') }, 'breach', /no `## Contract review` record/) === true &&
12014+
await state({ prRows: [], events: QUEUED_EARLY('objectstack-fleet[bot]') }, 'breach', /no `## Contract review` record/) === true);
1192112015
// Tier H on what the pull shows: the maintainer's merge, with the split's own reasons.
1192212016
assert('⭐ a-body-declaring-yes-no-line-or-a-doubled-line-stays-on-the-maintainers-list-Tier-H',
1192312017
await state({ body: 'Fixes #69\n\nRule-change: yes\n' }, 'tier-h', /declares `Rule-change: yes`/, 'reasons') === true &&

0 commit comments

Comments
 (0)