Security and secret isolation¶
How the workshop isolates administrative and publishing credentials from contributing developers across GitHub, GitLab, and Gitea.
Threat model¶
The workshop separates three roles:
- Fork contributors open pull requests from a separate repository and cannot push branches to the main repository.
- Write contributors can push branches and open pull requests in the main repository, and can merge changes into packages they own once required reviews pass.
- Repository administrators own the root
[owners]paths inCODEOWNERSand control repository settings, protected environments, and administrative tokens.
The goal is to prevent a Write contributor from reading administrative or
publishing credentials (FORGE_ADMIN_TOKEN, PYPI_TOKEN, or OIDC
publishing tokens), both from an unmerged branch and through code merged
into packages/*/.
Three-tier secret exposure model¶
Every CI credential falls into one of three tiers. fm security.check
prints this classification for the active repository.
| Tier | Credentials | Scope | Runtime | Exposure |
|---|---|---|---|---|
| Tier 1 | FORGE_ADMIN_TOKEN, PYPI_TOKEN / OIDC, artifact-only publish jobs |
Protected branches only (govern, pypi, or protected: true variables) |
Isolated python3 -I (no setup.sh, no packages/*/, no tasks.py, no .repo.env) |
Protected from unmerged PRs and from merged packages/*/ code |
| Tier 2 | FORGE_TOKEN (nightly), extension jobs that enter the workspace on main |
Protected branches only (bot, or protected: true variables) |
Normal workspace environment (setup.sh + fm ci.run) |
Protected from unmerged PRs; readable by any contributor who can merge into packages/*/ |
| Tier 3 | Any secret in a pull_request job, or any repository-level secret on GitHub |
Unscoped | Pull request or any branch | Exfiltrable without merging; disallowed and flagged as a failure by fm security.check |
Tier 2 has an explicit boundary. Any job that runs setup.sh or imports
workspace code can execute code from any package in packages/*/.
Scoping a credential to main stops unmerged pull requests from reading
it, not code that has already merged into a package. Any contributor who
can merge package code can exfiltrate Tier 2 secrets. Only Tier 1 jobs
withhold workspace code from the process that holds the credential.
Privilege boundary¶
A single list (privileged_paths in livery.workshop._governance) names
every path guarded by root [owners]:
/workshop.tomland the forge'sCODEOWNERSfile (/.github/CODEOWNERS,/.gitea/CODEOWNERS, or/.gitlab/CODEOWNERS)/.github/workflows/,/.gitea/workflows/,/.gitlab-ci.yml,/.gitlab//setup.sh,/tasks.py,/pyproject.toml,/uv.lock,/toolroom.lock,/records/,/.repo.env- When the workspace builds
livery-workshopitself,livery-workshopand every workspace member it transitively depends on
Why per-package workshop.toml files stay outside root CODEOWNERS¶
Leaving packages/*/workshop.toml outside root CODEOWNERS lets package
owners make routine package edits without root review. Three guards close
the indirect paths:
- Drift check. Changing a package's extensions, dependencies, name,
or CI points changes guarded root files (
pyproject.toml,uv.lock,toolroom.lock, or workflows), sofm drift.checkfails until those guarded files are updated under root review. - Approval header.
CODEOWNERSrenders# approvals: <max>on all three forges. Lowering or raising[owners] approvalsin any package'sworkshop.tomlchangesCODEOWNERS, which requires root review. - Rule ordering. Package rules render before root governance rules on
GitHub and Gitea (last-match-wins), so a package entry can never shadow
a guarded path beneath
packages/. On GitLab, root governance rules render in a dedicated additive[governance]section (with[governance][N]whenapprovals >= 2), which requires approval independently of package sections.
Stale review dismissal¶
Whenever approvals >= 1, fm workflow.configure enables stale approval
dismissal on the default branch (dismiss_stale_reviews on GitHub,
dismiss_stale_approvals on Gitea, and reset_approvals_on_push on
licensed GitLab instances). Pushing a new commit after a reviewer approves
invalidates the prior approval and requires re-review before merge.
Non-secret .repo.env wiring in CI¶
Committed .repo.env files hold non-secret defaults and variable names
(personal values stay local in .repo.env.local and .repo.shared.env).
Generated CI workflows wire keys declared in root .repo.env from
non-secret Actions variables (RUNG_<KEY>: ${{ vars.<KEY> }}), never from
secrets.*. Adding a key name to .repo.env cannot pull a CI secret into
a pull request job. Tier 1 isolated jobs do not read .repo.env at all.
Tier 1 isolation¶
Isolated govern¶
The govern job on main does not run setup.sh, does not install
workspace members from packages/*/, does not load tasks.py, and does
not fold .repo.env. Instead, a small stdlib python3 -I bootstrapper
reads uv.lock with tomllib and runs:
uv run --isolated --no-project --with livery-workshop==<version> -- \
python3 -I -m livery.workshop._govern_entry --if-changed
The entry reads workshop.toml, packages/*/workshop.toml, and
CODEOWNERS strictly as data and reconciles repository settings through
livery.forge. In CI it refuses to fall back to FORGE_TOKEN when
FORGE_ADMIN_TOKEN is absent.
Split release build and isolated publish¶
The release workflow separates building distributions from uploading them:
- Ref ancestry check. Both
buildandpublishverifygit merge-base --is-ancestoragainst the default branch before entering the workspace or reading credentials. Dispatchingrelease.ymlwith an unmerged branch commit fails immediately. - Unprivileged
build(and platformwheels). Thebuildjob runs with no publishing credentials, noenvironment:, and noid-token: write. It enters the workspace, builds release distributions, records each file's SHA-256 digest inpackages/.release-dists.json, and uploads them as the short-liveddistsartifact (1-day retention), alongside any platform wheel artifacts. - Isolated
publish. Thepublishjob runs in the protectedpypienvironment withPYPI_TOKEN/ OIDC and downloadsdists(andwheelswhen present). Without runningsetup.sh, loadingtasks.py, or installing workspace members, it launches pinnedlivery-workshopunderpython3 -I -m livery.workshop._publish_entry, verifies every SHA-256 digest againstpackages/.release-dists.jsonand the dispatched ref, uploads distributions withuv publish, waits until the index serves each version, and cuts receipt tags.
Future publishing destinations (static sites, SSH targets, registries, and other package indices) follow the same split: build artifacts in an unprivileged job, pass them as a short-lived artifact with digests, and upload from an isolated job.
Consumer repositories and self-hosting¶
Consumer repositories depend on livery-workshop as a versioned package
in uv.lock. Their Tier 1 jobs install only that pinned release from the
locked index and never install any package under packages/*/.
A self-hosting workspace that builds livery-workshop as an editable
member (such as livery itself) uses the same mechanism: the isolated
bootstrapper installs only livery-workshop and its transitive editable
dependencies from uv.lock, and privileged_paths guards every member of
that closure under root [owners] in CODEOWNERS. Non-closure packages
under packages/*/ are never installed in Tier 1 jobs.
Forge matrix¶
| Protection | GitHub | GitLab Premium/Ultimate | GitLab Free/CE | Gitea |
|---|---|---|---|---|
| Branch-scoped secrets | Environments (govern, bot, pypi) with protected_branches_only |
protected: true CI variables |
protected: true CI variables |
Unsupported (no branch-scoped Actions secrets) |
CODEOWNERS enforcement |
Enforced on main (last-match-wins) |
Enforced on main ([governance] section) |
Advisory only (licence-gated) | Enforced via official reviewers (last-match-wins) |
| Stale approval dismissal | dismiss_stale_reviews |
reset_approvals_on_push |
Advisory only (licence-gated) | dismiss_stale_approvals |
Tier 1 isolated govern and publish |
Yes | Yes | Yes | Yes |
| Operational fallback | None required once configured | None required once configured | Restrict merge on main to Maintainers only |
Require fork-only contributions, or keep FORGE_ADMIN_TOKEN off CI and run fm workflow.configure from a maintainer's desk |
Default GitHub environment names are govern, bot, and pypi. Override
them under [ci.environments] in workshop.toml:
Quickstart¶
- Declare root owners and at least one required approval in
workshop.toml:
Setting approvals = 0 keeps a solo-maintainer repository usable without
deadlocking self-approval; fm security.check reports it explicitly as
solo/unprotected mode.
- Regenerate
CODEOWNERSand workflows:
- Assert branch protection, stale review dismissal, and protected environments on the forge:
- Place each CI credential directly in its protected scope (never at repository scope on GitHub):
fm workflow.secret.set FORGE_ADMIN_TOKEN
fm workflow.secret.set FORGE_TOKEN
fm workflow.secret.set PYPI_TOKEN
- Verify both local files and live forge settings: