memorix 1.10.3 → 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 (67) hide show
  1. package/CHANGELOG.md +62 -1
  2. package/dist/cli/index.js +1886 -1273
  3. package/dist/index.js +1724 -1088
  4. package/dist/{maintenance-jobs-DVRF-46r.d.ts → maintenance-jobs-DweoCoTT.d.ts} +25 -15
  5. package/dist/maintenance-runner.d.ts +1 -1
  6. package/dist/maintenance-runner.js +694 -172
  7. package/dist/media-audio-runner.js +685 -164
  8. package/dist/media-video-runner.js +693 -172
  9. package/dist/memcode-runtime/CHANGELOG.md +44 -1
  10. package/dist/sdk.js +13952 -13345
  11. package/dist/vector-backfill-runner.d.ts +1 -1
  12. package/dist/vector-backfill-runner.js +693 -172
  13. package/docs/ARCHITECTURE.md +219 -0
  14. package/docs/CONFIGURATION.md +15 -0
  15. package/docs/DESIGN_DECISIONS.md +37 -0
  16. package/docs/DEVELOPMENT.md +1 -1
  17. package/docs/MODULES.md +7 -1
  18. package/docs/PERFORMANCE.md +14 -0
  19. package/docs/README.md +1 -1
  20. package/docs/ROADMAP-1.9.12-2.0.md +18 -2
  21. package/package.json +1 -1
  22. package/plugins/antigravity/memorix/plugin.json +1 -1
  23. package/plugins/claude/memorix/.claude-plugin/plugin.json +1 -1
  24. package/plugins/codebuddy/memorix/.codebuddy-plugin/plugin.json +1 -1
  25. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  26. package/plugins/copilot/memorix/plugin.json +1 -1
  27. package/plugins/gemini/memorix/gemini-extension.json +1 -1
  28. package/plugins/hermes/memorix/plugin.yaml +1 -1
  29. package/plugins/omp/memorix/package.json +1 -1
  30. package/plugins/openclaw/memorix/.codex-plugin/plugin.json +1 -1
  31. package/plugins/pi/memorix/package.json +1 -1
  32. package/server.json +2 -2
  33. package/src/cli/tui/chat-service.ts +6 -9
  34. package/src/cli/tui/data.ts +2 -2
  35. package/src/codegraph/auto-context.ts +9 -2
  36. package/src/codegraph/derived-view.ts +63 -0
  37. package/src/compact/engine.ts +10 -33
  38. package/src/config/resolved-config.ts +11 -0
  39. package/src/config/retrieval-strategy.ts +22 -0
  40. package/src/config/toml-loader.ts +5 -0
  41. package/src/config/yaml-loader.ts +7 -0
  42. package/src/core/derived-view.ts +15 -0
  43. package/src/core/maintenance-result.ts +33 -0
  44. package/src/core/retrieval-contracts.ts +57 -0
  45. package/src/core/retrieval-facade.ts +18 -0
  46. package/src/core/retrieval-policy.ts +44 -0
  47. package/src/core/runtime-context.ts +42 -0
  48. package/src/embedding/api-provider.ts +18 -8
  49. package/src/knowledge/workset.ts +0 -2
  50. package/src/memory/consolidation.ts +3 -2
  51. package/src/memory/feedback-model.ts +1 -4
  52. package/src/memory/observations.ts +165 -87
  53. package/src/runtime/control-plane-maintenance.ts +1 -0
  54. package/src/runtime/isolated-maintenance.ts +1 -0
  55. package/src/runtime/maintenance-jobs.ts +123 -32
  56. package/src/runtime/project-maintenance.ts +69 -1
  57. package/src/sdk.ts +3 -2
  58. package/src/search/fts-view.ts +53 -0
  59. package/src/search/orama-view.ts +40 -0
  60. package/src/search/retrieval-facade.ts +38 -0
  61. package/src/search/semantic-index.ts +13 -0
  62. package/src/search/semantic-view.ts +34 -0
  63. package/src/server.ts +19 -7
  64. package/src/store/obs-store.ts +15 -0
  65. package/src/store/orama-store.ts +116 -42
  66. package/src/store/sqlite-db.ts +22 -0
  67. package/src/store/sqlite-store.ts +27 -0
@@ -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.
@@ -318,6 +318,21 @@ Provider values:
318
318
  - `transformers`
319
319
 
320
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.
321
336
  `transformers` is no longer installed by default; install
322
337
  `@huggingface/transformers` explicitly in the project or global prefix where
323
338
  Memorix runs if you choose that provider. `fastembed` remains a supported local
@@ -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.3** 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
 
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,7 @@ 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.3**; it includes the CodeGraph, lazy-vector,
130
+ The current product line is **1.10.4**; it includes the CodeGraph, lazy-vector,
131
131
  search-regression, browser-launch, and Runcrate updates on top of the LanceDB
132
132
  growth fix, derived-view receipts, and the optional Cheaper Inference preset.
133
133
  Multi-device store sync is opt-in and keeps local SQLite canonical; existing
@@ -47,7 +47,7 @@ Memorix 已经超过“给 coding agent 加一个记忆工具”的阶段。当
47
47
 
48
48
  ### 1.1 当前事实
49
49
 
50
- 当前发布基线是 `v1.10.3`。1.10.2 修复了 LanceDB 语义索引无限增长;本补丁继续修复 CodeGraph、lazy vector、搜索回归和 CJK 性能;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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "memorix",
3
3
  "mcpName": "io.github.AVIDS2/memorix",
4
- "version": "1.10.3",
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.3"
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.3",
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.3",
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.3",
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.3",
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.3",
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.3"
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.3",
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.3",
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.3",
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.3",
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.3",
25
+ "version": "1.10.4",
26
26
  "runtimeHint": "npx",
27
27
  "packageArguments": [
28
28
  {
@@ -5,7 +5,6 @@ import type { ChatMessage, ToolDefinition, ToolCall } from '../../llm/provider.j
5
5
  import { initObservations, prepareSearchIndex, storeObservation, resolveObservations, getObservation, getAllObservations } from '../../memory/observations.js';
6
6
  import { canManageObservation, filterReadableObservations } from '../../memory/visibility.js';
7
7
  import type { ObservationReader, ObservationType } from '../../types.js';
8
- import { getLastSearchMode } from '../../store/orama-store.js';
9
8
  import type { MemorixDocument } from '../../types.js';
10
9
  import { getTuiOperatorContext } from './operator-context.js';
11
10
 
@@ -211,6 +210,7 @@ interface ToolExecutionContext {
211
210
  reader: ObservationReader;
212
211
  writerAgentId?: string;
213
212
  collectedSources: ChatSource[];
213
+ searchMode?: string;
214
214
  }
215
215
 
216
216
  async function resolveTuiContext() {
@@ -225,6 +225,7 @@ function executeSearchMemories(args: { query: string; limit?: number }, ctx: Too
225
225
  const limit = Math.min(args.limit ?? SEARCH_LIMIT, 10);
226
226
  return compactSearch({ query: args.query, limit, projectId: ctx.projectId, status: 'active', reader: ctx.reader })
227
227
  .then((result) => {
228
+ ctx.searchMode = normalizeSearchMode(result.receipt.mode);
228
229
  const entries = result.entries.slice(0, DETAIL_LIMIT);
229
230
  if (entries.length === 0) return 'No memories found for that query.';
230
231
 
@@ -460,8 +461,6 @@ export async function askMemoryQuestion(
460
461
 
461
462
  await prepareProjectSearch(project.id, dataDir);
462
463
 
463
- const searchMode = normalizeSearchMode(getLastSearchMode(project.id) || 'fulltext');
464
-
465
464
  // LLM not configured — legacy fallback
466
465
  if (!isLLMEnabled()) {
467
466
  const searchResult = await compactSearch({
@@ -483,7 +482,7 @@ export async function askMemoryQuestion(
483
482
  answer: buildFallbackAnswer(trimmedQuestion, sources),
484
483
  sources,
485
484
  usedLLM: false,
486
- searchMode,
485
+ searchMode: normalizeSearchMode(searchResult.receipt.mode),
487
486
  warning: sources.length === 0 ? 'No relevant memories found.' : 'LLM not configured.',
488
487
  };
489
488
  }
@@ -565,7 +564,7 @@ export async function askMemoryQuestion(
565
564
  sources,
566
565
  usedLLM: true,
567
566
  llmModel: getLLMConfig()?.model,
568
- searchMode,
567
+ searchMode: ctx.searchMode ?? 'fulltext',
569
568
  toolCallsCount: totalToolCalls,
570
569
  };
571
570
  }
@@ -652,8 +651,6 @@ export async function askMemoryQuestionStream(
652
651
 
653
652
  await prepareProjectSearch(project.id, dataDir);
654
653
 
655
- const searchMode = normalizeSearchMode(getLastSearchMode(project.id) || 'fulltext');
656
-
657
654
  // LLM not configured — legacy fallback (no streaming possible)
658
655
  if (!isLLMEnabled()) {
659
656
  const searchResult = await compactSearch({
@@ -675,7 +672,7 @@ export async function askMemoryQuestionStream(
675
672
  answer: buildFallbackAnswer(trimmedQuestion, sources),
676
673
  sources,
677
674
  usedLLM: false,
678
- searchMode,
675
+ searchMode: normalizeSearchMode(searchResult.receipt.mode),
679
676
  warning: sources.length === 0 ? 'No relevant memories found.' : 'LLM not configured.',
680
677
  };
681
678
  }
@@ -757,7 +754,7 @@ export async function askMemoryQuestionStream(
757
754
  sources,
758
755
  usedLLM: true,
759
756
  llmModel: getLLMConfig()?.model,
760
- searchMode,
757
+ searchMode: ctx.searchMode ?? 'fulltext',
761
758
  toolCallsCount: totalToolCalls,
762
759
  };
763
760
  }
@@ -241,14 +241,14 @@ export async function getRecentMemories(limit = 8, projectId?: string): Promise<
241
241
 
242
242
  export async function searchMemories(query: string, limit = 10): Promise<SearchResult[]> {
243
243
  try {
244
- const { searchObservations } = await import('../../store/orama-store.js');
244
+ const { retrievalFacade } = await import('../../search/retrieval-facade.js');
245
245
  const { initObservations, prepareSearchIndex } = await import('../../memory/observations.js');
246
246
  const { project: proj, dataDir, reader } = await getTuiOperatorContext();
247
247
 
248
248
  await initObservations(dataDir);
249
249
  await prepareSearchIndex();
250
250
 
251
- const results = await searchObservations({ query, limit, projectId: proj.id, reader });
251
+ const results = (await retrievalFacade.search({ query, limit, projectId: proj.id, reader })).entries;
252
252
 
253
253
  const typeIcons: Record<string, string> = {
254
254
  gotcha: '!',
@@ -2,6 +2,7 @@ import { existsSync, statSync } from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { truncateToTokenBudget } from '../compact/token-budget.js';
4
4
  import { getResolvedConfig } from '../config/resolved-config.js';
5
+ import { createRuntimeContext } from '../core/runtime-context.js';
5
6
  import {
6
7
  buildTaskWorkset,
7
8
  type TaskWorkset,
@@ -229,9 +230,15 @@ export async function buildAutoProjectContext(input: {
229
230
  const lens = resolveTaskLens(task);
230
231
  const continuationRequested = input.continuation === 'always'
231
232
  || (input.continuation !== 'never' && isContinuationTask(task));
232
- const codegraphConfig = getResolvedConfig({ projectRoot: input.project.rootPath }).codegraph;
233
+ const runtime = createRuntimeContext({
234
+ projectId: input.project.id,
235
+ projectRoot: input.project.rootPath,
236
+ dataDir: input.dataDir,
237
+ config: getResolvedConfig({ projectRoot: input.project.rootPath }),
238
+ });
239
+ const codegraphConfig = runtime.config.codegraph;
233
240
  const refreshMode = input.refresh ?? codegraphConfig.autoRefresh ?? 'auto';
234
- const exclude = input.exclude ?? codegraphConfig.excludePatterns;
241
+ const exclude = input.exclude ?? (codegraphConfig.excludePatterns ? [...codegraphConfig.excludePatterns] : undefined);
235
242
  const maxFileBytes = input.maxFileBytes ?? codegraphConfig.maxFileBytes;
236
243
  const store = new CodeGraphStore();
237
244
  await store.init(input.dataDir);