Skip to content

fix(statewrite): preserve unmodeled manifest config across state writes#371

Merged
joshua-temple merged 1 commit into
mainfrom
fix/statewrite-preserve-unmodeled-config
Jun 26, 2026
Merged

fix(statewrite): preserve unmodeled manifest config across state writes#371
joshua-temple merged 1 commit into
mainfrom
fix/statewrite-preserve-unmodeled-config

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem (#350)

Every state-write path (reset, rollback, promote, hotfix finalize) re-marshaled the typed CICDFile struct, silently dropping any manifest key the running binary does not model. config.drift_check and any unmodeled or future field were lost on a state write.

Fix

New internal/config helper WriteManifestState parses the manifest into a yaml.Node and replaces only the state and latest_release children, preserving config, unmodeled siblings/top-level keys, and comments verbatim. All six lossy sites route through it. The generated-workflow yq path was already byte-safe and is unchanged. No public schema change.

Tests

New internal/config/statemerge_test.go proves unmodeled top-level, config-level (drift_check shape), and nested keys survive a state write while stale state is cleared; reset_test.go asserts an unmodeled future_knob survives a reset. Full go test ./... 1955 pass; lint clean. Closes #350.

Every state-write path (reset, rollback, promote, hotfix finalize) loaded the manifest, mutated the typed CICDFile, and re-marshaled the whole struct, silently dropping any key the running binary does not model. config.drift_check and any unmodeled or future field were lost on a state write, exactly as #350 reported. Add a shared WriteManifestState helper that parses the manifest into a yaml.Node and replaces only the state and latest_release children, preserving config, unmodeled siblings, unmodeled top-level keys, and comments verbatim. Route all six lossy sites through it. No public schema change. Closes #350.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple joshua-temple force-pushed the fix/statewrite-preserve-unmodeled-config branch from d4f2a9c to 1fce499 Compare June 26, 2026 16:13
@joshua-temple joshua-temple enabled auto-merge (squash) June 26, 2026 16:14
@joshua-temple joshua-temple merged commit 3722c8e into main Jun 26, 2026
13 checks passed
joshua-temple added a commit that referenced this pull request Jun 27, 2026
…WriteManifestState (#389)

orchestrate writeConfig and external writeManifest re-marshaled the typed CICDFile, dropping any manifest config the running binary does not model (and writeConfig dropped the ci: wrapper). This is the last lossy state-write class after #350/#371: it strips cli_version_sha (added in #384) on the next state commit for a binary that predates it, leaving a pin_mode:sha repo with SHA-pinned workflows but a manifest that no longer declares the pin, which reads as permanent drift and would re-open the setup-cli code-scanning alerts. Route both writers through config.WriteManifestState so only state and latest_release change and all other config, modeled or not, survives verbatim. Closes #372.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
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.

State-write marshals only the typed struct, silently dropping unmodeled manifest config

1 participant