feat(sync): op-log sync protocol, client and axum server

Adds synapse-sync (protocol types, Remote transport and read API, SyncClient with
background loop, SSE realtime, resumable blobs) and synapse-server (multi-graph,
bearer auth, blob streaming, read API, authenticated update endpoint), with e2e
tests, docs/sync.md, docs/server.md, systemd unit and update script.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Sonnet 5.5 committed 2026-10-21 04:25:00 +02:00
1 parent fbcfcf678f
commit 4aa3c01a7f
25 files changed
+4299 -10

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# Idempotent update of a Synapse server install: pull, build, install the binary atomically.
# Run as the service user (by hand or via POST /admin/update). Exit codes:
# 0 updated; the caller (the server) exits so systemd restarts the new binary
# 10 already up to date, nothing to restart
# other: failed; the running binary is left untouched
set -euo pipefail
REPO_DIR="${SYNAPSE_REPO_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}"
BIN_DIR="${SYNAPSE_BIN_DIR:-/opt/synapse/bin}"
BRANCH="${SYNAPSE_UPDATE_BRANCH:-main}"
export PATH="$HOME/.cargo/bin:$PATH"
log() { printf '%s %s\n' "$(date -u +%FT%TZ)" "$*"; }
trap 'log "update FAILED (line $LINENO)"' ERR
cd "$REPO_DIR"
log "fetching $BRANCH"
git fetch --quiet origin "$BRANCH"
local_rev=$(git rev-parse HEAD)
remote_rev=$(git rev-parse "origin/$BRANCH")
if [ "$local_rev" = "$remote_rev" ] && [ -x "$BIN_DIR/synapse-server" ]; then
log "already up to date ($local_rev)"
exit 10
fi
log "updating $local_rev -> $remote_rev"
git merge --ff-only "origin/$BRANCH"
log "building (release)"
cargo build --release --locked -p synapse-server
# Schema migrations run in synapse-core when each graph is opened; nothing to do here.
mkdir -p "$BIN_DIR"
install -m 0755 target/release/synapse-server "$BIN_DIR/synapse-server.new"
mv -f "$BIN_DIR/synapse-server.new" "$BIN_DIR/synapse-server" # atomic replace
log "installed $remote_rev"