Skip to content

feat: refuse a promote that would move :latest backwards - #1631

Merged
c-vigo merged 12 commits into
devfrom
feature/1626-promote-latest-guard
Sep 14, 2026
Merged

c-vigo merged 12 commits into
devfrom
feature/1626-promote-latest-guard

Conversation

@c-vigo

@c-vigo c-vigo commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a semver guard to promote-release.yml so a promote can never move the floating refs backwards. Devkit moves GHCR :latest unconditionally; with the hotfix lane (#1621, #1623) a patch cut from main and a train cut from dev could, if both existed, promote in the wrong order and walk :latest back to an older version. The guard is the last line of defence behind the single-train refusals (#1627): the validate job compares the version against the highest published final GitHub Release — the version the floating refs follow — and fails before the irreversible publish when it is lower.

Design notes (plan comment on #1626): no org.opencontainers.image.version label exists (the image is built by Nix; flake.nix sets only title/source/licenses) and reading GHCR metadata needs a packages scope the scaffold token lacks, so the published-final list is the source of truth. No override input; the recovery is to abandon the stale train and re-cut the fix as the next patch of the published line.

Stacked on #1630 (#1627): this branch is based on feature/1627-prepare-release-single-train because both PRs rewrite the same hotfix runbook paragraph. Once #1630 merges, this branch gets rebased onto dev so the diff shrinks to the commits listed below.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • .github/workflows/promote-release.yml — new validate step Verify version does not move :latest backwards, after the draft-release check: pages repos/{repo}/releases, keeps draft == false && prerelease == false bare-semver tags, takes the highest with sort -V, and fails when VERSION sorts below it. Passes when no final release exists yet. A failed API call fails the step (no fail-open).
  • assets/workspace/.github/workflows/promote-release.yml — the same step for the opt-in git floating tags, gated on needs.resolve-toolchain.outputs.floating-tags != ''; release tags are filtered to the TAG_PREFIX line and compared after the prefix is stripped, so pre-devkit bare tags are ignored. Consumers without floating tags are unaffected.
  • tests/test_promote_release.py — shape pins for both copies (data source, filters, sort -V, placement after the draft check; devkit unconditional, scaffold gated and prefix-aware).
  • tests/test_promote_latest_guard.py (new) — runs the extracted step body with gh stubbed to answer the release listing: lower refused with the message and remedy, higher passes, numeric (not lexical) ordering, empty list / drafts-only passes, drafts and pre-releases ignored, prefix stripped, tags outside the prefix ignored.
  • docs/RELEASE_CYCLE.md — release-phases step 6, the hotfix runbook rule (now points at the guard), and a troubleshooting entry for the refusal. docs/DOWNSTREAM_RELEASE.md (+ mirror) — floating-tags note. CHANGELOG.md (+ mirror).

Changelog Entry

Added

  • promote-release refuses to move :latest backwards
    (#1626)
    • Devkit's promote-release.yml validate job now compares the version
      against the highest published final GitHub Release (the version :latest
      follows) and fails before the irreversible publish when it is lower.
      No override: abandon the stale train and re-cut the fix as the next
      patch of the published line
    • The scaffold copy carries the same guard for the opt-in git floating
      tags, active only when DEVKIT_FLOATING_TAGS is set; release tags are
      compared after the tag prefix is stripped, and consumers without
      floating tags keep the freedom to publish a patch for an older line

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

  • uv run pytest tests/test_promote_release.py tests/test_promote_latest_guard.py tests/test_floating_tag_move.py tests/test_workflow_prepare_extension.py tests/test_workflow_prepare_hotfix.py tests/test_release_tombstone_detection.py tests/test_ci_green_gate.py: 189 passed. The 16 new cases were RED before the workflow change (commit baf5bdf).
  • prek run --all-files: green.
  • No live promote was run (the next real promote exercises the happy path: the highest published release is 1.14.1, every regular train is higher).

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Second of three hotfix-lane follow-ups: #1627 (#1630) → #1626 (this PR) → #1625 (scaffold port). Merge #1630 first.

Refs: #1626

@c-vigo c-vigo self-assigned this Sep 14, 2026
Base automatically changed from feature/1627-prepare-release-single-train to dev September 14, 2026 14:26
## Description

Phase 2 of #1621: ports the hotfix release lane (#1623) to the workspace
scaffold so gitflow consumers get `prepare-hotfix.yml` and `just
prepare-hotfix X.Y.Z` before they need it — `workflow_dispatch` only
works once the file is on the consumer's default branch, so the lane
cannot be adopted and used in the same emergency.

The scaffold copy is written in the scaffold dialect: every job runs on
the mode-aware devkit toolchain (`resolve-toolchain` +
`setup-devkit-toolchain`, no `uv run`), the latest-tag lookup and the
collision check honour `DEVKIT_TAG_PREFIX`, every checkout sets
`persist-credentials: false`, and `prepare-release-extension.yml` stays
the only project-specific seam. The lane is gitflow-only: copy-excluded
under `DEVKIT_WORKFLOW=trunk` and pruned on a gitflow → trunk upgrade,
the same mechanism as `sync-main-to-dev.yml` — the two now share one
`TRUNK_EXCLUDED_WORKFLOWS` list in `init-workspace.sh` instead of a
sixth special case.

The scaffold `release-core.yml` validate job switched from grepping for
the bare `## [X.Y.Z] - TBD` heading to `prepare-changelog validate
--version`, so a seeded-but-unfilled hotfix section cannot ship
downstream (the `--version` flag ships in the same devkit release, so
the toolchain contract holds).

Stacked on #1631 (#1626), which is stacked on #1630 (#1627): all three
rewrite the same hotfix runbook paragraphs and workflow validate jobs.
Once #1631 merges, this branch gets rebased onto `dev` so the diff
shrinks to the commits listed below.

## Type of Change

- [x] `feat` -- New feature
- [ ] `fix` -- Bug fix
- [ ] `docs` -- Documentation only
- [ ] `chore` -- Maintenance task (deps, config, etc.)
- [ ] `refactor` -- Code restructuring (no behavior change)
- [ ] `test` -- Adding or updating tests
- [ ] `ci` -- CI/CD pipeline changes
- [ ] `build` -- Build system or dependency changes
- [ ] `revert` -- Reverts a previous commit
- [ ] `style` -- Code style (formatting, whitespace)

### Modifiers

- [ ] Breaking change (`!`) -- This change breaks backward compatibility

## Changes Made

- `assets/workspace/.github/workflows/prepare-hotfix.yml` (new) — the
scaffold lane: `resolve-toolchain` → `validate` (patch increment of the
latest `main` tag, single-train refusal, empty-Unreleased refusal via
`prepare-changelog`) → `prepare` (cut from `main`, seed the `## [X.Y.Z]
- TBD` section) → `extension` hook → `open-pr` (draft, targets `main`) →
`rollback` (deletes only the release branch). `dry_run` gates every job
but `validate`.
- `zizmor.yml` (root + scaffold) — baseline the managed basename for
`github-app`, `secrets-inherit` and `unpinned-images`; `artipacked` not
needed.
- `assets/workspace/.github/renovate-default.json` — the new managed
basename joins the trailing `enabled: false` rule (drift gate
`test_renovate_preset_managed_exclusion`).
- `assets/init-workspace.sh` — `TRUNK_EXCLUDED_WORKFLOWS` list +
`trunk_excluded()` replacing the five `sync-main-to-dev.yml` special
cases (preview classifier, upgrade deletions, rsync exclude, post-copy
prune, preserved-class carve-out); the hotfix lane joins the `release`
feature group; the `prepare-hotfix` recipe is stripped from
`justfile.gh` under trunk only.
- `scripts/manifest.toml` — drop the `RemoveBlock` that stripped `just
prepare-hotfix` from the scaffolded `justfile.gh`;
`assets/workspace/.devcontainer/justfile.gh` regenerated.
- `assets/workspace/.github/workflows/release-core.yml` — **Verify
CHANGELOG has TBD entry** now runs `prepare-changelog validate --version
"$VERSION"`.
- Tests — `tests/test_workflow_prepare_hotfix.py` parametrised over both
copies plus scaffold-only pins (toolchain, tag-prefix awareness,
`release-core.yml` content gate, recipe present);
`tests/test_workflow_model.py` pins gitflow-has / trunk-lacks and the
upgrade prune; `tests/test_workflow_zizmor_baseline.py` covers the
baseline entries; `tests/test_workflow_prepare_extension.py` adds the
scaffold lane to the callers.
- Docs — `docs/DOWNSTREAM_RELEASE.md` (+ mirror) hotfix-lane runbook and
trunk carve-out, `docs/MIGRATION.md` workflow lists and `release` group,
`docs/RELEASE_CYCLE.md` consumer-scaffold paragraph; `CHANGELOG.md` (+
mirror), including dropping the "devkit-only for now" note from the
#1623 entry.

## Changelog Entry

### Added

- **Hotfix release lane in the consumer scaffold**
  ([#1625](#1625))
  - `assets/workspace/.github/workflows/prepare-hotfix.yml` (Phase 2 of
[#1621](#1621)): the same lane in
the scaffold dialect — every job runs
    on the mode-aware devkit toolchain (`resolve-toolchain` +
`setup-devkit-toolchain`, no `uv run`), the latest-tag lookup and the
collision check honour `DEVKIT_TAG_PREFIX`, and every checkout drops its
git credential. `just prepare-hotfix X.Y.Z` now reaches consumers too
- Gitflow only: copy-excluded under `DEVKIT_WORKFLOW=trunk` and pruned
on a
gitflow → trunk upgrade exactly like `sync-main-to-dev.yml` (the two now
share one `TRUNK_EXCLUDED_WORKFLOWS` list in `init-workspace.sh`), with
the recipe dropped from the trunk `justfile.gh`; part of the `release`
    feature group
- The scaffold `release-core.yml` now gates on `prepare-changelog
validate
    --version` (content, not just the `## [X.Y.Z] - TBD` heading), so a
    seeded-but-unfilled hotfix section cannot ship downstream
  - `zizmor.yml` baselines the managed basename for `github-app`,
    `secrets-inherit` and `unpinned-images` only; consumer runbook in
    `docs/DOWNSTREAM_RELEASE.md` (Hotfix lane)

## Testing

- [x] Tests pass locally (`just test`)
- [x] Manual testing performed (describe below)

### Manual Testing Details

- `uv run pytest tests/test_workflow_prepare_hotfix.py
tests/test_workflow_model.py tests/test_workflow_zizmor_baseline.py
tests/test_workflow_prepare_extension.py tests/test_promote_release.py
tests/test_promote_latest_guard.py`: 148 passed. The new cases were RED
before the scaffold file landed (commit 564ebad).
- Full suite: 1608 passed, 1 skipped. Excluded: 201 errors in
`test_image.py` / `test_integration.py` / `test_install_script.py` (no
local `ghcr.io/vig-os/devcontainer:dev` image, environmental) and 4
`packages/vig-utils` CLI e2e cases that fail only under the Nix
devshell's `PYTHONPATH` (store build shadows the venv; 143 passed with
`PYTHONPATH` unset). The one real red,
`test_renovate_preset_managed_exclusion`, caught the new lane missing
from the preset's disabled list — fixed in commit 32cbfa1.
- `just precommit` (`prek run --all-files`): green.
- zizmor over `assets/workspace/.github/workflows/` with the shipped
baseline: the only unsuppressed findings are `self-repository` (an audit
newer than the CI-pinned 1.25.2) and they hit every existing managed
workflow identically, so the new lane adds nothing against the baseline.
CI's pinned run is the authority.
- Smoke-test rehearsal on `devkit-smoke-test` (prepare → fix PR →
candidate → abandon) is post-merge: it needs a devkit release to ship
the asset and `devkit-upgrade` to adopt it. Tracked on #1625.

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have updated the documentation accordingly (edit
`docs/templates/`, then run `just docs`)
- [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and
pasted the entry above)
- [x] My changes generate no new warnings or errors
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published (#1630, #1631
pending)

## Additional Notes

Acceptance criteria not closable in this PR: the smoke-test rehearsal
(see Testing).

Refs: #1625
@c-vigo
c-vigo enabled auto-merge September 14, 2026 14:26
@c-vigo
c-vigo merged commit 7dab755 into dev Sep 14, 2026
13 checks passed
@c-vigo
c-vigo deleted the feature/1626-promote-latest-guard branch September 14, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant