Skip to content

fix!: match exact driver package versions including build metadata - #634

Merged
eitsupi merged 2 commits into
feat/resolve-warning-capifrom
fix/exact-package-version
Dec 2, 2026
Merged

eitsupi merged 2 commits into
feat/resolve-warning-capifrom
fix/exact-package-version

Conversation

@eitsupi

@eitsupi eitsupi commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

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.

@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 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:

  1. GetPackage behaves differently in two ways, and it shipped in v0.3.0. GetPackage(1.0.0) now misses when the index only lists 1.0.0+a, and GetPackage(nil) now errors when the highest version appears twice with different build metadata (it used to pick one silently). The fix! title signals the break, but the release notes should spell out both cases for Go API users.

  2. 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 deprecated GetWithConstraint still combines both records through packageForVersion (#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 from packageForVersion or keep it deliberately.

  3. The replacement for the deprecated function behaves differently. GetWithConstraint(nil, p) falls back to an older version that has a build for p; GetPackage(nil, p, false) picks the highest version first and fails if it lacks p (pinned by TestDriverGetPackageLatestChecksPlatformAfterVersion). Ties also differ: first record with a build vs. an error. The deprecation note points to SelectRegistry, which is fine, but one sentence in the GetPackage doc comment would stop callers from assuming it's a drop-in replacement.

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

eitsupi commented Dec 1, 2026

Copy link
Copy Markdown
Member Author
  1. Agreed. If there is a blog post for 0.4.0, the Go API changes could get a short note there.
  2. A build comes from one record (fix: consistently match platforms by canonical target #630). GetPackage rejects duplicates of the requested full version, and SelectRegistry requires one record to cover every required build (feat!: prefer the highest eligible version across registries #631). The deprecated GetWithConstraint preserves its first eligible record on a tie for compatibility. None of them combine records.
  3. The GetPackage doc now says how it differs from GetWithConstraint and points constraint-based resolution to SelectRegistry.

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

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

Comment thread drivers.go
}

// GetLatestPackage returns the newest compatible package for the given platform.
// This lookup uses only this Driver and performs no signer checks. It accepts

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: "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".

Comment thread drivers.go
return d.packageForVersion(pkg, target, platformTuple)
}

// MaxVersion returns the record with the highest SemVer precedence, or false

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: 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.

@eitsupi
eitsupi merged commit a39c28c into main Dec 2, 2026
35 of 36 checks passed
@eitsupi
eitsupi deleted the fix/exact-package-version branch December 2, 2026 23:22
eitsupi added a commit that referenced this pull request Dec 2, 2026
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`.
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 — f1036fbd Deployed Dec 1, 2026 by eitsupi via snapshot #1432
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