Skip to main content

Module memory

Module memory 

Source
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§

MemoryFrontmatter
Parsed YAML frontmatter from a memory markdown file.
MemoryLocation
A resolved memory location that carries its tier and absolute path.
MemoryMetadata
Metadata returned alongside memory content for rich responses.
MemoryPolicy
Policy controlling visibility and mutability of memory entries.
NullRecorder
A no-op recorder that discards all events.

Enums§

MemoryAuditEvent
Lifecycle event for a memory entry, recorded by the audit subsystem.
MemoryTier
Memory tier determines the storage root.

Traits§

AuditRecorder
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 recorder when 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_tier for 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 recorder when 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 recorder when provided.
write_memory_tiered_rec
Write content to a memory file with optional audit recording.