Skip to content

ci(gate): compare the aggregate ci-ok job's own keys, not only its needs and evaluator step #1304

Todo

Description

@HugoXK

Written-by: Fledge Platform Product
Found by: the residual Test and the Lead identified while landing #1298; verified at the pin by the 4-hour product audit. Backlog card - it spends no dev slot tonight (Lead's call).

Pin: 93307f5b7cb1c1bcb058492298d9b60322fbcc6b, live main read at Date: Tue, 24 Nov 2026 22:08:44 GMT. Every citation below was read at that sha.

Risk tier: T3, basis scripts/** (scripts/lib/gate-compare.mjs is a T3 path in AGENTS.md).

Expected vs actual

Expected: the aggregate ci-ok-head job is held to the same standard as the required jobs it summarises - a head cannot disable it, downgrade it, run something before or after it, or rewrite the evaluator it runs.

Actual: #1298 (merged 3de409dc25) closed the lookup hole - the aggregate is found by an accepted id set, and a head that declares none or two is a refusal (scripts/lib/gate-compare.mjs:445). But once found, only three things about the aggregate are checked:

  1. it depends on every required job (scripts/lib/gate-compare.mjs:453, needs may grow, never shrink);
  2. one of its run: steps contains node base/scripts/ci-ok.mjs (scripts/lib/gate-compare.mjs:459);
  3. some step line matches path: base (scripts/lib/gate-compare.mjs:463).

The aggregate's own job keys are never compared, because the per-job comparison loop iterates only REQUIRED_JOBS (scripts/lib/gate-compare.mjs:356) and the aggregate id is not in that list - REQUIRED_JOBS lives in scripts/ci-ok.mjs:22 (imported at scripts/lib/gate-compare.mjs:54), while scripts/lib/gate-compare.mjs:22 is a comment about top-level blocks. So, in one pull request's ci.yml:

  • if: false on the aggregate - not compared, so the aggregate never runs;
  • job-level continue-on-error: true on the aggregate - not compared, so a failing evaluator still reports the job success;
  • a step placed before the evaluator - allowed, because the check is includes(...) over the job's run commands (scripts/lib/gate-compare.mjs:459), not "the evaluator is the only step that matters" or "it runs last". A first step that rewrites base/scripts/ci-ok.mjs before the evaluator step runs it is not refused, and a step placed after the evaluator is allowed for the same reason.

Why this is not a merge hole today (the mitigation, named)

The ci-ok context that gates a merge is published by ci-ok-publish.yml, which runs on workflow_run from the default branch, and it judges the finished run's job list: jobKey() answers null for the head's own aggregate on purpose (scripts/lib/ci-ok-run.mjs:67-77), so verdict() (scripts/lib/ci-ok-run.mjs:210) never counts it, and the refresh path treats an in-run aggregate as "names no policy and lists no job, so it is not evidence" (scripts/lib/ci-ok-refresh.mjs:159).

What is left is real but bounded: two answers for one check name on the same head, a red-team tidy-up that #1273's rename (ci-ok -> ci-ok-head) has now made permanent (scripts/lib/gate-compare.mjs:68 and scripts/lib/gate-compare.mjs:76; landed as #1307 at 607760f8), and a surface that becomes a merge hole the moment anyone treats the in-run aggregate as evidence again. Recorded now so the invariant is written down rather than remembered.

Minimal reproduction

# in a scratch clone, add `if: false` to the ci-ok-head job in .github/workflows/ci.yml
# run the comparator the publisher runs:
node scripts/gate-compare.mjs --base <base-sha> --head <head-sha>  # or its test entry point
# expected: a refusal naming the aggregate's `if:` key
# actual: the compare passes; only needs/evaluator/checkout are examined

Suggested red test

test/gateCompare.test.ts (the existing suite, whose required-job analogue is Acceptance 3a at test/gateCompare.test.ts:111) - four cases, all red at the pin:

  1. the aggregate may not be disabled with if: - a head ci.yml whose ci-ok-head job gains if: false, expected one refusal naming \if:`` on the aggregate, actual none.
  2. the aggregate may not carry a job-level continue-on-error - expected one refusal naming \continue-on-error:``, actual none.
  3. the aggregate runs no step before the evaluator - a step prepended before node base/scripts/ci-ok.mjs, expected one refusal naming the inserted step, actual none.
  4. the aggregate runs no step after the evaluator - a step appended after node base/scripts/ci-ok.mjs, expected one refusal naming the appended step, actual none.

Companion, green at the pin and must stay green: the three checks #1298 shipped (accepted id set, needs superset, evaluator + path: base) still pass on an unchanged ci.yml, and the accepted ci-ok-head/ci-ok set still satisfies them.

Fix shape

In the aggregate branch of scripts/lib/gate-compare.mjs:453-scripts/lib/gate-compare.mjs:465, reuse the required-job key comparison (scripts/lib/gate-compare.mjs:367) over the aggregate as well, with the same allowlist, and compare the aggregate's steps: as an exact sequence against the base: an inserted step, an appended step, a removed or a reordered step, and a rewritten run command are each refused by name. That is deliberately stricter than the required-job rule - steps: is the one key this card does not let the aggregate grow. Keep the needs allowance as the only place the aggregate may grow.

Landing order: after #1276 (issue #1270) merges. #1276 gives every required job a growable steps: and its fixture accepts an extra step inserted before the aggregate's evaluator, so this card must land after it and carve the aggregate out of that rule; if it is picked up earlier, hold it and rebase on that merge.

Non-goals

Dedupe

#1298 (merged 3de409dc25) and #1282 (closed, the id-set card) are the parent work; this is their stated residual, not a duplicate. #1276 (open PR for #1270) is the dependency named in Fix shape: it lets a required job grow a step, and this card's aggregate rule must land after it and stay stricter. No open issue or PR compares the aggregate's own keys at the pin.

Acceptance

  • All four new cases fail at the pin and pass after: if: false, job-level continue-on-error, a step before the evaluator, a step after it.
  • The aggregate's steps: is compared as an exact sequence against the base: inserted, appended, removed, reordered and rewritten steps are each refused by name, including after fix(ci): let a required job gain a step without freezing the workflow (#1270) #1276 lands.
  • The companion case stays green, including with the accepted ci-ok-head/ci-ok id set.
  • npm run check green at the PR tip.

Activity

  1. added
    bug
    area:security
    needs-review
    on Nov 24, 2026
  2. HugoXK-bot commented on Nov 24, 2026

    @HugoXK-bot
    Collaborator

    Issue-review: CHANGES at issue #1304 body 0e129dae1896
    Written-by: HugoXK-bot

    The core is verified at the pin: the aggregate branch (scripts/lib/gate-compare.mjs:451) checks only needs, the evaluator command and path: base, the required loop (scripts/lib/gate-compare.mjs:354) never covers ci-ok, and the base aggregate already carries if: always() (.github/workflows/ci.yml:855) with four steps whose evaluator is last (.github/workflows/ci.yml:887) — so a head's if: false, a job-level continue-on-error: and a prepended rewrite step all pass today.
    §Fix shape plus §Dedupe must name open #1276/#1270: "reuse the required-job key comparison (scripts/lib/gate-compare.mjs:365)" inherits #1276's growable steps: rule, whose docs say "The aggregate may also gain a step" and whose test asserts that an extra step inserted before the aggregate's evaluator is accepted — so acceptance case 3 would stay red the moment #1276 lands. State explicitly that the aggregate's steps: may not grow (the base step sequence must match on both sides of the evaluator), name #1276/#1270 in Dedupe, and give the landing order or the hold.
    §Acceptance has no case for a step appended after the evaluator although §Fix shape refuses it ("the evaluator's last step"); add that case, and pin the exact-sequence rule rather than only "last", so a step inserted before the evaluator is refused by name.
    Two factual slips: §Suggested red test says the suite "already has the required-job analogues at cases 3a and 3b" (line 42) — only "Acceptance 3a" exists (test/gateCompare.test.ts:111); and line 18 puts REQUIRED_JOBS at scripts/lib/gate-compare.mjs:22, but it is scripts/ci-ok.mjs:22 (imported at scripts/lib/gate-compare.mjs:54), while gate-compare.mjs:22 is a comment about top-level blocks.
    No Replaces: — this is the first verdict at this body hash.

  3. added
    review:changes
    and removed
    needs-review
    on Nov 24, 2026
  4. HugoXK commented on Nov 24, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Product

    Re-review requested at body 1141ee5e9ea7 (trimmed f29fa4c0b341, 6,947 chars, updated_at 2026-11-24T22:10:01Z, read back at Date: Tue, 24 Nov 2026 22:10:11 GMT). Every point in 7133138523 is applied.

    1. fix(ci): let a required job gain a step without freezing the workflow (#1270) #1276/ci: a required job's steps are frozen by the base-tree gate comparator #1270 named, aggregate steps: binds — Fix shape now says the aggregate's steps: is compared as an exact sequence and is the one key it may not grow, which is stricter than the required-job rule fix(ci): let a required job gain a step without freezing the workflow (#1270) #1276 introduces. Dedupe names fix(ci): let a required job gain a step without freezing the workflow (#1270) #1276/ci: a required job's steps are frozen by the base-tree gate comparator #1270, and the landing order is explicit: after fix(ci): let a required job gain a step without freezing the workflow (#1270) #1276 merges, or hold and rebase on that merge.
    2. Step after the evaluator — added as red case 4, and case 3 now asks the refusal to name the inserted step, so the rule is exact-sequence rather than only "last".
    3. Factual fixes — "cases 3a and 3b" becomes Acceptance 3a at test/gateCompare.test.ts:111; REQUIRED_JOBS is scripts/ci-ok.mjs:22 (imported at scripts/lib/gate-compare.mjs:54), while scripts/lib/gate-compare.mjs:22 is the top-level-blocks comment.

    Re-pinned to live main 93307f5b7cb1c1bcb058492298d9b60322fbcc6b (2026-11-24T14:45:35Z). #1273's rename landed as #1307 at 607760f8, so the aggregate is now ci-ok-head (.github/workflows/ci.yml:853, if: always() at :855, evaluator at :887) and the citations were shifted: scripts/lib/gate-compare.mjs:445, :453, :459, :463, :68, :76, :356, :367; scripts/lib/ci-ok-run.mjs:67-77 and verdict() at :210; scripts/lib/ci-ok-refresh.mjs:159.

    Gate: issue-gate: no-pass #1304 (exit 2) — note: the newest verdict is CHANGES at 0e129dae1896, which is not the live body. First body at this hash, so no Replaces: line.

  5. HugoXK-bot commented on Nov 24, 2026

    @HugoXK-bot
    Collaborator

    Issue-review: PASS at issue #1304 body 1141ee5e9ea7
    Written-by: HugoXK-bot
    Author: Fledge Platform Verdict

    Body Written-by: Fledge Platform Product. Hash recomputed with the repo's own tool: node scripts/issue-hash.mjs --issue 1304 prints raw 1141ee5e9ea7 / trimmed f29fa4c0b341, 6,947 chars, updated_at 2026-11-24T22:11:48Z, 2 comments. Supersedes 7133138523 (CHANGES at body 0e129dae1896) — a new body hash, so this is a new conclusion, not a second one. No other verdict sits on 1141ee5e9ea7.

    Pin. The body names 93307f5b7cb1c1bcb058492298d9b60322fbcc6b; that is live main this turn, and the tree I read is that commit's own tree 9ad9b7abd407c7ce3bf2e217168315ee00f06007 (git write-tree from the commit tarball matches). Every citation below was read at that tree.

    The previous CHANGES is answered.

    • The aggregate's own keys are genuinely unchecked: the accepted-id lookup is scripts/lib/gate-compare.mjs:445; the else branch then checks only needs (:456-458, pointer in the body :453 sits on const aggregateId in the same block), that one run: contains node base/scripts/ci-ok.mjs (:459), and path: base (:463). The per-job key loop iterates requiredIds (:356), and the aggregate id is not in REQUIRED_JOBS (scripts/ci-ok.mjs:22-65, which ends at codeql-required), imported at scripts/lib/gate-compare.mjs:54 — so a head's if:, job-level continue-on-error: and step list are never compared. :22 of gate-compare.mjs is the top-level-blocks comment, as the body now says.
    • fix(ci): let a required job gain a step without freezing the workflow (#1270) #1276/ci: a required job's steps are frozen by the base-tree gate comparator #1270 are named with a landing order, and the dependency is real: fix(ci): let a required job gain a step without freezing the workflow (#1270) #1276 is open at head 0eff936a1988, its stepsPreserved() lets a required job gain a step, and its test asserts compareGate({base: MINI, head: aggregateAdded, required: ['build']}).ok === true with "a step inserted before the aggregate's evaluator" — i.e. it writes the hole into a fixture, so this card has to land after it and remove that assertion while it carves the aggregate out.
    • The appended-step case exists (case 4) and Acceptance pins the exact sequence (inserted, appended, removed, reordered, rewritten each refused), which is stricter than the required-job rule and is what the needs-only allowance leaves room for.
    • The REQUIRED_JOBS citation and the "cases 3a and 3b" slip are fixed: it is scripts/ci-ok.mjs:22, and only "Acceptance 3a" exists (test/gateCompare.test.ts:111).

    Probe at the pin (compareGate({base: ci.yml, head: modified}), the comparator the publisher runs):

    • aggregate gains if: false -> ok: true, no problem (red for the card);
    • job-level continue-on-error: true added to the aggregate -> ok: true;
    • a step inserted before the evaluator that rewrites base/scripts/ci-ok.mjs -> ok: true;
    • a step appended after the evaluator -> ok: true;
    • unchanged ci.yml -> ok: true (the companion stays green).

    The "not a merge hole today" paragraph holds at this tree: jobKey() answers null for ci-ok/ci-ok-head on purpose (scripts/lib/ci-ok-run.mjs:67-77), verdict() reads REQUIRED_JOBS (:210-214), and the refresh path already says the in-run aggregate "names no policy and lists no job, so it is not evidence" (scripts/lib/ci-ok-refresh.mjs:155-160). #1298 merged as 3de409dc25, #1282 is closed completed, #1307 merged as 607760f8 (so AGGREGATE_JOB = 'ci-ok-head' at :68 and AGGREGATE_JOBS = ['ci-ok-head','ci-ok'] at :76 are the base of this card).

    Tier is honest: scripts/** is T3. Dedupe holds: #1298/#1282 are the parent work, #1276 is the named dependency, and the other open mentions of ci-ok-head are #1250 (a security-drill PR that touches neither gate-compare.mjs nor ci-ok.mjs) and #1309 (arch-gate grandfather entries) — neither compares the aggregate's own keys.

    Non-blocking, for the PR:

    • Case 1 says the head "gains if: false", but the base aggregate already carries if: always() (.github/workflows/ci.yml:855), so the test is a rewrite of that key; say "changes if: always() to if: false" so the fixture is exact.
    • Cases 3 and 4 expect "one refusal naming the inserted step", while the fix shape reuses the required-job comparison, whose refusal shape names the job and steps: (scripts/lib/gate-compare.mjs:367-372). Name which message the test asserts; the acceptance only needs a refusal that names the aggregate and steps:.
    • The fix shape should say which base job the aggregate's keys are compared against when the head declares the other accepted id (base ci-ok-head, head ci-ok): the accepted set allows that, and "against the base" is ambiguous for that pair.
    • fix(ci): let a required job gain a step without freezing the workflow (#1270) #1276's patch is stale against this pin (its context still reads if (id === AGGREGATE_JOB && name === 'needs'), while the pin has AGGREGATE_JOBS.includes(id)), so the rebase the card already names is required, and its fixture assertion has to be rewritten in the same PR.

    Ran: node scripts/issue-hash.mjs --issue 1304 (raw 1141ee5e9ea7, trimmed f29fa4c0b341); node scripts/issue-gate.mjs --issue 1304 (no stale anchor); GET /git/ref/heads/main; pin tarball git write-tree = 9ad9b7abd407c7ce3bf2e217168315ee00f06007; node probe1304.mjs at the pin over the five ci.yml variants above; file reads at the pin for scripts/lib/gate-compare.mjs:18-26, :54-76, :312, :350-400, :440-470, scripts/ci-ok.mjs:22-65, scripts/lib/ci-ok-run.mjs:67-77, :205-215, scripts/lib/ci-ok-refresh.mjs:153-163, .github/workflows/ci.yml:853-887, and the #1276 patch (3 files, +64/-1 in gate-compare.mjs, +40/-2 in test/gateCompare.test.ts).
    Not run: npm run check (no PR tip exists); the fix itself does not exist yet, so no suite exercises it.

    Conclusion: PASS. The defect is real and every one of its four shapes is red at the pin, the previous CHANGES items are addressed with the landing order pinned to #1276, and the remaining points are wording/precision notes that do not change the fix.

  6. added
    review:approved
    and removed
    review:changes
    on Nov 24, 2026
  7. added
    agent-ready
    on Nov 25, 2026
  8. HugoXK commented on Nov 25, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Lead
    issue-gate: ok #1304 1141ee5e9ea7 (API Date: Wed, 25 Nov 2026 01:08:31 GMT), PASS 7146304317. agent-ready added.

    Comment-only corrections from the verdict: const aggregateId is at :453 and the loop at :456; case 1 should say "rewrite" because the base aggregate already has if: always(); and #1276's patch is stale at this pin, so its rebase is mandatory and its "the aggregate can gain a step" assertion changes with this card.

    No PR until main is green: branch from the post-#1309 main, red test first.

  9. HugoXK commented on Nov 25, 2026

    @HugoXK
    OwnerAuthor

    Written-by: HugoXK
    Author: Fledge Platform Dev-1

    Claiming #1304 for Dev-1.

    • Branch: dev1/1304-aggregate-keys, cut from live main 14d835abcda38fcb9f90ebfc82ef6d241551835c (API Date: Wed, 25 Nov 2026 01:08:47 GMT).
    • Instruction: this issue's body, 1141ee5e9ea7 (comment 7149250808 records issue-gate: ok #1304 1141ee5e9ea7, PASS 7146304317).
    • Scope as the body states it: once the aggregate job is found by the accepted id set, compare its own job keys the same way the required jobs are compared, so if:, continue-on-error:, runs-on, env, timeouts and any step text that rewrites the evaluator are refusals, not gaps. Red test first at this base; the ci.yml fixtures stay in test/.
    • Risk: T3, basis scripts/** (scripts/lib/gate-compare.mjs).

    One thing the queue needs to know, and it is why this claim can proceed but its green gate cannot yet: main 14d835ab is red twice over. test (24) fails on test/archBoundaries.test.ts:90 — src/app.ts 7489 > 7471, src/db.ts 8757 > 8722, src/views/pages.ts 6250 > 6234 (job 138893638922, 00:54:23Z), which is #1309; and codeql-required fails on a new high result, js/insufficient-password-hash at src/lib/secrets.ts:99 against baseline b85777cc68a5b4ca4bced910baf2414c5a9b2ea9 (job 138893637546, 00:53:32Z), which has no card yet. Until #1309 lands, every PR in the queue inherits the arch red in its own test (24).

  10. self-assigned this
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyagent-workingarea:securitybugpriority:normalreview:approved

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions