Skip to content

Commit 26e1453

Browse files
feat(pm): an enqueue by an authorized account is the human review at the queue (#26230)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ86NgoAHToTmDrgbochfTZyA)_ Fixes #26066 Clause-②: no Metadata-protocol: none ## What changed The governed queue guard's `merge_group` leg now passes a governed pull request when EITHER an account in `GOVERNED_APPROVERS` holds a latest-decisive APPROVED review (the 2026-09-04 predicate, unchanged and read first) OR that account put the entry in the queue. The maintainer's own "Merge when ready" from `os-zhuang` or `hotlong` is the human review; no separate Approve is owed. The approver set is unchanged and is still the single constant. - `scripts/pm/check-governed-queue-guard.mjs` - `enqueuerFromTimeline` / `authorizedEnqueueVerdict` / `undeterminedEnqueue` (pure) and `makeTimelineReader` (paged `GET /issues/N/timeline`, throws on truncation because the newest event is on the last page). - `runGuard` reads the enqueuer SECOND, only for an entry the approval did not satisfy (monotone, free for approved entries), before any Tier S record read. `entrySatisfied` gains the enqueue limb between the approval and the record; `satisfiedBy` names the leg. - Log line (card §3): `✅ enqueued by an authorized account: LOGIN (added_to_merge_queue at T)`, a third CLEARED wording ("The ENQUEUE leg satisfied N of them: #N (enqueued by LOGIN)") so the clear never claims an approval it did not read, and on refusal `⛔ enqueued by LOGIN, outside GOVERNED_APPROVERS` or `⛔ enqueuer UNDETERMINED — reason`. - Size limb (card §4): `runSizeGuard` hands the enqueue reading beside the approval verdict to the sibling's lift; a governed and oversized PR costs one timeline read, not two. Remedies on both legs name the enqueue landing; the bypass-rules option stays named. - Header: a dated section for the 2026-10-26 ruling (verbatim quotes), the measured reading, why this is not the actor-field attribution #11704 retracted, the accepted cost, and the exit-table rows for 0 / 3 / 8. - `scripts/pm/check-governed-merges.mjs` (claim amendment, those two functions and their pins only): `sizeLiftFrom` reads an `authorized` enqueue as a second lift after the approval lift; `renderLiftApprovals` renders it; new `SIZE_ENQUEUE_LIFT_RULING`. - `AGENTS.md`, inside its line ratchet (1,117 lines before and after, no line over 120 bytes): Prime Directive 14 says Tier H lands "by the maintainer's hand (merge or enqueue) or an authorized approval"; one sentence adds "An authorized account's enqueue is a review record too: ⛔ never a seat's."; and Multi-agent §7 (c) says the size line lands by "the maintainer's merge or enqueue". The details (for that queue entry only, undetermined never passes) are in the guard header, which is where the rule's detail lives. ## The enqueuer reading, measured (card §2) Measured on 2026-10-26 against the live REST API of this repository: - Newest `added_to_merge_queue` timeline event's `actor.login` answers both paths. #26154 and #26011: armed through auto-merge, and the add event's actor is the account that armed it. #26166: direct enqueue, add event present, and no `auto_merge_enabled` event at all. - `auto_merge.enabled_by.login` is null on a direct enqueue (#26166 never had one) and on every merged PR read, so it answers only the armed path. Not used. - `GET /issues/N/timeline` answers `X-Accepted-GitHub-Permissions: issues=read; pull_requests=read`. The workflow's existing `pull-requests: read` covers it, so `.github/workflows/governed-surface-guard.yml` is untouched. - Not measured: a `merge_group` run's own token reading the timeline, and an enqueue armed from an authorized account reaching the queue (#26138 was armed by `os-zhuang` and not yet queued at read time). The first live queue build after this lands prints the reading either way, and an unreadable one is UNDETERMINED, which is today's behaviour. UNDETERMINED is never a pass: no add event, an actorless add, an unreadable or truncated timeline, and a newest queue event that is a removal (the current entry is not on the timeline yet, so the earlier add belongs to an entry that left) all leave the approval leg to decide alone, on its own exit code (3, not 4). ## Tests At head `9e0ae37b` (the last commit touched only `AGENTS.md`; both self-tests re-run there): - `node scripts/pm/check-governed-queue-guard.mjs --self-test`: 373 cases pass (was 345). New battery "the 2026-10-26 ENQUEUE leg" with 28 cases, floor 27 to 28. It covers the card's four fixtures (authorized enqueue with no review passes and names the leg; seat enqueue with no review is refused on 3 with today's words; seat enqueue with an authorized approval passes on the review leg and never reads the timeline; unreadable enqueuer with no review is refused on 3 naming UNDETERMINED). It also covers a stale add before a removal, no reader, an unreadable review list beside an authorized or a seat enqueue (0 and 4), the PR leg reading nothing, a Tier S entry clearing without a record read, the size lift and its refusal, `main()`'s wiring at one timeline read, and the reader's paging, truncation and non-2xx paths. - `node scripts/pm/check-governed-merges.mjs --self-test`: 537 assertions pass, including 3 new enqueue-lift pins. - Ablation 1, enqueue limb of `entrySatisfied` mutated (`scripts/ablation-replace.mjs`, blob `ecad10abe0f0` to `e05e95b1cbb5`): 5 of 373 cases red (fixture 1, its words, the unreadable-review case, the Tier S case, the governed-and-oversized case). Restored, blob equals HEAD, `git diff HEAD` empty. - Ablation 2, the removal-newest guard in `enqueuerFromTimeline` mutated: the stale-add case red (1 of 373). Restored, blob equals HEAD. The first attempt hit an anchor miss (wrong indentation), wrote nothing, and was re-run on the right anchor. ## Gates Derived with `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` (no paths; 3 changed paths vs merge base `fbb75998b`): 42 families. - At head `9e0ae37b`: 41 of 42 run locally, all exit 0 (exit captured before any pipe), including `node scripts/pm/check-governed-queue-guard.mjs --self-test`, `pnpm check:pm-governed-prose`, `pnpm check:pm-governed-merges`, `pnpm check:pm-skill-ratchet`, `pnpm check:pm-skill-id-lint`, `pnpm check:required-contexts`, `pnpm check:nul-bytes`. `--ran` reconciliation: 42 derived, 41 run, 0 NOT-MEASURED, 1 UNRUN. - The UNRUN one is `pnpm check:pm-dispatch-gates`. It ran at `8258383f` (the head before the AGENTS.md-only rewrap commit) and exited 0: fast tier, 1917 cases, 618 s. It was not re-run on `9e0ae37b`; CI runs it. - The first run at `8258383f` had one red, `pnpm check:pm-skill-ratchet`: AGENTS.md was over its 1,117-line ceiling (1,121) and had two lines over 120 bytes. The sentences were rewritten to fit the existing lines (no ceiling raised, no unrelated re-wrap). It is green at `9e0ae37b`. - ESLint (`pnpm exec eslint --no-inline-config`) on the two changed scripts: exit 0. Repo-wide `pnpm lint` is left to CI. ## Acceptance notes - The dispatch order names `pnpm check:governed-queue-guard-self-test`. No such script exists in `package.json`; the guard's `--self-test` is in the derived list and was run directly. Repo-wide `pnpm lint` is CI's per `.claude/agents/os-dev.md`; ESLint ran locally on the two changed scripts (exit 0). - An enqueue counts for that queue entry only: a seat's re-enqueue after an ejection is a new entry by a seat account and is refused without the approval or another authorized click. That is the card's "newest" reading; carrying the click across ejections the way ruling C carries an approval would be a separate maintainer decision. - Tier H (`AGENTS.md`). This PR stays draft and lands by the maintainer's hand. Chicken-and-egg: until this change is in `main`, that hand is an APPROVED review or the bypass-rules merge, not the enqueue. ## 维护者速读(草稿) **改了什么**:合并队列守卫多认一种"人工审核":PR 若是由授权账号(os-zhuang 或 hotlong)点"Merge when ready"送进队列的,队列守卫直接放行,不再要求先点 Approve。体积超 3000 行的 PR 同样适用。其他账号(包括车队机器人)入队仍然必须有授权 Approve。 **为什么改**:您在手机上原来要先点核准再点合并;按您的要求("大部分我还是希望入队,但是我想省掉 Approve"),以后直接点合并(入队)即可。 **风险与代价(含回滚)**:守卫读的是 PR 时间线上最新一次"入队"事件的操作账号。① 授权账号若被智能体代操作,入队就等于放行,所以 AGENTS.md 同步写明:任何智能体席位都不得以任何账号在未获批的受管 PR 上入队或开自动合并。② 入队后到落地前再推的提交不会被重新审核,与"批准在任意提交上都算"的代价相同。③ 读不到入队者时不放行,仍按原规则判。回滚:还原本 PR 即可,无数据迁移。 **席位意见**: **你要做的**:本 PR 改了 AGENTS.md,属 Tier H,需要您亲手落地:点 Approve 后由席位落地,或直接合并。新规则要等本 PR 进 main 后才生效,所以这一次还不能只靠入队。 --- _Generated by [Claude Code](https://claude.ai/code/session_01XDSBMAmqzG7QYwCD7qAGty)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ab112ea commit 26e1453

3 files changed

Lines changed: 489 additions & 54 deletions

File tree

‎AGENTS.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ localStorage / auth gotchas.
258258
When a cloud decision's **mechanism half** governs open code here, this repo carries its own ADR — own number, a
259259
`## Provenance` section naming the cloud record and its date, the commercial half left in cloud — and the cloud
260260
record gains a one-line pointer. Files never move between registries and numbers are never reassigned.
261-
14. **⛔ A governed surface lands only the way its tier allows — Tier H by the maintainer's hand or by an authorized
262-
approval, Tier S by the owning seat on a contract-tier review of record; before that record no AI seat merges,
263-
queues, or arms auto-merge on a PR whose diff touches one.** The governed surfaces are `docs/adr/**`,
261+
14. **⛔ A governed surface lands only the way its tier allows — Tier H by the maintainer's hand (merge or enqueue)
262+
or an authorized approval, Tier S by the owning seat on a contract-tier review of record; before that record no AI
263+
seat merges, queues, or arms auto-merge on a PR whose diff touches one.** The governed surfaces are `docs/adr/**`,
264264
`docs/NORTH-STAR.md`, `.claude/**` (agents, hooks and settings — not only skills), `skills/**`, `AGENTS.md`,
265265
`CLAUDE.md` and `.github/workflows/**`, and under `ui/` `ui/docs/adr/**`, `ui/.claude/**`, `ui/skills/**`,
266266
`ui/AGENTS.md`, `ui/CLAUDE.md` and `ui/.github/workflows/**`, all Tier H. The register is `GOVERNED_SURFACES` in
@@ -284,7 +284,7 @@ localStorage / auth gotchas.
284284
paths are register rows the queue leg regenerates byte-exact clears with zero approvals — an uncertified
285285
recompute, drift or a hand-authored sibling keeps it governed. ⛔ **No agent seat submits an approving review on a
286286
governed-surface PR, under any account** — an authorized account is agent-operated too; "CI is green" carries no
287-
information about a governance change.
287+
information about a governance change. An authorized account's enqueue is a review record too: ⛔ never a seat's.
288288

289289
**Already armed or queued when you read this?** Disable auto-merge AND convert it back to **draft**, which disarms
290290
an unqueued PR; no seat act, those two included, is measured to dequeue one (`platform-readings.md`, queue
@@ -513,8 +513,8 @@ Even inside your own worktree, operate defensively:
513513
so re-read it rather than recalling it); (b) the **Version Packages** PR, or any PR whose merge performs a
514514
release (**Prime Directive #15**); (c) a PR whose **changed lines exceed 3,000** (`additions + deletions`,
515515
generated files included) — it lands the way a Tier H surface does: an authorized APPROVED review and then
516-
the owning seat, or a human merge. Read the PR's file list (`get_files`), **its author and its size** before
517-
you arm anything.
516+
the owning seat, or the maintainer's merge or enqueue. Read the PR's file list (`get_files`), **its author and
517+
its size** before you arm anything.
518518

519519
**Green means the gate-carrying jobs' `conclusion` is `success`** — not "no failure
520520
yet"; `in_progress` is not a pass. Arming a red PR does not queue it, it hides it:

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

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,6 +1709,8 @@ export function testVerdict(paths, { repo, size = null, fork = null, checks = nu
17091709

17101710
/** The lift's citation, printed on every lifted reading so a queue log names what lifted it. */
17111711
export const SIZE_LIFT_RULING = 'maintainer ruling 2026-09-27, objectstack#20153';
1712+
/** The enqueue lift's citation: the maintainer's own enqueue from an authorized account (2026-10-26). */
1713+
export const SIZE_ENQUEUE_LIFT_RULING = 'maintainer ruling 2026-10-26, the enqueue from an authorized account';
17121714

17131715
/**
17141716
* The lift an authorized-approval verdict grants the SIZE limb (maintainer
@@ -1718,14 +1720,33 @@ export const SIZE_LIFT_RULING = 'maintainer ruling 2026-09-27, objectstack#20153
17181720
* (`{ login, commitId }` per counted approver), the field only the AUTHORIZED
17191721
* reduction carries. The generic per-reviewer reduction, an `unapproved` or an
17201722
* `unreadable` verdict, and no verdict at all answer null: no lift, fail closed.
1723+
*
1724+
* ⭐ The SECOND lift (maintainer ruling 2026-10-26): the queue guard hands the
1725+
* same verdict with its enqueue reading attached as `enqueue`, and an entry an
1726+
* account in `GOVERNED_APPROVERS` put in the queue is lifted the way an
1727+
* authorized approval lifts it — the size limb "lands the way a Tier H surface
1728+
* does", and the maintainer's own enqueue is now one of those landings. Still a
1729+
* READER: it asks for the guard's `authorized` state and a login, and decides
1730+
* nothing about who is authorized. The approval lift is read FIRST; an
1731+
* `unauthorized` or `undetermined` enqueue lifts nothing.
17211732
*/
17221733
export function sizeLiftFrom(approval = null) {
1723-
if (approval?.state !== 'approved' || !Array.isArray(approval.approvals) || approval.approvals.length === 0) return null;
1724-
const approvals = approval.approvals
1725-
.filter((a) => typeof a?.login === 'string' && a.login !== '')
1726-
.map((a) => ({ login: a.login, commitId: typeof a.commitId === 'string' ? a.commitId : '' }));
1727-
if (approvals.length === 0) return null;
1728-
return { approvers: approvals.map((a) => a.login), approvals, ruling: SIZE_LIFT_RULING };
1734+
if (approval?.state === 'approved' && Array.isArray(approval.approvals) && approval.approvals.length > 0) {
1735+
const approvals = approval.approvals
1736+
.filter((a) => typeof a?.login === 'string' && a.login !== '')
1737+
.map((a) => ({ login: a.login, commitId: typeof a.commitId === 'string' ? a.commitId : '' }));
1738+
if (approvals.length > 0) return { approvers: approvals.map((a) => a.login), approvals, ruling: SIZE_LIFT_RULING };
1739+
}
1740+
const enqueue = approval?.enqueue;
1741+
if (enqueue?.state === 'authorized' && typeof enqueue.login === 'string' && enqueue.login !== '') {
1742+
return {
1743+
approvers: [],
1744+
approvals: [],
1745+
enqueuedBy: { login: enqueue.login, at: typeof enqueue.at === 'string' ? enqueue.at : null },
1746+
ruling: SIZE_ENQUEUE_LIFT_RULING,
1747+
};
1748+
}
1749+
return null;
17291750
}
17301751

17311752
/**
@@ -1921,8 +1942,9 @@ export function renderSizeLines(size) {
19211942
);
19221943
}
19231944

1924-
/** The approver(s) and the commit each approval was given on, as one clause. Pure; `--self-test` pins it. */
1945+
/** The approver(s) and the commit each approval was given on — or the authorized enqueuer and when — as one clause. Pure; `--self-test` pins it. */
19251946
export function renderLiftApprovals(lifted) {
1947+
if (lifted?.enqueuedBy?.login) return `${lifted.enqueuedBy.login} (enqueued it${lifted.enqueuedBy.at ? ` at ${lifted.enqueuedBy.at}` : ''})`;
19261948
return (lifted?.approvals ?? [])
19271949
.map((a) => `${a.login} (on ${a.commitId ? a.commitId.slice(0, 12) : 'a commit the review did not name'})`)
19281950
.join(', ');
@@ -6422,6 +6444,22 @@ async function selfTest() {
64226444
assert('⛔ the-GENERIC-per-reviewer-reduction-carries-no-approvals-field-and-lifts-nothing-a-verdict-that-never-asked-WHO',
64236445
sizeLimbFires(sizeVerdict(overSize, { state: 'approved', approvers: ['anyone'], changesRequestedBy: [], reviewsRead: 1 })) === true &&
64246446
sizeLiftFrom({ state: 'approved', approvers: ['os-zhuang'], approvals: [] }) === null && sizeLiftFrom({ state: 'approved', approvals: [{ commitId: 'x' }] }) === null);
6447+
// ── the ENQUEUE lift (maintainer ruling 2026-10-26, objectstack#26066) ──
6448+
// The guard hands its approval verdict with the enqueue reading attached; an
6449+
// AUTHORIZED enqueue lifts, every other enqueue reading lifts nothing, and an
6450+
// authorized approval is still the lift that is read first.
6451+
const enqueued = (state, login = 'os-zhuang') => authorizedVerdict([], { enqueue: { state, login, at: '2026-10-26T15:00:00Z' } });
6452+
const liftedByEnqueue = sizeVerdict(overSize, enqueued('authorized'));
6453+
assert('⭐ an-AUTHORIZED-enqueue-LIFTS-the-size-limb-and-the-lift-names-the-enqueuer-and-the-ruling',
6454+
sizeLimbFires(liftedByEnqueue) === false && liftedByEnqueue.lifted?.enqueuedBy?.login === 'os-zhuang' && liftedByEnqueue.lifted.ruling === SIZE_ENQUEUE_LIFT_RULING &&
6455+
liftedByEnqueue.lifted.approvals.length === 0 && renderLiftApprovals(liftedByEnqueue.lifted) === 'os-zhuang (enqueued it at 2026-10-26T15:00:00Z)',
6456+
JSON.stringify(liftedByEnqueue.lifted));
6457+
assert('⛔ an-UNAUTHORIZED-or-UNDETERMINED-enqueue-lifts-nothing',
6458+
sizeLimbFires(sizeVerdict(overSize, enqueued('unauthorized', 'objectstack-fleet[bot]'))) === true &&
6459+
sizeLimbFires(sizeVerdict(overSize, enqueued('undetermined', null))) === true &&
6460+
sizeLiftFrom({ state: 'unapproved', approvals: [], enqueue: { state: 'authorized', login: '' } }) === null);
6461+
assert('an-authorized-APPROVAL-is-the-lift-read-first-even-with-an-authorized-enqueue-beside-it',
6462+
sizeLiftFrom(authorizedVerdict([{ login: 'hotlong', commitId: LIFT_SHA }], { enqueue: { state: 'authorized', login: 'os-zhuang' } })).ruling === SIZE_LIFT_RULING);
64256463
assert('an-approval-under-the-line-lifts-nothing-because-there-is-nothing-to-lift',
64266464
sizeVerdict({ additions: 10, deletions: 2 }, authorizedVerdict([{ login: 'hotlong', commitId: LIFT_SHA }])).lifted === null && sizeVerdict(null, authorizedVerdict([{ login: 'hotlong', commitId: LIFT_SHA }])).lifted === null);
64276465
const liftedGoverned = testVerdict(['AGENTS.md'], { repo: REPO, size: overSize, approval: authorizedVerdict([{ login: 'hotlong', commitId: LIFT_SHA }]) });

0 commit comments

Comments
 (0)