Skip to main content

Crate mnem_http

Crate mnem_http 

Source
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 when text is 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 values app derives 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 (shared Arc).
Error
HTTP error type for mnem http handlers. Renders as JSON {"schema": "mnem.v1.err", "error": "<message>"} with an HTTP status code attached via IntoResponse.
Metrics
Server-wide Prometheus metric registry.

Enums§

RemoteError
Error type for the /remote/v1/* surface. Each variant maps to a single HTTP status code and renders as RFC 7807 application/problem+json with fields type, title, status, and detail. The type URI is stable per variant so clients can programmatically branch on it without string-matching detail.

Functions§

app
Build the router for a repo whose .mnem/ lives at repo_dir. Opens or initialises the redb; returns the router you serve().
app_with_options
app with programmatic overrides. Used by integration tests so they can flip allow_labels without 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 http main is no longer hand-written and incomplete. Each entry is (METHOD-LIST, PATH, brief). Kept in sync with the Router::new().route(...) chain in app_with_options by colocating the data here; tests in tests/banner_route_table.rs assert the count matches the router’s route count.