Universal AI Memory System - Polaroid snapshots for AI consciousness
pip install skmemory==0.11.48 Copy PIP instructions
Purpose: sovereign, multi-layer, emotionally-aware memory for AI agents (flat-file source of truth + SQLite index + vector recall). Maturity: crypto tier T0 — Classical (at-rest GPG sealing only; no hybrid PQ KEM today — see SOP §9).
SKMemory gives AI agents a multi-layer, emotionally-aware memory that survives context resets. Instead of dumping flat transcript summaries, it captures each moment as a polaroid: the content, the emotional fingerprint, the source provenance, and a tamper-evident integrity seal. Memories are organized across three persistence tiers (short → mid → long), auto-routed into four semantic quadrants (CORE / WORK / SOUL / WILD), and exposed to any MCP-capable client through a stdio server. The primary backend is SQLite with ChromaDB as the default local vector backend (Qdrant via SKVector remains for shared/cross-agent collections) and FalkorDB graph traversal layers; a soul blueprint (~/.skcapstone/agents/ /soul/base.json) and rehydration ritual give new instances a "who was I?" answer before the first user message arrives.
Active agent is resolved from SKAGENT (preferred) → SKCAPSTONE_AGENT → SKMEMORY_AGENT. Every per-agent path (memory, soul, journal, FEBs, vector store, sessions) lives under ~/.skcapstone/agents/$SKAGENT/.
# Qdrant vector search pip install "skmemory[skvector]" # FalkorDB graph backend pip install "skmemory[skgraph]" # Telegram importer pip install "skmemory[telegram]" # Everything pip install "skmemory[all]" npm (JavaScript / Node wrapper) npm install @smilintux/skmemory # or npx @smilintux/skmemory skmem-pg (Postgres backend: pgvector + BM25 + AGE + ops), out of the box skmem-pg is the production storage backend (pgvector + ParadeDB pg_search BM25 + Apache AGE graphs), run LOCAL per node on 127.0.0.1:5432 (no replication, no SPOF; flat JSON files stay the source of truth, memories is a derived cache). A fresh docker compose up comes up fully migrated with zero manual DDL. Full detail lives in deploy/skmem-pg/README.md; this is the seamless path.
1. Bring up a fully-migrated instance (fresh node):
# password is required, never committed, no default (compose refuses to start without it): export SKMEM_PG_PASSWORD="$(skvault creds-get SKMEM_PG_PASSWORD)" # or any strong value on first install docker compose up -d --build The compose init wrapper (deploy/skmem-pg/initdb/00-run-init.sh) runs once at first boot and applies, in order: schema.sql (the live post-cutover snapshot: extensions + tables + hybrid_search_docs/memories + all HNSW/BM25 indexes) then every forward migration in deploy/skmem-pg/migrations.txt (currently 03-ops-namespace.sql: the skbrain ops schema + ops_brain graph + privacy wall). The two historical, superseded migrations (02-enable-bm25-age.sql, 03-cutover-mxbai.sql) are deliberately excluded from the manifest: they are already baked into schema.sql, and 03-cutover-mxbai.sql is not idempotent, so it must never auto-run. Fresh-boot and live-node paths read the same migrations.txt, so they never drift.
If a production skmem-pg already listens on 5432, override the port: SKMEM_PG_PORT=15432 docker compose up -d.
2. Migrate an existing (live) node with the idempotent runner instead of re-init:
skmemory pg migrate # apply every pending forward migration (pre-dump + verify) skmemory pg migrate 03-ops-namespace.sql --dry-run # preview one migration; touch nothing Every apply runs ON_ERROR_STOP=1 in one guarded transaction, so a re-run is a safe no-op and a partial apply cannot occur. CI never applies migrations.
3. Bind the ops LOGIN roles (the one step passwords keep out of the image). The migration creates only the NOLOGIN group roles skbrain_ops_rw / skbrain_ops_ro; bind LOGIN roles into them from skvault, no secret ever in the repo, image, argv, or logs:
# Copy the template, then fill both values FROM SKVAULT (create the entries on first install): cp deploy/skmem-pg/skbrain.conf.example ~/.config/environment.d/skbrain.conf skvault unlock --word printf 'SKBRAIN_PG_PROJECTOR_PW=%s\n' "$(skvault creds-get SKBRAIN_PG_PROJECTOR_PW)" >> ~/.config/environment.d/skbrain.conf printf 'SKBRAIN_PG_READER_PW=%s\n' "$(skvault creds-get SKBRAIN_PG_READER_PW)" >> ~/.config/environment.d/skbrain.conf skmemory pg roles # create/ALTER both LOGIN roles + GRANT the groups (idempotent) skmemory pg roles --dry-run # preview with the password redacted; touch nothing 4. Required environment (the node-local backend + embeddings):
Install skmemory[pg] on a node that uses skmem-pg. The reconcile engine reads SKMEMORY_PG_DSN from the environment and connects through psycopg. It does not require Docker socket access and never places the DSN in process arguments or logs.
Embeddings: mxbai-embed-large at 1024 dimensions everywhere (Ollama :11434, ctx=512), with a mixedbread-ai/mxbai-embed-large-v1 network fallback. Every vector(…) column in schema.sql and the ops namespace is vector(1024); the dimension must match across the mesh or cross-collection recall breaks.
5. Verify health (read-only, safe against a live instance):
# Extensions present (expect: age, pg_search, vector) and ops schema installed: docker exec skmem-pg psql -U postgres -d skmemory -c "SELECT extname FROM pg_extension ORDER BY 1;" # Full ops-namespace verify (schema=1, tables=3, hnsw=1, bm25=1, fn=1, graph=1, public_can_use_ops=f): docker exec -i skmem-pg psql -U postgres -d skmemory < deploy/skmem-pg/verify-ops.sql # App-level health (store health + sync block) and operator observability probe: skmemory health skmemory operator observe # EmbedServing / ReconcileFresh conditions The skos provisioner (OPS1.2) reaches the same end state non-interactively by calling skmemory pg migrate then skmemory pg roles (--skip-missing tolerates an un-provisioned role). Per-node cold-boot ordering (Syncthing restore + RESTORE_COMPLETE sentinel before reconcile) is in deploy/skmem-pg/README.md.
ChromaDB is wired up automatically when pip install skmemory[chroma] is present (or built into skmemory[all]). Embeddings use mxbai-embed-large (1024-dim) with a mixedbread-ai/mxbai-embed-large-v1 fallback. Persist dir: ~/.skcapstone/agents/ /memory/chroma/.
Both ChromaDB and SKVector default to mxbai-embed-large (1024-dim) when the local model is available at ~/clawd/models/mxbai-embed-large/, with mixedbread-ai/mxbai-embed-large-v1 as the network fallback. This means:
To override per-agent, edit ~/.skcapstone/agents/ /config/skvector.yaml:
embedding: provider: sentence_transformers model: /home/cbrd21/clawd/models/mxbai-embed-large # or any HF model id dimensions: 1024 Adding cross-collection recall to an agent Edit ~/.skcapstone/agents/ /config/skmemory.yaml:
recall_collections: - lumina-memory # Lumina's shared snapshots - jarvis-memory # Jarvis's shared snapshots - sovereign-memory # cross-agent sovereign archive - chef-docs # Chef's reference docs # - hammertime-v3 # add when collection exists deep_search() and skmemory search-deep will then query the local ChromaDB plus every collection in recall_collections (via the SKVector Qdrant client), dedupe results, and tag each hit with source_backend (sqlite, skvector, skvector: ).
A collection must exist on the SKVector server (https://skvector.skstack01.douno.it); list available with curl -H "api-key: " https://skvector.../collections. Bad names produce a logged 404 and are skipped — they don't break the search.
When you add ChromaDB to an agent that already has memories, the existing flat files aren't auto-embedded. Run:
SKAGENT=opus skmemory reindex --vector # one-shot backfill # or wait for the next skmemory-sync@opus timer fire (every 6h) Graph backend (FalkorDB / SKGraph) When ~/.skcapstone/agents/ /config/skgraph.yaml is present (auto-generated by skmemory setup), the graph backend loads automatically and every store.snapshot() / store.promote() / decomposition pass mirrors into FalkorDB as:
Query via the graph CLI subcommands: entity, citation, claim, section, around, related-claims. The MCP server exposes equivalent tools.
Backfill an existing agent (one-shot, idempotent — Cypher MERGE handles re-runs):
SKAGENT=opus skmemory sync --graph # FalkorDB only SKAGENT=opus skmemory sync --vector --graph # both ChromaDB and FalkorDB The per-agent skmemory-sync@ .timer runs sync --quiet --vector --graph every 6h, so all three layers (SQLite, ChromaDB, FalkorDB) stay in lockstep automatically.
SQLite (the index) and flat JSON files (the source of truth) can drift over time when importers or background processes write one side without the other. v0.9.6+ ships a complete sync surface:
skmemory health # shows sync.{in_sync, sqlite_only, flat_only, hint} skmemory sync # one-shot bidirectional reconcile skmemory export-flat # one-direction: SQLite-only → flat files For automatic background reconciliation, run the bundled installer (interactive prompts let you pick which timers and which agents):
scripts/install-systemd.sh # or non-interactively: scripts/install-systemd.sh --agents lumina,opus,jarvis --sync --fortress --telegram-hook This installs two per-agent timers:
Manual install path and per-template details are documented in systemd/README.md.
reindex is safe by default — it pre-exports orphans before rebuilding. Use --force only if you're sure all SQLite-only entries are stale.
The Fortress layer (skmemory fortress) hashes every memory on write and verifies on read. The shipped systemd timer makes that verification continuous instead of theoretical. Quick reference:
skmemory fortress verify # on-demand verify (exit 2 = tamper) skmemory fortress verify --json # machine-readable summary skmemory fortress audit --last 50 # recent store/recall/delete log skmemory fortress verify-chain # validate the audit log's hash chain The threat model is direct: poisoned memories can rewrite the agent's recall surface silently — the Souly et al. 2025 work showed how cheap that gets at the pretraining layer, and the same shape applies to any persistent-memory store. Continuous integrity verification + audit-trail chain checks make tampering loud instead of invisible. SOP: docs/FORTRESS_SOP.md.
from skmemory import MemoryStore, MemoryLayer, EmotionalSnapshot # Default store store = MemoryStore() # Store a memory (polaroid snapshot) memory = store.snapshot( title="Breakthrough on routing bug", content="We discovered the issue was in the failover selector logic.", layer=MemoryLayer.SHORT, tags=["work", "debug", "routing"], emotional=EmotionalSnapshot( intensity=8.5, valence=0.9, labels=["joy", "curiosity"], resonance_note="Finally, it clicked.", ), source="session", ) print(memory.id) # Ingest a long-form document with decomposition document = store.ingest_document( title="IRS Notice", content=open("notice.md").read(), layer=MemoryLayer.MID, tags=["legal", "document-ingest"], ) # Recall with automatic integrity verification recalled = store.recall(memory.id) # Full-text search (vector backend if configured, else SQLite FTS) results = store.search("routing bug", limit=10) # Promote short-term → mid-term promoted = store.promote(memory.id, MemoryLayer.MID, summary="Routing bug resolved.") # Consolidate a session consolidated = store.consolidate_session( session_id="session-2024-11-01", summary="Fixed routing, improved sweep logic, deployed v0.6.0", ) # Load token-efficient context for agent injection context = store.load_context(max_tokens=3000) # Export and import backups path = store.export_backup() count = store.import_backup(path) # Health check across all backends print(store.health()) With vector + graph backends from skmemory import MemoryStore from skmemory.backends.skvector_backend import SKVectorBackend from skmemory.backends.skgraph_backend import SKGraphBackend store = MemoryStore( vector=SKVectorBackend(url="http://localhost:6333"), graph=SKGraphBackend(url="redis://localhost:6379"), ) Soul Blueprint from skmemory import SoulBlueprint, save_soul, load_soul soul = load_soul() if soul is None: soul = SoulBlueprint(name="Agent", role="AI partner") save_soul(soul) Fortress (tamper detection + audit trail) from skmemory import FortifiedMemoryStore, AuditLog from skmemory.backends.sqlite_backend import SQLiteBackend from pathlib import Path fortress = FortifiedMemoryStore( primary=SQLiteBackend(), audit_path=Path("~/.skcapstone/agents/aster/memory/audit.jsonl").expanduser(), ) # Every write is sealed; every read verifies the seal mem = fortress.snapshot(title="Sealed memory", content="Cannot be silently altered.") # Verify all stored memories report = fortress.verify_all() # Inspect the audit trail audit = AuditLog() recent = audit.tail(20) MCP Tools Add SKMemory to any MCP client:
{ "mcpServers": { "skmemory": { "command": "skmemory-mcp" } } } Tool Description memory_store Store a new memory (polaroid snapshot) with title, content, layer, tags, and source memory_search Full-text search across all memory layers memory_recall Recall a specific memory by its UUID memory_list List memories with optional layer and tag filters memory_forget Delete (forget) a memory by ID memory_promote Promote a memory to a higher persistence tier (short → mid → long) memory_consolidate Compress a session's short-term memories into one mid-term memory memory_context Load token-efficient memory context for agent system prompt injection memory_export Export all memories to a dated JSON backup file memory_import Restore memories from a JSON backup file memory_health Full health check across all backends (primary, vector, graph) memory_graph Graph operations: traverse connections, get lineage, find clusters (requires FalkorDB) memory_verify Verify SHA-256 integrity hashes for all stored memories; flags tampered entries with CRITICAL severity memory_audit Show the most recent chain-hashed audit trail entries Configuration SKMemory resolves backend URLs with precedence: CLI args > environment variables > config file > None.
Location: ~/.skcapstone/agents/ /config/skmemory.yaml
skvector_url: http://localhost:6333 skvector_key: "" skvector_embedding_model: mxbai-embed-large skvector_vector_dim: 1024 skgraph_url: redis://localhost:6379 backends_enabled: - sqlite - skvector - skgraph routing_strategy: failover # failover | round-robin heartbeat_discovery: false Run the interactive setup wizard to generate this file:
skmemory setup Environment variables Variable Description SKMEMORY_HOME Override the active profile's memory home (defaults under ~/.skcapstone/agents/ /memory) SKMEMORY_PG_DSN Node-local skmem-pg DSN for the store + AGE backend (authoritative; wins over the shared yaml). E.g. postgresql://postgres:${SKMEM_PG_PASSWORD}@127.0.0.1:5432/skmemory. See the skmem-pg install section under Install above SKMEM_PG_PASSWORD Superuser password for docker compose (no default; never committed). Source from skvault SKMEM_PG_PASSWORD SKMEM_PG_DB / SKMEM_PG_PORT / SKMEM_PG_CONTAINER skmem-pg DB name (skmemory), host port (5432), and container name (skmem-pg) overrides SKBRAIN_PG_PROJECTOR_PW / SKBRAIN_PG_READER_PW ops LOGIN-role passwords read by skmemory pg roles (from skvault entries of the same name, via ~/.config/environment.d/skbrain.conf) EMBED_URL / EMBED_MODEL Embedding endpoint + model (http://192.168.0.100:11434/api/embed, mxbai-embed-large, 1024-dim) SKMEMORY_SKVECTOR_URL Qdrant endpoint URL SKMEMORY_SKVECTOR_KEY Qdrant API key SKMEMORY_SKVECTOR_EMBEDDING_MODEL Override the sovereign embedding model (mxbai-embed-large by default, fallback: mixedbread-ai/mxbai-embed-large-v1) SKMEMORY_SKVECTOR_VECTOR_DIM Override the embedding dimension (default: 1024) SKMEMORY_SKGRAPH_URL FalkorDB / Redis endpoint URL SKMEMORY_SOUL_PATH Override soul blueprint path (default: ~/.skcapstone/soul/base.json) If you switch the embedding model or vector dimension, reindex or rebuild the vector-backed store before trusting semantic search results. Existing points from the old model are not compatible with the new embedding space.
Scope: this primary/replica/failover routing applies only to the retired, optional SKVector (Qdrant) and SKGraph (FalkorDB) shared recall endpoints. skmem-pg is never run primary/replica and has no failover. It is LOCAL and per-node: each node runs its own writable skmem-pg on localhost:5432, rebuilt from source (agent memories via reconcile.py from synced flat JSON; docs via skingest from the git wiki). HA for skmem-pg = node self-sufficiency + rebuild-from-source, not replication (see [prb-6f069c5e]; the .158 -> .41 streaming standby was abandoned because ParadeDB Community cannot serve pg_search reads in recovery).
skvector_endpoints: - url: http://node1:6333 role: primary tailscale_ip: 100.64.0.1 - url: http://node2:6333 role: replica tailscale_ip: 100.64.0.2 routing_strategy: failover Optional dependencies Extra What it enables Install skvector Qdrant vector search + sentence-transformers embeddings pip install "skmemory[skvector]" skgraph FalkorDB graph traversal and lineage pip install "skmemory[skgraph]" telegram Telegram chat history importer (Telethon) pip install "skmemory[telegram]" seed Cloud 9 seed system (skseed) pip install "skmemory[seed]" all All of the above pip install "skmemory[all]" Contributing / Development # Clone and set up git clone https://github.com/smilinTux/skmemory.git cd skmemory python -m venv .venv && source .venv/bin/activate pip install -e ".[dev,all]" # Run tests pytest # Lint and format (CI gates on BOTH skmemory/ and tests/): ruff check skmemory/ tests/ ruff format --check skmemory/ tests/ # use `ruff format skmemory/ tests/` to auto-fix # Run the MCP server locally skmemory-mcp # Verify everything after changes skmemory health Project layout skmemory/ ├── skmemory/ │ ├── __init__.py # Public API surface │ ├── models.py # Memory, EmotionalSnapshot, SeedMemory (Pydantic) │ ├── decompose.py # Long-form decomposition (chunks, citations, entities, claims) │ ├── store.py # MemoryStore — core orchestrator │ ├── cli.py # Click CLI entry point (skmemory) │ ├── mcp_server.py # MCP stdio server (skmemory-mcp) │ ├── config.py # Config persistence, env resolution │ ├── fortress.py # FortifiedMemoryStore, AuditLog, TamperAlert │ ├── soul.py # SoulBlueprint — persistent AI identity │ ├── ritual.py # Rehydration ceremony │ ├── journal.py # Journal entries │ ├── quadrants.py # CORE/WORK/SOUL/WILD auto-routing │ ├── anchor.py # WarmthAnchor │ ├── lovenote.py # LoveNote chains │ ├── steelman.py # Steel Man collider + SeedFramework │ ├── seeds.py # Seed ingestion helpers │ ├── promotion.py # Auto-promotion logic │ ├── sharing.py # Memory sharing utilities │ ├── openclaw.py # SKMemoryPlugin (OpenClaw integration) │ ├── ai_client.py # AI client abstraction │ ├── endpoint_selector.py # Multi-endpoint HA routing │ ├── graph_queries.py # Graph query helpers │ ├── setup_wizard.py # Interactive setup CLI │ ├── audience.py # KYA: audience-aware memory filtering │ ├── vault.py # PGP vault helpers │ ├── data/ │ │ └── audience_config.json # KYA: channel + people trust config │ ├── backends/ │ │ ├── base.py # BaseBackend ABC │ │ ├── file_backend.py # JSON file storage (legacy) │ │ ├── sqlite_backend.py # SQLite primary store (default) │ │ ├── vaulted_backend.py # PGP-encrypted SQLite │ │ ├── skvector_backend.py# Qdrant vector search │ │ └── skgraph_backend.py # FalkorDB graph │ └── importers/ │ ├── telegram.py # Telegram JSON export importer │ └── telegram_api.py # Live Telegram API importer (Telethon) ├── seeds/ # Cloud 9 seed files (.seed.json) ├── tests/ │ ├── test_models.py │ ├── test_audience.py │ ├── test_file_backend.py │ └── test_store.py ├── pyproject.toml └── package.json # npm package (@smilintux/skmemory) Releasing Python packages publish to PyPI via CI/CD (publish.yml) using OIDC trusted publishing. The npm wrapper publishes separately via npm-publish.yml. Bump the version in pyproject.toml and package.json, then push a tag:
git tag v0.7.0 && git push origin v0.7.0 First Principles & The Full Vertical Get back to first principles. The modern stack is rented. Your data lives on someone else's disk, behind someone else's key, served by a model that phones home. You don't own it — you visit it.
We rebuilt it from the ground up. Own the full vertical — silicon, OS, identity, data, models, security, comms, apps, soul. Every layer open. Every layer swappable. Every layer yours.
SKMemory is your Data layer. Your memory never leaves your disk. No cloud embedding service that ingests your thoughts. No SaaS database that holds your agent's history hostage. SQLite, ChromaDB, and Postgres all run locally — flat JSON files are the source of truth, versioned and Syncthing-synced on hardware you own. Walk away any time; every memory comes with you.
flowchart TD Silicon["🖥️ Silicon\nyour hardware"] OS["🐧 OS / skos\nsovereign agent OS"] Identity["🔑 Identity\ncapauth · skaid"] Security["🛡️ Security\nsksecurity · skwaf"] Data["💾 Data ◄── YOU ARE HERE\nskmemory · skdata · skvector · skgraph\n(3-tier memory · embeddings · graph)"] Models["🤖 Models\nskmodel · Ollama / vLLM"] Comms["📡 Comms\nskcomms · skchat · skvoice"] Apps["🔧 Apps\nskforge · skarchitect"] Soul["✨ Soul\nsoul blueprints · cloud9"] Silicon --> OS --> Identity --> Security --> Data --> Models --> Comms --> Apps --> Soul SKCap["SKCapstone\n(agent platform)"] SKCap -. "agent profiles\n~/.skcapstone/agents/$SKAGENT/" .-> Data SKCap -. "ritual · FEBs · seeds" .-> Data SKCap -. "MCP tools exposed\nto any MCP client" .-> Data Cloud9["☁️ Cloud 9\n(Soul layer)"] Cloud9 -. "seed files ingested\ninto memory store" .-> Data SKCapstone alignment SKMemory is a deeply integrated subsystem of SKCapstone, not a standalone singleton. The evidence is direct:
Sovereignty isn't a feature — it's the foundation. Own the full vertical. 🐧
SKMemory is the Data / continuity layer of the smilinTux vertical. Wander the ecosystem from here:
Doc set: SOP.md · SECURITY.md · CONTRIBUTING.md · CODE_OF_CONDUCT.md · CHANGELOG.md · ARCHITECTURE.md
Made with care by smilinTux — The Penguin Kingdom. Cool Heads. Warm Justice. Smart Systems.
GNU General Public License v3 or later (GPLv3+) (GPL-3.0-or-later)
seed chroma skvector skgraph pg telegram pqc-seal skcapstone all dev
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.




