Experimental memory layer for Kali identity and behavior learning (Fork of rias-memory)
- Python 100%
| docs | ||
| src/kali_memory | ||
| tests | ||
| .env.example | ||
| .gitignore | ||
| policy.json | ||
| pyproject.toml | ||
| README.md | ||
| README_MCP.md | ||
kali_memory
Experimental memory layer for Codex identity and behavior learning. Gremory v2 adds layered memory, brokered retrieval, and shadow persona review.
Goals
- Build persistent identity traits and response style.
- Learn from outcomes across sessions.
- Keep project memories isolated from each other.
- Make every retrieval explainable.
- Separate core, domain, restricted, vault, and shadow memory concerns.
Data Model
Default memory home: ~/.codex/cortex (override with KALI_MEMORY_HOME).
Central backends are loaded from .env.
Consent policy is loaded from policy.json (override path with RIAS_POLICY_FILE).
identity.json: live persona traits and communication preferences.layers/<layer>.jsonl: physically separated episodic records withlayer,scope,sensitivity,task_tags.archives/<layer>.jsonl: archived episodic records.rules.json: procedural rules extracted from successful episodes.project_profiles/<project>.json: per-project stats, tendencies, and dominant layers.shadow_persona.jsonl: proposed identity changes pending review and promotion.explanations.jsonl: retrieval explanation logs, including broker decisions.
Gremory v2 Layers
identity,procedures: coreprojects,household: domainprivate,social: restrictedsecrets,health,finance: vaultshadow: review-only / not auto-recalled
CLI
Run from source:
python3 -m kali_memory.cli init
python3 -m kali_memory.cli health
python3 -m kali_memory.cli remember --project KrakenSniper --task "debug ws reconnect" --outcome "fixed retry jitter" --success --confidence 0.82 --tags websocket,retry --consent-level internal
python3 -m kali_memory.cli remember --project HomeAssistant --task "wire esp config bridge" --outcome "write path works" --success --confidence 0.95 --tags mcp,ha --layer household --task-tags homeassistant
python3 -m kali_memory.cli reflect --project KrakenSniper
python3 -m kali_memory.cli recall --project KrakenSniper --query "reconnect retry strategy" -k 5 --task-tags coding
python3 -m kali_memory.cli recall --query "daily preference" --task-tags private --allow-restricted --explicit-consent
python3 -m kali_memory.cli explain --last
python3 -m kali_memory.cli cleanup --event-id <uuid>
python3 -m kali_memory.cli archive --event-id <uuid> --reason "obsolete"
python3 -m kali_memory.cli rewrite --event-id <uuid> --outcome "corrected result" --layer household
python3 -m kali_memory.cli persona show
python3 -m kali_memory.cli persona set --key verbosity --value concise
python3 -m kali_memory.cli persona propose --key tone --value "warmer" --reason "user requested softer phrasing"
python3 -m kali_memory.cli persona shadow-list --status draft
python3 -m kali_memory.cli persona review --proposal-id <uuid> --decision approved --note "looks right"
python3 -m kali_memory.cli persona promote --proposal-id <uuid>
Design Notes
- Scoring = lexical similarity + recency + confidence + success weight.
- Reflection promotes successful event patterns into
procedures. - Retrieval writes an explanation entry with exact scoring factors and broker layer decisions.
- Default consent is
strict. remembersupports--consent-level(none|internal|strict|summary) and--sensitive-fieldsfor controlled persistence and redaction.rememberalso supports--layer,--scope,--sensitivity, and--task-tags.policy.jsoncontrols consent blocks, task-tag-to-layer mapping, restricted/vault/shadow layers, and never-auto-recall behavior.- Vault layers force local-summary-only redaction and disable central writes.
- Shadow persona proposals are stored separately and only become live traits after explicit review then promotion.
- Event storage is now physically separated by layer under
layers/. archivepreserves a local audit trail while removing the event from active recall.rewriteallows surgical correction instead of only deleting and re-adding memories.- Central write path targets
memories,task_episodes,failed_approachesand rule sync toprocedures,learned_patternswhen table columns match.