FastATP

RepoMirror

A class in fastatp.repo.sync (source).

RepoMirror(did: str, resolver: DIDResolver | None = None)

Verified follower of one producer's repo.

Keeps the current key->CID map, the record blocks, the last commit, and the last seen firehose seq (its resume cursor).

Attributes

Methods

signing_keys

async signing_keys() -> list[PublicKey]

Candidate signing keys, re-resolved per verification.

No local caching: the resolver already caches (WebResolver honors Cache-Control), so key rotation propagates instead of being pinned to whatever key the mirror saw first. Rotation-listed keys are excluded; the #atproto-fragment method is preferred.

Resolution failures propagate as themselves so callers can retry: DIDNotFound (miss) and DIDResolutionTimeout (transient) — deliberately NOT wrapped as RepoError, which signals a bad event.

handle_frame

async handle_frame(data: bytes) -> list[dict[str, Any]]

Dispatch one wire frame; returns new record JSONs for #commit.

apply_sync

async apply_sync(body: dict[str, Any]) -> None

Handle a #sync: verify the asserted commit; adopt or flag resync.

Per the sync spec the blocks CAR carries the commit block only. If the asserted state matches what this mirror already holds, it is a confirmation. Otherwise resync_target is set and the caller must fetch the full repo (getRepo) and pass it to load_checkpoint. A CAR that happens to carry the full state (FastATP's pre-Gate-14 checkpoint shape) is loaded directly.

load_checkpoint

async load_checkpoint(car: bytes) -> None

Adopt a full current-state CAR (a getRepo body) as local state.

apply_commit

async apply_commit(body: dict[str, Any]) -> list[dict[str, Any]]

Verify and apply one commit event; returns created/updated records.

get_record

get_record(collection: str, rkey: str) -> dict[str, Any] | None