Skip to main content

Module driver

Module driver 

Source
Expand description

Driving a place’s replica from the server (SPEC-ENGINE §3.4.3–§3.4.4): clone (signed manifest, then every segment, each verified before import, refetched once on a mismatch), tail since the cursor, and push of own events. The server log is the only source of truth: accepted pushes stay pending until the tail delivers them.

Structs§

PushReport
What a push did.
SyncReport
What a clone or tail did.
Verifier
How a place’s events are checked on receive: the Cloud snapshot keys and the signer rules of §3.3.5 (class W worker keys, class A Cloud keys).

Traits§

PlaceApi
The routes a replica needs. crate::transport::CloudClient implements it; tests use an in-memory server.

Functions§

clone_place
Clone place into an empty replica: verified manifest, then every segment. A segment that fails its checks is fetched once more; a second failure stops the clone (segment_unavailable) with nothing of it stored. A snapshot revision that rotated out meanwhile (404 not_found, only the latest 2 are kept) restarts the clone once from a fresh manifest.
deletions
Deletions while the month’s transfer is used up (E2E-FINAL). E4 then answers only the purge tombstones of purges still waiting for acks, with next_since = since (deleting is protected capacity). They fold on top of the replica’s graph without being stored, so the cursor never moves past events not received yet, and the bodies they purge are shredded at once; the caller denies, removes local text and acks. None: the answer was an ordinary page (it moved on, or held other events), so the quota is back and a full sync is due.
push_acks
Send signed purge acks alone (an ack-only E5 push, never metered).
push_pending
Push the replica’s pending own events in batches of push::MAX_BATCH, with the signed purge acks riding on the first request (one is sent even without events). Failed events leave the pending queue; everything else stays pending until the tail delivers it. report.acked is true when the acks reached the place.
reconcile
Failover reconcile (SPEC-ENGINE §3.4.4, RESOLUTIONS R48), once per trigger: re-push the kept own batches unchanged (the place answers duplicate for what it still holds and logs the lost ones again), re-tail from the lowest seq received in the last 24 h (or the place’s head_seq after a restore), drop local rows whose seq came back with another event or not at all, refold, then take the new epoch.
tail
Fetch the log since the replica’s cursor, page by page, store what verifies (and what does not, marked sig_invalid), settle own pending events the log now holds, and refold.