From 5af555e909f3b7b80a9d6a6d9212bb51f9c6ae75 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 15:20:03 +0000 Subject: [PATCH 1/2] fix(pm): claim-branch reader accepts the card-thread branch shape CLAIM_BRANCH_SHAPE now matches claude/project-thread-ID beside claude/issue-N-slug, so a claim naming a card thread's push branch reads as that branch and the closing-target guard judges it like any other. Self-test rows pin match, mismatch and a retired-branch note on a separate line in both readers. Claude-Session: https://claude.ai/code/session_01ASNY8VYEJsv7qCYaPgM6nB Co-authored-by: Claude --- scripts/check-closing-target-claim.mjs | 17 ++++++++++- scripts/pm/check-half-states.mjs | 41 +++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/scripts/check-closing-target-claim.mjs b/scripts/check-closing-target-claim.mjs index 42291636426..56ebdb91d50 100644 --- a/scripts/check-closing-target-claim.mjs +++ b/scripts/check-closing-target-claim.mjs @@ -993,6 +993,21 @@ async function selfTest() { '/repos/o/r/issues/15845/comments': [], '/repos/o/r/issues/15845': { state: 'open', number: 15845 }, })).verdict.exit, EXIT_UNCLAIMED); + // #39703 — the card-thread shape `claude/project-thread-`, the only branch a + // project card thread can push, is judged like the issue shape: match, mismatch, + // and a retired issue branch named in a note on a SEPARATE line. + const CARD_THREAD = 'claude/project-thread-7yrroi'; + const RETIRED = 'claude/issue-15845-retired-slug'; + const threadClaim = { body: `Claim: session_0deadbeef\nBranch: \`${CARD_THREAD}\`\nRetired: \`${RETIRED}\` (the card moved to its thread)` }; + const threadRoutes = { + '/repos/o/r/issues/15845/comments': [threadClaim], + '/repos/o/r/issues/15845': { state: 'open', number: 15845 }, + }; + const threadMatch = await run('Closes #15845', threadRoutes, { head: CARD_THREAD }); + t('MATCH: a claim naming this card-thread head is CLEAN (#39703)', threadMatch.verdict.exit, EXIT_CLEAN); + t('…with no UNDETERMINED warning — the branch now reads', text(threadMatch.verdict).includes('::warning::'), false); + t('MISMATCH: …another card thread\'s head is a FINDING', (await run('Closes #15845', threadRoutes, { head: 'claude/project-thread-hqa8ds' })).verdict.exit, EXIT_UNCLAIMED); + t('…and so is the retired issue branch its separate note line names', (await run('Closes #15845', threadRoutes, { head: RETIRED })).verdict.exit, EXIT_UNCLAIMED); // --- The negative controls: a PR that closes nothing and a PR that is only // `Part of` a card must be UNAFFECTED, and must add no output of their own. @@ -1296,7 +1311,7 @@ async function selfTest() { const threadRace = [claimA(THREAD_BRANCH), claimB, lostBy(LOSE)]; const threadWinner = await raced(threadRace, THREAD_BRANCH); t('a winner on a card-thread branch is no longer RED (the measured specimen)', threadWinner.verdict.exit, EXIT_CLEAN); - t('…it reads UNDETERMINED, warned about, because its branch is not one the reader parses', text(threadWinner.verdict).includes('::warning::UNDETERMINED'), true); + t('…it reads CLAIMED, with no UNDETERMINED warning, now that the card-thread branch parses (#39703)', [threadWinner.collected.targets[0].verdict === TARGET_CLAIMED, text(threadWinner.verdict).includes('::warning::UNDETERMINED')].join(), 'true,false'); t('…and the loser\'s PR on that thread is no longer read as CLAIMED', (await raced(threadRace, OTHER)).collected.targets[0].verdict !== TARGET_CLAIMED, true); const noSession = [claimA(), claimB, yieldBy('already claimed — yielding · seat 2', '2026-01-01T10:01:00Z')]; t('a yield naming NO session withdraws nothing — today\'s reading holds', (await raced(noSession, OTHER)).verdict.exit, EXIT_CLEAN); diff --git a/scripts/pm/check-half-states.mjs b/scripts/pm/check-half-states.mjs index fae5a66db83..3561655d4ec 100644 --- a/scripts/pm/check-half-states.mjs +++ b/scripts/pm/check-half-states.mjs @@ -6137,11 +6137,30 @@ export const DISPATCHED_NO_REF_STALE_MINUTES = 60; * extractor makes, for the same reason: a fabricated row sends a reader to * check something that was never there. * + * ## The card-thread arm — `claude/project-thread-` (#39703) + * + * A project card thread can push ONLY to its own harness branch, so a seat that + * resumes a card there must name that branch on its `Branch:` line. Without + * this arm the claim read as branchless (the closing-target guard's + * UNDETERMINED), and a claim that also named the retired issue branch read as + * THAT branch alone and accused the PR. This is a second branch SHAPE the + * platform writes, not a looser reading of the `Branch:` line: the line anchor + * and every other spelling stay exactly as they were. + * + * The id takes the slug's class rather than the measured six-character base + * (315 of 320 live `claude/project-thread-*` heads on 2026-12-04; the other + * five carry a suffix such as `-wip` or `-pr2`): a narrower class would match + * a suffixed branch's PREFIX and read the claim as a different, real branch. + * + * ⚠️ `branchNameTarget` stays issue-only on purpose — it reads a card NUMBER + * out of a ref, and a thread branch names none. Readers that need the number + * (H37's fold roster) already skip a branch it answers null for. + * * ⚠️ `g` is load-bearing (`matchAll` requires it) and therefore this constant * is for `matchAll` ONLY — `.test()`/`.exec()` on a shared global regex carry * `lastIndex` between callers and answer differently on alternate calls. */ -export const CLAIM_BRANCH_SHAPE = /claude\/issue-\d+-[A-Za-z0-9][A-Za-z0-9._-]*/g; +export const CLAIM_BRANCH_SHAPE = /claude\/(?:issue-\d+|project-thread)-[A-Za-z0-9][A-Za-z0-9._-]*/g; /** How many branches one row names before it counts the rest — H19's budget, same grounds. */ export const H20_BRANCH_LIST_CAP = 5; @@ -29587,6 +29606,20 @@ async function selfTest() { // blockquote, so the other order — the natural markdown for a bulleted line // INSIDE a blockquote — still yields nothing. t('H20 branch: a blockquoted BULLET (`> - `) is still out — the anchor is marker-then-quote', claimedBranches('> - Branch: `claude/issue-1-a`').length, 0); + // #39703 — the card-thread shape `claude/project-thread-`, the one branch a + // project card thread can push, reads beside the issue shape. Same line anchor, + // so a thread branch in prose or on a non-`Branch:` line is still out. + t('H20 branch: a card-thread branch reads (#39703)', claimedBranches('Branch: `claude/project-thread-7yrroi`').join(','), 'claude/project-thread-7yrroi'); + t('H20 branch: …whole, with a measured suffix — never truncated to the base thread', claimedBranches('Branch: `claude/project-thread-dwhq6r-25697-verify`').join(','), 'claude/project-thread-dwhq6r-25697-verify'); + t('H20 branch: …beside an issue branch on the plural spelling, in order', claimedBranches('Branches: `claude/project-thread-hqa8ds`, `claude/issue-1-a`').join(','), 'claude/project-thread-hqa8ds,claude/issue-1-a'); + t('H20 branch: …a retired issue branch in a note on a SEPARATE line is not read', claimedBranches('Branch: `claude/project-thread-7yrroi`\nRetired: `claude/issue-39208-old-slug` (not pushed)').join(','), 'claude/project-thread-7yrroi'); + t('H20 branch: …a card-thread branch in prose is not the claim field', claimedBranches('resumed in claude/project-thread-7yrroi').length, 0); + t('H20 branch: …an id-less `claude/project-thread-` is no branch', claimedBranches('Branch: claude/project-thread-').length, 0); + t('H20 branch: …and `branchNameTarget` stays issue-only — a thread branch names no card', branchNameTarget('claude/project-thread-7yrroi'), null); + const threadClaim39703 = 'Claim: PM loop round 2\nBranch: `claude/project-thread-7yrroi`\nRetired: `claude/issue-39208-old-slug`'; + t('H46 claim: MATCH — a claim naming the card-thread branch names that head', h46ClaimNamesBranch([threadClaim39703], 'claude/project-thread-7yrroi'), true); + t('H46 claim: MISMATCH — …and not another card thread\'s head', h46ClaimNamesBranch([threadClaim39703], 'claude/project-thread-hqa8ds'), false); + t('H46 claim: …nor the retired issue branch its separate note line names', h46ClaimNamesBranch([threadClaim39703], 'claude/issue-39208-old-slug'), false); // ⛔ And the claim MARKER is NOT widened with it (2026-08-11, 不放宽谓词). The // asymmetry is the fix rather than a residue: when BOTH lines carry a bullet // the marker misses too, so the comment is not a claim to any reader here and @@ -29651,10 +29684,10 @@ async function selfTest() { b(BATTERY_YIELD, 'yield: …and a claim with no `Session:` line speaks for nobody', claimSessionId('Claim: x\nBranch: `claude/issue-1-a`'), null); b(BATTERY_YIELD, 'yield: the measured race withdraws the LOSER\'s claim alone', yIds(yRace), '6396193561'); b(BATTERY_YIELD, 'yield: …not the winner\'s, whose session only the yield\'s BODY names', yieldedClaimIndexes(yRace).has(0), false); - b(BATTERY_YIELD, 'yield: the yielded claim no longer GOVERNS — the red on the winner\'s PR was this reading', claimGovernance(yRace).governing, null); - b(BATTERY_YIELD, 'yield: …the winner\'s claim is the newest standing one, malformed to this reader (UNDETERMINED, never UNCLAIMED)', claimGovernance(yRace).malformed?.id, 6396126096); + b(BATTERY_YIELD, 'yield: the yielded claim no longer GOVERNS — the WINNER\'s card-thread branch does (#39703)', govBranches(yRace), 'claude/project-thread-biervl'); + b(BATTERY_YIELD, 'yield: …and the winner\'s claim, the newest standing one, is no longer malformed (#39703: its card-thread branch reads)', claimGovernance(yRace).malformed, null); b(BATTERY_YIELD, 'yield: the loser\'s branch is no longer named by any claim (H46 and the closing-target guard)', h46ClaimNamesBranch(yRace.map((r) => r.body), 'claude/issue-25729-adr-tier-row'), false); - b(BATTERY_YIELD, 'yield: the hand re-post still reads as it did — the newest standing claim, malformed', claimGovernance([...yRace, yRepost]).malformed?.id, 6396460178); + b(BATTERY_YIELD, 'yield: the hand re-post governs on the same card-thread branch, nothing malformed (#39703)', [govBranches([...yRace, yRepost]), claimGovernance([...yRace, yRepost]).malformed].join('|'), 'claude/project-thread-biervl|'); const yWinOnIssue = { ...yClaimA, body: yClaimA.body.replace('claude/project-thread-biervl', 'claude/issue-25729-winner') }; const yIssueRace = [yWinOnIssue, yClaimB, yYield]; b(BATTERY_YIELD, 'yield: control — a winner on a protocol branch GOVERNS once the loser yields', govBranches(yIssueRace), 'claude/issue-25729-winner'); From 7b30853002e424ca1953ce1976b31efbfb728a84 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 15:50:07 +0000 Subject: [PATCH 2/2] docs(pm): name the card-thread branch shape in the claim guard prose The closing-target-claim header now names claude/project-thread- beside claude/issue-N-slug as a claim branch, and the two "never widen the reader for the latest spelling" passages each say the card-thread arm is a second branch shape the platform forces, not a spelling. Claude-Session: https://claude.ai/code/session_01ASNY8VYEJsv7qCYaPgM6nB Co-authored-by: Claude --- scripts/check-closing-target-claim.mjs | 8 +++++--- scripts/pm/check-half-states.mjs | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/check-closing-target-claim.mjs b/scripts/check-closing-target-claim.mjs index 56ebdb91d50..e7708d25e20 100644 --- a/scripts/check-closing-target-claim.mjs +++ b/scripts/check-closing-target-claim.mjs @@ -16,8 +16,9 @@ * * Every agent in this repository shares ONE GitHub identity, so the assignee * field is a presence bit and the `Claim:` comment — first line beginning - * `Claim:`, with a `Branch:` line naming `claude/issue-N-slug` — is the - * identity record. Two guards already run at pull-request time: the Duplicate + * `Claim:`, with a `Branch:` line naming `claude/issue-N-slug` or, for a card + * resumed in a project card thread, that thread's `claude/project-thread-` — + * is the identity record. Two guards already run at pull-request time: the Duplicate * Fix Guard asks whether another OPEN PR claims the same card, and the * Single-Claim Path Guard asks whether another open PR writes the same * at-most-one-writer path. Neither asks the question that actually decides @@ -146,7 +147,8 @@ * measured last — that treadmill closes one spelling and leaves the next one * exactly as silent, and widening what a claim IS is the one change the * 2026-08-11 ruling closes. The repair direction is the WRITE side, and the - * patrol rows that report a malformed claim are what drive it. + * patrol rows that report a malformed claim are what drive it. (The card-thread + * arm, #39703, is a second branch SHAPE the platform forces, not a spelling.) * * ## Which numbers are judged, and which are declined * diff --git a/scripts/pm/check-half-states.mjs b/scripts/pm/check-half-states.mjs index 3561655d4ec..47998235371 100644 --- a/scripts/pm/check-half-states.mjs +++ b/scripts/pm/check-half-states.mjs @@ -6342,7 +6342,8 @@ export function yieldedClaimIndexes(commentRows) { * measured last. That is the treadmill #16170 already bought once: it closes * one spelling and leaves the next one exactly as silent. What is returned here * is the STATE, so the next unrecognised spelling is a visible error on its - * first occurrence instead of a wrong reading. + * first occurrence instead of a wrong reading. (The card-thread arm, #39703, is + * a second branch SHAPE the platform forces, not a spelling dialect.) * * ## What `malformed` means, precisely *