Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OPERATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ repo-config/configure.sh apply owner/repo release|operational

`check` is read-only and exits non-zero on drift. `apply` is idempotent and drives entirely from the committed payloads, so it is a no-op on a conformant repo. `check` also asserts one group `apply` never writes, the existence and deployment-branch policy of every environment the registry's `environments` declares for the repo. So the two are not exact inverses. [docs/repo-config.md](./docs/repo-config.md) "Deployment Environments" says why.

Both modes need admin on the repository and project access on the token. The project access is needed because the fleet project link is read and written through GraphQL. A token that cannot read projects stops `apply` in its pre-flight with nothing written, naming the scope to grant, and reads as a failing project group under `check`. A token that can read them but not write one reaches the link write itself and fails there.
Both modes need admin on the repository and project access on the token. The project access is needed because the fleet project link is read and written through GraphQL. A token that cannot read projects stops `apply` in its pre-flight with nothing written, naming the scope to grant. Under `check` such a token reads as a failing project group. A token that can read them but not write one reaches the link write itself and fails there.

`apply` is not a narrow toggle. One run patches every key in `repo-config/settings.json`, sets the default branch, and enables both Dependabot features. That run also creates or updates every label in `repo-config/labels.json`. It creates or updates both branch rulesets too, and links the repository to the fleet project `repo-config/project.json` declares. On a repository that has deliberately drifted it silently reasserts the fleet configuration.

Expand Down
2 changes: 1 addition & 1 deletion STANDUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ python3 scripts/host_gate.py --repo "<path-to-target-checkout>" # after sectio

A finding at either point is a **host** misconfiguration to fix on the machine or surface to the maintainer, never something to patch per repo. [`docs/host-setup.md`][host-setup] is the contract it checks.

The scratch commit exercises the whole signing pipeline rather than one delivery path. That is because `ssh-add -L` or `gpg --list-secret-keys` only prove an agent holds a key. They say nothing about a host that signs straight from a key file with no agent running at all. That is a live and correctly configured case [git-commit-conventions][git-commit-conventions] documents in "Signing, verified not configured", the same rules [GOVERNANCE.md "Git and Commit Rules"][governance-git-and-commit-rules] points to. Signing is **SSH or GPG**, so this judges the configured format by its actual result, never by which delivery path produced it. A passing result is `sig=G`, or `sig=U` for a cryptographically good signature from an unrecognized signer. That signer is either a GPG key whose trust is merely undefined or an SSH key missing from the local `allowed_signers` file. A missing `--global` value, `sig` not reading `G` or `U`, or either printed email not matching the noreply address is a **host** misconfiguration to surface to the maintainer ([`docs/host-setup.md`][host-setup] is the setup procedure), not something to patch per repo. Patching it locally hides a broken host that then produces wrong identities in every other repo on that machine.
The scratch commit exercises the whole signing pipeline rather than one delivery path. That is because `ssh-add -L` or `gpg --list-secret-keys` only prove an agent holds a key. They say nothing about a host that signs straight from a key file with no agent running at all. That is a live and correctly configured case [git-commit-conventions][git-commit-conventions] documents in "Signing, verified not configured", the same rules [GOVERNANCE.md "Git and Commit Rules"][governance-git-and-commit-rules] points to. Signing is **SSH or GPG**, so this judges the configured format by its actual result, never by which delivery path produced it. A passing result is `sig=G`, or `sig=U` for a cryptographically good signature from an unrecognized signer. That signer is either a GPG key whose trust is merely undefined or an SSH key missing from the local `allowed_signers` file. A missing `--global` value, `sig` not reading `G` or `U`, or either printed email not matching the noreply address is a **host** misconfiguration. Surface it to the maintainer rather than patching it per repo. Patching it locally hides a broken host that then produces wrong identities in every other repo on that machine. [`docs/host-setup.md`][host-setup] is the setup procedure.

After `git init` and before the first commit, confirm the repo added no override of its own. This one needs a repository, since `--local` fails outside one. Read it here and run it in section 0B. That section places it between the init and the first commit, so nothing here is a prompt to init early:

Expand Down
16 changes: 8 additions & 8 deletions docs/repo-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ The hub holds all fleet-wide repository configuration:
- `project.json` declares the fleet project every repository is linked to, by owner, number, and title.
- `configure.sh` applies or checks those payloads through the GitHub API.

Downstream repositories carry no `repo-config/` directory. The registry's `workflowModel` selects the `develop` payload, and its `environments` declares the deployment environments the check mode asserts, both read from `registry/repos.json` rather than from a payload here. Commands that operate before registry enrollment pass the model explicitly.
Downstream repositories carry no `repo-config/` directory. The registry's `workflowModel` selects the `develop` payload, and its `environments` declares the deployment environments the check mode asserts. Both are read from `registry/repos.json` rather than from a payload here. Commands that operate before registry enrollment pass the model explicitly.

The carried `AUDIT.md` reaches the hub at `main` for its configuration check. The fleet-wide `spec/audit.py` reads the same hub payloads directly. Both paths compare live state against one source.

## Per-Repository Secrets

Downstream repositories carry no copy of `spec/secrets.json`. `baseline` applies to every fleet repo by definition, and `mechanisms`/`targetMechanisms`/`typeMechanisms` resolve from the registry entry (a repo's `publish[]` targets and `types[]`) rather than from anything repo-specific, so a per-repo copy could only restate the hub's own computation or drift from it between resyncs. `uv run --no-project --script spec/audit.py [RepoName]`, run from a hub checkout, resolves the required set the same way the mechanized `repo-setup` check does: `targetMechanisms`/`typeMechanisms` selects each applicable mechanism from the registry entry, `baseline` plus the selected `mechanisms` plus the registry entry's own `requiredSecrets[]` (the repo's domain-specific additions) gives the required and forbidden names, and the result is cross-checked against the repo's live Actions and Dependabot secret stores.
Downstream repositories carry no copy of `spec/secrets.json`. `baseline` applies to every fleet repo by definition. `mechanisms`/`targetMechanisms`/`typeMechanisms` resolve from the registry entry (a repo's `publish[]` targets and `types[]`) rather than from anything repo-specific. So a per-repo copy could only restate the hub's own computation or drift from it between resyncs. `uv run --no-project --script spec/audit.py [RepoName]`, run from a hub checkout, resolves the required set the same way the mechanized `repo-setup` check does. `targetMechanisms`/`typeMechanisms` selects each applicable mechanism from the registry entry. `baseline` plus the selected `mechanisms` plus the registry entry's own `requiredSecrets[]` (the repo's domain-specific additions) gives the required and forbidden names. The result is cross-checked against the repo's live Actions and Dependabot secret stores.

## Applying the Config

**Configure by importing the JSON payloads, never by hand-building the rules** (hand reconstruction has gone wrong on past setups). The result must be **exactly two rulesets named `develop` and `main`**, and the names are load-bearing (`AGENTS.md` and the workflows reference them). Only the `develop` *content* varies by model.

Remove all classic branch-protection rules and stray rulesets. Run `configure.sh apply` from a hub checkout at `main`, naming the target repository and its model. Both modes need project access on the token as well as admin on the repository, since the project link is read and written through GraphQL. A token that cannot read projects stops `apply` in its pre-flight with nothing written, naming the scope to grant, and reads as a failing project group under `check`. A token that can read them but not write one reaches the link write itself and fails there. The script applies `settings.json`, the Dependabot security features, the label set, both rulesets, and the link to the fleet project. The link is written only where it is absent, and the declared project title is compared with the live one first, since a project number is reusable and the same declared number is applied to every fleet repository. A registered repository can omit the model and use the registry lookup. A repository outside the registry passes the model explicitly:
Remove all classic branch-protection rules and stray rulesets. Run `configure.sh apply` from a hub checkout at `main`, naming the target repository and its model. Both modes need project access on the token as well as admin on the repository, since the project link is read and written through GraphQL. A token that cannot read projects stops `apply` in its pre-flight with nothing written, naming the scope to grant. Under `check` such a token reads as a failing project group. A token that can read them but not write one reaches the link write itself and fails there. The script applies `settings.json`, the Dependabot security features, the label set, both rulesets, and the link to the fleet project. The link is written only where it is absent. The declared project title is compared with the live one first. The comparison exists because a project number is reusable and the same declared number is applied to every fleet repository. A registered repository can omit the model and use the registry lookup. A repository outside the registry passes the model explicitly:

```sh
repo-config/configure.sh apply owner/repo release|operational
```

Then validate the result with `repo-config/configure.sh check owner/repo release|operational`, run from the same checkout, which asserts every applied ruleset, setting, label, security feature, and the fleet project link, plus the deployment environments described below, and exits non-zero on drift (the ruleset and settings checks are driven by the committed payloads, so they stay repo-agnostic). Or import each ruleset by hand with `gh api -X POST repos/<owner>/<repo>/rulesets --input repo-config/<name>.json` (operational repos use `operational/develop.json` for `develop`). `gh ruleset` is read-only, so creation goes through `gh api`. The required check binds by name and only turns green after the repo's PR workflow runs once. To edit a live ruleset, GET it, change the field, and PUT the whole writable subset back (a partial PUT `422`s).
Then validate the result with `repo-config/configure.sh check owner/repo release|operational`, run from the same checkout. The command asserts every applied ruleset, setting, label, security feature, and the fleet project link, plus the deployment environments described below. It exits non-zero on drift (the ruleset and settings checks are driven by the committed payloads, so they stay repo-agnostic). Or import each ruleset by hand with `gh api -X POST repos/<owner>/<repo>/rulesets --input repo-config/<name>.json` (operational repos use `operational/develop.json` for `develop`). `gh ruleset` is read-only, so creation goes through `gh api`. The required check binds by name and only turns green after the repo's PR workflow runs once. To edit a live ruleset, GET it, change the field, and PUT the whole writable subset back (a partial PUT `422`s).

## Deployment Environments

`check` asserts that every environment the registry entry's `environments` declares exists and carries the declared deployment-branch policy, and `apply` writes none. The asymmetry is deliberate. An environment's secrets and variables are credentials that exist nowhere in the hub, so an `apply` could create the environment and set its policy and still leave it unable to publish, while reporting success. Their names are enumerable through the API, and their values in the case of a variable, but no tool here queries those stores, which is a choice about what this script owns rather than a limit the API imposes. The policy is checkable on its own and worth checking, because it decides which refs may deploy at all, and on an OIDC publish that is half the gate: a ref the policy excludes mints no token.
`check` asserts that every environment the registry entry's `environments` declares exists and carries the declared deployment-branch policy, and `apply` writes none. The asymmetry is deliberate. An environment's secrets and variables are credentials that exist nowhere in the hub. So an `apply` could create the environment and set its policy and still leave it unable to publish, while reporting success. Their names are enumerable through the API, and their values in the case of a variable. But no tool here queries those stores. That is a choice about what this script owns rather than a limit the API imposes. The policy is checkable on its own and worth checking, because it decides which refs may deploy at all. On an OIDC publish that is half the gate: a ref the policy excludes mints no token.

Each entry names the environment and one of two `branchPolicy` forms. `custom` also declares `branches`, the exact set the environment allows, and the check compares the live set to it in both directions. Branches are the whole vocabulary a `custom` entry has: GitHub's custom policies admit a tag entry too, and one has no declaration here, so an environment allowing a tag under a `custom` policy reads as drift until this field grows a way to say so. `none` admits every ref and declares no branch set, so a repository whose gate lives in its deploy workflow instead records `none` and gets a policy appearing later read as a change rather than as the gate arriving.
Each entry names the environment and one of two `branchPolicy` forms. `custom` also declares `branches`, the exact set the environment allows, and the check compares the live set to it in both directions. Branches are the whole vocabulary a `custom` entry has. GitHub's custom policies admit a tag entry too, and one has no declaration here. So an environment allowing a tag under a `custom` policy reads as drift until this field grows a way to say so. `none` admits every ref and declares no branch set. So a repository whose gate lives in its deploy workflow instead records `none`. It then gets a policy appearing later read as a change rather than as the gate arriving.

GitHub offers a third form, protected branches only, and this field deliberately does not. It counts *classic* branch protection rules, which this document has already told you to remove in favor of rulesets, and no fleet repository has one. Declaring it would assert a gate that does not exist, and a live environment set to it fails the check as the drift it is.

```json
"environments": [{ "name": "pypi", "branchPolicy": "custom", "branches": ["develop", "main"] }]
```

A repository declaring no environment has nothing asserted against it, though the live list is still read and an unreadable one fails the run, and an environment the registry declares nothing about is reported rather than asserted, since GitHub creates some without being asked (the Copilot coding agent's is the one every fleet repository has). What no tool covers either way is whether an environment's secrets and variables are present and valid, so read a clean run as a statement about each declared environment existing and carrying the policy declared for it, and never as one about whether the deploy can succeed.
A repository declaring no environment has nothing asserted against it, though the live list is still read and an unreadable one fails the run. An environment the registry declares nothing about is reported rather than asserted. This is because GitHub creates some without being asked (the Copilot coding agent's is the one every fleet repository has). What no tool covers either way is whether an environment's secrets and variables are present and valid. So read a clean run as a statement about each declared environment existing and carrying the policy declared for it. Never read it as a statement about whether the deploy can succeed.

## Regenerating the Payloads

Expand Down Expand Up @@ -76,7 +76,7 @@ done

## Brownfield Migration (Maintainer Only)

`Require signed commits` rejects any pre-existing unsigned commit, so the first `develop -> main` release on a repo with unsigned history is blocked. Re-signing that history is a non-fast-forward that the `Block force pushes` rule rejects, **and the admin bypass does not cover `git push --force`**. Completing it requires temporarily disabling the ruleset and a maintainer force-push. This is a one-time, maintainer-performed migration that deliberately uses the force-push [GOVERNANCE.md "Git and Commit Rules"][governance-git-and-commit-rules] forbids agents from running. **An agent must never execute it, and must surface it to the maintainer instead.** Greenfield repos where signing is live before the first commit never hit this. When the rewrite touches commits committed under a bot or web-flow identity (`dependabot[bot]`, `github-actions[bot]`), set each commit's committer to the signing identity before re-signing so the committer GitHub verifies matches your key, rather than leaving your key over another identity's commit (see the history-rewrite rule in [GOVERNANCE.md "Git and Commit Rules"][governance-git-and-commit-rules]).
`Require signed commits` rejects any pre-existing unsigned commit, so the first `develop -> main` release on a repo with unsigned history is blocked. Re-signing that history is a non-fast-forward that the `Block force pushes` rule rejects, **and the admin bypass does not cover `git push --force`**. Completing it requires temporarily disabling the ruleset and a maintainer force-push. This is a one-time, maintainer-performed migration that deliberately uses the force-push [GOVERNANCE.md "Git and Commit Rules"][governance-git-and-commit-rules] forbids agents from running. **An agent must never execute it, and must surface it to the maintainer instead.** Greenfield repos where signing is live before the first commit never hit this. When the rewrite touches commits committed under a bot or web-flow identity (`dependabot[bot]`, `github-actions[bot]`), set each commit's committer to the signing identity before re-signing. That way the committer GitHub verifies matches your key, rather than leaving your key over another identity's commit. See the history-rewrite rule in [GOVERNANCE.md "Git and Commit Rules"][governance-git-and-commit-rules].

<!-- Repo -->

Expand Down
Loading
Loading