Skip to main content

Module boot

Module boot 

Source
Expand description

ai-memory boot — universal session-boot context primitive (issue #487).

Every AI-agent integration recipe (Claude Code SessionStart hook, Cursor .cursorrules boot directive, Cline / Continue / Windsurf system-message, Codex CLI / Claude Agent SDK / OpenAI Apps SDK programmatic prepend, OpenClaw built-in, local models via LM Studio / Ollama / vLLM) calls this same subcommand and consumes its stdout as the agent’s first-turn context.

Boot deliberately does not load the embedder. It returns the most-recently-accessed memories in the inferred namespace, falls back to the most-recently-accessed memories globally if the namespace is empty, and clamps output to a token budget so a misconfigured agent can’t bloat its first turn.

Failure modes are graceful by default:

  • DB unavailable + --quiet: exit 0, empty stdout (a hook that fails here would otherwise wedge the agent’s session).
  • DB unavailable + no --quiet: write the error to stderr, emit only the header on stdout, still exit 0.
  • No memories found: emit the header (or nothing with --no-header), exit 0.

§Diagnostic manifest (PR-4 of #487)

Boot’s header is a transparent, multi-field manifest — never a black box. Every field reflects a fact about this invocation so agents and humans always know exactly what was loaded and what’s configured. Fields:

  • version — binary version (CARGO_PKG_VERSION at compile time)
  • db — resolved DB path + schema version + total live memories
  • tier — active feature tier and configured (not loaded) embedder / reranker / llm models
  • latency — wall-clock from run() entry to header emit
  • namespace — resolved namespace + how many memories matched

Structs§

BootArgs
Args for ai-memory boot. Every field has a defaulted value so the subcommand is safe to invoke with no arguments — that is the contract every integration recipe relies on.

Enums§

BootFormat
Output formats supported by ai-memory boot.

Constants§

MAX_SUPPORTED_SCHEMA
Upper bound of the DB-schema range this binary supports.
MIN_SUPPORTED_SCHEMA
Lower bound of the DB-schema range this binary supports. Below this we emit a warn-schema-unsupported manifest header so the user knows their ai-memory binary is too new for an old DB. Set to the v0.6.3 baseline (16) — older schemas won’t have the columns the recall pipeline expects. v0.6.3.1 (PR-9h / issue #487 PR #497 req #72).

Functions§

run
ai-memory boot entry point.
schema_in_supported_range
Pure boundary check: true when v lies within [MIN_SUPPORTED_SCHEMA, MAX_SUPPORTED_SCHEMA]. Extracted so the boundary semantics (inclusive both ends) can be unit-tested without needing a synthetic DB whose schema_version lies outside the migration ladder’s reach. v0.6.3.1 (PR-9h / issue #487 PR #497 req #72).