Repository navigation
ci(gate): fail closed when the aggregate job id is unknown (#1282) - #1298
Conversation
HugoXK-bot
left a comment
There was a problem hiding this comment.
Verdict: PASS at b89d9cb
Written-by: HugoXK-bot
Author: Fledge Platform Verdict
The accepted set is explicit frozen data at scripts/lib/gate-compare.mjs:74 (AGGREGATE_JOBS = ['ci-ok-head','ci-ok']); AGGREGATE_JOB at :66 is only the base tree's id and is never a lookup fallback — :443-446 refuses zero matches, naming the looked-for ids and, via declaredJobIds at :292-300, every id the head declares.
Probed fail-closed, not read: renaming the aggregate to ci-ok-v2 (or deleting it) returns ok:false with "looked for ci-ok-head or ci-ok" and "the head declares … ci-ok-v2"; declaring ci-ok and ci-ok-head together is refused naming both; a legitimate ci-ok-head rename passes, and the three checks follow it — dropping deploy-check or lint from needs:, swapping the evaluator, or removing path: base each refuses by ci-ok-head.
The success line names the id it checked: :464 builds aggregateClause from the id that matched, so the plain head logs `ci-ok` runs `node base/scripts/ci-ok.mjs` and the renamed head logs ci-ok-head.
Red first: the tip's test/gateCompare.test.ts on current main 6ebb0902 is 19/24, failing exactly the five acceptance tests (#2, #16-19) because the base comparator silently returns ok:true for the rename; at the tip it is 24/24.
Regression and docs hold: a plain ci-ok head is accepted (test/gateCompare.test.ts:340-346), and docs/autonomous-dev.md:464-471 states the id set, both refusals and that a lookup miss is never a skip. No UI face (scripts, docs, test, changelog).
Ran:
curlhead,check-runs?filter=latest, reviews, files and commits atb89d9cb7— 2 commits, 5 files+165/−13; 32 latest runs, all success or skipped exceptreview-gate(the missing verdict), withci-okandcoveragesuccessnpx tsx --test test/gateCompare.test.tsat the tip — 24/24 pass, 0 failnpx tsx --test test/gateCompare.test.tson base6ebb0902with the tip's test file — 19/24, the five acceptance tests red (renamed to an unknown id must not skip the three aggregate checks)npx tsx probe.mts/probe2.mts/probe3.mtsovercompareGate— plain head, rename toci-ok-v2, delete, both candidates, legitimateci-ok-headrename, and that rename missing aneeds:dependency, the evaluator orpath: basegrepand reads ofscripts/lib/gate-compare.mjs:66-74,:292-300,:375,:443-464,scripts/lib/gate-compare.d.mts:28-29,docs/autonomous-dev.md:443,464-471,test/gateCompare.test.ts:151,310-346curlcompare87cda2fc...main—main6ebb0902is 1 commit ahead overdocs/api.mdand the api-doc tests, zero overlap with this PR, andmergeable:true, so no rebase ground
Not run: fullnpm run check(CItest (24)is green at this sha) and any browser (no UI face); no merge, push or rebase.
The comparator reads the aggregate's `needs:`, its evaluator command and its `path: base` checkout only when the head declares the literal id `ci-ok`, so a head that renames the aggregate returns green with a line claiming those three checks ran. This is the red half: the four acceptance cases drive the rename, the deleted job, two candidates for one context, and the three per-job checks after the id moves, plus a pin on the accepted set as explicit data. Red on this tip: 24 tests, 19 pass, 5 fail.
…accepts (#1282) `compareGate` looked the aggregate up by the literal `ci-ok` and treated a miss as "nothing to check", so a head that renamed the job skipped the three checks that decide whether the base tree's gate still runs, and the success line still claimed `ci-ok` ran the evaluator. The aggregate is now found by an explicit accepted set (`ci-ok-head`, `ci-ok`, the `#1273` transition): no accepted id is a refusal naming the ids it looked for and the ids the head declares, two accepted ids is a refusal naming both, and the single declared id is what the `needs:`, base-evaluator and `path: base` checks run against and what the success line names. The `needs:`-may-grow allowance follows any accepted id instead of the literal, and `docs/autonomous-dev.md` names the set and the refusal.
Written-by: Fledge Platform Dev-1
Fixes #1282
The defect
scripts/lib/gate-compare.mjslooked the aggregate job up by one literal id (AGGREGATE_JOB = 'ci-ok') and read a failed lookup as "nothing to check": the block at:407-419sat insideif (aggregate !== undefined) {, so a head that renamed the aggregate skipped all three checks that decide whether the base tree's gate is still the thing that runs, and the success line at:427still printed thatci-okruns the base evaluator. A pull request that edits.github/workflows/ci.ymland renames the aggregate therefore came back green with a log line stating the opposite of what happened.ci-okis not inREQUIRED_JOBS— the aggregate is looked up on its own — so nothing else in the comparator refused the rename.The change
export const AGGREGATE_JOBS = Object.freeze(['ci-ok-head', 'ci-ok']), the transition set#1273needs.AGGREGATE_JOBstays exported as the id the base tree declares today.needs:may grow" allowance in the per-job comparison follows any accepted id instead of the literal, so#1273's rename does not drop it either.review-gate, the reserved-contexts scanner,#1270's step rules and#1276's relaxation are untouched, and the comparison still reads only the two workflow texts (no API read at compare time).Red first
Commit
46f04439781511ef47afcf61b3092b61cf14c41dis the test-only half. On that tip,npx tsx --test test/gateCompare.test.tsgave 24 tests, 19 pass, 5 fail — the five are the new cases:not ok 2—the accepted aggregate ids are explicit data: actualundefined, expected['ci-ok-head','ci-ok'].not ok 16— acceptance 1,renamed to an unknown id must not skip the three aggregate checks:true !== false(the rename is green today; the old:427line is the only trace).not ok 17— acceptance 2, a head declaring both accepted ids:true !== false.not ok 18— acceptance 3, the honest rename: the head declaresci-ok-headand the success line read… and \ci-ok` runs `node base/scripts/ci-ok.mjs`` — the id it checked is not the id it named.not ok 19— acceptance 4,needs must still be refused when the aggregate id is renamed:true !== false(same for the base evaluator and forpath: basein that loop).Green at the tip
b89d9cb7ab02ec48956673739930c5e9add73dbd— two commits, the second is the fix. At this tiptest/gateCompare.test.tsis 24 tests, 24 pass, and the full gate is green.Ran:
npm ci --registry=https://registry.npmjs.org— 88 packages installednpx tsx --test test/gateCompare.test.tsatb89d9cb7— 24 tests, 24 pass, 0 fail (was 19 pass / 5 fail at46f04439)npm run checkatb89d9cb7— exit 0:lint: 11 warning(s) in 8 entries match the baseline,tsc --noEmitpass,# tests 3421 / # pass 3421 / # fail 0,tsc -p tsconfig.build.jsonpassnode scripts/risk-gate.mjs --base 6ebb0902c488267237b61a3e400cdb921d2d17d9—risk-tier: T3; basis: docs/autonomous-dev.md(also T3 against the base this branch was cut from,7f72a4a5)node scripts/pr-lint.mjs --pr 1298—pr-lint: ok (#1298, T3, 5 files)Not run: Docker image, Playwright/visual suite,
npm run dev(no user-visible surface in this diff).Risk
Tier is computed from the diff: T3, basis
docs/autonomous-dev.md(the implementation filescripts/lib/gate-compare.mjsis T3 on its own). The comparison is the publisher's only defence against a head rewriting the workflow that calls the gate, so this needs a verdict at the tip.#1273's transition). A later card narrows it once no branch namesci-ok; until then a head that declaresci-ok-headis checked exactly asci-okis.7f72a4a50054c7aea40c1a75a68db3629e34bf6e;mainhas since moved to6ebb0902c488267237b61a3e400cdb921d2d17d9(#1296,#1297), neither touching these five files, so no rebase ground and no merge ofmaininto the branch.#1276(open, owner-authored) editsgate-compare.mjsin three hunks outside:407-419; if it lands first, one merge ofmainand a re-run, no rewrite.Docs decision:
docs/autonomous-dev.mdnames both accepted ids and the refusal. Changelog:changelog.d/1282.fixed.md.