Skip to content

feat: add driver upgrades to lock and sync - #635

Merged
eitsupi merged 7 commits into
fix/exact-package-versionfrom
feat/lock-upgrade
Dec 2, 2026
Merged

eitsupi merged 7 commits into
fix/exact-package-versionfrom
feat/lock-upgrade

Conversation

@eitsupi

@eitsupi eitsupi commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Closes #196. dbc reuses compatible lock entries so repeated installs use the same versions, sources, and signers. Deleting the lock file to refresh one driver discards every driver's pins. The new flags let you choose which versions to resolve again.

  • Upgrades. dbc lock --upgrade and dbc sync --upgrade drop the locked-version preference for all drivers. Repeat --upgrade-driver NAME to target specific drivers. The two flags are mutually exclusive, and either conflicts with dbc sync --locked. Resolution follows the driver list's constraints, prerelease settings, platforms, and explicit sources. Other drivers follow the usual lock or sync rules. When sync writes the lock file and installation later fails, it warns on stderr and tells the user to rerun sync.
  • Archive pins. dbc reuses a v2 artifact's hash and size when the full version, source identity, canonical target, and recorded archive location match. With the same full version and source, dbc also keeps recorded artifacts it did not replace, including targets missing from the index, listed ambiguously, or removed from platforms. The update fails if a published hash conflicts with a pin or if retained and selected artifacts at the same location disagree on hash or size. The guide explains how to accept a corrected archive republished at the same version.
  • Signer changes. Repeat dbc lock --allow-signer-change NAME to approve changes for specific drivers. Each approval must be used to accept a change to a signer pinned in the v2 lock file during this run. Moving between unsigned sources also requires declaring the destination source. After saving, dbc reports the old and new sources and signers and warns when future installs will skip library signature verification. Sync rejects signer changes and shows the driver-specific dbc lock command for approval.

@eitsupi
eitsupi added this pull request to stack #632 December 1, 2026 03:14
@eitsupi eitsupi changed the title feat/lock upgrade feat: add driver upgrades to lock and sync Dec 1, 2026
@eitsupi
eitsupi requested review from amoeba and zeroshade December 1, 2026 03:49
@eitsupi
eitsupi marked this pull request as ready for review December 1, 2026 03:50

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

Solid feature; the strict per-driver signer approvals, unused-approval check, and refusal to silently re-pin a changed published hash all look right. A few things to address:

  1. One doc page still gives the old advice. docs/concepts/driver_registry.md:226 still says "delete dbc.lock and run dbc lock" to accept a key change. The matching text in driver_list.md and cli.md was rewritten, but this one was missed. Point it at dbc lock --allow-signer-change NAME.

  2. No documented way to accept a corrected archive. The guide used to say "delete dbc.lock and run dbc lock again" to pick up a corrected archive at the same location; it now only says "have the registry publish it as a new version", which users of a third-party registry can't do. Since --upgrade deliberately fails on a changed published hash, deleting the lock file is the only way out, and it's no longer documented. Either restore that escape hatch (with its "may also change other drivers" caveat) or add a narrower option.

  3. Pins for dropped platforms are kept. TestPlanLockUpgradeRetainsUnreplacedArtifacts/"target removed from declared platforms" pins that after platforms shrinks, an upgrade keeps the artifact for the removed target, so the lock lists artifacts outside its platforms and carries them as long as the version stays the same. Same for targets the index no longer lists. Keeping pins the index can't confirm makes sense, but dropping targets the user removed from platforms seems like the expected behavior. Please confirm this is intended and document it.

  4. A failed install leaves the lock ahead of what's installed. sync --upgrade writes the lock before installing (TestSyncUpgradeInstallFailureKeepsNewLock). That matches existing sync behavior, but after a failed install the lock says 1.1.0 while 1.0.0 is still installed. A one-line stderr warning in that case would tell users a rerun is needed.

  5. Changed signer-mismatch output for sync --locked (minor). The single trailing hint becomes a command repeated on each problem line. Better for scripts, but anything that parsed the old trailing hint will break; worth a release-note line.

  6. Stacking: this sits on #634 → #633 → #631, and #631 has changes requested. If #631 changes how versions are chosen across registries, the docs line "can select another registry with the same signing key" may need updating.

dbc sync writes the lock file before installing, so a failed install
leaves the lock ahead of the installed drivers. Say so in one line on
stderr and ask to rerun dbc sync. dbc sync --locked writes nothing, so
it does not warn.
…pped platforms

Point signer changes at the per-driver approval instead of deleting the
lock file, document how to accept a corrected archive republished at the
same version by resetting only that driver's lock entry, and state that
artifacts of targets removed from platforms stay pinned while the
version and source are unchanged. A missing version recorded in a
version 1 lock file now suggests dbc lock --upgrade-driver.
@eitsupi

eitsupi commented Dec 1, 2026

Copy link
Copy Markdown
Member Author
  1. Fixed. It now says to follow the command in the error: dbc lock --upgrade-driver NAME --allow-signer-change NAME when the lock entry would otherwise be reused, or dbc lock --allow-signer-change NAME alone when the driver is already being resolved again.
  2. The guide recommends a new release first. If the publisher confirms a replacement at the same version and location, remove that driver’s entire [[drivers]] block, run dbc lock, and review the diff. This discards that driver’s version, source, signer, and hash pins. Other compatible pins stay in place. The published-hash mismatch points to the guide. Cargo rejects the mismatch even on cargo update -p in the custom-registry case in Expected behavior if a crate version's checksum changes rust-lang/cargo#10071. Public npm versions are immutable, Go checks go.sum, and Bundler rejects checksum mismatches when validation is enabled. pip’s hash-checking mode requires an explicit hash edit. mise documents mise lock TOOL to refresh the current version’s checksum. uv’s explicit uv lock --upgrade-package PKG can accept a new hash for the same version, while --refresh alone retains the pin. We’re keeping dbc upgrades focused on version and source selection. A dedicated operation can wait for a concrete use case.
  3. Intentional. platforms is the minimum set the lock must cover, and a plain relock already keeps extra artifacts for the same version and source. This lets a temporarily dropped target reuse its pinned hash when it is added back. The guide and reference now explain this.
  4. When regular or upgrade sync writes the lock and installation then fails, stderr tells the user to fix the error and rerun sync. With --locked, there is no lock write and no such warning.
  5. dbc sync --locked came in feat: add dbc sync --locked to install from the lockfile without updating it #616 and has not been released, so this changes no released output format.
  6. The sentence still holds with the version-first rule; it now links to the selection rules. A v1 lock whose recorded version is gone now suggests dbc lock --upgrade-driver NAME.

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

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

  1. Signer-change advice: driver_registry.md now gives the --allow-signer-change recovery instead of "delete dbc.lock", and no doc page still tells users to delete the lock file.
  2. Corrected archives: "Accepting a corrected archive" documents a narrow escape hatch. You remove only that driver's [[drivers]] block, so other drivers keep their pins. The published-hash mismatch error links to it. The caveat about a stale published hash is a good addition.
  3. Artifacts for dropped platforms: keeping them is intended and now documented: platforms is the minimum set the lock must cover. additionalRegistryArtifacts keeps an old pin unless an accepted artifact replaces its target. If another target's artifact uses the same location with a different hash or size, it fails instead of silently dropping the pinned hash.
  4. Lock ahead of installed drivers: a failed install after the lock write now warns on stderr, and --locked stays quiet.
  5. --locked output: it was never released, so no release note is needed.
  6. Stacking: the selection-rules link covers the change in #631. The missing-v1-version error now suggests dbc lock --upgrade-driver NAME, and TestLockUpgradeDriverReplacesMissingV1Pin exercises that path end to end.

Two minor inline notes, neither blocking.

Comment thread cmd/dbc/sync.go
err = fmt.Errorf("failed to install driver package: %w", err)
}
program.Send(fmt.Errorf("failed to install driver package: %w", err))
program.Send(syncInstallFailedMsg{err: err})

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 cancelled install (for example Ctrl-C after the lock write) takes the s.ctx.Err() != nil early return just above and never sends this message, so the lock can still be ahead of the installed drivers with no warning. Consider sending the warning on that path too.

Comment thread cmd/dbc/sync.go
printCmd,
s.installDriver(s.cfg, s.installItems[s.index]),
)
case syncInstallFailedMsg:

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: writeLockFileV2 runs on every non---locked sync, even when nothing changed. So "the lock file was written" also appears when the lock still matches the installed drivers. Wording like "installation did not complete; fix the error and rerun dbc sync" would be accurate in both cases.

@eitsupi
eitsupi merged commit f8e42c6 into main Dec 2, 2026
32 checks passed
@eitsupi
eitsupi deleted the feat/lock-upgrade branch December 2, 2026 23:22
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 — 18b0aba8 Deployed Dec 1, 2026 by eitsupi via snapshot #1434
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.

Create dedicated way of upgrading drivers in the lockfile

2 participants