Documentation
Optional gRPC transport
VLite's versioned protobuf services are vlite.v1.VLite and vlite.v1.Kv.
They provide a bounded data transport over the same exclusively owned database
as REST, not another storage engine. Build the server with the optional grpc
Cargo feature:
cargo build --locked --features grpc --bin vlite-server
gRPC is disabled unless --grpc-bind is explicitly supplied. Bind to loopback
by default. Remote listeners require --allow-remote and bearer
authentication. Do not expose bearer credentials over an untrusted plaintext
network: either terminate TLS at a trusted proxy or serve native TLS:
vlite-server data.vlite --token-file admin.token --allow-remote \
--grpc-bind 0.0.0.0:50051 \
--grpc-tls-cert server-chain.pem --grpc-tls-key server-key.pem
The certificate chain (leaf first) and private key are PEM files. Both flags are
required together. They are read and validated, including that the key matches
the leaf, before the database is opened. A TLS listener reports
LISTENING grpcs://<address>, and clients connect with https:// and must trust
the issuing CA. Native TLS uses rustls with TLS 1.2 or later; it does not
request client certificates unless --grpc-tls-client-ca client-ca.pem is set.
That flag requires a certificate signed by the configured client CA on every
connection; bearer authentication still applies. REST supports native HTTPS
using --tls-cert/--tls-key. Bootstrap admins can call
POST /v1/admin/tls/reload to transactionally reload both listeners and client
CA roots without restarting; invalid files leave all old configurations active.
Existing TLS sessions are unchanged. See SECURITY.md for tenant
namespace isolation, persisted credential rate/vector limits, and optional OTLP
tracing. Rate/quota errors use RESOURCE_EXHAUSTED with retry-after: 1.
API keys bound to a suspended tenant get PERMISSION_DENIED with
vlite-error-code: tenant_suspended; tenant lifecycle administration and the
signed-in identity are REST-only.
When the REST router was configured with memory bindings, the gRPC adapter built
after it applies the same reservations: a reserved collection or graph answers
like a missing one on every RPC. A generated differential runs the checks of the
REST differential on every RPC (with and without bindings, reserved as missing,
the digest read back over REST); it never compares a REST answer with a gRPC
answer. vlite-server still refuses --grpc-bind while a memory binding is
configured or reserved records remain.
A program that builds the routers itself must build every REST router first
(configured_admin_router, then grpc_router) over one Service. The listener
adopts, once, when it is built, the tokens, credential store and reservations
that the REST routers had published: normally those of the last one. A router
that protects less (no admin token where the published one has one, or
reservations that do not cover the ones already published) does not replace
them. Only those two things are compared: the token values, the credential
store and the raw-access grants of the bindings are those of the router that
last replaced the publication. What the listener adopted changes in place:
token files are reloaded (POST /v1/admin/tokens/reload), credentials are
revoked and tenants suspended through the router whose state it adopted, and
the listener follows; the same calls made through any other router reach that
router's REST only. Any other change of tokens or reservations needs a new
Service and new routers, because a router built after the listener changes
what REST applies and not what the listener applies. configured_admin_router
returns an error when
- a
grpc_routerwas built from the service before any REST router, or after one that has no admin token, so that the listener serves every caller as the administrator; - the router reserves memory resources (a bindings file, or records that remain
in the database) and a
grpc_routerhas been built from the service; - in a build with the
grpcfeature, the published tokens and reservations and the router's own cannot be ordered: each protects something the other does not (the router has no admin token where they have one but reserves a resource they do not; it has a token where they have none but leaves one of their resources unreserved; or each reserves a resource the other does not), because a listener could adopt only one of them.
After any error the program closes the service (Service::close().await stops
the scheduler and the webhook dispatcher that a refused router may have
started) and drops it with every router built from it. What the refused router
already did stays: records written, the admin directory created and the first
account seeded, and the setting of the process-wide log buffer.
router and authenticated_router cannot refuse: they log a warning for the
first order, and keep the published tokens and reservations, with a warning, for
the last. These are the rules of the library routers in this release and may
change when gRPC serves memory.
Scope
The protobuf service covers listing, inspecting, creating and dropping collections; vector get/put/delete; atomic single-collection batches; exact, ready-only ANN and hybrid retrieval; and resumable import reservation, chunk, status, finish and abort operations. Ready-only vector search never builds an index. Hybrid search supports exact or ready-only vector legs, optional text- only retrieval, metadata filters and weighted reciprocal-rank fusion. Resumable-import RPCs use the same durable chunk identity and replay behavior as REST.
Import RPC responses wrap the corresponding REST JSON body in
ImportJsonResponse.json, preserving decimal-string job IDs without narrowing
64-bit identifiers. A rejected import chunk returns INVALID_ARGUMENT with
vlite-error-code: import_rows_invalid; its
vlite-error-details-base64 trailer contains base64-encoded UTF-8 JSON in the
same shape as the REST rejection body, including bounded per-row validation
details.
REST remains the operational interface for auto retrieval, index quality and maintenance, backup/restore, credentials and diagnostics. There is no reflection API.
Extended engine RPCs
The additive RPCs expose the engine's V5 record and retrieval APIs. PutVector
accepts optional absolute expires_at_ms, which must be later than the server
clock when the write is applied: an expiry at or before it is refused with
INVALID_ARGUMENT (vlite-error-code: invalid_input) and nothing is written.
Changed in 0.7.1: 0.7.0 answered OK to such a put and stored a record that
was already expired, so no read returned it; a client that sent an already due
deadline now gets this error and must send a later one.
A put that fails for another reason, such as a file older than V5, a failed
precondition or an invalid vector, answers that error first. UpdateMetadata
changes metadata without replacing the vector or payload. Both require a V5
file. Grouped search,
recommendations, facets, numeric statistics and geographic search preserve the
engine's typed metadata, filters, metrics and stable ID tie-breaking.
SearchRequest.rerank_mode optionally applies exact metric re-scoring or MMR to
returned vector candidates. rerank_candidates sets candidate depth (bounded to
4096 and at least k); MMR defaults to lambda 0.5. Hybrid result sets cannot be
post-reranked. Named-vector configuration, version upserts, vector/sparse puts,
named and sparse searches, and dense+sparse fusion are also V5-only. These RPCs
operate on the collection named in the request and follow the corresponding
read/search/write scoped-credential permissions.
Query accepts the bounded read-only query language described in
VECTORS.md; vector parameters are supplied separately in the
request map. Changes returns a durable cursor token and commit-boundary batch.
WatchChanges starts at that token (or the beginning when empty), emits batches
as they appear, and continues polling until the client cancels. Watch/change
access is admin-only because feed batches may contain events from any
collection. The watch interval is clamped to 100 ms–60 s, and credentials are
rechecked while polling. Since v0.6.0 both also serve graph-enabled files:
ChangeKind adds GRAPH_CREATED, GRAPH_DROPPED and GRAPH_BATCH, and
ChangeEvent adds graph, revision and graph_operations
(GraphChangeOperation); see
Change feed and webhooks.
BuildDiskAnn and SearchDiskAnn use an operator-specified sidecar path for
the administrator token, which must always send path. Every other caller (a
scoped credential or the read-only token) must leave path empty: the server
then uses the file the REST routes use for the collection,
disk-ann-<collection id>.dann in VLITE_ADMIN_DIR (409
admin_directory_disabled without one), and a path from such a caller is
refused with 422 invalid_input, so a credential scoped to one collection
can no longer write or read an arbitrary file. Clients that sent a path with a
scoped credential must drop it. The administrator's SearchDiskAnn now opens
the sidecar after the collection check, while it holds the database read lock,
so a bad path for a collection that does not exist answers NOT_FOUND for
the collection instead of the I/O error for the path. The RPCs
are not available for encrypted databases; the sidecar contains plaintext
vectors, so callers must protect its directory and restrict these admin/index
operations. Info reports format, sequence, lineage, timestamp support, and
whether the database is encrypted plus its non-secret key ID—never key material.
This gRPC server currently owns a primary Database, not a
ReplicaFollower; is_replica is false and the optional replica detail is
absent. Replica transport/status RPCs are not yet provided.
EmbedText exposes text-to-vector embedding as described below; clients can
also supply vectors from their own provider. The embedded engine's Embedder
trait and optional HTTP provider remain usable by applications.
Managed inference
EmbedText {collection, text, provider} returns {vector, dimensions, provider}.
An empty provider or hashing selects the local hashing embedder; http retains
the existing opt-in HTTP embedder behavior. Any other provider is an
administrator-bound alias, never a caller-supplied endpoint or credential.
Managed providers remain off by default. Without provider configuration,
hashing and existing search modes issue no provider calls.
Search accepts RERANK_MODE_CUSTOM=3 and optional rerank_provider (tag 18).
The provider is required for custom mode and forbidden for other modes.
Custom mode uses the shared REST workflow: 1 <= k <= candidates <= 1000,
default candidates max(k,50), vector-only search, and no MMR lambda.
Existing exact/MMR behavior is unchanged: at most 4096 candidates and default
4*k, with MMR lambda default 0.5. These defaults intentionally differ.
Custom results preserve the original metric distance. Each returned Hit
has optional rerank_score (tag 3), the negated provider cost (positive zero
for zero cost). Results are sorted by descending score, then numeric ID.
SearchResponse.ranking (tag 3) is {provider, order:"score_desc_id_asc"}.
Non-custom responses omit both optional additions.
Both operations require bearer authentication and search scope before provider
lookup; read-only bearer credentials are also allowed. Bindings use database
lineage, collection identity and the collection's owning tenant, not the caller's
tenant. The shared workflow releases the database
guard during inference and rechecks authorization, collection identity,
dimensions, binding generation, candidate revisions/expiry/visibility and the
original deadline before returning. Empty payload_fields never inspects
payload bytes. Otherwise only named top-level fields of a JSON object are sent;
absent named fields are omitted, invalid/non-object JSON fails, and metadata
is never sent implicitly.
All EmbedText input, including hashing, is limited to 16,384 UTF-8 bytes.
The managed adapters enforce
1 MiB request / 4 MiB response caps, at most 2 s connect / 10 s total timeouts,
non-blocking per-provider/per-tenant admission, TLS outside explicit loopback
HTTP exceptions, endpoint allowlisting, no redirects and at most one retry
only for replay-safe aliases. Responses require finite values, exact embedding
dimensions and exactly k unique ranking IDs from the candidate set.
For managed operations, a shorter standard grpc-timeout also cancels outbound
work; an already expired deadline prevents dispatch. Malformed timeout metadata
fails closed as invalid_provider_input. Tonic may enforce the transport
deadline first, returning CANCELLED with message Timeout expired and no
vlite-error-code trailer. A client RST_STREAM does not cancel the detached
managed inference task; it remains bounded by the 10 s cap and admission slots.
Provider errors use the existing vlite-error-code trailer:
| Stable code | gRPC status |
|---|---|
provider_not_configured |
FAILED_PRECONDITION |
invalid_provider_input |
INVALID_ARGUMENT |
provider_invalid_response |
UNAVAILABLE |
provider_unavailable |
UNAVAILABLE |
provider_timeout |
DEADLINE_EXCEEDED |
provider_busy |
RESOURCE_EXHAUSTED |
provider_snapshot_conflict |
ABORTED |
provider_busy reuses the existing retry-after: 1 trailer. The provisional
ABORTED snapshot-conflict mapping corresponds to REST 409
provider_snapshot_conflict. Conflicts are sanitized and have no retry hint;
retry the whole request. Missing bearer credentials remain UNAUTHENTICATED;
wrong scope or tenant remains
PERMISSION_DENIED. Errors do not expose provider inputs, vectors, payloads,
tenant identifiers or secrets.
The additions preserve existing v1 tags and enum meanings. Old clients can
continue using their existing modes and ignore the optional additions. An older
server has no EmbedText RPC and returns UNIMPLEMENTED; generated clients
propagate that status without fallback. Its Search handler rejects unknown
RERANK_MODE_CUSTOM as INVALID_ARGUMENT (invalid_input); it must not be
treated as exact/MMR or retried with another mode. New clients must handle both
cases explicitly. Rust bindings are generated by build.rs; the Python smoke
test generates its stubs from the same proto. No generated stubs are checked in.
Key-value entries
vlite.v1.Kv provides GetKvEntry, PutKvEntry, DeleteKvEntry,
ListKvEntries, GetKvEntries and WriteKvBatch. It is a separate service
from vlite.v1.VLite, and there are no lease RPCs. Addresses require a
nonempty collection name. Values are raw bytes, versions/deadlines are
uint64, and optional expiry distinguishes an unset deadline from zero. Get,
list and GetKvEntries require collection read; put, delete and
WriteKvBatch require collection write. Validation, CAS, tenant bindings,
quotas, audit, durability and pagination match the REST KV rules.
The list page boundary is measured using the canonical REST JSON encoding,
including base64 values, not the smaller protobuf encoding.
A client needs a receive limit of at least 16 MiB + 1 KiB for ListKvEntries
and GetKvEntries (the canonical JSON page cap is 16,777,216 bytes; the
protobuf page is not larger) and a send limit above 1 MiB (above 6 MiB to send a
full WriteKvBatch).
GetKvEntries(KvGetManyRequest) returns (KvGetManyResponse) reads many keys of
one collection, and WriteKvBatch(KvBatchRequest) returns (KvBatchResponse)
writes many, all or nothing. Their messages:
| Message | Fields |
|---|---|
KvKeyRef |
namespace, key |
KvGetManyRequest |
collection, repeated KvKeyRef keys |
KvGetManyItem |
KvEntry entry (a message field, unset for a key that is absent or due) |
KvGetManyResponse |
repeated KvGetManyItem items, optional uint32 next_index |
KvBatchPut |
namespace, key, bytes value, Expected expected |
KvBatchDelete |
namespace, key, Expected expected |
KvBatchOperation |
a oneof: KvBatchPut put or KvBatchDelete delete |
KvBatchRequest |
collection, repeated KvBatchOperation operations |
KvBatchResult |
a oneof: uint64 version or bool deleted |
KvBatchResponse |
repeated KvBatchResult results |
Multi-get. A call names 0 to 1,000 keys, and a key may repeat. items[i]
answers keys[i]: an unset entry means the key is absent or due, which is not
an error. One read guard and one expiry clock serve the call. If the entries
would pass 16,777,216 bytes of canonical REST JSON, the response holds the
largest prefix of the keys that fits (the first key always fits), and
next_index is the index of the first key not read, equal to the number of
items and at least 1. It is unset when every key was read. Calls share no
snapshot: ask again for the remaining keys.
Batch. A call holds 0 to 1,000 operations. It behaves as the
REST batch does: as if the operations ran one at a
time, in order, against the live state and one expiry clock, then committed once.
Each (namespace, key) may appear once, and the values of all puts total at most
4,194,304 bytes; either violation is INVALID_ARGUMENT with invalid_input,
and the message names the operation. An unset Expected means any. An operation
that sets neither put nor delete is INVALID_ARGUMENT (invalid_input), and
its message starts operations[<index>]:. The adapter converts every operation
before REST's ordered checks run, after it has checked the operation count, so
this fault is refused ahead of a bound fault in an earlier operation, like a
malformed operation object over REST (422 invalid_json, also refused first). A
put has no deadline field and clears the deadline of the entry it replaces.
results[i] answers operations[i]: version is the same uint64 for every
put of the batch, and deleted is false for a key with no live entry. The first
operation that cannot run fails the whole batch with the status of its single
call and writes nothing: ABORTED (precondition_failed) or
FAILED_PRECONDITION (kv_slots_exhausted, graph_attached_record).
UNKNOWN (commit_indeterminate) means that all of the batch or none of it was
written: read the keys back with GetKvEntries before you decide, and do not
retry blindly.
Older servers. A server that predates the two RPCs answers UNIMPLEMENTED
to every caller, authenticated or not, as it does for any method of the service
that it does not have, because the permission check is inside each method. gRPC
has no capabilities call: ask GET /v1/capabilities over REST and look for the
two route paths in routes (see
Batches and multi-get).
Streaming export and import
ExportVectors is a server stream of Vector messages for one collection, in
strictly ascending ID order without duplicates. It reads page_size records
(0 means 256; maximum 1000) per page. Each page is an atomic snapshot, but
writes committed between pages may or may not appear: the stream is not a
point-in-time snapshot of the whole collection. Pass the last received ID as
after to resume after a disconnect. Credentials and revocation are rechecked
for every page, so a revoked token ends the stream with an error. Read-only
tokens may export.
StreamImport is a client stream over an already reserved import job. Each
message names the same job and carries one numbered chunk with the same
durable, atomic, idempotent semantics as ImportChunk. Set finish only on
the last message; a control-only finish message (chunk 0, no operations) is
allowed. The response is the finish result or, without finish, the current
job status. If the stream fails, chunks already committed stay committed and
the job remains open: read GetImportStatus and resume from last_chunk + 1,
or replay the last chunk safely.
Both transports share requests_total and request_failures_total. The admin
/metrics view also reports grpc_requests_total,
grpc_request_failures_total and grpc_stream_messages_total. A streaming
call is recorded once when it is accepted. A later mid-stream failure, such as
revocation during export, also increments both failure counters and writes a
stream_error log line with the original request ID.
IDs and revisions are protobuf uint64, vector components are float, payloads
are raw bytes, and typed metadata is represented with protobuf oneofs. Generate
clients from the shipped proto/vlite/v1/vlite.proto; do not hand-convert
full-width IDs through JavaScript number.
Authentication and failure semantics
Send the same bearer credential as REST in authorization request metadata.
Admin, read-only and scoped credentials use the same authorization and
collection-lineage bindings. A client cannot gain write access by changing
transports. Public standard gRPC health is a liveness signal, not permission to
read data.
Invalid input maps to INVALID_ARGUMENT, missing records to NOT_FOUND,
scope failures to PERMISSION_DENIED, and unavailable ready indexes to
FAILED_PRECONDITION. Conditional conflicts use ABORTED. Capacity exhaustion
uses UNAVAILABLE. The vlite-error-code metadata preserves VLite's application
error code.
Do not blindly retry writes. A commit-indeterminate failure uses UNKNOWN:
the commit may already be durable. Read back the record or inspect application
state before deciding what to do. A disconnected client does not cancel or
roll back a database commit.
REST and gRPC share the owner and bounded request/worker resources. Unary requests and individual stream messages are capped at 8 MiB and responses at 16 MiB. A large response is an explicit transport failure, not a truncated successful result.