-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The Tauri relay (NotebookSyncClient) still holds a full AutoCommit Automerge replica. With daemon-owned loading (#598) complete, the relay's doc is only needed for:
get_doc_bytes()— frontend fetches full doc bytes to seed its WASM handleSyncUpdatemetadata diffing — detects metadata changes to emitnotebook:metadata_updatedevents
3. — removed in PR #602get_cells() in save_notebook_as
4. Cell population via — removed in PR #602initialize_notebook_sync
Remaining work
Reroute get_doc_bytes()
The frontend calls invoke("get_automerge_doc_bytes") at bootstrap to seed the WASM handle. Currently this reads from the relay's AutoCommit. Options:
- Daemon request: Add a
NotebookRequest::GetDocBytesthat returns the daemon's canonical doc bytes. The relay forwards the response without parsing. - WASM export: Have the frontend WASM export its own bytes. But on first bootstrap, the WASM doc is empty — it needs bytes from somewhere.
Daemon request is the cleaner path.
Move metadata change detection to frontend
The relay's run_sync_task uses SyncUpdate.notebook_metadata to detect metadata changes and emit notebook:metadata_updated. The frontend WASM doc already has full metadata — when receive_sync_message applies changes, the frontend can diff and emit events locally.
Strip the relay
- Remove
doc: AutoCommitfromNotebookSyncClient - Reduce
SyncCommandenum — removeAddCell,DeleteCell,UpdateSource,AppendSource,ClearOutputs,AppendOutput,SetExecutionCount,GetCells,SetMetadata,GetMetadata,GetDocBytes - Keep:
SendRequest,ReceiveFrontendSyncMessage, and lifecycle commands - Keep
peer_state+frontend_peer_state— Automerge sync protocol still needs peer state tracking
runtimed-py is unaffected
The Python SDK uses connect_split (not connect_split_with_raw_sync) and legitimately operates as a full Automerge peer. The simplification is Tauri-path-specific.
Impact
Eliminates 8 correctness findings from the protocol audit (including 2 High severity):
sync_to_daemon()broadcast droppingchanged_rx.recv()Lagged/Closed handling- Triple-merge divergence risk
try_sendsilent drops onchanges_txbiasedselect starvation- Virtual sync handshake 10-iteration limit
raw_sync_txsend failuresreceive_and_relay_sync_messagewrong peer state
Size
L (but closer than originally scoped — cell population and get_cells() already removed)