Synchronization protocol (v1)#
Client: packages/core/src/rvc_core/sync.py. Server: apps/api/src/rvc_api/routers/sync.py.
Base URL of a remote: https://<host>/api/v1/sync/<org>/<project>; authentication with
Authorization: Bearer <token> (API token or session). Every request carries
X-RVC-Protocol: 1.
Endpoints#
| Method | Path | Purpose |
|---|---|---|
| GET | /info |
protocol version, capabilities, caller's role |
| GET | /refs |
{refs: {name: id}, head: "refs/heads/main"} |
| POST | /objects/missing |
{ids} → {missing} (write permission required) |
| POST | /objects/pack |
upload a pack (≤ max_pack_bytes) |
| POST | /uploads |
start/resume a large-object upload {object_id,size} → {upload_id, offset} or {stored:true} |
| PUT | /uploads/{id}?offset=N |
append a chunk (≤ 64 MiB, optional X-Chunk-SHA256) |
| POST | /uploads/{id}/complete |
server verifies sha256 = object id, then stores |
| POST | /closure |
{wants, haves} → ids reachable from wants minus closure of haves |
| POST | /objects/fetch |
{ids} → pack of the small ones (large ones omitted) |
| GET | /objects/{id} |
stream one object (verified while streaming) |
| POST | /refs/update |
atomic multi-ref compare-and-swap |
Pack format#
"RVCPACK1" then repeated records: 64-byte ASCII id, 8-byte big-endian length, bytes.
The receiver verifies sha256(bytes) == id and validates structured objects against their
schema before storing anything referenced.
Push#
GET /refs. For each branch to push: reject locally if the remote value is not an ancestor of the local one (unless--force). Tags and releases are immutable remotely.- Compute the object closure of the new tips, excluding the closure of remote tips that exist locally.
POST /objects/missingin batches → upload small objects in packs, large ones (> 8 MiB) by resumable upload.POST /refs/updatewith{ref, old, new, force}. The server, inside one transaction with row locks: checks everyoldequals the current value; rejects non-fast-forward branch updates unlessforceand permitted; applies branch-protection rules; verifies the complete closure of each new tip is present and valid. All updates apply or none do.- On success the client updates
refs/remotes/<remote>/<branch>.
Fetch / pull / clone#
GET /refs → POST /closure with local ref values as haves → fetch packs (and stream large
objects individually) → verify the closure locally → only then update remote-tracking refs.
Tags/releases are created locally only if absent. pull = fetch + merge of the tracking
branch. clone = init + fetch + checkout of the remote HEAD branch.
Failure behaviour#
Objects are immutable and verified, so every step is idempotent and retryable. Objects are always written before refs; an interrupted push or fetch leaves only unreferenced objects (garbage-collectable), never a ref pointing to incomplete history. Large uploads resume from the server's recorded offset (the bytes on disk are authoritative).
Tenant isolation#
Each repository has its own object namespace on the server. Objects are not deduplicated
across repositories, so /objects/missing cannot be used to learn whether another tenant
holds a given file.