Skip to content

feat!: fall back only between registries with the same signer - #601

Merged
eitsupi merged 5 commits into
mainfrom
feat/same-signer-fallback
Nov 25, 2026
Merged

eitsupi merged 5 commits into
mainfrom
feat/same-signer-fallback

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Addresses the review of #595: with #584, a registry that serves a driver name also serves it for every driver list that does not pin it, so adding a registry with its own key adds a code signer for every name it lists. This keeps the #584 fallback, which is what lets a driver move between the built-in registries, but only between registries with the same signer, and makes the choice fail when it cannot be checked.

  • Same signer: when several registries list a driver name, whatever their versions and platforms, they must all verify their packages with the same signer. Otherwise ResolvePackage returns a SignerConflictError that names the registries and their signers, before any package is selected or downloaded, and the CLI suggests a source in dbc.toml (feat: select the registry of a driver with source in dbc.toml #599) or --registry. Registry priority stays project → user → built-in.
  • Missing index: a registry whose index cannot be fetched or read might list the driver too. Its signer is known from its configuration, so ResolvePackage returns ErrIncompleteIndex only if that signer differs from the signer of the registries that list the driver (or, if none does, from another failed registry's signer), or if it cannot identify the failed registry or its signer. A failed registry with the same signer is skipped, as before this PR. This applies to new resolution in dbc add, dbc install, dbc lock, dbc sync, Client.Install and Resolve in the bindings. Replaying a lock entry that still satisfies the driver list, drivers with a source and dbc install --registry only need the registries they use.
  • API: ResolvePackage (unreleased, from feat: handle multiple registries serving the same driver name #584) takes the error that Search returned with the drivers. Search reports each failed registry as a RegistryIndexError with the registry's configuration; its message leaves out the user information and query of the registry URL, also where the HTTP error repeats the request URL.
  • Bindings' Resolve: invalid registry metadata during package selection, such as a malformed archive hash or a missing version, now returns an error. If a listed driver has no eligible version, Resolve still returns its versions without latest. Previously both cases returned the same kind of result, even though Install already rejected the same invalid metadata on the host platform.
  • Relation to feat: configure signing keys for third-party registries #595: there is no per-registry key setting yet, so every registry is verified with the built-in Columnar key: no conflict can occur and no failed index fails the signer check until feat: configure signing keys for third-party registries #595 lands. feat: configure signing keys for third-party registries #595 will derive the identity from each registry's signing policy (the digest of the configured certificate for a key, and an identity of its own for each unsigned registry), marked with TODO comments. Once feat: configure signing keys for third-party registries #595 lands, a failed registry with a different signer can block resolution of drivers without a source. This should not be released before feat: configure signing keys for third-party registries #595.

@eitsupi

eitsupi commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

@lidavidm Do you think this change suits your needs of #584?

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

Until #595 every registry is verified with the same key, yet ErrIncompleteIndex still fires for any failed index. With the default config, a 5xx from dbc-cdn-private.columnar.tech now blocks dbc add/install/lock for public drivers too. I reproduced this against ResolvePackage with a 503 RegistryIndexError for the private registry and duckdb listed only by the public one.

A missing index can only hide a conflict if the failed registry's signer differs from the candidates'. registrySignerIdentity takes the registry configuration, so the signer is known without the index. Could ErrIncompleteIndex be limited to failed registries whose signer differs from the candidates' (or from each other's when there are no candidates)? That keeps the fail-closed behavior for a third-party key and avoids a new single point of failure across the built-in registries.

Otherwise the conflict check, the redaction in RegistryIndexError/SignerConflictError, and the exemptions for source, --registry and lock replay look right; go test ./... passes.

Base automatically changed from feat/driver-registry-source to main November 23, 2026 22:08
A driver name that several registries list is now resolved only when all of
them verify their packages with the same signer; otherwise ResolvePackage
returns a SignerConflictError before any package is selected, so adding a
registry cannot silently change who signs a driver. Between registries with
the same signer, the fallback to the next registry with a matching version
stays.

Choosing the registry needs every index: a registry whose index cannot be
fetched or read makes new resolution fail with ErrIncompleteIndex in dbc
add, install, lock and sync, Client.Install and the bindings' Resolve,
whether or not the reachable registries list the driver. Search reports
each failed registry as a RegistryIndexError and keeps its partial result.
Lock replay, drivers with a source and installs with --registry are not
affected.

Every registry is verified with the built-in Columnar key for now, so the
signer identity is the same for all of them until registries can name their
own key.
An HTTP error repeats the request URL with the registry's user information
and query, so redact the cause as well as the registry name. Move the
redaction of the CLI into internal/registryurl to share it.

Note what the signer identity has to become once registries can name their
own key, and say in the docs that only a lock entry that still satisfies the
driver list is used without every index.
…signer

A failed registry index no longer blocks resolving a driver when the
failed registry's packages are verified with the same signer as the
registries that list the driver (or, without such registries, as the
other failed registries). A failure that cannot be attributed to a
registry, or whose registry's signer cannot be determined, still fails
closed.

RegistryIndexError now carries the registry configuration so that the
signer of a failed registry is known without its index.
@eitsupi

eitsupi commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Thanks for your review.
Addressed in ccfc7f4.

@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, ccfc7f4 addresses my concern: a failed registry now blocks resolution only when its signer differs from the candidates' (or from the other failed registries when nothing lists the driver), when the failure cannot be attributed to a registry, or when its signer is unknown. With the built-in registries sharing a signer, a failing private CDN no longer blocks public drivers, and TestResolvePackageMissingIndex covers that with the real registrySignerIdentity. go test ./... passes on the head.

A few non-blocking notes inline.

Comment thread internal/api/ops.go
switch {
case errors.Is(err, dbc.ErrIncompleteIndex), errors.As(err, &conflict):
return ResolveResult{}, err
case err != nil && pkg.Driver.Path != "" && !errors.Is(err, dbc.ErrPackageMiss):

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 changes api.Resolve beyond the signer check. A terminal selection error (bad archive hash, missing version metadata) used to return {Path, Versions, Latest: nil} and now returns an error, as the updated TestResolveSelectedRegistry cases show. That seems reasonable, but it is visible to API callers, so could the PR description mention it (or could it go in a separate PR)?

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 added a "Bindings' Resolve" bullet to the PR description.
This PR already updates Resolve to return signer conflicts and incomplete-index errors, and returning invalid metadata as an error matches what Install already does on the host platform.

// TestIsSelectionError covers the hint for an error that only an explicit
// registry avoids.
//
// TODO: test a signer conflict end to end through add, install, lock and

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: fine to defer until registries can name their own key, but please track the end-to-end conflict test in an issue so this TODO does not go stale.

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 #613

// secrets is replaced by "REDACTED", for text that is not part of a URL. A
// text that contains a secret too short to replace safely becomes
// HiddenMessage.
func Redact(text string, secrets []string) 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: now that Redact/Secrets live in their own package and are also used by RegistryIndexError, a small table test here would keep the redaction rules pinned independently of the cmd/dbc tests.

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.

Added table tests for Secrets and Redact in ac1a266.

@eitsupi
eitsupi merged commit 7aeaa5d into main Nov 25, 2026
31 checks passed
@eitsupi
eitsupi deleted the feat/same-signer-fallback branch November 25, 2026 00:03
@eitsupi

eitsupi commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

I merge this and move on to work on #595 (if there are any issues with the revisions after the final review, I will make follow-up corrections later).

zeroshade pushed a commit that referenced this pull request Nov 25, 2026
Follow-up to #576. Custom registries (#360) can name the key their
packages are signed with, so drivers from them no longer need
`--no-verify`. This also turns on the signer check of #601 for these
keys. Closes #613.

```toml
[signing_keys.acme]
type = "openpgp"
public_key_file = "keys/acme.asc"  # or public_key = "-----BEGIN PGP PUBLIC KEY BLOCK-----..."

[[registries]]
url = "https://drivers.acme.example.com"
signing_key = "acme"  # omitted: built-in Columnar key; false: unsigned registry
```

- **Config:** in the user `config.toml` and in `dbc.toml`. A
`signing_key` name is resolved only in the file that declares the
registry, so adding a key to the user config never changes what a
project trusts. A project cannot declare a registry from the user config
or a default registry (compared without query, user information or
default port) with a different signing policy; that is an error. An
omitted `signing_key` always means the built-in Columnar key. `columnar`
is reserved. Registry URLs in these files reject empty interior path
segments, `.` or `..` segments even when escaped, and escaped slashes,
so that another spelling of a trusted registry's path cannot get past
this check. Registry identities, including lockfile sources, omit
default ports and normalize path escapes by decoding unreserved
characters and uppercasing the remaining hex digits, preserving the
distinction between escaped and literal reserved characters.
- **Keys:** exactly one public certificate, armored (or binary in a
file). Private keys, several keys or armor blocks, unknown packets and
trailing data are rejected instead of skipped. A relative
`public_key_file` is relative to the file that defines it; in `dbc.toml`
it must stay inside the project directory (no absolute or UNC paths or
`..` that leaves it, read through `os.Root`). The file is read only when
its key is needed, also for the signer check, and the certificate read
is reused for the rest of the operation; a failure is an error, never a
fallback to another key.
- **Signer check:** when several registries list a driver, or an index
is missing, their signers must match (#601). Keys match only when their
certificates are identical, and every unsigned registry is a signer of
its own, so a missing index of an unsigned registry, or of one with a
key the others do not share, stops new resolution of drivers without a
`source`. The signer check, the verification and the lock pin of one
operation use the same certificate, even if a `public_key_file` changes
meanwhile.
- **Lockfile:** the selected key's fingerprint is pinned as in #576, or
`type = 'none'` for `signing_key = false`. Replay requires the
registry's current configuration to select the same signer, also with
`--no-verify`, so a lock entry can neither switch keys nor turn
verification off on its own. Each unsigned registry counts as a separate
signer, so a driver locked from one is not resolved again from another
unsigned registry, even with a changed `source`.
- **Install:** `dbc install` and `Client.Install` select the key from
the registry of the chosen package before downloading it, so a driver
that a later registry with the same key serves (#584) is verified with
that registry's key. `--no-verify` / `AllowUnsigned` skip the signature
check, but not the signer check of an implicit selection; local archives
keep using the Columnar key. The `install` and `sync` JSON report
`signature_verified`, and `verify.start` / `verify.complete` are only
emitted when a signature is checked.
- **API:** `Registry.Signing` (`RegistrySigningPolicy`, zero value =
Columnar key) with `SignWith` / `Unsigned`, plus `NewSigningKey` and
`Registry.ResolveSigningKey`. `RegistrySigningOperation` keeps the keys
of one operation; its `ResolvePackage` replaces the unreleased function
of the same name (#584, #601). The unreleased `LoadProjectRegistries` /
`WithProjectRegistries` become `LoadProjectConfig` /
`WithProjectConfig`, so key definitions and their file path travel with
the registries. Bindings take `signingKey` on explicit registries
(`registry.<n>.signing_key` in the C API).

The policy only covers detached OpenPGP signatures of registry packages;
another source such as Packslip would get its own policy and lock signer
type.
eitsupi added a commit that referenced this pull request Dec 2, 2026
dbc used registry priority for overrides (#360), and #584 kept that
order when choosing the first registry with a matching version. This
gave order precedence over version, much as uv's default `first-index`
does to limit dependency confusion. The review of per-registry signing
keys (#595) showed that registry order could also determine the signer,
so #601 made cross-signer name collisions an error during implicit
resolution. Within that signer boundary, dbc now picks the highest
eligible version across registries, as pip does across indexes, so
drivers keep getting updates after moving to another registry.

- **Selection.** A candidate must satisfy the version requirements and
have builds for every required target in one record. Registry order
breaks ties at the highest SemVer precedence. In the winning registry, a
second eligible record of the same precedence or any duplicate of the
winning full version is an error. Exact requests include build metadata
and reject duplicate exact records even when none covers all required
targets. Errors in a selected artifact stop resolution.
- **CLI.** New resolutions can select a newer version from a
lower-priority registry. To take a driver from a specific registry, set
its `source`. Compatible lock entries still replay from their recorded
source. Successful CLI selections warn on stderr when a same-signer
index was skipped. Registry version constraints now reject build
metadata.
- **v1 lock files.** If the recorded version is no longer listed,
migration stops with or without `platforms`. A recorded version that
lacks a build for a declared platform is still resolved again.
- **Go API.** `Client.FetchIndex`, `Client.FetchRegistryIndex`, and
`SelectRegistry` replace `SigningOperation.ResolvePackage`. Requests
take a constraint or an exact version. The project planner decides
whether to keep a locked version. `Index` aliases an internal type so
public callers get complete snapshots from the client and cannot pass
filtered search results; tests outside the module can serve an index
through `NewClient` with `WithRegistries` and `WithHTTPClient`.
- **Bindings.** `Resolve` reports the highest eligible stable version as
`latest` and lists versions for the requested platform across reachable
same-signer registries, including prereleases. Go and npm-wasm expose
skipped indexes in `warning`. C and Rust warning support follows in
#633.

`Client.FetchRegistryIndex` requires exactly one configured endpoint
match before fetching. This prevents it from picking a signing policy by
list order when `WithRegistries` lists the same endpoint under different
policies.

The released `Driver` methods remain single-driver lookups. #634 aligns
`GetPackage` with exact version matching and deprecates
`GetWithConstraint`.

This branch was previously deployed

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