Skip to content

feat!: prefer the highest eligible version across registries - #631

Merged
eitsupi merged 3 commits into
fix/platform-alias-lookupfrom
feat/version-first-resolution
Dec 2, 2026
Merged

eitsupi merged 3 commits into
fix/platform-alias-lookupfrom
feat/version-first-resolution

Conversation

@eitsupi

@eitsupi eitsupi commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

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 feat: expose resolve warnings in C and Rust #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.

@eitsupi
eitsupi added this pull request to stack #632 December 1, 2026 01:50
@eitsupi eitsupi changed the title feat: select the highest eligible driver version across registries feat!: prefer the highest eligible version across registries Dec 1, 2026
@eitsupi
eitsupi marked this pull request as ready for review December 1, 2026 02:26

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. One equal-precedence pair breaks the whole driver. registryVersions checks 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, while Driver.GetPackage still accepts it. It also contradicts #630, whose packageForVersion and "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.

  2. 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 source instead; today their only signal is the stderr warning, which appears only when an index fails to load.

  3. Build-metadata constraints now fail at load time. decodeHTTPSources runs ParseRegistryConstraint on every registry driver when dbc.toml is loaded, so a file containing version = '=1.0.0+build' fails every command, including dbc sync replaying a still-valid lock, not just new resolutions. Please confirm that's intended, or move the check to resolution time.

  4. A vanished locked version is handled differently depending on platforms. With platforms declared, any exact-pin miss, including the locked version disappearing from the index (ErrExactVersionMissing), now re-resolves to a new version with only a warning. Without platforms, 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.

  5. dbc.Index aliases 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 against SelectRegistry without a live client. Fine if deliberate, but please call it out in the description.

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.
@eitsupi

eitsupi commented Dec 1, 2026 •

Copy link
Copy Markdown
Member Author
  1. Agreed, that was too strict. Selection now checks ties in the winning registry after filtering, so duplicates among older, ineligible, or losing versions no longer matter. A duplicate of the winning full version is an error even if one copy lacks a required target. Exact requests distinguish metadata variants and reject duplicate exact records when no copy covers the targets. fix: consistently match platforms by canonical target #630 reads only the selected record, since one record can already list every platform.
  2. Project registry configuration from feat(registry): configurable driver registries via TOML config #360 has never been released. The docs now show how to select a registry with source. With built-in registries or Go's WithRegistries, the change from v0.3.1 is that a newer eligible version can win over the first match.
  3. Intentional. v0.3.1 accepted =1.0.0+build as a constraint but also matched 1.0.0+other, so the metadata could not select a variant. Validating at load time gives every command the same rule regardless of the lock file. The error suggests =1.0.0. Full versions in the lock file can still include build metadata.
  4. A missing recorded version now stops v1 migration with or without platforms. Automatic re-resolution is reserved for a recorded version that lacks builds for declared targets. The error gives recovery steps. feat: add driver upgrades to lock and sync #635 adds dbc lock --upgrade-driver NAME to that guidance.
  5. The client supplies registry order and partial fetch failures for signer checks. External tests can use NewClient with WithRegistries and WithHTTPClient, backed by an httptest server or a stub transport serving index.yaml. The GoDoc and PR description cover this.

@eitsupi
eitsupi requested a review from zeroshade December 1, 2026 23:13

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread registry_selection.go
if exact == nil {
return nil
}
seen := make(map[*Registry]bool)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cmd/dbc/sync_plan.go
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); "+

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@eitsupi
eitsupi merged commit d064944 into main Dec 2, 2026
52 of 62 checks passed
@eitsupi
eitsupi deleted the feat/version-first-resolution branch December 2, 2026 23:22
eitsupi added a commit that referenced this pull request Dec 2, 2026
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.
eitsupi added a commit that referenced this pull request Dec 2, 2026
)

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`.
eitsupi added a commit that referenced this pull request Dec 4, 2026
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).

This branch was previously deployed

1 inactive deployment
snapshot — dac05d75 Deployed Dec 1, 2026 by eitsupi via snapshot #1435
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants