From 374afa106b2bc0a151f3db7f98860c9799fd98d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 10:24:08 +0000 Subject: [PATCH 1/2] ci(dispatch-gates): derive the temporal-conformance leg for a driver surface The job's if: since ruling record 7146156389 ends in the queue-path clause (never on pull_request; on merge_group only when filter.temporal_live matched). jobIfReading refused it whole, so a driver-sql card derived no row for the live PG + MySQL leg at all. It is now read as a third WHEN, decided per card: a path inside temporal_live gets the queue-build sentence, any other path gets the full-battery one. The check-required-contexts tombstone prose now says the leg also runs on such a queue entry and stays advisory. Claude-Session: https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW Co-authored-by: Claude --- scripts/check-required-contexts.mjs | 12 +++-- scripts/pm/dispatch-gates.mjs | 58 +++++++++++++++++++++---- scripts/pm/dispatch-gates.self-test.mjs | 47 ++++++++++++++++++++ 3 files changed, 105 insertions(+), 12 deletions(-) diff --git a/scripts/check-required-contexts.mjs b/scripts/check-required-contexts.mjs index 51d6b0175e1..97260935422 100644 --- a/scripts/check-required-contexts.mjs +++ b/scripts/check-required-contexts.mjs @@ -374,16 +374,20 @@ const UNATTRIBUTED_BATTERY = '(no battery open)'; * ⛔ TOMBSTONE — `Temporal Conformance (live PG + MySQL)` * (ci.yml:temporal-conformance), dropped by the * #22998 ruling (two-speed CI; ruling record 6120820653 on #22991): its leg - * runs in the FULL BATTERY only — `main`'s push, hourly and dispatch runs — so a - * PR or queue build carries the fast set and the context left the - * required set. The order is the #9325 two-step: the registry and the + * moved to the FULL BATTERY — `main`'s push, scheduled and dispatch runs — off + * the PR and queue builds' fast set, and the context left the + * required set. Since ruling record 7146156389 (#37095) the leg also runs on a + * `merge_group` entry whose diff hits ci.yml's `temporal_live` filter paths + * (never on `pull_request`); it is still no required context, so that queue run + * is advisory and its red lands on `main` — whether it rejoins the set is the + * maintainer's call, made in the ruleset. The order is the #9325 two-step: the registry and the * instruction surfaces drop the row in the PR, and the maintainer removes the * context from the ruleset in the same sitting as the merge; until then * `--verify-required-set` reports it in direction B (required, pinned by no * row), report-only, which is the sitting's own reminder. Prose and not a * RETIRED_CONTEXT_NAMES row, for the reason the `Build Docs` / `Console Pin * Gate` tombstone above gives: the name is not dead — the job still publishes - * this check-run on every full-battery run, and the instruction files name + * this check-run on every full-battery run and on such a queue entry, and the instruction files name * where it runs. * Returned: `Dogfood Regression Gate` (ci.yml:dogfood-gate) left with it by #22998 and is back since #30461 (letter B 6663883327 put its shards on `merge_group`; letter A 6669982756 re-enrolled the row below). */ diff --git a/scripts/pm/dispatch-gates.mjs b/scripts/pm/dispatch-gates.mjs index 4df103d93a7..0fde180be05 100644 --- a/scripts/pm/dispatch-gates.mjs +++ b/scripts/pm/dispatch-gates.mjs @@ -1215,6 +1215,15 @@ export function extractTriggerPaths(workflowText) { * It too discriminates events, never paths, and it says a different WHEN: the * job skips the PR and runs on the merge-queue build and the full battery. * + * ⭐ So is the QUEUE-PATH clause, under the same two conditions (ruling record + * 7146156389, ci.yml's `temporal-conformance`): `&& github.event_name != + * 'pull_request' && (github.event_name != 'merge_group' || needs..outputs. + * != 'false')`. It says a third WHEN: never on the PR, on the merge-queue + * build only when output `` matched the entry's diff, and always on the full + * battery. The output is returned as `queueGate` so a row can say which of the + * two the CARD's paths get; its globs never join the population, which stays + * the filter outputs ahead of the clause. + * * ⛔ Stripped is not FORGOTTEN (#24073). The clause decides nothing about paths, * but it decides WHEN: such a job never runs on the PR, and under the * full-battery clause never in the merge queue either. `jobIfReading` below @@ -1229,6 +1238,8 @@ const JOB_IF_STATUS_TERM = /(?:^|\s)!\s*cancelled\(\)\s*&&\s*/g; const JOB_IF_FULL_BATTERY_TERM = /\s*&&\s*github\.event_name\s*!=\s*'pull_request'\s*&&\s*github\.event_name\s*!=\s*'merge_group'\s*$/; const JOB_IF_QUEUE_AND_FULL_TERM = /\s*&&\s*github\.event_name\s*!=\s*'pull_request'\s*$/; +const JOB_IF_QUEUE_PATH_TERM = + /\s*&&\s*github\.event_name\s*!=\s*'pull_request'\s*&&\s*\(\s*github\.event_name\s*!=\s*'merge_group'\s*\|\|\s*needs\.([A-Za-z_][\w-]*)\.outputs\.([A-Za-z_][\w-]*)\s*!=\s*'false'\s*\)\s*$/; const JOB_FILTER_OUTPUT_TERM = /^needs\.([A-Za-z_][\w-]*)\.outputs\.([A-Za-z_][\w-]*)\s*(?:!=\s*(['"])false\3|==\s*(['"])true\4)$/; @@ -1243,14 +1254,16 @@ export function jobFilterOutputRefs(ifExpression) { } /** - * The whole reading of a job `if:` — `{ refs, fullBatteryOnly, notOnPullRequest }`, + * The whole reading of a job `if:` — `{ refs, fullBatteryOnly, notOnPullRequest, queueGate }`, * or null on exactly the refusals `jobFilterOutputRefs` makes, because that * function IS this one with the event facts dropped. `fullBatteryOnly` is true * when the full-battery clause was stripped as the last conjunct: the job runs * on `main`'s push and hourly runs and NEVER on a `pull_request` or * `merge_group` event. `notOnPullRequest` is true when either clause was * stripped: the job never runs on the PR (alone, the queue-and-full clause — - * the merge-queue build runs it). Both are read in the same pass as the refs, + * the merge-queue build runs it). `queueGate` is `{ job, output }` when the + * queue-path clause was stripped (the queue build runs the job only when that + * output matched), else null. All are read in the same pass as the refs, * from the same text, so the population and the event facts cannot describe * two different `if:`s. */ @@ -1260,6 +1273,12 @@ export function jobIfReading(ifExpression) { const wrapped = /^\$\{\{([\s\S]*)\}\}$/.exec(expr); if (wrapped) expr = wrapped[1].trim(); expr = expr.replace(JOB_IF_STATUS_TERM, ' ').trim(); + const queuePath = JOB_IF_QUEUE_PATH_TERM.exec(expr); + if (queuePath) { + const rest = jobIfReading(expr.slice(0, queuePath.index)); + if (!rest || rest.notOnPullRequest) return null; + return { ...rest, notOnPullRequest: true, queueGate: { job: queuePath[1], output: queuePath[2] } }; + } const fullFree = expr.replace(JOB_IF_FULL_BATTERY_TERM, '').trim(); const fullBatteryOnly = fullFree !== expr; // Only when the full-battery clause was NOT there: stripping both would read @@ -1287,7 +1306,7 @@ export function jobIfReading(ifExpression) { if (!m) return null; refs.push({ job: m[1], output: m[2] }); } - return refs.length ? { refs, fullBatteryOnly, notOnPullRequest } : null; + return refs.length ? { refs, fullBatteryOnly, notOnPullRequest, queueGate: null } : null; } /** @@ -1486,7 +1505,9 @@ const EXTGLOB_CONSTRUCT = /[!?*+@]\(/; * The path population a job's `if:` resolves to, or null — the whole of * direction 1, assembled from the three readings above. * - * Returns `{ paths, outputs, dropped, fullBatteryOnly, notOnPullRequest }`. + * Returns `{ paths, outputs, dropped, fullBatteryOnly, notOnPullRequest, queueGate, queuePaths }`; + * `queuePaths` are the queue-path output's translatable globs (null without the clause), and an + * untranslatable negation there, or an output the workflow does not declare, refuses the job. * `paths` is a UNION: the `if:` is an OR of filter outputs, so CI schedules the * job when ANY of them matched. The two flags are `jobIfReading`'s event facts, * carried so a row built from this population can say WHEN CI schedules it @@ -1495,7 +1516,13 @@ const EXTGLOB_CONSTRUCT = /[!?*+@]\(/; export function jobFilterPopulation(job, filterStepsByOutputSource) { const reading = jobIfReading(job.if); if (!reading) return null; - const { refs, fullBatteryOnly, notOnPullRequest } = reading; + const { refs, fullBatteryOnly, notOnPullRequest, queueGate } = reading; + let queuePaths = null; + if (queueGate) { + const globs = filterStepsByOutputSource.get(`${queueGate.job}.${queueGate.output}`); + if (!globs || globs.some((g) => g.startsWith('!') && EXTGLOB_CONSTRUCT.test(g))) return null; + queuePaths = globs.filter((g) => !EXTGLOB_CONSTRUCT.test(g)); + } const paths = []; const outputs = []; let dropped = 0; @@ -1514,7 +1541,7 @@ export function jobFilterPopulation(job, filterStepsByOutputSource) { } outputs.push(`${ref.job}.${ref.output}`); } - return paths.length ? { paths, outputs, dropped, fullBatteryOnly, notOnPullRequest } : null; + return paths.length ? { paths, outputs, dropped, fullBatteryOnly, notOnPullRequest, queueGate, queuePaths } : null; } /** @@ -2885,7 +2912,10 @@ export function alwaysRunSteps(entries) { * `main`'s push and hourly runs ONLY — never on this PR, never in the merge * queue. A row whose clause was the queue-and-full one carries * `notOnPullRequest: true` alone (#30461): never on this PR, first on the - * merge-queue build. Both renderings print the fact on the row's own line, so + * merge-queue build. A queue-path row (ruling record 7146156389) carries + * `queueOutput` and decides per CARD: a path of yours the output covers keeps + * `notOnPullRequest` alone, none covered sets `fullBatteryOnly` too. + * Both renderings print the fact on the row's own line, so * "scheduled BY YOUR PATHS" cannot be read as "this PR runs it". * * ⛔ NOT claimed: that a row is a test, a build or a setup step. @@ -2973,9 +3003,12 @@ export function jobFilteredSteps(entries, paths) { } if (steps.length === 0) continue; counts.named += 1; + const queueOutput = job.queueGate ? `${job.queueGate.job}.${job.queueGate.output}` : null; + const queueHit = queueOutput !== null && paths.some((p) => triggerListCovers(job.queuePaths, p)); rows.push({ workflow: file, job: job.name, outputs: job.outputs, hits, dropped: job.dropped, - fullBatteryOnly: job.fullBatteryOnly === true, notOnPullRequest: job.notOnPullRequest === true, steps, + fullBatteryOnly: job.fullBatteryOnly === true || (queueOutput !== null && !queueHit), + notOnPullRequest: job.notOnPullRequest === true, ...(queueOutput ? { queueOutput } : {}), steps, }); } } @@ -12908,6 +12941,15 @@ export function alwaysRunLines(rows, counts) { * pins — and the first run was `main`'s push battery, red. */ export function fullBatteryOnlyClause(row) { + const gate = typeof row?.queueOutput === 'string' ? row.queueOutput : null; + if (gate && row.fullBatteryOnly === true) { + return '⛔ does NOT run on this PR or in the merge queue: its `if:` excludes the pull_request event and admits merge_group' + + ` only when \`${gate}\` matched, which none of your paths does, so its first run on this change is \`main\`'s push battery, AFTER the merge`; + } + if (gate && row.notOnPullRequest === true) { + return '⛔ does NOT run on this PR: its `if:` excludes the pull_request event,' + + ` and your paths hit \`${gate}\`, so its first run on this change is the merge-queue build, after the PR is enqueued`; + } if (row?.fullBatteryOnly === true) { return '⛔ does NOT run on this PR or in the merge queue: its `if:` excludes the pull_request and merge_group events,' + " so its first run on this change is `main`'s push battery, AFTER the merge"; diff --git a/scripts/pm/dispatch-gates.self-test.mjs b/scripts/pm/dispatch-gates.self-test.mjs index 21a62fd5eda..dc8d893c091 100644 --- a/scripts/pm/dispatch-gates.self-test.mjs +++ b/scripts/pm/dispatch-gates.self-test.mjs @@ -6745,6 +6745,29 @@ export function selfTest({ tier = 'full' } = {}) { '...and an if: with no event clause reads notOnPullRequest FALSE', jobIfReading("${{ !cancelled() && needs.filter.outputs.console != 'false' }}")?.notOnPullRequest === false, ); + // Ruling record 7146156389: the QUEUE-PATH clause `temporal-conformance` carries — + // never on the PR, on the queue only when its output matched, always on the full battery. + const QUEUE_PATH = "github.event_name != 'pull_request' && (github.event_name != 'merge_group' || needs.filter.outputs.temporal_live != 'false')"; + const queuePathReading = jobIfReading(`\${{ !cancelled() && needs.filter.outputs.core != 'false' && ${QUEUE_PATH} }}`); + t( + 'jobIfReading: the queue-path clause reads notOnPullRequest TRUE, fullBatteryOnly FALSE and its queueGate, beside the same refs', + queuePathReading?.notOnPullRequest === true && queuePathReading?.fullBatteryOnly === false + && `${queuePathReading?.queueGate?.job}.${queuePathReading?.queueGate?.output}` === 'filter.temporal_live' + && queuePathReading?.refs.map((r) => `${r.job}.${r.output}`).join() === 'filter.core', + ); + t('...and every other reading carries queueGate NULL', queueAndFullReading?.queueGate === null && fullBatteryReading?.queueGate === null); + t( + '...but only as spelled: the two disjuncts reordered refuse', + jobFilterOutputRefs("${{ needs.f.outputs.a != 'false' && github.event_name != 'pull_request' && (needs.f.outputs.b != 'false' || github.event_name != 'merge_group') }}") === null, + ); + t( + '...an == merge_group disjunct refuses — it would say the opposite WHEN', + jobFilterOutputRefs("${{ needs.f.outputs.a != 'false' && github.event_name != 'pull_request' && (github.event_name == 'merge_group' || needs.f.outputs.b != 'false') }}") === null, + ); + t( + '...and the queue-path clause without the pull_request exclusion ahead of it refuses', + jobFilterOutputRefs("${{ needs.f.outputs.a != 'false' && (github.event_name != 'merge_group' || needs.f.outputs.b != 'false') }}") === null, + ); const fixturePops = jobPathPopulations(jobFilterWf, 'fixture.yml'); t( @@ -13592,6 +13615,30 @@ export function selfTest({ tier = 'full' } = {}) { && plainRowLine(shardStripped) !== '' && !plainRowLine(shardStripped).includes(NOT_ON_THIS_PR), ); + // Ruling record 7146156389: the queue-path row decides per CARD. A path outside + // `temporal_live` gets the full-battery sentence; a driver-sql path gets the queue build. + const QUEUE_PATH_NOTE = 'and your paths hit `filter.temporal_live`'; + const temporalLedger = ledgerRow('Temporal Conformance'); + t( + "LIVE: a route-ledger.ts change schedules 'Temporal Conformance', outside temporal_live, so its row reads full-battery-only and SAYS so", + temporalLedger?.queueOutput === 'filter.temporal_live' && temporalLedger?.fullBatteryOnly === true + && jobFilteredNotMeasuredLine(temporalLedger).includes(NOT_ON_PR) && plainRowLine(temporalLedger).includes(NOT_ON_PR), + ); + const driverRow = jobFilteredSteps(liveWorkflows, ['packages/drivers/driver-sql/src/sql-driver.ts']).rows + .find((r) => r.job.startsWith('Temporal Conformance')) ?? null; + t( + "LIVE: a driver-sql change hits temporal_live, so its row says the PR skips the job and the queue build runs it first, and NOT the full-battery sentence", + driverRow?.notOnPullRequest === true && driverRow?.fullBatteryOnly === false + && jobFilteredNotMeasuredLine(driverRow).includes(NOT_ON_THIS_PR) && jobFilteredNotMeasuredLine(driverRow).includes(QUEUE_PATH_NOTE) + && jobFilteredNotMeasuredLine(driverRow).includes(QUEUE_FIRST) && !jobFilteredNotMeasuredLine(driverRow).includes(NOT_ON_PR) + && plainRowLine(driverRow).includes(QUEUE_PATH_NOTE), + ); + const driverStripped = driverRow ? Object.fromEntries(Object.entries(driverRow).filter(([k]) => k !== 'queueOutput')) : null; + t( + '...ABLATED — queueOutput stripped from the row — the queue-path sentence disappears from BOTH lines', + Boolean(driverStripped) && !jobFilteredNotMeasuredLine(driverStripped).includes(QUEUE_PATH_NOTE) + && plainRowLine(driverStripped) !== '' && !plainRowLine(driverStripped).includes(QUEUE_PATH_NOTE), + ); const prJobRow = ledgerRow('Build Core'); t( 'LIVE NEGATIVE CONTROL: Build Core, scheduled by the same path and run on the PR, carries the fact as FALSE and no statement', From 0e1b4724af2defa73ed641744334ab05c05bca2e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 11:28:22 +0000 Subject: [PATCH 2/2] ci(dispatch-gates): decide the queue-path split on a glob matching the path itself A directory surface such as packages/runtime reached into the one-file cascade-delete glob of filter.temporal_live through triggerListCovers' directory rule, and its row said the merge-queue build runs the leg first. The split now uses triggerListMatches (no directory reach) and carries the deciding glob on the row; a surface that only reaches into the globs, or a queue list narrowed by a dropped extglob or carrying a plain negation, gets a hedged sentence instead. An unparenthesised A || B ahead of a stripped event clause is refused, and the docblocks name the third clause. Claude-Session: https://claude.ai/code/session_016WV4cxRDKprCtjpEdtiPFW Co-authored-by: Claude --- scripts/pm/dispatch-gates.mjs | 97 +++++++++++++++++++++---- scripts/pm/dispatch-gates.self-test.mjs | 49 +++++++++++++ 2 files changed, 132 insertions(+), 14 deletions(-) diff --git a/scripts/pm/dispatch-gates.mjs b/scripts/pm/dispatch-gates.mjs index 0fde180be05..0c366561d8d 100644 --- a/scripts/pm/dispatch-gates.mjs +++ b/scripts/pm/dispatch-gates.mjs @@ -1259,14 +1259,32 @@ export function jobFilterOutputRefs(ifExpression) { * function IS this one with the event facts dropped. `fullBatteryOnly` is true * when the full-battery clause was stripped as the last conjunct: the job runs * on `main`'s push and hourly runs and NEVER on a `pull_request` or - * `merge_group` event. `notOnPullRequest` is true when either clause was - * stripped: the job never runs on the PR (alone, the queue-and-full clause — - * the merge-queue build runs it). `queueGate` is `{ job, output }` when the + * `merge_group` event. `notOnPullRequest` is true when any of the three event + * clauses was stripped: the job never runs on the PR (with the queue-and-full + * clause the merge-queue build runs it; with the queue-path clause it runs it + * only when `queueGate` matched). `queueGate` is `{ job, output }` when the * queue-path clause was stripped (the queue build runs the job only when that * output matched), else null. All are read in the same pass as the refs, * from the same text, so the population and the event facts cannot describe * two different `if:`s. + * + * ⛔ An UNPARENTHESISED `A || B` ahead of a stripped event clause is refused: + * GitHub binds `&&` tighter than `||`, so the clause would bind to `B` alone, + * and reading both refs under it would put an event fact on `A` that its text + * does not carry. The parenthesised `(A || B)` reads as before. */ +function wrappedWhole(expr) { + if (!expr.startsWith('(') || !expr.endsWith(')')) return false; + let depth = 0; + for (let i = 0; i < expr.length; i++) { + if (expr[i] === '(') depth++; + else if (expr[i] === ')') depth--; + if (depth === 0 && i < expr.length - 1) return false; + } + return true; +} +const bareOr = (expr) => expr.includes('||') && !wrappedWhole(expr.trim()); + export function jobIfReading(ifExpression) { if (typeof ifExpression !== 'string') return null; let expr = ifExpression.trim(); @@ -1275,6 +1293,7 @@ export function jobIfReading(ifExpression) { expr = expr.replace(JOB_IF_STATUS_TERM, ' ').trim(); const queuePath = JOB_IF_QUEUE_PATH_TERM.exec(expr); if (queuePath) { + if (bareOr(expr.slice(0, queuePath.index))) return null; const rest = jobIfReading(expr.slice(0, queuePath.index)); if (!rest || rest.notOnPullRequest) return null; return { ...rest, notOnPullRequest: true, queueGate: { job: queuePath[1], output: queuePath[2] } }; @@ -1285,6 +1304,7 @@ export function jobIfReading(ifExpression) { // `!= 'pull_request' && != 'pull_request'` as one clause. const eventFree = fullBatteryOnly ? fullFree : expr.replace(JOB_IF_QUEUE_AND_FULL_TERM, '').trim(); const notOnPullRequest = eventFree !== expr; + if (notOnPullRequest && bareOr(eventFree)) return null; expr = eventFree; // One balanced outer paren pair at a time — `(A || B)` is the live spelling. for (;;) { @@ -1507,7 +1527,8 @@ const EXTGLOB_CONSTRUCT = /[!?*+@]\(/; * * Returns `{ paths, outputs, dropped, fullBatteryOnly, notOnPullRequest, queueGate, queuePaths }`; * `queuePaths` are the queue-path output's translatable globs (null without the clause), and an - * untranslatable negation there, or an output the workflow does not declare, refuses the job. + * untranslatable negation there, or an output the workflow does not declare, refuses the job; + * `queueUncertain` is true when a positive extglob was dropped from them or one is a plain negation. * `paths` is a UNION: the `if:` is an OR of filter outputs, so CI schedules the * job when ANY of them matched. The two flags are `jobIfReading`'s event facts, * carried so a row built from this population can say WHEN CI schedules it @@ -1518,10 +1539,16 @@ export function jobFilterPopulation(job, filterStepsByOutputSource) { if (!reading) return null; const { refs, fullBatteryOnly, notOnPullRequest, queueGate } = reading; let queuePaths = null; + let queueUncertain = false; if (queueGate) { const globs = filterStepsByOutputSource.get(`${queueGate.job}.${queueGate.output}`); if (!globs || globs.some((g) => g.startsWith('!') && EXTGLOB_CONSTRUCT.test(g))) return null; queuePaths = globs.filter((g) => !EXTGLOB_CONSTRUCT.test(g)); + // A dropped positive extglob narrows the list; a plain negation is read by + // dorny/paths-filter (picomatch, per pattern) and by GitHub's ordered + // `paths:` language differently. Either way "none of your paths matched" + // is stronger than the evidence, so the row hedges instead (N1, #38087). + if (queuePaths.length !== globs.length || queuePaths.some((g) => g.startsWith('!'))) queueUncertain = true; } const paths = []; const outputs = []; @@ -1541,12 +1568,13 @@ export function jobFilterPopulation(job, filterStepsByOutputSource) { } outputs.push(`${ref.job}.${ref.output}`); } - return paths.length ? { paths, outputs, dropped, fullBatteryOnly, notOnPullRequest, queueGate, queuePaths } : null; + return paths.length ? { paths, outputs, dropped, fullBatteryOnly, notOnPullRequest, queueGate, queuePaths, queueUncertain } : null; } /** * Every job in one workflow whose `if:` resolves to a path population, WITH the - * job's own text: `[{ job, name, text, outputs, paths, dropped, fullBatteryOnly, notOnPullRequest }]`. + * job's own text: `[{ job, name, text, outputs, paths, dropped, fullBatteryOnly, notOnPullRequest, + * queueGate, queuePaths, queueUncertain }]` — the last three from the queue-path clause, null/false without it. * * ⛔ No check filter here, and that is the whole reason this is its own * function. The caller below drops a job that invokes no discoverable check @@ -2913,8 +2941,13 @@ export function alwaysRunSteps(entries) { * queue. A row whose clause was the queue-and-full one carries * `notOnPullRequest: true` alone (#30461): never on this PR, first on the * merge-queue build. A queue-path row (ruling record 7146156389) carries - * `queueOutput` and decides per CARD: a path of yours the output covers keeps - * `notOnPullRequest` alone, none covered sets `fullBatteryOnly` too. + * `queueOutput` and decides per CARD, on a glob matching the path ITSELF + * (`queueGlob`, with the path in `queuePath`): a match keeps `notOnPullRequest` + * alone; no match sets `fullBatteryOnly` too. ⛔ Never `triggerListCovers`' + * directory reach here: a directory surface such as `packages/runtime` reaches + * into a one-file glob under it, which says CI MAY run the leg, not that it + * will. A surface that only reaches, or a queue list `queueUncertain` marks, + * carries `queueHedged` and a sentence that says it depends on the files. * Both renderings print the fact on the row's own line, so * "scheduled BY YOUR PATHS" cannot be read as "this PR runs it". * @@ -3004,11 +3037,24 @@ export function jobFilteredSteps(entries, paths) { if (steps.length === 0) continue; counts.named += 1; const queueOutput = job.queueGate ? `${job.queueGate.job}.${job.queueGate.output}` : null; - const queueHit = queueOutput !== null && paths.some((p) => triggerListCovers(job.queuePaths, p)); + let queue = {}; + let queueMiss = false; + if (queueOutput !== null) { + const exact = paths.map((p) => ({ path: p, glob: triggerListMatches(job.queuePaths, p) })).find((h) => h.glob); + const reach = paths.find((p) => triggerListCovers(job.queuePaths, p)); + if (job.queueUncertain === true || (!exact && reach)) { + queue = { queueOutput, queueHedged: true, ...(reach ? { queuePath: reach } : {}) }; + } else if (exact) { + queue = { queueOutput, queuePath: exact.path, queueGlob: exact.glob }; + } else { + queue = { queueOutput }; + queueMiss = true; + } + } rows.push({ workflow: file, job: job.name, outputs: job.outputs, hits, dropped: job.dropped, - fullBatteryOnly: job.fullBatteryOnly === true || (queueOutput !== null && !queueHit), - notOnPullRequest: job.notOnPullRequest === true, ...(queueOutput ? { queueOutput } : {}), steps, + fullBatteryOnly: job.fullBatteryOnly === true || queueMiss, + notOnPullRequest: job.notOnPullRequest === true, ...queue, steps, }); } } @@ -7913,6 +7959,22 @@ export function triggerCovers(pattern, inputPath) { return literalPrefix.length > 0 && literalPrefix.startsWith(`${inputPath}/`); } +/** + * `triggerListCovers` WITHOUT the directory reach: the deciding pattern only + * when one matches the path itself, in the same last-match-wins order. The + * queue-path row reads this (ruling record 7146156389): a directory that a + * one-file glob reaches into is not a changed file that glob matches. + */ +export function triggerListMatches(patterns, inputPath) { + let decided = null; + for (const raw of patterns ?? []) { + const negated = raw.startsWith('!'); + if (!triggerPatternRegex(negated ? raw.slice(1) : raw).test(inputPath)) continue; + decided = negated ? null : raw; + } + return decided; +} + /** * Evaluate a workflow's whole `paths:` list against one input path and return * the pattern that DECIDED the answer, or null. @@ -12932,7 +12994,9 @@ export function alwaysRunLines(rows, counts) { * on the PR like any other. * * Read off `row.fullBatteryOnly` and `row.notOnPullRequest`, the facts - * `jobIfReading` took from the job's own `if:`; ⛔ never keyed on a job name, so + * `jobIfReading` took from the job's own `if:`, and for a queue-path row + * (ruling record 7146156389) `row.queueOutput` with `row.queueGlob` or + * `row.queueHedged`, the per-card split `jobFilteredSteps` made; ⛔ never keyed on a job name, so * a job that gains or loses either event clause gains or loses the clause here * with nothing to update. A queue-and-full row (#30461) says the PR skips the * job and the merge-queue build is its first run. @@ -12946,9 +13010,14 @@ export function fullBatteryOnlyClause(row) { return '⛔ does NOT run on this PR or in the merge queue: its `if:` excludes the pull_request event and admits merge_group' + ` only when \`${gate}\` matched, which none of your paths does, so its first run on this change is \`main\`'s push battery, AFTER the merge`; } - if (gate && row.notOnPullRequest === true) { + if (gate && row.notOnPullRequest === true && row.queueHedged === true) { + return '⛔ does NOT run on this PR: its `if:` excludes the pull_request event, and the merge-queue build runs it only if a' + + ` changed file is in \`${gate}\`${row.queuePath ? ` (your surface \`${row.queuePath}\` reaches into it but does not match it)` : ''};` + + " otherwise its first run on this change is `main`'s push battery, AFTER the merge"; + } + if (gate && row.notOnPullRequest === true && typeof row.queueGlob === 'string') { return '⛔ does NOT run on this PR: its `if:` excludes the pull_request event,' + - ` and your paths hit \`${gate}\`, so its first run on this change is the merge-queue build, after the PR is enqueued`; + ` and your paths hit \`${gate}\` (\`${row.queuePath}\` ⇢ '${row.queueGlob}'), so its first run on this change is the merge-queue build, after the PR is enqueued`; } if (row?.fullBatteryOnly === true) { return '⛔ does NOT run on this PR or in the merge queue: its `if:` excludes the pull_request and merge_group events,' + diff --git a/scripts/pm/dispatch-gates.self-test.mjs b/scripts/pm/dispatch-gates.self-test.mjs index dc8d893c091..22d15d92974 100644 --- a/scripts/pm/dispatch-gates.self-test.mjs +++ b/scripts/pm/dispatch-gates.self-test.mjs @@ -275,6 +275,7 @@ import { trackedPrefixes, triggerCovers, triggerListCovers, + triggerListMatches, typeCheckLaneLines, typeCheckLaneSteps, unnamedRootWalk, @@ -6764,11 +6765,33 @@ export function selfTest({ tier = 'full' } = {}) { '...an == merge_group disjunct refuses — it would say the opposite WHEN', jobFilterOutputRefs("${{ needs.f.outputs.a != 'false' && github.event_name != 'pull_request' && (github.event_name == 'merge_group' || needs.f.outputs.b != 'false') }}") === null, ); + // N3 (#38087): GitHub binds `&&` tighter than `||`, so a BARE `A || B` ahead of a + // stripped event clause puts the clause on `B` alone — refused, never read as both. + t( + '...a bare A || B ahead of the queue-and-full clause refuses; parenthesised it reads', + jobFilterOutputRefs("${{ needs.f.outputs.a != 'false' || needs.f.outputs.b != 'false' && github.event_name != 'pull_request' }}") === null + && jobFilterOutputRefs("${{ (needs.f.outputs.a != 'false' || needs.f.outputs.b != 'false') && github.event_name != 'pull_request' }}")?.length === 2, + ); + t( + '...a bare A || B ahead of the queue-path clause refuses too', + jobFilterOutputRefs(`\${{ needs.f.outputs.a != 'false' || needs.f.outputs.b != 'false' && ${QUEUE_PATH} }}`) === null, + ); t( '...and the queue-path clause without the pull_request exclusion ahead of it refuses', jobFilterOutputRefs("${{ needs.f.outputs.a != 'false' && (github.event_name != 'merge_group' || needs.f.outputs.b != 'false') }}") === null, ); + // N1 (#38087): a queue list narrowed by a dropped positive extglob, or carrying a + // plain negation, cannot back "none of your paths matched" — it is marked uncertain. + const queueJob = { if: `\${{ needs.filter.outputs.core != 'false' && ${QUEUE_PATH} }}` }; + const queuePop = (globs) => jobFilterPopulation(queueJob, new Map([['filter.core', ['packages/**']], ['filter.temporal_live', globs]])); + t( + 'jobFilterPopulation: a clean queue list is certain; a dropped positive extglob or a plain negation marks it queueUncertain', + queuePop(['packages/a/**'])?.queueUncertain === false + && queuePop(['packages/a/**', 'apps/!(docs)/**'])?.queueUncertain === true + && queuePop(['packages/a/**', '!packages/a/b.ts'])?.queueUncertain === true, + ); + t('...and a negated extglob in it still refuses the job', queuePop(['packages/a/**', '!apps/!(docs)/**']) === null); const fixturePops = jobPathPopulations(jobFilterWf, 'fixture.yml'); t( 'only the jobs whose if: RESOLVED and that invoke a check family contribute a population', @@ -13639,6 +13662,32 @@ export function selfTest({ tier = 'full' } = {}) { Boolean(driverStripped) && !jobFilteredNotMeasuredLine(driverStripped).includes(QUEUE_PATH_NOTE) && plainRowLine(driverStripped) !== '' && !plainRowLine(driverStripped).includes(QUEUE_PATH_NOTE), ); + // S1 (#38087): a DIRECTORY surface that a one-file temporal_live glob only reaches + // into is not a queue hit — the row hedges, and never says the queue build runs it first. + const QUEUE_HEDGE = 'the merge-queue build runs it only if a changed file is in `filter.temporal_live`'; + t( + 'triggerListMatches decides on the path ITSELF: a directory a one-file glob reaches into is covered, never matched', + triggerListCovers(['packages/runtime/src/**/x-real-driver*'], 'packages/runtime') !== null + && triggerListMatches(['packages/runtime/src/**/x-real-driver*'], 'packages/runtime') === null + && triggerListMatches(['packages/runtime/src/**/x-real-driver*'], 'packages/runtime/src/a/x-real-driver.test.ts') !== null, + ); + const dirRow = jobFilteredSteps(liveWorkflows, ['packages/runtime']).rows.find((r) => r.job.startsWith('Temporal Conformance')) ?? null; + t( + "LIVE: the directory surface 'packages/runtime' gets the HEDGED sentence — not the queue-build-first one, not the full-battery one", + dirRow?.queueHedged === true && dirRow?.fullBatteryOnly === false && dirRow?.queueGlob === undefined + && jobFilteredNotMeasuredLine(dirRow).includes(QUEUE_HEDGE) && !jobFilteredNotMeasuredLine(dirRow).includes(QUEUE_FIRST) + && !jobFilteredNotMeasuredLine(dirRow).includes(NOT_ON_PR) && plainRowLine(dirRow).includes(QUEUE_HEDGE), + ); + const dirStripped = dirRow ? Object.fromEntries(Object.entries(dirRow).filter(([k]) => k !== 'queueHedged')) : null; + t( + '...ABLATED — queueHedged stripped from the row — the hedge disappears and the defect sentence (queue build first) is what remains', + Boolean(dirStripped) && !jobFilteredNotMeasuredLine(dirStripped).includes(QUEUE_HEDGE) + && jobFilteredNotMeasuredLine(dirStripped).includes(QUEUE_FIRST), + ); + t( + '...and the driver-sql file row names the glob that matched it, so the claim can be checked', + driverRow?.queueGlob === 'packages/drivers/driver-sql/**' && driverRow?.queuePath === 'packages/drivers/driver-sql/src/sql-driver.ts', + ); const prJobRow = ledgerRow('Build Core'); t( 'LIVE NEGATIVE CONTROL: Build Core, scheduled by the same path and run on the PR, carries the fact as FALSE and no statement',