Skip to main content

Module sync

Module sync 

Source
Expand description

Orchestration: turn observed changes and the vault’s authoritative state into server pushes/deletes. RagSync wires the observer; drain flushes the dirty-set (the fast path); reconcile is the correctness backbone. All server I/O goes through RagTransport, so this logic is tested with a fake against a real vault.

Structs§

RagSync
Bundles a vault, its dirty-set, and the server client, and drives sync. The caller (the TUI) owns the schedule: probe to gate features, and call tick periodically to keep the server in step.
ServerProbe
One /health round-trip’s worth of facts: what the server can do, and whether it gates its API behind a bearer token. /health itself is un-gated, so a client with a missing/wrong token still probes fine — auth_required lets it report “unauthorized” up front instead of discovering a 401 on the first sync call.

Enums§

ServerCapability
What a reachable server can do, derived from /health: search needs an embedder, question-answering needs an embedder AND an LLM.

Functions§

build_doc
Builds the wire document for a note: its canonical path, content hash, and heading sections pulled from the index. Returns None when the note has no indexable sections — an empty note is not RAG content, so it is never pushed (this keeps both backends from perpetually re-pushing chunkless notes, since only one of them records a hash for them server-side).
drain
Flushes the dirty-set to the server. Failed operations are re-queued so the next drain (or a reconcile) retries them.
reconcile
Reconciles the server with the vault: diff hash sets, then push/delete only the differences. Self-healing — repairs anything the drain path missed.