Skip to content

Commit 7046451

Browse files
committed
ci: the required-contexts wiring pin admits the scheduled-run skip on the pin lane
The lane hosting the required-context pin may now carry exactly one job-level if: -- lint.yml's scheduled-run skip, admitted only as the whole shape (byte-exact lane if, needs on schedule-gate, a gate job gated to schedule alone). Any other if: is still refused; six self-test cases pin both directions. Claude-Session: https://claude.ai/code/session_01QSeKYmhU5KEj1nukYhp1Tg Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1638799 commit 7046451

1 file changed

Lines changed: 68 additions & 4 deletions

File tree

‎scripts/check-required-contexts.mjs‎

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
235235
'the recognizer itself, in BOTH directions': 10,
236236
'…and the NARROW recognizer beside it, in both directions': 6,
237237
'is the pin WIRED into the required job?': 3,
238-
'the wiring recognizer, in BOTH directions': 13,
238+
'the wiring recognizer, in BOTH directions': 19,
239239
});
240240

241241
// DELETING an entry silences that battery's floor exactly as effectively as
@@ -991,6 +991,36 @@ function jobsCarriedByLint(doc) {
991991
return carried;
992992
}
993993

994+
// The ONE job-level `if:` a lane hosting the pin may carry: lint.yml's scheduled-run skip
995+
// (#26071, ruling 6416984681, letter A (i)). The lane needs `schedule-gate`, a job that runs
996+
// on `schedule` only; on every other event that job is skipped, its output reads empty, and
997+
// `!cancelled()` runs the lane past it — so no PR, queue build or push can arrange that the
998+
// pin does not run on it without editing one of these two byte-exact spellings, which is
999+
// what the wiring assertion then refuses. Any other `if:` on the lane is still refused.
1000+
const SCHEDULE_GATE_JOB = 'schedule-gate';
1001+
const SCHEDULE_GATE_JOB_IF = "github.event_name == 'schedule'";
1002+
const SCHEDULE_SKIP_LANE_IF = "${{ !cancelled() && needs.schedule-gate.outputs.skip != 'true' }}";
1003+
1004+
/**
1005+
* Whether every lane hosting the pin carries either no job-level `if:` or exactly the
1006+
* scheduled-run skip, read from one parsed lint.yml. The `lint` aggregate itself is exempt by
1007+
* construction: its `if: always()` (plus its schedule-only conjunct) is what makes it report.
1008+
*
1009+
* @param {unknown} doc a parsed lint.yml
1010+
* @returns {boolean}
1011+
*/
1012+
function pinLanesCarryNoArrangeableIf(doc) {
1013+
const gate = doc && typeof doc === 'object' && doc.jobs && typeof doc.jobs === 'object' ? doc.jobs[SCHEDULE_GATE_JOB] : undefined;
1014+
const gateIsScheduleOnly = !!gate && typeof gate === 'object' && gate.if === SCHEDULE_GATE_JOB_IF;
1015+
return jobsCarriedByLint(doc)
1016+
.filter(([, job]) => pinSteps(job).length > 0)
1017+
.every(([id, job]) => {
1018+
if (id === 'lint' || !Object.prototype.hasOwnProperty.call(job, 'if')) return true;
1019+
const needs = Array.isArray(job.needs) ? job.needs.map(String) : typeof job.needs === 'string' ? [job.needs] : [];
1020+
return gateIsScheduleOnly && job.if === SCHEDULE_SKIP_LANE_IF && needs.includes(SCHEDULE_GATE_JOB);
1021+
});
1022+
}
1023+
9941024
/**
9951025
* Judge a registry against already-parsed workflows.
9961026
*
@@ -3277,9 +3307,11 @@ async function selfTest() {
32773307
// …and, since the pin moved into a lane (#22991), neither may the LANE: a job-level `if:` is
32783308
// the same arrangement one level up, and it is the one a step-level read cannot see. The
32793309
// aggregate itself is exempt by construction — its `if: always()` is what makes it report.
3310+
// One spelling is admitted, the scheduled-run skip (`pinLanesCarryNoArrangeableIf`, #26071):
3311+
// it can skip the lane on `schedule` alone, never on a PR or a queue build.
32803312
assert(
3281-
hosts.every((h) => h.id === 'lint' || !Object.prototype.hasOwnProperty.call(h.job, 'if')),
3282-
'wiring: the lane hosting the required-context pin must carry NO job-level `if:` — a skipped lane is a pin that did not run',
3313+
pinLanesCarryNoArrangeableIf(lintDoc),
3314+
'wiring: the lane hosting the required-context pin must carry NO job-level `if:` other than the scheduled-run skip — a skipped lane is a pin that did not run',
32833315
);
32843316

32853317
// ── the wiring recognizer, in BOTH directions ────────────────────────────
@@ -3358,8 +3390,9 @@ async function selfTest() {
33583390
);
33593391
// (q) ⭐ #22991: the pin in a LANE of the `lint` aggregate — declared AND needed — is wired.
33603392
// The checked-in lint.yml is this shape; the fixture pins the reading apart from it.
3361-
const aggregateFixture = ({ declare, need, laneIf = null }) =>
3393+
const aggregateFixture = ({ declare, need, laneIf = null, gateIf = null, laneNeedsGate = false }) =>
33623394
lintFixture(
3395+
...(gateIf ? [' schedule-gate:', ` if: ${gateIf}`, ' runs-on: ubuntu-latest', ' steps:', ' - run: echo skip=false'] : []),
33633396
' lint:',
33643397
' name: Lint & Repo Gates',
33653398
...(need ? [' needs: [lint-lane]'] : []),
@@ -3370,6 +3403,7 @@ async function selfTest() {
33703403
' - name: Verify every lint lane succeeded',
33713404
' run: node verify.mjs',
33723405
' lint-lane:',
3406+
...(laneNeedsGate ? [' needs: [schedule-gate]'] : []),
33733407
...(laneIf ? [` if: ${laneIf}`] : []),
33743408
' runs-on: ubuntu-latest',
33753409
' steps:',
@@ -3401,6 +3435,36 @@ async function selfTest() {
34013435
'wiring: a job-level `if:` on the lane hosting the pin is SEEN by the hosts read (#22991) — the live no-`if:` assertion depends on it',
34023436
);
34033437
}
3438+
// (u) #26071: the live no-`if:` predicate itself, in BOTH directions. The scheduled-run skip
3439+
// is admitted only as the whole shape — the lane's byte-exact `if:`, its `needs:` on the gate,
3440+
// and a gate job that runs on `schedule` alone; any one half missing is refused again.
3441+
{
3442+
const skip = { declare: true, need: true, laneIf: SCHEDULE_SKIP_LANE_IF, gateIf: SCHEDULE_GATE_JOB_IF, laneNeedsGate: true };
3443+
assert(
3444+
pinLanesCarryNoArrangeableIf(parse(aggregateFixture({ declare: true, need: true }))),
3445+
'wiring: a pin lane with NO job-level `if:` passes the live predicate (#26071 control)',
3446+
);
3447+
assert(
3448+
pinLanesCarryNoArrangeableIf(parse(aggregateFixture(skip))),
3449+
'wiring: the scheduled-run skip (lane `if:` + `needs: [schedule-gate]` + a schedule-only gate) is admitted on the pin lane (#26071)',
3450+
);
3451+
assert(
3452+
!pinLanesCarryNoArrangeableIf(parse(aggregateFixture({ declare: true, need: true, laneIf: "github.event_name != 'pull_request'" }))),
3453+
'wiring: any other job-level `if:` on the pin lane is still refused (#26071)',
3454+
);
3455+
assert(
3456+
!pinLanesCarryNoArrangeableIf(parse(aggregateFixture({ ...skip, gateIf: "github.event_name != 'merge_group'" }))),
3457+
'wiring: the skip spelling is refused when the gate job also runs on a PR — there it could say skip (#26071)',
3458+
);
3459+
assert(
3460+
!pinLanesCarryNoArrangeableIf(parse(aggregateFixture({ ...skip, gateIf: null }))),
3461+
'wiring: the skip spelling is refused when no `schedule-gate` job exists to bound it (#26071)',
3462+
);
3463+
assert(
3464+
!pinLanesCarryNoArrangeableIf(parse(aggregateFixture({ ...skip, laneNeedsGate: false }))),
3465+
'wiring: the skip spelling is refused when the lane does not need the gate it reads (#26071)',
3466+
);
3467+
}
34043468
// (n) the genuine article, spelled the way lint.yml spells it.
34053469
assert(
34063470
pinWiredIn(lintJobFixture(' - name: Required-context name pin', ` run: pnpm ${PIN_SCRIPT}`)),

0 commit comments

Comments
 (0)