Skip to content

fix: make hotfix finalize fully trunk-based (read and write)#206

Merged
joshua-temple merged 2 commits into
mainfrom
fix/hotfix-finalize-trunk-read
Jun 17, 2026
Merged

fix: make hotfix finalize fully trunk-based (read and write)#206
joshua-temple merged 2 commits into
mainfrom
fix/hotfix-finalize-trunk-read

Conversation

@joshua-temple

@joshua-temple joshua-temple commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Problem

Hotfix finalize was not trunk-based on either the read or the write side, and the write side caused data loss.

  • Read: finalize read the prior env state from the checked-out manifest. On the pull_request closed run that tree is the env branch, which lags trunk because promote writes env state only to trunk. The target env recorded a stale or absent state SHA, so finalize failed with "environment has no recorded state SHA".
  • Write: finalize then serialized the checked-out env-branch manifest and PUT it to trunk. The env-branch manifest lags trunk for every env (empty post-reset in a 3-env setup), so writing it to trunk wiped the non-target envs' recorded trunk state.

Fix

Finalize now treats the trunk manifest as the single source of truth for both halves:

  • It reads the trunk manifest once (Contents API on real GitHub, plain git under act/gitea).
  • It uses that trunk manifest as the write basis, mutates only state[targetEnv] with the hotfix result (merge SHA, version, patches, base SHA, substates), and writes that manifest back to trunk.
  • Every other env's recorded trunk state is preserved. The merged code SHAs still come from the --fix-sha/--base-sha/--merge-sha inputs.

Verification

  • TestFinalize_ReadsPriorStateFromTrunk / TestFinalize_TrunkIsSourceOfPriorState guard the read.
  • TestFinalize_DoesNotClobberOtherEnvsTrunkState guards the write: trunk has populated state for all envs while the env-branch manifest is stale/empty; after finalize, the target env is updated and the other envs retain their trunk SHAs. Red before the write-basis change, green after.
  • go build ./... && go test ./... (1412 passed) && golangci-lint run ./... (no issues). e2e module builds and vets clean.

Hotfix finalize read the prior environment state from the checked-out
manifest, which on the pull_request closed run is the env branch. Promote
finalize writes env state only to trunk, so the env branch lags trunk and
records a stale or absent state SHA, making finalize fail with
'environment has no recorded state SHA'.

Finalize now reads the prior state from the trunk manifest, resolving trunk
the same way the state write does. Reading goes through the Contents API on
real GitHub and plain git under act, mirroring the existing write seam.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
Finalize read prior env state from trunk but still wrote the checked-out
env-branch manifest to trunk. On the pull_request closed run the checked-out
tree is the env branch, whose state lags trunk because promote writes env
state only to trunk. Serializing that lagging manifest to trunk wiped the
non-target envs' recorded state.

Finalize now uses the trunk manifest as the write basis: it reads trunk once,
mutates only state[targetEnv] with the hotfix result, and writes that manifest
back to trunk. Every other env's trunk state is preserved. The single trunk
read feeds both the prior-state lookup and the write basis.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple joshua-temple changed the title fix: read hotfix finalize prior state from trunk fix: make hotfix finalize fully trunk-based (read and write) Jun 17, 2026
@joshua-temple joshua-temple merged commit e626958 into main Jun 17, 2026
7 checks passed
@joshua-temple joshua-temple deleted the fix/hotfix-finalize-trunk-read branch June 17, 2026 15:07
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