Memory Categories
Categories classify memories by their semantic purpose. Defined insrc/cems/models.py:MemoryCategory:
Core Categories
preferences
preferences
User preferences about tools, languages, coding styles, and workflows.Examples:
- “I prefer Python for backend development”
- “Use snake_case for database column names”
- “I work with VS Code and Claude Code”
/remember or inferred from session patternsdecisions
decisions
Architecture decisions, technical choices, and their rationale.Examples:
- “Chose PostgreSQL over MySQL for better JSON support”
- “Using React instead of Vue for team familiarity”
- “Adopted pgvector for semantic search capabilities”
patterns
patterns
Recurring patterns in code, tools, workflows, and problem-solving approaches.Examples:
- “User always wraps async calls with try/catch”
- “Prefers integration tests over unit tests”
- “Uses Docker Compose for local development”
cems_post_tool_use.py) and observer daemoncontext
context
Project context, infrastructure, and high-level observations.Examples:
- “Project uses PostgreSQL + pgvector for vector storage”
- “Deploys to production via Coolify”
- “Monorepo structure with shared packages”
cems-observer)learnings
learnings
Session-specific learnings, solutions to problems, and discoveries.Examples:
- “Fixed CORS issue by adding credentials: ‘include’”
- “Memory consolidation improves recall by 15%”
- “HyDE technique bridges semantic gap in preference queries”
cems_stop.py)general
general
Uncategorized memories and general information.Examples:
- Generic notes
- Temporary information
- Unclassified content
gate-rules
gate-rules
Tool-blocking rules enforced by PreToolUse hooks.Examples:
- “Never run ‘rm -rf /’ commands”
- “Require confirmation before git push —force”
- “Block file deletions in production branches”
cems rule add commandMemory Scope
Scope determines visibility and sharing. Defined insrc/cems/models.py:MemoryScope:
Personal Scope
- Visibility: User-private, not shared with team
- Use cases:
- Individual preferences
- Personal workflow patterns
- Private notes and reminders
- Storage: Isolated by
user_idin database - Commands:
/remember(default scope)
Shared Scope
- Visibility: Shared across team members
- Use cases:
- Team conventions and standards
- Shared architecture decisions
- Codebase-specific patterns
- Storage: Isolated by
team_idin database - Commands:
/sharein Claude Code
Scope Selection in Search
Search can target specific scopes:Memory Metadata
Each memory includes rich metadata for tracking and scoring. Defined insrc/cems/models.py:MemoryMetadata:
Core Fields
| Field | Type | Purpose |
|---|---|---|
memory_id | UUID | Unique identifier for the memory |
user_id | string | Owner of the memory |
team_id | string | null | Team association for shared memories |
scope | enum | Personal or shared visibility |
category | string | Memory category (see above) |
tags | string[] | User-defined tags for organization |
Timestamps
| Field | Type | Purpose |
|---|---|---|
created_at | datetime | When the memory was first stored |
updated_at | datetime | Last modification time |
last_accessed | datetime | Last time memory was retrieved |
expires_at | datetime | null | Expiration time (null = never expires) |
Access Tracking
| Field | Type | Purpose |
|---|---|---|
access_count | int | Number of times memory was retrieved |
priority | float | Priority weight for retrieval (1.0 default, up to 2.0) |
- Each access increments
access_count - Priority increases:
priority = 1.0 + min(access_count * 0.05, 1.0) - Maximum priority: 2.0 (accessed 20+ times)
Source Tracking
| Field | Type | Purpose |
|---|---|---|
source | string | null | Origin of the memory (e.g., “session”, “observer”, “manual”) |
source_ref | string | null | Project/file reference (e.g., "project:myapp", "repo:src/api.py:42") |
source_ref get scoring adjustments:
- Same project: 1.3x boost (from
src/cems/retrieval.py:620) - Different project: 0.8x penalty
- No project tag: 0.9x mild penalty
Pinning
| Field | Type | Purpose |
|---|---|---|
pinned | bool | Whether memory is pinned (protected from decay) |
pin_reason | string | null | Reason for pinning |
pin_category | enum | null | Pin category (see below) |
- Never auto-pruned by maintenance jobs
- Get 1.1x score boost during retrieval (from
src/cems/retrieval.py:613) - Exempt from time decay penalties
Pin Categories
Defined insrc/cems/models.py:PinCategory:
guideline- Coding guidelines, style guidesconvention- Team conventionsarchitecture- Architecture decisionsstandard- Industry standardsdocumentation- Important documentation
Archival
| Field | Type | Purpose |
|---|---|---|
archived | bool | Whether memory is archived (soft-delete) |
- Excluded from search by default
- Can be restored if needed
- Eventually pruned by re-indexing job
Memory Storage Model
CEMS uses a document + chunk model for storage:Document Level
Stored inmemory_documents table:
Chunk Level
Stored inmemory_chunks table:
- Handles long documents without truncation
- Better recall (matches at snippet level)
- Efficient embedding reuse
- Deduplication by content hash
src/cems/chunking.py):
- Chunk size: 800 tokens
- Overlap: 15% (120 tokens)
- Short content (< 800 tokens): stored as single chunk
Score Adjustments
During retrieval, memories receive score adjustments based on metadata:Related Concepts
- How It Works - Memory lifecycle and integration
- Search Pipeline - How metadata affects retrieval
- Architecture - Storage schema and indexing