Repository navigation
Separate hash generation policy from verification policy - #21247
Merged
Merged
Conversation
This was referenced Aug 20, 2026
zanieb
force-pushed
the
zb/source-hash-verification-policy
branch
from
August 20, 2026 21:46
c73a17d to
a084d2c
Compare
zanieb
force-pushed
the
zb/source-hash-verification-policy
branch
from
August 21, 2026 00:08
a084d2c to
9a42c8d
Compare
zanieb
marked this pull request as ready for review
August 21, 2026 00:50
charliermarsh
approved these changes
Aug 21, 2026
zanieb
force-pushed
the
zb/source-hash-verification-policy
branch
from
August 21, 2026 18:44
9a42c8d to
f533ba4
Compare
zanieb
force-pushed
the
zb/source-hash-verification-policy
branch
from
August 24, 2026 16:47
f533ba4 to
fda53d3
Compare
astral-automations-bot Bot
pushed a commit
to astral-sh/uv-dev
that referenced
this pull request
Aug 24, 2026
Source archive helpers currently extract an archive and save it to the cache in the same call. Separate those steps so the type system records that extraction and its existing checks have completed before persistence. Introduce a private `ValidatedSourceArchive` that owns the temporary directory. Its HTTP and local constructors retain their transport setup, diagnostics, and cleanup behavior, while a private reader helper performs the shared extraction and hash collection. The consuming `persist` method saves the source tree and returns the collected hashes and byte count. This preserves existing behavior; it does not add trusted-hash comparisons or change cache repair. astral-sh#21247 separates hash generation from verification, and astral-sh#21248 checks caller-supplied hashes before persistence.
zanieb
added a commit
that referenced
this pull request
Aug 27, 2026
Source archives can be saved to the cache before their caller-supplied hashes are checked. Cache repair can also save replacement contents before detecting a mismatch with the previous revision. Check supplied hashes alongside the existing download-size check in `ValidatedSourceArchive::extract`, before it returns the value consumed by `persist`. Check every digest from a previous revision there too, before a repaired source tree is saved. Extraction still streams into a private temporary directory and returns parser errors immediately. This also removes the split in persistence behavior captured by `ArchiveOrigin`. HTTP and local archives now accept `AlreadyExists` or `DirectoryNotEmpty` only when the destination is a directory, and both retain temporary-directory ownership through persistence. The HTTP path no longer calls `TempDir::keep` for archives with multiple top-level entries, so failed persistence attempts clean up those staged files too. HTTP response handling and local file opening remain separate, and cache locations and `rename_with_retry` are unchanged. The caller still supplies the hashes and any download size to check; this PR does not read trusted hashes from `uv.lock`. #21223 supplies the hashes recorded in an existing `uv.lock`. Based on #21247.
zanieb
added a commit
that referenced
this pull request
Sep 8, 2026
`uv.lock` records archive digests, but checking an existing lockfile or resolving with `--locked` can obtain source metadata without comparing those digests. A replaced source archive can therefore run its build backend before a later hash or lockfile check rejects it. Construct a `HashStrategy` from the existing lockfile's hashes for registry packages, direct URLs, and local archives. Enforce the recorded hashes when reusing cached source metadata, resolving with `--locked`, and installing build dependencies recorded in the lockfile into isolated build environments. Normalize equivalent archive subdirectories so they find the same recorded hashes. Keep recorded hashes while checking whether an existing lockfile is still usable, but allow unlocked fresh resolution to replace them. Build dependencies without recorded hashes remain allowed. Based on #21248, which checks source archives before saving them to the cache. #21246 contains the structural refactor, and #21247 separates hash generation from verification. --------- Co-authored-by: Zanie Blue <[email protected]> Co-authored-by: Tomasz Kramkowski <[email protected]> Co-authored-by: Charlie Marsh <[email protected]>
This branch was previously deployed
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.
HashStrategycurrently represents hash generation and verification as mutually exclusive choices. A resolution may need both: verify artifacts whose hashes have been supplied, while generating hashes for new artifacts.Store generation separately from
HashVerificationinHashStrategy. Each distribution still receives aHashPolicyspecifying whether to generate or check hashes. Update existing call sites to use the separate settings while preserving their hash inputs and which hashes uv treats as trusted. Generation remains available for artifacts without supplied hashes, unless the caller requires a hash for every artifact. This does not read hashes fromuv.lockor add new archive comparisons.Based on #21246. #21248 checks caller-supplied hashes before source archives enter the cache. #21223 reads hashes from an existing
uv.lockand supplies them for verification.