Expand description
Project and global memory management.
Memory is organised in two tiers:
- Project:
<project>/.codelens/memories/ - Global:
$HOME/.codelens/memories/
The public API is intentionally flat (codelens_engine::memory::*) while
the implementation is split by responsibility to keep policy, path
resolution, persistence, archive, audit, and frontmatter logic independent.
Structs§
- Memory
Frontmatter - Parsed YAML frontmatter from a memory markdown file.
- Memory
Location - A resolved memory location that carries its tier and absolute path.
- Memory
Metadata - Metadata returned alongside memory content for rich responses.
- Memory
Policy - Policy controlling visibility and mutability of memory entries.
- Null
Recorder - A no-op recorder that discards all events.
Enums§
- Memory
Audit Event - Lifecycle event for a memory entry, recorded by the audit subsystem.
- Memory
Tier - Memory tier determines the storage root.
Traits§
- Audit
Recorder - Trait abstracting audit recording so the engine stays decoupled from the
MCP-layer
AuditSink.
Functions§
- archive_
memory - archive_
memory_ rec - Archive a memory entry with optional audit recording.
- delete_
memory - Delete a memory file. Rejects deletes on read-only entries.
- delete_
memory_ tiered - Delete a memory file from the appropriate tier.
Records an audit event via
recorderwhen provided. - delete_
memory_ tiered_ rec - Delete a memory file from the appropriate tier with optional audit recording.
- global_
memory_ dir - Return the global memory directory path:
$HOME/.codelens/memories. - list_
all_ memory_ names - List memory names from all tiers, returning (name, tier) pairs.
Entries from the global tier are prefixed with
global/. - list_
archived - List archived memory entries.
- list_
memory_ names - list_
memory_ names_ with_ policy - List memory names, filtering out entries matching the ignored policy.
- parse_
frontmatter - Parse an optional YAML frontmatter block from memory content.
- read_
memory - Read a memory file’s content from the appropriate tier.
- read_
memory_ from_ tier - Read a memory file from a specific tier’s directory.
- read_
memory_ with_ metadata - Read a memory file with full metadata: frontmatter links, stale detection,
and tier information. This is the rich-read counterpart of
read_memory_from_tierfor MCP responses that include metadata. - read_
policy - Read the current policy content for a memories directory.
- rename_
memory - Rename a memory file. Rejects if source is read-only or target exists.
- resolve_
memory_ path - Resolve a memory name to a filesystem path, with validation.
- resolve_
memory_ tier - Resolve which tier a memory name lives in.
- restore_
archived - Restore an archived memory entry.
Records an audit event via
recorderwhen provided. - restore_
archived_ rec - Restore an archived memory entry with optional audit recording.
- strip_
frontmatter - Strip frontmatter from content, returning just the body text.
- write_
memory - Write content to a memory file in the project tier. Creates directories if needed. Rejects writes to read-only entries.
- write_
memory_ tiered - Write content to a memory file, resolving the tier automatically.
Records an audit event via
recorderwhen provided. - write_
memory_ tiered_ rec - Write content to a memory file with optional audit recording.