Skip to content

fix(release): one fail-closed release path: cut branch from the remote release tip, uv.lock bump, draft flag, required label and milestone #982

Closed

Description

@dan-petty

fix(release): one fail-closed release path: cut branch from the remote release tip, uv.lock bump, draft flag, required label and milestone

Problem Statement

Split out of #743 (devops roadmap close) by the owner's decision (decisions.json, Q2 and 743): #743 keeps the closure job and the cut predicate; this item delivers the release path both the job and the manual commands run, and lands before #743. The owner's order of 2026-10-03 puts #753 and #741 first in v0.2.26, so #741's image-tag step and its _release_paths entry are already in release.py when this item moves the bump block and adds uv.lock to _release_paths. The owner also settled the branch question #743 left open: the cut commit goes on chore/cut-vX.Y.Z, built from origin/release/vX.Y.Z, and that branch's one PR into main is the release PR (decisions.json, 743).

devops release prepare <version> --create-pr (src/devops_cli/commands/release.py:645, calling release_pr at :773-780) is the only way a release is cut today (docs/ROUTINE_TASKS.md:46, :263-267; docs/SDLC.md:346; RELEASE_CYCLE.md:182-185), and it cannot cut the existing release branch. Checked at 9c879ae (release/v0.2.25):

  • It bumps the files before it makes a branch, then resets the release branch to wherever it is. release_prepare edits pyproject.toml and src/devops_cli/__init__.py (:748-757), collects the fragments (:760), syncs the docs (:767-769) and only then calls release_pr, whose _checkout_release_branch runs git checkout -B release/vX.Y.Z with no start point (:798-809, called at :1177): the branch is created at, or reset to, the caller's HEAD, with the edits carried along, not built from the release branch's tip. Nothing refuses a dirty tree, although _is_git_clean exists in the module (:131-135) and release check uses it (:1318).
  • It commits on release/vX.Y.Z and pushes it (_commit_and_push_release_branch, :812-830). The issue records that the live release ruleset (23059172) requires a PR for every update to refs/heads/release*/**/* (not verifiable from the repository), and no-commit-to-branch rejects the commit where pre-commit is installed (.pre-commit-config.yaml:8-10). v0.2.24's bump went in through PR fix(review): remediate session 20260928-160843 findings and harden feedback loop (#682) #683 (abe6bb5), and v0.2.25 was opened through chore/open-v0.2.25 (PR chore(release): open the v0.2.25 cycle #918, 44d1f90), the convention fix(release): changelog fragments so concurrent pull requests never conflict on CHANGELOG.md or docs/ROADMAP.md #933 wrote down for release-process PRs.
  • It warns where it should stop. A failed commit (:818-819) and a failed push (:826-829) print a warning and the command goes on to open the PR; when gh pr create fails, _execute_release_pr (:1081-1107) retries without the label or milestone GitHub rejected (_build_pr_fallback_cmd, _strip_pr_cmd_flag, :1064-1078) and a final failure warns and exits 0 (:1102-1106; tests/test_release.py:662 asserts that exit code).
  • It does not bump uv.lock, which records the project version in its own [[package]] entry (uv.lock:634-637; rg uv.lock src/devops_cli/commands/release.py finds nothing), so after a bump the gate's uv lock --check (src/devops_cli/commands/ci.py:459) fails on the release PR until someone updates the lock by hand. _release_paths (:522-537) stages pyproject.toml, __init__.py, CHANGELOG.md, README.md, docs/ and changelog.d/ where it exists.
  • The draft flag is fixed at the command. release prepare (:688) and release pr (:1119-1122) both default to --draft, and _build_release_pr_command (:1050-1051) adds --draft from that option. feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743's cut must open the release PR ready for review (automatic Copilot review runs only on PRs into main, 840.md:19, and skips drafts), so the shared path has to take the flag from its caller while the manual commands keep their default.
  • Its label is undeclared. The PR gets DEFAULT_RELEASE_LABEL = release (src/devops_cli/config/defaults.py:481) and milestone v<version> (:1200), and .github/labels.yml declares scope/release (:78-80) but no release; devops gh labels sync works from that file (src/devops_cli/github/labels.py:51; src/devops_cli/commands/gh.py:238-239).
  • release pr reads the version from the caller's checkout, not from the release tip: _validate_release_version (:788-795) runs at :1154, before any branch exists.
  • Readiness does not know the cut branch. _is_release_pr (src/devops_cli/commands/pr.py:1517-1523) exempts release/vX.Y.Z into the default branch; _is_release_process_pr (:1526-1536) exempts chore/open-vX.Y.Z or chore/cut-vX.Y.Z into release/vX.Y.Z (CONST_RELEASE_PROCESS_BRANCH_RE, src/devops_cli/config/constants.py:2577-2579, comment at :2567-2572). Under the owner's decision the release PR is chore/cut-vX.Y.Z into main, which neither function accepts, so devops pr check-readiness would block every release PR for closing no issue (:1573). Five doc sentences state today's convention: AGENTS.md:176, :180 (which also defines the release PR as release/vX.Y.Z into the default branch) and :240 ("from a release branch"), docs/agent/tasks/README.md:13 (rule 5), RELEASE_CYCLE.md:56. refactor(github): one github session per identity owning token, quota and transport #767's body still names the cut branch chore/release-vX.Y.Z (767.md:117).

Already delivered and built on: changelog fragments (#933, c224927): _plan_changelog_or_exit and _write_version_changelog (release.py:486-519) collect changelog.d/*.md into ## [X.Y.Z] - <date> and delete them, and _release_paths stages the deletions; _resolve_clean_release_notes reads that section first for the PR body (:979-996); _format_release_title (:540-550) gives feat(release): vX.Y.Z; #704's and #933's readiness exemptions with their tests (tests/test_pr_cmd.py:1803, :1824, :1993, :2015, :2030); a real-git fixture pattern with a local bare remote (tests/test_ci.py:813-821); fetch_all and is_git_clean in src/devops_cli/git/operations.py:202, :273-279.

Proposed Solution

One function in commands/release.py that cuts a release, called by release prepare --create-pr, by release pr, and by #743's roadmap close. It takes the version, the draft flag, the base, the labels, the release type and breaking flag, and the root, and runs these steps in this order, exiting non-zero at the first failure with nothing opened:

  1. Refuse a dirty tree (_is_git_clean, release.py:131-135) before any branch or file is touched.
  2. Fetch and build the cut branch: git fetch origin, then git checkout -B chore/cut-vX.Y.Z origin/release/vX.Y.Z. The branch always starts at the remote release tip; a local chore/cut-vX.Y.Z is reset, so a re-cut is a rebuild. A missing origin/release/vX.Y.Z is a failure naming the branch; there is no fallback to HEAD. This replaces _checkout_release_branch (:798-809).
  3. Edit on the cut branch (release prepare only; moved from before the checkout, :748-769, to after it): pyproject.toml (_update_pyproject_version, :312-332), src/devops_cli/__init__.py where it holds a literal (_update_init_version, :335-358), the project's own [[package]] entry in uv.lock (name = "<project>" followed by version = "...", uv.lock:634-637) when the file exists, the CHANGELOG section from the fragments (:760), and the docs sync as today under --sync-docs (:767-769). uv.lock joins _release_paths where it exists.
  4. Commit and push: git add <release paths>, git commit -m "<title>" ("nothing to commit" stays tolerated, for release pr on its own), git push --force-with-lease -u origin chore/cut-vX.Y.Z. A failed commit or push exits non-zero (today :818-819 and :826-829 warn).
  5. Open the release PR with gh pr create: base main (CONST_GIT_MAIN_BRANCH, constants.py:595), head chore/cut-vX.Y.Z, title from _format_release_title, body from _build_release_pr_body (:999), --label release (validated as today, :1054-1060), --milestone vX.Y.Z (passed as today, :1200), and --draft only when the caller asks. Label and milestone are required: a rejected flag is a failure, not a retry. _build_pr_fallback_cmd and _strip_pr_cmd_flag (:1064-1078) and the warn-and-continue tail of _execute_release_pr (:1102-1106) are deleted.

Around it:

  • release prepare <version> --create-pr runs steps 1-5; its --draft/--no-draft (:688) keeps its default and is passed through. Without --create-pr it keeps editing the working tree in place, as today.
  • release pr runs steps 1, 2, 4 and 5 for what is already committed on the release tip. Its version comes from --version or, after the checkout, from pyproject.toml on the cut branch (_validate_release_version, :788-795, moves from :1154 to after step 2), so the title names the release the tip holds. It keeps --base (default main, :1115-1118), --draft (:1119-1122), --labels, --type, --breaking and --root, and loses --push/--no-push (:1127-1130): a cut branch that is not pushed has no PR, and --dry-run is the way to look first. HELP.options.push stays, because release tag --push uses it (:1595). docs/commands/release.md:53-75 and docs/CLI_REFERENCE.md are regenerated.
  • feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 calls the function with draft=False; this item does not change roadmap commands.
  • .github/labels.yml declares release beside scope/release (:78-80), with a description naming the release PR.
  • Readiness: _is_release_pr (pr.py:1517-1523) accepts chore/cut-vX.Y.Z from the same repository into the default branch, which becomes the one definition of the release PR; release/vX.Y.Z into the default branch is no longer exempt (no command opens that PR after this item). _is_release_process_pr (:1526-1536) keeps chore/open-vX.Y.Z (optionally -<slug>) into release/vX.Y.Z and drops chore/cut-vX.Y.Z into release/vX.Y.Z. CONST_RELEASE_PROCESS_BRANCH_RE becomes the open-branch pattern, a new constant matches the cut branch, the comment at constants.py:2567-2572 says so, and CONST_RELEASE_BRANCH_RE keeps its other two users (pr.py:1533, :1654).
  • Docs for the manual cut: docs/ROUTINE_TASKS.md:267 says the command creates chore/cut-v<version> from origin/release/v<version> and opens the release PR into main; the "Initialize ## [Unreleased]" step at :275 goes (the collection leaves the heading in place, changelog.d/README.md:5); RELEASE_CYCLE.md:184 ("commits changes to branch 'release/vX.Y.Z'") says the cut branch; the convention sentences at RELEASE_CYCLE.md:56, docs/agent/tasks/README.md:13 and AGENTS.md:176, :180, :240 name chore/open-vX.Y.Z into release/vX.Y.Z as the one release-process PR and then chore/cut-vX.Y.Z into main as the release PR, in that order, so the rg check below cannot match them. docs/ROUTINE_TASKS.md:46, :255, :263 and docs/SDLC.md:346 keep naming release prepare --create-pr; feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 rewords them around roadmap close.
  • changelog.d/982.md and docs/agent/tasks/task-#982-<slug>.md; CHANGELOG.md and docs/ROADMAP.md are not edited.

Scope

The shared cut function and its two manual callers in commands/release.py; the uv.lock bump; removal of the fallback helpers and of --push/--no-push; the release label; the readiness and constants change with its tests; the five convention sentences and the two ROUTINE_TASKS.md lines; regenerated command docs. Effort: Medium. One PR.

Key Questions

  • Which branch carries the cut commit, and into which base is the PR opened? Answered by the owner: chore/cut-vX.Y.Z, built from origin/release/vX.Y.Z after a fetch, into main, one PR, which is the release PR. It needs no ruleset change (the ruleset covers refs/heads/release*/**/*), passes no-commit-to-branch, leaves release/vX.Y.Z as the item PRs left it, and reuses the name fix(release): changelog fragments so concurrent pull requests never conflict on CHANGELOG.md or docs/ROADMAP.md #933 introduced at constants.py:2578.
  • Does release/vX.Y.Z into main stay a release PR for readiness? No. After this item no command opens it, and the codebase keeps one definition (pre-1.0 policy: no obsolete shims). The exemption test at tests/test_pr_cmd.py:1803 changes its head to the cut branch, and release/v0.2.25 into main joins the held cases at :1824.
  • What does release pr do on its own? Refuses a dirty tree, builds the cut branch from the remote release tip, resolves the version from that tip, commits nothing new, pushes and opens the PR for what the tip holds. It is the way to reopen a release PR that was closed, or to open one for bumps already merged into the release branch.
  • Does --base stay on release pr? Yes, unchanged, default main; it also feeds the PR body's branch diff (_build_release_pr_body, :999). The shared function takes the base from its caller; release prepare and feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 pass main.
  • Why does --push/--no-push go? The path's one product is the PR; a branch kept local cannot have one, and a later release pr would rebuild the branch from the remote tip and drop the local commit. --dry-run shows the plan without writing.
  • What if origin/release/vX.Y.Z does not exist? Exit non-zero naming it, before any file is edited; the tree stays clean. A repository without a release branch for that version is not cut by this command.
  • Repositories other than devops-cli (ADR 0001)? pyproject.toml, __init__.py and uv.lock are bumped and staged only where they exist; _release_paths already stages changelog.d/ conditionally.
  • How is uv.lock bumped? By editing the version line of the project's own [[package]] entry (the one whose source = { editable = "." }, uv.lock:634-637); no uv subprocess. Measured at 9c879ae with uv 0.12.16: a copy of pyproject.toml and uv.lock both set to 0.2.26 passes uv lock --check --offline with an empty UV_CACHE_DIR in 0.17 s. The acceptance test runs that check.
  • Draft or ready? The function takes the flag; release prepare and release pr keep their --draft default for the manual path (tests at tests/test_release.py:307, :322 keep their meaning); feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 passes ready-for-review because Copilot review skips drafts.
  • Which label and milestone, and are they required? release (DEFAULT_RELEASE_LABEL, defaults.py:481), declared in .github/labels.yml by this item, and milestone vX.Y.Z (already built at :1200). Both are required: the release PR is how feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743's cut predicate (an open PR into the default branch with label release and milestone vX.Y.Z) and the readiness exemption recognise the release, so a PR opened without them is worse than none. --labels stays as an option; an invalid or rejected label fails the run.
  • Why fetch and branch before editing? So the edits are made on the release tip rather than carried over from the caller's HEAD, and so a dirty-tree refusal costs nothing. release prepare's bump block moves after the checkout; feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741's image-tag step moves with the block; feat(k8s): argo cd keeps the homelab cluster at the current release branch, with automated sync, prune and self-heal that never delete data #755 (v0.2.27) later adds its targetRevision step and k8s/argocd/ to _release_paths.
  • Does the docs sync stay? Unchanged under --sync-docs in release prepare, now run on the cut branch; feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 decides what its cut passes.
  • How does a re-cut work? checkout -B from the remote tip discards a stale local cut branch, and --force-with-lease (safe because the run fetched first) replaces the remote one, so after a release PR is closed unmerged and more items merge, the next run rebuilds the branch and the section from the new tip.
  • Who pushes from the service? refactor(github): one github session per identity owning token, quota and transport #767 pins GH_TOKEN for git push in the service; from a terminal the person's credentials push. Not this item.
  • How is this tested without the network? Git is a temporary repository with a local bare remote holding main and release/v0.2.26 (as tests/test_ci.py:813-821 builds one), built once per module and copied per test; gh is run_gh patched as tests/test_release.py:536-594 do; the lock check runs uv lock --check --offline with an empty cache directory.

Acceptance Criteria

Automated tests in tests/test_release.py and tests/test_pr_cmd.py unless marked otherwise; nothing touches the network.

Cut branch

  • devops release prepare 0.2.26 --create-pr on a dirty tree exits non-zero naming the dirty state; no branch is created and no file changes (git status --porcelain is unchanged).
  • On a clean clone checked out on another branch, the run pushes chore/cut-v0.2.26 to the bare remote; its parent commit is the remote release/v0.2.26 tip, and the remote release/v0.2.26 and main do not move.
  • With origin/release/v0.2.26 absent, the run exits non-zero naming the branch; the tree stays clean and no branch is created.
  • After one more commit is pushed to the remote release/v0.2.26 and the remote chore/cut-v0.2.26 already exists, a second run rebuilds the cut branch on the new tip and the push replaces the old branch.

Cut commit

  • With --no-sync-docs, the cut commit changes exactly pyproject.toml, src/devops_cli/__init__.py, uv.lock, CHANGELOG.md and the deleted changelog.d/*.md (git show --stat); CHANGELOG.md holds one ## [0.2.26] block built from the fragments and an empty ## [Unreleased].
  • After the bump, uv lock --check --offline passes on a temporary copy of pyproject.toml and uv.lock with an empty UV_CACHE_DIR (0.17 s measured; skipped when uv is not on PATH).
  • In a root without uv.lock, the run neither creates one nor stages it.

Pull request

  • The fake gh pr create receives base main, head chore/cut-v0.2.26, title feat(release): v0.2.26, --label release, --milestone v0.2.26, and --draft by default; with --no-draft, and when the shared function is called with draft=False, no --draft.
  • When the bare remote's pre-receive hook rejects the push, the run exits non-zero and gh pr create is never called.
  • When gh pr create fails naming the label, or naming the milestone, the run exits non-zero and gh pr create is called once (replacing test_release_pr_labels_and_draft at tests/test_release.py:536 and the gh-failure branch of test_release_pr_error_branches_and_breaking at :594, which today asserts exit code 0 at :662).
  • devops release pr alone on a clean tree pushes a cut branch equal to the remote release tip and opens the PR whose title names the version in the tip's pyproject.toml, not the caller's checkout; on a dirty tree it exits non-zero before any git write.
  • devops release pr --help lists no --push; rg -n "no-push" src docs/commands/release.md docs/CLI_REFERENCE.md finds nothing (today it hits release.py:1129, release.md:69 and CLI_REFERENCE.md:5429).

Dry run

  • release prepare 0.2.26 --create-pr --dry-run and release pr --dry-run print the cut branch chore/cut-v0.2.26, base main, the title and the fragments; no git ref changes and gh is not called (adapting tests/test_release.py:289, :322).

No merge

  • Across these tests the fake gh never receives pr merge or pr review; the bare remote's release/** and main refs are unchanged after every test.

Readiness

  • chore/cut-v0.2.25 from this repository into main is exempt before any lookup (the case at tests/test_pr_cmd.py:1803, head changed); release/v0.2.25 into main, a fork's chore/cut-v0.2.25 into main, and chore/cut-v0.2.25 into release/v0.2.25 are held to grounding (joining :1824, :2015 and :2030).
  • chore/open-v0.2.25 and chore/open-v0.2.25-cycle into release/v0.2.25 stay exempt (:1993).

Label

  • .github/labels.yml declares release; test_repository_labels_declare_the_release_label in tests/test_github_labels.py loads the repository's file with load_label_specs (src/devops_cli/github/labels.py:51) and asserts DEFAULT_RELEASE_LABEL is among the names.

Removal

  • rg -n "_build_pr_fallback_cmd|_strip_pr_cmd_flag|_checkout_release_branch" src tests docs -g '!docs/ROADMAP.md' -g '!docs/agent/tasks/**' finds nothing (today it hits release.py only; task-330 keeps its history).

Docs

  • rg -n "chore/cut-vX.Y.Z.{0,60}into .release/vX.Y.Z|from a release branch|chore/release-v" AGENTS.md RELEASE_CYCLE.md docs/agent/tasks/README.md docs/ROUTINE_TASKS.md finds nothing (today it hits exactly AGENTS.md:176, :180, :240, RELEASE_CYCLE.md:56 and docs/agent/tasks/README.md:13); rg -n "chore/cut-vX.Y.Z. into .main" AGENTS.md RELEASE_CYCLE.md docs/agent/tasks/README.md src/devops_cli/config/constants.py hits each of the four files at least once.
  • docs/ROUTINE_TASKS.md has no "Creates topic branch release/v<version>" sentence and no "Initialize ## [Unreleased]" step (rg -n "topic branch .release/v<version>|Initialize .## \[Unreleased\]" docs/ROUTINE_TASKS.md finds nothing; today it hits :267 and :275).
  • Review check on the PR: git diff <base> -- AGENTS.md changes only the sentences at :176, :180 and :240 and removes no other line.
  • uv run devops docs check passes; the new tests add at most 2 s (uv run pytest tests/test_release.py tests/test_pr_cmd.py tests/test_github_labels.py --durations=0); uv run devops ci passes.

Manual check (a person, against GitHub)

Out of Scope

Dependencies

Amended 2026-10-03: no fragment collection in the cut commit (owner decision, #1103)

The owner decided on 2026-10-03 that changelog fragments are collected when the release merges or publishes, never in a release-cut commit. #1103 owns that mechanism, and #743 was amended the same way. For this item:

Activity

  1. added this to the v0.2.26 milestone on Oct 2, 2026
  2. added
    priority/p1-high
    scope/release
    on Oct 2, 2026
  3. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    The owner's order of 2026-10-03 lands #753 and #741 first, so #741's image-tag step and its _release_paths entry are already in release.py when this item moves the bump block. #755 (v0.2.27) adds the targetRevision step after it.

  4. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    Note from the release-path fixes (2026-10-03), for whoever builds this item; scope and placement are unchanged:

  5. dan-petty commented on Oct 4, 2026

    @dan-petty
    OwnerAuthor

    Closed by #1164, merged into release/v0.2.26.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

  6. added a commit that references this issue on Oct 4, 2026
  7. added
    type/bug
    and removed on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/releasetype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions