Expand description
mimir-librarian — Mimir librarian. Ingests prose memory drafts,
sanitises them (separates observations from directives), structures
them into canonical Mimir Lisp, and commits them to the canonical
log via the in-process mimir_core::Pipeline.
Category 1 of the 2026-04-21 Rolls Royce engineering plan for librarian-governed draft processing.
§Status
Draft-ingestion foundation. The scope-aware draft envelope,
filesystem draft store, submit command, explicit file/directory
sweep command, rename-based lifecycle transitions, one-shot
run lifecycle skeleton, scratch-pipeline pre-emit validation,
bounded LLM validation retry with durable commit, and shared
workspace write-lock acquisition are wired. The remaining Category
1 work still lands one concern at a time per the build discipline
documented in the Rolls Royce plan.
See the crate README.md for the architectural decisions from
the 2026-04-21 Category 1 design conversation and the roadmap
of follow-up PRs that fill the skeleton in.
§Architecture sketch
┌───────────────┐ ┌───────────────┐ ┌─────────────────────┐
│ Drafts surface│──▶│ LlmInvoker │──▶│ PreEmitValidator │
│ (filesystem) │ │ (claude -p) │ │ (mimir_core Pipeline│
│ │ │ │ │ clone-on-write) │
└───────────────┘ └───────────────┘ └─────────┬───────────┘
│
▼
┌──────────────────────┐
│ mimir_core::Store │
│ commit_batch │
└──────────────────────┘The draft lifecycle, LLM invocation, bounded validation retry,
validator box, Store::commit_batch durable commit,
supersession-conflict policy, exact duplicate filtering across all
four memory types, and configurable same-day valid_at dedup for
Semantic / Inferential records are wired. The binary also exposes a
polling watch scheduler, and librarian-specific observability is
wired for runner and processor paths. Store commits acquire the
shared mimir_core::WorkspaceWriteLock, so direct librarian runs
and MCP write sessions exclude each other without introducing an
MCP dependency. The earlier Python prototype is retired and is no
longer shipped in the public tree.
Structs§
- Claude
CliInvoker - Production
LlmInvokerthat shells out to theclaudeCLI in non-interactive mode. - Dedup
Policy - Deterministic duplicate-detection policy for candidate records.
- Deferred
Draft Processor - Placeholder processor used until LLM structuring / validation / commit processing is wired.
- Draft
- A prose memory draft staged for librarian processing.
- DraftId
- Content-addressed identifier for a draft. First 8 bytes of the SHA-256 of the prose, rendered as a 16-character lowercase hex string on display.
- Draft
Metadata - Metadata required by
scope-model.md§ 4 for every raw draft. - Draft
RunItem - One processed draft row for operator-visible run summaries.
- Draft
RunSummary - Summary of one run.
- Draft
Store - Filesystem-backed draft surface.
- Draft
Transition - Result of a successful draft lifecycle transition.
- Librarian
Config - Runtime configuration for a single librarian invocation.
- Participant
Vote - Vote plus confidence and rationale.
- PreEmit
Validator - Validates a candidate canonical Lisp record against a scratch
mimir_core::Pipelinebefore the librarian attempts to commit it to the real log. - Quorum
Adapter Request - Request payload consumed by a future participant adapter.
- Quorum
Episode - Requested quorum episode envelope.
- Quorum
Participant - Participant identity captured for quorum auditability.
- Quorum
Participant Output - Participant prompt/response captured for a deliberation round.
- Quorum
Result - Synthesized quorum result envelope.
- Quorum
Store - File-backed quorum episode/result store.
- RawArchive
Draft Processor - Deterministic processor that archives raw draft text as governed pending-verification evidence without invoking an LLM.
- Retrying
Draft Processor - LLM-backed draft processor with bounded validation retry.
Enums§
- Consensus
Level - Degree of agreement in a quorum result.
- Decision
Status - Final quorum decision status.
- Draft
Processing Decision - Decision returned by a draft processor.
- Draft
Source - Where a draft came from. Drives provenance + retention policy
(e.g.
AutoMemorySweepdrafts may be deleted after successful commit;CliSubmitdrafts may be retained for operator review). - Draft
Source Surface - Source surface that exposed a draft to Mimir.
- Draft
State - Lifecycle state of a draft on the filesystem.
- Librarian
Error - Every externally-observable failure mode of the librarian.
- Quorum
Episode State - Lifecycle state for one quorum episode.
- Quorum
Round - Deliberation round that can receive participant outputs.
- Supersession
Conflict Policy - Policy for deterministic supersession conflicts.
- Vote
Choice - Individual participant vote.
Constants§
- DEFAULT_
DEDUP_ VALID_ AT_ WINDOW_ SECS - Default duplicate-detection
valid_atwindow, in seconds. - DEFAULT_
LLM_ TIMEOUT_ SECS - Default
claude -pinvocation timeout, in seconds. - DEFAULT_
MAX_ RETRIES_ PER_ RECORD - Default maximum number of per-record retries when a candidate record fails pre-emit validation.
- DEFAULT_
PROCESSING_ STALE_ SECS - Default age after which a draft left in
processing/is assumed abandoned and recovered topending/. - DRAFT_
SCHEMA_ VERSION - Current on-disk draft schema version.
- QUORUM_
SCHEMA_ VERSION - Current on-disk quorum episode/result schema version.
- SYSTEM_
PROMPT - Canonical location of the librarian’s system prompt.
Traits§
- Draft
Processor - Processor invoked for each claimed draft.
- LlmInvoker
- Ask the LLM to produce a JSON response for a prose draft.
Functions§
- run_
once - Run pending draft processing once.