Skip to main content

Module server_client

Module server_client 

Source
Expand description

The component inside Kimün that owns every dealing with the RAG server: connection/capability probing, pushing note changes, and hash-diff reconciliation (see CONTEXT.md, “Server client”). Core stays network-free; it feeds this module only through the observer seam, which reports a path, a content hash and upsert-or-delete, and knows nothing of RAG.

Published as the kimun_server_client crate until kimun-notes went to crates.io — which forced every path dependency of a published crate to be published too, and this one was on crates.io for no reason of its own. Like the ropetext module it stays self-contained, so it can go back out if a second consumer (a GUI) ever wants it: nothing here may name crate:: outside crate::server_client::, checked in CI. kimun_core is the one kimün dependency it keeps, and it would keep that as a crate too.

Re-exports§

pub use dto::ChunkResult;
pub use dto::WireSection;
pub use observer::DirtyOp;
pub use observer::DirtySet;
pub use observer::RagObserver;
pub use reconcile::ReconcilePlan;
pub use reconcile::diff as reconcile_diff;

Modules§

dto
Wire types mirroring the RAG server’s JSON. Defined here (not shared with the server crate) so the client stays independent of the server build.
observer
The IndexObserver the client registers on the vault, and the dirty-set it feeds. The dirty-set is deliberately best-effort in-memory: a lost entry costs a reconciliation pass, not a lost update.
reconcile
Hash-diff reconciliation: the correctness backbone. Given the vault’s authoritative {note-path → hash} and the server’s, compute exactly which notes to push and which to delete so the two agree.
sync
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§

RagClient
HTTP client for one vault’s collection on a RAG server.

Enums§

ContextSize
Number of results to request. Maps to the server’s context_size variants, so a caller can’t send an invalid string (which the server rejects with 400).
RagError

Traits§

RagTransport
The subset of server operations the sync orchestration depends on, behind a trait so it can be exercised with a fake in tests. RagClient is the real implementation.

Functions§

hash_string
The single place a note’s content hash is turned into its wire/reconcile string. Both the pushed WireDoc::hash and the reconcile local hash set MUST go through this — string equality in reconcile::diff only holds if the two are byte-identical.