Files
clawsync/crates/clawsync-agent/README.md
osobhandClaude Sonnet 4.6 6d2eb5a1db feat: QUIC backend tests, diff command, clippy/doc fixes, QUIC push race fix
- Add QuicSyncBackend + quic_scheduler; fix push stream/close race by
  waiting for peer close instead of calling close_and_drain() on the
  client side (SyncComplete stream was racing CONNECTION_CLOSE)
- Add PipeWriteHalf::shutdown_push() for client-sends-last QUIC paths;
  use it in cmd_push so the server can process SyncComplete before the
  connection tears down
- Add SshSyncBackend + ssh_scheduler with subprocess integration tests
- Add clawsync diff command with --porcelain flag and subprocess tests
- Add QUIC subprocess push/pull integration tests
- Fix clippy --tests violations across 5 crates
- Fix broken intra-doc links (reader.rs, lib.rs, scheduler.rs)
- Rewrite crate READMEs; update BENCHMARKS.md with clawsync-fs CDC row

653 tests, 0 failures.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
2026-04-06 22:40:31 -05:00

83 lines
2.9 KiB
Markdown

# 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("[email protected]", "/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 `<ssh_command> <user_host> clawsync serve <remote_path>
--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<B>` — 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.