memorix 1.0.7 → 1.0.8

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.
@@ -0,0 +1,488 @@
1
+ # Memorix Architecture
2
+
3
+ Memorix is an open-source cross-agent memory layer for coding agents via MCP.
4
+
5
+ It combines three core memory layers:
6
+
7
+ - **Observation Memory** for what changed and how things work
8
+ - **Reasoning Memory** for why choices were made
9
+ - **Git Memory** for engineering truth derived from commits
10
+
11
+ These layers are exposed through MCP tools, CLI workflows, and an HTTP control plane.
12
+
13
+ ---
14
+
15
+ ## 1. System Shape
16
+
17
+ Memorix is better understood as a container-style architecture with multiple ingress surfaces, a shared runtime/control plane, several memory substrates, and parallel processing/retrieval branches.
18
+
19
+ ```mermaid
20
+ flowchart LR
21
+ subgraph Clients["Clients and Surfaces"]
22
+ A1["IDEs / coding agents"]
23
+ A2["CLI / TUI"]
24
+ A3["Dashboard / browser"]
25
+ A4["Git hooks / ingest"]
26
+ end
27
+
28
+ subgraph Runtime["Runtime and Control Plane"]
29
+ B1["stdio MCP runtime"]
30
+ B2["HTTP control plane"]
31
+ B3["project binding + config provenance"]
32
+ end
33
+
34
+ subgraph Core["Memory Core"]
35
+ C1["Observation store"]
36
+ C2["Reasoning store"]
37
+ C3["Git memory store"]
38
+ C4["Session / team registry"]
39
+ end
40
+
41
+ subgraph Intelligence["Intelligence and Quality"]
42
+ D1["Formation + enrichment"]
43
+ D2["Embedding + search index"]
44
+ D3["Graph + relations"]
45
+ D4["Dedup + retention + archive"]
46
+ end
47
+
48
+ subgraph Experience["Retrieval and Experience"]
49
+ E1["Search / detail / timeline"]
50
+ E2["Dashboard / team / health"]
51
+ E3["Session handoff / agent recall"]
52
+ end
53
+
54
+ A1 --> B1
55
+ A1 --> B2
56
+ A2 --> B1
57
+ A2 --> B2
58
+ A3 --> B2
59
+ A4 --> B1
60
+
61
+ B1 --> B3
62
+ B2 --> B3
63
+
64
+ B3 --> C1
65
+ B3 --> C2
66
+ B3 --> C3
67
+ B3 --> C4
68
+
69
+ C1 --> D1
70
+ C1 --> D2
71
+ C1 --> D3
72
+ C1 --> D4
73
+ C2 --> D1
74
+ C2 --> D3
75
+ C3 --> D2
76
+ C4 --> D3
77
+
78
+ D1 --> E1
79
+ D2 --> E1
80
+ D3 --> E2
81
+ D4 --> E3
82
+ C4 --> E3
83
+ ```
84
+
85
+ ### Access and Runtime Layer
86
+
87
+ This layer provides the entry points that agents and users actually talk to.
88
+
89
+ Main pieces:
90
+
91
+ - `src/server.ts`
92
+ - `src/index.ts`
93
+ - `src/cli/index.ts`
94
+ - `src/cli/commands/serve.ts`
95
+ - `src/cli/commands/serve-http.ts`
96
+
97
+ Responsibilities:
98
+
99
+ - register MCP tools
100
+ - start stdio or HTTP transport
101
+ - manage project switching
102
+ - load config and dotenv state
103
+ - expose the dashboard and HTTP APIs
104
+
105
+ ### Memory Core
106
+
107
+ This layer stores, indexes, and serves persistent memory.
108
+
109
+ Main pieces:
110
+
111
+ - `src/memory/observations.ts`
112
+ - `src/store/orama-store.ts`
113
+ - `src/memory/session.ts`
114
+ - `src/memory/retention.ts`
115
+ - `src/memory/graph.ts`
116
+ - `src/memory/consolidation.ts`
117
+
118
+ Responsibilities:
119
+
120
+ - assign observation IDs
121
+ - persist project-scoped memory
122
+ - maintain the search index
123
+ - manage session state
124
+ - retention, archive, and deduplication
125
+ - knowledge graph entities and relations
126
+
127
+ ### Intelligence and Quality Layer
128
+
129
+ This layer improves memory quality and retrieval quality.
130
+
131
+ Main pieces:
132
+
133
+ - `src/memory/formation/`
134
+ - `src/search/intent-detector.ts`
135
+ - `src/compact/engine.ts`
136
+ - `src/llm/quality.ts`
137
+ - `src/embedding/provider.ts`
138
+
139
+ Responsibilities:
140
+
141
+ - formation pipeline
142
+ - fact extraction and evaluation
143
+ - source-aware retrieval
144
+ - compact formatting and token budgeting
145
+ - optional embedding-backed semantic search
146
+ - optional LLM-assisted quality improvements
147
+
148
+ ### Platform and Ecosystem Layer
149
+
150
+ This is the layer that makes Memorix more than a simple MCP memory server.
151
+
152
+ Main pieces:
153
+
154
+ - `src/hooks/`
155
+ - `src/git/`
156
+ - `src/workspace/`
157
+ - `src/rules/`
158
+ - `src/team/`
159
+ - `src/skills/`
160
+ - `src/dashboard/`
161
+
162
+ Responsibilities:
163
+
164
+ - IDE hook capture
165
+ - Git Memory ingestion
166
+ - workspace and rule sync across agents
167
+ - autonomous Agent Team state
168
+ - mini-skills and memory-driven workflows
169
+ - dashboard and control plane APIs
170
+
171
+ ---
172
+
173
+ ## 2. Core Memory Layers
174
+
175
+ ### Observation Memory
176
+
177
+ Observation memory captures operational and architectural facts such as:
178
+
179
+ - `what-changed`
180
+ - `problem-solution`
181
+ - `decision`
182
+ - `trade-off`
183
+ - `gotcha`
184
+ - `how-it-works`
185
+
186
+ This is the main general-purpose memory layer.
187
+
188
+ ### Reasoning Memory
189
+
190
+ Reasoning memory stores the thinking behind non-trivial decisions:
191
+
192
+ - why a choice was made
193
+ - alternatives considered
194
+ - constraints
195
+ - expected outcomes
196
+ - known risks
197
+
198
+ This layer is useful when a future agent asks:
199
+
200
+ - why did we do this?
201
+ - what trade-off did we accept?
202
+
203
+ ### Git Memory
204
+
205
+ Git Memory turns commits into structured memory with source provenance:
206
+
207
+ - `source='git'`
208
+ - `commitHash`
209
+ - changed files
210
+ - inferred observation type
211
+ - extracted concepts
212
+
213
+ This creates an engineering truth layer that complements human- or agent-authored observations.
214
+
215
+ ---
216
+
217
+ ## 3. Main Data Flows
218
+
219
+ The core operational model is not a single straight line. Memorix has multiple write paths that converge into shared memory substrates, then fan out again into indexing, quality, and retrieval surfaces.
220
+
221
+ ```mermaid
222
+ flowchart TB
223
+ W1["Manual store / MCP tools"]
224
+ W2["Git commit / git-hook / ingest"]
225
+ W3["IDE hook event"]
226
+ W4["Session start / team activity"]
227
+
228
+ W1 --> R["Runtime validation + project binding"]
229
+ W2 --> R
230
+ W3 --> R
231
+ W4 --> R
232
+
233
+ R --> S1["Observation persistence"]
234
+ R --> S2["Reasoning persistence"]
235
+ R --> S3["Git memory extraction"]
236
+ R --> S4["Session + team state"]
237
+
238
+ S1 --> P1["Formation / enrichment"]
239
+ S1 --> P2["Embedding / BM25 index"]
240
+ S1 --> P3["Graph relation update"]
241
+ S1 --> P4["Dedup / retention"]
242
+ S2 --> P1
243
+ S2 --> P3
244
+ S3 --> P2
245
+ S4 --> P3
246
+
247
+ P1 --> Q1["Search results"]
248
+ P2 --> Q1
249
+ P3 --> Q2["Dashboard / graph / team"]
250
+ P4 --> Q3["Handoff / archive / cleanup"]
251
+ S4 --> Q3
252
+ ```
253
+
254
+ ### Explicit store flow
255
+
256
+ - `memorix_store` / `memorix_store_reasoning`
257
+ - runtime validation and project binding
258
+ - persistence into observation/reasoning memory
259
+ - async quality/indexing branches
260
+ - retrieval through search/detail/timeline or dashboard surfaces
261
+
262
+ ### Git Memory flow
263
+
264
+ - `git commit`
265
+ - post-commit hook or manual `memorix ingest commit --auto`
266
+ - git extractor + noise filter
267
+ - persistence as Git Memory with provenance
268
+ - indexing and retrieval through normal search surfaces
269
+
270
+ ### Hook capture flow
271
+
272
+ - IDE hook event
273
+ - normalize and significance detection
274
+ - optional memory write
275
+ - session-aware context update
276
+
277
+ ### Retrieval flow
278
+
279
+ - `memorix_search` -> project-scoped search by default -> BM25 or hybrid retrieval -> source-aware ranking -> compact formatting
280
+ - `memorix_detail` -> full observation lookup with project-aware refs for global hits
281
+ - `memorix_timeline` -> chronological context around an anchor observation
282
+
283
+ ---
284
+
285
+ ## 4. Retrieval Model
286
+
287
+ Memorix does not treat all memory equally.
288
+
289
+ ### Default scope
290
+
291
+ - `memorix_search` defaults to the current project
292
+ - `scope="global"` searches across projects
293
+ - global hits can be opened with project-aware refs in `memorix_detail`
294
+
295
+ ### Source-aware retrieval
296
+
297
+ Retrieval weights memory differently depending on intent:
298
+
299
+ - "what changed" style queries boost Git Memory
300
+ - "why" style queries boost reasoning and decision memory
301
+ - "problem" style queries can boost both operational fixes and Git Memory
302
+
303
+ ### Progressive disclosure
304
+
305
+ Memorix retrieval is layered:
306
+
307
+ - compact search results
308
+ - timeline context
309
+ - full detail only when explicitly requested
310
+
311
+ This keeps normal retrieval efficient while still allowing deep inspection.
312
+
313
+ ---
314
+
315
+ ## 5. Project Identity Model
316
+
317
+ Project identity is central to Memorix.
318
+
319
+ Main idea:
320
+
321
+ - memory is project-scoped by default
322
+ - project IDs come from Git identity
323
+ - aliases and identity health are tracked explicitly
324
+
325
+ This prevents unrelated repositories, IDE install folders, or system directories from polluting the same memory namespace.
326
+
327
+ Useful runtime tools and surfaces:
328
+
329
+ - `memorix status`
330
+ - dashboard identity health page
331
+ - global search with project-aware refs
332
+
333
+ ---
334
+
335
+ ## 6. Configuration Model
336
+
337
+ Memorix is intentionally converging on:
338
+
339
+ - `memorix.yml` for behavior
340
+ - `.env` for secrets
341
+
342
+ Resolution order:
343
+
344
+ ### Behavior settings
345
+
346
+ 1. environment variables
347
+ 2. project `memorix.yml`
348
+ 3. user `~/.memorix/memorix.yml`
349
+ 4. legacy `~/.memorix/config.json`
350
+ 5. defaults
351
+
352
+ ### Secrets
353
+
354
+ 1. shell or host-provided environment variables
355
+ 2. project `.env`
356
+ 3. user `~/.memorix/.env`
357
+
358
+ The dashboard and `memorix status` expose config provenance so the active value source is visible.
359
+
360
+ ---
361
+
362
+ ## 7. Runtime Modes
363
+
364
+ ### `memorix serve`
365
+
366
+ Starts the stdio MCP server.
367
+
368
+ Use this for:
369
+
370
+ - Cursor
371
+ - Claude Code
372
+ - Codex
373
+ - Windsurf
374
+ - other stdio MCP clients
375
+
376
+ ### `memorix background start`
377
+
378
+ Starts the recommended long-lived HTTP control plane and dashboard in the background.
379
+
380
+ Use this when you want:
381
+
382
+ - an HTTP MCP endpoint
383
+ - one shared Memorix process for multiple agents
384
+ - Team features
385
+ - the control plane dashboard
386
+
387
+ Companion commands:
388
+
389
+ - `memorix background status`
390
+ - `memorix background logs`
391
+ - `memorix background stop`
392
+
393
+ ### `memorix serve-http --port 3211`
394
+
395
+ Starts the same HTTP MCP server and dashboard in the foreground.
396
+
397
+ Use this when you want:
398
+
399
+ - foreground logs
400
+ - manual supervision
401
+ - a custom port
402
+ - custom launch control
403
+
404
+ Main URLs:
405
+
406
+ - MCP endpoint: `http://localhost:3211/mcp`
407
+ - dashboard: `http://localhost:3211`
408
+
409
+ ### `memorix dashboard`
410
+
411
+ Standalone dashboard mode.
412
+
413
+ Useful for local inspection and debugging, but the main product mode is the dashboard embedded in the HTTP control plane.
414
+
415
+ ---
416
+
417
+ ## 8. Session and Control-Plane Coordination
418
+
419
+ The HTTP control plane is not just a transport wrapper. It is the coordination layer that keeps multiple agents, multiple projects, and multiple UX surfaces from drifting apart.
420
+
421
+ ```mermaid
422
+ flowchart LR
423
+ A1["Agent / IDE session"] --> B1["HTTP MCP initialize"]
424
+ B1 --> B2["memorix_session_start(projectRoot)"]
425
+ B2 --> C1["Project binding"]
426
+ C1 --> C2["Session context"]
427
+ C1 --> C3["Config provenance"]
428
+ C1 --> C4["Team / task registry"]
429
+
430
+ C2 --> D1["Recent Handoff"]
431
+ C2 --> D2["Key Project Memories"]
432
+ C2 --> D3["Recent Session History"]
433
+
434
+ C3 --> E1["doctor / status"]
435
+ C3 --> E2["dashboard config + health"]
436
+
437
+ C4 --> F1["team status"]
438
+ C4 --> F2["tasks / messages / locks"]
439
+ C4 --> F3["dashboard team view"]
440
+ ```
441
+
442
+ This is the layer that gives Memorix its cross-agent behavior:
443
+
444
+ - explicit `projectRoot` binding for HTTP sessions
445
+ - Git-backed project identity
446
+ - shared team/task/message state
447
+ - session handoff context that survives across clients and runs
448
+ - dashboard and CLI surfaces reading the same underlying runtime state
449
+
450
+ ---
451
+
452
+ ## 9. Dashboard as Control Plane
453
+
454
+ The dashboard is no longer just an observation browser.
455
+
456
+ It acts as a control plane for:
457
+
458
+ - memory source breakdown
459
+ - Git Memory visibility
460
+ - config provenance
461
+ - identity health
462
+ - sessions
463
+ - retention state
464
+ - read-only autonomous Agent Team state in the standalone dashboard and live state in HTTP control-plane mode
465
+
466
+ This is part of Memorix's shift from a single MCP server to a broader local memory platform.
467
+
468
+ ---
469
+
470
+ ## 10. Design Goals
471
+
472
+ Memorix is designed around a few guiding ideas:
473
+
474
+ - **Local-first**: memory should stay on the developer machine by default
475
+ - **Project-safe**: default recall should respect project boundaries
476
+ - **Cross-agent**: different tools should share one memory base
477
+ - **Layered truth**: Git Memory, observation memory, and reasoning memory each serve different jobs
478
+ - **Quality over volume**: retention, formation, compaction, and noise filtering matter as much as raw storage
479
+
480
+ ---
481
+
482
+ ## 11. Related Docs
483
+
484
+ - [Setup Guide](SETUP.md)
485
+ - [Configuration Guide](CONFIGURATION.md)
486
+ - [Git Memory Guide](GIT_MEMORY.md)
487
+ - [API Reference](API_REFERENCE.md)
488
+ - [Development Guide](DEVELOPMENT.md)