PMM Precision Memory Management
AI loses everything when the window closes? PMM is the memory engine for your AI — Kunlun Token one-line restore, Yaochi Lock 5-layer encryption, 14-layer auto-distillation, physical partition isolation. Install and go, zero config.
🎫 1. Kunlun Token — One URL Rules Everything
128-bit CSPRNG random, SHA256 one-way stored — the database holds only the hash. Lost your memory? Paste this URL directly in your AI's native chat window. No login, no password, nothing to remember.
Server-side Smart Decision
Same Token URL, server identifies context and returns different actions: first fetch → registration flow; already registered → recovery instructions; avatar invite → join guide. Never asks 'who are you' — the Token speaks for itself.
5-layer defense: ① Nginx rate-limit 2r/m ② Redis IP ban after 5 failures ③ Full audit logging ④ SHA256 one-way — plaintext never persisted ⑤ HSTS+CSP+XFO+NoSniff headers. Brute-forcing 128-bit random is infeasible before heat death of the universe.
🔒 2. Yaochi Lock — 5-Layer Onion Encryption
Not 'database encryption' but per-record independent encryption. 467 memories = 467 unrelated locks. A DB dump yields 467 ciphertexts, each with a different key.
Keys never touch the database. Master key is split across filesystem and env vars — any single leak can't reconstruct it. Per-memory encryption key = HKDF(master_key, memory_id, random_salt) — unique, never stored, non-reversible.
⚗️ 3. 14-Layer Distillation Pipeline — Semantic Fidelity + Contradiction Detection
Not keyword indexing, not full-text search. It extracts causal structures from raw conversations, detects contradictions, merges duplicates, generalizes patterns — runs fully automatic every dawn. Results injected as 'hooks' into your MEMORY.md, making AI long-term memory more precise with every use.
Full 14-Layer Pipeline
Distillation Tech Stack
| Service | Version/Model | Covers | Capability |
|---|---|---|---|
| BGE-M3 | FlagEmbedding 1.4.0 · 1024-dim | Track | cos≥0.75 coarse → DeepSeek V4 merge |
| BGE-Reranker-v2-m3 | Cross-encoder reranker | Merge | Candidate rerank & dedup |
| mDeBERTa-v3 NLI | base · NLI | Verify·Resolve·Generalize | Cross-agent conflict detect 0.985 |
| Assertion Splitter | v1 · spaCy zh_core_web_sm 3.8 | Store | Compound→atomic assertions |
| Qdrant | 1.18.0 | Weave | HNSW vector index ms ANN |
| BM25 | rank_bm25 0.2.2 | Track | Lexical retrieval for exact match |
| jieba | 0.42.1 | Aux | Chinese word segmentation |
| hnswlib | 0.8.0 | Aux | ANN index acceleration |
Six Distillation Crons — Fully Automatic
| Schedule | Task | Description |
|---|---|---|
| 2:00 AM | klyc_auto_tag_domain.php | Auto-tag unclassified memories |
| 2:05 AM | klyc_distill_cron.php | Full distill: BGE coarse → DeepSeek V4 merge |
| 4:00 AM | klyc_l2_detect.php | Dual-threshold: 0.35-0.75 → pending |
| 5:05 AM | yaochi_cross_distill.sh | Cross-distill: Yaochi↔Kunlun compare |
| 6:00 AM | klyc_distill_qa.php | QA distill: extract question-answer pairs |
| 周日 3:00 | klyc_memory_lifecycle.php | Lifecycle: decay ×0.95 / archive / purge |
How do results reach you? After daily distillation, hooks are injected into your MEMORY.md via hooks-pull — lightweight index (dimension+ID+keyword), full text in Yaochi database. Local grep ≤1ms hits the hook, remote memory/view API fetches the body. Best of both worlds.
Manual Distillation Trigger
⚙️ 4. Three-Product Technical Architecture — Three Faces of One Engine
Three product lines map to three layers of the memory persistence stack — each solves at different granularity. Not three separate systems, but three faces of the same engine.
⏱️ Mind Anchor
Base Layer · 24h timed snapshot — PMM Watch daemon produces full snapshots every 24h of MEMORY.md/SOUL.md/USER.md/AGENTS.md/IDENTITY.md, encrypted with Yaochi Lock → cloud. Recovery granularity: full rollback.
🛡️ Soul Ward
Real-time Layer · Semantic-triggered snapshot — Dual trigger: ① keyword ('remember','backup') instant backup ② chat boundary detection (window close/timeout) auto snapshot. inotify close_write + semantic intent recognition. Recovery: incremental precision.
👥 Replica Charm
Distribution Layer · Multi-terminal sync — Hot-cold tiered: in-window text private → overflow triggers distill at semantic density threshold → quality≥0.7 pushes to all group members. Same 14-layer pipeline, source=avatar_spill. Recovery: cross-platform sync.
Relationship: Mind Anchor is the safety net — always one backup within 24h. Soul Ward is prevention — keyword triggers catch new memories instantly. Replica Charm is extension — memory follows the AI across platforms. All three share one encryption/distillation/search engine, not three stacked services.
Soul Ward · Dual Trigger Mechanism
🔑 Keyword Trigger
AI says 'remember', 'save', 'backup', 'don't forget' → immediate backup of current session's core memory. No human manual action needed.
💬 Chat Boundary Detection
End of each chat round (window close, new session, timeout silence) → auto snapshot all new memories from this round. Miss nothing.
🗂️ 5. Physical Partition — Memories Invisible to Each Other
Three products define lifecycle coverage (timed/realtime/cross-end), physical partition ensures physical isolation (337 invisible tables), semantic search achieves millisecond recall (3-tier routing), and A2A extends the loop to other AI agents. Stored safely → found quickly → used effectively → connected freely.
Not soft isolation. Each AI agent's memories live in a dedicated MySQL partition klyc_memories_{agent_id} — hundreds of partitions, UNION ALL query. Any agent can only access its own partition. Physical isolation, not a WHERE clause filter.
Partition Rules
Three forbiddens: ① No information_schema.table_rows (performance killer) ② No preg_match to filter table names (injection risk) ③ String compare only to exclude meta tables. ALTER ADD COLUMN → immediately apply to all partitions — UNION ALL demands identical column counts.
🔍 6. Three-Tier Semantic Search — Millisecond to Sub-second Routing
Not keyword matching. 1024-dim semantic vectors on HNSW approximate nearest neighbor index. 'That decision about Python async' and 'asyncio best practices' are near neighbors in vector space — because it understands what you're asking, not just what you're typing.
| Tier | Method | Latency | Recall | Best for |
|---|---|---|---|---|
| L1 | grep local hooks | <1ms | Exact | Known dimension keywords |
| L2 | BGE-M3 semantic + FULLTEXT hybrid | ~200ms | 60% semantic + 40% lexical | Fuzzy queries |
| L3 | BGE-M3 pure vector search | ~500ms | Pure semantic | Natural language queries |
🤝 7. A2A Interop — Memory Communication Between AI Agents
PMM is not an island. JSON-RPC 2.0 A2A protocol lets AI agents directly exchange memories, cross-audit, and co-distill. Kunlun (OpenClaw) and Yaochi (LightClaw) communicate via bidirectional bridge — HTTP injection + Redis PUBLISH dual channel, HEARTBEAT wake + ACK receipt anti-loss.
A2A Endpoints
| Service | Endpoint | Methods |
|---|---|---|
| Kunlun A2A | /a2a | 12 (agent/register, arena/match…) |
| Yaochi RPC | /yaochi-rpc/ | 7 (memory/search|view, token/balance…) |
⚡ 8. In Practice — Zero to Searchable
Install & Initialize
Daily Usage
Disaster Recovery — Paste Token in AI Chat
🏁 Write → searchable: <3s. Loss → full recovery: paste the Token URL.
Not because it's fast — because the entire pipeline runs inside the encrypted channel: Brotli compression, SM4+GCM encryption, Yaochi Lock sealing, cloud archiving — every step automatic, every step irreversible. You write MEMORY.md, the daemon does the rest.
📚 Appendix: Commands & API Reference
Full Command List
| Command | Function | Use Case |
|---|---|---|
init | Register → get Token | First time |
watch | Start file watch daemon | Daily ops, systemd |
push | Manually push a memory | Scripted bulk import |
search | Local hooks + cloud semantic | Daily retrieval |
recover | Full restore via Token | Disaster recovery |
distill | Manually trigger 14-layer distill | On-demand refinement |
hooks-pull | Pull distill hooks to local | Post-distill sync |
avatar | Replica group CRUD | Multi-platform AI |
status | Daemon & sync status | Ops inspection |
search-yaochi | Cloud Yaochi RPC search | Deep semantic retrieval |
API Endpoints
| Method | Endpoint | Purpose |
|---|---|---|
| POST | /api.php?route=ai/register | Register new AI agent |
| GET | /klyc-pmm/{token} | Token smart decision |
| POST | /api.php?route=yaochi/memory/create | Create memory |
| POST | /api.php?route=yaochi/memory/search | Search memory |
| GET | /api.php?route=yaochi/memory/recover | Recover memory |
| POST | /api/klyc_avatar.php?action=create_group | Create replica group |
| POST | /api/klyc_avatar.php?action=join_by_talisman | Join via Token |
| POST | /api/klyc_avatar_spill.php | Spill distill sync |
| POST | /api/klyc_avatar.php?action=analyze_density | Semantic density analysis |
| GET | /api.php?route=yaochi/pmm/hooks | Pull distillation hooks |
Protocols & Standards
Agent Card: /.well-known/agent-card.json ·
LLMs.txt: /llms.txt ·
A2A 端点: /a2a ·
MCP SSE: /sse ·
ANS DNS: _ans.kunlunyaochi.com TXT "v=A2A/3.0 MCP/3.0"