diff --git a/changelog.d/1751.md b/changelog.d/1751.md new file mode 100644 index 0000000000..88e691f40b --- /dev/null +++ b/changelog.d/1751.md @@ -0,0 +1,2 @@ +### Added +- ADR 0011 decides the release model: topic pull requests target `main`, `towncrier` assembles the changelog from typed fragments, `uv version` sets the version, one dispatched workflow opens the release pull request and merging it publishes and creates the tag last, and Argo CD follows the semver tags, in place of the `release/vX.Y.Z` branch, the hand-made cut and the bespoke cut, collector and compactor code. It measures v0.2.36 and v0.2.37 (75 and 107 minutes, release pull requests of 188 and 990 files), compares four options, decides the points that needed the owner and orders the nine steps that migrate to it ([ADR 0011](docs/adr/0011-releases-come-from-trunk-towncrier-uv-and-semver-tags-instead-of-a-bespoke-cut.md), [#1751](https://github.com/dan-petty/devops-cli/issues/1751)). diff --git a/docs/adr/0011-releases-come-from-trunk-towncrier-uv-and-semver-tags-instead-of-a-bespoke-cut.md b/docs/adr/0011-releases-come-from-trunk-towncrier-uv-and-semver-tags-instead-of-a-bespoke-cut.md new file mode 100644 index 0000000000..ee93b76442 --- /dev/null +++ b/docs/adr/0011-releases-come-from-trunk-towncrier-uv-and-semver-tags-instead-of-a-bespoke-cut.md @@ -0,0 +1,128 @@ +# Releases come from trunk, and towncrier, uv and semver tags replace the bespoke cut + +Releases used to run through a `release/vX.Y.Z` integration branch. Topic pull requests merged into it, a cut commit (version, changelog, roadmap) reached it through its own pull request, a release pull request carried the branch to `main`, and `release.yml` published on the push to `main`. [#1751](https://github.com/dan-petty/devops-cli/issues/1751) asked whether that model is right. Measured on v0.2.36 and v0.2.37 it costs two hand-made pull requests and 75 to 107 minutes from the cut pull request's creation to the end of the publish run, and the release pull request held 188 and 990 files, more than a person can review as a diff. The release path is 3,190 lines of source, 4,446 lines of dedicated tests, 403 lines of workflow and a share of the 540 lines of pull request readiness rules. The 20 files this decision deletes or replaces whole hold 9,085 lines today and have taken 44 commits that added 12,561 lines and deleted 3,476 since the first release on 2026-08-17. A title search on 2026-10-22 finds 94 issues and 138 merged pull requests that name a release, changelog, cut or fragment; 97 of those pull requests carry the scope `release`, and 49 of them are fix, chore, refactor or docs pull requests that tend the release path, not releases. Eight of the nine defect clusters below exist because the project built its own branch topology, closer, changelog collector, notes compactor, cut and tag logic where an open tool or a GitHub feature does the job. This decision replaces them. The project does not defend its bespoke design, and no option below is judged by what it would cost to rewrite that code: where an open tool needs a convention, a checker or a test of this repository to change, those change. + +Pull requests target `main`. A workflow that a person dispatches opens one release pull request from `chore/release-vX.Y.Z`, built by `uv version` and `towncrier build`. Merging that pull request runs a second workflow that builds and attests the images, publishes the release and creates the tag as its last write. Argo CD follows the semver tags for manifests, and Argo CD Image Updater keeps rolling the image digest. Nothing in this decision depends on OpenSpec (#1753), which a separate decision may add to the prepare workflow at one named point. + +- **Branches and cuts (#1751 question 1).** Topic pull requests, item or otherwise, target `main`, and `Closes #N` closes the issue when they merge, as GitHub does for any pull request into the default branch. There are no `release/*` branches, no cut and no cut pull request. A release is the merge of one pull request, `chore/release-vX.Y.Z` into `main` titled `feat(release): vX.Y.Z`, opened by a workflow. Its merge triggers the publish workflow, and the tag is that workflow's last write. +- **Versions and changelog (question 2).** The version is the title of the milestone ([ADR 0001](0001-github-is-the-roadmap-source.md)), passed explicitly to `uv version X.Y.Z --no-sync`. No tool derives a version or notes from commit or pull request titles: git-cliff, commitizen and python-semantic-release each proposed 0.3.0 for a 0.2.N series when run on this history, and the notes would depend on the repository's `squash_merge_commit_title` setting. The changelog is `changelog.d/..md` fragments, one category per file, which `towncrier build` assembles once into `CHANGELOG.md` and deletes in the same commit. The GitHub Release body is the release pull request body, which is the `towncrier build --draft` output. +- **Milestones (question 3).** A milestone is the plan and the version authority. A person dispatches the prepare workflow when its milestone holds no open issue, and the publish workflow closes the milestone. While a milestone is the lowest open one, only its items may merge into `main`; the scope rule that held on a release branch holds on trunk. +- **The tip (question 4).** `ci.yml` already runs on every push to `main`, which on trunk is the release tip. The release pull request runs the whole suite, the image build as a dry run, `uv build` and a release gate. The `main` ruleset already has the strict policy and no required check yet; once it lists the checks, the merged tree is the tested tree. A merge queue is not relied on. +- **Effort (question 5).** Measured below on two releases. The new flow is three actions by a person: confirm the milestone is empty, dispatch the workflow, merge the pull request. +- **Deploy path.** The service image is built once as a reusable workflow that CI runs read-only and the release runs with publish scopes, pushed by digest, attested and tagged before the release exists. Argo CD applications read manifests from the highest semver tag at or above `0.2.0`, and Image Updater keeps rolling the digest of `service:latest`, which moves only at publish. GitHub Pages stays as it is. + +## Evidence + +- **Cost of two releases.** v0.2.36: 25 pull requests merged into `release/v0.2.36`, the hand-made cut pull request #1614 (28 files) was open 56 minutes, the release pull request #1615 (188 files, 25 commits, +12,791/-2,949) 62 minutes, and the publish run took 12.4 minutes, so 75 minutes passed from the cut pull request's creation to the end of the run. v0.2.37: 54 pull requests, cut #1719 (39 files) open 85 minutes, release pull request #1720 (990 files, 54 commits, +31,843/-18,003) 89 minutes, publish run 14.7 minutes, 107 minutes in all. Its release pull request ran item-only checks for over 20 minutes until #1721 and #1723 scoped them, and its cut was made by hand because the Argo CD report's tokens expired during the close. Every cut since v0.2.36 has been a hand-made pull request (#1614, #1719, #1798) because the roadmap Service is suspended (#1562). v0.2.38 was merged twice, its release pull request as #1799 (582 files) and its cut, retargeted at `main`, as #1798 (549 files), 27 seconds apart. The push run of #1799 was cancelled and that of #1798 took 26 minutes. +- **Publish runs.** Of 99 `release.yml` runs between 2026-08-17 and 2026-10-21, 79 succeeded, 16 failed and 4 were cancelled. 61 ran for a push to `main`, and 16 of those 61 were merges that were not releases, because the workflow runs on every push to `main`. Releases came 15 times between 2026-10-01 and 2026-10-21 (v0.2.24 to v0.2.38). +- **Scale.** `main` holds 60 commits, 45 of them `feat(release): vX.Y.Z` squashes, against 855 merged pull requests, because a release branch is squashed as one commit. Tokens spent on the release path cannot be measured from the repository, the issues or the runs, so none is claimed; the lines, pull requests and minutes stand in for them. +- **Cluster 1, integration-branch topology.** GitHub closes issues only for pull requests into the default branch, so the project wrote `roadmap/close.py` (618 lines plus 85 in `request_plan.py`, 55 in `run.py` and 74 in `commands/roadmap.py`) to close items and comment. It needed sync pull requests (#1258, #1259), closure fixes after the milestone closed or an item reopened (#1362, #1414, #1417), generated-notes workarounds (#332, #383, #393, #394), readiness rules for the `chore/open` and `chore/cut` pull request kinds (#1344), and a retargeted cut that merged beside its release pull request, with fragments left for a follow-up (#1798, #1799, #1802). Trunk removes the cause: items are already on `main`, so the release pull request is its version bump, the changelog and one deleted fragment per entry (about 20 files, 18 in a scratch run of the drafted steps) instead of 582 or 990, `Closes #N` closes natively, and `close.py` has no input. +- **Cluster 2, changelog authoring.** Every pull request used to edit `CHANGELOG.md`, which conflicted three times in one hour in v0.2.25 (#933). Fragments plus a home-grown collector fixed that and created two writers, cut and merge ordering hazards and late fragments (#863, #1450, #1792, #1802, #1099, #1102, #1293, #1340, #1355, #1105). `towncrier` is the one tool that reads fragments and writes the changelog, and the prepare workflow is its only caller, so there is one writer; a late fix means running prepare again, which rebuilds the pull request from current `main`. A fragment added after the first scratch run was collected by the second with no edit. +- **Cluster 3, release-notes size.** v0.2.25's section is 199,004 characters against limits of 125,000 (Release) and 65,536 (pull request body); it is the only one of 53 released sections over the pull request limit, and no later section is longer than 38,140 (v0.2.29). Notes are the same `towncrier` output as the changelog section, with one size test in prepare that replaces an oversize body by a link before any merge (#1097, #1105, #140). +- **Cluster 4, release pull request body and epics.** The body was generated once at the cut from a `gh` query and fell out of date after every post-cut fix (#1020, #1346), and 15 Release Epic issues were kept in step by code that was later deleted (#928). The body is now the `towncrier` draft regenerated by every prepare run, and the milestone page is the progress view. +- **Cluster 5, the cut pushing to protected branches.** The cut pushed to `release/*` under a ruleset bypass or a local credential helper and was refused with GH013 (#1280, #1124, #1397, #1628, #1544, #1638, #1343). The App opens a pull request from a branch that neither ruleset matches. +- **Cluster 6, service image tag and order.** Argo CD rolled a pod onto an image that did not exist yet (#1451, #1260, #1486), and Image Updater already fixed the pin (#1485, #1486). What remains is the order of the tag, the image and the cluster, which the publish workflow fixes by making the tag its last write. +- **Cluster 7, tag and publish semantics.** An existing tag was tolerated until #1805, when v0.2.37's assets were rebuilt from v0.2.38's code. The publish workflow runs only for a merged `chore/release-vX.Y.Z` pull request and writes nothing public before every image is attested. +- **Cluster 8, a green pull request does not mean publishable.** Eight of 45 release-merge runs failed and two were cancelled (#1425, #1651, #1544, #1721, #1723, #842). The release pull request runs the same image workflow as the publish, the same `uv build` and the same release gate. +- **Cluster 9, the admission engine** (`roadmap/reprioritize.py`, 3,316 lines) is project policy, not release mechanics, and no open release tool plans scope. It stays. +- **Why not the commit titles.** The 52 entries of v0.2.38 have a median length of 270 characters as fragments; the titles of the 52 pull requests merged into `release/v0.2.38` have a median of 82. +- **Settings read on 2026-10-22.** The repository is owned by a user account. Its two rulesets are `main` (strict required-status-checks policy, empty list of required checks, no bypass actor) and `release` (matches `release*/**/*`, one user as bypass actor); there is no tag ruleset. GitHub Pages builds legacy from `main:/docs`. The repository setting for immutable releases exists and the REST endpoint answers `enabled: false`. All 44 tags are `vN.N.N`. +- **Tools run or read.** Run on the repository or in scratch: uv 0.12.23, towncrier 26.9.0, git-cliff 2.14.2, commitizen 4.19.2, python-semantic-release 10.7.0, hatch-vcs 0.5.0, OpenSpec 1.14.3, conftest 0.71.1, actionlint 1.7.12, zizmor 1.30.1, dorny/paths-filter v4.0.3. `uv version 0.2.40 --no-sync` run on a copy of this tree under uv 0.12.23 changed one line of `pyproject.toml` and one of `uv.lock`; under uv 0.12.16 it also rewrote the lock's `revision` from 5 to 3, and the two pins differ today (`.github/actions/setup-toolchain/action.yml` pins 0.12.16, the `Dockerfile` 0.12.23). Read from source and documentation but not run: release-please 17.11.2, peter-evans/create-pull-request v8.1.1, actions/create-github-app-token v3.3.0, softprops/action-gh-release v3, Argo CD's tag resolution (`util/versions/tags.go`), GitHub's ruleset documentation. + +## Design + +- **Item pull requests.** Target `main`, say `Closes #N` or `Part of #N`, and add a fragment `changelog.d/..md` with `type` one of `added`, `changed`, `deprecated`, `removed`, `fixed`, `security`. A second entry of a type is `...md`. The file holds the entry text only: no heading, no `- `, and no trailing issue link, which `towncrier` appends from `issue_format`. `towncrier.toml` defines the six types and `CHANGELOG.md` holds the start marker in place of `## [Unreleased]`. `towncrier==26.9.0` is in a `release` dependency group with hashes in `uv.lock`, run as `uv run --only-group release --frozen towncrier`. `ci.yml` runs `towncrier build --draft` on every pull request, so a fragment that does not parse fails there, and `devops pr check-readiness` keeps the policy that an item pull request edits neither `CHANGELOG.md` nor the version. +- **Trunk scope rule.** `devops pr check-readiness` requires a pull request into the default branch to close, or deliver part of, an item whose milestone is the current release, the lowest open `vX.Y.Z` milestone. This is the rule that held for a pull request into `release/vX.Y.Z`, retargeted. Without it nothing keeps an item of the next milestone out of `main` while the release pull request is open, and `towncrier` would sweep its fragment into the wrong release. +- **Prepare.** `prepare-release.yml` is a `workflow_dispatch` with the version as its input and runs in the `release` environment, which holds `RELEASE_APP_CLIENT_ID` and `RELEASE_APP_PRIVATE_KEY`. It mints an App token (`actions/create-github-app-token`, contents, pull requests and issues write), checks out `main`, and runs the release gate, a local composite action that requires the milestone `vX.Y.Z` to exist and hold no open issue (pull requests excluded, since the release pull request carries the milestone), the tag `vX.Y.Z` to be absent, at least one fragment to exist, and every fragment to name an issue of that milestone. Then `uv version`, `towncrier build --draft` into the runner's temporary directory, `towncrier build --yes`, a size test that replaces notes over 65,000 bytes by an absolute link to `CHANGELOG.md` on `main`, and `peter-evans/create-pull-request` with no `add-paths`, so it stages the working tree, with `sign-commits`, branch `chore/release-vX.Y.Z`, the `release` label and the milestone. Running it again updates the same branch and pull request from current `main`. +- **Release pull request checks.** The App token makes the pull request trigger `ci.yml`. A `Release Gate` job runs the same composite action on pull requests whose head begins `chore/release-v` and is skipped otherwise, which counts as passing. The image workflow runs as a dry run on the release pull request and, for item pull requests, only when a file that defines how the image is built or what it installs changes. `uv build` and a check that `changelog.d` holds only its README run on the release pull request. `devops pr check-readiness` recognises the release pull request by the same predicate the roadmap store uses, the default branch as base plus the `release` label and a milestone (`is_release_pull_request`), and holds its diff to `pyproject.toml`, `uv.lock`, `CHANGELOG.md` and `changelog.d`. +- **Images.** Two reusable workflows, because GitHub lets a called workflow only reduce the permissions its caller grants, and a called workflow requesting more than the caller grants is refused at startup. `image.yml` builds, smoke-tests and scans with `contents: read` and nothing else, and CI calls it. `image-publish.yml` pushes by digest, attests, then tags with `docker buildx imagetools create`, and only the release calls it. The smoke test's read-only, tmpfs, dropped-capability and health probes move verbatim from the two workflows that hold them today. Labels come from `docker/metadata-action`, and `devops devcontainer validate --oci-labels` is deleted: it compares labels the action just emitted from `github.repository` with a constant naming the canonical repository, and it fails on any copy of the repository. +- **Publish.** `release.yml` runs on `pull_request: closed` for `main` with `permissions: {}`, and its gate job runs only for a merged pull request from this repository whose head begins `chore/release-v`. The workflow definition is the one on `main`, so a pull request cannot change the workflow that publishes it. The gate checks out `merge_commit_sha`, reads `uv version --short --no-sync`, requires the head to be `chore/release-v` plus that version, requires no fragment and no open issue in the milestone, and reads the tag: absent means publish, present on this commit with a published release means skip to the milestone close, present elsewhere stops and names both commits (#1805). The images are built and published next. The publish job, in the `release` environment, then runs `uv build`, writes `SHA256SUMS.txt`, and runs `softprops/action-gh-release` with the App token, `draft: false`, `target_commitish` set to the merge commit, `body_path` set to the pull request body, `overwrite_files: false` and `fail_on_unmatched_files: true`. The tag is created by that publication, so nothing public exists before every image is attested. A separate `close-milestone` job runs `gh api -X PATCH` on the milestone, which is idempotent, so "Re-run failed jobs" finishes a run that failed there, and "Re-run all jobs" after the tag exists skips straight to it. +- **Tags are production.** A tag that matches the Argo CD constraint deploys, so tags are protected: a tag ruleset on `refs/tags/v*` restricts creation, update and deletion to the release App, which holds the bypass. GitHub's ruleset documentation lists GitHub Apps among bypass actors and says that with creations restricted only actors with bypass can create tags matching the pattern. +- **Deploy.** `targetRevision: ">=0.2.0"` on the 28 git sources in 27 files under `k8s/argocd`; chart-version sources keep theirs. Argo CD resolves the highest semver tag and skips tags that are not semver, and all 44 existing tags are `vN.N.N`. `argocd_overrides.render_at_revision` reads the resolved revision from the Application when `targetRevision` is a constraint. The image and the manifests follow two independent pins, so a rollback is two actions. +- **Settings.** The `main` ruleset requires the status checks of [ADR 0004](0004-ci-is-the-authoritative-gate.md) plus `Release Gate`, with the strict policy it already has, and the `release` ruleset and the remaining `release/*` branches are removed. These are person-run. +- **Hotfix and late critical fix.** A critical fix is filed into the current milestone by intake as before, so the milestone is not empty until it merges. After a release, a hotfix is the next patch: its milestone must be empty, so the open items of the next milestone move to the one after, and then dispatch and merge are the same two actions. +- **Failure and recovery.** A failure before the tag leaves a draft or nothing; the gate refuses a tag on another commit, and `softprops/action-gh-release` finds an existing release by its tag and updates it, so a re-run reuses its own unpublished draft. A merge after prepare, while required checks are set, makes the release pull request stale and the `Release Gate` fails on the updated branch; dispatching prepare again rebuilds it. If a gate fails after the merge, closing what it names and re-running the workflow publishes. + +## Cutover and Sequence + +The last release made by the old pipeline is v0.2.39, published from `release/v0.2.39`; its cut collects every old-format fragment, so `changelog.d` holds only its README at that point, and no `release/v0.2.40` is opened. No step below merges before v0.2.39 is published. Each step is one item, filed through `devops roadmap intake` after this decision merges, delivered by one pull request into `main` that keeps `devops ci` passing; the two that only a person can do are marked. No pull request carries both systems, and at no point can both produce a release. + +1. `ci(image): one reusable workflow builds the service and devcontainer images, and the pull request build holds no write scope` adds `image.yml`, which builds, smoke-tests and scans the service image with `contents: read`, replaces the service-image job body in `ci.yml` by a call to it behind one `dorny/paths-filter` job (a caller job that uses a workflow has no steps, so the hand-written changed-path detection becomes a job), and stops the pull request devcontainer build from pushing, which deletes its open-state check, its write scope and `cleanup-devcontainer.yml`. +2. `feat(release): fragments are typed and towncrier assembles the changelog` adds `towncrier.toml`, the `release` dependency group, the typed names, the `ci.yml` draft build, the readiness rule, the `uv` pin parity test, and converts the fragments written since v0.2.39. +3. `feat(release): one workflow opens the release pull request` adds `prepare-release.yml`, the release gate action and the `Release Gate` job. +4. `ci(k8s): the Argo CD build gate runs in devops ci on every change to k8s` moves `check_argocd_gate` into `devops ci`. +5. `feat(release): topic pull requests target main, and merging the release pull request publishes` adds `image-publish.yml` and the new `release.yml`, replaces the old one, moves `ci.yml`, `fail-to-pass.yml` and `codeql.yml` to `main`, scopes the jobs that keyed on `github.base_ref`, makes readiness trunk-shaped (the trunk scope rule, the release pull request predicate and file allowlist, the cut and open pull request kinds removed) and retargets the Copilot pass commands, and rewrites the documents that name branch targets. From its merge a push to `main` publishes nothing. +6. `feat(k8s): Argo CD follows release tags` sets the constraint and updates `tests/test_k8s_argocd_apps.py`. +7. `refactor(release): delete the bespoke release machinery` removes the code, tests, documents and strings in the Consequences list. +8. `chore(settings): the release App, environment and rulesets are in place`, person-run: the App and `release` environment before the first dispatch, the tag ruleset before step 6 merges, required checks before the first dispatch, and the old ruleset and branches after step 7. +9. `chore(release): v0.2.40 is the first release made by the new pipeline`, person-run: the dispatch, the merge, the cluster flip, and the measured cost of the release beside v0.2.36 and v0.2.37. + +The order is a dependency order. Step 5 needs steps 1 to 3, so the new publisher exists when the old one goes. Step 7 needs step 4, because the cut was the gate's only caller (`release/cut.py` is the only caller of `check_argocd_gate`), and must merge before the first dispatch, so the first release is built on a tree without the old system. Step 6 needs the tag ruleset. The parent applications `bootstrap` and `cluster` read their own definitions from the revision they track, so they stay on `main` until a tag contains the constraint, set to sync policy none before step 6 merges and to `>=0.2.0` with `argocd app diff` first once v0.2.40 exists, when `main` equals the tag and the change is empty. Between steps 5 and 9 nothing publishes; the window is days, because v0.2.40 is not due until its milestone empties. Step 5 merges only after a rehearsal in a throwaway copy of the repository, which checks four premises no document settles: that `merge_commit_sha` and the milestone number are in the `pull_request: closed` payload of a squash merge, that a pull request opened with the App token triggers `ci.yml`, that `softprops/action-gh-release` with `draft: false` uploads assets before the tag exists, and that a called workflow requesting more than its caller grants is refused. The rehearsal also confirms that `uv version`, run under the pin `setup-toolchain` installs, changes `uv.lock` only in its version lines. + +## What Stays Custom + +Each piece below names the open tool considered and why it does not cover the capability. The cost of what this decision builds is small beside the cost of what it deletes: about 55 lines of Python, about 40 of shell and about 470 of workflow, estimated from the design and not yet written, against about 9,900 lines deleted and the history in the Evidence section. The tokens to build, maintain and fix each piece are not recorded anywhere this repository can read. + +- **Item admission, caps, slots and critical-fix placement** (`roadmap/reprioritize.py`, `store.py`). Considered: GitHub milestones and Projects as storage only; release-please, towncrier, git-cliff and python-semantic-release do not plan scope. It is project policy (a cap, slots, P0/P1 placement). It loses only its release-branch writes (`_branch_writes`, `store.create_branch`, `release_cut_branch`, about 20 lines). Its `CUT`, `MERGED` and `SHIPPED` states keep working because the release pull request matches `is_release_pull_request` (base, `release` label, milestone). +- **Pull request readiness** (`commands/pr.py`). Considered: required checks, the pull request template, `towncrier check --compare-with`. Issue grounding, `Part of #N`, the rule that an item pull request edits neither `CHANGELOG.md` nor the version, the trunk scope rule and the release pull request's file allowlist are repository policy no generic check knows. About 270 of the 540 lines of release-process and grounding rules (`pr.py:1464-2003`) go. Fragment presence stays advisory. +- **The release gate** (one composite action, about 40 lines of shell, used by prepare, the pull request check and the publish gate). Considered: a ruleset or required check cannot see milestones, and no release tool treats a milestone as the version authority. It is new and small, and it is the one place the three callers share. +- **The Argo CD build gate and host overrides** (`k8s/argocd_gate.py` 316 lines, `argocd_overrides.py` 173). Considered: `kustomize build` with kubeconform, `argocd app diff --local`, and conftest (a 20-line Rego rule enforced the placeholder-domain rule in scratch). The rule is this repository's policy and `argocd_overrides._host_fields` is shared with `deploy-stack`, so a Rego copy would duplicate it; moving the check to Rego is left as a follow-up, not made part of the release model. The gate's only caller was the cut, so it moves into `devops ci` and runs on every change to `k8s/**`, where it catches a broken application earlier. `argocd_live_report.py` loses its only caller and is deleted, and the `ArgoCdApplicationOutOfSync` alert covers drift. +- **Roadmap Service jobs** (intake, refine, reprioritize, render; suspended, #1562). Considered: Projects built-in workflows cover status and display only. Releases no longer depend on them, so the suspension stops blocking the release path. Whether an App token can read a user-owned Projects v2 board is not settled; GitHub's documentation says `GITHUB_TOKEN` cannot, which is why the release path does not render the roadmap. +- **Copilot pass commands** (`github/copilot_budget.py` 216, `review_thread_issues.py` 377). Considered: delete them. They stay, retargeted from "the release pull request" to any open pull request into the default branch, because the passes are a review control and not a release mechanism. Pull requests get a pass only when a person requests one, as the release pull request did. +- **The service image smoke test** (YAML in `image.yml`). Considered: `container-structure-test`, which was not run. The probes are repository-specific and move verbatim. + +## Decisions Taken + +Each point below needed the owner. Each is decided here, confirmed by merging this ADR and reversible by a later ADR. + +1. **Fragments stay, typed and assembled by `towncrier`.** The entry is written by its author with the change and reviewed in the same pull request, so it can say what changed, and it does not move when the repository's squash title setting does. release-please is the smaller option only if this rule is dropped, and only a later ADR drops it. +2. **A person dispatches prepare.** An `issues: closed` trigger that dispatches prepare when a milestone empties is about 12 lines (the trigger plus the gate) and is not built. Fifteen releases came in the three weeks to 2026-10-21, and a dispatch is one click beside the 75 to 107 minutes a release costs today. +3. **One release App, for this repository only.** It is installed with contents, pull requests and issues write, and its credentials live in the `release` environment as `RELEASE_APP_CLIENT_ID` and `RELEASE_APP_PRIVATE_KEY`. It is separate from the roadmap Service's identity (ADR 0002, #1562, #1647), so the release path waits for neither. +4. **Tags are protected by a tag ruleset on `refs/tags/v*`** that restricts creation, update and deletion, with the App as bypass actor. If this user-owned repository does not accept an App as a bypass actor, only update and deletion are restricted, the setting item records that any writer with contents access can create a tag the cluster follows, and a later ADR revisits. +5. **The `main` ruleset requires `Static Analysis`, `Tests & Coverage` and `Release Gate`**, with the strict policy kept. The `release` ruleset and the `release/v0.2.*` branches are removed after step 7. A merge queue is not relied on. +6. **Immutable releases stay off.** The setting exists and answers `enabled: false`. The publish order (assets uploaded, then published) is compatible with turning it on, so a person may do so later with no change; the model does not need it. +7. **GitHub Pages keeps its legacy build from `main:/docs`.** Unreleased documentation goes live when it merges. A deploy step in the publish workflow (about 10 lines: `upload-pages-artifact` and `deploy-pages`) is the alternative, and no step builds it. +8. **`docs/ROADMAP.md` and the compactor stay.** The release no longer writes `docs/ROADMAP.md`; the roadmap Service's render job does when it runs again (ADR 0001). `docs/RELEASE_NOTES.md` is deleted, and so is the release-notes half of the documentation compactor that has no file left (`compact_release_notes` and `devops docs compact --release-notes-only`). The rest of `docs/compactor.py` (547 lines, with 514 lines of tests) and `docs/ROADMAP.md` stay until a separate decision (#881) stops committing the roadmap. +9. **Copilot review is by request.** No pull request gets an automatic pass by policy, the release pull request included: it is a generated diff of four paths. A person requests a pass on any pull request into `main`, and each pass costs tokens in proportion to the pull requests reviewed. +10. **Adjacent refactors are not part of this decision.** A conftest policy for the placeholder-domain rule, `dorny/paths-filter` for the changed-path blocks that remain after step 1 (`fail-to-pass.yml` and two jobs of `ci.yml`), and GitHub's `closingIssuesReferences` in the closing half of readiness are each their own item if one is ever filed, and no step waits for them. + +- Pending a person: create the release GitHub App, install it on this repository only, keep its private key out of the repository, and set `RELEASE_APP_CLIENT_ID` and `RELEASE_APP_PRIVATE_KEY` in an environment named `release`, before the first dispatch. +- Pending a person: create the tag ruleset on `refs/tags/v*` with the App as bypass actor before step 6 merges, and record what `devops gh api repos/dan-petty/devops-cli/rulesets` then lists. +- Pending a person: set `Static Analysis`, `Tests & Coverage` and `Release Gate` as required checks of the `main` ruleset with the strict policy on, before the first dispatch. +- Pending a person: after step 7 merges, delete the `release` ruleset and the remote `release/v0.2.*` and `chore/open-*` branches, and confirm no workflow trigger names `release/**`. +- Pending a person: keep or change the immutable releases setting and the Pages source, and read them with `devops gh api repos/dan-petty/devops-cli/immutable-releases` and `devops gh api repos/dan-petty/devops-cli/pages`. +- Pending a person: dispatch prepare for v0.2.40 once its milestone is empty, merge the release pull request, and record the wall time, the number of actions, every failed step and the release pull request's size beside the v0.2.36 and v0.2.37 figures. +- Pending a person: once v0.2.40 exists, flip the Argo CD applications `bootstrap` and `cluster` to `>=0.2.0` after `argocd app diff` shows no change, and confirm every application resolves to `v0.2.40`. + +## Considered Options + +- **A. Trunk with release-please**: the smaller option if the fragment rule were dropped, and rejected for now. It builds its commit through the API from its own `changes` and force-pushes its branch (`github.ts` sets `force: true`), so the `towncrier` output, an OpenSpec archive and the fragment removal cannot ride on that branch and a second writer is overwritten on the next run, which is cluster 2 again. It writes notes from commit titles, which depend on the squash setting, and the median 0.2.38 entry is 82 characters as a title and 270 as a fragment. It updates `uv.lock` only through a TOML JSONPath extra-file that works through an undocumented tagged-value parser. It tags at merge, before the images exist. It still needs the App token. Its configuration, if the fragment rule goes, is `release-type`, `versioning: always-bump-patch`, `pull-request-title-pattern: feat(release): v${version}`, `include-v-in-tag` and `extra-files` for `uv.lock`. +- **B. Keep the integration branch and replace the cut with open tools** (`towncrier`, `uv` and a workflow-opened pull request into `release/vX.Y.Z`): rejected. It removes the cut, the collector and the compactor (about 1,500 lines) and leaves `close.py` and its three call sites, sync pull requests, release pull requests of hundreds of files, an untested release tip and two rulesets, which are clusters 1, 5 and 8. +- **C. Trunk, release by pushing a tag, versions and notes from commits** (git-cliff, commitizen, python-semantic-release, hatch-vcs): rejected. The bump proposals were wrong for this series, notes are commit titles, and a person pushing a tag publishes with no pull request, no checks before the publish and no tip test. `hatch-vcs` had its last release in 2025-05 and needs `SETUPTOOLS_SCM_PRETEND_VERSION` in image builds without `.git`. GitHub's generated notes list pull requests by label, and the label audit is not enforced in CI. +- **D. Trunk with towncrier, uv, one prepare workflow, one publish workflow and Argo CD on semver tags**: chosen. Every mechanical step is an open tool or a GitHub feature, and `changie` (the same shape in Go) was not chosen because `towncrier` pins by hash in `uv.lock` without a new kind in `tools.lock`. + +## Consequences + +- About 4,200 lines of Python are deleted: `release/cut.py` 1,126, `changelog_fragments.py` 286, `notes_compaction.py` 109, `release/__init__.py` 1, `commands/release.py` 888, `github/release_notes.py` 111, `models/release.py` 51, `roadmap/close.py` 618, `k8s/argocd_live_report.py` 312 (3,502 in whole files), and about 700 more in pieces: 85 in `roadmap/request_plan.py`, 55 in `roadmap/run.py`, 74 in `commands/roadmap.py`, about 270 in `commands/pr.py`, six `Release*Error` classes (137) in `exceptions/git.py`, about 20 in `reprioritize.py` and `store.py`, and the `--oci-labels` validator (about 60). Added are about 55 lines of Python and about 40 of shell. +- About 4,850 lines of tests are deleted as whole files (`test_release.py` 2,975, `test_roadmap_close.py` 876, `test_release_changelog_fragments.py` 283, `test_release_notes_sync.py` 192, `test_release_notes_compaction.py` 120, `test_k8s_argocd_live_report.py` 356, `tests/support/release_notes_examples.py` 44), and about 15 other test files lose cases. Nine tests that assert the old job layout are rewritten against the new workflows. +- About 600 lines of workflow go (`release.yml` 403, the `ci.yml` service-image job 94, `cleanup-devcontainer.yml` 110) and about 470 arrive (`image.yml`, `image-publish.yml`, `prepare-release.yml`, `release.yml`, the gate action). The `devops release` and `devops roadmap close` commands, the `resource://release/status` MCP resource, `docs/RELEASE_NOTES.md` (36) and `docs/commands/release.md` (188) are removed. About 20 documents that name them are edited, among them `AGENTS.md`, `ARCHITECTURE.md`, `README.md`, `RELEASE_CYCLE.md`, `docs/SDLC.md`, `docs/ROUTINE_TASKS.md`, `docs/MCP_TOOLS.md`, `changelog.d/README.md` and eight knowledge base articles. +- In all, about 9,900 lines are deleted (4,203 of Python, 4,846 of tests, 607 of workflow, 224 of documents) against about 565 added. +- An item of the next milestone cannot merge between the moment the current milestone empties and its publish. In the old model the next branch did not exist until the previous release shipped, so the freeze is the same. +- The closure comment with check verdicts and acceptance criteria that `roadmap close` posted is gone. `devops pr check-readiness` verifies both before merge. +- A hotfix needs an empty milestone, so releasing early means moving the open items out of the current milestone. +- Changelog entries read `... . ([#N](url))` where they read `... ([#N](url)).` before, a fragment carries one category, and an author who adds a trailing issue link doubles it. +- Anyone with write access can edit the release pull request body, so the published notes can differ from `CHANGELOG.md`. +- Documentation under `docs/` is published by GitHub Pages from `main`, so unreleased documentation goes live when it merges. +- The image and the manifests follow independent pins. Once the tag ruleset is in place only the release App can create a tag. +- Pull requests no longer publish a `devcontainer:pr-` image, which nothing read. +- The Copilot pass on the release pull request reviewed a 990-file diff and was the only Copilot-reviewed gate. The release pull request is now a generated diff of four paths, and Copilot reviews a pull request only when a person requests a pass, so no automatic review gate remains. +- `docs/ROADMAP.md` is no longer rewritten at a release. Until the roadmap Service renders it again, it lags GitHub. + +## Revisit Conditions + +- The rehearsal falsifies one of its four premises. Each has a named fallback: reading the merge commit and the milestone from the pull request's REST resource instead of the event payload, a `workflow_dispatch` run of `ci.yml` on the release branch started by prepare, a draft release created and uploaded to before it is published by `gh release edit --draft=false`, and a single image workflow with a read-only job and a publishing job. +- A later ADR drops the fragment rule: release-please becomes the smaller option and replaces `prepare-release.yml`, with the App token kept. +- GitHub lets a user-owned repository enable a merge queue, immutable releases are enabled for it, or an App cannot be a bypass actor on this repository's tag ruleset. +- A milestone sits empty and unreleased for a day because nobody dispatched, or a second maintainer joins: reconsider dispatch by hand against an `issues: closed` trigger that dispatches prepare when a milestone empties. +- Argo CD's constraint resolution picks an unexpected tag, or the cluster needs a rollback faster than two actions: pin the application to a tag by hand and reconsider Image Updater's `semver` strategy. +- Release 1.0.0: this ADR is superseded by Semantic Versioning, feature flags and deprecation windows. diff --git a/docs/agent/tasks/task-1751-release-model-adr.md b/docs/agent/tasks/task-1751-release-model-adr.md new file mode 100644 index 0000000000..080bd58367 --- /dev/null +++ b/docs/agent/tasks/task-1751-release-model-adr.md @@ -0,0 +1,34 @@ +# Task: Releases Come from Trunk, and towncrier, uv and Semver Tags Replace the Bespoke Cut (#1751) + +**Issue**: [#1751](https://github.com/dan-petty/devops-cli/issues/1751) +**Scope**: type/docs +**Feasibility**: Checked at release/v0.2.39 (07c49010) on 2026-10-22, offline except for read-only GitHub reads through `devops gh api`. Every line count is `wc -l` or `git grep` over the tree (the release path is 3,190 lines of source and 4,446 of tests, `release.yml` 403, the readiness rules in `commands/pr.py` 540 lines at 1464-2003). The 94 issues and 138 merged pull requests are the title search `release OR changelog OR cut OR fragment` over `search/issues`, and the scopes, pull request sizes and times, the 99 `release.yml` runs, the rulesets, the immutable releases setting and the Pages source come from `repos/dan-petty/devops-cli/...` reads. The changelog section sizes are parsed from `CHANGELOG.md`, and the 28 git sources in 27 files under `k8s/argocd` from the YAML. In scratch, `towncrier build --draft` (towncrier 26.9.0) rendered typed fragments, and `uv version 0.2.40 --no-sync` on a copy of the tree changed one line each of `pyproject.toml` and `uv.lock` under uv 0.12.23 and also rewrote the lock's `revision` under 0.12.16, so the two pins in the tree (`setup-toolchain` 0.12.16, the `Dockerfile` 0.12.23) differ in effect. The investigation ran git-cliff 2.14.2, commitizen 4.19.2 and python-semantic-release 10.7.0, which each proposed 0.3.0 for the 0.2.N series, and read release-please 17.11.2, the GitHub Actions the design names, Argo CD's tag resolution and GitHub's ruleset documentation without running them. Two independent reviewers reviewed the design. + +## Description +The release model ran through a `release/vX.Y.Z` branch, a hand-made cut pull request, a release pull request of 188 to 990 files and a publish on the push to `main`, at 75 to 107 minutes and about 9,900 lines of dedicated code, tests, workflow and documents. [ADR 0011](../../adr/0011-releases-come-from-trunk-towncrier-uv-and-semver-tags-instead-of-a-bespoke-cut.md) decides that releases come from trunk: item pull requests target `main`, `towncrier` assembles the changelog from typed fragments, `uv version` sets the version, one dispatched workflow opens the release pull request, merging it publishes and creates the tag as its last write, and Argo CD follows the semver tags. It answers the five questions of the issue, measures v0.2.36 and v0.2.37, compares four options, names what stays custom with the open tool considered for each, and decides the ten points that needed the owner under "Decisions Taken". This pull request is the decision record only: no code, workflow or setting changes, and nothing in it publishes or deploys. + +## Acceptance Criteria +- [x] The cost of a release is measured on two releases: v0.2.36 took 75 minutes and v0.2.37 took 107 minutes from the cut pull request's creation to the end of the publish run, with release pull requests of 188 and 990 files (ADR 0011, Evidence). +- [x] Each option is compared on owner steps, failure modes and the deploy path: the four options in "Considered Options", with the nine defect clusters of the old model in Evidence. +- [x] The ADR states the decision, answers the five questions of the issue, and lists the nine steps that migrate to it in delivery order (ADR 0011, "Cutover and Sequence"). +- [x] The ADR records no point as open: the ten points that needed the owner are under "Decisions Taken", each confirmed by merging the ADR and reversible by a later ADR. +- [x] Every figure in the ADR was re-counted against the tree and GitHub on 2026-10-22, and the ones that could not be reproduced were replaced by figures that can (the pull request and issue counts by scope, the changelog section sizes and the title and fragment lengths). +- Pending a person: create the release GitHub App for this repository only and set `RELEASE_APP_CLIENT_ID` and `RELEASE_APP_PRIVATE_KEY` in an environment named `release`. `devops gh api repos/dan-petty/devops-cli/environments --jq '.environments[].name'` then lists `release`. +- Pending a person: create the tag ruleset on `refs/tags/v*` with the App as bypass actor before the Argo CD tag-following step merges. `devops gh api repos/dan-petty/devops-cli/rulesets --jq '.[] | {name, target}'` then lists a ruleset with target `tag`; if GitHub does not accept the App as a bypass actor, record that and restrict only update and deletion. +- Pending a person: set `Static Analysis`, `Tests & Coverage` and `Release Gate` as required checks of the `main` ruleset with the strict policy on. `devops gh api repos/dan-petty/devops-cli/rulesets/21466414 --jq '.rules[] | select(.type=="required_status_checks")'` then lists the three checks. +- Pending a person: after the machinery-deletion step merges, delete the `release` ruleset and the remote `release/v0.2.*` and `chore/open-*` branches. `devops gh api repos/dan-petty/devops-cli/rulesets --jq '.[].name'` then lists no `release`, and `git ls-remote --heads origin 'release/*'` prints nothing. +- Pending a person: keep or change the immutable releases setting and the Pages source, which ADR 0011 leaves off and legacy from `main:/docs`. `devops gh api repos/dan-petty/devops-cli/immutable-releases` and `devops gh api repos/dan-petty/devops-cli/pages` show what is set. +- Pending a person: dispatch `prepare-release.yml` for v0.2.40 when its milestone is empty, merge the release pull request, flip the Argo CD applications `bootstrap` and `cluster` to `>=0.2.0` after `argocd app diff` shows no change, and record the wall time, the number of actions and the failed steps beside the v0.2.36 and v0.2.37 figures. + +## Deliverables +- [x] `docs/adr/0011-releases-come-from-trunk-towncrier-uv-and-semver-tags-instead-of-a-bespoke-cut.md`, and `changelog.d/1751.md`. +- Not done: one reusable workflow builds the service and devcontainer images and the pull request build holds no write scope; it follows in a later item. +- Not done: fragments are typed and `towncrier` assembles the changelog; it follows in a later item. +- Not done: one workflow opens the release pull request, with the release gate; it follows in a later item. +- Not done: the Argo CD build gate runs in `devops ci` on every change to `k8s/`; it follows in a later item. +- Not done: topic pull requests target `main` and merging the release pull request publishes, after a rehearsal in a throwaway copy of the repository; it follows in a later item. +- Not done: Argo CD follows release tags; it follows in a later item. +- Not done: the bespoke release machinery is deleted; it follows in a later item. +- Not done: the settings item (the release App, environment and rulesets), done by a person; it follows in a later item. +- Not done: v0.2.40 is the first release made by the new pipeline, done by a person; it follows in a later item. +- Not done: the nine items above are filed through `devops roadmap intake` after this merges, so their issue numbers do not exist yet.