diff --git a/scripts/check-required-contexts.mjs b/scripts/check-required-contexts.mjs index beb91310746..78508c4f0dc 100644 --- a/scripts/check-required-contexts.mjs +++ b/scripts/check-required-contexts.mjs @@ -629,8 +629,8 @@ export const INSTRUCTION_SURFACES = [ // Regression Gate` back (#30461), and 11→12 with `Temporal Conformance // (live PG + MySQL)` back (#38087), when the sentence also dropped its // count word (AGENTS.md's volatile-counts rule). The full set is pinned - // here so the corrected sentence cannot rot back — a rename in ANY of the - // twelve reddens this gate instead. + // here so the corrected sentence cannot rot back — a rename in ANY of them + // reddens this gate instead. file: 'AGENTS.md', statesTheSet: true, mustName: [ diff --git a/scripts/pm/check-expected-skips.mjs b/scripts/pm/check-expected-skips.mjs index a2ca2618e92..1311a77790c 100644 --- a/scripts/pm/check-expected-skips.mjs +++ b/scripts/pm/check-expected-skips.mjs @@ -374,10 +374,11 @@ function nameRefusal({ named }, bearers) { export const PR_EVENTS = Object.freeze(['pull_request', 'merge_group']); /** The term kinds `gateTerm` recognises, in the order a reason names them. */ -export const GATE_TERM_KINDS = Object.freeze(['filter-output', 'pr-event', 'event-action', 'label']); +export const GATE_TERM_KINDS = Object.freeze(['filter-output', 'pr-event', 'queue-filter', 'event-action', 'label']); const FILTER_TERM = /^needs\.filter\.outputs\.([A-Za-z_][A-Za-z0-9_-]*)\s*!=\s*'false'$/; const PR_EVENT_TERM = /^github\.event_name\s*!=\s*'([a-z_]+)'$/; +const QUEUE_EVENT_TERM = /^github\.event_name\s*!=\s*'merge_group'$/; const EVENT_ACTION_TERM = /^github\.event\.action\s*!=\s*'([a-z_]+)'$/; const LABEL_TERM = /^(!?)contains\(\s*github\.event\.pull_request\.labels\.\*\.name\s*,\s*'([^']+)'\s*\)$/; /** Any read of a `filter` output: a job spelling one that `gateTerm` does not read is refused, never ignored. */ @@ -436,6 +437,9 @@ function unwrapParens(term) { * `||` whose every term is one — false only when the filter * said `false` for every output it names * pr-event `github.event_name != ''`, `` in `PR_EVENTS` + * queue-filter `(github.event_name != 'merge_group' || needs.filter.outputs. != 'false')` + * — the merge-queue build runs the job only on an entry whose + * diff hits that output's paths filter * event-action `github.event.action != ''` — a pull_request event of * that action is its own run on the same head, and skips * label `contains(github.event.pull_request.labels.*.name, '')`, @@ -448,6 +452,8 @@ export function gateTerm(conjunct) { const inner = unwrapParens(term); if (inner !== null) { const alternatives = splitTopLevel(inner, '||') ?? []; + const queueOutput = alternatives.length === 2 && QUEUE_EVENT_TERM.test(alternatives[0]) ? FILTER_TERM.exec(alternatives[1])?.[1] : null; + if (queueOutput) return { kind: 'queue-filter', outputs: [queueOutput] }; const outputs = alternatives.map((a) => FILTER_TERM.exec(a)?.[1] ?? null); return outputs.length > 0 && outputs.every(Boolean) ? { kind: 'filter-output', outputs: [...new Set(outputs)] } : null; } @@ -510,7 +516,7 @@ function queueWidened(expr) { * job's skip stays exit 4. */ function filterTermProblem(wf, job, gate) { - const outputs = gate.terms.filter((t) => t.kind === 'filter-output').flatMap((t) => t.outputs); + const outputs = gate.terms.filter((t) => t.kind === 'filter-output' || t.kind === 'queue-filter').flatMap((t) => t.outputs); if (outputs.length === 0) return null; const needs = Array.isArray(job.needs) ? job.needs : typeof job.needs === 'string' ? [job.needs] : []; if (!needs.includes('filter')) return "its `if:` reads the `filter` job's outputs but the job does not `needs: filter` — the outputs read empty and the gate is not the filter's"; @@ -526,6 +532,7 @@ const tick = (xs) => xs.map((x) => `\`${x}\``).join(' / '); /** The reason a derived gated row carries, built from the terms the job really spells. */ function gatedReason(workflow, wf, gate, matrix) { + const queueFilter = gate.terms.find((t) => t.kind === 'queue-filter'); const parts = gate.terms.map((t) => { if (t.kind === 'filter-output') { const read = t.outputs.filter((o) => !queueWidened(String(wf.jobs?.filter?.outputs?.[o] ?? ''))); @@ -533,7 +540,9 @@ function gatedReason(workflow, wf, gate, matrix) { `gated on ${workflow}'s \`filter\` output ${tick(t.outputs)}${t.outputs.length > 1 ? ' (it skips only when every one said false)' : ''}: ` + 'a diff outside those paths skips it on the PR head, ' + (read.length === 0 - ? "and the merge-queue build widens it to 'true' and runs it on the merged tree" + ? queueFilter + ? "and the merge-queue build widens it to 'true'" + : "and the merge-queue build widens it to 'true' and runs it on the merged tree" : "the merge-queue build reads the same paths filter against the queue's base, and the scheduled full run widens it to 'true'") ); } @@ -545,9 +554,16 @@ function gatedReason(workflow, wf, gate, matrix) { if (PR_EVENTS.every((e) => t.events.includes(e))) { return `full battery only: its \`if:\` excludes ${tick(t.events)}, so it skips on ${where} and is answered by main's push and scheduled runs`; } - const answered = t.events.includes('pull_request') ? "the merge-queue build and main's push and scheduled runs" : "every PR head and main's push and scheduled runs"; + const answered = !t.events.includes('pull_request') + ? "every PR head and main's push and scheduled runs" + : queueFilter + ? `main's push and scheduled runs, and by the merge-queue build only on an entry whose diff hits ${tick(queueFilter.outputs)}` + : "the merge-queue build and main's push and scheduled runs"; return `its \`if:\` excludes ${tick(t.events)} alone, so it skips on ${where} and is answered by ${answered}`; } + if (t.kind === 'queue-filter') { + return `the merge-queue build runs it only when the entry's diff hits ${workflow}'s \`filter\` output ${tick(t.outputs)} (that output's paths filter) and skips it on every other entry`; + } if (t.kind === 'event-action') { return `its \`if:\` excludes the ${tick(t.actions)} pull_request event(s); each such event is its own run on the same head, beside the run that concluded`; } @@ -1116,9 +1132,11 @@ export function gateTermsSpelling(terms) { ? `filter ${t.outputs.join('|')}` : t.kind === 'pr-event' ? `pr-event ${t.events.join('|')}` - : t.kind === 'event-action' - ? `event-action ${t.actions.join('|')}` - : `label ${t.mode} ${t.label}`, + : t.kind === 'queue-filter' + ? `queue-filter ${t.outputs.join('|')}` + : t.kind === 'event-action' + ? `event-action ${t.actions.join('|')}` + : `label ${t.mode} ${t.label}`, ) .join(' + '); } @@ -1540,6 +1558,9 @@ export function selfTest() { t('jobGate: …nor always(), an absent if:, a non-string, or two ${{ }} blocks', [jg('always()'), jg(undefined), jg(true), jg("${{ needs.filter.outputs.a != 'false' }} && ${{ needs.filter.outputs.b != 'false' }}")].every((x) => x === null), true); t('jobGate: …nor an if: whose parentheses do not balance', jg("!cancelled() && (needs.filter.outputs.core != 'false'"), null); t('spelling: a gate renders in one short line', gateTermsSpelling(jg(FULL_BATTERY_IF).terms), 'filter core + pr-event pull_request|merge_group'); + const QUEUE_PATH_IF = "${{ !cancelled() && needs.filter.outputs.core != 'false' && github.event_name != 'pull_request' && (github.event_name != 'merge_group' || needs.filter.outputs.temporal_live != 'false') }}"; + t('jobGate: the queue-path shape reads its parenthesised merge_group clause as one queue-filter term', JSON.stringify(jg(QUEUE_PATH_IF)), JSON.stringify({ terms: [{ kind: 'filter-output', outputs: ['core'] }, { kind: 'pr-event', events: ['pull_request'] }, { kind: 'queue-filter', outputs: ['temporal_live'] }], other: 1 })); + t('term: NARROWNESS — the queue-filter clause is one spelling: reversed, or on another event, it is not read', [term("(needs.filter.outputs.x != 'false' || github.event_name != 'merge_group')"), term("(github.event_name != 'pull_request' || needs.filter.outputs.x != 'false')")].every((x) => x === 'null'), true); t('jobGate: the queue-and-full shape (#30461) is one pr-event term excluding pull_request alone', JSON.stringify(jg(QUEUE_AND_FULL_IF)?.terms.find((x) => x.kind === 'pr-event')?.events), JSON.stringify(['pull_request'])); // ---- the derivation, on the frozen fixture tree ---------------------------- @@ -1569,6 +1590,16 @@ export function selfTest() { const queueRow = fxRow('Dogfood Regression Gate (${{ matrix.shard }}/3)'); t('reason: a job excluding pull_request alone is NOT called full battery only (#30461)', queueRow?.reason.includes('full battery only'), false); t('reason: …it says only PR heads skip it and the merge-queue build answers it', queueRow?.reason.includes('skips on every PR head and is answered by the merge-queue build') && !queueRow?.reason.includes('every queue build'), true); + const qpFx = fixtureRoster((d) => { + d['ci.yml'].jobs.filter.outputs.temporal_live = "${{ steps.changes.outputs.temporal_live || 'true' }}"; + d['ci.yml'].jobs['queue-path'] = { name: 'Queue Path Job', needs: 'filter', if: QUEUE_PATH_IF }; + }); + const qpRow = qpFx.roster.find((r) => r.name === 'Queue Path Job'); + t('reason: a queue-path job names the path filter the queue build reads', qpRow?.reason.includes("the merge-queue build runs it only when the entry's diff hits ci.yml's `filter` output `temporal_live`"), true); + t('reason: …and never says the queue build answers it unconditionally', /answered by the merge-queue build|runs it on the merged tree/.test(qpRow?.reason ?? 'answered by the merge-queue build'), false); + t('reason: …and counts only the status function as unread', qpRow?.reason.includes('(plus 1 further condition(s)'), true); + const qpBad = fixtureRoster((d) => (d['ci.yml'].jobs['queue-path'] = { name: 'Queue Path Job', needs: 'filter', if: QUEUE_PATH_IF })); + t('derive: a queue-filter output the filter job does not declare is refused (the filter contract holds for it too)', qpBad.derivation.refused.some((r) => r.job === 'queue-path' && r.reason.includes('temporal_live')), true); t('reason: an opt-out label names its label', fxRow('Check Changeset')?.reason.includes('`skip-changeset` label skips it'), true); t('reason: a matrix job names its raw template', fxRow('Test Core (${{ matrix.shard }}/6)')?.reason.includes('raw `name:` template'), true); t('reason: unread conjuncts are counted, never hidden', fxRow('Build UI Deps')?.reason.includes('1 further condition(s)'), true); diff --git a/scripts/pm/dispatch-gates.mjs b/scripts/pm/dispatch-gates.mjs index 467214e58ab..2a1a8ba5701 100644 --- a/scripts/pm/dispatch-gates.mjs +++ b/scripts/pm/dispatch-gates.mjs @@ -2946,7 +2946,8 @@ export function alwaysRunSteps(entries) { * 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, + * will — unless the glob is that directory's whole subtree (`D/**` for the + * surface `D`), which every file under it matches. 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". @@ -3040,7 +3041,11 @@ export function jobFilteredSteps(entries, paths) { let queue = {}; let queueMiss = false; if (queueOutput !== null) { - const exact = paths.map((p) => ({ path: p, glob: triggerListMatches(job.queuePaths, p) })).find((h) => h.glob); + // A bare directory whose whole subtree one glob names (`D` beside `D/**`) is + // matched too: every file under it hits. Negations already set queueUncertain. + const exact = paths + .map((p) => ({ path: p, glob: triggerListMatches(job.queuePaths, p) ?? (job.queuePaths ?? []).find((g) => g === `${p.replace(/\/+$/, '')}/**`) ?? null })) + .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 } : {}) }; diff --git a/scripts/pm/dispatch-gates.self-test.mjs b/scripts/pm/dispatch-gates.self-test.mjs index b604353b233..d6b848545ef 100644 --- a/scripts/pm/dispatch-gates.self-test.mjs +++ b/scripts/pm/dispatch-gates.self-test.mjs @@ -14540,6 +14540,26 @@ export function selfTest({ tier = 'full' } = {}) { '...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', ); + // N4 (#38087): the bare directory a whole-subtree glob names is a match, not a reach. + const bareDirRow = jobFilteredSteps(liveWorkflows, ['packages/drivers/driver-sql']).rows.find((r) => r.job.startsWith('Temporal Conformance')) ?? null; + t( + "LIVE: the bare directory 'packages/drivers/driver-sql' gets the queue-build-first sentence, naming the whole-subtree glob, and NOT the hedge", + bareDirRow?.queueGlob === 'packages/drivers/driver-sql/**' && bareDirRow?.queuePath === 'packages/drivers/driver-sql' + && bareDirRow?.queueHedged === undefined && bareDirRow?.fullBatteryOnly === false + && jobFilteredNotMeasuredLine(bareDirRow).includes(QUEUE_FIRST) && !jobFilteredNotMeasuredLine(bareDirRow).includes(QUEUE_HEDGE), + ); + // N5 (#38087): queueUncertain reaches the ROW — a plain negation in temporal_live hedges + // even a file the list matches exactly (the list cannot back the queue-build-first claim). + const negatedWorkflows = liveWorkflows.map((w) => (w.file === 'ci.yml' + ? { ...w, text: w.text.replace(" - 'packages/drivers/driver-sql/**'\n", " - 'packages/drivers/driver-sql/**'\n - '!packages/drivers/driver-sql/README.md'\n") } + : w)); + t('the negation fixture really edits the live temporal_live list', negatedWorkflows.find((w) => w.file === 'ci.yml')?.text.includes("- '!packages/drivers/driver-sql/README.md'")); + const uncertainRow = jobFilteredSteps(negatedWorkflows, ['packages/drivers/driver-sql/src/sql-driver.ts']).rows.find((r) => r.job.startsWith('Temporal Conformance')) ?? null; + t( + 'LIVE + a plain negation: the exactly-matched driver-sql file row is queueHedged with no queueGlob, and says the hedge, not queue build first', + uncertainRow?.queueHedged === true && uncertainRow?.queueGlob === undefined && uncertainRow?.fullBatteryOnly === false + && jobFilteredNotMeasuredLine(uncertainRow).includes(QUEUE_HEDGE) && !jobFilteredNotMeasuredLine(uncertainRow).includes(QUEUE_FIRST), + ); 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',