Repository navigation
Conversation
| input: requirements_txt.clone(), | ||
| line: calculate_row_column(content, start).0, | ||
| }); | ||
| data.require_hashes = data.require_hashes.or(sub_constraints.require_hashes); |
There was a problem hiding this comment.
[P3] Separate nested-constraint enforcement from provenance tracking
This also changes which inputs enable hash enforcement. With requirements.txt containing -c policy.txt and an unhashed pinned requirement, --require-hashes in policy.txt now makes install/sync fail; the base implementation only merged constraint entries here. The new nested-constraint tests therefore cover a policy change as well as diagnostics. Move this enforcement change and its regression tests into a separate preparatory fix so its compatibility implications can be reviewed independently of the provenance plumbing.
There was a problem hiding this comment.
I also noticed this during review, I think I agree that it'd be best as a separate PR.
Merging this PR will improve performance by 16.3%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ |
Simulation | discover_workspace_from_all_members_with_excludes |
165.6 ms | 142.4 ms | +16.3% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing zb/configuration-provenance (a0081fb) with main (64e2ac8)
Footnotes
-
35 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
9cee94d to
0513d82
Compare
0513d82 to
bdb3364
Compare
| impl FromArgMatches for HashCheckingArgs { | ||
| fn from_arg_matches(matches: &ArgMatches) -> Result<Self, clap::Error> { | ||
| let args = HashCheckingOptions::from_arg_matches(matches)?; | ||
| let setting = |yes, no, name, yes_id, no_id, yes_flag, no_flag| { |
There was a problem hiding this comment.
I don't know how I'd improve this necessarily, but flagging that it's pretty hard to read.
There was a problem hiding this comment.
(Also FWICT any hints here get dropped anyways in enabled_hints?)
| let sources = match (&self.verification, &constraints.verification) { | ||
| ( | ||
| HashVerification::Required(_), | ||
| HashVerification::None | HashVerification::IfPresent(_), | ||
| ) => self.verification_sources.clone(), | ||
| ( | ||
| HashVerification::None | HashVerification::IfPresent(_), | ||
| HashVerification::Required(_), | ||
| ) => constraints.verification_sources.clone(), | ||
| (HashVerification::Required(_), HashVerification::Required(_)) | ||
| | ( | ||
| HashVerification::None | HashVerification::IfPresent(_), | ||
| HashVerification::None | HashVerification::IfPresent(_), | ||
| ) => { | ||
| let mut sources = self.verification_sources.clone(); | ||
| sources.extend(&constraints.verification_sources); | ||
| sources | ||
| } | ||
| }; | ||
| let (requirement_hashes, mode) = match &self.verification { |
There was a problem hiding this comment.
I think these two match statements could be merged for clarity.
| input: requirements_txt.clone(), | ||
| line: calculate_row_column(content, start).0, | ||
| }); | ||
| data.require_hashes = data.require_hashes.or(sub_constraints.require_hashes); |
There was a problem hiding this comment.
I also noticed this during review, I think I agree that it'd be best as a separate PR.
| fn _schemars_private_non_optional_json_schema(generator: &mut SchemaGenerator) -> Schema { | ||
| T::_schemars_private_non_optional_json_schema(generator) | ||
| } | ||
|
|
||
| fn _schemars_private_is_option() -> bool { | ||
| T::_schemars_private_is_option() |
There was a problem hiding this comment.
[P3] Derive the transparent schema instead of forwarding private hooks
This implementation delegates every schema method to T, including _schemars_private_* hooks. A feature-gated JsonSchema derive with transparent schema behavior handles the single non-skipped field, following the existing DisplaySafeUrl pattern in uv-redacted. Use that derive and retain #[serde(skip)] on sources; this preserves the value-only schema while avoiding handwritten coupling to schemars internals.
cb26d9e to
f998a7c
Compare
| hint: `--no-index` was enabled by `tool.uv.no-index` in `script.py` | ||
| "); | ||
|
|
||
| uv_snapshot!(context.run().arg("script.py"), @" |
There was a problem hiding this comment.
[P3] Put command-specific regressions in their existing test suites
This uv run scenario and hash_sync_environment are registered under the pip_install test target, so focused runs of the existing run and pip_sync suites miss their new provenance coverage. The script test also combines two independent command paths. Move this invocation into a separately named test in crates/uv/tests/project/run.rs, and move the sync case into crates/uv/tests/pip/pip_sync.rs, alongside their existing script-configuration and hash-checking tests.
7b88ba8 to
40ce712
Compare
| collect_hint::<uv_lock_operations::LockError>(cause, &mut hints); | ||
| collect_hint::<uv_resolve_operations::Error>(cause, &mut hints); | ||
| collect_hint::<uv_install_operations::Error>(cause, &mut hints); | ||
| collect_hint::<uv_types::HashStrategyError>(cause, &mut hints); |
There was a problem hiding this comment.
[P2] Update the existing nested-constraints snapshot
Collecting these hints also changes install_require_hashes_in_nested_constraints_txt in crates/uv/tests/pip_install/pip_install.rs. Its fixture enables hash checking through -c constraints.txt, so it now emits the hint identifying constraints.txt at line 1, included from requirements.txt at line 1. The existing snapshot still expects only the error and will no longer match. Update that snapshot alongside the new provenance tests.
5f0aeaa to
75da088
Compare
| options | ||
| }; | ||
| Ok(options) | ||
| Ok(options.with_config_source(&path.into(), "")) |
There was a problem hiding this comment.
[P3] Keep filesystem configuration sources explicitly local
From<&Path> interprets the literal path - as RequirementsInput::Stdin, but read_file reads it as an ordinary file. Consequently, --config-file - with pip.require-hashes = true attributes the resulting error to “script metadata read from stdin” instead of the configuration file. Construct RequirementsInput::Local(path.to_path_buf()) here so attaching provenance does not reinterpret the known filesystem source.
| if self.index_locations.no_index() | ||
| && derivation_tree_packages(&self.error) | ||
| .filter_map(PubGrubPackage::name_no_root) | ||
| .any(|name| { | ||
| matches!( | ||
| self.unavailable_packages.get(name), | ||
| Some(UnavailablePackage::NoIndex) | ||
| ) | ||
| }) | ||
| { |
There was a problem hiding this comment.
[P3] Generate provenance in the existing index-hint path
This introduces a second index-hint eligibility check over the unreduced error tree. The existing PubGrubReportFormatter::generate_hints uses the reduced tree and invokes index_hints for Custom/NoVersions incompatibilities; this pass also includes packages mentioned only in dependency edges. Attribution consequently follows different relevance rules, and future hint changes must maintain both paths. Generate a structured provenance hint in the existing UnavailablePackage::NoIndex handling, including its find-links branch, and leave this implementation responsible for rendering the collected hints.
75f3880 to
a0081fb
Compare
--require-hashesand--no-indexfailures can be caused by configuration or nested requirements directives whose origins are lost during settings resolution. IntroduceSourced<T>to carry effective source information into hash and resolver diagnostics, identifying environment variables, configuration keys, and requirements file line numbers and include chains.Scalar precedence retains the winning declaration, while cumulative flags retain every enabling declaration. Source metadata is excluded from value equality, hashing, serialization, and configuration schemas.
Includes the nested-constraints hash enforcement from astral-sh#22275, so included constraints retain both their policy and its source.