Skip to main content

Crate hyprstream_pds

Crate hyprstream_pds 

Source
Expand description

atproto PDS record store — the federated spine’s signed-mutable-pointer layer (#392).

Per-account record store hosting ai.hyprstream.model records in a Merkle Search Tree (MST), emitting signed commits, and serving CAR proofs. This is the consensus-free versioning primitive: a signed mutable pointer → immutable OID that makes federation work without a coordinator.

§What this crate provides

  • Existing native CBOR deterministic encode/decode (dag_cbor): map keys sorted in lexical text-byte order, minimal-length ints and no duplicate keys. Public AT DAG-CBOR instead requires length-first key order; atproto_cbor provides that explicit boundary without changing existing native signed artifacts. Public repository call-site integration is still required; the existing commit/MST APIs retain their existing bytes. CID links use CBOR tag 42 per the DAG-CBOR spec. The same record produces identical bytes → same CID every time.
  • ai.hyprstream.model record (record) — the confirmed 3-field lexicon: repo (at-uri), currentOid (cid), createdAt (datetime). DAG-CBOR encoded; currentOid is a format: "cid" string (not a link).
  • MST (mst) — the atproto repo structure (Auvolat & Taïani, SRDS 2019). Insert/delete records keyed by TID; compute the MST root CID. Implemented as the full recursive tree (NodeData { l, e: [TreeEntry { p, k, v, t }] }) matching the atproto reference.
  • Signed commit (commit) — {did, version: 3, rev, data, prev, sig}. sig is ES256 (P-256 ECDSA over SHA-256) of the DAG-CBOR of the unsigned commit (commit minus the sig field), signed with the DID’s #atproto P-256 key.
  • CAR proof (car) — serve getRepo/getRecord as a CAR (Content Addressable aRchive) containing the commit + MST path + record.
  • verifyRecordProof (car::verify_record_proof) — offline verification: check commit sig, walk the MST proof to the record, verify the record’s CID. Enforces the D5 untrusted-host posture.

§What this crate deliberately is NOT

  • No libtorch / inference — this is a metadata/crypto layer.
  • No networking — proofs are produced and verified in-process; a transport (HTTP/moq) wraps this separately.
  • No general repo database — MST/CAR stores remain in-memory. The narrow exception is DirectoryHostedAccountStore, which durably establishes an account’s immutable genesis bundle and generated #atproto secret.

§Reused infrastructure

ES256/P-256 key handling mirrors hyprstream::auth::key_rotation (Es256SigningKeyStore) and the DID-document #atproto verification method from hyprstream::services::oauth::did_document. The signing key type is the same p256::ecdsa::SigningKey, so a key from the rotation store drops in directly.

Re-exports§

pub use account_label::AccountLabel;
pub use account_label::AccountLabelRegistry;
pub use account_label::ReservedAccountLabel;
pub use account_label::MAX_ACCOUNT_LABEL_LEN;
pub use account_label::RESERVED_ACCOUNT_LABELS;
pub use cid::Cid;
pub use did_op::sign_genesis;
pub use did_op::DidOpSignature;
pub use did_op::GenesisDidOp;
pub use did_op::GenesisRepoHead;
pub use did_op::GenesisRotationKeys;
pub use did_op::HostKeyEnrollment;
pub use did_op::HostRotationKey;
pub use did_op::HybridRotationKey;
pub use did_op::RecoveryKeyEnrollment;
pub use did_op::RecoveryRotationKey;
pub use did_op::RotationSlotRef;
pub use did_op::UnsignedGenesisDidOp;
pub use did_op::UserRotationKey;
pub use did_op::DID_OP_SIGNATURE_CONTEXT;
pub use did_op::DID_OP_VERSION;
pub use hosted_account::is_hosted_account_staging_directory;
pub use hosted_account::AccountRecord;
pub use hosted_account::AllocatedAccountName;
pub use hosted_account::DirectoryHostedAccountStore;
pub use hosted_account::HostedAccountMint;
pub use hosted_account::PendingHostedAccountMint;
pub use hosted_account::SealedHostedAccount;
pub use hosted_account::ACCOUNT_RECORD_VERSION;
pub use hosted_account::ATPROTO_SIGNING_KEY_FILE;
pub use hosted_account::DID_DOCUMENT_FILE;
pub use hosted_account::GENESIS_DID_OP_FILE;
pub use hosted_did_document::SealedHostedDidDocument;
pub use hosted_did_document::DID_DOCUMENT_MEDIA_TYPE;
pub use hosted_did_document::DID_DOCUMENT_PATH;
pub use hosted_did_document::DID_OPERATION_LOG_PATH;
pub use hosted_repo::HostedRepoGenesis;
pub use ledger::AllocationRecord;
pub use ledger::CheckpointRecord;
pub use ledger::GrantClass;
pub use ledger::ReceiptRecord;
pub use ledger::StateRoot;
pub use ledger::Unit;
pub use name_record::NameRecord;
pub use placement::GroupItemRecord;
pub use placement::GroupRecord;
pub use placement::NodeRecord;
pub use placement::WorkloadRecord;
pub use record::ModelRecord;
pub use repo_authority::accept_repo_authority;
pub use repo_authority::RepoAuthority;

Modules§

account_label
Account-label grammar and never-reuse allocation policy (#1160 / A2).
at9p
did:at9p capsule, update-record, and shard-manifest schema.
at9p_alias
Authoritative direction for did:web / did:key ↔ did:at9p aliasing (#896 / D4; design #879 Q4, ratified #905 §2/§6).
at9p_chain
B1: did:at9p update-record chain validation — the successor-check (#885).
at9p_duplicity
B2 (#886): KERI-style duplicity detection — the duplicity-check layer that wraps B1’s validate_successor (#885) — and B3 (#887): the empty/exhausted next_key_commitments commitment-lifecycle semantics.
at9p_gate
GATE verification pipeline for did:at9p genesis capsules (#884, design #879 §5.6).
at9p_resolver
hyprstream-pds implementation of hyprstream_rpc::identity_resolver::At9pCapsuleResolver — the bridge from the A4 GATE pipeline (#884) to the did:at9p admission and resolver arms (D2/#894).
at9p_sign
Policy-gated composite signing and verification for did:at9p records (capsules and update-records), per design #879 §4.4 (Hybrid-pinning) and review rules R4/R8 (findings A18/A19).
atproto_cbor
Explicit public AT Protocol CBOR boundary over the existing value type.
car
CAR (Content Addressable aRchive) proof production and verification.
cid
CIDv1 (Content IDentifier) for DAG-CBOR blocks.
commit
Signed atproto repository commits.
dag_cbor
Hyprstream’s existing deterministic CBOR encoding/decoding.
did_op
The permanent genesis operation for a hyprstream-hosted did:web account.
event_group
ai.hyprstream.event.group / ai.hyprstream.event.groupItem — lexicon records for EventService managed-list groups (epic #600, EV2 #602).
hosted_account
Hosted-account record and mint state machine.
hosted_did_document
Canonical DID-document artifact for a hyprstream-hosted account.
hosted_repo
Initial atproto repository state for a hosted PDS account.
ledger
ai.hyprstream.ledger.* — the cellular-ledger inventory lexicons (#924).
list_record
Generic atproto “list” + “listitem” record shapes, shared by every list-style lexicon in this crate (ai.hyprstream.placement.group/ groupItem, ai.hyprstream.event.group/groupItem, and any future one).
mst
Merkle Search Tree (MST) — the atproto repo’s per-account record store.
name_record
ai.hyprstream.name — the NameRecord: the trusted, PQ-signed name → DID URL layer (#908, design #905 §1/§3/§6; #879 §Name-resolution).
placement
ai.hyprstream.placement.* — the P1 placement-directory lexicons.
rds
Records/repository RDS (Multi-AZ Postgres) binding and its contract validation (#1257).
record
ai.hyprstream.model — the per-account signed-mutable-pointer record.
repo_authority
Which DID methods our PDS accepts as a repo authority — the account DID that owns a repository and signs its commits (#908, design #905 §6).
tid
atproto TID (Timestamp Identifier) — lexicographically-sortable record keys.