Skip to content

feat: add dbc lock to update the lock file without installing - #575

Merged
zeroshade merged 9 commits into
columnar-tech:mainfrom
eitsupi:feat/lock-command
Nov 17, 2026
Merged

zeroshade merged 9 commits into
columnar-tech:mainfrom
eitsupi:feat/lock-command

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Part of #196. This adds dbc lock, which creates or updates dbc.lock from the driver list without installing drivers. A follow-up PR will add --upgrade and --upgrade-driver <name> to dbc lock to move locked drivers to newer versions within the driver list's constraints, as suggested in #196.

  • dbc lock resolves the driver list the same way dbc sync does: compatible pins in an existing lock are kept, v1 lock files are upgraded, and the project lock is held while resolving. Nothing is installed.
  • An archive is downloaded only when the registry publishes no hash for the current platform or a v1 library checksum has to be checked. It is extracted with the same safety checks as an install, its Columnar signature is verified unless --no-verify is set, and only then is its hash recorded; the download is removed afterwards. The lock file is written only after every driver succeeded.
  • config.InspectPackageArchive gains WithInspectSignatureVerifier so a package signature can be checked without installing. Sync's resolution and downloaded-archive checks are shared with dbc lock; sync behaviour is unchanged.
  • --json prints a lock.status object with the lock file path and the locked drivers.

InspectPackageArchive accepts WithInspectSignatureVerifier, which runs a
PackageVerifier on the private staging directory and manifest in the
same extraction pass, before any digest is returned. This lets callers
check a package signature without installing the package.
…hecks

Move the planning, per-driver fetch loop and lock write of sync into
driverListResolution, and the size, hash and library proof checks of a
downloaded archive into checkDownloadedArchive, so another command can
resolve a driver list with its own per-driver step. Sync behaviour is
unchanged.
dbc lock resolves the driver list like dbc sync, keeping compatible pins
and upgrading v1 lock files, but installs nothing. An archive is
downloaded only when the registry publishes no hash for the current
platform or a v1 library checksum has to be checked; its signature is
verified before its hash is recorded unless --no-verify is set, and the
download is removed afterwards. The lock file is written only after
every driver succeeded.
@eitsupi
eitsupi marked this pull request as ready for review November 11, 2026 00:44
With --no-verify, dbc lock recorded the SHA-256 of a downloaded archive
without extracting it, so a malformed archive could be pinned. Always
extract it with the install-time safety checks and skip only the
signature verification.

Also test that dbc lock writes the same lock file as dbc sync and that
it replays a complete lock file without contacting the registry.
…h sync

Replace the no-op verifier that forced dbc lock to extract downloaded
archives with explicit archiveChecks, and share the download step
(downloadArchive) and the Columnar signature verifier
(columnarSignatureVerifier) between dbc sync and dbc lock. Sync now
detects signature failures through the error chain instead of a flag;
its behaviour and messages are unchanged.
@eitsupi eitsupi changed the title feat: add dbc lock to update the lock file without installing feat: add dbc lock to update the lock file without installing Nov 11, 2026
@eitsupi
eitsupi requested a review from zeroshade November 16, 2026 22:49

@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. Pulling driverListResolution.resolve out of sync is clean, sync and lock now differ only in the per-driver fetch step, and signatureVerificationError is a nice replacement for the verificationFailed closure flag. I built it and tried it: dbc lock writes a v2 lock with per-platform artifacts, and a failed run leaves the existing lock file unchanged.

A few small things:

  1. The jsonschema.LockStatus.Drivers comment says "in driver list order", but planner.plan goes through slices.Sorted(maps.Keys(list.Drivers)), so drivers come out sorted by name. A TOML table has no reliable order to keep anyway, so the comment should say sorted by name.
  2. dbc lock picks each driver's version and artifact for the host platform (config.PlatformTuple()). Locking on a Linux CI runner therefore fails for a driver that has no Linux build, even though the lock file also records artifacts for other platforms. Since the docs suggest dbc lock for CI, cli.md should say this. A --target option could be a follow-up alongside --upgrade.
  3. Nit: the checksum_failed error-code mapping is now repeated in syncModel.Update and lockModel.Update. A shared helper would keep the two from drifting.
  4. Nit: pressing Ctrl-C during dbc lock exits 0 without writing anything, because baseModel quits without setting a status. sync behaves the same, but for a command meant for CI, an interrupted run that reports success is easy to miss.
  5. Nit: when the registry publishes a hash, dbc lock pins it without downloading or checking the signature; that happens later, when sync installs. One explicit sentence in cli.md would avoid the impression that dbc lock checks every pinned archive.

Map checksum, size and v1 library mismatches to checksum_failed in one
helper used by both commands. Correct the lock.status driver order
comment: drivers are sorted by name. Leave a TODO that dbc lock still
depends on the host platform.
@eitsupi

eitsupi commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review.
Addressed in 3d23f55 and fb05424:

  1. Fixed the comment: drivers are sorted by name.
  2. Agreed that dbc lock should not depend on the host platform at all, since it installs nothing and the lock file covers every platform. There are two parts. The version choice is being changed in feat: handle multiple registries serving the same driver name #584 (pick the version without looking at the platform). After that, a follow-up PR will let dbc lock lock a driver with no build for the host. I think that covers the CI case better than --target. I left a TODO in lock.go for now instead of documenting the current behavior.
  3. Moved the mapping into a shared jsonErrorCode helper.
  4. For dbc lock this doesn't happen: lockModel doesn't implement NeedsRenderer, so main runs it with tea.WithInput(nil). Ctrl-C then arrives as SIGINT, and Bubble Tea returns ErrInterrupted, so it exits 1 ("program was interrupted"). I checked this in plain and --json mode. dbc sync can exit 0 when Ctrl-C is read as a key press in an interactive terminal. That's existing behavior, and I'll look at it separately.
  5. Added a sentence to cli.md saying that an archive whose hash the registry publishes is neither downloaded nor signature-checked until sync installs it.

@eitsupi
eitsupi requested a review from zeroshade November 17, 2026 01:49

@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 follow-ups look good. jsonErrorCode keeps the sync/lock mapping in one place and the existing checksum_failed tests cover both paths; the cli.md sentence on registry-published hashes is clear. Your Ctrl-C explanation checks out (lockModel has no NeedsRenderer, so it runs with tea.WithInput(nil)). For the host-platform limitation, could you open an issue to track the follow-up after #584 rather than relying on the TODO in lock.go? driver_list.md suggests dbc lock for CI, so it'd be good to have it visible. Still LGTM.

@eitsupi

eitsupi commented Nov 17, 2026

Copy link
Copy Markdown
Member Author

Thanks, I've opened #592

@zeroshade
zeroshade merged commit c7bc08f into columnar-tech:main Nov 17, 2026
20 checks passed
zeroshade added a commit that referenced this pull request Nov 17, 2026
Fixes the failing `Run pre-commit hooks` job on main
(https://github.com/columnar-tech/dbc/actions/runs/44146064069).

#575 merged after #583 enabled golangci-lint with `--fix`, and its CI
ran before that, so the modernizer rewrite of `errors.As` to
`errors.AsType` in `checkDownloadedArchive` was never applied. This is
the hook's own output.

Verified locally: `pre-commit run --all-files` passes, `go build ./...`
and `go test ./cmd/dbc/` pass.
@eitsupi
eitsupi deleted the feat/lock-command branch November 18, 2026 00:31
zeroshade pushed a commit that referenced this pull request Nov 18, 2026
Follow-up to #575 (`dbc lock`).

Lockfile v2 pins sources and archive hashes, but not the key signatures
are verified with. This PR adds that before v2 ships.

- **Lockfile:** each driver requires a `signer` table pinning the
OpenPGP primary key its packages must verify with. This records the
expected signer, not successful verification. A v2 lock without it is
invalid; v2 is unreleased, so there is no migration. v1 upgrades are
unchanged.

  ```toml
  [drivers.signer]
  type = 'openpgp'
  fingerprint = 'ab7766e9b341299ebc7f45dd82abd0a33a3c9e48'
  ```

- **Enforcement:** `dbc sync` and `dbc lock` verify reused
installations, new installations and hash-measuring downloads with the
pinned key. An untrusted pin, or a re-resolution that would change the
pin, fails before anything is downloaded, installed or written. There is
no fallback key. `--no-verify` skips that run's signature check without
changing or bypassing the pin.
- **API:** `dbc.SigningKey` exposes one key's fingerprint and
verification; `dbc.ColumnarSigningKey()` returns the built-in key.
`SignedByColumnar` and `VerifyPackageSignature` are unchanged.

Only Columnar's built-in key is trusted. Existing users see only the new
lock field; `dbc install`, `Client.Install` and install receipts are
unchanged.

### Other sources and verification methods

The table identifies who must authenticate a release; `type` specifies
how. It belongs to the driver release rather than its source: one
registry can serve multiple publishers.

- **Other OpenPGP keys**, including custom-registry keys, would use
`openpgp` with another fingerprint, without format changes.
- **Other authentication methods**, such as the Packslip source explored
in #497, would need no OpenPGP signature. Another `type` would pin the
verified identity (project, issuer and workflow identity for Sigstore
keyless signing), so replaying the lock elsewhere does not trust a new
identity on first use. Verified metadata hashes stay in `evidence`.

This PR defines only `openpgp`. An unknown type makes the lock invalid
rather than skipping verification, so new types are additive.
eitsupi added a commit that referenced this pull request Nov 24, 2026
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`.
eitsupi added a commit that referenced this pull request Dec 1, 2026
…623)

Align measured hashes with the published-hash path ahead of HTTP URL
template sources (#621).

- **Background:** #575 checked signatures before pinning measured
archives, to catch invalid signatures before saving the lockfile;
`--no-verify` skipped that check. After review, it also extracted those
archives even with the flag, so that locking would catch malformed
tarballs.
- **Why change:** A lockfile pins archive bytes and the required signer;
it does not prove that every platform's package installs. Installation
always verifies the signature with the pinned key, so checking at lock
time only reports a bad archive earlier, and a published hash was
already pinned without these checks. The checks also cost an extraction
for every newly measured platform, which an HTTP source without
`checksum_url` needs for every archive.
- **Archive hashes:** `dbc lock` and `dbc sync` use the published hash
when available and otherwise record the downloaded archive's SHA-256,
without extracting it or verifying its signature. An applicable v1
library checksum still requires extracting the current platform's
archive.
- **Installation:** `dbc sync` checks the archive during extraction and
uses the pinned key to verify the driver library's signature when
required. The signature covers the library alone. A malformed archive or
one with an invalid signature can now be pinned and fail at
installation.
- **Lock options:** Remove `dbc lock --no-verify` now that signature
checks happen at installation or reuse. Both commands still reject a
signer that differs from the registry configuration before downloading
any archives, even with `dbc sync --no-verify`.
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