Repository navigation
feat!: prefer the highest eligible version across registries - #631
Conversation
zeroshade
left a comment
There was a problem hiding this comment.
The overall design holds up: signers are checked first, then the highest version wins among registries with the same signer, and lock entries replay from their recorded registry. A few things need addressing before this lands:
-
One equal-precedence pair breaks the whole driver.
registryVersionschecks every record of a driver in a registry, including old and ineligible versions, and errors on any two with the same SemVer precedence, including the same version split across two records. One bad historical record in a third-party registry then makes every version of that driver unresolvable through the CLI, whileDriver.GetPackagestill accepts it. It also contradicts #630, whosepackageForVersionand "split records" test treat split records as valid. Either reject only among eligible candidates (or only the winner), or drop split-record support in #630 so the two agree. -
Overriding by registry priority no longer works. A user who put a same-signer private registry first to override a driver (the #360 use case) now gets the public build whenever it has a higher version. The docs describe the new rule, but the release notes should tell those users to set
sourceinstead; today their only signal is the stderr warning, which appears only when an index fails to load. -
Build-metadata constraints now fail at load time.
decodeHTTPSourcesrunsParseRegistryConstrainton every registry driver whendbc.tomlis loaded, so a file containingversion = '=1.0.0+build'fails every command, includingdbc syncreplaying a still-valid lock, not just new resolutions. Please confirm that's intended, or move the check to resolution time. -
A vanished locked version is handled differently depending on
platforms. Withplatformsdeclared, any exact-pin miss, including the locked version disappearing from the index (ErrExactVersionMissing), now re-resolves to a new version with only a warning. Withoutplatforms, the same situation is an error. Previously re-resolution happened only when the locked version didn't cover the declared platforms. Either keep it to that case or make both paths behave the same. -
dbc.Indexaliases an internal generic type. It renders in godoc as*registryindex.Snapshot[Driver], and code outside the module can't construct one, so driver authors can't test againstSelectRegistrywithout a live client. Fine if deliberate, but please call it out in the description.
…ingle-driver lookups
Equal-precedence or duplicated records used to make a driver unresolvable even when they belonged to old or ineligible versions. Selection now picks the winner from eligible records first and rejects only ambiguity in the winning registry: another eligible record of the same precedence, or another record of the same full version. Exact requests keep versions that differ only in build metadata apart. A version 1 lock entry whose recorded version is gone now stops the migration whether or not platforms are declared; re-resolution remains only for a recorded version that lacks builds for the declared platforms.
de2969f to
dac05d7
Compare
|
zeroshade
left a comment
There was a problem hiding this comment.
Thanks, all earlier points are addressed. Ambiguity is now checked only in the winning registry (duplicate of the winning full version, or another eligible record of equal precedence), which matches #630 reading only the selected record. A vanished v1 pin now stops with recovery steps regardless of platforms, with re-resolution limited to ErrRequiredTargets. Load-time rejection of build-metadata constraints and the Index alias are reasonable as explained.
Two minor inline notes, neither blocking.
| if exact == nil { | ||
| return nil | ||
| } | ||
| seen := make(map[*Registry]bool) |
There was a problem hiding this comment.
Nit: the exact-miss duplicate check keys on the *Registry pointer, which assumes every driver entry from one registry shares the same pointer in the snapshot. True today, but worth a comment or keying on the registry identity.
| exact := dbc.Request{Name: name, Exact: pin, Targets: req.Targets} | ||
| selected, err = dbc.SelectRegistry(op, index, exact) | ||
| if errors.Is(err, resolution.ErrExactVersionMissing) { | ||
| err = fmt.Errorf("driver %s: version %s recorded in the version 1 lock file was not found in the available registry indexes (%w); "+ |
There was a problem hiding this comment.
Nit: wrapping the miss repeats the version, roughly "version X recorded in the version 1 lock file was not found ... (version X not found for driver foo)". Harmless.
Follow-up to #631, which added resolve warnings to Go and npm-wasm. - **C API.** When `dbc_resolve` succeeds after skipping an unavailable same-signer index, callers can read the warning with `dbc_list_info(result, DBC_FIELD_WARNING)`. - **Rust.** `ResolveResult::warning` exposes the same field as an `Option<String>`. The existing `#[non_exhaustive]` annotation permits this addition.
) Follow-up announced in #631. `SelectRegistry` matches exact requests by the full version string. `Driver.GetPackage` matched by SemVer precedence, so a request for `1.0.0+b` could return `1.0.0+a`. - **`GetPackage`.** An explicit version now requires an exact match, including build metadata. Requesting `1.0.0` returns `ErrPackageMiss` if the index lists only `1.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 unlike `GetWithConstraint` it does not fall back to an older version that has the build. - **Other Go APIs.** `GetWithConstraint` is deprecated in favor of `SelectRegistry` and keeps its v0.3.1 behavior. This PR removes the unreleased `GetLatestPackage` and `GetLatestVersionAnyPlatform` methods. - **CLI.** Lock completion still uses the full version recorded in the lock file. It now relies on `GetPackage` for the exact match and drops the `withExactVersion` workaround. The exact lookups share `resolution.SameVersion`.
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).
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-indexdoes 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.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.platforms. A recorded version that lacks a build for a declared platform is still resolved again.Client.FetchIndex,Client.FetchRegistryIndex, andSelectRegistryreplaceSigningOperation.ResolvePackage. Requests take a constraint or an exact version. The project planner decides whether to keep a locked version.Indexaliases 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 throughNewClientwithWithRegistriesandWithHTTPClient.Resolvereports the highest eligible stable version aslatestand lists versions for the requested platform across reachable same-signer registries, including prereleases. Go and npm-wasm expose skipped indexes inwarning. C and Rust warning support follows in feat: expose resolve warnings in C and Rust #633.Client.FetchRegistryIndexrequires exactly one configured endpoint match before fetching. This prevents it from picking a signing policy by list order whenWithRegistrieslists the same endpoint under different policies.The released
Drivermethods remain single-driver lookups. #634 alignsGetPackagewith exact version matching and deprecatesGetWithConstraint.