feat(state): scoped state serializer preserving sibling components on concurrent writes - #508
Merged
Merged
Conversation
… concurrent writes Add WriteScopedState, which node-patches only the addressed (component, env) leaf and preserves every sibling subtree as a verbatim YAML node, so a concurrent finalizer cannot drop another component's state. Reimplement WriteManifestState as a delete-aware single-component wrapper (reconcile to the map: patch present keys, delete keys present in the fetched bytes but absent from the map) so the publish transition still drops the prerelease marker and single-component output stays byte-identical. Widen the reserved ComponentState to the full EnvState the lifecycle needs. Refs #282. Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
…State CodeQL go/allocation-size-overflow flagged the len(state)+1 make capacity. The delete loop and latest write append past that hint regardless, so size the slice to len(state) and drop the arithmetic. Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
This was referenced Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Multi-component state must let each component's finalizer write its own
(component, env)state without dropping a sibling component's state under concurrency. Today the wholestatenode is replaced from a typed map, so a writer that does not model a sibling would erase it.Fix
WriteScopedState: node-patches only the addressed(component, env)leaf (state.components.<name>.<env>, a fullEnvState) and preserves every sibling subtree as a verbatim YAML node. On a 409,CommitWithRetryre-applies against re-fetched bytes and the node-disjoint leaf write gives sibling survival.WriteManifestStateas a delete-aware single-component wrapper: reconcile to the map (patch present keys, emit an explicit node delete for keys present in the fetched bytes but absent from the map, pluslatest_releasewhen nil). This keeps the publish transition dropping theprereleasemarker and single-component output byte-identical.ComponentStateto the fullEnvStatethe lifecycle needs.Single-component behavior is byte-identical. Per-component workflow generation and the release shape land in #283.
Verification
go build ./...,go test ./...(2554 pass),go test ./... -race(2554 pass),golangci-lint run ./...clean. A publish-delete byte-identical test fails against a naive patch-only wrapper and passes with the delete-aware one; a concurrent two-component finalize test asserts neither loses state.Refs #282.