# `RepoMirror`

A class in `fastatp.repo.sync` ([source](https://github.com/jacoblapenna/fastatp/blob/main/fastatp/repo/sync.py#L192)).

```python
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

- `did`
- `resolver`
- `store`
- `entries: dict[str, CID]`
- `commit: Commit | None`
- `seq: int | None`
- `resync_target: Commit | None`
- `rev: str | None`

## Methods

### `signing_keys`

```python
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`](https://fastatp.com/api/didnotfound.md) (miss) and [`DIDResolutionTimeout`](https://fastatp.com/api/didresolutiontimeout.md) (transient) —
deliberately NOT wrapped as RepoError, which signals a bad event.

### `handle_frame`

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

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

### `apply_sync`

```python
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`

```python
async load_checkpoint(car: bytes) -> None
```

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

### `apply_commit`

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

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

### `get_record`

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