Cache-key hardening (full key + base image in key)#142
Draft
markovejnovic wants to merge 2 commits into
Draft
Conversation
Fold the step's `image` field into the outer SHA-256 pre-image so that the same command run on two different base images no longer collides on one cache entry. Image is inserted right after step_key, before parent_resolved_key, using the same NUL-delimited layout in both the Python and TypeScript implementations (byte-identical output for identical input). Pre-image layout (v0.1): pipeline_org NUL pipeline_slug NUL step_key NUL image NUL parent_resolved_key NUL policy_resolution This is a deliberate one-time cache invalidation: old snapshots keyed under the previous format will not be reachable after this change.
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.
Cache-key hardening
Two correctness/robustness fixes to the content-addressed layer cache key, in support of the cloud cross-build cache (harmont-dev/simci#91). No user-facing changes.
1.
hm-exec: use the full cache key in the docker tagstable_cache_tagtruncated the cache key to 16 hex chars (64 bits) when building the local Docker image tag. 64 bits is collision-feasible; the full SHA-256 is now used. (One-time effect: existing localhm runDocker-tag caches cold-rebuild once.)2.
keygen: include the base image in the layer cache keyA layer's output depends on the base image it ran on, but the image was not part of the cache key — so the same command on two different base images would collide on one cache entry (a real correctness bug). The image is now folded into the key pre-image, in both the Python and TypeScript DSLs with byte-identical layout (
… step_key NUL image NUL parent_resolved NUL policy_resolution). All formula/golden tests were recomputed to include the image slot. (One-time effect: cache keys change once, invalidating prior cached layers.)Tests