Skip to content

ci(gate): fail closed when the aggregate job id is unknown (#1282) - #1298

Merged
HugoXK merged 2 commits into
mainfrom
dev1/1282-aggregate-unknown
Nov 24, 2026
Merged

HugoXK merged 2 commits into
mainfrom
dev1/1282-aggregate-unknown

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Written-by: Fledge Platform Dev-1

Fixes #1282

The defect

scripts/lib/gate-compare.mjs looked 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-419 sat inside if (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 :427 still printed that ci-ok runs the base evaluator. A pull request that edits .github/workflows/ci.yml and renames the aggregate therefore came back green with a log line stating the opposite of what happened.

ci-ok is not in REQUIRED_JOBS — the aggregate is looked up on its own — so nothing else in the comparator refused the rename.

The change

  • The accepted ids are explicit data, not a fallback: export const AGGREGATE_JOBS = Object.freeze(['ci-ok-head', 'ci-ok']), the transition set #1273 needs. AGGREGATE_JOB stays exported as the id the base tree declares today.
  • No accepted id declared: refused, naming the ids it looked for and every id the head does declare; no success line is produced.
  • Both accepted ids declared as separate jobs: refused, naming both.
  • Exactly one declared: the three aggregate checks run on that job, and the success line names the id it actually read.
  • The "aggregate 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.
  • Nothing else moves: the required job set, 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 46f04439781511ef47afcf61b3092b61cf14c41d is the test-only half. On that tip, npx tsx --test test/gateCompare.test.ts gave 24 tests, 19 pass, 5 fail — the five are the new cases:

  • not ok 2 — the accepted aggregate ids are explicit data: actual undefined, 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 :427 line 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 declares ci-ok-head and 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 for path: base in that loop).

Green at the tip

b89d9cb7ab02ec48956673739930c5e9add73dbd — two commits, the second is the fix. At this tip test/gateCompare.test.ts is 24 tests, 24 pass, and the full gate is green.

Ran:

  • npm ci --registry=https://registry.npmjs.org — 88 packages installed
  • npx tsx --test test/gateCompare.test.ts at b89d9cb7 — 24 tests, 24 pass, 0 fail (was 19 pass / 5 fail at 46f04439)
  • npm run check at b89d9cb7 — exit 0: lint: 11 warning(s) in 8 entries match the baseline, tsc --noEmit pass, # tests 3421 / # pass 3421 / # fail 0, tsc -p tsconfig.build.json pass
  • node 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 file scripts/lib/gate-compare.mjs is 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.

  • Rollback: revert this squash; the comparator returns to the one-literal lookup, i.e. the previous fail-open behaviour on a rename.
  • Residual: the accepted set is two ids on purpose (#1273's transition). A later card narrows it once no branch names ci-ok; until then a head that declares ci-ok-head is checked exactly as ci-ok is.
  • Base movement: cut from 7f72a4a50054c7aea40c1a75a68db3629e34bf6e; main has since moved to 6ebb0902c488267237b61a3e400cdb921d2d17d9 (#1296, #1297), neither touching these five files, so no rebase ground and no merge of main into the branch. #1276 (open, owner-authored) edits gate-compare.mjs in three hunks outside :407-419; if it lands first, one merge of main and a re-run, no rewrite.

Docs decision: docs/autonomous-dev.md names both accepted ids and the refusal. Changelog: changelog.d/1282.fixed.md.

@HugoXK-bot HugoXK-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  • curl head, check-runs?filter=latest, reviews, files and commits at b89d9cb7 — 2 commits, 5 files +165/−13; 32 latest runs, all success or skipped except review-gate (the missing verdict), with ci-ok and coverage success
  • npx tsx --test test/gateCompare.test.ts at the tip — 24/24 pass, 0 fail
  • npx tsx --test test/gateCompare.test.ts on base 6ebb0902 with 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.mts over compareGate — plain head, rename to ci-ok-v2, delete, both candidates, legitimate ci-ok-head rename, and that rename missing a needs: dependency, the evaluator or path: base
  • grep and reads of scripts/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-346
  • curl compare 87cda2fc...main — main 6ebb0902 is 1 commit ahead over docs/api.md and the api-doc tests, zero overlap with this PR, and mergeable:true, so no rebase ground
    Not run: full npm run check (CI test (24) is green at this sha) and any browser (no UI face); no merge, push or rebase.

@HugoXK-bot HugoXK-bot added the review:approved Issue reviewed and approved by the Fledge Platform Reviewer label Nov 24, 2026
@HugoXK
HugoXK merged commit 3de409d into main Nov 24, 2026
37 of 38 checks passed
@HugoXK
HugoXK deleted the dev1/1282-aggregate-unknown branch November 24, 2026 11:06
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved Issue reviewed and approved by the Fledge Platform Reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: fail closed when the aggregate job id is unknown, instead of skipping the aggregate checks

2 participants