← Back to Pull requests

Retain configuration provenance in hash and index diagnostics #2326

Open
zaniebot opened this pull request with 1555 lines diff across 35 files
View on GitHub
zaniebot zaniebot commented on Oct 07, 2026 20:15 UTC
Author

--require-hashes and --no-index failures can be caused by configuration or nested requirements directives whose origins are lost during settings resolution. Introduce Sourced<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/uv#22275, so included constraints retain both their policy and its source.

Diff: 1555 lines (+1413 / -142) across 35 files Reviewer: woodruffw Review duration: 80169m
All Vouch review confidence checks passed
Residual risk 0.10 = Change Risk (0.96) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.96 · 1555 lines diff across 35 files
0.96
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.93 · 5 substantive comment(s)
0.93
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
90%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.400
Sensitive Paths sensitive_paths
0.096
Mass File Touch mass_file_touch
0.080
Real PR Conversation Timeline
12 items
astral-automations-bot[bot] astral-automations-bot[bot] commented on code on Oct 07, 2026 20:21 UTC
Code Review
crates/uv-requirements-txt/src/lib.rs:1
@@ -477,6 +485,13 @@ impl RequirementsTxt {
                     for constraint in sub_constraints.constraints {
                         data.constraints.push(constraint);
                     }
+                    sub_constraints
+                        .require_hashes
+                        .included_by(&RequirementsLocation {
+                            input: requirements_txt.clone(),
+                            line: calculate_row_column(content, start).0,
+                        });
+                    data.require_hashes = data.require_hashes.or(sub_constraints.require_hashes);

[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.

codspeed[bot] codspeed[bot] commented on Oct 07, 2026 21:58 UTC
Bot

<!-- __CODSPEED_PERFORMANCE_REPORT_COMMENT__ -->

Merging this PR will improve performance by 16.3%

<details>
<summary>:warning: <b>8 benchmarks spent significant time in system calls</b></summary>

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

> Measurement and system calls

> - ` discover_workspace_from_all_members_with_excludes

- discover_workspace_from_all_members

- resolve_warm_airflow

- install_wheel_many_files

- run_python_version_synthetic_workspace

- resolve_warm_jupyter_universal

- unpack_sdist_many_files

- resolve_warm_jupyter

</details>
<details>
<summary>:warning: <b>Different runtime environments detected</b></summary>

Some benchmarks with significant performance changes were compared across different runtime environments,

which may affect the accuracy of the results.

> Open the report in CodSpeed to investigate

</details>

⚡ 1 improved benchmark
✅ 68 untouched benchmarks
⏩ 35 skipped benchmarks[^skipped]

Performance Changes

| | Mode | Benchmark | BASE | HEAD | Efficiency |
| --- | ---- | --------- | ------ | ------ | ---------- |
| ⚡ :warning: | 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.

---

<sub>Comparing <code>zb/configuration-provenance</code> (a0081fb) with <code>main</code> (64e2ac8)</sub>

<a href="https://app.codspeed.io/astral-sh/uv-dev/branches/zb%2Fconfiguration-provenance?utm_source=github&utm_medium=comment-v2&utm_content=button">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://codspeed.io/pr-report/open-in-codspeed-dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://codspeed.io/pr-report/open-in-codspeed-light.svg">
<img alt="Open in CodSpeed" src="https://codspeed.io/pr-report/open-in-codspeed-light.svg" width="169" height="32">
</picture>
</a>

[^skipped]: 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.

woodruffw woodruffw commented on code on Oct 08, 2026 14:38 UTC
Code Review
crates/uv-cli/src/options.rs:1
@@ -57,6 +63,80 @@ pub(crate) fn flag(yes: bool, no: bool, name: &str) -> anyhow::Result<Option<boo
     }
 }
 
+impl Args for HashCheckingArgs {
+    fn augment_args(command: Command) -> Command {
+        HashCheckingOptions::augment_args(command)
+    }
+
+    fn augment_args_for_update(command: Command) -> Command {
+        HashCheckingOptions::augment_args_for_update(command)
+    }
+}
+
+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| {

I don't know how I'd improve this necessarily, but flagging that it's pretty hard to read.

woodruffw woodruffw commented on code on Oct 08, 2026 14:43 UTC
Code Review
crates/uv-cli/src/options.rs:1
@@ -57,6 +63,80 @@ pub(crate) fn flag(yes: bool, no: bool, name: &str) -> anyhow::Result<Option<boo
     }
 }
 
+impl Args for HashCheckingArgs {
+    fn augment_args(command: Command) -> Command {
+        HashCheckingOptions::augment_args(command)
+    }
+
+    fn augment_args_for_update(command: Command) -> Command {
+        HashCheckingOptions::augment_args_for_update(command)
+    }
+}
+
+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| {

(Also FWICT any hints here get dropped anyways in enabled_hints?)

woodruffw woodruffw commented on code on Oct 08, 2026 14:44 UTC
Code Review
crates/uv-types/src/hash.rs:1
@@ -68,9 +72,29 @@ impl HashStrategy {
     /// Preserve hash collection and require hashes if either strategy requires them. Constraints
     /// for identities absent from this strategy remain available for newly resolved dependencies.
     pub fn with_constraint_hashes(mut self, constraints: &Self) -> Result<Self, HashStrategyError> {
+        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 {

I think these two match statements could be merged for clarity.

woodruffw woodruffw commented on code on Oct 08, 2026 14:45 UTC
Code Review
crates/uv-requirements-txt/src/lib.rs:1
@@ -477,6 +485,13 @@ impl RequirementsTxt {
                     for constraint in sub_constraints.constraints {
                         data.constraints.push(constraint);
                     }
+                    sub_constraints
+                        .require_hashes
+                        .included_by(&RequirementsLocation {
+                            input: requirements_txt.clone(),
+                            line: calculate_row_column(content, start).0,
+                        });
+                    data.require_hashes = data.require_hashes.or(sub_constraints.require_hashes);

I also noticed this during review, I think I agree that it'd be best as a separate PR.

astral-automations-bot[bot] astral-automations-bot[bot] commented on code on Oct 08, 2026 20:18 UTC
Code Review
crates/uv-distribution-types/src/setting.rs:1
@@ -0,0 +1,266 @@
+#[cfg(feature = "schemars")]
+use std::borrow::Cow;
+use std::fmt;
+use std::hash::{Hash, Hasher};
+
+#[cfg(feature = "schemars")]
+use schemars::{JsonSchema, Schema, SchemaGenerator};
+use serde::{Deserialize, Serialize};
+
+use crate::RequirementsInput;
+
+/// A setting and the declarations responsible for its effective value.
+///
+/// Sources are diagnostic metadata: serialization, equality, and hashing depend only on the value.
+/// Scalar precedence should select the entire setting, so a value cannot retain a shadowed source.
+#[derive(Clone, Default, Serialize, Deserialize)]
+#[serde(transparent)]
+pub struct Sourced<T> {
+    value: T,
+    #[serde(skip)]
+    sources: SettingSources,
+}
+
+impl<T> Sourced<T> {
+    pub fn new(value: T, source: SettingSource) -> Self {
+        Self {
+            value,
+            sources: SettingSources(Box::new([source])),
+        }
+    }
+
+    pub fn value(&self) -> &T {
+        &self.value
+    }
+
+    pub fn sources(&self) -> &SettingSources {
+        &self.sources
+    }
+
+    pub fn into_parts(self) -> (T, SettingSources) {
+        (self.value, self.sources)
+    }
+
+    #[must_use]
+    pub fn with_sources(mut self, sources: &SettingSources) -> Self {
+        self.sources.extend(sources);
+        self
+    }
+
+    pub fn map<U>(self, map: impl FnOnce(T) -> U) -> Sourced<U> {
+        Sourced {
+            value: map(self.value),
+            sources: self.sources,
+        }
+    }
+
+    /// Associate a deserialized setting with its configuration file and key.
+    pub fn set_source(&mut self, source: SettingSource) {
+        self.sources = SettingSources(Box::new([source]));
+    }
+
+    /// Record the parent input through which a requirements directive was reached.
+    pub fn included_by(&mut self, location: &RequirementsLocation) {
+        for source in &mut self.sources.0 {
+            if let SettingSource::Requirements { included_by, .. } = source {
+                included_by.push(location.clone());
+            }
+        }
+    }
+}
+
+impl Sourced<bool> {
+    /// Enable a cumulative flag if either input enables it, retaining every enabling declaration.
+    #[must_use]
+    pub fn or(mut self, other: Self) -> Self {
+        if !self.value {
+            return other;
+        }
+        if other.value {
+            self.sources.extend(&other.sources);
+        }
+        self
+    }
+}
+
+impl<T> From<T> for Sourced<T> {
+    fn from(value: T) -> Self {
+        Self {
+            value,
+            sources: SettingSources::default(),
+        }
+    }
+}
+
+impl<T: fmt::Debug> fmt::Debug for Sourced<T> {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        // Sources are exposed separately so settings dumps focus on effective values.
+        self.value.fmt(f)
+    }
+}
+
+impl<T: PartialEq> PartialEq for Sourced<T> {
+    fn eq(&self, other: &Self) -> bool {
+        self.value == other.value
+    }
+}
+
+impl<T: Eq> Eq for Sourced<T> {}
+
+impl<T: Hash> Hash for Sourced<T> {
+    fn hash<H: Hasher>(&self, state: &mut H) {
+        self.value.hash(state);
+    }
+}
+
+#[cfg(feature = "schemars")]
+impl<T: JsonSchema> JsonSchema for Sourced<T> {
+    fn inline_schema() -> bool {
+        T::inline_schema()
+    }
+
+    fn schema_name() -> Cow<'static, str> {
+        T::schema_name()
+    }
+
+    fn schema_id() -> Cow<'static, str> {
+        T::schema_id()
+    }
+
+    fn json_schema(generator: &mut SchemaGenerator) -> Schema {
+        T::json_schema(generator)
+    }
+
+    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()

[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.

astral-automations-bot[bot] astral-automations-bot[bot] commented on code on Oct 09, 2026 15:42 UTC
Code Review
crates/uv/tests/pip_install/configuration_provenance.rs:1
@@ -0,0 +1,361 @@
+use anyhow::Result;
+use assert_fs::prelude::*;
+use indoc::indoc;
+
+use uv_static::EnvVars;
+use uv_test::uv_snapshot;
+
+/// Distinguish an environment value from the same value supplied explicitly on the command line.
+#[test]
+fn hash_environment() {
+    let context = uv_test::test_context!("3.12");
+
+    uv_snapshot!(context.pip_install()
+        .arg("iniconfig")
+        .env(EnvVars::UV_REQUIRE_HASHES, "1"), @"
+    exit_code: 2 (failure)
+    ----- stderr -----
+    error: In `--require-hashes` mode, all requirements must have their versions pinned with `==`, but found: iniconfig
+
+    hint: `--require-hashes` was enabled by environment variable `UV_REQUIRE_HASHES`
+    ");
+
+    uv_snapshot!(context.pip_install()
+        .arg("iniconfig")
+        .arg("--require-hashes")
+        .env(EnvVars::UV_REQUIRE_HASHES, "1"), @"
+    exit_code: 2 (failure)
+    ----- stderr -----
+    error: In `--require-hashes` mode, all requirements must have their versions pinned with `==`, but found: iniconfig
+    ");
+
+    // Clap rejects this combination before settings are resolved.
+    uv_snapshot!(context.pip_install()
+        .arg("iniconfig")
+        .arg("--no-require-hashes")
+        .arg("--no-index")
+        .env(EnvVars::UV_REQUIRE_HASHES, "1"), @"
+    exit_code: 2 (failure)
+    ----- stderr -----
+    error: the argument '--no-require-hashes' cannot be used with '--require-hashes'
+
+    Usage: uv pip install --cache-dir [CACHE_DIR] --no-index --exclude-newer <EXCLUDE_NEWER> <PACKAGE|--requirements <REQUIREMENTS>|--editable <EDITABLE>|--group <GROUP>>
+
+    For more information, try '--help'.
+    ");
+}
+
+/// A false environment flag does not override configuration, but a negated CLI flag does.
+#[test]
+fn hash_explicit_configuration() -> Result<()> {
+    let context = uv_test::test_context!("3.12");
+    context.temp_dir.child("policy.toml").write_str(indoc! {r"
+        no-index = true
+        [pip]
+        require-hashes = true
+    "})?;
+
+    uv_snapshot!(context.pip_install()
+        .arg("iniconfig")
+        .arg("--config-file")
+        .arg("policy.toml")
+        .env(EnvVars::UV_REQUIRE_HASHES, "0"), @"
+    exit_code: 2 (failure)
+    ----- stderr -----
+    error: In `--require-hashes` mode, all requirements must have their versions pinned with `==`, but found: iniconfig
+
+    hint: `--require-hashes` was enabled by `pip.require-hashes` in `policy.toml`
+    ");
+
+    uv_snapshot!(context.pip_install()
+        .arg("iniconfig")
+        .arg("--config-file")
+        .arg("policy.toml")
+        .arg("--no-require-hashes"), @"
+    exit_code: 1 (failure)
+    ----- stderr -----
+    error: No solution found when resolving dependencies
+      cause: Because iniconfig was not found in the provided package locations and you require iniconfig, we can conclude that your requirements are unsatisfiable.
+
+    hint: Packages were unavailable because index lookups were disabled and no additional package locations were provided (try: `--find-links <uri>`)
+
+    hint: `--no-index` was enabled by `no-index` in `policy.toml`
+    ");
+
+    Ok(())
+}
+
+/// A project setting retains its fully qualified TOML key.
+#[test]
+fn hash_pyproject_configuration() -> Result<()> {
+    let context = uv_test::test_context!("3.12");
+    context
+        .temp_dir
+        .child("pyproject.toml")
+        .write_str(indoc! {r"
+        [tool.uv.pip]
+        require-hashes = true
+    "})?;
+
+    uv_snapshot!(context.pip_install().arg("iniconfig"), @"
+    exit_code: 2 (failure)
+    ----- stderr -----
+    error: In `--require-hashes` mode, all requirements must have their versions pinned with `==`, but found: iniconfig
+
+    hint: `--require-hashes` was enabled by `tool.uv.pip.require-hashes` in `pyproject.toml`
+    ");
+    Ok(())
+}
+
+/// Requirements directives accumulate independently of the effective scalar setting.
+#[test]
+fn hash_configuration_and_requirements() -> Result<()> {
+    let context = uv_test::test_context!("3.12");
+    context.temp_dir.child("uv.toml").write_str(indoc! {r"
+        [pip]
+        require-hashes = true
+    "})?;
+    context
+        .temp_dir
+        .child("requirements.txt")
+        .write_str(indoc! {r"
+        # All requirements need hashes.
+        --require-hashes
+        iniconfig
+    "})?;
+
+    uv_snapshot!(context.pip_install().arg("-r").arg("requirements.txt"), @"
+    exit_code: 2 (failure)
+    ----- stderr -----
+    error: In `--require-hashes` mode, all requirements must have their versions pinned with `==`, but found: iniconfig
+
+    hint: `--require-hashes` was enabled by `pip.require-hashes` in `uv.toml`
+
+    hint: `--require-hashes` was enabled by `requirements.txt` at line 2
+    ");
+    uv_snapshot!(context.pip_install().arg("-r").arg("requirements.txt")
+        .arg("--no-require-hashes"), @"
+    exit_code: 2 (failure)
+    ----- stderr -----
+    error: In `--require-hashes` mode, all requirements must have their versions pinned with `==`, but found: iniconfig
+
+    hint: `--require-hashes` was enabled by `requirements.txt` at line 2
+    ");
+    Ok(())
+}
+
+/// A winning false value must discard the source of the shadowed true value.
+#[test]
+#[cfg_attr(
+    windows,
+    ignore = "Configuration tests are not yet supported on Windows"
+)]
+fn hash_configuration_precedence() -> Result<()> {
+    let context = uv_test::test_context!("3.12");
+    let xdg = context.temp_dir.child("config");
+    xdg.child("uv/uv.toml").write_str(indoc! {r"
+        [pip]
+        require-hashes = true
+    "})?;
+    context.temp_dir.child("uv.toml").write_str(indoc! {r"
+        no-index = true
+        [pip]
+        require-hashes = false
+    "})?;
+
+    uv_snapshot!(context.pip_install().arg("iniconfig")
+        .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @"
+    exit_code: 1 (failure)
+    ----- stderr -----
+    error: No solution found when resolving dependencies
+      cause: Because iniconfig was not found in the provided package locations and you require iniconfig, we can conclude that your requirements are unsatisfiable.
+
+    hint: Packages were unavailable because index lookups were disabled and no additional package locations were provided (try: `--find-links <uri>`)
+
+    hint: `--no-index` was enabled by `no-index` in `uv.toml`
+    ");
+
+    context
+        .temp_dir
+        .child("uv.toml")
+        .write_str("no-index = true")?;
+    uv_snapshot!(context.pip_install().arg("iniconfig")
+        .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @"
+    exit_code: 2 (failure)
+    ----- stderr -----
+    error: In `--require-hashes` mode, all requirements must have their versions pinned with `==`, but found: iniconfig
+
+    hint: `--require-hashes` was enabled by `pip.require-hashes` in `config/uv/uv.toml`
+    ");
+    Ok(())
+}
+
+/// Source information survives initial hash collection and reaches transitive resolution errors.
+#[test]
+fn hash_transitive_requirement() -> Result<()> {
+    let context = uv_test::test_context!("3.12");
+    context.temp_dir.child("requirements.txt").write_str(indoc! {r"
+        -r policy.txt
+        werkzeug==3.0.0 --hash=sha256:cbb2600f7eabe51dbc0502f58be0b3e1b96b893b05695ea2b35b43d4de2d9962
+    "})?;
+    context
+        .temp_dir
+        .child("policy.txt")
+        .write_str("--require-hashes")?;
+
+    uv_snapshot!(context.pip_install().arg("-r").arg("requirements.txt"), @"
+    exit_code: 1 (failure)
+    ----- stderr -----
+    error: In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: `markupsafe`
+
+    hint: `--require-hashes` was enabled by `policy.txt` at line 1 (included from `requirements.txt` at line 1)
+    ");
+    Ok(())
+}
+
+/// Both pip entry points retain environment provenance.
+#[test]
+fn hash_sync_environment() -> Result<()> {
+    let context = uv_test::test_context!("3.12");
+    context
+        .temp_dir
+        .child("requirements.txt")
+        .write_str("iniconfig")?;
+
+    uv_snapshot!(context.pip_sync().arg("requirements.txt")
+        .env(EnvVars::UV_REQUIRE_HASHES, "1"), @"
+    exit_code: 2 (failure)
+    ----- stderr -----
+    error: In `--require-hashes` mode, all requirements must have their versions pinned with `==`, but found: iniconfig
+
+    hint: `--require-hashes` was enabled by environment variable `UV_REQUIRE_HASHES`
+    ");
+    Ok(())
+}
+
+/// Report all enabling declarations and their include sites, without repeating a visited input.
+#[test]
+fn no_index_nested_requirements() -> Result<()> {
+    let context = uv_test::test_context!("3.12");
+    context
+        .temp_dir
+        .child("requirements.txt")
+        .write_str(indoc! {r"
+        -r nested/first.txt
+        -r nested/second.txt
+        -r nested/first.txt
+        iniconfig
+    "})?;
+    context
+        .temp_dir
+        .child("nested/first.txt")
+        .write_str(indoc! {r"
+        # Use local packages.
+        --no-index
+    "})?;
+    context
+        .temp_dir
+        .child("nested/second.txt")
+        .write_str("--no-index")?;
+
+    uv_snapshot!(context.pip_install().arg("-r").arg("requirements.txt"), @"
+    exit_code: 1 (failure)
+    ----- stderr -----
+    error: No solution found when resolving dependencies
+      cause: Because iniconfig was not found in the provided package locations and you require iniconfig, we can conclude that your requirements are unsatisfiable.
+
+    hint: Packages were unavailable because index lookups were disabled and no additional package locations were provided (try: `--find-links <uri>`)
+
+    hint: `--no-index` was enabled by `nested/first.txt` at line 2 (included from `requirements.txt` at line 1)
+
+    hint: `--no-index` was enabled by `nested/second.txt` at line 1 (included from `requirements.txt` at line 2)
+    ");
+
+    context.temp_dir.child("wheels").create_dir_all()?;
+    uv_snapshot!(context.pip_install().arg("-r").arg("requirements.txt")
+        .arg("--find-links").arg("wheels"), @"
+    exit_code: 1 (failure)
+    ----- stderr -----
+    error: No solution found when resolving dependencies
+      cause: Because iniconfig was not found in the provided package locations and you require iniconfig, we can conclude that your requirements are unsatisfiable.
+
+    hint: `--no-index` was enabled by `nested/first.txt` at line 2 (included from `requirements.txt` at line 1)
+
+    hint: `--no-index` was enabled by `nested/second.txt` at line 1 (included from `requirements.txt` at line 2)
+    ");
+    Ok(())
+}
+
+/// Pip configuration takes precedence over the top-level setting, including its source.
+#[test]
+fn no_index_configuration() -> Result<()> {
+    let context = uv_test::test_context!("3.12");
+    context.temp_dir.child("uv.toml").write_str(indoc! {r"
+        no-index = true
+        [pip]
+        no-index = true
+    "})?;
+
+    uv_snapshot!(context.pip_install().arg("iniconfig"), @"
+    exit_code: 1 (failure)
+    ----- stderr -----
+    error: No solution found when resolving dependencies
+      cause: Because iniconfig was not found in the provided package locations and you require iniconfig, we can conclude that your requirements are unsatisfiable.
+
+    hint: Packages were unavailable because index lookups were disabled and no additional package locations were provided (try: `--find-links <uri>`)
+
+    hint: `--no-index` was enabled by `pip.no-index` in `uv.toml`
+    ");
+
+    context.temp_dir.child("uv.toml").write_str(indoc! {r"
+        no-index = true
+        [pip]
+        no-index = false
+    "})?;
+
+    uv_snapshot!(context.pip_install().arg("iniconfig==2.0.0").arg("--dry-run"), @"
+    exit_code: 0 (success)
+    ----- stderr -----
+    Resolved 1 package in [TIME]
+    Would download 1 package
+    Would install 1 package
+     + iniconfig==2.0.0
+    ");
+    Ok(())
+}
+
+/// Inline script configuration retains its input and TOML key.
+#[test]
+fn no_index_script_configuration() -> Result<()> {
+    let context = uv_test::test_context!("3.12");
+    context.temp_dir.child("script.py").write_str(indoc! {r#"
+        # /// script
+        # dependencies = ["iniconfig"]
+        # [tool.uv]
+        # no-index = true
+        # ///
+    "#})?;
+
+    uv_snapshot!(context.pip_install().arg("-r").arg("script.py"), @"
+    exit_code: 1 (failure)
+    ----- stderr -----
+    error: No solution found when resolving dependencies
+      cause: Because iniconfig was not found in the provided package locations and you require iniconfig, we can conclude that your requirements are unsatisfiable.
+
+    hint: Packages were unavailable because index lookups were disabled and no additional package locations were provided (try: `--find-links <uri>`)
+
+    hint: `--no-index` was enabled by `tool.uv.no-index` in `script.py`
+    ");
+
+    uv_snapshot!(context.run().arg("script.py"), @"

[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.

astral-automations-bot[bot] astral-automations-bot[bot] commented on code on Oct 09, 2026 18:13 UTC
Code Review
crates/uv/src/commands/diagnostics.rs:1
@@ -36,6 +36,7 @@ pub(crate) fn hints_for_error(err: &anyhow::Error) -> Hints<'static> {
         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);

[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.

astral-automations-bot[bot] astral-automations-bot[bot] commented on code on Oct 12, 2026 09:03 UTC
Code Review
crates/uv-settings/src/lib.rs:1
@@ -237,7 +243,7 @@ fn read_file(path: &Path) -> Result<Options, Error> {
     } else {
         options
     };
-    Ok(options)
+    Ok(options.with_config_source(&path.into(), ""))

[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.

astral-automations-bot[bot] astral-automations-bot[bot] commented on code on Oct 13, 2026 16:55 UTC
Code Review
crates/uv-resolver/src/error.rs:1
@@ -903,10 +907,30 @@ impl std::error::Error for NoSolutionError {}
 
 impl uv_errors::Hinted for NoSolutionError {
     fn hints(&self) -> uv_errors::Hints<'_> {
-        self.pubgrub_hints()
+        let mut hints: uv_errors::Hints<'_> = self
+            .pubgrub_hints()
             .iter()
             .map(ToString::to_string)
-            .collect()
+            .collect();
+        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)
+                    )
+                })
+        {

[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.

Reviewers
Assignees
zaniebot zaniebot
Labels
risk: low confidence: 90% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 96% (HIGH) · Higher = larger blast radius
96%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 90% · Lower = rushed or shallow review
90%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 9.6% · Safe to merge
9.6%