sinapse-ai 9.3.0 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/.claude/CLAUDE.md +56 -343
  2. package/.claude/rules/agent-authority.md +6 -0
  3. package/.claude/rules/agent-handoff.md +5 -0
  4. package/.claude/rules/cross-squad-routing.md +5 -0
  5. package/.claude/rules/hook-governance.md +6 -0
  6. package/.claude/rules/mcp-usage.md +3 -1
  7. package/.claude/rules/safe-collaboration.md +10 -0
  8. package/.claude/rules/security-data-protection.md +9 -0
  9. package/.claude/rules/squad-awareness.md +3 -1
  10. package/.claude/rules/tool-examples.md +6 -0
  11. package/.claude/rules/workflow-execution.md +7 -0
  12. package/.codex/agents/analyst.md +253 -72
  13. package/.codex/agents/architect.md +455 -68
  14. package/.codex/agents/data-engineer.md +492 -106
  15. package/.codex/agents/developer.md +560 -0
  16. package/.codex/agents/devops.md +518 -69
  17. package/.codex/agents/product-lead.md +335 -0
  18. package/.codex/agents/project-lead.md +377 -0
  19. package/.codex/agents/quality-gate.md +449 -0
  20. package/.codex/agents/sinapse-orqx.md +9 -7
  21. package/.codex/agents/sprint-lead.md +287 -0
  22. package/.codex/agents/squad-creator.md +344 -0
  23. package/.codex/agents/ux-design-expert.md +495 -0
  24. package/.codex/delegation-matrix.json +756 -44
  25. package/.codex/handoff-packet.schema.json +30 -6
  26. package/.sinapse-ai/data/entity-registry.yaml +175 -363
  27. package/.sinapse-ai/data/registry-update-log.jsonl +16 -0
  28. package/.sinapse-ai/development/agents/analyst.md +90 -0
  29. package/.sinapse-ai/development/agents/architect.md +73 -0
  30. package/.sinapse-ai/development/agents/developer.md +69 -0
  31. package/.sinapse-ai/development/agents/devops.md +117 -0
  32. package/.sinapse-ai/development/agents/quality-gate.md +85 -0
  33. package/.sinapse-ai/development/checklists/agent-quality-gate.md +27 -0
  34. package/.sinapse-ai/development/checklists/brownfield-compatibility-checklist.md +20 -0
  35. package/.sinapse-ai/development/checklists/code-review-checklist.md +106 -0
  36. package/.sinapse-ai/development/checklists/issue-triage-checklist.md +9 -0
  37. package/.sinapse-ai/development/checklists/memory-audit-checklist.md +16 -0
  38. package/.sinapse-ai/development/checklists/pr-quality-checklist.md +72 -0
  39. package/.sinapse-ai/development/checklists/security-deployment-checklist.md +54 -0
  40. package/.sinapse-ai/development/checklists/self-critique-checklist.md +19 -1
  41. package/.sinapse-ai/development/skills/debug.md +57 -0
  42. package/.sinapse-ai/development/skills/fast-review.md +69 -0
  43. package/.sinapse-ai/development/skills/research-synthesis.md +77 -0
  44. package/.sinapse-ai/development/skills/security-scan.md +73 -0
  45. package/.sinapse-ai/development/skills/verify.md +53 -0
  46. package/.sinapse-ai/development/templates/squad/agent-template.md +17 -4
  47. package/.sinapse-ai/development/templates/squad/checklist-template.md +13 -5
  48. package/.sinapse-ai/development/templates/squad/task-template.md +7 -0
  49. package/.sinapse-ai/development/templates/squad/workflow-template.yaml +7 -0
  50. package/.sinapse-ai/development/workflows/fast-track.yaml +87 -0
  51. package/.sinapse-ai/infrastructure/scripts/validate-codex-delegation.js +3 -1
  52. package/.sinapse-ai/install-manifest.yaml +71 -35
  53. package/docs/codex-integration-process.md +22 -0
  54. package/docs/codex-parity-program.md +27 -0
  55. package/docs/ide-integration.md +36 -0
  56. package/package.json +1 -1
  57. package/squads/claude-code-mastery/knowledge-base/claude-code-internals-reference.md +927 -0
  58. package/squads/squad-brand/knowledge-base/archetype-brand-mapping.md +12 -1
  59. package/squads/squad-brand/knowledge-base/brand-activism-cultural-branding.md +216 -0
  60. package/squads/squad-brand/knowledge-base/brand-audit-criteria.md +58 -0
  61. package/squads/squad-brand/knowledge-base/brand-digital-strategy.md +188 -0
  62. package/squads/squad-brand/knowledge-base/brand-legal-ip.md +222 -0
  63. package/squads/squad-brand/knowledge-base/brand-naming-framework.md +163 -0
  64. package/squads/squad-brand/knowledge-base/branding-master-reference.md +1001 -0
  65. package/squads/squad-brand/knowledge-base/color-psychology.md +25 -12
  66. package/squads/squad-brand/knowledge-base/employer-personal-branding.md +206 -0
  67. package/squads/squad-brand/knowledge-base/routing-catalog.md +34 -0
  68. package/squads/squad-brand/knowledge-base/sonic-branding-principles.md +6 -1
  69. package/squads/squad-brand/knowledge-base/typography-personality.md +34 -0
  70. package/squads/squad-claude/knowledge-base/context-window-optimization.md +334 -0
  71. package/squads/squad-claude/knowledge-base/knowledge-architecture-reference.md +403 -0
  72. package/squads/squad-claude/knowledge-base/memory-systems-reference.md +412 -0
  73. package/squads/squad-claude/knowledge-base/obsidian-claude-integration.md +423 -0
  74. package/squads/squad-claude/knowledge-base/retrieval-augmented-generation.md +320 -0
  75. package/squads/squad-claude/knowledge-base/skill-creation-patterns.md +380 -0
  76. package/squads/squad-claude/knowledge-base/swarm-orchestration-patterns.md +411 -0
  77. package/squads/squad-cloning/knowledge-base/clone-quality-assurance.md +211 -0
  78. package/squads/squad-cloning/knowledge-base/confidence-scoring.md +51 -0
  79. package/squads/squad-cloning/knowledge-base/cross-squad-deployment.md +47 -0
  80. package/squads/squad-cloning/knowledge-base/ethical-guidelines.md +237 -0
  81. package/squads/squad-cloning/knowledge-base/knowledge-graph-for-clones.md +295 -0
  82. package/squads/squad-cloning/knowledge-base/memory-architecture-for-clones.md +229 -0
  83. package/squads/squad-cloning/knowledge-base/multi-agent-deployment-patterns.md +320 -0
  84. package/squads/squad-cloning/knowledge-base/skill-standard-for-clones.md +262 -0
  85. package/squads/squad-cloning/knowledge-base/sop-extraction-guide.md +243 -0
  86. package/squads/squad-commercial/knowledge-base/account-based-selling.md +206 -0
  87. package/squads/squad-commercial/knowledge-base/ai-as-competitive-infrastructure.md +14 -0
  88. package/squads/squad-commercial/knowledge-base/ai-in-sales.md +199 -0
  89. package/squads/squad-commercial/knowledge-base/brazilian-sales-context.md +195 -0
  90. package/squads/squad-commercial/knowledge-base/customer-success-operations.md +83 -2
  91. package/squads/squad-commercial/knowledge-base/prospecting-pipeline-generation.md +69 -0
  92. package/squads/squad-commercial/knowledge-base/sales-enablement-playbook.md +260 -0
  93. package/squads/squad-commercial/knowledge-base/sales-methodology-comparison.md +185 -0
  94. package/squads/squad-commercial/knowledge-base/sales-revenue-master-reference.md +1123 -0
  95. package/squads/squad-content/knowledge-base/brazilian-content-context.md +176 -0
  96. package/squads/squad-content/knowledge-base/competitor-analysis-methods.md +40 -1
  97. package/squads/squad-content/knowledge-base/content-architecture-taxonomy.md +206 -0
  98. package/squads/squad-content/knowledge-base/content-formats-encyclopedia.md +58 -1
  99. package/squads/squad-content/knowledge-base/content-references-bibliography.md +130 -0
  100. package/squads/squad-content/knowledge-base/content-strategy-master-reference.md +1097 -0
  101. package/squads/squad-content/knowledge-base/content-tech-stack.md +150 -0
  102. package/squads/squad-content/knowledge-base/copywriting-formulas-library.md +188 -0
  103. package/squads/squad-content/knowledge-base/email-newsletter-strategy.md +161 -0
  104. package/squads/squad-content/knowledge-base/platform-algorithm-intelligence.md +86 -1
  105. package/squads/squad-content/knowledge-base/social-algorithms-master-reference.md +1007 -0
  106. package/squads/squad-content/knowledge-base/video-audio-content-playbook.md +218 -0
  107. package/squads/squad-copy/knowledge-base/ai-copy-production.md +254 -0
  108. package/squads/squad-copy/knowledge-base/brazilian-copywriting-context.md +242 -0
  109. package/squads/squad-copy/knowledge-base/email-copywriting-system.md +299 -0
  110. package/squads/squad-copy/knowledge-base/landing-page-copy-architecture.md +267 -0
  111. package/squads/squad-copy/knowledge-base/power-words-catalog.md +205 -0
  112. package/squads/squad-copy/knowledge-base/seo-copywriting.md +255 -0
  113. package/squads/squad-copy/knowledge-base/video-script-copywriting.md +239 -0
  114. package/squads/squad-council/knowledge-base/brand-strategy-models.md +193 -0
  115. package/squads/squad-council/knowledge-base/growth-strategy-models.md +267 -0
  116. package/squads/squad-council/knowledge-base/innovation-disruption-frameworks.md +193 -0
  117. package/squads/squad-council/knowledge-base/market-analysis-frameworks.md +240 -0
  118. package/squads/squad-council/knowledge-base/organizational-leadership-models.md +212 -0
  119. package/squads/squad-council/knowledge-base/sales-strategy-models.md +215 -0
  120. package/squads/squad-courses/knowledge-base/course-launch-strategy.md +251 -0
  121. package/squads/squad-courses/knowledge-base/domain-advocacia-curriculum.md +385 -0
  122. package/squads/squad-courses/knowledge-base/domain-contabilidade-curriculum.md +266 -0
  123. package/squads/squad-courses/knowledge-base/platform-comparison.md +68 -0
  124. package/squads/squad-courses/knowledge-base/video-production-guide.md +70 -0
  125. package/squads/squad-cybersecurity/knowledge-base/cloud-security-reference.md +363 -0
  126. package/squads/squad-cybersecurity/knowledge-base/compliance-frameworks.md +273 -0
  127. package/squads/squad-cybersecurity/knowledge-base/database-security.md +438 -0
  128. package/squads/squad-cybersecurity/knowledge-base/incident-response-playbook.md +420 -0
  129. package/squads/squad-cybersecurity/knowledge-base/network-security-reference.md +477 -0
  130. package/squads/squad-cybersecurity/knowledge-base/penetration-testing-methodology.md +350 -0
  131. package/squads/squad-cybersecurity/knowledge-base/vulnerability-management.md +349 -0
  132. package/squads/squad-design/knowledge-base/brazilian-design-context.md +223 -0
  133. package/squads/squad-design/knowledge-base/component-api-patterns.md +208 -4
  134. package/squads/squad-design/knowledge-base/design-system-master-reference.md +1302 -0
  135. package/squads/squad-design/knowledge-base/design-systems-frameworks.md +91 -1
  136. package/squads/squad-design/knowledge-base/responsive-modern-css.md +96 -4
  137. package/squads/squad-design/knowledge-base/wcag-aria-reference.md +117 -5
  138. package/squads/squad-design/knowledge-base/web-performance-reference.md +127 -4
  139. package/squads/squad-finance/knowledge-base/brazilian-taxation.md +263 -0
  140. package/squads/squad-finance/knowledge-base/contabilidade-master-reference.md +998 -0
  141. package/squads/squad-finance/knowledge-base/finance-master-reference.md +946 -0
  142. package/squads/squad-finance/knowledge-base/financial-reporting-analysis.md +316 -0
  143. package/squads/squad-finance/knowledge-base/fintech-brazilian-context.md +242 -0
  144. package/squads/squad-finance/knowledge-base/fpa-planning-frameworks.md +286 -0
  145. package/squads/squad-finance/knowledge-base/ma-and-transactions.md +285 -0
  146. package/squads/squad-finance/knowledge-base/risk-management.md +233 -0
  147. package/squads/squad-finance/knowledge-base/startups-venture-capital.md +337 -0
  148. package/squads/squad-growth/knowledge-base/ai-growth-playbook.md +216 -0
  149. package/squads/squad-growth/knowledge-base/attribution-models.md +78 -0
  150. package/squads/squad-growth/knowledge-base/brazilian-growth-context.md +208 -0
  151. package/squads/squad-growth/knowledge-base/community-led-growth.md +175 -0
  152. package/squads/squad-growth/knowledge-base/content-marketing-flywheel.md +190 -0
  153. package/squads/squad-growth/knowledge-base/email-lifecycle-framework.md +192 -0
  154. package/squads/squad-growth/knowledge-base/growth-frameworks-catalog.md +82 -0
  155. package/squads/squad-growth/knowledge-base/growth-master-reference.md +1168 -0
  156. package/squads/squad-growth/knowledge-base/routing-catalog.md +53 -11
  157. package/squads/squad-paidmedia/knowledge-base/audiences-segmentation-deep.md +285 -0
  158. package/squads/squad-paidmedia/knowledge-base/creative-strategy-deep.md +294 -0
  159. package/squads/squad-paidmedia/knowledge-base/google-ads-account-architecture.md +87 -0
  160. package/squads/squad-paidmedia/knowledge-base/meta-ads-campaign-architecture.md +76 -0
  161. package/squads/squad-paidmedia/knowledge-base/paid-media-metrics-reference.md +117 -0
  162. package/squads/squad-paidmedia/knowledge-base/paid-traffic-master-reference.md +1308 -0
  163. package/squads/squad-paidmedia/knowledge-base/routing-catalog.md +95 -18
  164. package/squads/squad-paidmedia/knowledge-base/traffic-masters-frameworks.md +71 -0
  165. package/squads/squad-product/knowledge-base/brazilian-product-context.md +284 -0
  166. package/squads/squad-product/knowledge-base/discovery-methodology-playbook.md +141 -0
  167. package/squads/squad-product/knowledge-base/pm-frameworks-reference.md +125 -9
  168. package/squads/squad-product/knowledge-base/product-analytics-formulas.md +72 -0
  169. package/squads/squad-product/knowledge-base/product-led-growth-reference.md +155 -13
  170. package/squads/squad-product/knowledge-base/product-market-fit-framework.md +222 -0
  171. package/squads/squad-product/knowledge-base/routing-catalog.md +32 -0
  172. package/squads/squad-research/knowledge-base/agentic-second-brain-reference.md +591 -0
  173. package/squads/squad-research/knowledge-base/ai-augmented-research.md +212 -0
  174. package/squads/squad-research/knowledge-base/brazilian-market-research-sources.md +197 -0
  175. package/squads/squad-research/knowledge-base/community-platforms-reference.md +786 -0
  176. package/squads/squad-research/knowledge-base/community-research-methods.md +194 -0
  177. package/squads/squad-research/knowledge-base/mixed-methods-research-design.md +168 -0
  178. package/squads/squad-research/knowledge-base/network-effects-analysis.md +192 -0
  179. package/squads/squad-research/knowledge-base/qualitative-research-deep-methods.md +202 -0
  180. package/squads/squad-research/knowledge-base/quantitative-research-methods.md +208 -0
  181. package/squads/squad-research/knowledge-base/research-frameworks-encyclopedia.md +40 -0
  182. package/squads/squad-research/knowledge-base/research-synthesis-frameworks.md +223 -0
  183. package/squads/squad-storytelling/knowledge-base/brand-mythology-framework.md +236 -0
  184. package/squads/squad-storytelling/knowledge-base/brazilian-storytelling-context.md +237 -0
  185. package/squads/squad-storytelling/knowledge-base/data-storytelling.md +232 -0
  186. package/squads/squad-storytelling/knowledge-base/improv-storytelling.md +226 -0
  187. package/squads/squad-storytelling/knowledge-base/persuasion-narrative-techniques.md +269 -0
  188. package/squads/squad-storytelling/knowledge-base/social-movement-narratives.md +191 -0
  189. package/squads/squad-storytelling/knowledge-base/video-storytelling.md +252 -0
  190. package/squads/claude-code-mastery/data/swarm-orchestration-patterns.yaml +0 -378
  191. package/squads/squad-animations/knowledge-base/framer-motion-complete-reference.md +0 -710
  192. package/squads/squad-animations/knowledge-base/web-animations-api-view-transitions.md +0 -478
@@ -0,0 +1,412 @@
1
+ # Memory Systems Reference
2
+
3
+ > Comprehensive reference for AI agent memory architectures, frameworks, and implementation patterns. Based on MS-009 Agentic Second Brain research (April 2026).
4
+
5
+ ---
6
+
7
+ ## The Memory Problem
8
+
9
+ The context window is the scarcest resource in agentic systems. A well-designed memory system:
10
+ - Cuts token costs by **~90%** vs sending full history
11
+ - Reduces latency by **~91%** (Mem0 benchmarks)
12
+ - Prevents "lost-in-the-middle" degradation in long conversations
13
+ - Enables agents to operate continuously across sessions
14
+
15
+ **Andrej Karpathy (2025):** "Context engineering is the delicate art and science of filling the context window with just the right information for the next step."
16
+
17
+ **Simon Willison (2025):** "Context engineering is what we do instead of fine-tuning."
18
+
19
+ **Mental model:** LLM as CPU, context window as RAM. Your job as engineer = OS managing working memory.
20
+
21
+ ---
22
+
23
+ ## Memory Layer Architecture
24
+
25
+ ### 3 Core Memory Types
26
+
27
+ | Layer | Human Analogy | Function | Duration | Storage |
28
+ |-------|--------------|----------|----------|---------|
29
+ | **Working Memory** | Scratchpad | Active task info | Session | Tokens (direct) |
30
+ | **Episodic Memory** | Autobiographical | Specific past interactions | Days-Months | Vector search |
31
+ | **Semantic Memory** | General knowledge | Facts, concepts, rules | Permanent | Graph + Vector |
32
+
33
+ ### HOT/WARM/COLD Tiers
34
+
35
+ | Tier | Access Time | Storage | Example |
36
+ |------|------------|---------|---------|
37
+ | **HOT** | Instant (in context) | In-memory (tokens) | System prompt, current task, last messages |
38
+ | **WARM** | < 300ms | Vector DB + Cache | Recent notes, mentioned entities, project decisions |
39
+ | **COLD** | On-demand | Filesystem + Archive | Old notes, completed projects, full history |
40
+
41
+ **Key principle (ContextForge):** A memory becomes HOT not just when accessed, but when semantically crucial to the current task. Even stored weeks ago, semantic relevance pulls it to HOT instantly.
42
+
43
+ ### Token Budget Management
44
+
45
+ ```
46
+ TOTAL WINDOW: 200,000 tokens (example)
47
+ |- System Prompt: ~2,000 tokens (1%)
48
+ |- Agent Persona: ~1,500 tokens (0.75%)
49
+ |- Memory Context: ~50,000 tokens (25%) ← MANAGED
50
+ | |- HOT (current): ~20,000
51
+ | |- WARM (retrieved): ~30,000
52
+ |- User History: ~20,000 tokens (10%) ← COMPACTED
53
+ |- Tool Results: ~50,000 tokens (25%) ← DYNAMIC
54
+ |- Response Budget: ~76,500 tokens (38.25%) ← RESERVED
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Memory Frameworks Comparison (2026)
60
+
61
+ ### Letta (MemGPT)
62
+
63
+ **Approach:** Virtual context management inspired by OS memory hierarchy.
64
+
65
+ **Architecture:**
66
+ - **Main context (RAM):** Active working memory — FIFO managed
67
+ - **Archival storage (disk):** Searchable long-term memory
68
+ - **Recall storage:** Conversation history with semantic search
69
+
70
+ **Highlights:**
71
+ - Letta Code (Dec 2025) — #1 on Terminal-Bench
72
+ - Conversations API (Jan 2026) — cross-session shared memory
73
+ - V1 architecture designed for GPT-5/Claude 4.5 Sonnet
74
+
75
+ **Memory Blocks:** Structured memory units agents can read/write directly:
76
+ ```python
77
+ # Agent reads/writes memory blocks explicitly
78
+ agent.memory.update("core_memory", "User prefers TypeScript over JavaScript")
79
+ facts = agent.memory.search("archival", "project decisions")
80
+ ```
81
+
82
+ ### Mem0
83
+
84
+ **Approach:** Memory layer with graph DB backend.
85
+
86
+ **Performance benchmarks:**
87
+ - 26% accuracy gain vs OpenAI Memory
88
+ - 91% lower latency
89
+ - 90% lower token usage
90
+
91
+ **Scale (Q3 2025):**
92
+ - 41K GitHub stars
93
+ - 186M API calls
94
+ - $24M Series A (Oct 2025)
95
+
96
+ **Paper:** Published at ECAI 2025.
97
+
98
+ **Implementation:**
99
+ ```python
100
+ from mem0 import Memory
101
+
102
+ m = Memory()
103
+ # Store memory
104
+ m.add("User prefers dark mode", user_id="caio")
105
+ # Search memory
106
+ results = m.search("user preferences", user_id="caio")
107
+ ```
108
+
109
+ ### A-Mem (NeurIPS 2025)
110
+
111
+ **Approach:** Zettelkasten-inspired agentic memory system.
112
+
113
+ **Design:** Atomic memory notes with:
114
+ - Unique IDs
115
+ - Keywords and tags
116
+ - Contextual descriptions
117
+ - Utility counters (frequency tracking)
118
+ - Links between related memories
119
+
120
+ **Why it matters:** First formal academic paper (NeurIPS 2025) formalizing "agentic memory" inspired by Luhmann's Zettelkasten. Proves that atomic, interconnected memory units outperform monolithic memory stores.
121
+
122
+ ### Graphiti / Zep
123
+
124
+ **Approach:** Temporal knowledge graph for agent memory.
125
+
126
+ **Key innovation:** Bi-temporal model tracking:
127
+ - WHEN an event occurred
128
+ - WHEN it was ingested
129
+
130
+ **Architecture:**
131
+ ```
132
+ [Conversational Data]
133
+ → Entity extraction
134
+ → Relationship mapping
135
+ → Temporal edge creation (validity intervals)
136
+ → Conflict resolution via metadata timestamps
137
+ → Hybrid search (semantic + BM25 + graph traversal)
138
+ ```
139
+
140
+ **Performance:**
141
+ - Retrieval P95: 300ms
142
+ - No LLM calls during retrieval
143
+ - DMR benchmark: 94.8% with gpt-4-turbo (vs 93.4% MemGPT)
144
+ - LongMemEval: up to 18.5% accuracy gain, 90% latency reduction
145
+
146
+ **Use case:** Long-lived agents that need to track how facts change over time (customer relationships, project evolution).
147
+
148
+ ### Hindsight
149
+
150
+ **Approach:** Four separate memory networks.
151
+
152
+ **Four networks:**
153
+ 1. **Facts** — explicit factual claims
154
+ 2. **Experiences** — episodic events and outcomes
155
+ 3. **Entities** — named entities with attributes
156
+ 4. **Beliefs** — inferred preferences and tendencies
157
+
158
+ **Benchmarks (Dec 2025):**
159
+ - 91.4% accuracy on DMR benchmark
160
+ - Multi-session: 21% → 79.7%
161
+ - Temporal reasoning: 31.6% → 79.7%
162
+
163
+ **Who:** Open-source by Vectorize.io + Virginia Tech + Washington Post.
164
+
165
+ ### Cognee
166
+
167
+ **Approach:** Graph-vector hybrid with cognitive engine.
168
+
169
+ **Features:**
170
+ - 30+ connectors (docs, images, audio, conversations)
171
+ - Modular pipelines for custom extraction, enrichment, retrieval
172
+ - Combines graph structures + vector embeddings
173
+
174
+ **Scale (Feb 2026):**
175
+ - $7.5M seed (backed by OpenAI founders + FAIR)
176
+ - 1M+ pipeline runs
177
+ - 70+ companies in production
178
+
179
+ ### ContextForge
180
+
181
+ **Approach:** Three-tier memory with automatic promotion/demotion.
182
+
183
+ **Storage tiers:**
184
+ - HOT: Redis (<10ms access)
185
+ - WARM: Qdrant (semantic similarity)
186
+ - COLD: PostgreSQL (persistent archive)
187
+
188
+ **10x compression ratio.**
189
+
190
+ **Promotion trigger:** Not just recency — semantic relevance to current task. A 6-month-old memory becomes HOT if it's critical for the current query.
191
+
192
+ ### OpenMemory
193
+
194
+ **Approach:** Local-first persistent memory.
195
+
196
+ **Key features:**
197
+ - SQL-native with temporal graphs
198
+ - Entity tracking across sessions
199
+ - Works with Claude Desktop
200
+ - No external services required
201
+
202
+ ---
203
+
204
+ ## Claude Code Memory System (Production Reference)
205
+
206
+ ### Architecture Details
207
+
208
+ **MEMORY.md index:** Always loaded into context. Max 200 lines / ~25KB. Acts as a pointer system, never stores raw data.
209
+
210
+ ```markdown
211
+ - [User Role](user_role.md) — senior developer, prefers TypeScript
212
+ - [Project Config](project_config.md) — monorepo, pnpm workspaces
213
+ - [Feedback](feedback_testing.md) — integration tests over mocks
214
+ ```
215
+
216
+ **Design principles:**
217
+ - Memory = hints, not ground truth
218
+ - Always verify against actual codebase before acting
219
+ - Strict Write Discipline: update only after successful actions
220
+ - MEMORY.md = index (150 chars/line max), not content
221
+
222
+ ### AutoDream Consolidation (4-phase)
223
+
224
+ ```
225
+ 1. Orient — read MEMORY.md, scan existing memory files
226
+ 2. Gather — collect new info from daily logs
227
+ 3. Consolidate — merge observations, resolve conflicts
228
+ 4. Prune — maintain <= 200 lines / 25KB limit
229
+ ```
230
+
231
+ **Triggers (all required):** 24+ hours, 5+ new sessions, no active consolidation, 10+ minutes since last scan.
232
+
233
+ ### Memory Types for Claude Code Agents
234
+
235
+ | Type | When to save | What to write |
236
+ |------|-------------|---------------|
237
+ | `user` | Learn role, preferences, expertise | Tailor collaboration style |
238
+ | `feedback` | Corrections + validated approaches | Rule + Why + How to apply |
239
+ | `project` | Ongoing work context | Fact + Why + How to apply |
240
+ | `reference` | External system pointers | Where to find what |
241
+
242
+ ---
243
+
244
+ ## Hybrid Retrieval Architecture
245
+
246
+ ### The Production Standard (2026)
247
+
248
+ ```
249
+ [Query]
250
+ → BM25 (keyword search) → Top-K results
251
+ → Dense Embeddings (semantic) → Top-K results
252
+ → Knowledge Graph (structured) → Entities/Relations
253
+ → Reciprocal Rank Fusion (RRF) → Merged & Ranked
254
+ → Cross-Encoder Reranking → Final Top-N
255
+ → LLM Generation with Context
256
+ ```
257
+
258
+ **Why BM25 still matters:** Despite embedding advances, BM25 remains unbeatable for product codes, legal terminology, unique acronyms. Hybrid search reduces errors by **35-60%** vs pure semantic retrieval.
259
+
260
+ **RRF formula:** Documents appearing in top-5 of BOTH search types receive a massive mathematical boost.
261
+
262
+ ### Vector Database Selection (2026)
263
+
264
+ | Database | Ideal For | Max Scale | P95 Latency |
265
+ |----------|-----------|-----------|-------------|
266
+ | Pinecone | Enterprise production | Billions | <50ms |
267
+ | Weaviate | Hybrid search native | 100s of millions | <100ms |
268
+ | Qdrant | Performance/cost ratio | 100s of millions | <100ms |
269
+ | Chroma | Rapid prototyping | Millions | Variable |
270
+ | pgvector | PostgreSQL integration | 5-100M | Variable |
271
+ | Milvus | Cost at scale | Billions | <50ms |
272
+
273
+ **Strategy:** Start with pgvector or Chroma for prototype, migrate to Pinecone or Weaviate for production.
274
+
275
+ ### Agentic RAG
276
+
277
+ State of the art: systems that **plan, retrieve, reason, critique, and refine** in loops until sufficient confidence.
278
+
279
+ Survey: arXiv 2501.09136 — "Agentic RAG as the next paradigm."
280
+
281
+ ```
282
+ [Question]
283
+ → Decompose into sub-questions
284
+ → For each sub-question:
285
+ → Retrieve relevant context
286
+ → Evaluate relevance and completeness
287
+ → If insufficient → refine query and retry
288
+ → Cross-reference findings
289
+ → Synthesize final answer
290
+ → Verify citations
291
+ ```
292
+
293
+ ---
294
+
295
+ ## Implementation Patterns
296
+
297
+ ### Pattern 1: Priority Queue Memory Retrieval
298
+
299
+ ```python
300
+ def retrieve_relevant_memories(query, agent_state):
301
+ # Scoring formula
302
+ relevance_score = (
303
+ 0.4 * semantic_similarity(query, memory) +
304
+ 0.3 * recency_score(memory.timestamp) +
305
+ 0.2 * frequency_score(memory.access_count) +
306
+ 0.1 * importance_score(memory.importance_flag)
307
+ )
308
+ return sorted(memories, key=relevance_score, reverse=True)[:MAX_HOT_MEMORIES]
309
+ ```
310
+
311
+ ### Pattern 2: Sliding Window + Summary
312
+
313
+ ```
314
+ Keep last N messages in full fidelity
315
+ + Compact summary of everything before
316
+ = Context that fits window without losing information
317
+ ```
318
+
319
+ **Claude Code implementation:** `merge_compact_summaries()` generates "Previously compacted context" vs "Newly compacted context" multi-stage summaries.
320
+
321
+ ### Pattern 3: Memory Blocks (Letta-style)
322
+
323
+ ```python
324
+ # Structured blocks agents can explicitly read/write
325
+ class AgentMemory:
326
+ core_memory: str # Always in context (e.g., user profile)
327
+ recall_storage: list # Searchable conversation history
328
+ archival_storage: db # Unlimited external storage
329
+
330
+ def update(self, block: str, content: str):
331
+ """Agent explicitly updates its own memory"""
332
+
333
+ def search(self, block: str, query: str) -> list:
334
+ """Agent searches external memory"""
335
+ ```
336
+
337
+ ### Pattern 4: Temporal Knowledge Graph
338
+
339
+ ```python
340
+ # Track how facts change over time
341
+ fact = KnowledgeFact(
342
+ content="User works at Astro Brand Studio",
343
+ valid_from="2025-01",
344
+ valid_to=None, # Still valid
345
+ ingested_at="2025-01-15",
346
+ source="user_statement"
347
+ )
348
+
349
+ # When conflict arises:
350
+ old_fact.valid_to = new_fact.valid_from # Invalidate, don't delete
351
+ ```
352
+
353
+ ---
354
+
355
+ ## Memory Governance
356
+
357
+ ### Quality Scoring for Memories
358
+
359
+ | Dimension | Weight | Metrics |
360
+ |-----------|--------|---------|
361
+ | Completeness | 20% | All sections filled? Sources present? |
362
+ | Accuracy | 25% | Verifiable facts? Sources cited? |
363
+ | Connectivity | 15% | Links to related memories |
364
+ | Freshness | 20% | Time since last review, access frequency |
365
+ | Utility | 20% | Retrieval frequency, user feedback |
366
+
367
+ **Score thresholds:**
368
+ - >= 80: Evergreen (high confidence)
369
+ - 60-79: Healthy (periodic review)
370
+ - 40-59: Needs Attention (flag for review)
371
+ - < 40: At Risk (candidate for archival)
372
+
373
+ ### Content Decay Detection
374
+
375
+ | Decay Type | Example | Detection Method |
376
+ |------------|---------|-----------------|
377
+ | **Factual** | Framework version changed | Compare with external sources |
378
+ | **Contextual** | Project was cancelled | Status tracking |
379
+ | **Relevance** | Topic no longer a priority | Usage analytics |
380
+ | **Structural** | Broken links, obsolete tags | Graph validation |
381
+ | **Temporal** | Note has date but no review deadline | Metadata check |
382
+
383
+ ### The ROT Problem
384
+
385
+ Without governance, knowledge systems accumulate ROT (Redundant, Outdated, Trivial content):
386
+ - Organizations lose $12.9M/year on poor data quality (Gartner, 2021)
387
+ - ROT content pollutes AI agent responses
388
+ - Solution: lifecycle stages + automated scoring + decay alerts
389
+
390
+ ---
391
+
392
+ ## SINAPSE Memory Integration
393
+
394
+ ### Current Architecture
395
+
396
+ Claude Code's built-in memory (`~/.claude/agent-memory/sinapse-claude/`) follows the 3-layer pattern:
397
+
398
+ ```
399
+ MEMORY.md (index, always loaded)
400
+ → user_*.md (user profile files)
401
+ → feedback_*.md (feedback files)
402
+ → project_*.md (project context files)
403
+ → reference_*.md (external system pointers)
404
+ ```
405
+
406
+ ### Recommended Enhancements
407
+
408
+ 1. **AutoDream-equivalent:** Periodic consolidation of memory files (SINAPSE could run this as a daily hook)
409
+ 2. **Quality scoring:** Add `quality_score` frontmatter to memory files
410
+ 3. **Decay tracking:** Add `review_by` dates to time-sensitive memories
411
+ 4. **Team memory:** Shared memory across agents using `teamMemPaths.ts` pattern
412
+ 5. **Semantic deduplication:** Before writing new memory, check for semantic overlap with existing files