Skip to content

feat: add dbc sync --locked to install from the lockfile without updating it - #616

Open
eitsupi wants to merge 7 commits into
mainfrom
feat/sync-locked
Open

eitsupi wants to merge 7 commits into
mainfrom
feat/sync-locked

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Add dbc sync --locked for CI and other environments that need to install from a reviewed lockfile.

  • Locked install. It leaves the lockfile untouched and skips registry indexes. It reuses matching installed packages and downloads the recorded archives as needed.
  • Preflight checks. Before downloading drivers, it requires a v2 lockfile with the same drivers and declared platforms as the driver list. Each locked version must satisfy the current version and pre-release requirements and match any explicit registry source. The current platform must be declared if the list specifies platforms, and every entry must record an artifact for it.
  • Diagnostics. The preflight reports lock mismatches and trust problems together. Use dbc lock to create, migrate, or update the lockfile. If the configured registries or signing keys do not accept a locked entry, check the configuration first to preserve the existing pins.
  • Flag name. --locked follows the manifest-checking behavior of uv, Cargo, and Pixi. Their --frozen flags differ in how they handle manifest checks and network access.

Note: #621 adds HTTP sources, which --locked does not handle yet. Whichever of the two PRs merges second should extend --locked to them, reporting a removed HTTP declaration or a switch between HTTP and registry sources as a mismatch.

@eitsupi eitsupi changed the title feat: add dbc sync --locked to install from the lock file without updating it feat: add dbc sync --locked to install from the lockfile without updating it Nov 25, 2026
@eitsupi
eitsupi marked this pull request as draft November 25, 2026 15:33
@eitsupi

This comment was marked as outdated.

…ating it

dbc sync --locked plans every driver from its entry in a version 2 lock
file, fetches no registry index and never writes the lock file. Before
anything is downloaded it checks that the lock file matches the driver
list (drivers, platforms as a set, version constraints with the
pre-release setting, explicit sources) and that every entry has an
artifact for this platform, a configured registry and a trusted signer.
All problems are reported at once; mismatches point to dbc lock, trust
problems to the configuration.
… --locked

planLocked returned at the first lock file mismatch, so an untrusted signer or an unconfigured registry of another entry was only reported on the next run. Plan the drivers that the driver list has even when there are mismatches and report all problems together.
An undeclared host or a missing host artifact skipped the signer and registry checks of the entry. Check them for every driver of the driver list and report the undeclared host as one more problem.
The checks and the plan shared one loop, and every early continue could
hide a later check. checkLockedReplay now runs each check whenever what
it needs is there and only collects problems; planLocked builds the plan
from what it found when neither it nor lockMismatches found a problem.
An untrusted signer no longer hides an invalid artifact location. An
invalid locked version is an error in both checks, since readLockFile
already rejects it. fromLock is back to its original form.
…cked

Since the signer of a lock entry is now checked against the policy of its
bound registry, fromLock, relock and sync --locked all bind the registry,
check the pinned signer and find the host artifact in the same order.
replayLock does this once and records each problem; the normal plan stops
at the first one and may complete a missing artifact from the index, while
--locked collects every problem and completes nothing.
A lock entry from a registry with its own key, or from an unsigned
registry, installs without any index. Once the registry selects another
signer, sync --locked fails before any download, also with --no-verify.
The package is verified with the certificate that the signer check read.

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

LGTM. The preflight/replay split reads well, and the fromLock/relock refactor onto replayLock keeps the existing order of checks (bind, signer, artifact). A few small suggestions inline, none blocking.

Comment thread cmd/dbc/sync_plan.go
if i := slices.IndexFunc(d.Artifacts, func(a lockedArtifact) bool { return a.Target == host }); i >= 0 {
r.host = &d.Artifacts[i]
}
r.bound, r.trustErr = p.bind(name, d.Source.URL)

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.

bind also fails when p.registries() itself errors (a configuration load failure), which isn't about this entry. Under --locked that one failure then gets repeated once per driver under "the configuration does not accept the lock file", followed by the signing-keys advice. Could replayLock return a p.registries() failure as its plain error and keep trustErr for an unconfigured registry or a signer mismatch? fromLock/relock wouldn't change, since they return it either way.

Comment thread cmd/dbc/sync_locked.go
// file. Mismatches between the lock file and the driver list are fixed by
// dbc lock; trust problems, such as a key that the lock file pins but the
// configuration does not trust, by checking that configuration first.
type lockedSyncError struct {

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.

Since CI is the main use case: jsonErrorCode maps this to the generic fallback, so a --json consumer can't tell a stale lockfile from a network or registry failure without parsing the message. Maybe add a dedicated code (e.g. lock_mismatch / lock_untrusted), or expose mismatches/trust as structured fields in the error envelope?

Comment thread cmd/dbc/sync_locked.go
return nil, problems, err
}
if r.trustErr != nil {
problems.trust = append(problems.trust, r.trustErr.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.

Nit: a signer mismatch from trustedSigner already ends with signerChangeHint ("remove the lock file and run dbc lock…"), and the closing line of lockedSyncError then says to check the configuration because updating the lock file would change what it pins. Both make sense, but they show up one after the other. Maybe word the closing line as "if the key change is intended, …", or leave out the hint for items shown here?

Comment thread cmd/dbc/sync_locked.go
if _, ok := list.Drivers[d.Name]; !ok {
continue
}
v, err := semver.NewVersion(d.Version)

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: this branch (and the one in lockMismatches) can't trigger for a lockfile returned by readLockFile, because validate() already requires a canonical semver. Fine to keep for consistency with plan().

This branch was successfully deployed

1 active deployment
snapshot — c814a2b6 Deployed Nov 25, 2026 by eitsupi via snapshot #1364
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