Skip to content

Commit 4394d31

Browse files
committed
fix(merge-queue-triage): walk the stack through green, non-victim queue groups
stacksFor() unioned two victims only when one victim's base was another victim's head. A victim stacked on another through green groups (whose affected-only Test Core never ran the failing package) read as an independent hit. Walk base to head through every merge_group run already in stackEdges, with a visited set; full-sha equality and the unresolved count are unchanged. Add the affected-only control line to the anchor's reading guidance, and mutation M29 (walk stopped at its first hop -> A18 red). Claude-Session: https://claude.ai/code/session_01TB4mXrHF2oa5RXawpKD7Rj Co-authored-by: Claude <noreply@anthropic.com>
1 parent f6efe20 commit 4394d31

2 files changed

Lines changed: 61 additions & 17 deletions

File tree

‎.github/workflows/merge-queue-triage.yml‎

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,19 @@ jobs:
554554
* construction. One deterministic break therefore ejects everyone
555555
* behind it, and the raw victim count measures QUEUE DEPTH.
556556
*
557-
* ⚠️ The test is full-sha equality in the strict direction: one
558-
* victim's base == another victim's head. ⛔ Never a base PREFIX and
559-
* ⛔ never time ordering — both would fuse genuinely independent hits
560-
* into one stack, trading this limb's false positive for a false
561-
* negative, which is strictly worse. The count exists to be true.
557+
* ⚠️ The test is full-sha equality in the strict direction, walked
558+
* base to head: from a victim's base, through every merge_group run
559+
* in `stackEdges` whose head is that sha (green, non-victim groups
560+
* included), until the chain reaches another victim's head. A green
561+
* group between two victims is NOT a break in the stack: its
562+
* affected-only selection may simply never have run the failing
563+
* package, so it carries the broken tree without failing on it.
564+
* Walking only victim-to-victim read one deterministic break as two
565+
* independent hits (#26265). ⛔ Never a base PREFIX and ⛔ never time
566+
* ordering — both would fuse genuinely independent hits into one
567+
* stack, trading this limb's false positive for a false negative,
568+
* which is strictly worse. The count exists to be true. The index is
569+
* data, not git, so the walk keeps a visited set and ends on a loop.
562570
*
563571
* A victim whose runs are not in the index (a run older than the
564572
* window, or a ref that is not a queue ref) is left as its own group:
@@ -582,6 +590,14 @@ jobs:
582590
}
583591
}
584592
593+
// head sha -> the bases of EVERY indexed run that produced it,
594+
// victim or not: the edges the walk below steps back along.
595+
const basesOf = new Map();
596+
for (const e of stackEdges.values()) {
597+
if (!basesOf.has(e.head)) basesOf.set(e.head, new Set());
598+
basesOf.get(e.head).add(e.base);
599+
}
600+
585601
const inherited = new Set();
586602
let unresolved = 0;
587603
for (const [pr, runs] of byPr) {
@@ -590,10 +606,18 @@ jobs:
590606
const e = stackEdges.get(String(id));
591607
if (!e) continue;
592608
resolved = true;
593-
for (const upstream of producers.get(e.base) ?? []) {
594-
if (upstream === pr) continue;
595-
inherited.add(pr);
596-
union(pr, upstream);
609+
const visited = new Set();
610+
const frontier = [e.base];
611+
while (frontier.length > 0) {
612+
const sha = frontier.pop();
613+
if (visited.has(sha)) continue;
614+
visited.add(sha);
615+
for (const upstream of producers.get(sha) ?? []) {
616+
if (upstream === pr) continue;
617+
inherited.add(pr);
618+
union(pr, upstream);
619+
}
620+
for (const b of basesOf.get(sha) ?? []) frontier.push(b);
597621
}
598622
}
599623
if (!resolved) unresolved++;
@@ -839,8 +863,9 @@ jobs:
839863
? [
840864
"⚠️ **Queue depth is not evidence.** The `stack` column is read out of the queue",
841865
'branch names: GitHub builds each queued PR on top of the previous entry, so a',
842-
"build whose BASE commit IS another victim's queue HEAD contains that victim's",
843-
'tree by construction. A single deterministic break therefore ejects every PR',
866+
"build whose BASE chain reaches another victim's queue HEAD (directly, or through",
867+
"green groups queued between them) contains that victim's tree by construction.",
868+
'A single deterministic break therefore ejects every PR',
844869
'behind it, and the raw victim count climbs with QUEUE DEPTH until the owner',
845870
`lands a fix. Start with the ${independent === 1 ? 'root' : 'roots'} above; an `
846871
+ '`inherited` row is a bystander until shown otherwise.',
@@ -867,6 +892,10 @@ jobs:
867892
'opposite diagnoses), decide the cause, and close this issue with the fix or with',
868893
'the reason it is not one.',
869894
'',
895+
'A later queue build that went green on the same `main` is a control only if its',
896+
'affected-only selection ran the failing package; a green group that never selected',
897+
'it carried the same tree without testing it.',
898+
'',
870899
`Last refreshed by queue build [${run.id}](${run.html_url}) (PR #${prNumber}).`,
871900
'',
872901
'---',

‎scripts/check-merge-queue-triage-outcome.mjs‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@
122122
// announcement, create an anchor without having established one does not exist,
123123
// revert the anchor lookup to the `open` + `finding` selection that made a
124124
// GRADED anchor invisible, stop recognising a closed-as-duplicate chain, drop
125-
// the link a regression anchor owes the anchor it regressed from,
126-
// and move the redelivery guard below the aggregation -- and requires the
125+
// the link a regression anchor owes the anchor it regressed from, stop the
126+
// stack walk at its first hop so a green group between two victims splits
127+
// their stack again, and move the redelivery guard below the aggregation --
128+
// and requires the
127129
// battery to go RED for each, naming the scenario it expects. Each mutation
128130
// also asserts its own anchor was PRESENT before substituting: a mutation that
129131
// silently matched nothing would leave the battery green and read exactly like
@@ -567,8 +569,9 @@ const sightingComment = (key, pr, runId) =>
567569
*
568570
* `base` is the sha the queue branch NAME carries (the commit this build was
569571
* stacked on); `head` is the commit the build actually produced. Limb ②'s stack
570-
* test is `one victim's base === another victim's head`, so a fixture that let
571-
* these two default to the same shape could not tell the test from a tautology.
572+
* test walks `base === head` from a victim's base, through any indexed run, to
573+
* another victim's head, so a fixture that let these two default to the same
574+
* shape could not tell the test from a tautology.
572575
*/
573576
const queueRun = (id, pr, base, head, conclusion = 'failure') => ({
574577
id,
@@ -1723,8 +1726,8 @@ const MUTATIONS = [
17231726
{
17241727
id: 'M16',
17251728
what: 'same-stack is inferred from CO-OCCURRENCE instead of base === head, so unrelated victims fuse into one stack and a real cross-PR signal is under-reported',
1726-
from: ' for (const upstream of producers.get(e.base) ?? []) {',
1727-
to: ' for (const upstream of [...producers.values()].flatMap((s) => [...s])) {',
1729+
from: ' for (const upstream of producers.get(sha) ?? []) {',
1730+
to: ' for (const upstream of [...producers.values()].flatMap((s) => [...s])) {',
17281731
// The mirror of M15, and the reason both exist. M15 removes the evidence and
17291732
// the count goes UP; M16 stops requiring it and the count goes DOWN. A stack
17301733
// rule can be wrong in either direction, and a battery that only catches one
@@ -1743,6 +1746,18 @@ const MUTATIONS = [
17431746
// does not simply red the battery.
17441747
keepGreen: ['A1'],
17451748
},
1749+
{
1750+
id: 'M29',
1751+
what: 'the stack walk stops at the first hop, so a victim stacked on another THROUGH green, non-victim groups reads as an independent hit again',
1752+
from: ' for (const b of basesOf.get(sha) ?? []) frontier.push(b);',
1753+
to: '',
1754+
expect: ['A18'],
1755+
// ⚠️ A12 must NOT move: its stack is victim-on-victim, one hop each, so it is
1756+
// the control that proves A18's red comes from the walk and not from the
1757+
// stack test as a whole. A13 holds the other direction: a stopped walk can
1758+
// only fuse less, never invent a stack.
1759+
keepGreen: ['A12', 'A13'],
1760+
},
17461761
{
17471762
id: 'M17',
17481763
what: 'the anchor lookup goes back to selecting `open` + `finding`, so a GRADED anchor is invisible and every further ejection files another one',

0 commit comments

Comments
 (0)