Skip to content

feat(promote): guard promotion against diverged environments - #102

Merged
joshua-temple merged 2 commits into
mainfrom
feat/hotfix-promotion-guards
Jun 11, 2026
Merged

joshua-temple merged 2 commits into
mainfrom
feat/hotfix-promotion-guards

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem

When an environment is pinned to an integration branch carrying out-of-band patches, its recorded SHA is not on trunk. Promotion copies SHAs between env states blindly, so today a diverged env can leak a non-trunk SHA upward, reach the publish path, or be overwritten by an incoming SHA that silently regresses a fix deployed into it.

Fix

Three additive preflight guards, surfaced through the promote preflight so the generated workflow fails before deploy rather than mid-run:

  1. Refuse promotion FROM a diverged env. Both default and cascade modes block with an error that names the env, its integration branch, and the carried patches, plus the escape hatches.
  2. Promotion INTO a diverged env requires the incoming SHA to contain every recorded patch, verified with git ancestry. The existing force flag overrides with a loud warning naming the regressed patch.
  3. Publish-path assertion: the SHA reaching publish (env mode and library/CLI mode) must come from a non-diverged source.

Every guard fires only when divergence fields are present, so a manifest with none exercises zero new code paths. The git-ancestry checker is injected through a functional option (WithAncestorFunc), keeping required inputs positional and making the patch-containment rule deterministically testable.

Verification

  • go build ./...
  • go test ./internal/promote/... ./internal/orchestrate/... (140 pass)
  • go test ./... (1076 pass)
  • go test -race ./internal/promote/...
  • go vet ./internal/promote/...
  • golangci-lint run ./internal/promote/...

All green. Existing promote and preflight tests untouched and passing.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
Add three additive preflight guards for hotfix divergence:
refuse promotion from a diverged env, require the incoming SHA to
contain every recorded patch when promoting into a diverged env
(force overrides with a loud warning), and assert the publish path
never sources from a diverged env. Guards fire only when divergence
fields are present, so manifests without them are unaffected. The
git-ancestry checker is injected via a functional option.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit d4b780f into main Jun 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant