Skip to content

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

Merged
charliermarsh merged 4 commits intomainfrom
charlie/val
Aug 15, 2024
Merged

Validate lockfile (rather than re-resolve) in uv lock#6091
charliermarsh merged 4 commits intomainfrom
charlie/val

Conversation

@charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Aug 14, 2024

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 #6063.

Loading
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 lock Related to universal resolution and locking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv lock sometimes changes the lock file when run for a second time

3 participants