uv
e3f345ce - Validate lockfile (rather than re-resolve) in `uv lock` (#6091)

Comment changes are shownComment changes are hidden
Commit
324 days ago
Validate lockfile (rather than re-resolve) in `uv lock` (#6091) ## Summary Historically, in order to "resolve from a lockfile", we've taken the lockfile, used it to pre-populate the in-memory metadata index, then run a resolution. If the resolution didn't match our existing resolution, we re-resolved from scratch. This was an appealing approach because (in theory) it didn't require any dedicated logic beyond pre-populating the index. However, it's proven to be _really_ hard to get right, because it's a stricter requirement than we need. We just need the current lockfile to _satisfy_ the requirements provided by the user. We don't actually need a second resolution to produce the exact same result. And it's not uncommon that this second resolution differs, because we seed it with preferences, which fundamentally changes its course. We've worked hard to minimize those "instabilities", but they're still present. The approach here is intended to be much simpler. Instead of resolving from the lockfile, we just check if the current resolution satisfies the state of the workspace. Specifically, we check if the lockfile (1) contains all the relevant members, and (2) matches the metadata for all dependencies, recursively. (We skip registry dependencies, assuming that they're immutable.) This may actually be too conservative, since we can have resolutions that satisfy the requirements, even if the requirements have changed slightly. But we want to bias towards correctness for now. My hope is that this scheme will be more performant, simpler, and more robust. Closes https://github.com/astral-sh/uv/issues/6063.
Author
Parents
  • crates
    • pypi-types/src
      • File
        requirement.rs
    • uv-resolver/src
      • File
        lib.rs
      • File
        lock.rs
      • resolver
        • File
          mod.rs
      • snapshots
        • uv_resolver__lock__tests__hash_optional_missing.snap
        • uv_resolver__lock__tests__hash_optional_present.snap
        • uv_resolver__lock__tests__hash_required_present.snap
        • uv_resolver__lock__tests__missing_dependency_source_unambiguous.snap
        • uv_resolver__lock__tests__missing_dependency_source_version_unambiguous.snap
        • uv_resolver__lock__tests__missing_dependency_version_unambiguous.snap
        • uv_resolver__lock__tests__source_direct_has_subdir.snap
        • uv_resolver__lock__tests__source_direct_no_subdir.snap
        • uv_resolver__lock__tests__source_directory.snap
        • uv_resolver__lock__tests__source_editable.snap
    • uv
      • src
        • commands/project
          • File
            lock.rs
          • File
            mod.rs
        • File
          lib.rs
      • tests
        • File
          branching_urls.rs
        • File
          edit.rs
        • File
          lock.rs
        • File
          lock_scenarios.rs
        • snapshots
          • ecosystem__black-lock-file.snap
          • ecosystem__github-wikidata-bot-lock-file.snap
          • ecosystem__home-assistant-core-lock-file.snap
          • ecosystem__packse-lock-file.snap
          • ecosystem__transformers-lock-file.snap
          • ecosystem__warehouse-lock-file.snap
        • File
          sync.rs
        • File
          workspace.rs
  • scripts/scenarios/templates
    • File
      lock.mustache
Loading