vgi.secret_protocol
Module overview
VGI secret protocol â the wire contract for Orchardâs standalone secret service.
Orchard is an independently-deployed microservice that brokers downstream
credentials (S3/HTTP/GCS/âŚ) for a single authenticated account. The DuckDB
extensionâs VgiRemoteSecretStorage calls :meth:VgiSecretProtocol.secret_lookup
lazily whenever a secret consumer (e.g. httpfs resolving an s3:// path) asks
the secret manager for a credential.
This protocol is versioned independently of :class:vgi.protocol.VgiProtocol
(the worker/catalog protocol). It has exactly one method and a tiny surface so it
can evolve on its own cadence â see protocol_version below.
Wire shape
secret_lookup takes the requested path and type as direct scalar
parameters (not a wrapped request dataclass), so the generated C++ builder
BuildSecretLookupParams(path, type) is directly callable without a hand-coded
inner serializer. The response is :class:SecretLookupResponse, IPC-serialized
into the unary result envelope and validated C++-side against
SecretLookupResultSchema().
Identity is carried entirely by the OAuth bearer token on the HTTP request (the
same CatalogAuth the catalog established at ATTACH) â there is no
account/storage identifier in the request body.
function encode_secret_values
Section titled âfunction encode_secret_valuesâencode_secret_values(mapping: dict[str, Any]) -> pa.RecordBatch | None
Build the one-row values RecordBatch from a Python mapping.
Each key becomes a column; the cell at row 0 is the secret value. Types are
inferred by pyarrow (strâutf8, intâint64, boolâbool, dictâstruct, listâlist,
âŚ). Pass a pa.array([...]) as a value for explicit control over the type.
Returns None for an empty mapping (no values to ship).
class SecretLookupResponse
Section titled âclass SecretLookupResponseâBases: ArrowSerializableDataclass
Description
Response for :meth:VgiSecretProtocol.secret_lookup.
values is the secretâs keyâvalue map carried as a one-row RecordBatch
(serialized to binary on the wire): each column is a secret key and its row-0
cell is the value. This lets values be any Arrow/DuckDB type â string, int64,
bool, struct, list, nested â not just strings. Build it with
:func:encode_secret_values. The C++ side converts each cell to a typed
DuckDB Value via the ArrowâDuckDB bridge. redact_keys lists the subset
of keys whose values must be redacted by duckdb_secrets() â honor it or
values leak.
ttl_seconds is the serverâs suggested cache lifetime. expires_at_unix
is the credentialâs own hard expiry as a Unix timestamp (0 = no intrinsic
expiry); the client caches for min(ttl_seconds, expires_at_unix - now) so
a short-lived STS token is never served past its own expiry.
When found is False every other field is empty/zero and the client caches
a short-TTL negative entry.
Attributes
attribute found
Section titled âattribute foundâbool
Whether a matching credential was located; when False every other field is empty/zero.
attribute secret_type
Section titled âattribute secret_typeâstr
The DuckDB secret type the resolved credential is for.
attribute provider
Section titled âattribute providerâstr
The provider/backend that issued the credential.
attribute scope
Section titled âattribute scopeâlist[str]
URI prefixes the secret applies to (DuckDB secret scope list).
attribute values
Section titled âattribute valuesâAnnotated[pa.RecordBatch | None, ArrowType(pa.binary())]
The secretâs key->value map as a one-row RecordBatch
(serialized to binary on the wire); None when not found.
attribute redact_keys
Section titled âattribute redact_keysâlist[str]
Subset of value keys whose values must be redacted by
duckdb_secrets().
attribute ttl_seconds
Section titled âattribute ttl_secondsâint
Serverâs suggested cache lifetime in seconds.
attribute expires_at_unix
Section titled âattribute expires_at_unixâint
The credentialâs own hard expiry as a Unix timestamp (0 means no intrinsic expiry).
class VgiSecretProtocol
Section titled âclass VgiSecretProtocolâBases: Protocol
Description
Wire protocol for Orchardâs standalone secret service.
A single unary method, secret_lookup. vgi_rpc.RpcServer(VgiSecretProtocol, impl) handles serialization, dispatching, and version enforcement exactly as
it does for :class:vgi.protocol.VgiProtocol.
Application protocol surface version
protocol_version is the canonical semver (MAJOR.MINOR.PATCH) of this
contract, independent of VgiProtocol.protocol_version. The framework
enforces an exact major+minor match (patch ignored) at the dispatch boundary.
The C++ extension reads VGI_SECRET_PROTOCOL_VERSION from
vgi/src/generated/vgi_secret_protocol_version.hpp (generated; sibling of
vgi_protocol_version.hpp) and passes it as a per-call
protocol_version_override so it never collides with the worker protocolâs
global version constant.
Bump rules mirror :class:vgi.protocol.VgiProtocol: major for any
backwards-incompatible change, minor for additive, patch for worker-side fixes.
Attributes
attribute protocol_version
Section titled âattribute protocol_versionâstr
Canonical semver (MAJOR.MINOR.PATCH) of this contract, enforced as an exact major+minor match at the dispatch boundary.
Methods
method secret_lookup
Section titled âmethod secret_lookupâsecret_lookup(path: str, type: str) -> SecretLookupResponseResolve the credential for path of secret type.
type is the lowercased DuckDB secret type the consumer probed for
(s3 / r2 / gcs / aws / http / âŚ). Identity comes from
the OAuth bearer on the transport. Return SecretLookupResponse(found=False)
when the account has no matching credential.