acdp-registry-rs

Reference ACDP registry server implemented in Rust

CI License: MIT OR Apache-2.0 MSRV

Reference registry implementation for the Agent Context Distribution Protocol v0.1.0 through v0.5.0. Implements the acdp-registry-core and acdp-registry-discovery profiles on top of acdp — plus, as the corresponding config sections are enabled: the ACDP 0.2.0 trust-hardening surface (the acdp-registry-receipts profile — signed, atomically-persisted publish receipts, RFC-ACDP-0010 — self-certifying did:key producers, and a self-hosted /.well-known/did.json, see docs/RECEIPTS.md), the 0.3.0 lifecycle, transparency-log, and head-receipt profiles, and 0.4.0 witness cosignature aggregation (RFC-ACDP-0015), and the 0.5.0 retraction recall profiles (RFC-ACDP-0018: the acdp-registry-changes feed at GET /changes, and acdp-registry-events signed change hints via /subscriptions). Version-gated anchors acceptance (RFC-ACDP-0016, Draft) is unconditional — every deployment advertises acdp_version >= 0.5.0 and accepts well-formed anchors on every publish, see docs/HTTP-API.md.

Profiles and the config that advertises them

ProfileSpec referenceAdvertised when
acdp-registry-coreRFC-ACDP-0003in the default registry.profiles
acdp-registry-discoveryGET /contexts/searchin the default registry.profiles
acdp-registry-federatedcross-registry resolutionlisted in registry.profiles
acdp-registry-receiptsRFC-ACDP-0010a [receipt] key is configured
acdp-registry-head-receiptsRFC-ACDP-0011receipt.head_receipts = true
acdp-registry-transparency-logRFC-ACDP-0012[log] enabled = true
acdp-registry-lifecycleRFC-ACDP-0013[lifecycle] enabled = true
acdp-registry-changesRFC-ACDP-0018 §5 (Draft)[changes] enabled = true
acdp-registry-eventsRFC-ACDP-0018 §8 (Draft)[events] enabled = true
acdp-registry-keylessRFC-ACDP-0021 §13 (Draft)[keyless] enabled = true; off by default, and needs a [receipt] key, lifecycle and the log

The full rules, including which profiles must be listed and which are added automatically, are in docs/CONFIGURATION.md.

What you get

  • RFC-ACDP-0003-conformant publish pipeline — full DID-resolution + signature verification + lineage coherence + atomic commit.
  • Pluggable storage — Postgres (production), SQLite (dev / CI), and an in-memory backend, behind a unified ExtendedRegistryStore trait. The memory backend is for demos only (ephemeral: everything is lost on restart), and its q= search is a case-insensitive substring match of the whole query, not the stemmed all-words match of SQLite/Postgres.
  • DID-bound authentication — challenge / response over Ed25519, short-lived JWTs (HS256 or EdDSA with a published JWKS), token revocation, anonymous public reads opt-in.
  • Multi-tenancy — tenant-scoped publish / retrieve / search via a signed JWT tenant claim, with an optional strict mode. X-Tenant-Id is honoured only across a declared trust boundary (auth.tenant_header_trust, default none; see docs/MULTI-TENANCY.md).
  • Cross-registry resolution — foreign ctx_ids are resolved against their home registry (public-only, SSRF-guarded).
  • Signed receipts & lifecycle — RFC-ACDP-0010 publish receipts and head receipts, plus RFC-ACDP-0013 retract/republish lifecycle events.
  • Transparency log — RFC-ACDP-0012 append-only Merkle log with signed checkpoints, inclusion/consistency proofs, and RFC-ACDP-0015 witness cosignature aggregation.
  • Retraction recall — RFC-ACDP-0018 change feed (retractions, supersessions, key revocations, each with its receipt evidence) behind durable encrypted cursors, plus signed, content-free change hints to subscriber callbacks.
  • Keyless signing (off by default) — RFC-ACDP-0021 (Draft): a CI job or workload trades its OIDC ID token or SPIFFE JWT-SVID for a short-lived, registry-signed attestation of an ephemeral key, then publishes under its controller's DID with no long-lived key. See the matrix below and docs/OPERATIONS.md.
  • HMAC-signed webhooks — context.published, context.retrieved, context.retracted, context.republished, search.executed.
  • Abuse controls & observability — per-IP and global /auth/* rate limiting (per process by default, optionally counted across replicas in Postgres with [rate_limit] backend = "postgres"), per-agent publish and challenge budgets, and an optional Prometheus /metrics endpoint.
  • Playground mode — a runtime config flag ([playground] enabled = true, compiled into every build) that skips DID verification for hands-on demos; never enable in production. Only its admin routes are compile-gated behind the playground Cargo feature.

Repository layout

acdp-registry-rs/
├── Cargo.toml                      # workspace
├── crates/
│   ├── acdp-registry-types/        # config, wire types, errors
│   ├── acdp-registry-store/        # ExtendedRegistryStore trait
│   ├── acdp-registry-pg/           # Postgres backend
│   ├── acdp-registry-sqlite/       # SQLite backend (dev / test)
│   ├── acdp-registry-auth/         # DID challenge-response + JWT
│   ├── acdp-registry-webhook/      # HMAC-signed event emitter
│   ├── acdp-registry-core/         # axum router + handlers
│   └── acdp-registry-server/       # binary: `acdp-registry`
├── docker/                         # Dockerfile + docker-compose
├── deploy/                         # production Compose + Kubernetes examples
├── tools/live-smoke/               # end-to-end check of a deployed registry
├── config/                         # example TOML configs
└── docs/                           # reference docs (API, auth, config, ops)

See docs/ for architecture, the HTTP API, authentication, configuration, multi-tenancy, webhooks, and operations.

What this repository treats as done, and what it deliberately defers, is in STATUS.md and DEFERRED.md.

Quick start

Local dev (SQLite)

# `acdp` is pulled from crates.io — no sibling checkout needed.
# Run with default config (SQLite under ./data/registry.db).
cargo run -p acdp-registry-server

# Or with a config file. NOTE: the example is a production-shaped template —
# it sets auth.enabled = true with an empty jwt_secret and
# allow_ephemeral_secret = false, so it will REFUSE to boot without a secret.
# Supply one (the config's own guidance, in its header and above `jwt_secret`):
ACDP_REGISTRY_CONFIG=config/registry.example.toml \
ACDP_REGISTRY_AUTH__JWT_SECRET="$(openssl rand -base64 32)" \
    cargo run -p acdp-registry-server

# For a throwaway local run you may instead set
# ACDP_REGISTRY_AUTH__ALLOW_EPHEMERAL_SECRET=true, which mints a random
# process-lifetime key. Tokens do not survive a restart; never use it in
# production.

Then:

curl http://localhost:8443/.well-known/acdp.json
curl http://localhost:8443/healthz
# {"status":"ok","storage":true,"version":"<version>"}
curl http://localhost:8443/livez
# {"status":"ok","version":"<version>"}

version identifies the running build. A locally built binary reports the bare package version; an image built by CI reports &lt;version&gt;+g<shortsha>, which is what actually pins it to a commit. Treat the string as opaque — see HTTP-API.md.

Postgres + Docker (local)

cd docker
docker compose up --build

This is a local stack built from source with auth off. It accepts did:key producers as well as did:web, because a did:web document on this machine is not fetchable by the registry. For a real deployment (pinned image or release binary, receipts and lifecycle on, signing-key handling, TLS, backups, upgrades) follow docs/DEPLOY.md. It ships a production Compose file and a Kubernetes manifest under deploy/, and a public reference instance runs at https://registry.agentcontextdistributionprotocol.io.

Configuration

Configuration starts from built-in defaults, is layered with the TOML file named by ACDP_REGISTRY_CONFIG (if set — there is no fallback file; with the variable unset only the built-in defaults apply), and is overridden by ACDP_REGISTRY_<SECTION>__<FIELD> environment variables (double underscore separates levels). See config/registry.example.toml for an annotated, production-shaped template.

An EMPTY ACDP_REGISTRY_* variable is treated as absent, not as an override (#271). ACDP_REGISTRY_REGISTRY__AUTHORITY="" leaves your TOML value alone rather than blanking it; unset the variable or give it a value. Any empty variable that was ignored is named in a startup warn!.

This exists because docker compose renders an unset variable as set-to-empty rather than absent, so every ${VAR:-} passthrough in a compose environment: block used to silently overwrite the config file. Note that ${VAR:-false} is not the same thing — it renders the literal string "false", which is a real value and still overrides.

Upgrading: see docs/UPGRADING.md, which is the operator's pre-upgrade read for every version. For this change specifically: before it, an empty value either overrode with "" or, for a number, boolean, or list field, failed the config load outright. If you deploy docker/docker-compose.yml, upgrade the image at the same time — the current recipe passes empty values that an older binary would reject at boot.

Selected fields:

TOML keyEnv varNotes
registry.authorityACDP_REGISTRY_REGISTRY__AUTHORITYBare lowercase DNS name; also the did:web identifier.
registry.portACDP_REGISTRY_REGISTRY__PORTDefault 8443.
storage.backendACDP_REGISTRY_STORAGE__BACKEND"postgres", "sqlite", or "memory".
storage.postgres_urlACDP_REGISTRY_STORAGE__POSTGRES_URLRequired when backend = "postgres".
auth.jwt_secretACDP_REGISTRY_AUTH__JWT_SECRETBase64-encoded ≥32-byte secret.
webhook.urlACDP_REGISTRY_WEBHOOK__URLHMAC-signed POST target.
playground.enabledACDP_REGISTRY_PLAYGROUND__ENABLEDSkips DID verification — dev only.

HTTP surface

Selected routes (the full surface, including request/response shapes, is in docs/HTTP-API.md):

MethodPathNotes
GET/.well-known/acdp.jsonCapabilities document.
GET/.well-known/jwks.jsonJWKS (EdDSA public key; empty for HS256).
GET/.well-known/did.jsonRegistry DID document (when a receipt key is configured).
GET/livezProcess liveness — always 200 while the process is up; never touches storage.
GET/healthzStorage readiness + the running build's version; 503 when the backend is down.
GET/metricsPrometheus metrics (when metrics.enabled).
POST/contextsPublish (full RFC-ACDP-0003 §2.1 pipeline).
GET/contexts/{ctx_id}Retrieve full context.
GET/contexts/{ctx_id}/bodyRetrieve body only.
GET/contexts/searchKeyword + filter search.
POST/contexts/{ctx_id}/retractProducer retraction (RFC-ACDP-0013).
POST/contexts/{ctx_id}/republishProducer republish (RFC-ACDP-0013).
GET/lineages/{lineage_id}Full lineage (visibility-filtered).
GET/lineages/{lineage_id}/currentNewest non-superseded version.
GET/log/checkpointSigned transparency-log checkpoint (RFC-ACDP-0012).
GET/log/proofInclusion / consistency proofs.
GET/log/entriesLog leaves (visibility-filtered).
GET/changesChange feed: retractions, supersessions, key revocations (RFC-ACDP-0018; when changes.enabled).
POST/subscriptionsCreate a change-hint subscription; the secret is shown once (RFC-ACDP-0018 §8; when events.enabled).
GET/subscriptions/{id}Read your own subscription, without its secret (when events.enabled).
DELETE/subscriptions/{id}Delete your own subscription (when events.enabled).
POST/auth/challengeIssue a nonce for DID challenge-response (when auth.enabled).
POST/auth/tokenVerify signed challenge → JWT (when auth.enabled).
POST/auth/token/revokeRevoke your own token by jti (when auth.enabled).
GET/admin/statusOperational snapshot (admin bearer).
GET/admin/lineages/{id}/auditOn-demand lineage integrity audit (admin bearer).
POST/admin/contexts/{id}/retractAdmin retraction (admin bearer).
POST/admin/contexts/{id}/republishAdmin republish (admin bearer).
GET/admin/contextsCompile-gated by playground (admin bearer).
POST/admin/pinned-keys/reloadCompile-gated by playground (admin bearer).

Visibility (public / restricted / private) is enforced server-side per RFC-ACDP-0008 §4.5; authenticated callers identify themselves via Authorization: Bearer <jwt>. A header the registry does not recognise as a bearer is treated as anonymous rather than refused on these routes — it never reaches token validation — while /admin/* refuses it. See Presenting a bearer. Full request/response shapes, error envelope, auth flow, config, and ops are documented under docs/.

When auth.enabled = false, the /auth/challenge, /auth/token, and /auth/token/revoke routes are not mounted, and any Authorization header is ignored — every caller is treated as anonymous, so the public/restricted/private gate runs against None.

Production TLS

The server's [registry.tls] block can serve HTTPS directly via rustls, but the recommended production topology is to terminate TLS upstream (Nginx, Caddy, an ALB) and let acdp-registry listen on plain HTTP behind it. The example config's port = 8443 is a hint that HTTPS is expected at the edge; the binary itself happily serves plain HTTP on any port. Reasons:

  • The DID-web SSRF policy in acdp-rs requires HTTPS for outbound resolution; that's separate from how the registry serves inbound traffic.
  • TLS termination at the load balancer is the standard ops pattern, gives you cert rotation without restarting the registry, and decouples performance tuning from the protocol implementation.

For the playground profile (--features storage-sqlite,playground), inbound HTTPS is convenient for cross-registry demos; set registry.tls.enabled = true and point cert_path / key_path at a self-signed cert.

Running PG integration tests locally

The Postgres-backed integration suite (tests/pg_integration.rs) mirrors the SQLite suite but exercises PgStore. It's gated on ACDP_REGISTRY_TEST_PG_URL and skips cleanly when unset, so day-to-day cargo test is unaffected.

docker run --rm -d --name acdp-test-pg -p 5433:5432 \
  -e POSTGRES_USER=acdp -e POSTGRES_PASSWORD=acdp -e POSTGRES_DB=acdp_registry \
  postgres:16-alpine

ACDP_REGISTRY_TEST_PG_URL=postgres://acdp:acdp@localhost:5433/acdp_registry \
  cargo test -p acdp-registry-server \
  --no-default-features --features storage-pg \
  --test pg_integration

docker stop acdp-test-pg

Tests run serially (#[serial_test::serial]) and truncate the registry tables between cases.

Build matrix

cargo build --release                                          # default = SQLite
cargo build --release -p acdp-registry-server                   \
    --no-default-features --features storage-pg                # Postgres only
cargo build --release -p acdp-registry-server                   \
    --no-default-features --features storage-memory            # In-memory
cargo build --release -p acdp-registry-server                   \
    --features storage-sqlite,playground                       # Playground

These four are the common ones, not the whole set. The binary's feature space is eight — 4 backend states (sqlite | pg | memory | none) x playground on/off — and CI builds all eight on every commit (#200).

Rather than repeat the list here and give it a second place to go stale, the authoritative index is the comment above the feature steps in the clippy job of .github/workflows/ci.yml. It carries the arithmetic that generates the count, so the list can be checked rather than trusted.

Note this is the server binary's feature space, not the workspace's: acdp-registry-types also builds without its default axum feature, and CI covers that separately: the clippy job lints it with --no-default-features (#221).

License

Dual-licensed under either of

  • Apache License, Version 2.0
  • MIT License

at your option. See LICENSE.