memorix 1.10.2 → 1.10.4

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 (101) hide show
  1. package/CHANGELOG.md +82 -1
  2. package/README.md +3 -1
  3. package/README.zh-CN.md +3 -1
  4. package/dist/cli/index.js +2281 -1486
  5. package/dist/cli/memcode.js +0 -0
  6. package/dist/index.js +1874 -1126
  7. package/dist/{maintenance-jobs-DVRF-46r.d.ts → maintenance-jobs-DweoCoTT.d.ts} +25 -15
  8. package/dist/maintenance-runner.d.ts +1 -1
  9. package/dist/maintenance-runner.js +802 -194
  10. package/dist/media-audio-runner.js +793 -186
  11. package/dist/media-video-runner.js +801 -194
  12. package/dist/memcode-runtime/CHANGELOG.md +64 -1
  13. package/dist/sdk.js +14036 -13317
  14. package/dist/types.d.ts +1 -1
  15. package/dist/vector-backfill-runner.d.ts +1 -1
  16. package/dist/vector-backfill-runner.js +801 -194
  17. package/docs/ARCHITECTURE.md +219 -0
  18. package/docs/CONFIGURATION.md +49 -0
  19. package/docs/DESIGN_DECISIONS.md +37 -0
  20. package/docs/DEVELOPMENT.md +1 -1
  21. package/docs/INTEGRATIONS.md +1 -1
  22. package/docs/MODULES.md +7 -1
  23. package/docs/PERFORMANCE.md +14 -0
  24. package/docs/README.md +2 -1
  25. package/docs/ROADMAP-1.9.12-2.0.md +18 -2
  26. package/docs/SETUP.md +19 -4
  27. package/package.json +1 -1
  28. package/plugins/antigravity/memorix/plugin.json +1 -1
  29. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  30. package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
  31. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  32. package/plugins/copilot/memorix/plugin.json +1 -1
  33. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  34. package/plugins/hermes/memorix/plugin.yaml +1 -1
  35. package/plugins/omp/memorix/package.json +1 -1
  36. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  37. package/plugins/pi/memorix/package.json +1 -1
  38. package/server.json +2 -2
  39. package/src/cli/commands/agent-integrations.ts +1 -1
  40. package/src/cli/commands/background.ts +1 -1
  41. package/src/cli/commands/context.ts +3 -2
  42. package/src/cli/commands/doctor.ts +9 -0
  43. package/src/cli/commands/explain.ts +3 -2
  44. package/src/cli/commands/init.ts +6 -2
  45. package/src/cli/commands/setup.ts +9 -6
  46. package/src/cli/commands/uninstall.ts +15 -0
  47. package/src/cli/tui/App.tsx +9 -16
  48. package/src/cli/tui/ConfigureView.tsx +2 -0
  49. package/src/cli/tui/chat-service.ts +6 -9
  50. package/src/cli/tui/data.ts +2 -2
  51. package/src/codegraph/auto-context.ts +10 -3
  52. package/src/codegraph/derived-view.ts +63 -0
  53. package/src/codegraph/store.ts +37 -0
  54. package/src/codegraph/types.ts +3 -0
  55. package/src/compact/engine.ts +10 -33
  56. package/src/config/dotenv-loader.ts +1 -0
  57. package/src/config/resolved-config.ts +18 -2
  58. package/src/config/retrieval-strategy.ts +22 -0
  59. package/src/config/toml-loader.ts +6 -0
  60. package/src/config/yaml-loader.ts +11 -2
  61. package/src/core/derived-view.ts +15 -0
  62. package/src/core/maintenance-result.ts +33 -0
  63. package/src/core/retrieval-contracts.ts +57 -0
  64. package/src/core/retrieval-facade.ts +18 -0
  65. package/src/core/retrieval-policy.ts +44 -0
  66. package/src/core/runtime-context.ts +42 -0
  67. package/src/dashboard/server.ts +5 -6
  68. package/src/embedding/api-provider.ts +18 -8
  69. package/src/hooks/handler.ts +0 -1
  70. package/src/integrations/registry.ts +2 -1
  71. package/src/knowledge/workset.ts +0 -2
  72. package/src/llm/provider.ts +2 -1
  73. package/src/memory/consolidation.ts +3 -2
  74. package/src/memory/feedback-model.ts +1 -4
  75. package/src/memory/observations.ts +226 -104
  76. package/src/multimodal/image-loader.ts +2 -2
  77. package/src/runtime/control-plane-maintenance.ts +1 -0
  78. package/src/runtime/isolated-maintenance.ts +1 -0
  79. package/src/runtime/maintenance-jobs.ts +123 -32
  80. package/src/runtime/open-browser.ts +25 -0
  81. package/src/runtime/project-maintenance.ts +69 -1
  82. package/src/sdk.ts +3 -2
  83. package/src/search/fts-view.ts +53 -0
  84. package/src/search/orama-view.ts +40 -0
  85. package/src/search/retrieval-facade.ts +38 -0
  86. package/src/search/semantic-index.ts +13 -0
  87. package/src/search/semantic-view.ts +34 -0
  88. package/src/server.ts +21 -9
  89. package/src/store/obs-store.ts +15 -0
  90. package/src/store/orama-store.ts +143 -45
  91. package/src/store/sqlite-db.ts +22 -0
  92. package/src/store/sqlite-store.ts +27 -0
  93. package/src/types.ts +1 -1
  94. package/src/workspace/mcp-adapters/pi.ts +58 -0
  95. package/plugins/pi/memorix/skills/memorix-git-memory/SKILL.md +0 -26
  96. package/plugins/pi/memorix/skills/memorix-memory/SKILL.md +0 -51
  97. package/plugins/pi/memorix/skills/memorix-mini-skills/SKILL.md +0 -31
  98. package/plugins/pi/memorix/skills/memorix-orchestrate/SKILL.md +0 -28
  99. package/plugins/pi/memorix/skills/memorix-reasoning/SKILL.md +0 -30
  100. package/plugins/pi/memorix/skills/memorix-sessions/SKILL.md +0 -25
  101. package/plugins/pi/memorix/skills/memorix-troubleshooting/SKILL.md +0 -27
@@ -2,6 +2,218 @@
2
2
 
3
3
  Memorix is an open-source cross-agent memory layer for coding agents via MCP.
4
4
 
5
+ > **Architecture audit: 2026-11-05**
6
+ >
7
+ > The current implementation is feature-rich but boundary-fragile. The largest
8
+ > runtime files are `src/server.ts` (~5.5k lines), `src/store/orama-store.ts`
9
+ > (~1.7k), `src/memory/observations.ts` (~1.6k), and
10
+ > `src/cli/commands/setup.ts` (~1.9k). Around 139 direct environment/config
11
+ > reads are spread across `src/`, and multiple hosts assemble the same project
12
+ > context independently. This explains why fixes repeatedly appear in several
13
+ > layers and why derived-index failures can look like successful empty state.
14
+ >
15
+ > The project is not suffering from one bad model or one bad dependency. It has
16
+ > a missing kernel boundary: canonical records, derived views, retrieval policy,
17
+ > runtime hosts, and maintenance jobs are implemented as cooperating conventions
18
+ > rather than enforceable interfaces. New features therefore cross too many
19
+ > mutable singletons and can regress lazy mode, search ranking, retention, or
20
+ > cross-process behavior without a compiler error.
21
+ >
22
+ > The target architecture below is the refactor contract for 1.11. It preserves
23
+ > SQLite local-first semantics and avoids a wholesale storage rewrite.
24
+
25
+ ## 0. Current Architecture Audit and Refactor Target
26
+
27
+ ### 0.1 What is going wrong
28
+
29
+ 1. **Canonical and derived state are mixed in control flow.** SQLite is the
30
+ documented source of truth, but Orama, Lance, CodeGraph, cache hydration,
31
+ and in-memory observation state each have their own readiness and repair
32
+ paths. A lazy corpus can be empty in memory while still being healthy in
33
+ SQLite, yet older callers interpret the empty array as "no missing work".
34
+ 2. **The write pipeline has too many owners.** Observation persistence,
35
+ embedding scheduling, CodeGraph binding, evidence projection, claims, and
36
+ maintenance enqueueing all happen from `memory/observations.ts`. A provider
37
+ or index failure can therefore affect unrelated write behavior and is hard to
38
+ test as an isolated contract.
39
+ 3. **Retrieval policy is distributed.** `server.ts`, `orama-store.ts`, CodeGraph
40
+ context assembly, compact formatting, and profile registration each shape
41
+ what the agent sees. There is no single retrieval plan object that records
42
+ candidate sources, freshness, cost, abstention, and final selection.
43
+ 4. **Background jobs report lifecycle, not truth.** A job can reach `completed`
44
+ while doing zero useful work in a lazy or unavailable state. Maintenance
45
+ needs progress counters and explicit `degraded`/`retry` outcomes.
46
+ 5. **Runtime hosts duplicate binding and policy.** stdio, HTTP, hooks, CLI, and
47
+ Dashboard call adjacent functions with different defaults. The codegraph
48
+ refresh policy and project binding must be resolved once and passed down.
49
+ 6. **The current graph is a derived cache without a full retention owner.**
50
+ Snapshot manifests and stale symbols were allowed to grow until #371. The
51
+ same failure pattern already appeared in Lance metadata in #365.
52
+
53
+ ### 0.2 Target layers
54
+
55
+ ```text
56
+ Host adapters
57
+ stdio MCP | HTTP MCP | CLI | hooks | dashboard | SDK
58
+ |
59
+ Runtime facade
60
+ ProjectBinding + ResolvedConfig + SessionScope + RetrievalRequest
61
+ |
62
+ Memory kernel
63
+ WritePipeline | RetrievalFacade | MaintenanceCoordinator | EvidencePolicy
64
+ |
65
+ Canonical record plane
66
+ SQLite records, scopes, provenance, lifecycle, optional append-only events
67
+ |
68
+ Derived view plane
69
+ FTS | Orama | Lance | CodeGraph | receipts | caches
70
+ ```
71
+
72
+ Host adapters may depend on the runtime facade. The runtime facade may depend on
73
+ the memory kernel. Derived views may read canonical records and publish health,
74
+ generation, and rebuild operations, but they may never decide that canonical
75
+ storage is empty or successful. The kernel owns policy; views own mechanics.
76
+
77
+ ### 0.3 Non-negotiable contracts
78
+
79
+ - **Canonical truth:** all durable records have a stable ID, project/scope,
80
+ provenance, lifecycle state, created/updated time, and source revision. An
81
+ index row is never the only copy of a fact.
82
+ - **Derived view contract:** every view implements `status`, `refresh`,
83
+ `rebuild`, `compact`, and `close`; status distinguishes `ready`, `stale`,
84
+ `degraded`, `rebuilding`, and `unavailable`. No derived failure returns a
85
+ fake empty result without a receipt.
86
+ - **Write contract:** the canonical write commits first. Derived work is an
87
+ idempotent outbox/maintenance action with `attempted`, `succeeded`, `failed`,
88
+ and `remaining` counts. A completed job with zero attempted work is not a
89
+ successful backfill.
90
+ - **Retrieval contract:** one `RetrievalPlan` carries query intent, project
91
+ binding, allowed sources, freshness policy, token budget, and abstention
92
+ rules. One `RetrievalReceipt` records candidates, selected IDs, omitted IDs,
93
+ source generations, elapsed time, and degraded reasons.
94
+ - **Freshness contract:** current truth and historical belief are separate.
95
+ Changing a fact supersedes or invalidates the old version; it does not erase
96
+ the audit record. Future temporal memory work should use valid-time and
97
+ transaction-time fields rather than another overwrite-only vector row.
98
+ - **Context contract:** retrieval is progressive disclosure. Index/abstract
99
+ first, overview next, full detail only on demand. A search tool must never
100
+ return a large raw corpus as its default answer.
101
+ - **Config contract:** providers, refresh policy, thresholds, and credentials
102
+ are resolved once into an immutable runtime config. Business modules do not
103
+ read `process.env` directly.
104
+ - **Maintenance contract:** retention, compaction, backfill, and graph refresh
105
+ are resumable, observable, bounded, and safe when another process is active.
106
+
107
+ ### 0.4 Refactor sequence
108
+
109
+ **P0 - contract extraction, current patch line:** complete the missing safety
110
+ fixes, preserve local SQLite, and add regression tests for lazy vectors, CJK
111
+ search, affinity ordering, CodeGraph growth, shell-free browser launch, and
112
+ provider isolation.
113
+
114
+ **P1 - 1.11 kernel extraction:** introduce `src/core/` contracts for
115
+ `ProjectBinding`, `ResolvedRuntimeConfig`, `RetrievalPlan`, `RetrievalReceipt`,
116
+ `DerivedView`, and `MaintenanceResult`. Move host code behind these interfaces;
117
+ do not move data tables yet. Add architecture tests for allowed dependency
118
+ directions and one store-to-search-to-detail integration fixture.
119
+
120
+ The first P1 slice is implemented: `RuntimeContext` captures a verified project
121
+ and immutable per-request config; CodeGraph uses it. Lance has a concrete
122
+ `DerivedView` adapter used by vector writes. Other hosts and derived views still
123
+ need migration. A dependency test now rejects host, persistence, and adapter
124
+ imports from `src/core/`. `MaintenanceResult` is defined in the kernel; its
125
+ progress counts are validated before a runner persists them. Maintenance
126
+ progress is durable in SQLite. The MCP server captures a `RuntimeContext` after
127
+ project binding and refreshes it on runtime activation and project switch;
128
+ CodeGraph host operations consume that immutable configuration snapshot.
129
+
130
+ SQLite FTS5, Orama, and CodeGraph now have concrete `DerivedView` adapters
131
+ alongside Lance.
132
+ Their lifecycle reports missing, stale, unavailable, and ready states instead
133
+ of making each host infer index health from an empty result.
134
+
135
+ **P2 - 1.11 durable write pipeline:** add a small canonical write service and
136
+ an idempotent derived-work outbox. Observation capture, Git ingest, and
137
+ explicit MCP store calls use the same pipeline. Keep formation and provider
138
+ calls outside canonical SQLite transactions.
139
+
140
+ The first P2 slice is implemented for vector work: observation writes register
141
+ the deduplicated backfill job inside the SQLite transaction, foreground success
142
+ leaves project-level work for the worker to verify, and maintenance rows persist
143
+ real progress counters. The same transaction now also registers qualification
144
+ and claim derivation for inserted observations and topic-key updates. Topic-key
145
+ updates commit SQLite before refreshing Orama; a failed canonical write or
146
+ linked-record callback leaves the prior search result in place. Other derived
147
+ projections now use an `observation-project` outbox item. The foreground path
148
+ tries CodeGraph and evidence immediately and acknowledges the item only when
149
+ both succeed; a crash or failure leaves the item for an isolated idempotent
150
+ retry.
151
+
152
+ The outbox also records writes that arrive during a running deduplicated job.
153
+ The worker either performs a follow-up pass after completion, or preserves the
154
+ new work through retry exhaustion and lease recovery. Recurring jobs process a
155
+ new event before returning to their long schedule; provider retry cooldowns
156
+ remain in force. The new SQLite flag defaults to false for pre-1.11 rows.
157
+
158
+ Automatic cleanup jobs re-check the resolved behavior configuration when they
159
+ execute. Disabling `memory.autoCleanup` therefore neutralizes already queued
160
+ retention, consolidation, and long-term maintenance work without affecting
161
+ explicit user-requested cleanup actions.
162
+
163
+ **P3 - 1.11 retrieval/context plane:** move ranking, freshness, provenance,
164
+ admission, and progressive disclosure into `RetrievalFacade`. Keep Orama,
165
+ Lance, FTS, and CodeGraph adapters replaceable. Add a retrieval evaluation
166
+ matrix based on real issue-resolution tasks, with recall, precision, latency,
167
+ token cost, and abstention correctness.
168
+
169
+ The first P3 slice is implemented: a host-independent facade normalizes the
170
+ retrieval plan and returns entries with the diagnostics and derived-view status
171
+ from that same execution. Compact search, SDK, TUI search, TUI chat, and index probes no longer read a
172
+ project-wide last-search value after another request can overwrite it. The
173
+ facade applies feedback from the active canonical data directory and records
174
+ feedback omissions separately from embedding fallback. The
175
+ existing 20-case offline task matrix passes with a fresh 40k local-store gate;
176
+ ranking and admission policy still live in their current modules, and the
177
+ matrix is not an unseen live-task benchmark.
178
+
179
+ Workset assembly follows the same rule: it uses derived-view status supplied by
180
+ the current context build and does not read a process-global last-search view.
181
+ The remaining P3 work is to move more ranking/admission decisions behind the
182
+ facade and add unseen issue-resolution evaluations.
183
+
184
+ **P4 - 1.12 ecosystem boundary:** generate host capability manifests from one
185
+ registry, validate setup/doctor/repair/uninstall from the same manifest, and
186
+ keep provider and agent integrations outside the kernel. Add package smoke,
187
+ provenance, SBOM, and support-matrix checks to release gates.
188
+
189
+ **2.0 remains conditional.** A larger version is justified only if remote
190
+ canonical storage, tenant authorization, or public MCP contracts require a
191
+ breaking change. File size, accumulated integrations, or a desire to "start
192
+ clean" are not reasons to rewrite the product.
193
+
194
+ ### 0.5 Research basis
195
+
196
+ The refactor follows current agent-memory evidence rather than adding another
197
+ database for fashion:
198
+
199
+ - [PROJECTMEM](https://arxiv.org/html/2606.12329v1) uses typed append-only
200
+ events and deterministic projections for auditable coding-agent memory.
201
+ - [Stratum](https://arxiv.org/html/2610.36153v1) separates structural,
202
+ historical, and experiential repository memory and treats retrieval as a
203
+ page-safe, costed operation.
204
+ - [OpenViking](https://github.com/volcengine/OpenViking) uses hierarchical
205
+ L0/L1/L2 context loading so agents inspect summaries before full detail.
206
+ - [Mem0](https://arxiv.org/html/2504.19413v1) makes consolidation an explicit
207
+ ADD/UPDATE/DELETE/NOOP decision rather than appending every observation.
208
+ - [Zep/Graphiti](https://arxiv.org/abs/2501.13956) demonstrates why temporal
209
+ validity and transaction history matter when facts change.
210
+ - Recent releases from [claude-mem v15.7.0](https://github.com/thedotmack/claude-mem/releases/tag/v15.7.0),
211
+ [Hindsight v1.1.0](https://github.com/vectorize-io/hindsight/releases/tag/v1.1.0),
212
+ and [Graphiti v0.31.2](https://github.com/getzep/graphiti/releases/tag/v0.31.2)
213
+ emphasize background-job coalescing, environment isolation, redaction,
214
+ retention, decision-model concurrency, and security defaults. These are
215
+ operational contracts, not optional polish.
216
+
5
217
  It combines three source-of-truth memory layers and a curated long-term memory layer:
6
218
 
7
219
  - **Observation Memory** for what changed and how things work
@@ -194,6 +406,13 @@ Responsibilities:
194
406
  - optional embedding-backed semantic search
195
407
  - optional LLM-assisted quality improvements
196
408
 
409
+ Remote embedding is treated as a retryable transport boundary. HTTP status
410
+ retries and connection failures use the same bounded backoff, while caller
411
+ deadlines and explicit retry opt-outs remain authoritative. The API embedding
412
+ cache is restored in bounded timer-yielding batches after provider
413
+ initialization; a cache restore cannot monopolize the control-plane event loop
414
+ or make formation timeouts depend on cache size.
415
+
197
416
  ### Platform and Ecosystem Layer
198
417
 
199
418
  This is the layer that makes Memorix more than a simple MCP memory server.
@@ -244,6 +244,33 @@ background memory processing. Embeddings and memcode's model registry are
244
244
  unchanged. Image analysis requires explicitly selecting a vision-capable model;
245
245
  the default is for text memory.
246
246
 
247
+ ### Runcrate memory preset
248
+
249
+ [Runcrate](https://runcrate.ai) serves open-weight models through an
250
+ OpenAI-compatible API and is available in `memorix init` and the configuration
251
+ TUI as an optional memory LLM preset:
252
+
253
+ ```toml
254
+ [memory.llm]
255
+ provider = "runcrate"
256
+ model = "deepseek-ai/DeepSeek-V4.1-Flash"
257
+ ```
258
+
259
+ The preset uses `https://api.runcrate.ai/v1` and the existing
260
+ OpenAI-compatible chat completion transport. Set `RUNCRATE_API_KEY` or
261
+ `MEMORIX_LLM_API_KEY`, or store `api_key` in your private global config. Keep
262
+ credentials out of project TOML. Explicit `model` and `base_url` overrides
263
+ still apply; model IDs use the `vendor/model` form from the endpoint's
264
+ `/v1/models` catalog, for example `zai-org/GLM-5.3` or `Qwen/Qwen3.6-35B-A3B`.
265
+ Get a key at https://runcrate.ai/dashboard/api-keys.
266
+
267
+ `RUNCRATE_API_KEY` is used only when this memory preset is selected, and the
268
+ preset does not borrow OpenAI, Anthropic, OpenRouter, Requesty, API Route,
269
+ Cheaper Inference, or Atlas Cloud keys. Setting the key alone does not enable
270
+ paid background memory processing. Embeddings and memcode's model registry are
271
+ unchanged. Image analysis requires explicitly selecting a vision-capable model
272
+ such as `moonshotai/Kimi-K3`; the default is for text memory.
273
+
247
274
  ### OrcaRouter custom endpoint
248
275
 
249
276
  OrcaRouter works through the generic OpenAI-compatible gateway path. Keep the
@@ -291,6 +318,21 @@ Provider values:
291
318
  - `transformers`
292
319
 
293
320
  If embedding is unavailable, Memorix falls back to BM25/full-text search.
321
+
322
+ ### `[retrieval]`
323
+
324
+ Chooses the ranker after a query is embedded. Project `memorix.toml` overrides `~/.memorix/config.toml`, same as `[embedding]`. Invalid values are ignored.
325
+
326
+ ```toml
327
+ [retrieval]
328
+ cjk = "vector"
329
+ ascii = "hybrid"
330
+ ```
331
+
332
+ - `vector`: rank by the Lance neighbor order and dedupe by memory id. Recency and the affinity tie-break still apply afterwards. If the Lance table has no vectors, search falls back to `hybrid` and the diagnostics record `lance vector index empty; hybrid search used`.
333
+ - `hybrid`: the existing Orama hybrid ranker.
334
+
335
+ `cjk` applies when more than 30% of the query characters are CJK. Everything else uses `ascii`. Defaults are `cjk = "vector"` and `ascii = "hybrid"`. `MEMORIX_RETRIEVAL_CJK` and `MEMORIX_RETRIEVAL_ASCII` override the files.
294
336
  `transformers` is no longer installed by default; install
295
337
  `@huggingface/transformers` explicitly in the project or global prefix where
296
338
  Memorix runs if you choose that provider. `fastembed` remains a supported local
@@ -479,6 +521,7 @@ Common keys:
479
521
 
480
522
  - `exclude_patterns = ["vendor/**", "third_party/**", "generated/**"]`
481
523
  - `max_file_bytes = 2097152` (2 MiB per source file by default)
524
+ - `auto_refresh = "auto"` (`"always"` or `"never"` can force or disable built-in Code Memory scans)
482
525
  - `external_context = "auto"` (`"off"` keeps the built-in Lite provider only)
483
526
  - `external_command = "C:\\tools\\codegraph.cmd"` (optional path when CodeGraph is not on `PATH`)
484
527
  - `external_timeout_ms = 3000` (bounded local semantic-query timeout; values are clamped to 5 seconds)
@@ -494,6 +537,12 @@ suggested reads. Files larger than `max_file_bytes` are also skipped so a
494
537
  generated or minified source file cannot monopolize an incremental scan. Raise
495
538
  the limit only for a repository where that file is intentional source.
496
539
 
540
+ Built-in CodeGraph keeps the latest two completed snapshots, removes stale
541
+ symbols and dependent edges after a successful refresh, and reclaims SQLite WAL
542
+ and free pages when derived data was removed. `auto_refresh = "never"` is useful
543
+ for large BM25-only stores that do not need code indexing; `memorix codegraph`
544
+ refresh remains available for an explicit scan.
545
+
497
546
  `external_context = "auto"` is deliberately conservative. Memorix checks for
498
547
  an already-initialized local `.codegraph` index and uses it only when its status
499
548
  matches the current project and has no pending changes. It never runs
@@ -5,6 +5,43 @@
5
5
 
6
6
  ---
7
7
 
8
+ ## ADR-017: Memory Kernel and Derived-View Boundary
9
+
10
+ **状态**: 已采纳(1.11 重构基线)
11
+
12
+ **背景**: 1.10.x 已经同时包含 SQLite、FTS、Orama、Lance、CodeGraph、
13
+ hooks、MCP、HTTP、CLI 和 Dashboard。它们曾依靠约定共享状态,导致派生索引
14
+ 膨胀、lazy mode 无声降级、检索排序回归和后台任务“成功但没有工作”。
15
+
16
+ **决策**: 保持 SQLite 为 canonical record plane,抽出一个 Memory Kernel,
17
+ 用统一的 Runtime Facade、RetrievalPlan/Receipt、DerivedView 和
18
+ MaintenanceResult 契约连接所有宿主和派生视图。结构、历史和经验记忆可以有
19
+ 不同索引,但不能有多个互相竞争的真相源。
20
+
21
+ **理由**:
22
+
23
+ - 新功能只应依赖 kernel contract,不应直接穿透到另一个宿主的 singleton;
24
+ - 派生视图必须能够报告 stale/degraded/rebuilding,并且可独立重建;
25
+ - canonical write 与 embedding、graph、rerank、LLM 等副作用解耦;
26
+ - 同一个 RetrievalPlan 让 MCP、CLI、HTTP 和 Dashboard 产生可比较的结果;
27
+ - 事件/版本/来源保留审计能力,为未来 relay 和时间推理留下迁移路径。
28
+
29
+ **不做**:
30
+
31
+ - 不立即把 SQLite 换成云端数据库;
32
+ - 不为了“架构重写”删除现有 MCP/CLI 兼容面;
33
+ - 不把所有 observation 自动提升为长期记忆或图谱事实;
34
+ - 不新增一个向量数据库来掩盖生命周期和检索策略问题。
35
+
36
+ **影响**:
37
+
38
+ - 1.11 先抽接口和门面,再逐个迁移宿主;
39
+ - 每个派生视图必须有 rebuild/compact/status 测试;
40
+ - 发布门槛增加检索质量、资源上限和降级语义测试;
41
+ - 当前大模块可渐进拆分,避免一次性高风险迁移。
42
+
43
+ ---
44
+
8
45
  ## 决策编号规则
9
46
  - `ADR-XXX`: Architecture Decision Record (架构决策)
10
47
  - 按时间顺序编号
@@ -13,7 +13,7 @@ Memorix is a TypeScript project built around:
13
13
 
14
14
  ## Current Development Baseline
15
15
 
16
- The current release line is **1.10.2** and package metadata is kept
16
+ The current release line is **1.10.4** and package metadata is kept
17
17
  synchronized with the root package and MCP Registry manifest. The next larger
18
18
  feature phase follows the 1.11 relay-preview plan.
19
19
 
@@ -85,7 +85,7 @@ Generated guidance also has scope:
85
85
  | OpenClaw | `memorix setup --agent openclaw --global` | OpenClaw compatible bundle | `~/.openclaw/extensions/memorix` with `.mcp.json`, skills, and OpenClaw `HOOK.md`/`handler.ts` hook pack | Setup attempts `openclaw plugins install <path> --force` and `openclaw hooks enable memorix` when OpenClaw is available. |
86
86
  | Hermes Agent | `memorix setup --agent hermes --global` | Hermes plugin | Hermes home (`%LOCALAPPDATA%\hermes` on native Windows, `~/.hermes` elsewhere, or `HERMES_HOME`), plugin enablement in `config.yaml`, and `mcp_servers.memorix` | The plugin registers hooks, a slash command, a CLI command, and skills through Hermes' plugin context. Existing YAML keys are preserved. |
87
87
  | Oh-my-Pi | `memorix setup --agent omp --global` | Oh-my-Pi `omp.extensions` package | `.omp/packages/memorix` or `~/.omp/agent/packages/memorix`, plus `.omp/mcp.json` or `~/.omp/agent/mcp.json` | Setup attempts `omp plugin link <path>`. This target uses Oh-my-Pi's package/extension manifest, not Pi's legacy package manifest. |
88
- | Pi | `memorix setup --agent pi --global` | Pi package | User Pi package with extension and official skills, registered through `pi install <path> --approve` | Run without `--global` only when you want a project-local Pi package. Pi currently does not need a separate Memorix MCP config lane. |
88
+ | Pi | `memorix setup --agent pi --global` | Pi package + native MCP (Pi 1.0+) | Extension and official skills registered through `pi install <path> --approve`, plus `~/.pi/agent/mcp.json` | Project setup writes `.pi/packages/memorix` and `.pi/mcp.json`; trust the project in Pi. Default stdio runs `memorix serve --mode lite`; `--mcp http` selects the shared endpoint. Run `pi mcp list`, then `/reload`. |
89
89
  | Windsurf | `memorix setup --agent windsurf --global` | Windsurf MCP/rules/hooks config | stdio MCP config, `.windsurf/rules/memorix.md`, hook config | Uses Windsurf's current config surfaces. |
90
90
  | Kiro | `memorix setup --agent kiro --global` | Kiro MCP/steering/hooks config | MCP config, `.kiro/steering/memorix.md`, `.kiro/hooks/*.kiro.hook` | Uses Kiro steering and hook files. |
91
91
  | Antigravity | `memorix setup --agent antigravity --global` | **Primary supported target** | Plugin under `~/.gemini/config/plugins/memorix` or `.agents/plugins/memorix`, with `plugin.json`, `mcp_config.json`, `hooks.json`, rules, and skills | Uses Antigravity's official plugin layout. Dedicated MCP configs live at `~/.gemini/config/mcp_config.json` or `.agents/mcp_config.json`; legacy Gemini settings are read only for compatibility. |
package/docs/MODULES.md CHANGED
@@ -1,17 +1,23 @@
1
1
  # Memorix 模块详解
2
2
 
3
- > 最后更新: 2026-09-01(当前发布线 v1.8.6)
3
+ > 最后更新: 2026-11-18(源码与 npm 发布版本 v1.10.4)
4
4
  > 本文档记录当前模块边界、关键算法和兼容层,不把历史实现误写成运行时主路径。
5
5
 
6
6
  > 当前真实主路径先看下面的模块总览,再看各模块的细节。早期 JSON/Orama
7
7
  > 说明仍保留用于迁移和实现背景,但不代表 JSON 是运行时主存储。
8
8
 
9
+ > 2026-11 架构审计结论:当前模块表描述了职责,但代码仍有多个宿主直接
10
+ > 穿透业务模块。后续 1.11 以 [ARCHITECTURE.md § 0](ARCHITECTURE.md#0-current-architecture-audit-and-refactor-target)
11
+ > 定义的 Memory Kernel、Runtime Facade、Derived View 和 MaintenanceResult
12
+ > 契约为准;本文件不再把“模块存在”当成“边界已隔离”。
13
+
9
14
  ## 当前模块总览
10
15
 
11
16
  | 模块 | 当前作用 | 是否主路径 |
12
17
  | --- | --- | --- |
13
18
  | `store/sqlite-db.ts`、`store/sqlite-store.ts` | 持久化观察、会话、图谱、知识、长期记忆、媒体和协作状态 | 是 |
14
19
  | `store/orama-store.ts` | 从 SQLite 数据重建的全文/向量检索索引 | 是,索引层 |
20
+ | `core/retrieval-facade.ts`、`search/retrieval-facade.ts` | 规范化请求并将检索结果与本次执行收据绑定;排序仍由搜索适配器实现 | 是,逐步迁移中 |
15
21
  | `memory/graph.ts` | MCP 兼容的实体/关系操作外观,底层写入 SQLite | 是 |
16
22
  | `wiki/knowledge-graph.ts` | Dashboard 的证据化 Memory Map 投影,不是真实数据源 | 是,展示层 |
17
23
  | `dashboard/static/` | 只保留 ECharts Memory Map 这一套图谱界面 | 是 |
@@ -114,6 +114,12 @@ the compatibility fallback.
114
114
 
115
115
  ### LanceDB semantic index maintenance
116
116
 
117
+ The Lance write bridge implements the internal `DerivedView` contract: its
118
+ status distinguishes a missing table from a ready table, refresh uses bounded
119
+ single/vector-batch writes, and rebuild/compact/close operate on one profile.
120
+ This is the first view migrated to the 1.11 Memory Kernel boundary; SQLite
121
+ remains authoritative if the optional native index is unavailable.
122
+
117
123
  The persistent semantic index groups individual observation writes into batches
118
124
  of up to 100 vectors, flushing after 50 ms. It compacts fragments and prunes
119
125
  versions older than 24 hours after every 20 committed batches. Existing vectors
@@ -218,6 +224,14 @@ crash must be reconciled before a dangerous retry.
218
224
 
219
225
  ## Large-Store Release Gate
220
226
 
227
+ 2026-11-05 Windows/Node 22 offline run at 40,000 seeded records: seed and
228
+ index 74.6s, steady write p50/p95 1.2/3.6ms, warm SDK search 33.6ms,
229
+ HTTP MCP cold search 418.7ms, receipt assembly 10ms, peak RSS 411.8MB.
230
+ SDK reopen, HTTP MCP store, hook store, and durable row-count checks passed.
231
+ The 20-case context task matrix passed 20/20 when supplied this gate report.
232
+ These measurements use disabled embeddings and one local machine; remote
233
+ provider latency and unseen task quality are separate checks.
234
+
221
235
  `npm run gate:large-store -- --records 40000` builds Memorix and creates a
222
236
  temporary Git project with an isolated data directory. It runs with embeddings
223
237
  disabled, so it does not use provider credentials or make paid network calls.
package/docs/README.md CHANGED
@@ -127,7 +127,8 @@ Historical/deep-reference documents may describe older designs. If they conflict
127
127
 
128
128
  ## Current Product Line
129
129
 
130
- The current product line is **1.10.2**; it includes the LanceDB semantic-index
130
+ The current product line is **1.10.4**; it includes the CodeGraph, lazy-vector,
131
+ search-regression, browser-launch, and Runcrate updates on top of the LanceDB
131
132
  growth fix, derived-view receipts, and the optional Cheaper Inference preset.
132
133
  Multi-device store sync is opt-in and keeps local SQLite canonical; existing
133
134
  users do not upload anything until they configure a relay provider explicitly.
@@ -47,7 +47,7 @@ Memorix 已经超过“给 coding agent 加一个记忆工具”的阶段。当
47
47
 
48
48
  ### 1.1 当前事实
49
49
 
50
- 当前发布基线是 `v1.10.2`。本补丁修复 LanceDB 语义索引无限增长;1.9.12 的 CJK 搜索、搜索回退、大库 alias 迁移、
50
+ 当前发布基线是 `v1.10.4`。1.10.2 修复了 LanceDB 语义索引无限增长;1.10.3 继续修复 CodeGraph、lazy vector 和搜索回归;1.10.4 增加 embedding 传输恢复、启动缓存节流和 CJK 向量排序;1.9.12 的 CJK 搜索、搜索回退、大库 alias 迁移、
51
51
  Node 26 Pi hooks、Qwen hooks、API Route provider、session label、发布
52
52
  provenance 收紧和后台更新脚本隔离,已经与 1.10 的可信上下文、检索收据、
53
53
  真实矩阵评估和容量门禁一起发布。
@@ -432,9 +432,25 @@ CLI、Dashboard 和 doctor 要能回答:
432
432
 
433
433
  ## 4. 1.11:本地优先 relay 与协作预览
434
434
 
435
- 1.11 才开始验证 hosted/relay 需求。它必须是 opt-in preview,不能改变默认本地
435
+ 1.11 先完成 Memory Kernel 和 derived-view 边界收敛,再开始验证 hosted/relay
436
+ 需求。它必须是 opt-in preview,不能改变默认本地
436
437
  产品。
437
438
 
439
+ ### 4.0 结构前置条件
440
+
441
+ relay 不能建立在当前多宿主直接访问 store/singleton 的结构上。进入 relay
442
+ 实现前必须完成:
443
+
444
+ - `ProjectBinding`、`ResolvedRuntimeConfig`、`RetrievalPlan`、
445
+ `RetrievalReceipt`、`DerivedView`、`MaintenanceResult` 的内部契约;
446
+ - canonical write 与派生 embedding/CodeGraph/FTS/Lance 工作解耦;
447
+ - 所有宿主使用同一个 RetrievalFacade 和 refresh policy;
448
+ - backfill、snapshot retention、compaction 的完成条件包含实际进度;
449
+ - 1k/10k/40k/100k 规模下记录检索召回、token、RSS、延迟和降级行为。
450
+
451
+ 否则 relay 只会把本地的边界问题复制到远程系统,推迟而不是解决数据一致性、
452
+ 权限、删除、重试和审计问题。
453
+
438
454
  ### 4.1 Relay 目标
439
455
 
440
456
  - SQLite 继续是每个本地 project 的 canonical store;
package/docs/SETUP.md CHANGED
@@ -85,7 +85,7 @@ What this does:
85
85
  - Codex: installs a user-level Personal marketplace plugin under `~/plugins/memorix`, attempts `codex plugin add memorix@personal`, and keeps project-local `.codex` configuration untouched. The plugin owns its MCP server, skills, and optional hooks without changing your model, approval, or sandbox settings.
86
86
  - GitHub Copilot CLI: installs a local plugin package and attempts `copilot plugin install <local-path>`.
87
87
  - Cursor: writes Cursor MCP config, rules, skills, and hook guidance.
88
- - Pi: installs the user-level Memorix Pi package and attempts `pi install <path> --approve`.
88
+ - Pi: installs the user-level Memorix Pi package, attempts `pi install <path> --approve`, and writes native MCP config to `~/.pi/agent/mcp.json` (Pi 1.0+). Project setup uses `.pi/packages/memorix` and `.pi/mcp.json`.
89
89
  - Gemini CLI: installs a local extension package under `~/.gemini/extensions/memorix` with MCP, `GEMINI.md`, hooks, commands, and skills. Antigravity CLI has an official Gemini CLI migration path, but Memorix keeps Gemini CLI as its own active standalone target.
90
90
  - OpenCode: installs a local plugin file, OpenCode skill, MCP config, and `AGENTS.md` guidance.
91
91
  - Antigravity: installs a native plugin under `~/.gemini/config/plugins/memorix` for global setup or `.agents/plugins/memorix` for workspace setup. The plugin bundles `plugin.json`, `mcp_config.json`, `hooks.json`, rules, and skills.
@@ -459,13 +459,13 @@ Project config: `.kiro/settings/mcp.json`
459
459
 
460
460
  ### Pi
461
461
 
462
- Pi uses its package system instead of a separate Memorix MCP config lane:
462
+ Requires [Pi 1.0+](https://github.com/earendil-works/pi/blob/v1.0.0/packages/coding-agent/docs/mcp.md). Setup installs both the extension/skills package and a native MCP server entry:
463
463
 
464
464
  ```bash
465
465
  memorix setup --agent pi --global
466
466
  ```
467
467
 
468
- This writes the user-level Memorix Pi package and registers it with:
468
+ This merges `mcpServers.memorix` into `~/.pi/agent/mcp.json`, preserving unrelated servers and settings. The default stdio entry runs `memorix serve --mode lite`. It also writes the user-level Memorix Pi package and registers it with:
469
469
 
470
470
  ```bash
471
471
  pi install ~/.pi/agent/packages/memorix --approve
@@ -477,7 +477,22 @@ Check the loaded package resources with:
477
477
  pi config --approve
478
478
  ```
479
479
 
480
- You should see the Memorix extension and the official Memorix skills listed under the Pi package.
480
+ You should see the Memorix extension and the shared official Memorix skills listed under the Pi package. Setup generates the same skills used by other supported agents; Pi does not maintain a separate skill set. Native MCP supplies the tools, and lifecycle capture comes from the extension.
481
+
482
+ For project-local setup, run `memorix setup --agent pi` from the project root. This writes `.pi/mcp.json` and installs `.pi/packages/memorix` with `pi install <path> -l --approve`. Pi must trust the project before it loads project-local MCP configuration.
483
+
484
+ For an explicitly shared HTTP control plane:
485
+
486
+ ```bash
487
+ memorix setup --agent pi --global --mcp http
488
+ memorix background start
489
+ ```
490
+
491
+ This writes `mcpServers.memorix.url = "http://localhost:3211/mcp"` instead of a stdio command. In HTTP mode, bind the active repository with `memorix_session_start(projectRoot=...)`.
492
+
493
+ Use `--mcp none` to skip MCP configuration. Existing MCP configuration is left untouched.
494
+
495
+ After setup, run `pi mcp list` to check connections, then `/reload` in Pi (or restart it). Use `/mcp` to inspect servers in a session. Pi exposes MCP tools through codemode by default; tool discovery is not evidence that the server is missing. Extensions such as `pi-mcp-adapter` that replace Pi's built-in `/mcp` also replace native config loading; use Pi's built-in MCP support for this setup.
481
496
 
482
497
  ### Gemini CLI, OpenCode, Antigravity, Trae, OpenClaw, Hermes Agent, Oh-my-Pi, and other MCP clients
483
498
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "memorix",
3
3
  "mcpName": "io.github.AVIDS2/memorix",
4
- "version": "1.10.2",
4
+ "version": "1.10.4",
5
5
  "description": "Local-first shared memory layer for AI coding agents across MCP clients, Git history, reasoning context, and project sessions.",
6
6
  "type": "module",
7
7
  "sideEffects": false,
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "memorix",
3
- "version": "1.10.2"
3
+ "version": "1.10.4"
4
4
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://anthropic.com/claude-code/plugin.schema.json",
3
3
  "name": "memorix",
4
- "version": "1.10.2",
4
+ "version": "1.10.4",
5
5
  "description": "Shared workspace memory for Claude Code and other AI coding agents.",
6
6
  "author": {
7
7
  "name": "AVIDS2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memorix",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "Local-first project memory for CodeBuddy Code and other coding agents.",
5
5
  "author": {
6
6
  "name": "AVIDS2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memorix",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "Shared workspace memory for Codex and other AI coding agents.",
5
5
  "author": {
6
6
  "name": "AVIDS2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memorix",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "Shared local workspace memory for GitHub Copilot CLI and other AI coding agents.",
5
5
  "author": {
6
6
  "name": "AVIDS2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memorix",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "mcpServers": {
5
5
  "memorix": {
6
6
  "command": "memorix",
@@ -1,5 +1,5 @@
1
1
  name: memorix
2
- version: "1.10.2"
2
+ version: "1.10.4"
3
3
  description: Shared workspace memory bridge for Hermes Agent.
4
4
  author: AVIDS2
5
5
  license: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memorix-omp-package",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "Memorix shared workspace memory package for Oh-my-Pi.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memorix",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "Shared workspace memory for OpenClaw and other AI coding agents.",
5
5
  "author": {
6
6
  "name": "AVIDS2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memorix-pi-package",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "Memorix shared workspace memory package for Pi coding agent.",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
package/server.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "https://github.com/AVIDS2/memorix",
8
8
  "source": "github"
9
9
  },
10
- "version": "1.10.2",
10
+ "version": "1.10.4",
11
11
  "websiteUrl": "https://mem.rglens.com",
12
12
  "icons": [
13
13
  {
@@ -22,7 +22,7 @@
22
22
  {
23
23
  "registryType": "npm",
24
24
  "identifier": "memorix",
25
- "version": "1.10.2",
25
+ "version": "1.10.4",
26
26
  "runtimeHint": "npx",
27
27
  "packageArguments": [
28
28
  {