Repository navigation
Conversation
950a438 to
45a2f93
Compare
45a2f93 to
67d98bb
Compare
480a990 to
8c43163
Compare
9e0833d to
eb3a02d
Compare
6911491 to
a916ce9
Compare
a916ce9 to
96332c7
Compare
Merging this PR will not alter performance
|
| let mut dynamic = | ||
| match StaticMetadata::read(source, source_dist_entry.path(), subdirectory).await? { | ||
| StaticMetadata::Some(metadata) => { | ||
| return Ok(ArchiveMetadata { |
There was a problem hiding this comment.
[P2] Reauthorize backend-generated source metadata
An authority-enabled backend can write a complete PKG-INFO into this source tree during metadata preparation. If a later invocation uses the same authority key but the catalog no longer admits one of that backend’s build dependencies, uv pip compile can still accept the generated metadata here: url_revision() reauthorizes only the source archive, and this return bypasses read_authority_receipt(). The authority namespace isolates ordinary builds but remains mutable across authorized builds. Restrict this shortcut to metadata from a pristine verified extraction, or track and reauthorize the workspace’s build inputs before consuming generated metadata. Cover this transition with a backend that writes PKG-INFO and a subsequent catalog missing its build dependency.
| let (revision, _source_is_pristine) = self | ||
| .url_revision(source, ext, url, index, source_cache_shard, hashes, client) | ||
| .await?; |
There was a problem hiding this comment.
[P2] Authorize cached source workspaces before building wheels
url() discards the pristine-source flag and reuses any existing source directory when no wheel is cached. Unlike url_metadata(), this path never reauthorizes the workspace’s previous build inputs. For example, an authority-enabled uv lock can run a metadata backend that generates source files and changes subsequent build requirements. If its original build dependency is later removed from the catalog, uv sync --frozen reaches this path directly and can build from those generated files; the new receipt then omits that dependency. Before rebuilding, restore a pristine verified extraction or reauthorize evidence covering the existing workspace. Share this policy with the metadata path, and cover the lock-to-frozen-sync transition in the existing authority tests.
| if let Some(authority) = client.checksum_authority() { | ||
| // Unversioned namespaces can contain outputs from shared mutable source workspaces. | ||
| shard.shard(format!("authority-v2-{}", authority.public_key())) |
There was a problem hiding this comment.
[P2] Update package cache cleanup for authority settings shards
For a direct-URL sdist built with authority mode and --config-settings, metadata now lives at <revision>/authority-v2-<key>/<settings>/metadata.msgpack. However, CacheBucket::remove identifies these packages using is_match, whose traversal stops at .max_depth(2). If no ordinary or default-settings build exists, uv cache clean <package> therefore leaves the source revision and built wheels cached. Extend that lookup to recognize the authority namespace while retaining the src exclusion, and cover this layout in the existing cache-clean tests.
| )); | ||
| let mut hasher = Sha256::new(); | ||
| let mut remaining = record.size(); | ||
| while let Some(chunk) = body.chunk().await? { |
There was a problem hiding this comment.
[P3] Distinguish archive-transfer failures from authority failures
If the package download times out or its connection breaks, this ? converts the body error into Error::Http, displayed as Checksum authority request failed. The authority lookup and signature verification have already succeeded; the failing response comes from the package index or CDN. This misleading context directs troubleshooting toward the wrong service. Map archive-body failures to a separate error variant carrying the artifact identity and original cause, reserving the authority-request diagnostic for lookup failures.
| if hash_policy == ArchiveHashPolicy::Generate | ||
| || self.client.unmanaged.has_checksum_authority() | ||
| { | ||
| let wheel = self.get_wheel(dist, hash_policy).await?; |
There was a problem hiding this comment.
[P3] Guard the public metadata API in authority mode
This branch protects DistributionDatabase callers, but an authority-configured RegistryClient still exposes wheel_metadata(), which can return cached, PEP 658, or range-read metadata without consulting the authority. The current CLI route is checked, but other consumers must remember this external routing rule to uphold the configured policy. Add a guard rejecting unverified remote metadata reads in RegistryClient::wheel_metadata() when authority mode is enabled, or route that method through verified archive handling. The existing database path can continue providing cache reuse.
| write_atomic(metadata_entry.path(), rmp_serde::to_vec(&metadata)?) | ||
| .await | ||
| .map_err(Error::CacheWrite)?; | ||
| let _ = write_authority_receipt(client.unmanaged, &metadata_entry).await?; |
There was a problem hiding this comment.
[P3] Reuse the receipt-aware metadata writer
This wheel-build path duplicates the metadata-and-receipt write sequence now owned by CachedMetadata::write, which all four writes in url_metadata() use. Maintaining both implementations makes changes to metadata persistence or receipt handling liable to diverge between wheel builds and metadata preparation. Replace this sequence with CachedMetadata::write(&metadata, &metadata_entry, client.unmanaged).await? so both paths share the same persistence policy.
| { | ||
| remote.push(dist.clone()); | ||
| continue; |
There was a problem hiding this comment.
[P2] Preserve authority identity across in-memory cache hits
Routing into remote does not guarantee authority verification: Preparer::get_wheel first checks in_flight.downloads, keyed by distribution_id(). For registry files, that ID is the first index-advertised hash, without the source or filename. A build dependency admitted from index A can therefore populate shared state that satisfies a later requirement from index B with the same name, version, and hash, without checking B's admission. The resolver metadata cache uses the same identity and can bypass its lookup too. Include the authority artifact identity in these cache keys, or reauthorize the requested identity before accepting either shortcut.
Ad hoc dependency resolution learns expected archive hashes from the package index itself, which leaves no independent check if that index is compromised. Add an optional checksum authority that signs explicitly admitted archive sizes and SHA-256 digests, identified by source and distribution filename.
uvverifies those records with a separately configured Ed25519 public key and checks complete archive bytes before extraction, while retaining existing lockfile and requirements hash checks.The new
uv-checksum-authority-servicecrate provides a read-only Rust server and commands to generate a key and admit local archives. Authority mode reads metadata from complete verified wheels and reuses cached archives whose computed hashes and sizes match the authority. Source-build outputs are isolated by verification key and carry receipts that bind their bytes to the archive authorizations observed during the build. The crate README describes the protocol, configuration, and verification policy.