Repository navigation
fix!: match exact driver package versions including build metadata - #634
Conversation
zeroshade
left a comment
There was a problem hiding this comment.
The change itself looks correct: removing GetLatestPackage/GetLatestVersionAnyPlatform breaks nothing released (v0.3.0 only shipped GetWithConstraint and GetPackage), tie detection handles a higher later version correctly, and removing withExactVersion is safe since every CLI call site passes the full version recorded in the lock file. A few comments:
-
GetPackagebehaves differently in two ways, and it shipped in v0.3.0.GetPackage(1.0.0)now misses when the index only lists1.0.0+a, andGetPackage(nil)now errors when the highest version appears twice with different build metadata (it used to pick one silently). Thefix!title signals the break, but the release notes should spell out both cases for Go API users. -
Split records now get three different answers. With 2.0.0 listed in two records,
GetPackage(2.0.0)errors with "more than one record",SelectRegistry(#631) rejects the whole driver, and only the deprecatedGetWithConstraintstill combines both records throughpackageForVersion(#630). That leaves the multi-record scan added in #630 reachable only from a deprecated function. This is the same question as point 1 on #631: please settle one policy there, then either remove the scan frompackageForVersionor keep it deliberately. -
The replacement for the deprecated function behaves differently.
GetWithConstraint(nil, p)falls back to an older version that has a build forp;GetPackage(nil, p, false)picks the highest version first and fails if it lacksp(pinned byTestDriverGetPackageLatestChecksPlatformAfterVersion). Ties also differ: first record with a build vs. an error. The deprecation note points toSelectRegistry, which is fine, but one sentence in theGetPackagedoc comment would stop callers from assuming it's a drop-in replacement. -
Stacking: this sits on #633 → #631, which has changes requested, so it may need a rebase once those land.
GetPackage, the artifact collection of the lock planner, and the host build check now share resolution.SameVersion. The GetPackage doc tells how it differs from GetWithConstraint. A version 1 migration records all published artifacts of the exact version it keeps.
0ccb684 to
f1036fb
Compare
|
zeroshade
left a comment
There was a problem hiding this comment.
Thanks, the earlier points are addressed. Builds come from a single record across #630/#631/#634, the GetPackage doc now says how it differs from GetWithConstraint and points to SelectRegistry, and the two GetPackage breaks (exact match including build metadata; tie at the highest precedence with a nil version) are covered by TestDriverGetPackageVersionIdentity. Removing withExactVersion is safe: every CLI call site passes the full version from the lock file, and SameVersion is now the single comparison.
Two minor doc notes inline, neither blocking. Please do spell out both GetPackage changes in the 0.4.0 notes for Go API users.
| } | ||
|
|
||
| // GetLatestPackage returns the newest compatible package for the given platform. | ||
| // This lookup uses only this Driver and performs no signer checks. It accepts |
There was a problem hiding this comment.
Nit: "It accepts constraints containing build metadata" reads as if the metadata is honoured, but TestDriverGetPackageVersionIdentity pins that =1.0.0+a returns 1.0.0+b. Maybe "accepts ... but compares only SemVer precedence, so build metadata does not select a record".
| return d.packageForVersion(pkg, target, platformTuple) | ||
| } | ||
|
|
||
| // MaxVersion returns the record with the highest SemVer precedence, or false |
There was a problem hiding this comment.
Nit: MaxVersion (used by dbc info) takes the first record on a tie, while GetPackage(nil, ...) now errors on the same tie. Documented, so fine, but dbc info can show a version that GetPackage refuses as ambiguous.
dbc used registry priority for overrides (#360), and #584 kept that order when choosing the first registry with a matching version. This gave order precedence over version, much as uv's default `first-index` does to limit dependency confusion. The review of per-registry signing keys (#595) showed that registry order could also determine the signer, so #601 made cross-signer name collisions an error during implicit resolution. Within that signer boundary, dbc now picks the highest eligible version across registries, as pip does across indexes, so drivers keep getting updates after moving to another registry. - **Selection.** A candidate must satisfy the version requirements and have builds for every required target in one record. Registry order breaks ties at the highest SemVer precedence. In the winning registry, a second eligible record of the same precedence or any duplicate of the winning full version is an error. Exact requests include build metadata and reject duplicate exact records even when none covers all required targets. Errors in a selected artifact stop resolution. - **CLI.** New resolutions can select a newer version from a lower-priority registry. To take a driver from a specific registry, set its `source`. Compatible lock entries still replay from their recorded source. Successful CLI selections warn on stderr when a same-signer index was skipped. Registry version constraints now reject build metadata. - **v1 lock files.** If the recorded version is no longer listed, migration stops with or without `platforms`. A recorded version that lacks a build for a declared platform is still resolved again. - **Go API.** `Client.FetchIndex`, `Client.FetchRegistryIndex`, and `SelectRegistry` replace `SigningOperation.ResolvePackage`. Requests take a constraint or an exact version. The project planner decides whether to keep a locked version. `Index` aliases an internal type so public callers get complete snapshots from the client and cannot pass filtered search results; tests outside the module can serve an index through `NewClient` with `WithRegistries` and `WithHTTPClient`. - **Bindings.** `Resolve` reports the highest eligible stable version as `latest` and lists versions for the requested platform across reachable same-signer registries, including prereleases. Go and npm-wasm expose skipped indexes in `warning`. C and Rust warning support follows in #633. `Client.FetchRegistryIndex` requires exactly one configured endpoint match before fetching. This prevents it from picking a signing policy by list order when `WithRegistries` lists the same endpoint under different policies. The released `Driver` methods remain single-driver lookups. #634 aligns `GetPackage` with exact version matching and deprecates `GetWithConstraint`.
Follow-ups to the non-blocking review notes on #630, #631, #634 and #635. `dbc sync` saves the lock file before installing. It already warned on install failure, but could exit without a warning after Ctrl-C or SIGINT. It now warns once on stderr if it saved the lock file and installation did not finish or could not be confirmed. On an install error, the warning asks you to fix it and rerun `dbc sync`. On interruption, it says installation "may be incomplete" and asks you to rerun, since the last install may have finished before sync received its result. Both warnings say the lock file "has been saved" to avoid implying that its contents changed. SIGINT stops the CLI program without canceling sync's worker context. On exit, sync prevents a preparation worker from starting a lock-file write and waits for any write already in progress before deciding whether to warn. Smaller follow-ups: - Call `Target.PlatformTuple()` directly (#630). - Explain why the ambiguity check uses registry pointers to distinguish configurations that share a URL (#631). - Clarify that `GetWithConstraint` ignores build metadata when selecting a record (#634).
Follow-up announced in #631.
SelectRegistrymatches exact requests by the full version string.Driver.GetPackagematched by SemVer precedence, so a request for1.0.0+bcould return1.0.0+a.GetPackage. An explicit version now requires an exact match, including build metadata. Requesting1.0.0returnsErrPackageMissif the index lists only1.0.0+a. It reports an ambiguity error for duplicate records of the requested version or, with a nil version, for a tie at the highest eligible SemVer precedence. With a nil version it still picks the highest version before checking the platform, so unlikeGetWithConstraintit does not fall back to an older version that has the build.GetWithConstraintis deprecated in favor ofSelectRegistryand keeps its v0.3.1 behavior. This PR removes the unreleasedGetLatestPackageandGetLatestVersionAnyPlatformmethods.GetPackagefor the exact match and drops thewithExactVersionworkaround. The exact lookups shareresolution.SameVersion.