You're offline — showing cached data

Wiki

06-vault-and-memory/overview
2026-06-13 07:27:27 SAST
Wiki Home → 06-vault-and-memory/overview

Vault and Memory Overview

How Luci's knowledge persistence works: the vault architecture, directory structure, database schema, MCP server tools, indexer, and the two-DB split between vault.db and mc.db.

Core Principle

Markdown files are the source of truth. vault.db is a derived query index. mc.db is Luci's operational database.

The vault.db can be rebuilt from files at any time via python index.py --rebuild. Only the activity_log table is authoritative in the DB (append-only, not derived from files).

Two-DB Architecture

Implemented 2026-04-07. Two databases with clear ownership, one MCP server that queries both transparently.

vault.db -- Knowledge Graph (Lucienne owns)

mc.db -- Mission Control Ops (Luci owns)

Rules

  1. Lucienne NEVER writes to mc.db (access via API only)
  2. Luci NEVER writes to vault.db (read-only via git pull)
  3. Cross-system queries go through the MC API, not direct DB access
  4. vault.db travels via git sync (every 15 min)

Directory Structure

PKA Vault (PKA/Vault/)

Project-specific structured data:

Vault/
  vault.db          # SQLite query index (derived from files)
  vault.db-wal      # WAL journal
  vault.db-shm      # Shared memory
  schema.sql        # DDL for vault.db (v2, 2026-03-30)
  memory/           # Memory files (durable reference knowledge)
    MEMORY.md       # Memory index -- lists all memories
    auto/           # Auto-generated memories from Claude sessions
    *.md            # Individual memories (feedback, project, reference, user)
  tasks/            # Task files with YAML frontmatter
  projects/         # Project tracking files
  notes/            # General notes

Personal Vault (~/.claude/vault/)

Cross-project personal data shared between PKA, CoWork, and other projects:

~/.claude/vault/
  identity/         # KYC profiles (Elmar, Nicolette, children)
  entities/         # Company profiles (ENCFT, Werda, YellowNickel), group financials
  contacts/         # Master contact list (people + companies)
  work/             # FlySafair role/team/tools, glossary
  secrets/          # API keys, POPIA passwords, SSH keys
  preferences/      # About me, communication style
  infrastructure/   # Server profiles, network/SSH config, service inventory
  references/       # Reference documents
  scripts/          # Utility scripts
  session_tracker.py  # Session registration
  sessions.json     # Session log
  next-session.md   # Carry-forward notes

Database Schema (vault.db)

Schema v2 (2026-03-30). Key tables:

Core Tables

Operational Tables

Removed (MC-462, 2026-04-09): vitals_log and task_runs were dropped from vault.db. Both were always empty — all task runs go to mc.db, and vitals were never populated. vault_cleanup.py handles this cleanup.

Search

Views

Vault MCP Server

Script: vault_mcp.py (runs as stdio MCP server, configured in .mcp.json)

Provides 8 tools for Claude Code sessions to query the knowledge graph:

Tool Source Purpose
memory_search vault.db (FTS5) Full-text search across all indexed files
memory_recall vault.db (FTS5 + edges) FTS matches plus graph-connected neighbors
graph_neighbors vault.db (edges) All files connected to a given path
file_lookup vault.db (files) Query by type, status, project, assignee
memory_health vault.db (files) Memory lifecycle: stale, unreviewed, status
session_search vault.db + Luci MC API Search past session transcripts (merged)
activity_log vault.db + Luci MC API Recent activity entries (merged local + remote)
luci_status Luci MC API only Live Luci state: active tickets, inbox, activity

The three cross-boundary tools (session_search, activity_log, luci_status) call the MC API at http://100.118.207.3:3001 over HTTP with bearer token auth (mc-lucienne-2026).

Circuit breaker (MC-462, 2026-04-09): HTTP fallback calls use a circuit breaker — after 3 consecutive failures, the breaker opens for 5 minutes and returns a clear error instead of hanging. This prevents silent degradation when Luci is down.

Ticket context auto-logging: When memory_recall or file_lookup is called during a worker session (detected via MC_TICKET_ID env var), the consulted vault files are automatically logged to mc.db's ticket_context table via the MC API. This creates a ticket↔vault bridge so tickets know which knowledge was consulted.

Connection: Read-only to vault.db (file:...?mode=ro). Never writes.

Indexer

Script: index.py

Scans markdown files from two roots and populates vault.db:

Scan Roots

  1. PKA root (label: pka) -- Team/.md, Vault/memory/.md, Vault/tasks/.md, Vault/projects/.md, Vault/notes/*.md, Lucienne.md, CLAUDE.md, SETUP.md
  2. Personal vault (label: personal) -- identity, contacts, entities, preferences, work, infrastructure (excludes secrets/)

What It Does

  1. Collects all .md files matching glob patterns
  2. Parses YAML frontmatter (title, type, status, priority, due_date, assigned, project, tags)
  3. Computes content hash for incremental updates (skips unchanged files)
  4. Upserts into files table
  5. Creates edges from:
  6. Frontmatter related: field (relation: related_to)
  7. Typed frontmatter fields: project -> belongs_to, assigned -> assigned_to, depends_on, blocks, parent -> subtask_of
  8. [wikilinks](/wiki/wikilinks) in body text (relation: references)
  9. Populates FTS5 index (search_fts)
  10. Cleans up deleted files from all tables
  11. Logs the run to activity_log

Usage

python index.py              # Incremental (skip unchanged files)
python index.py --rebuild    # Full rebuild (preserves activity_log, vitals_log, task_runs)
python index.py --stats      # Show index statistics

Rebuild safety: --rebuild drops and recreates the DB from schema.sql, but first saves and restores activity_log, vitals_log, and task_runs rows.

Memory File Format

Memory files use YAML frontmatter followed by markdown content:

---
name: Memory Title
description: One-line summary
type: project | feedback | reference | user
created: 2026-04-07
last_reviewed: 2026-04-07
status: active
owner: lucienne | luci | both
stale_after: 30d | never
---

## Content

Markdown body with details, decisions, and context.

Key frontmatter fields: - type -- Categorizes the memory (project, feedback, reference, user) - status -- Lifecycle state (active, archived, etc.) - stale_after -- Duration before memory is considered stale (e.g., 30d, never). The v_memory_health view uses this to flag memories needing review. - last_reviewed -- Date of last human/system review - owner -- Who maintains this memory (lucienne, luci, both)

Memory index: Vault/memory/MEMORY.md is the manually curated index that lists all memories grouped by category (User, Project, Reference, Feedback).

Session Transcript Indexing

Git Sync

Related Articles

Key Takeaways

Help