Skip to content

refactor(templates): clean up the shipped automerge and approve-fork-ci workflows - #96

Merged
pasrom merged 7 commits into
mainfrom
refactor/workflow-cleanup
Nov 15, 2026
Merged

pasrom merged 7 commits into
mainfrom
refactor/workflow-cleanup

Conversation

@pasrom

@pasrom pasrom commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Cleanup of the shipped team workflows. Behaviour is unchanged: the templates need no new km automerge flag or output, so they still run against a pinned km 1.20.0 or later.

Changes

  • automerge, App condition: "KM_AUTOMERGE_APP=1 and a merge" was written out three times (act's environment, the token step's if, the merge script's APP). It is now one decide output, app, and act reads it in all three places. An environment: key cannot read env or steps, so a job output is the only shared place. The gate tests evaluate the output's expression on the same three cases.
  • automerge, review rule and marker: act holds the write token and runs no km, so it keeps its jq copy of the latest-review rule and of the comment marker. A new table-driven test runs both rules on the same review lists (a null user, a later comment, a dismissal, two pages) and requires the same answer. It also requires act's marker to equal automerge.MARKER.
  • automerge header: the condition list is gone. The header points at km's README and src/km/automerge.py at the commit ci.yml pins.
  • App setup docs: a new README section, "GitHub Apps for the team workflows", sets up both Apps side by side. Both use the secret names CI_APP_CLIENT_ID/CI_APP_PRIVATE_KEY in different environments. The names stay, since existing brains already hold them. Each header names the other App and links the section, and keeps the steps for its own App. A brain's copy then still describes itself at the km version it pins, and the pointers in km doctor, km upgrade and the skill's setup reference stay true.
  • approve-fork-ci, cutoff test: the run listing's filter, the paging stop and the check before each approval each wrote their own time comparison against the cutoff. They now share one jq prelude (after, at, fresh), and an unreadable time still counts as 0. Mutating the listing filter alone showed that no test failed, because the later check refused the run anyway. A test case now covers it: an older run is passed over and waited past.
  • SHIPPED: adds the new hashes of the three templates and keeps every old one. Checked that km upgrade replaces main's unchanged copies of all three.

Left out

  • Unused id: merge: kept. The workflow does not read it, but tests/automerge_smoke.sh uses it to find the merge step (step act merge and the token assertion).
  • Mint the App token right before the merge call: not done. act's GITHUB_TOKEN already has contents: write, so the App token gives no extra privilege during the re-checks. Its only difference is that its merge starts workflows. Splitting the step would put comment posting in two steps and widen the gap between the last re-read and the merge.
  • Move the >= 1.20.0 comparison into km: not done. The comparison decides whether the pinned km gets installed at all, so the gated km cannot decide it, and act does not run km. Tests 81g-88g pin this to the pin step, including the rule that the pin comment wins over __init__.py.
  • Fewer runner starts / API calls: none found that keep behaviour. Merging resolve into decide saves one short job, and only for a km:ready pull request, because the others stop in resolve. It would add a guard to each decide step, and the e2e check that a push-ci run concludes skipped relies on the job-level if. The act and decide re-reads guard real races, and the stand-in tests pin their exact call counts.
  • approve-fork-ci "variable never read": not found. shellcheck reports none, and the template is unchanged since 1.19.0.
  • approve-fork-ci "redundant retries": none are redundant. The run listing reads two different listings, not the same one twice. The pull-request re-read before each approval guards a pull request opened or retargeted during the wait (tests pr-opened-while-waiting, base-changed-while-waiting).

Checks

  • Smoke: automerge, team (incl. the approve-fork-ci/ready.control sync test), doctor, e2e, mounted_pins: all pass.
  • Mutation checks, each of which fails a test: act's review rule (DISMISSED dropped, grouped by state), act's marker, the app output (variable, merge term), act's APP, the token step's if, and in approve-fork-ci each cutoff site separately (listing filter, page stop, unreadable time, pre-approval recheck, after).
  • Sandbox e2e (E01, E02, E05, E05-ctl, E06, E07-github, E07-scripts, E20, AM-*), with the merge App, on this head: result to follow in a comment.

The run listing's filter and the paging stop each parsed a run's creation
time and compared it with the cutoff; one jq definition now does both. A
test case makes the listing filter bite on its own: an older run is passed
over and waited past, not only refused by the check before approval.
KM_AUTOMERGE_APP=1 and a merge was written out for act's environment, its
token step and the merge script. decide now outputs it as app, and act
reads that output in all three places (an environment cannot read a
step's or the job's env). The gate tests evaluate the output's expression
on the same three cases.
act holds the write token and runs no km, so it repeats the latest-review
rule in jq and the comment marker. A table of review lists (a null user,
a later comment, a dismissal, two pages) runs through both rules and must
give the same answer, and act's marker must be km's MARKER.
…st in the header

automerge's header no longer repeats the merge conditions: it points at
km's README and src/km/automerge.py at the pinned commit. Both App
workflows use secrets named CI_APP_CLIENT_ID and CI_APP_PRIVATE_KEY for
two different Apps in two environments; the names stay, since brains hold
them. A README section now sets up both Apps side by side, and each
header names the other App and points at it, while keeping the steps for
its own App so a brain's copy describes itself at the km it pins.
@pasrom

pasrom commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Sandbox e2e on 9c2a76c (E01, E02, E05, E05-ctl, E06, E07-github, E07-scripts, E20, AM-*, with the merge App): 16 pass, 2 fail. Both failures are jobs GitHub did not start: their annotation says the sandbox account's Actions spending limit was reached. They are not runs that failed.

  • AM-ok: the App merged the PR by rebase at the judged head, with the comment, and main-guard's commit rule held. The push runs of ci and main-guard that the merge started were not started by GitHub (billing), so the served-bundle and main-guard checks could not pass. The follow-up automerge run concluded skipped, so there was no loop.
  • E20: the bump PR is correct. The ci run it dispatched was not started (billing).
    Every check that tests a template this PR changes passed. The three remaining checks need a rerun once the sandbox's Actions allowance is restored.

The 1.21.0 release bump replaced the version in this requirement sentence
too; the workflow's gate stays at 1.20.0.
The pin step's need= is the one place the required km is stated; the
header, the README paragraph and km upgrade's note must name that version,
so a release's blanket version bump that moves one of them fails a test.
The release test reads only pin lines (pasrom/km, frozen:), so it neither
caught nor needed to ignore the README sentence.
@pasrom

pasrom commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Two new commits:

  • docs: the README's automerge paragraph said km 1.21.0 or later; the workflow's version gate requires 1.20.0, so the sentence now says 1.20.0. The 1.21.0 release bump had replaced that number. The release-pin lines (pasrom/km@<commit> # v1.21.0, frozen: v1.21.0) are unchanged.
  • test(automerge): need= in the pin step is now the one place the required km is stated. The workflow header, the README paragraph and km upgrade's note must each name that version. Changing any one of them to 1.21.0 fails the test.

The release test reads only lines that contain pasrom/km or frozen:, and only vX.Y.Z. It neither caught the wrong number nor has to skip the requirement sentence. CI is green on 9f0380d. No sandbox rerun: this month's Actions allowance is used up.

@pasrom
pasrom merged commit 2caff79 into main Nov 15, 2026
4 checks passed
@pasrom
pasrom deleted the refactor/workflow-cleanup branch November 15, 2026 10:13
@pasrom pasrom mentioned this pull request Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant