Skip to content

Separate metadata and archive hash policies - #21549

Merged
charliermarsh merged 7 commits into
mainfrom
charlie/separate-metadata-hash-policy
Sep 10, 2026
Merged

charliermarsh merged 7 commits into
mainfrom
charlie/separate-metadata-hash-policy

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Summary

HashPolicy currently carries both resolution-wide hash collection settings and requirements for a specific archive. We split those into MetadataHashPolicy, with collection and validation fields, and ArchiveHashPolicy, which describes the hashes an archive must provide.

The distribution database selects the archive policy. Expected hashes continue to take precedence over collection.

Preparation for #21279, which adds URL-hash reuse on top of this refactor.

@charliermarsh
charliermarsh added this pull request to stack #21550 September 9, 2026 00:40
@charliermarsh
charliermarsh force-pushed the charlie/separate-metadata-hash-policy branch from f8a2d37 to 58f33c1 Compare September 9, 2026 00:47
@charliermarsh
charliermarsh force-pushed the charlie/separate-metadata-hash-policy branch from 58f33c1 to 9f01084 Compare September 9, 2026 00:50
@charliermarsh
charliermarsh force-pushed the charlie/separate-metadata-hash-policy branch from 9f01084 to 651738f Compare September 9, 2026 01:10
@charliermarsh charliermarsh changed the title Separate metadata hash collection from archive hashing Separate metadata and archive hash requests Sep 9, 2026
@charliermarsh
charliermarsh force-pushed the charlie/separate-metadata-hash-policy branch from 651738f to 41dda0e Compare September 9, 2026 01:18
@charliermarsh
charliermarsh requested a review from zanieb September 9, 2026 01:20
@charliermarsh charliermarsh added the internal A refactor or improvement that is not user-facing label Sep 9, 2026
/// The context in which hashes should be generated.
/// Hash requirements accompanying a distribution metadata lookup.
///
/// These concern the distribution archive, not a hash of the metadata.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you commenting on the way it's phrased, or the actual content of what it's saying?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry just driving by randomly at night... uhh I'm confused that it says this on the MetadataHashRequest and don't understand what it means in that context

@astral-sh-bot

astral-sh-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the main base revision.

  • Added tests: 1
  • Removed tests: 1
  • Changed suites: 1
uv-types: +1 / -1

Added:

  • uv-types::hash::tests::required_hashes_take_precedence_over_collection

Removed:

  • uv-types::hash::tests::required_hashes_take_precedence_over_generation

@charliermarsh
charliermarsh force-pushed the charlie/separate-metadata-hash-policy branch from 41dda0e to dcd65a2 Compare September 9, 2026 01:48
@EliteTK
EliteTK self-requested a review September 9, 2026 21:34

@EliteTK EliteTK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe if the naming was "...Policy" rather than "...Request" then this would be better. I still think this stuff is confusing, but I'd say that this does seem like somewhat of an improvement.

I haven't seen the follow up PR yet so this stuff might make more sense later.

Comment thread crates/uv-distribution-types/src/hash.rs Outdated
Comment thread crates/uv-distribution/src/source/validated_archive.rs Outdated
Comment thread crates/uv-types/src/hash.rs Outdated
Comment thread crates/uv-types/src/hash.rs Outdated
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct MetadataHashRequest<'a> {
/// Which missing hashes to collect for the resolution.
pub collection: Option<HashCollection>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-existing: It feels kind of weird that we have some things with ::None variants and here HashCollection doesn't and ends up in an Option.

@charliermarsh
charliermarsh force-pushed the charlie/separate-metadata-hash-policy branch from dcd65a2 to 1e491b4 Compare September 10, 2026 00:34
@charliermarsh charliermarsh changed the title Separate metadata and archive hash requests Separate metadata and archive hash policies Sep 10, 2026
@charliermarsh
charliermarsh merged commit cf68824 into main Sep 10, 2026
60 checks passed
@charliermarsh
charliermarsh deleted the charlie/separate-metadata-hash-policy branch September 10, 2026 01:16

This branch was previously deployed

1 inactive deployment
automations — 1e491b46 Deployed Sep 10, 2026 by charliermarsh via review / security review #46233
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants