# clawsync-agent ClawSync agent integration — autonomous sync scheduling and versioned memory for ZeroClaw/OpenClaw agents. ## Overview `clawsync-agent` wires `clawhdf5-onion` versioning into the ZeroClaw/OpenClaw agent runtime. After each agent flush, an autonomous `SyncScheduler` pushes new `.onion` revisions to a configured peer — no manual invocation required. Three transport backends are provided out of the box: | Backend | When to use | |---------|-------------| | `TcpSyncBackend` | Same LAN, pre-running `clawsync serve` daemon | | `QuicSyncBackend` | WAN / lossy links; QUIC + TLS 1.3; self-signed cert (dev) or CA-signed (prod) | | `SshSyncBackend` | No daemon required; spawns `clawsync serve --stdio` on demand via SSH | ## Quick start ```rust use clawsync_agent::{OnionMemory, tcp_scheduler, ssh_scheduler}; use clawsync_onion::selector::SyncSelector; // Versioned memory store — each save() auto-commits an onion revision. let mut memory = OnionMemory::create(config)?; memory.save(entry)?; // TCP scheduler — push to a running server. let sched = tcp_scheduler("127.0.0.1:9999", memory.path().to_owned(), "agent-1", SyncSelector::All)?; sched.push_if_dirty().await?; // SSH scheduler — no pre-running daemon needed. let sched = ssh_scheduler("alice@server.example.com", "/data/agent.claws", memory.path().to_owned(), "agent-1", SyncSelector::All); sched.push_if_dirty().await?; // Restore to an earlier revision. let old_memory = memory.restore_revision(0)?; ``` ## Modules ### `backend` `SyncBackend` trait + `TcpSyncBackend` / `QuicSyncBackend` / `SshSyncBackend`. All three implementations share the same IBLT pre-flight + W=16 pipelined push protocol, differing only in their transport layer. `QuicSyncBackend` uses `QuicConfig::insecure()` on the client side (skips cert verification); suitable for development and same-LAN deployments. For production, construct the backend manually with a trusted CA chain. `SshSyncBackend` spawns ` clawsync serve --stdio` per connection. The SSH binary defaults to `ssh` but can be overridden via `CLAWSYNC_SSH_COMMAND` — useful for testing with a fake-SSH shim. ### `onion_memory` `OnionMemory` — revision-aware wrapper around `HDF5Memory`. Maintains a WAL so in-flight entries are not lost on crash, and exposes `restore_revision(n)` for point-in-time rollback. ### `scheduler` `SyncScheduler` — tracks `last_pushed_rev` and calls `B::push` only when new revisions are available. `push_if_dirty()` is the entry point; `push_force()` bypasses the dirty check. Convenience constructors: `tcp_scheduler`, `quic_scheduler`, `ssh_scheduler`. ### `negotiator` `negotiate(local, remote) -> SessionCapabilities` — exchanges `PeerCapabilities` frames and returns the intersection of features both sides support (compression codec, BLAKE3, branching). ## License MIT — see repository root.