diff --git a/config/merge-queue/ruleset.queue-refs.json b/config/merge-queue/ruleset.queue-refs.json index a04898dd552..144d2dba767 100644 --- a/config/merge-queue/ruleset.queue-refs.json +++ b/config/merge-queue/ruleset.queue-refs.json @@ -1,11 +1,11 @@ { - "_comment": "omni-queue ruleset template for the queue's OWN refs (docs/ops/OMNI_QUEUE.md): the state branch and the candidate branches. Applied by scripts/merge-queue/apply-ruleset.mjs --kind queue-refs, which fills the App bypass actor_id from --app-id. Only the queue's GitHub App may create, update or delete these refs; nobody can rewrite their history. Keys starting with '_' are stripped before the REST call.", + "_comment": "omni-queue ruleset template for the queue's OWN refs (docs/ops/OMNI_QUEUE.md): the state branch and the candidate branches. Applied by scripts/merge-queue/apply-ruleset.mjs --kind queue-refs, which fills the App bypass actor_id from --app-id. Only the queue's GitHub App may create, update or delete these refs; nobody can rewrite their history. Keys starting with '_' are stripped before the REST call. The candidate pattern is omni-queue/**/* and must stay so: in GitHub's ruleset patterns a trailing ** matches ONE path segment only, and candidate refs have two (omni-queue//-), so omni-queue/** left them unprotected (measured against GitHub on 2026-11-15).", "name": "omni-queue refs protection", "target": "branch", "enforcement": "active", "conditions": { "ref_name": { - "include": ["refs/heads/omni-queue-state", "refs/heads/omni-queue/**"], + "include": ["refs/heads/omni-queue-state", "refs/heads/omni-queue/**/*"], "exclude": [] } }, diff --git a/docs/ops/OMNI_QUEUE.md b/docs/ops/OMNI_QUEUE.md index 5737f8109e0..7e8bd44c7f7 100644 --- a/docs/ops/OMNI_QUEUE.md +++ b/docs/ops/OMNI_QUEUE.md @@ -732,7 +732,11 @@ of the door, which is why it lives in a protected environment (see `omni-queue-state` and `omni-queue/**`, with the fixed name `omni-queue refs protection`. It has the rules `creation`, `update`, `deletion` and `non_fast_forward`, and one bypass actor: the App (`Integration`, bypass mode `always`). Only the App creates, updates or deletes the state branch and -the candidate branches. Two consequences: +the candidate branches. Its include patterns are `refs/heads/omni-queue-state` and +`refs/heads/omni-queue/**/*`: in GitHub's ruleset patterns a trailing `**` matches one path segment +only, and a candidate ref has two (`omni-queue//-`), so `omni-queue/**` left +the candidates unprotected (measured against GitHub on 2026-11-15); do not simplify the pattern. +Two consequences: - once it is applied, a candidate rehearsal can only be started through `workflow_dispatch` of the `omni-queue` workflow: a user token can no longer push an `omni-queue/**` ref; diff --git a/scripts/merge-queue/apply-ruleset.mjs b/scripts/merge-queue/apply-ruleset.mjs index a235a720708..5dd43db1445 100644 --- a/scripts/merge-queue/apply-ruleset.mjs +++ b/scripts/merge-queue/apply-ruleset.mjs @@ -13,7 +13,7 @@ // (config.landing.statusContext) written by the queue's GitHub App, pinned with // integration_id. The queue writes that status on the validated candidate right // before landing it; the landing push is then made as config.landing.actor. -// queue-refs ruleset.queue-refs.json — the queue's own refs (omni-queue-state, omni-queue/**): +// queue-refs ruleset.queue-refs.json — the queue's own refs (omni-queue-state, omni-queue/**/*): // only the App (its single bypass actor) may create, update or delete them. Takes no // --base; the ruleset keeps the fixed name of its template. // Created when absent, updated when its normalized form differs, left alone otherwise. --dry-run diff --git a/tests/unit/merge-queue/apply-ruleset.test.mjs b/tests/unit/merge-queue/apply-ruleset.test.mjs index ed288d9195e..e93033c28fb 100644 --- a/tests/unit/merge-queue/apply-ruleset.test.mjs +++ b/tests/unit/merge-queue/apply-ruleset.test.mjs @@ -278,7 +278,7 @@ test("queue-refs template: valid REST shape, the queue's refs, App-only bypass s assert.equal(parsed.success, true, JSON.stringify(parsed.error?.issues)); assert.deepEqual(qr.conditions.ref_name.include, [ "refs/heads/omni-queue-state", - "refs/heads/omni-queue/**", + "refs/heads/omni-queue/**/*", ]); assert.deepEqual(qr.rules.map((r) => r.type).sort(), [ "creation", @@ -292,6 +292,16 @@ test("queue-refs template: valid REST shape, the queue's refs, App-only bypass s assert.ok(!JSON.stringify(qr).includes(BASE_PLACEHOLDER), "no base placeholder"); }); +test("queue-refs template: no include pattern ends in a trailing double star", () => { + // In GitHub's ruleset patterns a trailing `**` matches ONE path segment only (measured against + // GitHub on 2026-11-15): `omni-queue/**` covered `omni-queue/x` but not the two-segment + // candidate refs `omni-queue//-`, so a user token could plant them. + // `omni-queue/**/*` covers every depth. + for (const pattern of queueRefsTemplate().conditions.ref_name.include) { + assert.ok(!pattern.endsWith("/**"), `${pattern} ends in a trailing double star`); + } +}); + // ───────────────────────────── buildRuleset ───────────────────────────── test("release ruleset: one required status pinned to the App and no bypass actor", () => { @@ -509,7 +519,7 @@ test("queue-refs ruleset: only the App may create, update or delete", () => { assert.equal(rs.name, queueRefsTemplate().name, "fixed name, no branch suffix"); assert.deepEqual(rs.conditions.ref_name.include, [ "refs/heads/omni-queue-state", - "refs/heads/omni-queue/**", + "refs/heads/omni-queue/**/*", ]); assert.deepEqual(rs.conditions.ref_name.exclude, []); assert.deepEqual(rs.rules.map((r) => r.type).sort(), [ @@ -814,7 +824,7 @@ test("main --kind queue-refs applies the queue refs ruleset: no --base, App id r assert.equal(created.name, queueRefsTemplate().name); assert.deepEqual(created.conditions.ref_name.include, [ "refs/heads/omni-queue-state", - "refs/heads/omni-queue/**", + "refs/heads/omni-queue/**/*", ]); assert.deepEqual(created.bypass_actors, [ { actor_id: 4242, actor_type: "Integration", bypass_mode: "always" },