mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
Merge branch 'refs/heads/claude/sync-server-edc467' into feat/integration
# Conflicts: # docs/sync.md
This commit is contained in:
commit
cd03301abf
11 files changed
+433
-54
No files matched your search
@@ -12,6 +12,7 @@ See `.env.example`.
|
||||
| `SYNAPSE_DATA_DIR` | yes | Server graphs live in `<dir>/<graph_id>/` (`synapse.db` + `blobs/`) |
|
||||
| `SYNAPSE_AUTH_TOKEN` | yes | Bearer token(s), comma separated, ≥ 16 chars. Compared in constant time |
|
||||
| `SYNAPSE_BIND` | no | Listen address, default `127.0.0.1:7878` |
|
||||
| `SYNAPSE_MAX_CLOCK_SKEW_MINUTES` | no | Reject pushed ops whose HLC is further ahead of the server clock (default 10) |
|
||||
| `SYNAPSE_UPDATE_TOKEN` | no | Enables `/admin/update`; separate from the sync tokens |
|
||||
| `SYNAPSE_UPDATE_SCRIPT` | no | Default `/opt/synapse/scripts/update.sh` |
|
||||
| `SYNAPSE_LOG_FORMAT` | no | `text` (default) or `json` |
|
||||
|
||||
+25
-3
@@ -79,9 +79,31 @@ sync on SSE hint, when ops are pending or when due; on failure exponential backo
|
||||
with jitter); "offline" (connect/timeout errors) never loses edits, they stay pending. Call
|
||||
`trigger()` after local edits to sync without waiting for the poll.
|
||||
|
||||
The graph is shared as `Arc<Mutex<Graph>>`; the client locks it only for short DB steps. In the
|
||||
app, `synapse_ffi::api::graph::SynapseGraph::shared()` returns that same `Arc` to build a
|
||||
`SyncClient` next to the FFI handle.
|
||||
### Graph handle (FFI integration)
|
||||
`SyncClient::new(graph: Arc<Mutex<Graph>>, cfg)` — the expected handle type is
|
||||
`Arc<Mutex<synapse_core::Graph>>` (std `Mutex`). `synapse-ffi` holds its graph as that same
|
||||
`Arc` (`SynapseGraph::shared()` returns it) so UI edits and sync share one HLC clock and one
|
||||
connection. The client locks it only for short database
|
||||
steps (never across network calls) and runs them on `spawn_blocking`; it needs a tokio
|
||||
runtime (`start()` spawns onto the current one). After local edits call `trigger()`.
|
||||
|
||||
### Robustness
|
||||
- **Invalid ops**: the server validates every pushed op (`protocol::validate_op`: well-formed
|
||||
HLC, `PutAsset.hash` = 64 lowercase hex) and rejects ops whose HLC is more than
|
||||
`SYNAPSE_MAX_CLOCK_SKEW_MINUTES` (default 10) ahead of the server clock. Rejected ops are
|
||||
not stored; they are listed in `PushResponse.rejected` (`{index, reason}`) and the rest of the
|
||||
batch is still applied. Ops that fail to apply with a non-transient error (`Invalid`, `Json`,
|
||||
`Conflict`, `NotFound`) are rejected the same way; storage errors fail the request (retry).
|
||||
- **Quarantine (client)**: a pulled op that can never apply is logged, stored in table
|
||||
`sync_quarantine` (`server_seq, hlc, payload, reason`) and skipped, so the cursor advances.
|
||||
`SyncState.quarantined_ops` counts these plus ops the server rejected (per session).
|
||||
- **Missing local blob**: the asset's `PutAsset` op is not pushed (warning,
|
||||
`SyncState.skipped_assets`) and later ops still flow.
|
||||
- **Failed blob downloads** (e.g. 404): logged, counted in `SyncState.failed_blobs`, retried
|
||||
next cycle; other blobs and the op sync are unaffected. Connectivity/auth errors still abort
|
||||
the cycle.
|
||||
- **Uploads** only complete when the server reports the blob stored (`HEAD` 200); `202`/`409`
|
||||
responses make the client resume until done.
|
||||
|
||||
## Limits / not in v1
|
||||
- Per-user tokens and per-graph ACLs: `auth::Principal` already carries a graph allow-list;
|
||||
|
||||
Reference in new issue
Block a user