Skip to content

Feat(publish): Prepare forks in a separate job - #204

Merged
ModeSevenIndustrialSolutions merged 3 commits into
lfreleng-actions:mainfrom
modeseven-lfreleng-actions:feat/prepare-forks-job
Nov 22, 2026
Merged

ModeSevenIndustrialSolutions merged 3 commits into
lfreleng-actions:mainfrom
modeseven-lfreleng-actions:feat/prepare-forks-job

Conversation

@ModeSevenIndustrialSolutions

@ModeSevenIndustrialSolutions ModeSevenIndustrialSolutions commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Why

The publish job created a missing fork with an App token holding Administration: write. A GitHub App holds its permissions on every installation at once, so the code monkey App could administer every repository in lfreleng-actions, although only the fork pools needed it, and only to create or rename a fork (POST /repos/{target}/forks, PATCH /repos/{fork}). An audit of every write in scripts/ and .github/workflows/ found no other use of the grant.

What changes

Test(publish): Expect forks made outside the App: expected-fail contract and unit tests for the new shape.

Feat(publish): Prepare forks in a separate job

  • A new Prepare forks job (forks) runs after select, beside the author matrix, on live branches and pull-requests runs only. It holds contents: read, checks out the pinned trusted assets and nothing else, and runs scripts/fork_pool.py prepare.
  • Its one credential, the new optional fork_pool_token secret, reaches that one step. fork_pool.py refuses any token that is not a classic token scoped to public_repo alone (read from X-OAuth-Scopes), proves each matrix entry against config/fork-orgs.json, then finds, renames or creates each target's fork. It requests every missing fork before waiting for any, against one shared one-minute deadline, so a large first run waits about as long as one fork; it writes each summary row as that fork's outcome is final, tries every target, and fails the job if any fork is not ready. The job's timeout is 30 minutes. Without the secret it warns and does nothing.
  • Publish now depends on forks but still runs if forks fails or is skipped. The fork-create-token mint is gone, so no App mint requests Administration. The publisher's require_fork only reads the fork. When the fork is missing, no fork token is minted and the push fails that one issue with a reason naming the forks job.
  • The fork creation code and its tests move from branch_refs.py / test_fork_publish.py to fork_pool.py / test_fork_pool.py.
  • The cron caller forwards secrets.FORK_POOL_TOKEN.

Docs: Describe the forks job and pool token: updates DESIGN.md §4, §4.3, §8, §9.1, §10.1, §13 and §14, adds §10.6 on the fork pool credential, and updates README.md and docs/index.md.

Rollout

  1. Create a machine account that is a member of lfreleng-bot-forks, lfreleng-bot-forks-onap, lfreleng-bot-forks-oransc and lfreleng-bot-forks-opendaylight and of nothing else, with permission to create repositories there.
  2. Store its classic token (scope public_repo only) as the FORK_POOL_TOKEN repository secret here.
  3. After this merges and a run confirms the forks job, remove Administration from the LF/RelEng Code Monkey Bot App.

Until step 2, existing forks keep working. Every active public lfreleng-actions repository already has a fork in lfreleng-bot-forks.

Validation

  • uv run python -B -m unittest discover -s tests: 1618 tests OK (1587 before), at the head and at the Feat commit.
  • prek run --files <changed files>: all hooks pass, including aislop, basedpyright, mypy, actionlint and write-good.
  • scripts/agents/aislop-gate.sh upstream/main: clean, 16 files.
  • zizmor --persona auditor .github/workflows/ in online mode, both v1.30.1 locally and the version in config/zizmor-version.txt: no findings.

Creating or renaming a fork needs Administration: write, and a GitHub
App holds its permissions on every installation at once. The fork
creation mint therefore leaves the App able to administer every
repository in the target organisation, not just the fork pools.

These expected-fail tests describe the replacement: a "Prepare forks"
job, beside the author matrix, that creates and renames forks with a
machine account's token, which reaches that one step alone. No App
mint may request Administration, the publish job loses its fork
creation mint, and the publisher reads the fork it needs, reporting a
missing one by naming the forks job instead of making it. The caller
forwards the token from a FORK_POOL_TOKEN repository secret.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>

This comment was marked as outdated.

The publish job created a missing fork with an App token holding
Administration: write. A GitHub App holds its permissions on every
installation at once, so the code monkey App could administer every
repository in the target organisation, although only the fork pools
needed it, and only to create or rename a fork.

A new "Prepare forks" job does that instead, beside the author matrix.
It holds one credential, a fork_pool_token secret: a classic token of
a machine account that belongs to the fork organisations alone. The
job refuses any token not scoped to public_repo alone, proves every
matrix entry against the committed fork mapping, and finds, renames or
creates each target's fork, trying every target before failing. It
requests every missing fork before it waits for any, against one
shared deadline, and writes each fork's summary row as its outcome is
final, so a large first run fits its timeout and keeps its report.

The publisher now only requires the fork. It loses the fork creation
mint, so no App mint requests Administration and the App can drop the
permission. A fork still missing at publish time gets no fork token,
and the push fails that one issue with a reason naming the forks job.
fork_pool.py takes over the creation code and its tests; the cron
caller forwards the token from a FORK_POOL_TOKEN repository secret.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
The design described the publisher creating and renaming forks with
an App token holding Administration: write. The forks job does that
now, with a machine account's classic token, and the App holds no
Administration grant.

Section 4.3 gives the forks job step 1 and explains why the grant
cannot sit on the App; section 8 drops the creation mint; section 10.1
loses the Administration rows; a new section 10.6 describes the fork
pool credential and its reach. The failure modes gain an absent or
too-broad token, and the README and the overview show the new job and
the optional fork_pool_token secret.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Matthew Watkins <mwatkins@linuxfoundation.org>
Copilot AI balanced review requested due to automatic review settings November 18, 2026 20:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The credential migration requires operator verification of fork-pool-only machine-account access and post-rollout removal of App Administration permissions, which token scope checks cannot establish.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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.

2 participants