Expand description
HTTP JSON API for mnem.
Library half of the mnem http binary. app(repo_dir) builds an
axum Router that wraps an open ReadonlyRepo on repo_dir/.mnem
(auto-initialising if needed).
Scope v1:
GET /v1/healthz- liveness probe.GET /v1/stats- head op-id, commit CID, ref + label counts.POST /v1/nodes- commit a new node (label + summary + props).GET /v1/nodes/{id}- fetch one node by UUID.DELETE /v1/nodes/{id}- commit a removal of one node.GET /v1/retrieve?text=&budget=&limit=- dense vector retrieval (embedder required whentextis set). Returns rendered items plus budget metadata.
Tokio lives ONLY in this crate. mnem-core stays WASM-clean.
This crate compiles to a single binary + library pair.
Modules§
- leiden_
state - Gap 10 Phase-1 public surface: exposed for integration tests and operators who need to observe / override the Leiden cache policy.
Structs§
- AppOptions
- Options consumed by
app_with_options. Fields default to the same valuesappderives from the environment; tests construct an explicit value to bypass the env-var read. - AppState
- Shared application state passed to every axum handler via
State<AppState>. Clones are cheap (sharedArc). - Error
- HTTP error type for
mnem httphandlers. Renders as JSON{"schema": "mnem.v1.err", "error": "<message>"}with an HTTP status code attached viaIntoResponse. - Metrics
- Server-wide Prometheus metric registry.
Enums§
- Remote
Error - Error type for the
/remote/v1/*surface. Each variant maps to a single HTTP status code and renders as RFC 7807application/problem+jsonwith fieldstype,title,status, anddetail. ThetypeURI is stable per variant so clients can programmatically branch on it without string-matchingdetail.
Functions§
- app
- Build the router for a repo whose
.mnem/lives atrepo_dir. Opens or initialises the redb; returns the router youserve(). - app_
with_ options appwith programmatic overrides. Used by integration tests so they can flipallow_labelswithout touching the environment.- derive_
max_ path_ bytes - Runtime derivation:
max_path_bytes_total = remaining_ms * serialization_rate_bytes_per_ms, saturating on overflow. - route_
table - audit-2026-04-25 P2-7: enumerate every route the router mounts so
the startup banner in
mnem httpmain is no longer hand-written and incomplete. Each entry is(METHOD-LIST, PATH, brief). Kept in sync with theRouter::new().route(...)chain inapp_with_optionsby colocating the data here; tests intests/banner_route_table.rsassert the count matches the router’s route count.