From 1c433b21f90b669ba5134603cf4d8ecaf5451b81 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 16:43:32 +0000 Subject: [PATCH] fix(pm): dequeue read-back pins and jsdocs, a carried approval refused on a signature on any line - E2: a self-test row pins a failed SECOND pull read after the dequeue (ok, 502, ok, ok): the 502 confirms nothing, the queue is read again and the pair starts over, landing at three polls. - E3: the jsdocs on dequeueAction and dequeuePullAfter now say the pull is read twice, one poll apart, matching the file headers. - D3: the SIZE lift's carrying comment is refused when ANY line holds a seat signature, not only the first; the "signature lower down still carries" row flips to a refusal. Claude-Session: https://claude.ai/code/session_01ADHkmPoZhhhS5uc7UQqwZ7 Co-authored-by: Claude --- scripts/pm/fleet-write/execute.mjs | 23 +++++++++++++++-------- scripts/pm/fleet-write/ops.mjs | 16 +++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/scripts/pm/fleet-write/execute.mjs b/scripts/pm/fleet-write/execute.mjs index 221a0ff252f..9a91addd5a2 100644 --- a/scripts/pm/fleet-write/execute.mjs +++ b/scripts/pm/fleet-write/execute.mjs @@ -191,7 +191,7 @@ * full page read as unreadable) and reduced by the queue guard's * `authorizedApprovalVerdict`; an approval that is not on the head reads the * action's `approval_comment` by its own GET. Unread, unauthorised, elsewhere, - * carried by nobody or by a comment opening with a seat signature + * carried by nobody or by a comment holding a seat signature on any line * (`readSignatureLine`, passed in), the line holds and the mutation is NOT SENT. * * ## The dequeue — `pr_dequeue`, fenced on the PULL, its QUEUE and its CAUSE, audited, and read back @@ -1426,7 +1426,8 @@ export async function dequeuePreflight(req, payload, api, t) { * ONE dequeue (header: "The dequeue"): the fences, then the ONE audit comment (paced; a comment that does not answer * 201 with an id stops the action, the mutation NOT SENT), then the mutation behind the node id the preflight's own * pull read answered, then the queue read back until the entry is gone and the pull's own GET reads it open and - * unmerged. Returns `{ ok, call, status, result | why }` for the row. Never throws on a status. + * unmerged TWICE, one `pollMs` apart — a second read that fails is no confirmation: the queue is read again and the + * pair starts over. Returns `{ ok, call, status, result | why }` for the row. Never throws on a status. */ export async function dequeueAction(req, { payload, api, t, sleep, now, windowMs = DEQUEUE_WINDOW_MS, pollMs = DEQUEUE_POLL_MS }) { const { pull, reason, cause } = req.dequeue; @@ -2602,12 +2603,14 @@ const SELF_TEST_BATTERIES = Object.freeze({ // 17 → 21 with the head fence: a stale head, the embedded copy never trusted, a run naming no pull, a pull unread. "the run_rerun_failed: the five fences judged HERE on the run and its pull, read immediately before ONE bodiless POST — the pull's current head by its own GET, never the run's embedded copy, and a run naming no pull refused by name; each refused with the POST not sent and accepted on the measured run; a run, pull, baseline or fence that fails is zero writes; the 201 confirmed only by reading attempt 2 back with its failed jobs queued or in progress, naming their job ids; attempt 2 never seen, a failed job completed, or a job list unread is FAILED; no annotation": 21, "the pr_enqueue_front: the pull's own GET, its whole file list and its base's queue read immediately before ONE enqueuePullRequest mutation with jump true and the expected head — open, ready, its head, not Version Packages, no governed path, at most the human-merge line count, a queue read whole with no jumped entry; each fence refused with the mutation not sent; GraphQL errors FAILED naming the missing grant; the 200 confirmed only by reading the queue back with the pull jumped and nothing ahead; queued without the jump or behind another is FAILED, never re-sent; the queue read unpaced; no annotation": 20, - // 9 → 12 with a carrying comment that opens with a seat signature refused, its other way, and no reader carrying nothing. - "the pr_enqueue_front SIZE lift: a pull over the human-merge line is jumped only on an authorised APPROVED review on its current head, or an earlier one carried to the head by an authorised comment on the pull naming it — the reviews read only over the line, a full page or an unread list lifting nothing, a non-approver, an approval elsewhere, a comment naming another head or pull or opening with a seat signature refused with the mutation not sent": 12, + // 9 → 12 with a carrying comment that opens with a seat signature refused, its other way, and no reader carrying nothing; + // the other way flipped (still 12) when a signature on ANY line refused the carry, not only the first. + "the pr_enqueue_front SIZE lift: a pull over the human-merge line is jumped only on an authorised APPROVED review on its current head, or an earlier one carried to the head by an authorised comment on the pull naming it — the reviews read only over the line, a full page or an unread list lifting nothing, a non-approver, an approval elsewhere, a comment naming another head or pull or holding a seat signature on any line refused with the mutation not sent": 12, // 16 → 27 with seat-asks bound to the landing seat (another seat, the relay's own audit, no trailer, the pure match), // the pull read back open and unmerged (merged, closed, a late read, the pure reading) and the node id from the first read; - // 27 → 28 with the second pull read one interval later, a merge that shows only there refused. - "the pr_dequeue: the pull's own GET, its base's queue with each entry's merge-group rollup and, for seat-asks alone, its comments read before ONE audit comment and ONE dequeuePullRequest mutation — open, its head, not Version Packages, a queue read whole that lists it, and the cause holding on those reads (conflict: dirty; own-failure: UNMERGEABLE or a failing rollup, never an unread one; seat-asks: a relay comment signed by the landing seat its body's trailer names, under the dispatching session — another seat's comment refused); each fence refused with nothing written; no audit comment, no mutation; GraphQL errors FAILED naming the grant; the 200 confirmed only by reading the queue back without the pull and the pull still open and unmerged on two reads one interval apart, a merge or close inside the window FAILED, UNCONFIRMED after the window": 28, + // 27 → 28 with the second pull read one interval later, a merge that shows only there refused; + // 28 → 29 with a failed second pull read starting the pair over. + "the pr_dequeue: the pull's own GET, its base's queue with each entry's merge-group rollup and, for seat-asks alone, its comments read before ONE audit comment and ONE dequeuePullRequest mutation — open, its head, not Version Packages, a queue read whole that lists it, and the cause holding on those reads (conflict: dirty; own-failure: UNMERGEABLE or a failing rollup, never an unread one; seat-asks: a relay comment signed by the landing seat its body's trailer names, under the dispatching session — another seat's comment refused); each fence refused with nothing written; no audit comment, no mutation; GraphQL errors FAILED naming the grant; the 200 confirmed only by reading the queue back without the pull and the pull still open and unmerged on two reads one interval apart, a merge or close inside the window FAILED, UNCONFIRMED after the window": 29, "the hierarchy link: sub_issue_add and sub_issue_remove read the parent's and the child's own answers, then the child's parent (add) or the parent's whole list (remove), immediately before ONE write whose body is the child's REST id from its own answer — never its number, never replace_parent; a pull, a transferred or unread card, a child under another parent, one the parent does not list, or a read that is neither answer is zero writes; a child already under this parent is a no-op landed on the list; the answer confirmed only when the parent's list reads the child back (or no longer does) inside the window; a refused write, a list that never settles or never reads whole is FAILED; no annotation, and the rows ride a stroke beside other ops": 20, "the advisory rows: advisory_report and advisory_create are ONE POST of their body each, landed on a 2xx carrying an id — a draft's reading state draft — that the row and a notice annotation name; advisory_collaborators_add, advisory_versions and advisory_state read the advisory first and send ONE PATCH — every existing login kept with the missing ones added, an all-present list a no-op, the versions entries alone, or the one state a legal transition reaches, the reopen and the publish among them — or nothing at all on a fence: an unread, other or wrong-state advisory, an illegal move, a list the versions may not replace or a publish whose versions are not set; each lands only when its answer shows the result, a publish only read back as published with the versions it was sent, and a landed publish alone is annotated with its id; ⛔ the marker in a report's or a draft's summary, description and packages and in every advisory answer's summary, description and vulnerabilities reaches no log line, row, step summary or annotation": 41, "the mailbox branch delete: the pull's own answer, the open pulls on its head and the ref read immediately before ONE DELETE of the ref under the App token — an open, unlabelled, other-headed or forked pull, an open pull on that head, a ref moved off the pull's head, or a read that does not answer is zero writes with every failing fence named; the DELETE lands only when the ref reads back absent, a ref already gone an idempotent landing and one still there FAILED; and mailbox-open's close stroke — comment, close, delete — leaves no branch, while a head outside claude/mailbox-* sends no DELETE": 7, @@ -3429,7 +3432,7 @@ export async function selfTest() { } // ── the jump's SIZE lift ──────────────────────────────────────────────── - battery("the pr_enqueue_front SIZE lift: a pull over the human-merge line is jumped only on an authorised APPROVED review on its current head, or an earlier one carried to the head by an authorised comment on the pull naming it — the reviews read only over the line, a full page or an unread list lifting nothing, a non-approver, an approval elsewhere, a comment naming another head or pull or opening with a seat signature refused with the mutation not sent"); + battery("the pr_enqueue_front SIZE lift: a pull over the human-merge line is jumped only on an authorised APPROVED review on its current head, or an earlier one carried to the head by an authorised comment on the pull naming it — the reviews read only over the line, a full page or an unread list lifting nothing, a non-approver, an approval elsewhere, a comment naming another head or pull or holding a seat signature on any line refused with the mutation not sent"); { const PULL = 3227; const HEAD = '7a1e2d3c4b5a69788796a5b4c3d2e1f00f1e2d3c'; @@ -3471,7 +3474,8 @@ export async function selfTest() { ], [refused, refused, refused, refused, refused]); const seatSigned = commentOf({ body: `triage#1 · ${APPROVER} · session_01ABCDEFGHJKMNPQRSTVWXYZ\n\nHead-sha: ${HEAD.slice(0, 9)}` }); t('⛔ CARRIED, refused: the approver\'s comment naming the head but opening with a SEAT signature (an agent-operated account\'s knock or record) carries nothing, the reading naming the seat', [await verdict({ [REVIEWS]: reviewsOf(review(APPROVER, EARLIER)), [COMMENT]: seatSigned }, { approval_comment: 71 }), (await run(stroke({ approval_comment: 71 }), { ...happy, [REVIEWS]: reviewsOf(review(APPROVER, EARLIER)), [COMMENT]: seatSigned })).rows[0]?.result.includes('a seat\'s comment is no carried approval')], [refused, true]); - t('⭐ CARRIED, the other way: the same approver\'s comment with the signature line further down, not first, still carries it', [await verdict({ [REVIEWS]: reviewsOf(review(APPROVER, EARLIER)), [COMMENT]: commentOf({ body: `The approval carries to ${HEAD.slice(0, 9)}.\n\ntriage#1 · ${APPROVER} · session_01ABCDEFGHJKMNPQRSTVWXYZ` }) }, { approval_comment: 71 })], [landed]); + const signedLower = commentOf({ body: `The approval carries to ${HEAD.slice(0, 9)}.\n\ntriage#1 · ${APPROVER} · session_01ABCDEFGHJKMNPQRSTVWXYZ` }); + t('⛔ CARRIED, refused on ANY line: the same approver\'s comment with the seat signature further down, not first, carries nothing either — the reading naming the seat', [await verdict({ [REVIEWS]: reviewsOf(review(APPROVER, EARLIER)), [COMMENT]: signedLower }, { approval_comment: 71 }), (await run(stroke({ approval_comment: 71 }), { ...happy, [REVIEWS]: reviewsOf(review(APPROVER, EARLIER)), [COMMENT]: signedLower })).rows[0]?.result.includes('holds the seat signature triage#1')], [refused, true]); const pastApproval = { state: 'approved', approvals: [{ login: APPROVER, commitId: EARLIER }] }; t('enqueueFrontSizeLift with no signature reader carries nothing — the opening line unjudged is never a pass', [enqueueFrontSizeLift({ verdict: pastApproval, headSha: HEAD, comment: commentOf(), pull: PULL, approvers: GOVERNED_APPROVERS }).lifts, enqueueFrontSizeLift({ verdict: pastApproval, headSha: HEAD, comment: commentOf(), pull: PULL, approvers: GOVERNED_APPROVERS, signatureOf: () => null }).lifts], [false, true]); t('⛔ an approval by an account outside GOVERNED_APPROVERS, or one the approver later dismissed, lifts nothing even on the head', [await verdict({ [REVIEWS]: reviewsOf(review('os-support-ai', HEAD)) }), await verdict({ [REVIEWS]: reviewsOf(review(APPROVER, HEAD), review(APPROVER, HEAD, 'DISMISSED')) })], [refused, refused]); @@ -3558,6 +3562,9 @@ export async function selfTest() { const pullLate = await run(stroke(), { ...happy, [PULL_GET]: [pullAt(), { status: 502, json: { message: 'Bad Gateway' } }, pullAt()] }, timing); t('a pull read that fails after the queue reads it gone is read again at the interval, and lands when it reads open and unmerged', [pullLate.exit, clock], [EXIT_OK, 2 * DEQUEUE_POLL_MS]); clock = 0; + const secondFails = await run(stroke(), { ...happy, [PULL_GET]: [pullAt(), pullAt(), { status: 502, json: { message: 'Bad Gateway' } }, pullAt()] }, timing); + t('a SECOND pull read that fails (ok, 502) confirms nothing: the queue is read again at the interval and the pair starts over (ok, ok), landing at three polls', [secondFails.exit, clock, secondFails.seen.filter((x) => x.call === PULL_GET).length, secondFails.seen.filter((x) => x.call === GQL).length], [EXIT_OK, 3 * DEQUEUE_POLL_MS, 5, 4]); + clock = 0; const mergedLate = await run(stroke(), { ...happy, [PULL_GET]: [pullAt(), pullAt(), pullAt({ state: 'closed', merged: true, merged_at: '2026-11-15T08:40:15Z' })] }, timing); const mergedLateClock = clock; const mergedAtOnly = await run(stroke(), { ...happy, [PULL_GET]: [pullAt(), pullAt(), pullAt({ merged: false, merged_at: '2026-11-15T08:40:15Z' })] }, timing); diff --git a/scripts/pm/fleet-write/ops.mjs b/scripts/pm/fleet-write/ops.mjs index 773063d6253..e87f7661430 100644 --- a/scripts/pm/fleet-write/ops.mjs +++ b/scripts/pm/fleet-write/ops.mjs @@ -391,8 +391,8 @@ * more leading hex characters of it) — the maintainer's confirmation that * the approval carries to this head. The comment is read by its own GET * (`/repos/{repo}/issues/comments/{id}`); a comment on another pull, by - * another author, or naming another head lifts nothing. Nor does one whose - * first non-empty line is a seat signature (`LANE#N · ACCOUNT · SESSION`): + * another author, or naming another head lifts nothing. Nor does one with + * a seat signature (`LANE#N · ACCOUNT · SESSION`) on ANY line, not only the first: * an authorised account is agent-operated too (AGENTS.md Prime Directive * #14), and a seat's knock or record quoting the head is no confirmation * by the maintainer's own hand. @@ -1469,9 +1469,10 @@ export function enqueueFrontSizeLift({ verdict = null, headSha = null, comment = const author = c.user?.login ?? null; if (!approvers.includes(author)) return { lifts: false, way: null, reading: `${earlier}; the approval_comment's author ${author ?? 'unread'} is not an authorised approver` }; if (!new RegExp(`/issues/${pull}$`).test(String(c.issue_url ?? ''))) return { lifts: false, way: null, reading: `${earlier}; the approval_comment is not on #${pull}` }; - if (typeof signatureOf !== 'function') return { lifts: false, way: null, reading: `${earlier}; the approval_comment's opening line was not judged` }; - const seat = signatureOf(c.body); - if (seat) return { lifts: false, way: null, reading: `${earlier}; the approval_comment by ${author} opens with the seat signature ${seat.lane}#${seat.seat} · ${seat.account} — a seat's comment is no carried approval` }; + if (typeof signatureOf !== 'function') return { lifts: false, way: null, reading: `${earlier}; the approval_comment's lines were not judged for a seat signature` }; + // Every line is read, not only the first: a signature lower down is a seat's record all the same (header). + const seat = String(c.body ?? '').split(/\r?\n/u).map((line) => signatureOf(line)).find(Boolean) ?? null; + if (seat) return { lifts: false, way: null, reading: `${earlier}; the approval_comment by ${author} holds the seat signature ${seat.lane}#${seat.seat} · ${seat.account} — a seat's comment is no carried approval` }; const tokens = String(c.body ?? '').match(/\b[0-9a-f]{7,40}\b/giu) ?? []; const carries = head !== '' && tokens.some((tok) => tok.length >= CARRIED_HEAD_MIN_CHARS && head.startsWith(tok.toLowerCase())); if (!carries) return { lifts: false, way: null, reading: `${earlier}; the approval_comment by ${author} names no prefix of the current head` }; @@ -1626,8 +1627,9 @@ export function dequeueReadBack({ pull, queue } = {}) { } /** - * The second half of a dequeue's landing (header): the pull's own GET once the queue no longer lists it — still open - * and `merged` false, so it left the queue without landing. `{ ok, pending, why }`: a read that is not a 200 object + * The second half of a dequeue's landing (header): ONE of the pull's own GETs once the queue no longer lists it — + * still open and `merged` false, so it left the queue without landing. The executor takes TWO such reads, one poll + * apart, and lands only when both are `ok`. `{ ok, pending, why }` for each read: a read that is not a 200 object * is `pending` (read again inside the window); a merged pull, or one closed unmerged, is a terminal failure. Pure. */ export function dequeuePullAfter(answer) {