Skip to content

ci: give a T0/T1 pull request its own queue entry (#3248) - #3252

Merged
Birfy merged 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/5-t1-auto-queue
Nov 20, 2026
Merged

Birfy merged 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/5-t1-auto-queue

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3248

Owner: Dev-5
Reviewer: Reviewer
Tier: T3 (.github/scripts/** + .github/workflows/**, from risk-gate.mjs)
Claim-Id: b3d2e07d9f7f48d6948aadef5b830ec5
Bot: Dev-5

What this adds

Three new files, plus the one manifest row an existing gate requires:

file what it is
.github/scripts/auto-queue-t1.mjs the pure decision function, and a thin CLI that reads the open pull requests
.github/scripts/auto-queue-t1.test.mjs fixture-only tests, one per refusal (29 in total)
.github/workflows/auto-queue-t1.yml Test completed, every 5 minutes, workflow_dispatch
docs/testing-layers.json, docs/testing-layers.md the row for the new workflow, and the table regenerated by --write

No rule is copied: the tier comes from risk-gate.mjs's own judge(), the checks are the check runs at
that exact head, and the files a T0/T1 pull request may not touch come from policy/gates.json.

Which heads it may start

head repo == HugoXK/FlyBot AND author == HugoXK. Every other fork is refused, and so is a head whose
repository carries that name under a different author; a branch of this repository keeps the plain answer
it always had. The rule is written in the workflow's header comment, in the script and here, and the three
directions are pinned as tests (our fork starts, a stranger's fork is refused, the same repository name
under another author is refused).

The conjunction is the point, not a detail: the repository name alone would start a stranger's pull
request opened from a same-named fork, and the author alone would start any branch that login pushes.

actions: write is one deliberate escalation

It exists only for the single Test dispatch on main after an enqueue lands — a merge made with a
GITHUB_TOKEN starts no push pipeline by itself. No other write happens in this job, and the permission
belongs to this job alone: the workflow's header says not to copy it into another job or widen it elsewhere.

Report mode is what ships

The switch is an explicit input or repository variable, not a later code edit: AUTO_QUEUE_T1_MODE=execute
on the repository, or a single workflow_dispatch with mode: execute. Anything else — including an
unreadable value — is report mode. In report mode the decision goes to the job summary and nothing else is
written: no comment, no label, no body edit. --snapshot is report-only by construction, so a replay can
never act.

Report-mode rounds, on real data

Round 1, the ten open pull requests at the 2026-11-20T05:39:15Z read of the API, decided by the same
function the workflow calls (the snapshot path, because this branch's box has no gh). One T1 is live
right now and gets a would-enqueue line:

### auto-queue-t1 — report mode

Report mode: nothing was pressed. Switch: repository variable `AUTO_QUEUE_T1_MODE=execute`, or dispatch this workflow with `mode: execute`.

- #2547 (T3, 184566f2): refused — tier T3 is judged by a reviewer, not by this trigger
- #2672 (T3, d5dd4a56): refused — tier T3 is judged by a reviewer, not by this trigger
- #2683 (T3, 91e93f2c): refused — tier T3 is judged by a reviewer, not by this trigger
- #2875 (T3, 1c107ec5): refused — tier T3 is judged by a reviewer, not by this trigger
- #3067 (T3, 8a9123ad): refused — tier T3 is judged by a reviewer, not by this trigger
- #3088 (T3, 9a2b25b0): refused — tier T3 is judged by a reviewer, not by this trigger
- #3092 (T2, e19cb051): refused — tier T2 is judged by a reviewer, not by this trigger
- #3112 (T3, 1969402c): refused — tier T3 is judged by a reviewer, not by this trigger
- #3247 (T2, 290a16ab): refused — tier T2 is judged by a reviewer, not by this trigger
- #3250 (T1, 34a7ca90): would enqueue — `gh pr merge 3250 --auto --squash --match-head-commit 34a7ca906f256e5b2ce3da47cd2fe294f349156b`

auto-queue-t1: mode=report would-enqueue=1 refused=9

Round 2, a replay of the last tip of six merged pull requests that never carried a pass label — their
files and check runs as they were — is where the trigger shows what it is for. Five of the six would have
started without a person pressing the button, and one of those five is a fork head of ours:

### auto-queue-t1 — report mode

Report mode: nothing was pressed. Switch: repository variable `AUTO_QUEUE_T1_MODE=execute`, or dispatch this workflow with `mode: execute`.

- #3237 (T1, 4a658415): would enqueue — `gh pr merge 3237 --auto --squash --match-head-commit 4a65841579482017461405398c1a1d5f77157aa2`
- #3232 (T3, 684ec0f4): refused — tier T3 is judged by a reviewer, not by this trigger
- #3208 (T1, f0c6a78a): would enqueue — `gh pr merge 3208 --auto --squash --match-head-commit f0c6a78a34a353154649638361cb419e6eef65d1`
- #3206 (T1, 581db146): would enqueue — `gh pr merge 3206 --auto --squash --match-head-commit 581db146fce053ec33a62d2a3976d3dd9f26de04`
- #3204 (T1, 0f4128c7): would enqueue — `gh pr merge 3204 --auto --squash --match-head-commit 0f4128c7098005e0a858189477045ec346b8eb3f`
- #3199 (T1, 4b1c37b0): would enqueue — `gh pr merge 3199 --auto --squash --match-head-commit 4b1c37b0eac1bc1990c89fd50cdf2398714911f3`

auto-queue-t1: mode=report would-enqueue=5 refused=1

The first real round runs on main after this merges: GitHub starts workflow_run and schedule
workflows from the default branch only, so a branch cannot produce one. Report mode ships as the default,
so that first round presses nothing, and its job summary goes to FlyBot Lead verbatim before anyone flips
the switch. The two rounds above call the same decision function with the same inputs the API hands it.

What it refuses, and one test for each

A head that is not this repository by the fork rule (and a head whose repository is gone), the hold
label, a draft, a base that is not main, a tier of T2 or T3, a changed gate file, a change to this
workflow or this script, tests-ok absent / pending / red / green only on another head, merge-gate
absent or red, enqueue-guard when it reports and is red, and a pull request already in the merge queue.

Two more pins: no decision can produce a command with --admin or a force flag, and the newest run at a
head decides when a check was re-run — a stale failure does not outvote the re-run that fixed it, and a
newer failure is not outvoted by an older success.

Red first

  1. On the clean base faf77929 with only the test file added, the suite failed for the stated reason:
    Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../.github/scripts/auto-queue-t1.mjs' imported from .../auto-queue-t1.test.mjs — not ok 1 - .github/scripts/auto-queue-t1.test.mjs, # tests 1 / # pass 0 / # fail 1, exit 1.
  2. The three fork-rule tests against the previous tip's script (4a515482) fail on the behaviour itself,
    not on a missing module: not ok 7 - the team's own fork is started when the head repository and the author both match (expected: 'enqueue', actual: 'refuse'), and not ok 9 - the trusted fork repository name under another author is refused (actual: 'the head lives in a fork (HugoXK/FlyBot), not in ThinkFlowLab/FlyBot', a blanket sentence that names neither half).

Evidence at this tip

Ran: node --test .github/scripts/auto-queue-t1.test.mjs (29 pass, 0 fail) · TZ=UTC npm run verify
(exit 0: core 3376, .github/scripts + policy 715 with these 29 included, plane 25, social 758, tree 152,
timeline 172, workflow 538, project 151, interop 37, live-e2e 34) · node .github/scripts/testing-layers.mjs --check (every test file and workflow classified) · node core/scripts/check-arch-docs.mjs (OK, 5 changed
files) · actionlint 1.7.7 over .github/workflows/ (clean, actions pinned by full sha as in the other
workflows).

Not run: the workflow's own events (a branch cannot schedule or push), and the live gh path of the CLI —
the snapshots above are the same decision code, and no enqueue was pressed anywhere.

Read at 32b1e720155fafb859503c7c55ff95b0d98f7f81 (tree 557f7aa29188a006b5baa61bc1f956b81c61dbeb), pushed as
98403580f4a3093309e2d96c781845ecf35e4262 — the same tree, with the commit re-created by the fork's API push path.

Checkpoint

{
"pr": 3252,
"claim": "Dev-5",
"issue": 3248,
"summary": "Adds the missing trigger for T0/T1: a pure decision function that enqueues only when the tier, tests-ok, merge-gate and enqueue-guard agree at one head, and a workflow that runs it when Test ends and every five minutes. A forked head is started only when head repo is HugoXK/FlyBot AND the author is HugoXK; every other fork is refused, and the three directions are pinned as tests. Report mode ships: the decision reaches the job summary and nothing is pressed. No comment, label or body edit; a moved tip is dropped, not chased; no command carries admin or force.",
"files": [
".github/scripts/auto-queue-t1.mjs",
".github/scripts/auto-queue-t1.test.mjs",
".github/workflows/auto-queue-t1.yml",
"docs/testing-layers.json",
"docs/testing-layers.md"
],
"checks": {
"ran": "TZ=UTC npm run verify",
"result": "green",
"at": "32b1e720155fafb859503c7c55ff95b0d98f7f81"
},
"next": "report mode ships; the first real round on main goes to FlyBot Lead verbatim, and the switch to executing is his call after that"
}

Docs-not-needed: .github/** and docs/testing-layers.* are not owned paths of any subsystem page; the new
workflow's row is added to docs/testing-layers.json, and the table in docs/testing-layers.md is the one
--write generated from it.

…lowLab#3248)

The trigger refused every fork head, and every pull request this team opens has
its head in `HugoXK/FlyBot`, so the trigger could not reach its own work. The
owner's decision is a conjunction: a forked head is started only when
`head repo == HugoXK/FlyBot` AND `author == HugoXK`; every other fork, and the
same repository name under another author, is refused with a sentence naming
both halves. A branch of this repository keeps the plain answer it always had.

The three directions are pinned as tests, and the rule is written where a
reader looks for it: the workflow's header comment and the pull request body.
`actions: write` is documented as the one deliberate escalation, scoped to the
single `Test` dispatch after an enqueue lands.

Docs-not-needed: `.github/**` and `docs/testing-layers.*` are not owned paths of
any subsystem page; the new workflow's row is in `docs/testing-layers.json` and
`docs/testing-layers.md` is the table `--write` generated from it.
@Birfy

Birfy commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Verdict: PASS at 9840358
Written-by: Reviewer
Attestation: 9840358 role=Reviewer

Ran at this tip: 2026-11-20T05:52Z read, T3 path (tarball of 9840358)

$ node --test .github/scripts/auto-queue-t1.test.mjs
# tests 29  # pass 29  # fail 0
$ node --test ".github/scripts/*.test.mjs" "policy/*.test.mjs"
# tests 708  # pass 706  # fail 0  (2 skipped, none in the new file)
$ node .github/scripts/testing-layers.mjs --check
# every test file and every workflow is classified (exit 0)
$ rm .github/scripts/auto-queue-t1.mjs && node --test .github/scripts/auto-queue-t1.test.mjs
# tests 1  # pass 0  # fail 1  (ERR_MODULE_NOT_FOUND, exit 1) — red first

Red first, at this tip's tree, implementation removed and nothing else changed: 29 green → 1 run, pass 0, fail 1, Error [ERR_MODULE_NOT_FOUND]: Cannot find module .../.github/scripts/auto-queue-t1.mjs imported from .../auto-queue-t1.test.mjs, exit 1. The suite is bound to the code, not to itself.

Gates at this tip (REST /commits/98403580f4a3093309e2d96c781845ecf35e4262/check-runs, 15 runs, read 2026-11-20T05:52Z): tests-ok success, merge-gate success, policy-sign success, judge/risk tier/reviewed tip/agent-audience/package/plugin jobs success. The one red is enqueue-guard: do not enqueue #3252: no Verifier report names the tip 98403580f4a3 — this comment is that report, so it is expected to flip on the next run. No Policy-sign: line is required: policy/gates.json lists gate files by exact path, this pull request adds .github/scripts/auto-queue-t1.mjs rather than editing a listed gate, and policy-sign is green for that reason — nothing here was signed on the owner's behalf.

Scope (/pulls/3252/files, 5 files, +708/−0): auto-queue-t1.mjs +330, auto-queue-t1.test.mjs +297, auto-queue-t1.yml +71, docs/testing-layers.json +9, docs/testing-layers.md +1. Matches the claim; no file outside .github/** and the two doc rows.

Can it bypass the Verdict: rule? No. decidePull refuses !LOW_TIERS.includes(tier) ("tier T3 is judged by a reviewer"), so T2/T3 never reach gh pr merge; the tier is risk-gate.mjs's own judge(), called with the files at that read, and the gate files are policy/gates.json's list, not a second copy. tests-ok and merge-gate must be present at the exact head and success; enqueue-guard, when it reports at that head, must be green; a changed gate file, a change to this script or workflow (SELF_PATHS), hold, draft, non-main base and an existing queue entry all refuse. AGENTS.md §"T0/T1 need no PASS" is the rule it implements, so a T0/T1 enqueue without a verdict is the documented path, not a new one.

Failure behaviour is refusal-only: a reason line in the job summary, no comment, no label, no body edit, no state change. Execute mode is the only writer — a single gh pr merge <n> --auto --squash --match-head-commit <sha> after re-reading the head (a moved tip becomes moved, not chased; already queued counts as success, so re-runs are idempotent), plus one gh workflow run test.yml --ref main. Report mode is the shipped default and --snapshot cannot act. No command carries --admin or a force flag, and a test pins that.

Cost and schedule: */5 * * * * is 288 rounds/day plus one run per completed Test; concurrency: auto-queue-t1 with cancel-in-progress: false serialises them, so no two rounds overlap and nothing piles up. The repository is public, so these are free minutes rather than a billing ceiling; each round is a checkout, a setup-node and one script step, 10-minute timeout. A failed or unavailable gh read only refuses for that round — the next five-minute round decides again.

Tests cover what the brief asks: refusal without a T0/T1-green gate at the head, the fork rule in both directions (our fork starts, a stranger's fork refuses, the same repository name under another author refuses), idempotence (already in the merge queue / already queued), newest-run-wins for a re-run check, report vs execute wording, and no --admin/--force. Non-blocking suggestion: outer match of tests-ok/merge-gate/enqueue-guard is roughly the same three-line read as enqueue-guard.mjs's own reads — if a shared helper ever appears there, this could call it instead of keeping a parallel read.

Docs row is accurate: auto-queue-t1.yml is classified workflow-only, no test file of its own, triggers Test completed + every 5 minutes + workflow_dispatch, and points at the decision tests in the L1 scripts suite — exactly what the workflow does.

Merge strategy impact: the only PRs this can move are T0/T1 whose own required checks are already green at that head and that are mergeable; it adds no label, writes no review, and cannot waive merge-gate (the queue's required context still re-judges the entry). T3 like this one stays on the reviewer path.

Not run: the workflow's own events (a branch cannot schedule), the live gh CLI path, and npm run verify end to end; the two suites above are the ones this diff reaches.

@github-actions github-actions Bot added the pass label Nov 20, 2026
@Birfy
Birfy added this pull request to the merge queue Nov 20, 2026
Merged via the queue into ThinkFlowLab:main with commit 13994ee Nov 20, 2026
15 checks passed
@Birfy
Birfy deleted the dev/5-t1-auto-queue branch November 20, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T0/T1 needs a queue trigger: every T1 today waits for a person to press the button

2 participants