Repository navigation
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Related to #497 ## Summary dbc 0.3.0 silently accepts lockfiles with unsupported versions, including v2 files with source and artifact metadata. During `dbc sync`, it can treat such entries as v1 registry locks and overwrite the file as v1. Validate the top-level version immediately after TOML decoding. Version 1 still loads; versions 2 and later, as well as a missing version, now fail before lock entries are used. A failed sync leaves the lockfile unchanged.
zeroshade
left a comment
There was a problem hiding this comment.
Requesting changes. Tests/vet/race pass and extraction + atomic lock-write look solid, but there are regressions vs main (inline):
- Blockers: re-download/re-verify on already-installed
dbc install; registry credentials persisted into dbc.lock; sync fails on missing secondary driver roots; install lock requires every root writable. - Major: path source can't add a second target; v1 migration silently replaces pinned library; Ctrl+C can't stop stalled sync; undefined
revision; Packslip identity policy too loose, continuity rules cause false failures, replay has no authenticity check. - Also: binary grows 16.5 MB → 35.8 MB (sigstore stack); docs lack packslip/path source fields, trust model/recovery, and the lock upgrade path; 8 new files have truncated Apache headers.
Given the size (136 files, +27k), consider splitting: atomicfile/fslock + install transactions → lockfile v2 (registry/path) → Packslip.
| } | ||
| } | ||
|
|
||
| needsArchive := item.AlreadyInstalled == nil || !canReuseLockedEntry(*item) |
There was a problem hiding this comment.
Already-installed direct installs always re-download: lock entry is nil, and hash-less registry receipts never match. install --no-verify X then install X now fails on missing signature (main: "already installed").
| return resolution.ResolvedRelease{}, fmt.Errorf("invalid registry package platform %q: %w", pkg.PlatformTuple, err) | ||
| } | ||
| release := resolution.ResolvedRelease{ | ||
| DriverID: driver.Path, |
There was a problem hiding this comment.
Registry userinfo/query (https://user:tok@…, ?token=) is persisted into dbc.lock source.url, receipts, and --json. Strip credentials from identity/locations; relative package URLs with userinfo now fail outright.
| return nil, err | ||
| } | ||
| } | ||
| var ensurePackage func(context.Context, config.Config, string, config.ExpectedPackageMetadata, config.EnsurePackageCallbacks) (config.EnsurePackageResult, error) |
There was a problem hiding this comment.
Sync passes raw s.cfg; install filters via installConfigForEnsure. Missing secondary root (e.g. $CONDA_PREFIX/etc/adbc/drivers) now fails dbc sync.
| }) | ||
| } | ||
| for _, root := range lockRoots { | ||
| if err := ctx.Err(); err != nil { |
There was a problem hiding this comment.
Locks every precedence root, so an unwritable secondary root (system conda env) aborts install/sync. Only the primary root is written; skip EACCES/EROFS on others.
| return fmt.Errorf("duplicate artifact target %q", artifactSelectorIdentity(artifact)) | ||
| } | ||
| seenTargets[artifact.Target] = struct{}{} | ||
| if prior, exists := seenLocations[artifact.Location]; exists { |
There was a problem hiding this comment.
Path sources stamp the same location on every target, so adding a second platform (different bytes) fails this shared-location check. Contradicts driver_list.md; exempt path locations.
| if err := toml.NewDecoder(f).Decode(&m.list); err != nil { | ||
| return err | ||
| } | ||
| if err := m.list.validateSources(); err != nil { |
There was a problem hiding this comment.
Validation blocks removing the malformed entry itself.
| if err != nil { | ||
| return empty, nil, fmt.Errorf("error reading tar archive: %w", err) | ||
| } | ||
| if header.Typeflag == tar.TypeDir { |
There was a problem hiding this comment.
PAX global headers (git archive) are rejected; skip TypeXGlobalHeader.
| return expected, nil | ||
| } | ||
|
|
||
| func loadInstalledDriver(cfg Config, loc, runtimeID string) (*DriverInfo, error) { |
There was a problem hiding this comment.
Undecodable existing manifest now aborts install; main overwrote it.
| return nil | ||
| } | ||
| var cleanupErr error | ||
| remove := func(directory string) { |
There was a problem hiding this comment.
On Windows, a loaded DLL survives RemoveAll while the receipt is deleted, so the generation is never reclaimed. Remove receipt last.
| item := &prepared.items[i] | ||
| ensured, err := executor.ensurePreparedPackage(ctx, item) | ||
| if err != nil { | ||
| var checksumErr syncChecksumError |
There was a problem hiding this comment.
syncChecksumError is never constructed, so checksum_failed JSON is unreachable (behavior change). Also dead: writeLockFile, candidateLockSavedMsg, parsePlatformTuple, locked-mode branches.
|
Thank you for the detailed review! I will revise the PR to be split according to your suggestion. |
Related to #497 ## Summary dbc 0.3.0 silently accepts lockfiles with unsupported versions, including v2 files with source and artifact metadata. During `dbc sync`, it can treat such entries as v1 registry locks and overwrite the file as v1. Validate the top-level version immediately after TOML decoding. Version 1 still loads; versions 2 and later, as well as a missing version, now fail before lock entries are used. A failed sync leaves the lockfile unchanged.
Related to #497 ## Summary dbc 0.3.0 silently accepts lockfiles with unsupported versions, including v2 files with source and artifact metadata. During `dbc sync`, it can treat such entries as v1 registry locks and overwrite the file as v1. Validate the top-level version immediately after TOML decoding. Version 1 still loads; versions 2 and later, as well as a missing version, now fail before lock entries are used. A failed sync leaves the lockfile unchanged.
Related to #497 ## Summary dbc 0.3.0 silently accepts lockfiles with unsupported versions, including v2 files with source and artifact metadata. During `dbc sync`, it can treat such entries as v1 registry locks and overwrite the file as v1. Validate the top-level version immediately after TOML decoding. Version 1 still loads; versions 2 and later, as well as a missing version, now fail before lock entries are used. A failed sync leaves the lockfile unchanged.
Related to #497 ## Summary dbc 0.3.0 silently accepts lockfiles with unsupported versions, including v2 files with source and artifact metadata. During `dbc sync`, it can treat such entries as v1 registry locks and overwrite the file as v1. Validate the top-level version immediately after TOML decoding. Version 1 still loads; versions 2 and later, as well as a missing version, now fail before lock entries are used. A failed sync leaves the lockfile unchanged.
## Summary This PR extracts the transactional package installation foundation from #497 for dbc 0.4.0. Direct install, sync, and `Client.Install` prepare a validated, dbc-owned driver payload before replacing the runtime registration. The previous installation remains usable until commit. It also removes **manifest-only dbc package installation**, an undocumented feature with no known usage. Every installed package must contain an actual `Files.driver` payload; `Driver.shared` is no longer a fallback for a missing payload. This requirement applies even when signature verification is disabled. Ordinary ADBC runtime manifests that reference externally managed libraries remain supported. Removing manifest-only **packages** does not remove external runtime registration discovery or parsing. ## Transaction contract ```text private staging -> archive validation and optional verification -> ownership receipt -> unique owned-payload generation publication -> runtime registration replacement [commit] -> conservative post-commit cleanup ``` - Pre-commit failures preserve the previous registration and payload. Post-commit cleanup failures do not roll back a successful installation. - Unix registrations use atomic file replacement. Windows restores previous raw registry values after ordinary partial failure; rollback failure preserves the candidate because registration state is uncertain. - Driver-scoped locks serialize cooperating mutations. Install/update writes only the primary root; lower-priority installations remain in place. - Cleanup retains filesystem identity, symlink/TOCTOU, cross-root reference, and external-registration borrower checks. Receipts describe owned payloads only and are deleted last. - `InstallPackage(ctx, ...)` supports cancellation during lock waits and safe pre-commit boundaries. Registration mutation completes once started, including any rollback. ## Behavior changes in 0.4.0 | Case | Previous behavior | Behavior in this PR | | --- | --- | --- | | Package without `Files.driver` | Could install only a manifest pointing to an external library; this was undocumented. | Rejected before publication or registration changes. | | Replacing an installed version | Some paths uninstalled the working version before the replacement was ready. | Prepare and validate the replacement first, then switch registration and clean up. | | Receipt-backed dbc package uninstall | No transactional ownership receipt. | Remove registration, then delete validated owned files conservatively. | | Normal pre-0.4 dbc package uninstall | Could recursively remove the package directory. | Recognize `source = "dbc"` and a safe same-root legacy layout; delete only the exact registered driver binary, then remove its directory if empty. Metadata may remain. | | External or ambiguous registration uninstall | External library bytes could be deleted in some cases. | Remove registration and retain library bytes. | | `config.UninstallDriverShared` | Public API for shared-library removal. | Removed; use `Config.UninstallDriver` or `Client.Uninstall`. | Legacy ownership is a compatibility assumption based on the old install layout, not a provenance proof. Unsafe paths, uncertain filesystem identity, conflicting references, or unknown/corrupt receipts prevent payload deletion. No additional heuristics reconstruct legacy ownership. ## Compatibility and scope Same-version direct install still exits before download or verification. `Client.Install` does not gain mandatory signature or MANIFEST-version checks. `InstallDriver` remains a deprecated, non-transactional API, with the same owned-payload requirement. Native locks coordinate processes; Wasm locks are runtime-local. Wasm uninstall retains payloads because directory identity cannot be pinned safely. Post-uninstall cleanup errors identify retained paths; recovery of registration-less generations is deferred. Stable Windows registry lock identity remains follow-up work. With `ADBC_DRIVER_PATH`, cleanup scans other configured roots without taking their locks, so a manifest created there concurrently could reference a just-removed library; dbc never creates such cross-root references itself. Stale-generation cleanup errors after a successful install or uninstall are currently dropped; reporting them is follow-up work. Owned payloads are stored in hidden `.dbc-package-g-*` directories next to the driver manifest, created with the process umask applied. On Unix, lock files are intentionally left in place after release. Lockfile v2, Packslip, a new package format, external registration commands, aliases, and replay/repair are outside this PR. This foundation accepts prepared owned payloads so future package decoding and reproducible-artifact locking can build on the same transaction model. ## Validation CI passes on Linux, macOS, Windows, and Wasm (Node and Deno). Windows tests now use the shared registry and directory isolation from #508.
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.
Stacked on #598. Since #584, a driver comes from the highest-priority registry that has a matching version, so which registry serves a driver depends on the order of the registries and on what each one publishes at the time. This lets a driver list name the one registry a driver comes from, like a dependency's registry in Cargo or `[tool.uv.sources]` in uv. ```toml [[registries]] url = "https://drivers.acme.example.com" name = "acme" [drivers.snowflake] source = { type = "registry", name = "acme" } [drivers.flightsql] source = { type = "registry", url = "https://dbc-cdn.columnar.tech" } ``` - **Selection:** `name` refers to a `[[registries]]` entry in the same file (a project cannot refer to a name from the user config); `url` selects a configured registry by the identity `dbc.lock` records (no user information, query or fragment). The source must bind to exactly one configured registry, since registries that differ only in query cannot be told apart in the lockfile. `type` is required so other source types can be added later (#497). - **Built-in registries:** `https://dbc-cdn.columnar.tech` and `https://dbc-cdn-private.columnar.tech` have no configured name, so a source selects them by `url`, as `flightsql` does above. Declaring one in `[[registries]]` with a `name` also works. - **No fallback:** the driver is resolved from that registry's index alone. A missing driver, a missing version or a failed fetch is an error, and the merged index is not fetched when every driver has a source. - **Lockfile:** nothing new is recorded; the lock keeps the registry identity. If the source selects another registry than the lock entry, `dbc sync` stops and `dbc lock` resolves the driver again (the pinned signer is still compared as before). Naming the same registry another way keeps the entry. - **CLI:** `dbc add --registry <name|url>` records the source, and `dbc add` without it keeps a driver's existing source. `dbc install --registry <name|url>` installs from one registry of the user config, and installs again when the same version is already installed, since an installed driver does not record its registry. `GetDriverList` honors the source too. `Client.Install` and the bindings have no registry option yet. - **Names:** a registry name must be unique within its file, and a configured name now takes precedence over the name a registry's index gives itself, so the name used in `source` is also the one `dbc search` shows.
|
For now, with the HTTP support introduced in #621 enabling off-registry driver installation, this PR has served its purpose and will be closed. |
This PR is a Proof of Concept.
A subsequent independent PRs will implement the solution based on this PoC.
sourcein dbc.toml #599, feat: install drivers from HTTP URL templates in dbc.toml #621, feat(install): install driver archives from HTTP(S) URLs #640)Summary
This PR introduces source-aware package resolution and lockfile v2.
It adds:
Related to #394 and #400. Most of the change is shared resolution, lockfile, and package-lifecycle infrastructure; Packslip is one consumer. This PR does not fully close either issue: release discovery, source authoring, and publication of all-platform registry hashes remain follow-up work.
User-facing workflows
Install directly from an exact signed Packslip release:
Signed metadata supplies the driver identity and artifact selection. Direct installation does not create or modify a project
dbc.tomlordbc.lock.For reproducible project installation, declare the source in
dbc.toml:Run
dbc syncto resolve the release, record its artifacts in lockfile v2, and install the current target. Subsequent syncs can replay a recorded target without repeating release discovery.Exact versions are a current prototype constraint. Version discovery is required before general availability; the resulting lock will still record an exact release.
Design decisions requiring review
These contracts affect future compatibility and are the main design review points.
dbc metadata in Packslip
The signed release extension declares the driver ID:
{ "predicate": { "extensions": { "dbc": { "schema_version": 1, "driver_id": "iceberg" } } } }Installable artifacts carry this marker:
{ "extensions": { "dbc": {} } }MANIFESTpackage metadata.Lockfile v2 and registry coverage
Every locked artifact requires an archive SHA-256 hash. Size is optional and checked when present. Installed-library digests are tracked separately.
hashfield. All-target hashes allow a complete lock from index metadata; otherwise the host download establishes a hash for a partial lock. Measured size stays in the receipt.Registry-provided sizes are not read by this PR. The YAML decoder tolerates unknown fields, leaving size support to a later change. Publishing and backfilling registry hashes is separate from this client implementation.
Verification comparison
Defaults for new installation or repair from an archive:
--no-verify--no-verify. Columnar signatures use dbc's embedded public key; Packslip requires no additional Columnar signature. Direct local installation creates no lockfile; local replay uses a project path source.--no-verifyinstall. Receipts record integrity, not signature history; the flag is not persisted in the lock.Compatibility and scope
Package metadata
All sources support the existing
MANIFESTformat. Direct local installation derives the driver ID from the filename:local-driver_linux_amd64_v1.2.3.tar.gzbecomeslocal-driveron Linux amd64.A future self-describing format should remove this dependency and separate dbc-owned identity/target metadata from ADBC Driver Manifest metadata. This PR reserves only
dbc-package.toml; its schema and compatibility rules remain for follow-up design. Archives containing it, alone or alongsideMANIFEST, are rejected without parsing or installing it as payload. Metadata discovery and dispatch provide the future extension point.Manifest-only packages register externally managed libraries without bundling their bytes. They remain supported and have no bundled library signature to check. They should eventually be retired in favor of explicit external-library registration: archive hashes cannot pin those external bytes, and package repair, upgrade, or uninstall cannot manage them reliably. Retirement requires a replacement workflow and migration policy.
Lockfile migration
Suggested review order
End-to-end validation
Using the public tokoko-adbc-iceberg v0.1.2 release:
--no-verify.Actual dbc.lock generated during manual testing
Current limitations
dbc add: updates existing Packslip entries; new source declarations require manual TOML edits.tar.gzandtgz. Non-empty Packslip host requirements are rejected.Future work
dbc-package.toml; identity/target, ADBC metadata separation and mapping, migration, compatibility, trust.dbc add.dbc lockwithout installation;dbc sync --lockedrejecting resolution or lock changes.--no-verifyoption: Because it is unclear what to verify and what not to verify, something like--no-signature(rpm like option name) would be more appropriate.