feat(sync): client sync engine with links, settings conflicts, transfers and background agent

Per-sequence state between the local index and a server from listings and
manifest diffs; version-counter settings sync with explicit conflicts; upload,
original and proxy download jobs; WebSocket-driven background agent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 22:23:23 +00:00
1 parent 7d95536096
commit b79e4ed6d9
13 files changed
+1858 -2

No files matched your search

@@ -0,0 +1,30 @@
-- Client sync state (BRIEF §4.4, §14.5): one row per sequence of a server this client has listed, linked to the local
-- copy when there is one. Versions are the counters both sides agreed on at the last sync. Mirrors sqlite/0004_sync.sql.
CREATE TABLE sync_links (
server text COLLATE "C" NOT NULL,
remote_id uuid NOT NULL,
local_id uuid REFERENCES sequences (id) ON DELETE SET NULL,
title text NOT NULL,
frame_count integer NOT NULL DEFAULT 0,
total_bytes bigint NOT NULL DEFAULT 0,
render_count integer NOT NULL DEFAULT 0,
remote_status integer NOT NULL DEFAULT 0,
remote_settings_version integer NOT NULL DEFAULT 0,
remote_frames_version integer NOT NULL DEFAULT 0,
remote_updated_at timestamptz NOT NULL,
base_local_settings integer,
base_remote_settings integer,
diff_local_frames integer,
diff_remote_frames integer,
missing_remote integer NOT NULL DEFAULT 0,
missing_local integer NOT NULL DEFAULT 0,
conflict_local_settings integer,
conflict_remote_settings integer,
conflict_settings text,
proxies_cached integer NOT NULL DEFAULT 0,
proxies_frames_version integer,
synced_at timestamptz,
PRIMARY KEY (server, remote_id)
);
CREATE UNIQUE INDEX ix_sync_links_local ON sync_links (server, local_id);
@@ -0,0 +1,30 @@
-- Client sync state (BRIEF §4.4, §14.5): one row per sequence of a server this client has listed, linked to the local
-- copy when there is one. Versions are the counters both sides agreed on at the last sync. Mirrors postgres/0004_sync.sql.
CREATE TABLE sync_links (
server TEXT NOT NULL,
remote_id TEXT NOT NULL,
local_id TEXT REFERENCES sequences (id) ON DELETE SET NULL,
title TEXT NOT NULL,
frame_count INTEGER NOT NULL DEFAULT 0,
total_bytes INTEGER NOT NULL DEFAULT 0,
render_count INTEGER NOT NULL DEFAULT 0,
remote_status INTEGER NOT NULL DEFAULT 0,
remote_settings_version INTEGER NOT NULL DEFAULT 0,
remote_frames_version INTEGER NOT NULL DEFAULT 0,
remote_updated_at TEXT NOT NULL,
base_local_settings INTEGER,
base_remote_settings INTEGER,
diff_local_frames INTEGER,
diff_remote_frames INTEGER,
missing_remote INTEGER NOT NULL DEFAULT 0,
missing_local INTEGER NOT NULL DEFAULT 0,
conflict_local_settings INTEGER,
conflict_remote_settings INTEGER,
conflict_settings TEXT,
proxies_cached INTEGER NOT NULL DEFAULT 0,
proxies_frames_version INTEGER,
synced_at TEXT,
PRIMARY KEY (server, remote_id)
);
CREATE UNIQUE INDEX ix_sync_links_local ON sync_links (server, local_id);