Skip to content

feat: lock a version without a build for the current platform - #607

Merged
eitsupi merged 3 commits into
mainfrom
feat/lock-without-host-build
Nov 24, 2026
Merged

eitsupi merged 3 commits into
mainfrom
feat/lock-without-host-build

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Part of #592. As noted in the review of #575, dbc lock required a build for the current platform, so a Linux CI runner could not lock a macOS-only driver.

If the selected version has no build for the current platform, dbc lock records builds with published archive hashes. It downloads no archives for other platforms and fails if it cannot record any. If an existing entry lacks an artifact for the current platform and the locked version has no build for it, dbc lock keeps the entry.

Version and registry selection remain independent of the current platform (#584). If the selected version lacks a build for that platform, dbc sync fails without switching versions or registries. Upgrading a v1 entry also fails if its library checksum was recorded for the current platform and there is no build to check it against.

#608 adds declared platforms to dbc.toml.

dbc lock installs nothing, so a selected version that has no build for
the current platform no longer stops it. The lock entry then records
the platforms whose archive hash the registry publishes; no archive of
another platform is downloaded, so a version without any published hash
still cannot be locked there. The version and registry are chosen as
before, without regard to platforms, and dbc sync on such a machine
still fails instead of choosing another version or registry.

A lock entry that has no artifact for the current platform is kept as
it is when the locked version has no build for it. A version 1 lock
checksum recorded for the current platform cannot be checked without
that build and is an error.

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

Looks good. The version is still chosen without regard to platforms, a missing host build is only accepted for a listed version that has packages (invalid metadata still fails), no archive of another platform is downloaded, and dbc sync keeps failing without switching versions or registries, since a platform miss is not ErrPackageMiss. The v1 checksum refusal is a good catch. go test ./cmd/dbc/ ./ passes on the head.

A few non-blocking notes inline.

Comment thread cmd/dbc/sync_plan.go
}
listed = true
for _, pkg := range info.Packages {
if pkg.Platform == platform {

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.

Non-blocking: this compares raw platform tuples, while lockArtifacts groups packages by resolution.CanonicalTarget (darwin→macos, aarch64→arm64, bare linux→gnu). For an index that lists only darwin_arm64 on a macos_arm64 host, this reports no host build, yet lockArtifacts records that package under the host's canonical target, so sync would replay it from the lock and the v1 proof check above would refuse needlessly. It matches GetPackage's exact matching today, but comparing canonical targets here would keep the two paths in agreement.

@eitsupi eitsupi Nov 24, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As commented in 3796761, this is intentional.
If only this check matched aliases, dbc lock would try to look up macos_arm64 in an index that only lists darwin_arm64, and GetPackage would fail.

I'll update both lookups to match aliases in a follow-up.

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.

Makes sense: matching aliases in only one of the two lookups would send GetPackage to a tuple the index lacks. Thanks for the comment and for pinning the v1-checksum case in TestPlanV1ProofWithAliasHostBuild. Looking forward to the follow-up that makes both lookups match aliases.

@eitsupi eitsupi Nov 24, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've opened #612

Comment thread cmd/dbc/sync_plan.go
if info.Version == nil {
return false
}
if info.Version.String() != v.String() {

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.

Non-blocking: GetPackage matches the version with Version.Equal (build metadata ignored); !info.Version.Equal(v) here would keep both lookups identical.

@eitsupi eitsupi Nov 24, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As commented in 3796761, this is intentional.
The lock records the version string including build metadata, and sync checks the package manifest against it.
This check matches the withExactVersion filter applied before calling GetPackage.

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.

Agreed, my suggestion was wrong here: the full spelling, build metadata included, is what the lock records and what sync checks the manifest against, and it matches withExactVersion. Thanks for adding the comment.

Comment thread cmd/dbc/lock.go Resolved
Comment thread cmd/dbc/sync_plan.go
@@ -390,7 +445,16 @@ func (p *syncPlanner) resolve(name string, spec driverSpec, pin *semver.Version,
return plannedDriver{}, err
}
pkg, err := dbc.ResolvePackage(drivers, name, func(candidate *dbc.Driver) (dbc.PkgInfo, error) {

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.

Heads-up: #601 adds an indexErr parameter to dbc.ResolvePackage, so whichever lands second needs a rebase here (passing the registry errors only when target == nil, as #601 does).

…form

Also explain in comments why hostBuildMissing compares the exact version
spelling and the raw platform tuple.
Also correct the comments of hostBuildMissing and pin the alias cases in
tests.
@eitsupi
eitsupi requested a review from zeroshade November 24, 2026 13:03
@eitsupi
eitsupi merged commit 913cb9f into main Nov 24, 2026
31 checks passed
@eitsupi
eitsupi deleted the feat/lock-without-host-build branch November 24, 2026 23:16
eitsupi added a commit that referenced this pull request Nov 24, 2026
Close #592, and the project-side answer to the first review point of
#584: instead of falling back to an older version that has a build for
the machine running the command, a project can declare the platforms its
drivers must support.

```toml
platforms = ["linux_amd64", "macos_arm64", "macos_amd64"]
```

- **Selection.** `dbc add`, `dbc lock` and `dbc sync` choose the newest
allowed version with a build for every listed platform, on every
machine. A missing build does not trigger registry fallback. If the
selected version lists more than one package for a listed platform that
needs an artifact, dbc reports an error instead of selecting an older
version. The list must contain at least one valid, distinct platform (an
alias such as `darwin_arm64` counts as a duplicate), and the current
platform is not added implicitly. `dbc sync` requires the current
platform to be listed.
- **Lockfile.** `dbc.lock` records the declaration and an artifact for
each listed platform. A listed platform is handled like the current one:
for a new artifact, dbc records the published hash when available, and
otherwise downloads the archive, checks it with the installation's
extraction safeguards, verifies its signature unless `--no-verify` is
set, and records the measured hash. Other platforms are still recorded
from published hashes.
- **Changes.** When the declaration is added or changed, dbc fills
missing listed platforms from the locked version and registry. If all
are already recorded, it skips the index. Extending an entry keeps every
recorded artifact, even if the registry no longer lists it. This follows
normal lock replay, much like [Cargo keeps using locked crates after a
yank](https://doc.rust-lang.org/cargo/commands/cargo-yank.html). If the
locked version lacks a build needed to extend the entry, dbc resolves
the driver again and warns if its version or registry changes.
Completion fails if the locked registry uses a query string or no longer
lists the driver. Removing the declaration returns to normal lock
replay.
- **Warnings.** `dbc lock` warns once when the current platform is not
listed, because `dbc sync` will refuse it. It also warns when a v1 pin
is dropped because its version lacks a listed platform, even if there
was no checksum.

**Without `platforms`,** the implicit platform means two different
things, on purpose:
- for version selection, no platform counts, so every machine resolves
the same version (#592);
- for what the lock records, the current platform is the one required
platform when the selected version has a build for it: its archive is
measured when no hash is published, as v1 lock files and #607 already
do, while other platforms are recorded from published hashes only.

Treating the undeclared case as "every platform" would download every
platform's archive to measure the hashes a registry does not publish;
treating it as "the current platform" for selection would make the
locked version depend on the machine. `dbc add` now also accepts a
version without a build for the current platform.

`dbc install`, `dbc search -v`, `dbc info` and `dbc list` ignore
`platforms`: `install` picks the newest version with a build for the
current platform (#584), `search -v` lists the versions available for
it, `info` shows the latest version's packages for every platform, and
`list` shows installed drivers.

This branch was previously deployed

1 inactive deployment
snapshot — 37967614 Deployed Nov 24, 2026 by eitsupi via snapshot #1348
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