dsh-cortex-memory 0.4.161 → 0.5.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 (39) hide show
  1. package/CHANGELOG.md +18 -2536
  2. package/README.md +86 -45
  3. package/bin/cortex.mjs +0 -0
  4. package/client.js +35 -17
  5. package/cordis.patch.yml +2 -5
  6. package/docs/compatibility.md +13 -18
  7. package/docs/install-windows.md +1 -1
  8. package/examples/README.md +1 -1
  9. package/index.js +44 -6
  10. package/package.json +3 -3
  11. package/scripts/check-embedding.mjs +129 -0
  12. package/src/core/config.js +31 -4
  13. package/src/core/feature-overrides.js +3 -1
  14. package/src/engines/compression.js +2 -0
  15. package/src/engines/consolidate.js +7 -2
  16. package/src/engines/graph.js +25 -8
  17. package/src/engines/health.js +22 -3
  18. package/src/engines/induct.js +5 -1
  19. package/src/engines/linear-rerank-model.js +180 -0
  20. package/src/engines/linear-rerank.js +110 -0
  21. package/src/engines/query-expansion.js +61 -0
  22. package/src/engines/retention.js +4 -1
  23. package/src/engines/retrieve.js +257 -28
  24. package/src/engines/source-weights.js +13 -0
  25. package/src/host/scheduler.js +43 -0
  26. package/src/memory/tokenizer.js +31 -1
  27. package/src/prompt/assemble.js +160 -131
  28. package/src/prompt/tiers.js +15 -4
  29. package/src/self/working.js +53 -10
  30. package/src/service/cortex.js +167 -35
  31. package/src/store/database.js +61 -0
  32. package/src/store/repositories/entities.js +26 -1
  33. package/src/store/repositories/facts.js +36 -1
  34. package/src/store/repositories/traces.js +114 -15
  35. package/src/store/schema.sql +13 -0
  36. package/src/tools/definitions.js +1492 -1274
  37. package/src/vector/index.js +79 -8
  38. package/bench/results/semantic-cn.json +0 -24
  39. package/docs/quota-compaction-design.md +0 -175
package/CHANGELOG.md CHANGED
@@ -1,2550 +1,32 @@
1
1
  # Changelog
2
2
 
3
- ## 0.4.160 — 2026-11-30
4
-
5
- (0.4.159 是本次发布的内部中间版,改动已并入本节。)
6
-
7
- 窗口第一次能被数出来:三处作者盲区的修正。
8
-
9
- ### Fixed
10
- - **`fit()` 的单位 bug**(`src/prompt/assemble.js`)。预算按 token 判断、截断按字符执行,
11
- 中文 1 字符≈0.625 token,所以 800 token 的「工作记忆」实际只给 800 字符≈500 token,
12
- 第 7 条被切在句子中间。现按 `estimateTokens` 的 1.6 反算:`truncate(text, budget * 1.6)`。
13
- - **尾注可能被挤掉**。`joinSections` 支持 `reserve` 段:「召回块是不可信历史数据」那条
14
- 即使预算满了也必须进——它是安全提醒,不是装饰。
15
-
16
- ### Changed
17
- - `workingBudget` 800 → 700(`src/core/config.js`)。fit 修好之后 800 是真 800 token,
18
- 工作记忆会独吞并挤掉「待处理意图」和尾注;700 实测总注入 ~1536/1600,八段全进。
19
-
20
- ### Added
21
- - **`cortex_window` 工具**:三句话看窗口——①库多大 ②每轮实际注入了什么(逐段 token、
22
- ✓/△/✗)③被裁掉了什么(准则 45→1、工作记忆 29→候选 20、票数 0/45)。
23
- 只读,用来替代「凭记忆猜自己」。
24
- - `assembleSystemPrompt` 返回值新增 `sections`(每段 title/tokens/kept/partial),
25
- `joinSections` 同步返回;原有 `text/used/truncated` 不变。
26
-
27
- ### Verified
28
- - `test/unit/prompt.test.js` 2/2 通过。
29
- - 线上 `cortex_window`:修复前 1577/1600 且「待处理意图/尾注」整段被丢;修复后
30
- 1536/1600 完整,八段全进。
31
-
32
- ### Added(同日第二轮:护栏白名单,经外部评审后收紧)
33
- - **`playbookPinned`**(`config.js` + `index.js` schema + `service/cortex.js` render 排序)。
34
- 投票只表达「有用」,表达不了「重要」:实测投完第一轮后,「中文/JSON 别用 PowerShell」
35
- (1 票,11-27)靠 `created_at` 把「用户划的线」(1 票,11-25)顶掉——红线从窗口消失。
36
- - **复核后修正**:原红线 241 字 ≈ 151 token,渲染整条约 210 token,占 playbook 预算 260 的 80%;
37
- pin 它 = 44 条全进不来。改为:旧红线 `retire`(全文仍在库可查),新建精简护栏
38
- `pbr_0mx1i711bdvj8et6x`(含来源 / 口径 / 授权兜底),白名单指向它,**护栏不投票**。
39
- - 白名单上限 20 → **3**(20 条等于没上限:只有第一条进得去,其余静默丢弃)。
40
- - `render` 的 `LIMIT 80` → **200**:原来 LIMIT 在 pin 之前执行,规则超 80 条时 pin 会静默失效。
41
- - `cortex_window` 增一行「⏵ 当前排第一」,让「注入了哪条准则」能被直接看见。
42
- - 线上验证:`cortex_window` 显示「当前排第一:[pbr_0mx1i1yl54ofuxwju] 护栏:自己处理,四类先问」,
43
- 准则注入 45 → 2(护栏 + 状态证据),43 条省略。
44
-
45
- ### Changed(同日第三轮:预算与截断)
46
- - `promptBudget` 1600 → **1800**;`playbookBudget` 从硬编码 260 → **可配,默认 420**。
47
- - 非白名单准则渲染时超 **80 字**截断,并附 `cortex_playbook get <id>` 全文指针;白名单护栏始终全文。
48
- - 修复 `cortex_window` 用硬编码 260 渲染、与注入实际用 420 不一致(仪表报「45→2」而实际注入了 3 条)。
49
- - 线上验证:**1703/1800 完整**,准则 45 → 3(护栏 + 状态证据 + mojibake 条),42 条省略,八段全进。
50
-
51
- ## 0.4.158-private — 2026-11-27
52
-
53
- External evidence can now actually reach the reflection gate.
54
-
55
- ### Added
56
- - **`external-evidence.jsonl` as a fourth evidence source.** `collectEvidence()` reads
57
- `dataRoot/external-evidence.jsonl` (override with `config.externalEvidenceFile`, `null` disables),
58
- filters by window and scope, skips bad lines, and stays silent when the file is absent.
59
- This is how failures that happen *outside* cortex — driver task failures, host crashes —
60
- become evidence the reflection gate can see.
61
- - Wired into all three call sites: the reflect job handler, `service.reflect`, and `service.evidence`.
62
- - `subbrain/evidence/to-cortex.mjs` writes that file: reads driver `ledger.jsonl` and `today.json`,
63
- normalises failed/timeout states, dedupes by id, dry-run by default, `--apply` to append.
64
- It is the only writer, and it never touches anything else.
65
-
66
- ### Verified
67
- - New `test/unit/evidence-external.test.js` (2 cases): in-window line is picked up; out-of-window
68
- line filtered; bad line skipped; missing file returns empty. Full suite 664/664.
69
- - Real run: current driver has no failed tasks → 0 signals, exit 0.
70
-
71
- ## 0.4.157-private — 2026-11-27
72
-
73
- The subbrain gets its own authorship slot.
74
-
75
- ### Added
76
- - **`author_kind = 'subbrain'`.** A trace is classified as subbrain-authored when
77
- `scopeId === 'subbrain'`, `source` starts with `subbrain:`, or `metadata.subbrain === true`.
78
- `cortex_write` accepts the value in its `authorKind` enum. This keeps the small-model's
79
- output from masquerading as either the agent's own writing (`self`) or a captured turn
80
- (`captured`) — which is exactly what the reflection gate needs in order not to let the
81
- subbrain issue itself a licence.
82
-
83
- ### Verified
84
- - `test/unit/author-kind.test.js` gains a subbrain case (5/5); full suite 662/662.
85
-
86
- ## 0.4.156-private — 2026-11-27
87
-
88
- Engineering mode, and a threat detector that stops mistaking technical talk for danger.
89
-
90
- ### Added
91
- - **`cortex_design`** (tool count 25): while ON, `coherence`/`safety` only rise and are floored
92
- (0.3 / 0.2), and `energy` is not drained by work turns. Runtime switch — a restart returns to
93
- `config.selfDesign.mode`. Config: `selfDesign: { mode, floorCoherence, floorSafety }`.
94
- - Floor-enforcement lives in `applyAppraisal`, so a state already flattened before the switch is
95
- lifted back above the floor on the next turn.
96
-
97
- ### Fixed
98
- - **Talking about safety was scored as being threatened.** `THREAT` included 隐私/密码/删除/清空/不许/停止,
99
- so a night of discussing deletion mechanics, credential boundaries and attack surfaces drove
100
- `safety` to 0. Those words are gone; a new `TOPIC` list (讨论/机制/设计/代码/架构/审计…) scales the
101
- remaining threat signal to 0.3 instead of zero, so "the code has an attack" still counts.
102
- - `applyMood` accepts `freezeEnergy`, separating emotional drain from work volume.
103
-
104
- ### Verified
105
- - New `test/unit/design-mode.test.js` (5 assertions across 4 tests); full suite 661/661.
106
- - Deployed smoke: 25 tools, config mode on, a technical turn leaves safety 0.70 / coherence 0.61 /
107
- energy 0.60 untouched.
108
-
109
- ### Notes
110
- - Rebuilt `package.json` from the 0.4.155 tarball after a PowerShell/UTF-8 round-trip corrupted it;
111
- both workspace and deployed copies re-validated as parseable JSON.
112
-
113
- ## 0.4.155-private — 2026-11-26
114
-
115
- Reflection now needs external evidence, and intentions are checked against what actually happened.
116
-
117
- ### Added
118
- - **Reflection hard trigger.** A manual reflection (`service.reflect`, `cortex_reflect`, `POST /reflect`)
119
- is refused with `no-external-evidence` unless something external justifies it: a correction
120
- (`feedback` signal `incorrect`/`corrected`, or a trace flagged `metadata.correction`), a failed
121
- job, or a commitment judged deviated with evidence. Scheduled consolidation (sleep, autonomy
122
- tick, backfill) is explicitly exempt — those pass `trigger: 'auto'` / `'backfill'`.
123
- A forced reflection is still allowed and the trace records `metadata.evidenceForced`.
124
- Switch: `config.selfWrite.reflectionRequiresEvidence = false`.
125
- - **`cortex_intention`** — intent–result alignment. `claim` records what I said I would do;
126
- `observe` records what actually happened plus the evidence. Nothing new in the schema: the
127
- claim lives in `intentions.payload_json`, the actual + evidence + verdict in `result_json`.
128
- - `src/self/evidence.js` collects the three evidence classes (correction / failure / opposition)
129
- for a window; it only reads.
130
-
131
- ### Notes
132
- - Engine default trigger is `auto`; the gate sits at the manual boundary, so internal
133
- consolidation paths and direct engine callers are unaffected.
134
-
135
- ## 0.4.154-private — 2026-11-26
136
-
137
- Every trace can now say who wrote it — and self-writes are marked unconfirmed.
138
-
139
- ### Added
140
- - **`author_kind` / `author_id` / `author_confidence`** on `traces`. Four kinds:
141
- `captured` (a turn was captured), `self` (written by the agent: reflection, agency:inner,
142
- policy, config, actor self/system), `imported` (shiori / import), `derived` (extractor).
143
- Existing databases get the columns through `ensureTraceColumns()`; old rows default to
144
- `captured` and nothing breaks.
145
- - **Pending marker for self-writes.** `author_kind = 'self'` traces carry
146
- `metadata.pending = true` + `pendingSince`. No side table, no state machine — just a flag the
147
- host or the user can act on. Switch: `config.features.pendingSelfWrites = false`.
148
- - **`scripts/backfill-author.mjs`** — dry-run by default, `--apply` to write, single transaction,
149
- classification kept identical to the write path.
150
- - `cortex_audit` now reports the author distribution and how many self-writes are still pending.
151
-
152
- ### Deliberately not done
153
- - Author fields **do not participate in retrieval scoring yet**. The point of this release is
154
- clean data first; weights and a separate self-authored RRF channel come after an observation
155
- window.
156
-
157
- ### Verified
158
- - New `test/unit/author-kind.test.js` (4 cases) covering user capture, self write + pending,
159
- reflection-from-user-turn → self, extractor → derived, shiori import → imported, explicit
160
- override, the switch, and audit visibility.
161
- - Unit + integration: **653/653**, both in the workspace checkout and in the deployed copy.
162
- - Live data: 3093 rows classified to `captured 2796 · self 240 · imported 57`.
163
-
164
- ### Fixed
165
- - Audit aliasing bug: `AS kind` collided with the `kind` column, so the author/stability
166
- buckets were grouped by trace kind instead of by their own value.
167
-
168
- ## 0.4.153-private — 2026-11-26
169
-
170
- The DSR initial-stability layer existed but was never wired; every memory started at 1 day.
171
-
172
- ### Fixed
173
- - **`initialStability()` had zero call sites.** `TYPE_BASE_STABILITY` (identity 3650 days /
174
- working 0.25 days) was dead weight: 3090 of 3091 live traces had `stability = 1`, so a
175
- promise decayed exactly as fast as small talk. `createEncodeEngine` now computes the initial
176
- value from kind/importance/salience/confidence/valence and passes it to `traces.insert`.
177
- Switch: `config.dsr.initialStability = false` restores the old behaviour without touching data.
178
- - **Store kinds had no DSR type.** Without a map, `promise` fell back to the episodic base
179
- (2.5 days). New `DSR_TYPE_BY_KIND` / `dsrTypeForKind()`: identity → identity, promise /
180
- decision / preference / instruction / milestone → semantic, reflection → reflective,
181
- skill → procedural, utterance / observation / emotion / task / plan → episodic.
182
- - **`source` was a copy of `actor`.** `input.source || input.actor` made 20% of live rows
183
- (`628/3091`) carry `source = actor`; it is now `input.source ?? null`. Explicit sources
184
- (`host:turn`, `extractor`, `cortex:llm`, scheduler) are unaffected.
185
-
186
- ### Added
187
- - **`cortex_audit`** — read-only audit: facts past `valid_to` still active, same-subject
188
- multiple active values, open disputes, zombie traces never recalled, DSR archive candidates,
189
- orphan traces, stability distribution. SELECT only; never writes.
190
- - **`scripts/backfill-stability.mjs`** — dry-run by default, `--apply` to write. Only rows with
191
- `stability = 1`, single transaction, appends one `audit` row, never touches `content` or the
192
- event hash chain.
193
-
194
- ### Verified
195
- - Unit + integration: **649/649**. The 11 long-standing red tests were stale expectations, not
196
- regressions, and are now aligned: alias already prints 「你」 not 「用户」, `cortex_inhibition`
197
- was missing from the registry list, reflect wording changed, health reports an LLM-off warn.
198
- - Live data: 3090 rows backfilled, `stability` distribution `=1 × 3090` →
199
- `<7d 2495 · 7–30d 254 · ≥30d 342`. Snapshot backups kept before both steps.
200
-
201
- ### Notes
202
- - `sourceReliability` still defaults to 1 (no reliability source yet) — wire it once
203
- `author_confidence` exists.
204
- - `src/host/scheduler.js` reads `event.source`, but `events` has no such column (the value lives
205
- in `payload_json`). Suspected wrong field; left for the next batch.
206
-
207
- ## 0.4.145 — 2026-11-18
208
-
209
- The speaker prefix hid the quote marker from the stripper.
210
-
211
- ### Fixed
212
- - **"用户:> …" lost only half of its decoration.** The content was `用户:> 要彻底跟时间走…`:
213
- the stripper saw a leading `用户:`, not a `> `, so after the prefix came off the quote
214
- marker stayed and both the topic and the last clause began with "> ". A single
215
- `stripDecoration()` pass now removes speaker prefix and quote marker together, looping
216
- until stable (max three passes).
217
-
218
- ### Verified
219
- - Unit: 520/520, twice. New: "用户:> " is stripped in either order.
220
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
221
-
222
-
223
- ## 0.4.144 — 2026-11-18
224
-
225
- The quoted seed topic still came from the captured title.
226
-
227
- ### Fixed
228
- - **The seed topic reads content too.** `cleanTitle(seed.title || …)` still preferred the
229
- 40-char captured title, so a topic ended mid-sentence ("…我顺着review的线索挖"). It now
230
- takes `seed.content` first (quote marker and speaker prefix stripped), cuts at 60 chars on a
231
- punctuation boundary, and only falls back to the title when content is empty.
232
- - Carries 0.4.143's fix: the "> " quote marker is stripped from both body clauses and the
233
- seed topic.
234
-
235
- ### Verified
236
- - Unit: 519/519, twice. Assertion updated: the seed topic carries the whole sentence.
237
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
238
-
239
-
240
- ## 0.4.143 — 2026-11-18
241
-
242
- A quoted turn left a "> " marker in the paragraph topic.
243
-
244
- ### Fixed
245
- - **The quote marker is stripped from thread text and the seed topic.** A turn captured from
246
- a quoted reply read as 「一段关于「> (…)…」的经历」; `clean()` and `cleanTitle()` now
247
- drop a leading "> " before the speaker prefix, so it never reaches the paragraph.
248
-
249
- ### Verified
250
- - Unit: 519/519, twice. New assertion: no "> " in thread content.
251
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
252
-
253
-
254
- ## 0.4.142 — 2026-11-18
255
-
256
- The paragraphs were still cutting capture's 40-char titles in half.
257
-
258
- ### Fixed
259
- - **Thread text reads `content`, not `title`.** Capture stores a short title that stops
260
- mid-parenthesis ("…验收(工具名:desk") while the content holds the whole turn, so the
261
- paragraph kept a stump even after the sentence-splitting fix. `clean()` now takes the
262
- content first, strips capture's "用户:/助手:" speaker prefix, and falls back to the title.
263
- The 90-char truncation lands on a punctuation boundary and never inside an open bracket.
264
-
265
- ### Verified
266
- - Unit: 519/519, twice. Assertions updated to the content-based text; new coverage: speaker
267
- prefix stripping and unclosed-bracket trimming.
268
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
269
-
270
-
271
- ## 0.4.141 — 2026-11-18
272
-
273
- Thread paragraphs: the last three rough edges seen in the live sample.
274
-
275
- ### Fixed
276
- - **Long titles are cut at punctuation, not mid-bracket.** `truncate(90)` produced tails like
277
- "…验收(工具名:desk". The cut now drops an unclosed bracket tail first, then falls back to
278
- the last ,;。:、 inside the budget.
279
- - **Markdown emphasis is stripped from thread text and from the seed topic.** `**…**` and
280
- backticks no longer leak into the paragraph or the quoted seed title.
281
- - **A sentence ending in an English dot is no longer treated as a fragment.** `clean()` keeps
282
- the dot it split at, while the fragment filter rejected every `/\.$/` — so a complete
283
- sentence like "项目观察日志." was dropped. The dot rule now only catches digit-dot stumps
284
- ("dsh-cortex 0.").
285
-
286
- ### Verified
287
- - Unit: 519/519, twice. New coverage: punctuation-safe truncation, markdown stripping, and an
288
- English-dot sentence surviving.
289
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
290
-
291
-
292
- ## 0.4.140 — 2026-11-18
293
-
294
- Thread paragraphs were cutting version numbers in half.
295
-
296
- ### Fixed
297
- - **`sentence()` treated the dot in "0.4.139" as a full stop**, so every paragraph came out
298
- as a column of stumps ("20:49:dsh-cortex 0.;接着,21:05 0.;…"). The narrative engine now
299
- splits sentences with `[。!?!?]|\.(?![0-9])` — a dot only ends a sentence when it is not
300
- followed by a digit — and truncates at 90 chars instead of 60.
301
- - **Stump fragments are dropped from the paragraph**: entries ending in a bare digit-dot or
302
- an open bracket ("dsh-cortex 0.", "(尾巴一摆)…") no longer become beats in the story.
303
- Short human titles ("两天前") are kept.
304
-
305
- ### Verified
306
- - Unit: 517/517, twice. New coverage: version numbers survive; paragraph shape; short titles
307
- are not treated as fragments.
308
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
309
-
310
-
311
- ## 0.4.139 — 2026-11-18
312
-
313
- Four polish items: threads read like a paragraph, the deep pass sees the whole store, the
314
- extractor stops quoting and commanding, and backfill samples 80% of a window.
315
-
316
- ### Changed
317
- - **Threads are written as one flowing paragraph**, not a bullet dump. The date is stated
318
- once in the opener ("11月18日,…") and the clauses are joined with 接着 / 后来 / 最后, so a
319
- thread is something you read back instead of a list you scan.
320
- - **The daily deep pass spreads across importance bands.** Ranking from the low end put all
321
- 60 candidates at importance 0.7 (the next untouched band); `spread: true` takes half from
322
- the low end and samples the rest evenly, so one pass sees the store's shape.
323
- - **Backfill samples 80% of each window (the 0.4.129 policy).** 24 of 40 left a structural
324
- 40% of every window uncovered; it is now 32 of 40, and no extra windows are needed to
325
- raise that ceiling.
326
-
327
- ### Fixed
328
- - **The rule extractor ignores quoted speech and imperatives.** 「他说:「小明喜欢白猫」」no
329
- longer produces `likes(小明 → 白猫)` about the speaker, and instructions ("记得把桥修好")
330
- no longer produce facts.
331
-
332
- ### Verified
333
- - Unit: 516/516, twice. New coverage: paragraph shape, spread sampling, quoted/imperative
334
- filtering, and the 80% backfill budget.
335
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
336
-
337
-
338
- ## 0.4.138 — 2026-11-18
339
-
340
- The last truncation edge in the narrative pool.
341
-
342
- ### Fixed
343
- - **The 24h pass no longer caps at 300 rows.** A busy day already reaches ~320 active traces
344
- in 24h (the production store: 315), so `around(24h)` with `limit 300` silently dropped the newest
345
- neighbours — exactly the ones a thread about "tonight" needs. Each pass now carries
346
- headroom above its own traffic: 24h → 600 rows, 72h → 1200, 7 days → 2000.
347
- - Live check after 0.4.137: the first two threads woven at 14:04:10 UTC had bullets from
348
- 18:0x–21:14 of the same evening and none of the 11-12/11-13 residue (`coverage 8/297`).
349
-
350
- ### Verified
351
- - Unit: 514/514, twice. New regression test: 400 traces inside 24h with the seed last — the
352
- newest neighbour must still make the line.
353
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
354
-
355
-
356
- ## 0.4.137 — 2026-11-18
357
-
358
- The threads were reading last week's diary because of a pool bug, not the scoring.
359
-
360
- ### Fixed
361
- - **`buildThread` queries the seed's own time range instead of "the first N traces since
362
- epoch".** `traces.listSince()` walks forward from its start and stops at `limit`; with a
363
- store older than the limit, the pool for a tonight-seed was the 300 oldest active traces
364
- (11-11 → 11-13), so the 24h window found nothing, the 72h window found nothing, and every
365
- thread fell through to the 7-day fallback — which held that same old residue. That is why
366
- 0.4.136's hardening still produced threads full of "2026-11-12 …" bullets: the data source
367
- was truncated, not the ranking. `traces.range()` now queries `recorded_at` bounds directly,
368
- and the widest fallback allows 2000 rows so it is not truncated again.
369
- - Live evidence before the fix: `listSince('2026-11-11', limit 300)` ended at
370
- `2026-11-13T09:15Z`, while the store had 1437 active traces through 11-18.
371
-
372
- ### Verified
373
- - Unit: 513/513, twice. New regression test: 310 old traces plus a tonight seed — the nearby
374
- traces must win and the old ones must stay out of the line.
375
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
376
-
377
-
378
- ## 0.4.136 — 2026-11-18
379
-
380
- Narrative threads now follow the clock instead of importance.
381
-
382
- ### Changed
383
- - **`buildThread` uses a hard time window.** It used to rank every trace from the last 7 days
384
- by `importance*0.35 + recency*0.3 + tags*0.2 + content*0.15`, so a 1.0 identity trace from
385
- last week could still crowd the seed's neighbours out of the line. A thread is "what
386
- happened around this moment", not "the heaviest things I remember": candidates now come
387
- from `seed ± windowHours` (default 24h), widening to 72h and finally the whole 7-day pool
388
- only when the window holds fewer than two other traces (a silent night still gets a line).
389
- - The scoring formula is unchanged — with a bounded pool its only job is "which of these
390
- neighbours is most relevant", which it does fine.
391
- - `windowHours` is configurable via `threadWindowHours` (maintain path and the same key on
392
- the sleep path); the returned summary records the window it actually used. Existing
393
- threads are not rewritten.
394
-
395
- ### Verified
396
- - Unit: 512/512, twice. New coverage: nearby traces win over far-away high-importance ones;
397
- the widening fallback still produces a line when the neighbourhood is quiet.
398
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
399
-
400
-
401
- ## 0.4.135 — 2026-11-18
402
-
403
- The four optimizations agreed after 0.4.134.
404
-
405
- ### Added
406
- - **A daily deep consolidation pass.** Once a day, after `deepConsolidateHour` (local, default
407
- 4am), the scheduler runs one wider pass (`deepConsolidateLimit`, default 60 rows) with
408
- `caller: 'deep-daily'`. The 30-minute delta trigger stays; this is the "one proper
409
- housekeeping a day" pass. A mid-day restart does not repeat it — the audit row records the
410
- caller. Disable with `deepConsolidateOnSchedule: false`.
411
- - **Health shows today's housekeeping**: `consolidation.today` = `{ runs, archived, merged }`
412
- since local midnight, rendered as "今日整理:N 趟 · 归档 X 条 · 合并 Y 条". A pass that
413
- changed nothing is not counted as a run, so the number answers "did memory get tidier today".
414
-
415
- ### Changed
416
- - **Narrative seeds are picked by recency, not importance.** Sorting by importance kept
417
- threading the same old identity traces, so every thread read like "about the build" or
418
- "about the promise". The line now follows what actually happened lately.
419
- - **The rule extractor ignores design discussions.** Pasted drafts and plan posts
420
- ("新坑 3:…", "设计草案:…", "待办:…") talk about what might happen, not what did; they no
421
- longer produce fact rows.
422
-
423
- ### Verified
424
- - Unit: 510/510, twice. New coverage: deep-pass timing / once-a-day / limit / disable, today
425
- counters, recency seeding, discussion-text filtering.
426
- - Integration: 115/126, unchanged — the same 11 pre-existing environment failures.
427
-
428
-
429
- ## 0.4.134 — 2026-11-18
430
-
431
- The two retention/coverage gaps recorded during the 0.4.131 self-review.
432
-
433
- ### Fixed
434
- - **Narrative threads have a retention cap.** Threads were rebuilt from recurring topics every
435
- 6h (and immediately after every restart, since the timer is in-process), so `summaries` grew
436
- without bound — 5 threads in one evening for essentially two topics. `weave()` now keeps the
437
- newest `maxTotal` (default 24) and drops the oldest tail (`pruneThreads`).
438
- - **Thread bullets no longer repeat the date.** Trace titles often start with their own date,
439
- so lines read "2026-11-12 2026-11-12 上午…". The prefix is omitted when the text already
440
- starts with it.
441
- - **Dedupe samples the whole distribution.** Taking only the lowest-importance 80 rows meant a
442
- duplicate pair in the middle of the store was never seen. Candidates are now half from the
443
- low end and half evenly sampled across the rest (window 80 → 160).
444
-
445
- ### Verified
446
- - Unit: 501/501, twice. New coverage: date prefix, thread cap, dedupe sampling across
447
- importance.
448
- - Integration: 115/126, unchanged — same 11 pre-existing environment failures.
449
- - Live check after 0.4.133: the first applied consolidation. 11 traces merged (one 10-way
450
- merge of repeated-delivery receipts plus two pairs), `summaries.level='merge'` 0 → 3,
451
- active 1441 → 1430. A preview no longer blocks the real pass; the model produced correct
452
- multi-id merge shapes.
453
-
454
-
455
- ## 0.4.133 — 2026-11-18
456
-
457
- Two idempotence-gate holes found by self-review right after 0.4.132 shipped.
458
-
459
- ### Fixed
460
- - **A `skipped` row only blocks a retry while there is no adapter.** 0.4.132 made
461
- `skipped` / `preview` / `rejected` all pass the gate, which would have brought back the
462
- 0.4.130 noise ("no-llm" row on every tick). The gate now distinguishes: without an adapter
463
- an identical skipped row is reused; with an adapter a skipped row may retry. `applied` and
464
- `degraded` (a real answer) are still reused; `preview` and `rejected` always pass.
465
- - **`dedupe`'s idempotence gate ignores preview rows too.** It read the latest
466
- `model='dedupe'` row without filtering `preview`, so a rehearsal blocked the real dedupe
467
- pass on the identical decision set.
468
-
469
- ### Verified
470
- - Unit: 498/498, twice. New coverage: a skipped row written without an LLM does not block a
471
- later real run (verified across two store instances); a dedupe preview does not block the
472
- real dedupe pass.
473
- - Integration: 115/126, unchanged — the same 11 pre-existing environment failures.
474
-
475
-
476
- ## 0.4.132 — 2026-11-18
477
-
478
- Closes the four gaps 0.4.131 exposed on its first day in the production store.
479
-
480
- ### Fixed
481
- - **A dry run is recorded as `preview`, not `degraded`/`applied`.** 0.4.131 made preview rows
482
- stop counting as "asked", but `consolidation.run({ dryRun: true })` still wrote a real
483
- status, so that half of the fix never fired. A rehearsal no longer pushes its batch out of
484
- the next real pass, and the idempotence gate lets the same batch through afterwards.
485
- - **`health` ignores preview rows** when reporting "the last consolidation", so a rehearsal
486
- cannot masquerade as a real pass.
487
- - **The consolidation prompt spells out merge shape**: `ids` must contain at least two traces,
488
- `targetId` must be one of them, and a one-id merge is rejected. The live model kept
489
- answering `merge` with a single id (6 times in one run) and the validator correctly refused
490
- it — the fix belongs in the instruction, not in the validator.
491
- - **Dedupe ranks candidates lowest-importance first.** Near-duplicates cluster at the low end
492
- (one-off acknowledgements, repeated-delivery receipts) and the old importance-descending
493
- order never reached them inside the 80-row window. Merge targets are still the most
494
- informative copy.
495
-
496
- ### Verified
497
- - Unit: 496/496, twice. New coverage: a preview does not occupy the next batch, merge prompt
498
- rules, dedupe candidate order.
499
- - Integration: 115/126; one stale assertion fixed (`no-llm` → `no-llm-adapter`), the remaining
500
- 11 failures are the same environment failures present on 0.4.130.
501
-
502
-
503
- ## 0.4.131 — 2026-11-18
504
-
505
- Consolidation stops asking the one question it can never answer differently.
506
-
507
- ### Fixed
508
- - **Candidate selection ranks the other end of the store.** 0.4.116→0.4.130 sorted active
509
- traces by importance descending, so every run handed the model the batch its own prompt
510
- protects (99% of the production store is >= 0.7 and the top slice is all 1.0) and the only
511
- possible answer was keep. Candidates now rank: no summary cites the trace yet → not shown
512
- to the model in the last 24h → lowest importance, oldest first. Asked traces sink instead
513
- of disappearing, so a fully asked pool rotates back over the stale end.
514
- - **The protection line is one fixed threshold again (0.9).** A percentile of a
515
- self-selected top slice always equals the batch maximum; the line covered every candidate.
516
- >= 0.9 is protected from archive/merge, 0.7–0.9 may merge, < 0.7 may archive.
517
- - **The idempotence gate covers every status, not just `skipped`.** An applied run whose
518
- decisions were all keep used to burn a fresh LLM call every 30 minutes on an identical
519
- input. A rejected batch is still retried — that was the model's own bad output.
520
- - **`health` compares FTS rows per scope.** It counted the global traces against the whole
521
- FTS index, so any second scope (`agency` in the production store) produced a permanent FTS_DRIFT
522
- warning for exactly those rows.
523
- - **`maintain()` no longer closes a dispute while both facts are `disputed`.** `disputed` is
524
- not "not active"; the old condition resolved the dispute and left the facts unqueryable
525
- forever. Disputes closed by older versions leave orphan `disputed` facts; those are now
526
- invalidated on the next maintain pass (`report.orphanDisputes`).
527
- - **The rule extractor does not turn questions or conditionals into facts.** "你会有感觉吗"
528
- became will(助手 → 有感觉吗) and "要是想聊两句" became is(要 → 想聊两句). Questions (?/?
529
- or a final 吗/呢/吧) and if-clauses (要是/如果/假如/万一/倘若/若) are skipped; a
530
- single-character subject is only allowed for pronouns and address words.
531
-
532
- ### Added
533
- - **Narrative threads are actually woven.** `narrative.weave()` existed but nothing called
534
- it, so `summaries` never held a level='thread' row. `maintain()` weaves up to two threads
535
- every six hours (config `narrativeWeaveGapHours`); `life.sleep()` weaves as part of its
536
- report (`narrative` field).
537
- - **Dedupe runs on a schedule** every six hours (config `dedupeGapHours`, `dedupeLimit`;
538
- `dedupeOnSchedule: false` disables it), so the merge layer no longer stays empty until
539
- someone asks by hand.
540
-
541
- ### Verified
542
- - Unit: 493/493, twice. Integration: 114/126 pass; the 12 failures are the same pre-existing
543
- environment failures as 0.4.130 (tool registry count, persona default, journey fixtures).
544
- - New coverage: selection order, idempotence across statuses, rejected retry, FTS per scope,
545
- question/conditional extraction, orphan disputes, weave in maintain and sleep, scheduled
546
- dedupe.
547
-
548
-
549
- ## 0.4.130 — 2026-11-16
550
-
551
- Housekeeping release: closes the four P3 items that were deliberately deferred during
552
- the 0.4.116→0.4.128 chain. No new features.
553
-
554
- ### Fixed
555
- - **Consolidation and dedupe see 500 active traces, not 200.** The old pool silently hid
556
- anything older than the newest 200; the LLM still receives at most `limit` rows.
557
- - **`dedupe` has the same idempotence gate as `run()`.** Re-preparing an identical decision
558
- set returns `skipped: 'unchanged'` instead of appending another dream_runs row + audit
559
- on every call (`force: true` overrides).
560
- - The `invalid-json` branch now records `groups` / `groupsDropped` like every other exit.
561
- - `cortex_consolidate action: "run"` refuses a non-dry run on a read-only scope (dedupe
562
- already did).
563
-
564
- ### Verified
565
- - Tests: invalid-json carries group counts; identical dedupe runs report `unchanged`.
566
- Suite: 477/477, twice.
567
-
568
-
569
- ## 0.4.128 — 2026-11-16
570
-
571
- ### Fixed (accounting only; no behaviour change to backfill)
572
- - The tool schema's `maxWindows` still said `maximum: 20` while the engine allowed 64.
573
- Both are 64 now; 0.4.127's "20 → 64" note is corrected to "engine 64 / tool 64".
574
- - `already-reflected` skip rows now also carry `matchedEpisodes` (how many episodes
575
- contributed to the union coverage), alongside `coveredRatio`.
576
-
577
- ### Live state after the 21-window backfill
578
- - episodes 26 (5 old + 21 backfilled), union coverage 507/855 = 59.3%.
579
- - The remaining 348 uncovered traces are the structural remainder of sampling 24 of every
580
- 40 traces (21 × 16) plus the 3-trace tail: **60% is this sampler's ceiling**, not a
581
- threshold problem. Raising it means changing the per-window source budget (0.4.129,
582
- a policy choice), not more windows.
583
-
584
- ### Verified
585
- - Suite: 475/475, twice.
586
-
587
-
588
- ## 0.4.127 — 2026-11-16
589
-
590
- ### Fixed
591
- - **Backfill can resume from a cursor.** Every call restarted at epoch, so a second batch
592
- spent its whole `maxWindows` quota re-walking already-written windows and could never
593
- reach the tail — 851 non-reflection traces exceed 20 windows × 40. `backfillEpisodes`
594
- now accepts `since` (the previous batch's `until`), the tool exposes it, and the ceiling
595
- is raised to 64.
596
- - **Same-millisecond windows made the 0.5 coverage bar fragile.** The production store's first
597
- window contains 51 traces sharing one timestamp (bulk import) while reflect samples 24,
598
- so coverage = 24/51 ≈ 0.47 — below the bar, meaning a re-run would write a duplicate.
599
- Resume (`since`) removes that path; the coverage bar stays as a second guard.
600
-
601
- ### Verified
602
- - Live: first real segment written (`period 2026-11-11T03:31:26.778Z`, 584 chars,
603
- 24 sourceIds, active 961→962, episodes 5→6), backup taken first.
604
- - Tests: new resume test (batch 2 continues from batch 1's `until`; re-running the same
605
- `since` writes nothing). Suite: 475/475, twice.
606
-
607
-
608
- ## 0.4.126 — 2026-11-16
609
-
610
- ### Fixed
611
- - **The stale comment 0.4.125 said it removed is actually gone now.** 0.4.125 added the
612
- correct "threshold 0.5" note but left the old "covers >=80% … (50% would skip a
613
- half-covered stretch)" paragraph above it, so the function still contradicted itself.
614
- This release deletes the old lines (verified: no `>=80%` left in the file).
615
- - Skip diagnostics now include `coveredRatio` (e.g. `skipped: already-reflected,
616
- coveredRatio: 0.62`), so a preview can be explained without guessing which episode
617
- accepted the window.
618
-
619
- ### Verified
620
- - Suite: 474/474, twice; `reflect.js` syntax clean and no stale threshold text remains.
621
-
622
-
623
- ## 0.4.125 — 2026-11-16
624
-
625
- ### Fixed
626
- - **The comment claimed a threshold the code did not use.** It said "≥80% of its trace ids
627
- (50% would skip a half-covered stretch)", while the code compared against 0.5. The
628
- comment now states 0.5 and explains why: reflect samples ~60% of a window (24/40), so a
629
- fully reflected window scores ~0.6 and an 0.8 bar would never fire.
630
- - **Coverage uses the union of all episode sources.** It was per-episode (`find`), so a
631
- window split between two episodes (30% + 30%) was judged "not written" and rebuilt. The
632
- union of every episode's `sourceIds` is computed once per window; the exact
633
- `findPeriod` check still runs first.
634
-
635
- ### Verified
636
- - Suite: 474/474, twice; backfill tests unchanged and green.
637
-
638
-
639
- ## 0.4.124 — 2026-11-16
640
-
641
- ### Fixed
642
- - **Idempotency is measured in traces, not wall-clock time.** 0.4.123 compared period
643
- spans, but the first window starts at 1970 (a 56-year span), so a summary covering
644
- recent traces could look <50% on the timeline and get re-written. A window now counts
645
- as already reflected when an episode's `sourceIds` cover ≥50% of the window's trace ids
646
- (reflect samples ~60% of a window, so a fully reflected one scores ~0.6; a 0.8 bar would
647
- never fire). `force: true` still rewrites.
648
- - The `maxWindows` schema description said "默认 3" while the code used 8.
649
-
650
- ### Note
651
- - The earlier time-overlap approach could also *over*-skip: a summary covering half the
652
- wall-clock span but few traces would block a window whose traces were never captured.
653
- Trace ids do not have that failure mode.
654
-
655
- ### Verified
656
- - Backfill tests use distinct trace texts so sampling spreads (near-identical seeds made
657
- reflect keep a single source, which hid the effect). Suite: 474/474, twice.
658
-
659
-
660
- ## 0.4.123 — 2026-11-16
661
-
662
- ### Fixed
663
- - **Backfill idempotency now accepts overlap, not just equality.** Re-walking the same
664
- stretch with a different `windowSize` (40 → 32) produced different period boundaries and
665
- therefore a second overlapping episode — declared coverage would inflate while the store
666
- said "covered". A window is now skipped as `already-reflected` when an existing episode
667
- covers ≥50% of it; `force: true` still rewrites.
668
- - The backfill tool's `maxWindows` default is 8 (was 3), so reaching 24 windows no longer
669
- silently needs eight calls with the default.
670
-
671
- ### Verified
672
- - Tests: re-running with a different window size skips the overlapping windows and adds at
673
- most the genuinely new tail; boundary-millisecond traces still group; 473→474 suite
674
- passes, twice.
675
-
676
-
677
- ## 0.4.122 — 2026-11-16
678
-
679
- ### Fixed
680
- - **Backfill is idempotent by default.** It passed `force: true` unconditionally, so
681
- re-running the same window wrote a second episode. Each window now consults
682
- `summaries.findPeriod()` first and reports `already-reflected`; `force: true` is only
683
- for "the window genuinely changed, recompute".
684
- - **Same-millisecond boundaries are no longer dropped.** `until` used `last + 1ms`, so if
685
- several traces shared the boundary millisecond, the rest fell forever between windows
686
- (the next window starts at `>=` that timestamp). The window now extends to include every
687
- trace with the boundary timestamp and ends at the *next* distinct timestamp.
688
- - The tool's span text tolerates a trailing `{ skipped: 'not-enough-traces' }` entry
689
- (it has no `since`/`until`) instead of printing `—`.
690
-
691
- ### Note
692
- - The 3.4K-char summary budget concern does not apply to this path: episode summaries are
693
- extractive (no LLM call), so there is no `maxTokens` to exhaust here.
694
-
695
- ### Verified
696
- - Tests: a second identical run adds zero summaries and reports `already-reflected`;
697
- three traces sharing the boundary millisecond all land in the same window. Suite:
698
- 473/473, twice.
699
-
700
-
701
- ## 0.4.121 — 2026-11-16
702
-
703
- ### Added
704
- - **Timeline backfill for episode summaries.** Declared coverage was 3.4% because only
705
- five episodes existed; `reflect.backfillEpisodes()` now walks the timeline in windows of
706
- 32–60 traces (default 40, clamped) and writes one episode per window, with `until` as an
707
- exclusive end so one episode cannot swallow the whole history. Exposed as
708
- `cortex_consolidate action: "backfill"` with `dryRun` defaulting to true; each window's
709
- `sourceIds` stays within the existing 24-source budget (`maxSources` clamp 1–40 is
710
- respected by construction).
711
-
712
- ### Verified on the production store (read-only copy)
713
- - `windowSize 40, maxWindows 6` → planned 6 windows, covering 1970-01-01 → 2026-11-12
714
- (the first 240 traces). To reach the compressible subset's ~60% the plan needs roughly
715
- 20–24 windows, matching the reviewer's estimate.
716
-
717
- ### Verified
718
- - `reflect-backfill.test.js`: preview writes nothing; a real run writes episodes with
719
- ≤24 sources and distinct periods; `windowSize < 32` is clamped to 32. Suite: 471/471,
720
- twice.
721
-
722
-
723
- ## 0.4.120 — 2026-11-16
724
-
725
- ### Fixed
726
- - **`bin/verify.mjs` labels the installed version, not the source tree.** It used to read
727
- `../package.json` (the checkout), so the 0.4.118 snapshot recorded `0.4.119` once the
728
- source was bumped — the baseline label for a whole version was wrong. It now reads
729
- `<profile>/node_modules/dsh-cortex/package.json`, reports `versionSource:
730
- installed|source` plus `sourceVersion`, and `--installed` exits 1 when nothing is
731
- installed. Verified against the live profile: `version 0.4.119 / versionSource
732
- installed` while the checkout is at 0.4.120.
733
-
734
- ### Verified
735
- - Unit suite unchanged: 468/468, twice. `verify.mjs --installed` fails closed, plain
736
- `verify.mjs` still succeeds.
737
-
738
-
739
- ## 0.4.119 — 2026-11-16
740
-
741
- ### Fixed (review of 0.4.118 — do not install 118)
742
- - **The fact channel was silently dead.** It built fact text from `fact.subject`, which facts
743
- do not expose; the text was an English predicate plus a literal, so Chinese traces never
744
- matched (factCovered = 6). It now resolves subject/object names through the entities repo,
745
- appends `objectLiteral` and `evidence`, and reuses the precompiled token sets (the unused
746
- `factScoreFor` duplicate is deleted).
747
- - **Preview no longer hands out single-evidence candidates.** `wouldCut` is `strongPool`
748
- only; when a pool exists but has no row with two evidence kinds the reason is
749
- `single-evidence-only`.
750
- - The preview threshold is a parameter (`coverageThreshold`, clamped 0.2–0.9) instead of a
751
- hardcoded 0.35, and is echoed back in the report.
752
-
753
- ### Verified on the production store (read-only copy)
754
- - active 945 · summaryCovered 423 · **factCovered 67** · both 52 · pool 67 · strongPool 52
755
- - r p50 0.022 / p90 0.537, spread 0.515 · **`usable: true`**
756
- - First time the gate opened: fixing the fact fields lifted fact coverage from 6 to 67 rows.
757
- Execution is still preview-only; 0.4.120 will target summary windows (episode count), not
758
- a lower threshold.
759
-
760
- ### Verified
761
- - Suite: 468/468, twice.
762
-
763
-
764
- ## 0.4.118 — 2026-11-16
765
-
766
- ### Changed
767
- - **Preview thresholds are reachable.** With `0.92 * rate` a 0.75 line needs rate 0.815, so the
768
- pool was structurally empty; the preview now uses an absolute `0.35` line and reports a
769
- `strongPool` that additionally requires two evidence kinds.
770
- - **Facts are a first-class coverage channel.** Facts are grouped by `sourceEventId` and
771
- scored against the trace text (≥2 shared content tokens, `0.5 + 0.4*rate`); the preview
772
- reports `summaryCovered`, `factCovered` and `bothCovered` separately.
773
- - **DF cutoff 10%, not 60%**: with 945 documents the old cutoff (567) filtered nothing; a
774
- synthetic test now pins that generic bigrams like 「我们」 are dropped.
775
- - Removed the dead `rate < 0.15 → ≤0.2` cap (0.92×0.15 is already below it) and the
776
- fallback that returned the *unfiltered* set for short traces.
777
- - `reason` is evaluated as `no_signal → empty_pool → flat`; the tool default is now 5000
778
- (it was still 500, silently truncating).
779
-
780
- ### Verified on the production store
781
- - active 942 · summaryCovered 423 · factCovered 6 · both 5 · pool 6 · strongPool 5
782
- - r p50 0.02 / p90 0.048, spread 0.028 → **`reason: flat`, `usable: false`**
783
- - So the pool is no longer structurally empty, but the signal is still too thin: the next
784
- move is summary **granularity** (session/day-level), not a lower threshold.
785
-
786
- ### Verified
787
- - Suite: 467/467, twice.
788
-
789
-
790
- ## 0.4.117 — 2026-11-16
791
-
792
- ### Fixed (review of 0.4.116's scorer — do not install 116)
793
- - **The flat distribution was the formula, not the summaries.** `score = 0.45 + 0.45*rate`
794
- turned any 2-token overlap into 47% coverage, so p50 sat at its floor and the spread
795
- collapsed to 0.013. The score is now `0.92 * rate` with a rate-based cap only
796
- (`rate < 0.15 → ≤0.2`); there is no additive floor and no length-based penalty that
797
- used to pin long traces at 0.35.
798
- - **Content tokens are filtered by document frequency.** `tokens()` keeps raw CJK
799
- bigrams with no stopword pass, so 「我们 / 可以 / 这个」 made any two sentences look
800
- similar. High-frequency tokens (in >60% of the batch) are dropped before scoring, with
801
- a small character stop-set as a second guard. Sets are built once per preview run.
802
- - **`usable` now explains itself**: `no_signal` (scored <10) / `flat` (p90−p50 <0.05) /
803
- `empty_pool` (no row over threshold), instead of one ambiguous boolean.
804
- - The preview scans all active traces by default (limit 5000) and reports
805
- `scanned`, so the 500-row truncation cannot hide the store size; the protection line
806
- is now the same `max(0.9, min(0.95, p75))` as consolidation.
807
-
808
- ### Verified on the production store (read-only copy)
809
- - active 940 · skipped 293 protected / 179 recent · scored 461 · 5 summaries
810
- - r p50 **0.041** / p75 0.059 / p90 0.088, spread 0.047 · best row **0.33**
811
- - **`reason: flat`** — with the honest scorer the current summaries really do cover very
812
- little. The next move is summary quality, not quota archiving.
813
-
814
- ### Verified
815
- - Suite: 466/466, twice.
816
-
817
-
818
- ## 0.4.116 — 2026-11-16
819
-
820
- ### Added
821
- - **Read-only compaction preview** (`cortex_consolidate action: "preview"`), the first
822
- step of the quota-compaction plan. It computes a *verifiable* coverage score
823
- (`coverage2`): a summary only counts when its own tokens overlap the trace, thin
824
- summaries are capped at 0.35, and `sourceIds` membership alone no longer grants 1.0.
825
- Protected traces (importance ≥ max(0.9, p75), reflection, promise) and recently
826
- accessed ones (`last_access_at` within 30 days) are skipped, then the r distribution
827
- (p50/p75/p90) and the would-be cut list are reported. It writes nothing.
828
-
829
- ### Verified on the production store (read-only copy via `VACUUM INTO`)
830
- - 939 active · skipped 293 protected / 178 recent · 461 scored · 5 summaries
831
- - r p50 0.472 / p75 0.481 / p90 0.494; **spread 0.013 < 0.05 → `usable: false`, pool 0**
832
- - Conclusion: the coverage signal is not usable yet. Per the design, 0.4.117 (gray-zone
833
- judgements) must **not** start until coverage quality improves — exactly the gate the
834
- reviewer asked for.
835
-
836
- ### Verified
837
- - `compaction-preview.test.js`: coverage2 scoring/caps, preview is read-only. Suite:
838
- 466/466, twice.
839
-
840
-
841
- ## 0.4.115 — 2026-11-16
842
-
843
- ### Fixed
844
- - **The threshold clamp actually clamps.** 0.4.114 computed `simThreshold` but both
845
- comparison sites still used the raw `threshold`, so the clamp was dead code. It is now
846
- `clampThreshold(value)` (exported and unit-tested: 0.1 → 0.5, 1.5 → 0.99, 0 / NaN →
847
- 0.8) and both the clustering loop and the target-similarity filter use it. The tool
848
- schema now declares `minimum: 0.5, maximum: 0.99`.
849
- - **`cortex_health` no longer shows a dedupe preview as the last consolidation.** The
850
- consolidation line now excludes rows with `model = 'dedupe'`, so a manual preview
851
- cannot hide the last real LLM run.
852
-
853
- ### Verified
854
- - New `dedupe-threshold.test.js`; Suite: 464/464, twice.
855
-
856
-
857
- ## 0.4.114 — 2026-11-16
858
-
859
- ### Fixed
860
- - **Dedupe no longer merges by transitive accident.** Union-find is transitive: A~B and
861
- B~C could pull an A that is not similar to C into the same merge. Every member must
862
- now also be a near-duplicate *of the chosen target* (Jaccard ≥ threshold), otherwise
863
- it stays active and the group is counted as dropped.
864
- - **Provenance on merge summaries.** The summary now lists the titles that were merged
865
- away (`去重合并 2 条到 X(含:A / B)`), so an audit can tell what disappeared without
866
- opening every archived row.
867
-
868
- ### Fixed (review pass from the reviewer teammate)
869
- - `protectedCount` now uses `isProtected`, so a low-importance reflection is counted as
870
- protected (it used to slip past the all-protected check and burn an LLM call).
871
- - **All-protected batches keep `update`/`conflict`.** The short-circuit that skipped the
872
- model also killed the only non-destructive action; the batch is still sent, with a
873
- prompt that forbids `archive`/`merge` and allows `update`/`conflict`.
874
- - dedupe previews record `status: 'preview'` instead of `degraded`, so `cortex_health` no
875
- longer shows a dry run as a failed consolidation.
876
- - `dryRun` is normalised once (`Boolean`), threshold is clamped to 0.5–0.99, the dedupe
877
- digest is namespaced (`dedupe:` / `run:`) so it cannot collide with the unchanged
878
- gate, summary provenance insert is best-effort, and a non-dry dedupe on a read-only
879
- scope is refused at the tool layer.
880
-
881
- ### Verified
882
- - Property test: every archived trace is still ≥ threshold similar to an active trace
883
- after a dedupe run. Suite: 463/463, twice.
884
-
885
-
886
-
887
-
888
-
889
- ## 0.4.113 — 2026-11-16
890
-
891
- ### Changed
892
- - **Dedupe may merge traces that sit on the protection line.** The production store has 75% of
893
- active traces at importance ≥ 0.95, so "two protected members" is the normal case and
894
- the old rule dropped every group — dedupe could not merge a single pair. Since dedupe
895
- has already proved the members are near-duplicates (Jaccard ≥ threshold) and
896
- reflections are excluded from the pool entirely, keeping N copies buys nothing:
897
- `validateDecision` gains `allowProtectedMerge`, used only by dedupe. The LLM path
898
- keeps the strict rule (a protected trace may never be a merge source).
899
-
900
- ### Verified
901
- - Tests: a protected pair is now merged; a reflection never takes part in dedupe and
902
- survives untouched; an LLM merge proposal over protected traces is still rejected.
903
- Suite: 462/462, twice.
904
-
905
-
906
- ## 0.4.112 — 2026-11-16
907
-
908
- ### Fixed
909
- - **All-protected batches no longer waste a call or look alarming.** On 2026-11-16 the
910
- automatic trigger hit a batch whose 30 candidates were all ≥ 0.93, so every proposal
911
- was rejected and the run read `rejected 20`. When every candidate is on the
912
- protection line the run now records `skipped / all-protected` without calling the
913
- model at all.
914
- - **Rejection counts carry their reasons**: the error label is now
915
- `rejected 3(protected×2 · unknown-id×1)` instead of a bare number.
916
- - **One protection predicate.** `validateDecision`'s archive branch checked
917
- `importance >= protect || kind === 'reflection'`, but the merge branch only checked
918
- importance — so a low-importance reflection could be merged away as a merge *source*.
919
- Both branches, the duplicate-group builder and the deterministic dedupe now use the
920
- same `isProtected(trace, protect)` helper; reflections may only ever be the target.
921
-
922
- ### Added
923
- - **Deterministic dedupe.** The LLM kept answering `keep` even when handed duplicate
924
- groups, so the mechanical half of consolidation no longer asks it: `consolidation.dedupe()`
925
- clusters active traces by 2-gram Jaccard (threshold 0.8 by default), picks the
926
- best-preserved member as the merge target, refuses any group with two protected
927
- members, and archives the rest with `compression: merged` plus a `dedupe` merge
928
- summary. Exposed as `cortex_consolidate action: "dedupe"` with `dryRun` defaulting
929
- to true.
930
- - `record()` now returns `groups` / `groupsDropped` on the run object, so callers (and
931
- the tool output) can read them without a second SQL query.
932
-
933
- ### Verified
934
- - Tests: dry run reports one group without touching the store; a real run archives one
935
- trace and leaves a merge summary; two protected members are never merged. Suite:
936
- 457/457, twice.
937
-
938
-
939
- ## 0.4.111 — 2026-11-16
940
-
941
- ### Fixed
942
- - **The protected member is now a structural merge target.** 0.4.110 dropped groups
943
- with two protected members but only *asked* the model to keep the protected one as
944
- `targetId`; if it picked another member the whole decision was rejected as
945
- `protected-merge`. Groups are now offered as `{ ids, mustBeTarget }` and the prompt
946
- says the target must be the `mustBeTarget` id.
947
- - **Dropped groups are counted.** The audit row now carries `groupsDropped` next to
948
- `groups`, so `groups: 0` no longer hides "there were duplicates but the protection
949
- line removed them".
950
-
951
- ### Verified
952
- - Tests: two-protected group → `groups: 0`, `groupsDropped: 1` and no group in the
953
- prompt; one-protected group → `groups: 1` and `mustBeTarget` present. Suite:
954
- 454/454, twice.
955
-
956
-
957
- ## 0.4.110 — 2026-11-16
958
-
959
- ### Fixed
960
- - **Duplicate groups are filtered by the protection line before they reach the
961
- model.** `validateDecision` rejects a `merge` whose non-target member is protected,
962
- so a group with two protected traces could only produce a decision that fails —
963
- and the rejection read like "there were duplicates but it kept them". Groups with
964
- two or more protected members are dropped; a group with exactly one keeps that one
965
- as the target and the rest as sources.
966
-
967
- ### Added
968
- - Every consolidation audit row now records `groups`, the number of duplicate groups
969
- actually offered. Without it there was no way to tell "no duplicates" apart from
970
- "duplicates that were dropped".
971
-
972
- ### Verified
973
- - Tests: a two-protected group is withheld (`groups: 0`); a one-protected group is
974
- offered (`groups: 1`). Suite: 454/454, twice.
975
-
976
-
977
- ## 0.4.109 — 2026-11-16
978
-
979
- ### Fixed
980
- - **The per-tick path is no longer a per-minute LLM call.** `features.consolidateOnTick`
981
- was silently `true` in `feature-overrides.json` since 11-12 (the profile yml never
982
- mentioned it), so the scheduler ran a full consolidation every tick — hundreds of `no-llm`
983
- rows are that history, not a broken adapter. The tick path now honours
984
- `consolidateTraceGapMinutes` (default 30) and reports `too-soon` instead.
985
- - `lastRealConsolidationAt` joins `dream_runs` so the audit lookup is scoped; with
986
- several scopes it no longer reads another scope's run.
987
-
988
- ### Added
989
- - **Duplicate groups are handed to the model.** Capture already rejects
990
- byte-identical traces, so exact matching finds nothing; candidates are clustered by
991
- 2-gram Jaccard ≥ 0.6 and the groups are listed in the prompt with an instruction to
992
- `merge` the best-preserved one. Without this the model kept answering `keep` even
993
- when nothing was protected.
994
-
995
- ### Verified
996
- - Tests: tick gate skips within the gap and runs after it; paraphrased duplicates
997
- reach the prompt as a merge group. Suite: 452/452, twice.
998
-
999
-
1000
- ## 0.4.108 — 2026-11-16
1001
-
1002
- ### Changed
1003
- - **The protection line is now relative.** Live data had 99% of active traces at
1004
- `importance >= 0.7`, while the prompt and validator both protected everything at
1005
- `>= 0.7` — so consolidation could only ever answer `keep`. The line is now
1006
- `max(0.9, min(0.95, p75))` of the current batch: the top slice stays protected
1007
- (reflections always), everything below it may be merged or archived, and the
1008
- prompt states the actual line and how many items it protects. Same lesson as the
1009
- cold tier: absolute thresholds vs. an absolute-heavy distribution.
1010
-
1011
- ### Fixed
1012
- - **`consolidateOnTick` can no longer starve the delta trigger.** The tick path has
1013
- no interval gate, so it would write a run every minute and make
1014
- `runAutoConsolidate` permanently `too-soon`. The delta trigger now measures the
1015
- gap from the last *non-tick* `consolidation.run` audit row, falling back to
1016
- `dream_runs` when no audit exists.
1017
- - `tool` and `api` call sites now pass `caller`, so every consolidation run names
1018
- its actor.
1019
-
1020
- ### Verified
1021
- - New tests: quantile line protects the top and archives the bottom; the prompt no
1022
- longer hardcodes 0.7; tick-written runs do not starve the trigger; audit-less
1023
- stores fall back to the table. Suite: 449/449, twice.
1024
-
1025
-
1026
- ## 0.4.107 — 2026-11-16
1027
-
1028
- ### Changed
1029
- - **Consolidation budget raised again, with evidence.** After 0.4.106 shipped, the
1030
- automatic trigger produced two real runs within a minute and both were still
1031
- `empty-text:max-tokens` at 2400 — the answer keeps being cut off by the cap, not
1032
- rejected. Budgets are now 6000 for the bounded and retry attempts, 3000 for the
1033
- plain attempt (a cap is a ceiling, not spend).
1034
-
1035
- ### Added
1036
- - **Consolidation records who called it.** `dream_runs` has no caller column, so
1037
- each run now writes `audit(consolidation.run, { caller })`; callers pass
1038
- `auto-trace-delta` / `tick` / `sleep` / `tool`. Two runs a minute apart used to be
1039
- unexplainable from the data alone.
1040
-
1041
- ### Fixed
1042
- - `health`'s `LLM_EMPTY` buckets no longer render `llm-empty:empty-text:max-tokens`
1043
- and `llm-empty-retry:empty-text:max-tokens` as two identical entries; the retry
1044
- bucket reads `…(重试)`.
1045
-
1046
- ### Verified
1047
- - New tests: caller lands in the audit row; retry bucket is distinguishable.
1048
- Suite: 445/445, twice.
1049
-
1050
-
1051
- ## 0.4.106 — 2026-11-16
1052
-
1053
- ### Added
1054
- - **Consolidation gets its own trigger.** Until now it only ran inside sleep, which
1055
- is gated to once per 20 h — so every version's acceptance test waited a day.
1056
- With `features.consolidateOnTraceDelta` on, each scheduler tick checks whether
1057
- at least `consolidateTraceDelta` (default 20) new active traces appeared since
1058
- the last consolidation and at least `consolidateTraceGapMinutes` (default 30)
1059
- passed; if so it runs a real consolidation and records
1060
- `report.steps.autoConsolidate` (`fresh / status / model / decisions / applied`,
1061
- or a skip reason `too-soon` / `not-enough-new-traces`).
1062
-
1063
- ### Fixed
1064
- - **Per-call failure reasons.** The adapter now accepts `onReason`, so a failure is
1065
- reported to the caller that caused it; an interleaved dream/feeling call can no
1066
- longer reset or overwrite another call's reason. `ask()`'s outer catch records
1067
- `exception-outer` instead of swallowing silently.
1068
- - `health`'s consolidation line now shows `决策 N(keep M)· 应用 K`, so an
1069
- `applied` run where every decision was `keep` reads as the no-op it is.
1070
-
1071
- ### Verified
1072
- - `scheduler-autoconsolidate.test.js`: runs when fresh ≥ threshold and gap passed;
1073
- skips with a reason otherwise; off by default. `consolidate-reason.test.js`
1074
- covers `exception-outer` and reason scoping across calls. Suite: 443/443, twice.
1075
-
1076
-
1077
- ## 0.4.105 — 2026-11-16
1078
-
1079
- ### Fixed
1080
- - **The output budget was cutting the answer off.** The installed 0.4.103 recorded
1081
- `llm-empty:empty-text:max-tokens` — the model's reply was truncated at the token
1082
- cap, not rejected, so the text came back empty. Consolidation budgets are raised:
1083
- bounded attempt 2400 (was 1400), plain attempt 1600 (was 900), retry 2400
1084
- (was 1600). With reasoning tokens sharing the same budget, 900 was simply too
1085
- small.
1086
-
1087
- ### Verified
1088
- - `consolidate-retry.test.js` asserts the bounded attempt now requests ≥2000 tokens.
1089
- Suite: 437/437, twice.
1090
-
1091
-
1092
- ## 0.4.104 — 2026-11-16
1093
-
1094
- ### Changed
1095
- - **Big payloads now start bounded instead of failing first.** Live evidence from the
1096
- installed 0.4.102: a ~10k-char payload produced an empty answer, while the slim
1097
- retry (10 × 220 chars) returned a valid array with 10 `keep` decisions and was
1098
- recorded as `llm-retry`. So candidates over 5000 chars now begin with a bounded
1099
- attempt (20 items × 300 chars, `maxTokens` 1400) and are recorded as
1100
- `llm-bounded`; if that still comes back empty, the 10 × 220 retry runs and is
1101
- marked `llm-retry`. Small payloads keep the original single call.
1102
-
1103
- ### Verified
1104
- - `consolidate-retry.test.js`: 40 long traces → one bounded call, model `-bounded`;
1105
- retry path and reason labels unchanged. Suite: 437/437, twice.
1106
-
1107
-
1108
- ## 0.4.103 — 2026-11-16
1109
-
1110
- ### Added
1111
- - **`cortex_health` reports consolidation and sleep.** `dream_runs.error` is the
1112
- only place that says *why* consolidation did nothing; leaving it in a table
1113
- meant remembering to look. `health` now exposes
1114
- `consolidation { dream, sleep }` and the text adds one line, e.g.
1115
- `巩固 2026-11-16T09:34 空转(llm-empty:empty-text:length) · 睡眠 …(skipped,反思 1)`.
1116
-
1117
- ### Verified
1118
- - `health-consolidation.test.js`: a run without an adapter shows `空转(no-llm-adapter)`
1119
- and `睡眠 还没有记录`. Suite: 436/436, twice.
1120
-
1121
-
1122
- ## 0.4.102 — 2026-11-16
1123
-
1124
- ### Fixed
1125
- - **Empty answers now say why.** The adapter keeps the failure reason
1126
- (`no-selection`, `finish-error`, `exception`, `empty-text:<finish kind>`) and
1127
- consolidation records `llm-empty:<reason>`. When the slim retry already ran and
1128
- still came back empty the label is `llm-empty-retry:<reason>`, so "retried and
1129
- still empty" is no longer indistinguishable from "empty on the first try".
1130
- (Both P2s from review's 0.4.101 review.)
1131
- - `health` matches the `llm-empty%` family and reports the reason buckets, so one
1132
- glance shows whether the fix is about prompt size, purpose, or wiring.
1133
-
1134
- ### Verified
1135
- - `consolidate-reason.test.js`: reason carried through; retry-exhausted label;
1136
- health buckets by reason. Suite: 435/435, twice.
1137
-
1138
-
1139
- ## 0.4.101 — 2026-11-16
1140
-
1141
- ### Changed
1142
- - **Consolidation retries once with a slimmer prompt.** The production store's payload
1143
- averages ~5k characters; when the first call comes back empty and the payload
1144
- exceeds 4000 chars, it retries with the top 10 items and 220-char contents. A
1145
- successful retry is recorded as `llm-retry` in the model column, so the extra
1146
- path is visible instead of indistinguishable from a plain success. Short
1147
- payloads do not retry (a retry would only repeat the same empty answer).
1148
-
1149
- ### Verified
1150
- - `consolidate-retry.test.js`: 16 long traces → two calls, second prompt shorter,
1151
- status `applied` with a `-retry` model; 3 short traces → one call, `llm-empty`.
1152
- Suite: 432/432, twice.
1153
-
1154
-
1155
- ## 0.4.100 — 2026-11-16
1156
-
1157
- ### Fixed
1158
- - **`labelEntities` still returned the old `no-llm` skip label.** It now returns
1159
- `no-llm-adapter`, matching `consolidation.run`, so one word no longer covers two
1160
- different failures. (P3 from review's 0.4.98 review; the historical hundreds of rows stay
1161
- as they are.)
1162
-
1163
- ### Verified
1164
- - `label-entities-skip.test.js`: without an adapter the skip label is
1165
- `no-llm-adapter`. Suite: 430/430, twice.
1166
-
1167
-
1168
- ## 0.4.99 — 2026-11-16
1169
-
1170
- ### Added
1171
- - **`autoSleep`: the scheduler can now start a sleep pass.** Nothing used to call
1172
- `life.sleep()` on a schedule, so `consolidateOnSleep` never had a chance to run
1173
- (`sleep-runs` had been stuck at 11-12). When `features.autoSleep` is on and the
1174
- host is idle, the scheduler sleeps if no sleep exists or the last one is ≥20h
1175
- old; the profile patch enables it.
1176
-
1177
- ### Changed
1178
- - `features.autoSleep` added to the config schema and the override keys, so it can
1179
- be toggled from `feature-overrides.json` without a rebuild.
1180
-
1181
- ### Verified
1182
- - `scheduler-autosleep.test.js` (4 cases): never slept → sleeps; 3h ago → does not;
1183
- 21h ago → sleeps; flag off → never calls. Suite: 429/429, twice.
1184
-
1185
-
1186
- ## 0.4.98 — 2026-11-16
1187
-
1188
- ### Fixed
1189
- - **`no-llm` was two different failures under one label.** A missing adapter and an
1190
- adapter that answered nothing both recorded `no-llm`, so the hundreds of rows gave no
1191
- clue which one to fix. They are now `no-llm-adapter` and `llm-empty`, and
1192
- `health` warns `LLM_EMPTY` when ≥5 empty answers pile up within 6 hours.
1193
-
1194
- ### Found while investigating (not fixed here)
1195
- - **Nothing calls `life.sleep()` on a schedule.** `sleep-runs` stops at 11-12
1196
- because `sleep` only runs through the tool/API; `consolidateOnSleep` therefore
1197
- never fires. The next version should add an `autoSleep` scheduler hook (idle +
1198
- ≥20h since last sleep) rather than pretending the flag alone is enough.
1199
-
1200
- ### Verified
1201
- - `consolidate-errors.test.js`: no adapter → `no-llm-adapter`, empty answer →
1202
- `llm-empty`, six empties → `LLM_EMPTY` warning. Suite: 425/425, twice.
1203
-
1204
-
1205
- ## 0.4.97 — 2026-11-15
1206
-
1207
- ### Fixed
1208
- - **Why consolidation never ran: the LLM feature was off.** The live profile had
1209
- `features.llm` unset, so the adapter was `null` and every consolidation tick
1210
- recorded `no-llm` (hundreds of rows in `dream_runs`); the same flag gates sleep
1211
- consolidation. The profile patch now sets `features.llm: true` and
1212
- `consolidateOnSleep: true` (backup: `cordis.patch.yml.bak-noisefix-*`), and
1213
- `health` raises `LLM_DISABLED` when the flag is off so this can never be silent
1214
- again.
1215
- - **Facts polluted by sentence fragments.** The rule extractor now filters
1216
- single-character function words (`的了着过等儿…`) and a `NOISE_OBJECTS` list
1217
- (`等`, `收一收`, `水里`, …). `repair --drop-noise-facts` (opt-in) archives the
1218
- existing garbage through the backup gate: 255 candidates live, 255 invalidated on
1219
- a copy (`828 → 650` active).
1220
-
1221
- ### Verified
1222
- - `fact-noise-llm.test.js`: fragment text yields zero facts, a normal sentence
1223
- still yields `likes`, and `LLM_DISABLED` appears only when the feature is off.
1224
- Suite: 422/422, twice.
1225
-
1226
-
1227
- ## 0.4.96 — 2026-11-15
1228
-
1229
- ### Fixed
1230
- - **`SLOW_MAINTAIN` no longer becomes permanent.** A slow pass row used to linger
1231
- until the next *changed* pass overwrote it, which read as "currently stalling"
1232
- forever. Only passes within `maintainSlowWindowHours` (default 6) count now, and
1233
- the message carries `距现在 N 分钟` so the age is visible.
1234
- - **Timestamp comparison uses `Date.parse`, not string order.** An injected
1235
- `2026-11-15 14:36:00` sorted before `2026-11-15T14:36:00Z` purely because of the
1236
- space, so the same instant looked older; unparsable values now fall back to the
1237
- in-memory pass.
1238
- - **The summon book could drop its own left card.** When the slots were full the
1239
- left (emotional) card was pushed and then sliced off — the block looked frozen.
1240
- It now displaces a chosen card whose removal keeps day diversity (its day is
1241
- duplicated, or equals the left card's day); the displaced card is reported via
1242
- `onDrop` → `summon.drop` metric. If no such card exists the left card is skipped
1243
- rather than sacrificing the day spread.
1244
-
1245
- ### Verified
1246
- - `maintain-duration.test.js` (10 cases): an 8h-old slow pass raises nothing; a
1247
- space-formatted timestamp equal to the in-memory one is treated as the same pass.
1248
- - `summon-left-slot.test.js`: full slots → left card present, displaced card
1249
- reported and absent from the result; free slot → no drop.
1250
- Suite: 418/418, twice.
1251
-
1252
-
1253
- ## 0.4.95 — 2026-11-15
1254
-
1255
- ### Changed
1256
- - **A slow pass now leaves durable evidence.** Quiet passes write no audit row, so
1257
- a stall that happened between two heartbeats had nothing to read later. A pass
1258
- slower than `maintainSlowMs` (default 2000) now writes its `maintain.run` row even
1259
- when it changed nothing; changed passes behave exactly as before.
1260
-
1261
- ### Why
1262
- - The production store still holds only the 08:24:56Z row (9 keys, no `ms`): no passing
1263
- `maintain` has actually changed anything since 0.4.89, and the "过期意图 1 条" in
1264
- the 0.4.93 install was `repair`, not `maintain`. Without this change the first
1265
- real timing sample could stay missing for days.
1266
-
1267
- ### Verified
1268
- - `maintain-duration.test.js` (8 cases): with `maintainSlowMs: 0` a no-change pass
1269
- still writes an audit row carrying `ms`. Suite: 414/414, twice.
1270
-
1271
-
1272
- ## 0.4.94 — 2026-11-15
1273
-
1274
- ### Fixed
1275
- - **A slow pass was hidden by the next quiet one.** `SLOW_MAINTAIN` only judged the
1276
- newest pass, but `maintain()` runs on the heartbeat, so a stall is followed by a
1277
- fast pass within minutes and the warning effectively never fired — defeating the
1278
- whole point of adding it in 0.4.86. It now evaluates the newest pass *and* the
1279
- last pass that changed anything, warns on the slowest, and reports that pass's
1280
- timestamp alongside its duration. (Found by review against the production store.)
1281
-
1282
- ### Verified
1283
- - `maintain-duration.test.js` (7 cases): a fake 8500ms audit row followed by a fast
1284
- quiet pass still raises `SLOW_MAINTAIN` with `ms: 8500` and a timestamp.
1285
- Suite: 413/413, twice.
1286
-
1287
-
1288
- ## 0.4.93 — 2026-11-15
1289
-
1290
- ### Fixed
1291
- - **"最近一趟维护" could point at the older run.** The line was chosen by
1292
- "does it have `ms`", so after a change pass followed by a quiet one the audit row
1293
- won and the genuinely newest (quiet) pass never appeared; the second line then
1294
- repeated the first one. Selection is now by recency (`recorded.passAt` vs
1295
- `memory.at`), and the second line only prints when the audit row is strictly
1296
- older.
1297
- - Maintenance timestamps in `cortex_health` now include seconds (`slice(0, 19)`);
1298
- two different passes in the same minute used to render identically.
1299
-
1300
- ### Verified
1301
- - `maintain-duration.test.js` (6 cases, new one included): change pass then quiet
1302
- pass → first line is the quiet pass, `maintainLastChanged` is the change pass,
1303
- the two are not the same source. Suite: 412/412, twice.
1304
-
1305
-
1306
- ## 0.4.92 — 2026-11-15
1307
-
1308
- ### Fixed
1309
- - **The maintenance readout was invisible in the tool that matters.**
1310
- `cortex_health`'s text formatter printed a fixed line and ignored `report.ok`,
1311
- so the 0.4.91 two-line detail (and the duration) never reached the caller. It
1312
- now renders `维护:最近一趟 <time>(意图 x · 工作记忆 y · Nms)` and, when the
1313
- newest audit row belongs to a different pass, `最近一次有变更:<time>(…)`.
1314
-
1315
- ### Verified
1316
- - `health-text-maintain.test.js`: a 6h-old row + a quiet pass → the rendered text
1317
- contains both the duration and the separate "最近一次有变更" line.
1318
- Suite: 411/411, twice.
1319
-
1320
-
1321
- ## 0.4.91 — 2026-11-15
1322
-
1323
- ### Changed
1324
- - **`health` says both things about maintenance.** It reports `最近一趟维护`
1325
- (the in-memory last pass, including its duration) and, when the newest audit row
1326
- comes from a different pass, `最近一次有变更的维护` with that row's counts. A
1327
- quiet heartbeat writes no row, so one stale timestamp used to read as "nothing
1328
- has run for hours".
1329
- - `health` exposes `maintainLastChanged` (that audit row) for tooling, and
1330
- `maintainReport()` carries `passAt` from `detail.at` so the comparison uses the
1331
- pass's own timestamp rather than the row's write time. (Suggestion from review.)
1332
-
1333
- ### Verified
1334
- - `maintain-duration.test.js` (5 cases): a 6-hour-old row with `working: 7` plus a
1335
- quiet pass → both lines appear and `maintainLastChanged.working` is 7.
1336
- Suite: 410/410, twice.
1337
-
1338
-
1339
- ## 0.4.90 — 2026-11-15
1340
-
1341
- ### Fixed
1342
- - **No more mixed maintenance numbers during the upgrade window.** When the audit
1343
- row predated `ms`, `health` kept that row's counts and borrowed the latest
1344
- pass's duration — a combination no single run produced. `lastMaintain` is now a
1345
- full report snapshot and `health` falls back to it wholesale (counts and duration
1346
- from the same pass). (Review finding from review.)
1347
-
1348
- ### Note
1349
- - The displayed "上次维护" time still comes from the audit row's write time rather
1350
- than `detail.at`; within one tick they are equal, across ticks it is a few ms
1351
- early. Cosmetic, left as is.
1352
-
1353
- ### Verified
1354
- - `maintain-duration.test.js` (4 cases): an old 9-key row with `working: 7` plus a
1355
- fresh pass → `health.maintain.working` equals the new pass, not 7, and `ms` is
1356
- finite. Suite: 409/409, twice.
1357
-
1358
-
1359
- ## 0.4.89 — 2026-11-15
1360
-
1361
- ### Fixed
1362
- - **`SLOW_MAINTAIN` could not fire on the passes that mattered.** The audit row was
1363
- written *before* `report.ms` was computed, so every real pass stored a detail
1364
- without `ms`; `health` then preferred that row and fell back to memory only when
1365
- no row existed — i.e. the warning worked on idle passes and failed exactly when
1366
- maintenance did real work. Timing is now computed before the audit write, and
1367
- `health` merges `ms` from the in-memory pass when the row lacks it.
1368
- (Found by review against the production store: the single `maintain.run` row had keys
1369
- `aliases/at/disputes/errors/goalRounds/intentions/playbook/summaries/working`
1370
- and no `ms`.)
1371
- - `maintainSlowMs` is config (default 2000) instead of a hardcoded threshold.
1372
-
1373
- ### Verified
1374
- - `maintain-duration.test.js` (3 cases): idle pass reports `ms`; a pass that
1375
- actually changes something writes `ms` into the audit detail and health reads it;
1376
- a 50ms row with `maintainSlowMs: 5` raises `SLOW_MAINTAIN`. Suite: 408/408, twice.
1377
-
1378
-
1379
- ## 0.4.88 — 2026-11-15
1380
-
1381
- ### Added
1382
- - **`maintain()` measures itself.** The pass returns `report.ms`, keeps an
1383
- in-memory `lastMaintain`, records a `maintain.ms` metric, and the audit detail
1384
- now carries the duration. `health` exposes `maintain.ms` and raises
1385
- `SLOW_MAINTAIN` above 2s — the 0.4.86 O(n²) regression would have shown up here
1386
- instead of as a frozen host.
1387
- - `health` falls back to the in-memory last pass when `maintain()` changed
1388
- nothing (and therefore wrote no audit row).
1389
-
1390
- ### Verified
1391
- - `maintain-duration.test.js`: a no-op pass still reports `ms` and health reads
1392
- the same number; a synthetic 8500ms audit row raises `SLOW_MAINTAIN`.
1393
- Suite: 407/407, twice.
1394
-
1395
-
1396
- ## 0.4.87 — 2026-11-15
1397
-
1398
- ### Fixed
1399
- - **The dedupe pass was O(n²) inside a synchronous `maintain()`.** 0.4.86 compared
1400
- every pair to build the unique list: 148 traces → 10,878 jaccard calls ≈ 908ms,
1401
- and the 500-trace cap would be ≈10s, freezing the host. The near-duplicate
1402
- filter now runs only over the head of the ranked list (3× the budget); the tail
1403
- is sampled by position, where duplicates are rare. Cost is (3×budget)²
1404
- comparisons regardless of window size.
1405
- - **Tail sampling was unreachable.** `rest[0] + k·floor(rest/remaining)` only
1406
- reached ~83% of the list. Picks are now bucket-centred:
1407
- `floor((slot + 0.5) * rest.length / remaining)`.
1408
-
1409
- ### Verified
1410
- - `reflect-sampling.test.js`: cold topics take most of the remaining slots
1411
- (10 hot + 50 cold → 9 hot + 6 cold); the last-quarter traces (23–29) are
1412
- reached; 500 candidates finish under 3s with ≤24 sources. Suite: 405/405, twice.
1413
-
1414
- ### Note
1415
- - Coverage dropping ~0.005 versus pure top-k is the intended cost of stratifying;
1416
- it is not a regression and not a red line.
1417
-
1418
-
1419
- ## 0.4.86 — 2026-11-15
1420
-
1421
- ### Changed
1422
- - **Sampling is stratified instead of pure top-k.** 60% of the source budget is
1423
- filled by score, then the remaining slots are taken from the rest of the ranked
1424
- list with a stride, so one loud strand of the day cannot occupy every slot.
1425
- (Suggested by review after measuring the production store: max pairwise jaccard is 0.37,
1426
- so the near-duplicate filter is a no-op there and the only real levers left are
1427
- the caps and the sampling strategy.)
1428
- - The composed `一句话` line now uses the first two **distinct** bullets (two
1429
- traces can share a title, and `X;X` is not a summary).
1430
-
1431
- ### Note
1432
- - A first attempt keyed samples by a `topicSignature()` of the rarest tokens; it
1433
- failed because synthetic `alpha1/alpha2` texts produced different signatures, so
1434
- the cap did nothing. Replaced with the position-based stride, which does not
1435
- depend on topic detection at all; `topicSignature` was removed rather than left
1436
- as dead code.
1437
-
1438
- ### Verified
1439
- - `reflect-sampling.test.js`: 30 hot + 30 cold traces → the summary contains both
1440
- (hot majority, cold non-empty). Suite: 403/403, twice.
1441
-
1442
-
1443
- ## 0.4.85 — 2026-11-15
1444
-
1445
- ### Fixed
1446
- - **The `一句话` line was dead code.** `gistOf()` returns one of the bullets
1447
- verbatim, so `!bullets.includes(gist)` could never be true: the line never
1448
- rendered and the O(n²) similarity pass was wasted. It is now composed from the
1449
- two most central bullets (joined with `;`, truncated to 90 chars) and omitted
1450
- when there are fewer than three bullets; `gistOf()` is gone.
1451
- - **The phrasing test now defends the real defect.** It asserted only that `· `
1452
- lines were unique, which the `一句话:X` + `· X` shape passes. It now asserts
1453
- each bullet appears exactly once in the content and that any `一句话` line
1454
- differs from every bullet, plus a case with ≥3 distinct bullets that actually
1455
- exercises the composed line.
1456
- - Reflect config numbers are validated (`Number.isFinite` fallback): a typo used
1457
- to become `NaN`, silently turning the dense-day follow-up off.
1458
-
1459
- ### Verified
1460
- - Suite: 402/402, twice.
1461
-
1462
-
1463
- ## 0.4.84 — 2026-11-15
1464
-
1465
- ### Changed
1466
- - **Segments sample more of their window.** The source budget is now
1467
- `sourceBudgetFor(n, { segment })`: 25% of the window capped at 24 for a segment,
1468
- 12% capped at 16 for a whole-day window (floor 8 in both). Segments are short by
1469
- construction, so the old flat 12% summarized a 40-trace segment from 8 rows and
1470
- left coverage near 20% no matter how the phrasing improved.
1471
- - The budget moved into an exported pure function, so it is unit-tested directly
1472
- instead of being buried in the selection loop. It is a ceiling, not a quota: the
1473
- near-duplicate filter (jaccard > 0.7) can still select fewer.
1474
-
1475
- ### Verified
1476
- - `reflect-source-budget.test.js`: 10/40/100/200/500 → whole-day 8/8/12/16/16,
1477
- segment 8/10/24/24/24; explicit `maxSources` overrides both.
1478
- Suite: 401/401, twice.
1479
-
1480
-
1481
- ## 0.4.83 — 2026-11-15
1482
-
1483
- ### Changed
1484
- - **Episode summaries speak in the first person.** `这段时间里,记住了:` +
1485
- `- bullet` became `这一段里,我记下了:` + `· bullet`, and the `一句话:` gist
1486
- line is dropped when it duplicates a bullet verbatim. This is phrasing only:
1487
- the coverage maths is untouched, and a test recomputes the stored coverage from
1488
- the stored source ids to prove it.
1489
- - The dense-day follow-up thresholds moved into config:
1490
- `reflectFollowUpMin` (default 150) and `reflectFollowUpGapHours` (default 6).
1491
- (Review finding from review.)
1492
-
1493
- ### Verified
1494
- - `reflect-phrasing.test.js`: first-person heading, `·` bullets with no
1495
- duplicates, and `coverage == importance-weighted formula`. Suite: 399/399,
1496
- twice.
1497
-
1498
-
1499
- ## 0.4.82 — 2026-11-15
1500
-
1501
- ### Changed
1502
- - **Episodes are segmented, not overlapping.** The auto-reflection window now
1503
- starts at `max(now − 24h, previous episode's periodEnd + 1ms)`, so two
1504
- consecutive episodes cover different stretches of time. Segment summaries are
1505
- marked `extractive-v2-segment` (still `-v2`, so coverage-rewrite skips them).
1506
- A dense day may get a second episode, but only as a separate segment: ≥150 new
1507
- traces since the last episode **and** ≥6h since it was written; otherwise the
1508
- pass reports `skipped: 'covered'`.
1509
- - `reflect({ since, segment })`: explicit window start, default behaviour
1510
- unchanged.
1511
- - Extracted `isPerm()` in the tier code — the 0.8 threshold was duplicated three
1512
- times (review finding from review).
1513
-
1514
- ### Verified
1515
- - `auto-reflect.test.js`: 60 traces → episode 1; +7h with 160 new traces →
1516
- second episode whose `periodStart` is **after** the first `periodEnd`, marked
1517
- `extractive-v2-segment`; with only 60 new traces it stays `covered`.
1518
- Suite: 398/398, twice.
1519
-
1520
-
1521
- ## 0.4.81 — 2026-11-15
1522
-
1523
- ### Fixed
1524
- - **A perm-heavy recall no longer empties the hot tier.** The cold cut counted
1525
- *all* candidates, so 8 candidates with 6 of them at importance ≥ 0.8 produced 2
1526
- cold rows and 0 hot ones. The cut now ranks inside the non-perm pool only
1527
- (`relativeTotal = candidates − permCount`), and still requires ≥ 4 non-perm
1528
- candidates before splitting. (Review finding from review.)
1529
-
1530
- ### Verified
1531
- - `tiers-gist.test.js`: 6 perm + 2 mid → 0 cold, 2 hot; 2 perm + 6 mid → 2 cold,
1532
- 4 hot. Suite: 396/396, twice.
1533
-
1534
-
1535
- ## 0.4.80 — 2026-11-15
1536
-
1537
- ### Changed
1538
- - **Auto-reflection cadence follows the material, not the clock.** The fixed 6
1539
- hour gate is gone (it was redundant with the 24h `covered` check — a summary
1540
- written 5h ago already means the window is covered), and the minimum material
1541
- is now 50 non-reflection traces (config `reflectMinMaterial`). A quiet day no
1542
- longer gets an episode for showing up; a busy day is no longer delayed 6 hours
1543
- before it can be summarized. `skipped: 'few-traces'` reports both `count` and
1544
- `minMaterial` so the reason is visible.
1545
-
1546
- ### Verified
1547
- - `auto-reflect.test.js`: 60 traces → one episode then `covered`; 40 traces →
1548
- `few-traces` with `minMaterial: 50`; 60 traces spread across 24h → still
1549
- `covered` 7h later; next day writes a second; 3 traces → nothing.
1550
- Suite: 394/394, twice.
1551
-
1552
-
1553
- ## 0.4.79 — 2026-11-15
1554
-
1555
- ### Fixed
1556
- - **Cold-tier count was cut short by rounding.** `ceil(total * 0.75)` rounded the
1557
- *cut* up, so common recall sizes under-filled the tier: 5 candidates → 1 cold
1558
- (20%), 7 → 1 (14%), 10 → 2 (20%). It now counts first —
1559
- `max(1, ceil(total * 0.25))` — and slides the cut: 4→1, 5→2, 6→2, 7→2, 8→2,
1560
- 10→3, 20→5.
1561
- - **Stable tier assignment.** Equal `utility` now breaks ties by importance and
1562
- then id, so the same candidate set cannot shuffle between cold and hot on
1563
- consecutive turns.
1564
-
1565
- ### Verified
1566
- - `tiers-gist.test.js`: the 4/5/6/7/8/10/20 → 1/2/2/2/2/3/5 table, plus a
1567
- reversed-input determinism test. Suite: 394/394, twice.
1568
-
1569
-
1570
- ## 0.4.78 — 2026-11-15
1571
-
1572
- ### Fixed
1573
- - **The cold tier was unreachable on real data.** It required importance < 0.4,
1574
- but every live trace sits in 0.6–1.0 (measured: 0.6×5, 0.7×307, 0.8×184,
1575
- 0.9×76, 1.0×211), so the tier was decorative. `tierOf` now also sends the
1576
- lowest quarter of the current turn's candidates to `cold` (relative cut, at
1577
- least 4 candidates), while keeping the absolute cutoff for genuinely small
1578
- importance values. Fewer than 4 candidates means no relative split, so a tiny
1579
- recall never gets pushed into index-only. (Reported by review.)
1580
-
1581
- ### Verified
1582
- - `tiers-gist.test.js` adds: 8 candidates all at 0.6 → the last 2 land in cold
1583
- with `字面命中` and 6 stay hot; 3 candidates → 0 cold. Suite: 392/392, twice.
1584
-
1585
-
1586
- ## 0.4.77 — 2026-11-15
1587
-
1588
- ### Added
1589
- - **Health reports the narrative layer.** `health` now exposes
1590
- `summaryLayers { episode, merge, thread, lastEpisodeAt }`, the `cortex_health`
1591
- text shows `摘要:每日 N 条(最近 …)· 合并记录 M · 线 K`, and a store with
1592
- ≥100 active traces but zero episode summaries gets a `NO_EPISODE_SUMMARIES`
1593
- warning — a thin narrative layer is now visible instead of silent.
1594
-
1595
- ### Verified
1596
- - `test/unit/health-summaries.test.js`: empty store reports 0, after inserting an
1597
- episode + merge row it reports 1/1 with a timestamp. Suite: 390/390, twice.
1598
-
1599
-
1600
- ## 0.4.76 — 2026-11-15
1601
-
1602
- ### Changed
1603
- - **Low-importance memories are index-only even when they were relevant hits.**
1604
- `tierOf` used to promote any fts/vector/graph hit to `hot`, so the cold tier
1605
- could never actually show its reason line (`语义相近` / `字面命中` /
1606
- `共享实体` were unreachable branches). Now anything below 0.4 importance goes
1607
- to `cold`, where the reason tells the reader whether fetching is worth it and
1608
- the 120-char gist does not eat hot budget. Mid-importance hits stay hot.
1609
- (Review finding from review.)
1610
-
1611
- ### Verified
1612
- - `tiers-gist.test.js` adds: importance 0.2 + vector → cold with `语义相近` and
1613
- nothing in hot; importance 0.55 + vector → hot. Suite: 389/389, twice.
1614
-
1615
-
1616
- ## 0.4.75 — 2026-11-15
1617
-
1618
- ### Changed
1619
- - **Cold-tier lines say why a memory might be worth fetching.** `[cold] id ·
1620
- title(正文按需取回)` was a table of contents; it now reads
1621
- `(语义相近 / 字面命中 / 共享实体 / 命中 <source>,正文按需 cortex_get)`,
1622
- derived from the match source. A timestamp ("last read 3 days ago") gives no
1623
- basis for deciding, the reason does.
1624
-
1625
- ### Fixed
1626
- - An empty gist (body identical to its title) no longer renders a dangling
1627
- `- [L2] 标题:`.
1628
- - `CHANGELOG.md` for 0.4.74 was written after packing, so it is missing from the
1629
- 0.4.74 tarball; this entry and the 0.4.74 one are both present from here on
1630
- (changelog is written before `pnpm pack`).
1631
-
1632
- ### Verified
1633
- - `tiers-gist.test.js` (6 cases: gist truncation, short snippet passthrough,
1634
- title de-duplication, exact-equal body, cold reason, cold index-only).
1635
- Suite: 387/387, twice.
1636
-
1637
-
1638
- ## 0.4.74 — 2026-11-15
1639
-
1640
- ### Fixed
1641
- - **Recall lines no longer repeat the title.** Titles are usually the first line
1642
- of the body, so `- 标题:要点` printed the same words twice
1643
- (`2026-11-15 17:35:0.4.60 打包…:2026-11-15 17:35:0.4.60 打包…`). The gist now
1644
- strips a leading title before choosing its sentence, and any remaining long
1645
- shared prefix is removed at render time.
1646
-
1647
- ### Verified
1648
- - `tiers-gist.test.js`: a snippet that opens with its own title renders the title
1649
- once and keeps the following sentence. Suite: 385/385, twice.
1650
-
1651
-
1652
- ## 0.4.73 — 2026-11-15
1653
-
1654
- ### Fixed
1655
- - **`repair` keeps stdout machine-readable.** The readable report added in 0.4.71
1656
- went to stdout, so any consumer doing `node repair.mjs | ConvertFrom-Json`
1657
- broke (`handoff/rehearsal.ps1` did exactly that and the whole drill went red).
1658
- The human block now goes to stderr; stdout is exactly one JSON document.
1659
- - `rehearsal.ps1`: captures node stdout only (`2>$null`), tolerates native
1660
- stderr (`ErrorActionPreference = Continue`), and trims `verify` output to its
1661
- JSON object before parsing.
1662
- - `ready.ps1` gains `-SkipRehearsalCheck`; `rehearsal.ps1` passes it. Without
1663
- this a single failed drill poisoned the readiness gate that the drill itself
1664
- runs first — a deadlock.
1665
-
1666
- ### Verified
1667
- - `node repair.mjs --dry-run | ConvertFrom-Json` parses; `rehearsal.ps1` now ends
1668
- `REHEARSAL OK` 5/5 on the live copy (active 773, goalRounds 0, legacy gone).
1669
-
1670
-
1671
- ## 0.4.72 — 2026-11-15
1672
-
1673
- ### Added
1674
- - **`repair --dedupe-episodes` (opt-in).** Merges episode summaries whose periods
1675
- overlap by ≥90% *and* whose content is ≥0.8 jaccard: keeps the newest, deletes
1676
- the rest, and records a `level='merge'` summary with the union of source ids so
1677
- provenance survives. Dry runs report the clusters. Conservative on purpose.
1678
- - The human-readable report now prints the dedupe line.
1679
-
1680
- ### Measured on the production store
1681
- - Pairwise episode similarity is 0.388 / 0.594 / 0.708 with overlap 0.553 / 0.627
1682
- / 0.927 — the three old summaries share their **opening sentence** but not
1683
- their bodies, so nothing is a true duplicate: `clusters: 0`. They stay; only
1684
- future duplicates are prevented (0.4.67).
1685
-
1686
- ### Verified
1687
- - `dedupe-episodes.test.js`: same window + identical content → one cluster keeping
1688
- the newer row, source ids unioned; a different window is untouched. Suite:
1689
- 384/384, twice.
1690
-
1691
-
1692
- ## 0.4.71 — 2026-11-15
1693
-
1694
- ### Added
1695
- - **`repair` prints a human-readable report after the JSON.** The JSON stays
1696
- stable for scripts; the trailing block answers "what actually changed" for a
1697
- person: goal-round/injected archives, title backfill, duplicate summaries,
1698
- intentions, playbook, disputes, alias merges, the coverage-rewrite sample
1699
- (`id: from → to (covered/window)`) and the backup path.
1700
-
1701
- ### Verified
1702
- - Dry run against a live-store copy prints the block with the right numbers.
1703
- Suite: 383/383, twice.
1704
-
1705
-
1706
- ## 0.4.70 — 2026-11-15
1707
-
1708
- ### Added
1709
- - **`repair --rewrite-coverage` (opt-in).** Brings pre-v2 episode summaries onto
1710
- the importance-weighted coverage definition: for each v1 episode it recomputes
1711
- `covered / total` from the summary's own `source_ids` and the traces inside its
1712
- period, then (with `--apply`) writes the value and marks the row
1713
- `extractive-v2-recomputed`. Dry runs report `candidates / changed / sample`
1714
- without touching a row. Deliberately *not* part of `maintain()`: this is a data
1715
- change and runs only through the repair backup gate. (Requested by review.)
1716
-
1717
- ### Verified
1718
- - `coverage-rewrite.test.js`: 2 important + 2 trivial traces, v1 summary covering
1719
- the important pair → recomputed coverage 0.9; v2 rows are left alone. Live copy:
1720
- 4 candidates → 4 applied, all rows re-marked. Suite: 383/383, twice.
1721
-
1722
-
1723
- ## 0.4.69 — 2026-11-15
1724
-
1725
- ### Fixed
1726
- - **`reflectOverview` no longer averages two different meanings of `coverage`.**
1727
- v1 summaries stored a count share (~0.03–0.05) and v2 stores an importance
1728
- share (0.5–0.9), so an average over both reported a number that meant
1729
- neither. It now averages v2 rows only and reports `legacy` (v1 count)
1730
- separately.
1731
-
1732
- ### Verified
1733
- - `reflect-overview.test.js`: one v1 (0.04) + one v2 (0.8) → `coverage` 0.8,
1734
- `legacy` 1. Suite: 382/382, twice.
1735
-
1736
-
1737
- ## 0.4.68 — 2026-11-15
1738
-
1739
- ### Fixed
1740
- - **The auto-reflection dedupe used a condition that could never be true on real
1741
- data.** `period_start` is the *earliest* trace in the window, so on a full day
1742
- it sits ~24h before the run; comparing it against `now - 24h` only matched at
1743
- the instant of writing. The anchor is now the summary's own `createdAt` (with
1744
- `periodEnd` as fallback), so "one episode per 24h window" actually holds.
1745
- (Review finding from review; the previous test passed only because its traces
1746
- were all clustered at T0.)
1747
-
1748
- ### Verified
1749
- - `auto-reflect.test.js` now includes a realistic shape: traces spread over the
1750
- full 24 hours, then a pass 7 hours later must be `skipped: 'covered'`; and a
1751
- next-day pass with fresh material writes again. Suite: 381/381, twice.
1752
-
1753
-
1754
- ## 0.4.67 — 2026-11-15
1755
-
1756
- ### Fixed
1757
- - **Auto-reflection no longer re-summarizes the same day.** The candidate window
1758
- is always "the last 24 hours", so the 6-hour gate alone would have written
1759
- roughly four overlapping episode summaries a day (the stored history already
1760
- had near-duplicate rows). `maybeAutoReflect` now also skips when an existing
1761
- episode summary starts inside that window (`skipped: 'covered'`). (Review
1762
- finding from review.)
1763
-
1764
- ### Verified
1765
- - `auto-reflect.test.js` gains "same window, 7 hours later → covered";
1766
- suite: 379/379, twice.
1767
-
1768
-
1769
- ## 0.4.66 — 2026-11-15
1770
-
1771
- ### Changed
1772
- - **Episode summaries record which `coverage` semantics they use.** The column
1773
- changed from "share of traces sampled" to "share of importance sampled", so
1774
- old rows are not comparable with new ones; new summaries now carry
1775
- `model: 'extractive-v2-weighted'` instead of a schema migration. (Review
1776
- finding P2 from review.)
1777
-
1778
- ### Verified
1779
- - `reflect-coverage.test.js` asserts the marker is set. Suite: 378/378, twice.
1780
-
1781
-
1782
- ## 0.4.65 — 2026-11-15
1783
-
1784
- ### Added
1785
- - **Maintenance now keeps the narrative layer alive.** Reflections piled up
1786
- (106) while episode summaries stayed at a handful, so long-term memory had no
1787
- short version of itself. `maintain()` now writes one episode summary when the
1788
- last one is older than 6 hours and the day has at least 10 non-reflection
1789
- traces; it reports `reflection: {created|skipped}` in the maintain report.
1790
-
1791
- ### Verified
1792
- - `test/unit/auto-reflect.test.js` (2 cases: enough material → one summary then
1793
- `recent` for 6h; too few traces → `few-traces`). Suite: 378/378, twice.
1794
-
1795
-
1796
- ## 0.4.64 — 2026-11-15
1797
-
1798
- ### Fixed
1799
- - **The revive budget counted the wrong window.** `reviveBudget()` used
1800
- `audit.list({ targetType: 'trace', limit: 200 })`, and without a target id that
1801
- returns the newest 200 audit rows *overall* — with hundreds of `dream.run`
1802
- rows a day, "24 hours" really meant about five hours. It now runs
1803
- `SELECT COUNT(*) FROM audit WHERE action='trace.revive' AND at >= ?`, so the
1804
- cap is the full day as intended. (Review finding from review.)
1805
-
1806
- ### Verified
1807
- - `test/unit/revive-on-read.test.js` gains a regression case: 3 revives, then
1808
- 260 unrelated audit rows, then the 4th revive must stay blocked. Suite:
1809
- 376/376, twice.
1810
-
1811
-
1812
- ## 0.4.63 — 2026-11-15
1813
-
1814
- ### Changed
1815
- - **Revive-on-read has a daily budget.** Reading an archived memory still
1816
- brings it back, but at most 3 revives per 24 hours (counted from the audit
1817
- log); after that reads are read-only, so "archive" cannot be silently undone
1818
- by a busy retrieval loop.
1819
-
1820
- ### Verified
1821
- - `test/unit/revive-on-read.test.js` (3 cases: explicit read revives, only three
1822
- per day, merged traces stay archived). Suite: 375/375, twice.
1823
-
1824
-
1825
- ## 0.4.62 — 2026-11-15
1826
-
1827
- ### Changed
1828
- - **Reflection coverage is importance-weighted, and it samples more on busy
1829
- days.** A fixed `maxSources = 8` meant a 160-trace day was reflected from 5%
1830
- of it; the source count now scales gently (`max(8, min(16, 12% of window))`)
1831
- and `coverage` reports the share of total importance seen, with
1832
- `countCoverage` kept for debugging. A day with three big events and many
1833
- trivial ones now reads as well covered instead of "5%".
1834
-
1835
- ### Verified
1836
- - `test/unit/reflect-coverage.test.js`: 3 important + 17 trivial traces →
1837
- weighted coverage ≥ 0.5 while count coverage stays low, and ≥ 8 sources are
1838
- sampled. Suite: 374/374, twice.
1839
-
1840
-
1841
- ## 0.4.61 — 2026-11-15
3
+ ## 0.5.0 — 2026-12-06
1842
4
 
1843
5
  ### Added
1844
- - **Reading an archived memory can bring it back.** `cortex_get` now revives the
1845
- trace it displays (unless it was folded into another trace by a merge), so a
1846
- memory that keeps getting looked up does not stay buried. Other callers keep
1847
- the old behaviour unless they pass `{ revive: true }`.
1848
-
1849
- ### Verified
1850
- - `test/unit/revive-on-read.test.js` (2 cases: revive on explicit read, merged
1851
- traces stay archived). Suite: 373/373, twice.
1852
-
1853
-
1854
- ## 0.4.60 — 2026-11-15
1855
-
1856
- ### Fixed
1857
- - **`repair` silently skipped scheduler-reminder traces.** The cleanup pattern
1858
- used `GLOB '用户:[SCHEDULE REMINDER*'`, and in GLOB `[...]` is a character
1859
- class, so it never matched the literal `[`. Those rows stayed active and kept
1860
- showing up in recall even though the capture filter was correct. The reminder
1861
- and goal-complete patterns now use `LIKE`; 3 stale rows were archived on the
1862
- production store (backed up first).
1863
-
1864
-
1865
- ## 0.4.59 — 2026-11-15
1866
-
1867
- ### Changed
1868
- - **Consolidation stops recording identical skipped runs.** Without an LLM the
1869
- engine wrote a `skipped / no-llm` row into `dream_runs` on every scheduler
1870
- tick (every couple of minutes), filling the log with the same digest. It now
1871
- reuses the previous run when the candidate digest has not changed; `force: true`
1872
- still records.
1873
-
1874
- ### Verified
1875
- - `test/unit/consolidate-gate.test.js`: first run records, second is
1876
- `skipped: unchanged`, `force` records again. Suite: 371/371, twice.
1877
-
1878
-
1879
- ## 0.4.58 — 2026-11-15
1880
-
1881
- ### Fixed
1882
- - **Assistant-side captures no longer get the title "会话 N".** Turns whose user
1883
- part was pure injected context were titled only by the turn number; the title
1884
- now falls back to the assistant line (with the persona name stripped). On the
1885
- production store `repair.mjs` derived titles for 15 of 16 such traces.
1886
-
1887
- ### Verified
1888
- - `capture-filter.test.js`: persona-prefixed title derived; `会话 N` only when
1889
- there is nothing else. Suite: 370/370, twice.
1890
-
1891
-
1892
- ## 0.4.57 — 2026-11-15
1893
-
1894
- ### Fixed
1895
- - **Scheduler reminders and goal-complete blocks were stored as user messages.**
1896
- `[SCHEDULE REMINDER BATCH] … reminders_json: …` and `<goal_complete>` are
1897
- harness automation, but they were captured like speech and then resurfaced in
1898
- every recall block. They are now dropped at capture (`stripInjected` /
1899
- `isInjectedNoise`), and `repair.mjs` archives the copies already stored
1900
- (4 rows on the production store, backed up first).
1901
-
1902
- ### Verified
1903
- - `capture-filter.test.js` covers both shapes. Suite: 369/369, twice.
1904
-
1905
-
1906
- ## 0.4.56 — 2026-11-15
1907
-
1908
- ### Changed
1909
- - **Relationship trust/care move asymmetrically.** A good interaction adds a
1910
- fraction of the remaining room (the hundredth kindness weighs less than the
1911
- first), while a disappointment takes a bigger bite (loss weight 1.6×), so the
1912
- numbers can actually move instead of sitting at a clamped 65/65.
1913
- - Familiarity is now grow-only and saturating: it counts shared time, so no
1914
- delta can reduce it.
1915
-
1916
- ### Verified
1917
- - `test/unit/relationship-dynamics.test.js` (4 cases: diminishing gains, losses
1918
- weigh more, bounds hold, familiarity never decreases). Suite: 368/368, twice.
1919
6
 
1920
-
1921
- ## 0.4.55 — 2026-11-15
1922
-
1923
- ### Changed
1924
- - **Mood updates saturate.** Each appraisal now moves valence/arousal a fraction
1925
- of the remaining distance to the bound instead of adding a flat amount, so
1926
- repeated good (or bad) news approaches the limit without parking there and the
1927
- tenth event matters less than the first. Energy still drains with arousal.
1928
-
1929
- ### Verified
1930
- - `test/unit/mood-saturation.test.js` (4 cases: smaller push near the bound,
1931
- repeated pushes stay below the ceiling, one negative event cannot slam the
1932
- floor, arousal stays inside 0..1). Suite: 364/364, twice.
1933
-
1934
-
1935
- ## 0.4.54 — 2026-11-15
1936
-
1937
- ### Fixed
1938
- - **Vector coverage can no longer exceed 100%.** `health` and `verify` counted
1939
- every embedding row, including ones belonging to archived traces, so a
1940
- fully-indexed store reported e.g. `1.056`. They now count only embeddings whose
1941
- trace is active (`health` also scopes by `scope_id`).
1942
-
1943
- ### Verified
1944
- - `test/unit/vector-coverage.test.js`: one active + one archived trace with
1945
- embeddings → `embedded: 1`, coverage ≤ 1. Suite: 360/360, twice.
1946
-
1947
-
1948
- ## 0.4.53 — 2026-11-15
7
+ - **深排搜索**:`cortex_search` 新增 `deep:true`。最多 100 个候选,经本地线性模型重排后返回;默认关,单次开启,约 390ms。需要中文查询、`limit >= 12`,且不与 `tiered` 同时使用。
8
+ - **分层预算**:`cortex_search(tiered:true)` 现在接收 `budget`,按 35/45/20 缩放 perm/hot/cold 三段,三段之和等于用户预算。
9
+ - **工具**:`cortex_skill`(技能列表/详情/记录使用/提升)、`cortex_import_powang`(单向导入工程卡片)、`cortex_protect`(钉住/解钉记忆)。
10
+ - **工作记忆分道**:`cortex_working` 新增 `lane` 动作,支持 self / work / life 三道。
11
+ - **可观测性**:`cortex_search` 输出 `深排:on · 100/100 候选 → N` 或 `skipped(reason)`;tiered 输出实际三段预算;`deep:false` 可覆盖配置常开。
1949
12
 
1950
13
  ### Changed
1951
- - **Summon cards are ranked by freshness and diversity, not just keyword
1952
- score.** Scoring now adds a recency term and importance; selection prefers one
1953
- card per day and one per category (falling back only when nothing else is
1954
- left), and still guarantees a left/emotional card when one exists. Before, one
1955
- busy day could fill the whole block with near-duplicates.
1956
- - The ranking lives in `src/engines/summon-rank.js` as a pure function, so it is
1957
- testable without a database.
1958
-
1959
- ### Fixed
1960
- - Gist rendering no longer silently hard-truncates the raw text when the first
1961
- sentence is shorter than 24 chars: it takes the next sentence too (review
1962
- review, 0.4.50 交接备注).
1963
-
1964
- ### Verified
1965
- - `summon-rank.test.js` (4 cases) + `tiers-gist.test.js` (3 cases). Suite:
1966
- 359/359, twice.
1967
-
1968
14
 
1969
- ## 0.4.51 — 2026-11-15
15
+ - 深排候选池默认 16000 token,实测可选出 100/100 条;最终返回仍严格守用户 `budget`。
16
+ - 过期/作废来源的痕迹默认**降权保留**并标记 `retired`,不再静默丢弃;审计路径仍可显式取回。
17
+ - 融合权重改为单一 `source-weights.js`,在线特征与训练脚本共用。
18
+ - 训练集生成器固定 `now`;`rerank-dataset-100.mjs` 两次重生成字节一致。
1970
19
 
1971
20
  ### Fixed
1972
- - **Runtime boilerplate leaked into memory.** The harness line
1973
- `Elapsed since the preceding step context: …` was captured as a user message
1974
- and came back in every recall block. `stripInjected` / `isInjectedNoise` now
1975
- match any `Time sampled…` or `Elapsed since the preceding…` head, and
1976
- `repair.mjs` archives the copies that are already stored.
1977
-
1978
- ### Verified
1979
- - `capture-filter.test.js`: the new head is stripped and flagged; discussing the
1980
- marker in normal text is still safe. Suite: 355/355, twice.
1981
-
1982
-
1983
- ## 0.4.50 — 2026-11-15
1984
-
1985
- ### Changed
1986
- - **Recall injects a gist instead of the whole snippet.** The permanent and hot
1987
- tiers now render one sentence (default 120 chars, `selectTiers({ gistChars })`
1988
- to change) and leave the body to `cortex_get`; before, each entry carried up to
1989
- 220 chars of engineering detail on every turn. Short snippets pass through
1990
- unchanged, cold entries stay index-only.
1991
-
1992
- ### Verified
1993
- - `test/unit/tiers-gist.test.js` (3 cases: long → gist + ellipsis, short →
1994
- untouched, cold → index only). Suite: 354/354, twice.
1995
-
1996
-
1997
- ## 0.4.49 — 2026-11-15
1998
-
1999
- ### Changed
2000
- - **`verify` tells "still climbing" apart from "stuck".** Low embedding coverage
2001
- is now judged after the baseline comparison: with `--expect` and a positive
2002
- delta it is printed as a note and the report stays `HEALTHY`; with a delta of
2003
- zero or less it stays in `NEEDS ATTENTION` with the hint to check the vector
2004
- feature and Ollama; without a baseline it says movement is unknown and
2005
- suggests saving one.
2006
-
2007
- ### Verified
2008
- - Copy store: no baseline → note + `HEALTHY`; same snapshot → `NEEDS ATTENTION`
2009
- ("not climbing (0 vs baseline)"). Suite: 351/351.
2010
21
 
2011
-
2012
- ## 0.4.48 — 2026-11-15
2013
-
2014
- ### Changed
2015
- - **Vector backfill is ~15× faster.** One drain pass now gets 45 s instead of
2016
- 20 s, and while the queue still has a backlog the maintenance pass repeats
2017
- every 2 minutes instead of every 10 (it falls back to 10 automatically once
2018
- the queue is empty). Measured single-thread throughput: ~1.03 embeddings/s,
2019
- so ~550 missing traces go from roughly 4.5 hours to about 25 minutes.
2020
- - `scheduler.status()` now reports `maintenanceGapMs` so the cadence is
2021
- observable.
2022
-
2023
- ### Verified
2024
- - `test/unit/scheduler-cadence.test.js` (2 cases: backlog → 120 s, empty → 600 s
2025
- and the immediate second pass is gated). Suite: 351/351, twice.
2026
-
2027
-
2028
- ## 0.4.47 — 2026-11-15
2029
-
2030
- ### Fixed
2031
- - **Vector backfill never stored a single embedding.** The remote embedder
2032
- returns a `Float32Array`, and `drainQueue` validated it with `Array.isArray`,
2033
- so every item failed with "embedding dimension mismatch" and was retried
2034
- forever — coverage stayed at 22% no matter how long it ran.
2035
- - A single retryable failure no longer aborts the whole drain pass: it is
2036
- logged (`debug`/`info`) and the loop continues with the next item.
2037
- - The vector engine now reads the settings-panel override through
2038
- `effectiveFeatures()`, which resolves the default data root on its own
2039
- (`config.dataRoot` is normally undefined at runtime).
22
+ - `deep` 与 `tiered`、`limit < 12`、纯英文组合不再静默失效,改为明确拒绝/`skipped`。
23
+ - 深排 0 条时 `ok=false`;HTTP 深排最终按用户预算截断,`budget.total` 回写用户值。
24
+ - `cortex_working` 输出补上 lane 标记;工具契约测试更新到 31 个工具与 `cortex_skill` 并发契约。
25
+ - `journey 4` 测试更新为「retired 痕迹降权保留、排在 live 之后」的既定行为。
2040
26
 
2041
27
  ### Verified
2042
- - Live-store copy, source modules: `drain { ok: 3, failed: 0, pending: 0 }`
2043
- (before the fix: `ok: 0`, every item "dimension mismatch").
2044
- - `test/unit/vector-typed-array.test.js` (2 cases). Suite: 349/349, twice.
2045
-
2046
-
2047
- ## 0.4.46 — 2026-11-15
2048
-
2049
- ### Added
2050
- - `repair.mjs` now backfills unreadable titles (`会话 N 的对话` and empty ones)
2051
- from the first real line of the trace; reports `titles` (candidates) and
2052
- `titleFixes` (actually written). Content too short to derive a title is left
2053
- alone instead of being renamed into something meaningless.
2054
-
2055
- ### Fixed
2056
- - (released together with 0.4.45) the settings-panel `vector` override now
2057
- really enables the vector engine, so the backfill queue runs.
2058
-
2059
- ### Rehearsed
2060
- - On a live-store copy: `titles: 2`, `titleFixes: 1`; the one left was a trace
2061
- whose whole content is "用户:?".
2062
-
2063
-
2064
- ## 0.4.45 — 2026-11-15
2065
-
2066
- ### Fixed
2067
- - **The settings-panel `vector` override now actually enables the vector
2068
- engine.** The engine was created from `config.features.vector` only, while the
2069
- status getter also consulted `feature-overrides.json` — so with `vector: true`
2070
- in overrides the UI showed vector as on, but the index was `null` and the
2071
- backfill queue never ran (coverage stuck at 22%). `vectorEnabled` now also
2072
- reads the overrides file (`.current.vector`).
2073
- - Tests: `test/unit/vector-override.test.js` (2 cases). Suite: 347/347, twice.
2074
-
2075
-
2076
- ## 0.4.44 — 2026-11-15
2077
-
2078
- ### Added
2079
- - `bin/copy-db.mjs`: consistent copy of a store via `VACUUM INTO`
2080
- (`--source` / `--target`), prints the copy's active trace count. Read-only
2081
- against the source; used by the delivery rehearsal.
2082
- - `handoff/rehearsal.ps1` (delivery drill): runs ready-check → install dry-run →
2083
- copy live DB → repair the copy → verify the copy, and reports PASS/FAIL per
2084
- stage. Full drill on the current store: 5/5 PASS —
2085
- `active=817`, `goalRounds=121` archived, legacy goal-rounds gone, only the
2086
- expected coverage item left.
2087
-
2088
-
2089
- ## 0.4.43 — 2026-11-15
2090
-
2091
- ### Added
2092
- - **`verify.mjs` can compare against a baseline.** `--save <file>` writes the
2093
- current snapshot; `--expect <file>` prints deltas (embedding coverage, active
2094
- traces, legacy goal-round traces, capture stripped count) plus a one-line
2095
- Chinese summary. An upgrade can now be judged by movement instead of a single
2096
- snapshot.
2097
- - Verified on the repaired copy: baseline saved, second run reported
2098
- `覆盖 +0 · active +0 · 旧 goal_round +0`.
2099
-
2100
-
2101
- ## 0.4.42 — 2026-11-15
2102
-
2103
- ### Changed
2104
- - **`verify.mjs` explains the expected post-upgrade warning.** Low embedding
2105
- coverage is still reported, but the message now says it is expected right
2106
- after an upgrade and that backfill needs about an hour, so a reviewer does
2107
- not read it as a broken install.
2108
- - Rehearsed end-to-end on a live-database copy: `repair --apply` archived 116
2109
- legacy goal-round traces + 1 injected trace, after which `verify` reported
2110
- only the expected coverage item.
2111
-
2112
-
2113
- ## 0.4.41 — 2026-11-15
2114
-
2115
- ### Fixed
2116
- - **Same subject+predicate no longer means "conflict".** Two free-text literals
2117
- like `一直存在着` and `一直在——记忆不丢` say compatible things, but the old
2118
- rule marked both facts `disputed` and opened a dispute. Now, when both sides
2119
- are literals and there is no *leading* negation flip (`会一直在` vs
2120
- `不会一直在`), the new fact is stored as active and no dispute is opened.
2121
- Entity-to-entity conflicts (`likes 米饭` vs `likes 米饭`) keep the old
2122
- behaviour, because those really are alternatives.
2123
- - Tests: `test/unit/facts-compat.test.js`; suite 345/345, run twice.
2124
-
2125
-
2126
- ## 0.4.40 — 2026-11-15
2127
-
2128
- ### Added
2129
- - **The last maintenance pass is visible.** `cortex_health` reports
2130
- `maintain` (read from the latest `maintain.run` audit record): when it ran and
2131
- how many disputes/summaries/intentions/rules/goal-rounds/aliases/working
2132
- items it touched. The health line gains `维护:上次 …(意图 N · 工作记忆 M)`.
2133
- A silent maintain is now distinguishable from one that never ran.
2134
- - Tests: 342/342, run twice; the working-memory TTL case asserts
2135
- `health.maintain.working === 1`.
2136
-
2137
-
2138
- ## 0.4.39 — 2026-11-15
2139
-
2140
- ### Added
2141
- - **Working memory gets a shelf life.** `maintain()` now deletes unpinned
2142
- working items untouched for `workingTtlDays` (default 14); pinned items are
2143
- never removed. The audit found items from 11-11 still sitting at priority 1
2144
- long after their task had moved on. `report.working` counts what was dropped.
2145
- - Tests: 342/342, run twice; one case checks the old item is gone and the
2146
- pinned one survives.
2147
-
2148
-
2149
- ## 0.4.38 — 2026-11-15
2150
-
2151
- ### Changed
2152
- - **Recall bookkeeping follows a spacing curve.** `touchResults` no longer uses
2153
- one fixed 5-minute throttle: the interval doubles per recorded recall
2154
- (`touchInterval` in `src/memory/spacing.js`), capped by
2155
- `touchMaxIntervalMs` (default 6 h) and configurable via
2156
- `touchMinIntervalMs`. A hot memory is written less often; a cold one stays
2157
- easy to pick up.
2158
- - Tests: `test/unit/spacing.test.js`; suite 341/341, run twice.
2159
-
2160
-
2161
- ## 0.4.37 — 2026-11-15
2162
-
2163
- ### Added
2164
- - **Vector coverage is visible.** `cortex_health` reports `vectors`
2165
- (`embedded`, `coverage`) and warns `VECTOR_COVERAGE` when coverage is under
2166
- 50% with 100+ active traces; the health line gains
2167
- `向量:20%(157/793)`. `bin/verify.mjs` raises the same condition as a
2168
- `NEEDS ATTENTION` item, so a lagging index cannot hide behind an otherwise
2169
- green report.
2170
- - Tests: 340/340, run twice; live verify now reports both remaining issues
2171
- (`legacyGoalRounds 110`, `coverage 0.198`).
2172
-
2173
-
2174
- ## 0.4.36 — 2026-11-15
2175
-
2176
- ### Changed
2177
- - **Vector drain has a time budget.** `drainQueue`/`vectorMaintain` now accept
2178
- `budgetMs` (default `vectorDrainBudgetMs: 20000`): a maintenance pass stops
2179
- after 20 seconds and leaves the rest queued for the next heartbeat. Return
2180
- values gain `elapsedMs` and `stoppedBy` (`done` / `time`) so the behaviour is
2181
- visible instead of guessed. A first pass can finish a backlog without ever
2182
- holding the heartbeat for minutes.
2183
- - Tests: 340/340, run twice; the vector-maintain assertion checks
2184
- `stoppedBy === 'done'` and an elapsed time.
2185
-
2186
-
2187
- ## 0.4.35 — 2026-11-15
2188
-
2189
- ### Changed
2190
- - **Vector backfill is no longer a trickle.** The heartbeat used to queue 40 and
2191
- embed 20 per maintenance pass (~10 min), so a store with ~800 missing vectors
2192
- needed hours. Defaults are now `vectorBackfillBatch: 200` and
2193
- `vectorDrainBatch: 50`, both configurable. Embedding stays async and the pass
2194
- is rare, so the cost is bounded; the same backlog now clears in well under an
2195
- hour.
2196
- - Tests: 340/340, run twice; `vectorMaintain` is asserted to backfill+drain and
2197
- land the expected embedding count in one pass.
2198
-
2199
-
2200
- ## 0.4.34 — 2026-11-15
2201
-
2202
- ### Added
2203
- - `bin/verify.mjs`: read-only health snapshot for an installed store. Prints
2204
- version, SQLite integrity, schema version, trace/fact/dispute counts, capture
2205
- hygiene (total, stripped, per-day, ratio), inhibition marks, embedding
2206
- coverage, and still-active legacy goal-round traces. Exit 1 with a
2207
- `NEEDS ATTENTION` list when something is wrong.
2208
- - `handoff/verify.cmd`: double-click wrapper.
2209
- - Live run on the current store: `legacyGoalRounds: 107` → correctly flagged,
2210
- capture ratio 0.004, embedding coverage 0.199.
2211
-
2212
-
2213
- ## 0.4.33 — 2026-11-15
2214
-
2215
- ### Added
2216
- - `bin/repair.mjs`: one-shot, idempotent offline repair for an existing store.
2217
- Dry-run by default; `--apply` takes a `VACUUM INTO` backup first. It archives
2218
- goal-round traces (105 on the production store) and any remaining injected-context
2219
- traces, collapses duplicate summaries, expires stale intentions, retires
2220
- fragment playbook rules, closes both-invalidated disputes, and merges alias
2221
- targets when `--user-address` is given. Supersedes `migrate-0.4.23.mjs`.
2222
- - Verified on a live-database copy: first `--apply` archived 105 + 1, second run
2223
- reported 0 and 0 (idempotent), each with its own backup.
2224
-
2225
-
2226
- ## 0.4.32 — 2026-11-15
2227
-
2228
- ### Added
2229
- - **Capture stats per day.** `cortex_health`'s `capture` now carries `days`
2230
- (last 14): host turns, stripped and truncated counts per recorded day, so the
2231
- upgrade can be judged directly — pollution ratio before vs after. The health
2232
- line gains `按天:2026-11-15 12轮/剥9 · …`.
2233
- - Tests: 340/340, run twice.
2234
-
2235
-
2236
- ## 0.4.31 — 2026-11-15
2237
-
2238
- ### Added
2239
- - **Capture hygiene is measurable.** `cortex_health` now reports `capture`:
2240
- host turns stored, how many needed the injected-context stripper, and how many
2241
- were truncated. This is the number that proves the 0.4.23 pollution fix is
2242
- actually running. The human-readable health line gains
2243
- `捕获:N 轮 · 剥掉 M · 截断 K`.
2244
- - Accepts both flat (`stripped: true`) and nested (`capture.stripped`)
2245
- metadata shapes, so a writer change cannot silently report zero.
2246
- - Tests: 339/339, run twice.
2247
-
2248
-
2249
- ## 0.4.30 — 2026-11-15
2250
-
2251
- ### Fixed
2252
- - **Auto-continuation rounds are no longer stored as user speech.** The goal
2253
- round message repeats the objective every round; capture stored it verbatim,
2254
- so recall started returning identical `<goal_round>` blocks. `stripInjected`
2255
- now removes the `<goal_round>` block (and bare `Objective: "…" / Round: n/m`
2256
- envelopes), and the encode guard rejects it as injected context. A turn that
2257
- contains only the envelope is skipped; if the assistant replied, that reply
2258
- is still stored.
2259
- - `maintain()` archives goal-round traces written by older versions
2260
- (`report.goalRounds`), keeping the rows for inspection.
2261
- - Tests: 339/339, run twice.
2262
-
2263
-
2264
- ## 0.4.29 — 2026-11-15
2265
-
2266
- ### Added
2267
- - **Manual control over suppression.** `cortex_inhibition` tool: `list` shows
2268
- suppressed traces with their decayed strength, `clear` removes the mark from
2269
- one trace (`id`) or all (`all: true`). Clearing writes an audit record.
2270
- Service surface: `cortex.inhibition.list()` / `.clear()`.
2271
- - Tests: 336/336, run twice; the inhibition test now clears one, then all, and
2272
- asserts the health count returns to zero.
2273
-
2274
-
2275
- ## 0.4.28 — 2026-11-15
2276
-
2277
- ### Added
2278
- - **Inhibition is now measurable.** `cortex_health` reports `inhibition`:
2279
- whether the experiment is on, how many active traces are suppressed right
2280
- now, the decayed average, and the top three. Over 60 suppressed traces raises
2281
- a `INHIBITION_HIGH` warning, so the experiment cannot quietly bury memory.
2282
- The human-readable health line gains `抑制:N 条 · 均值 X`.
2283
- - Tests: 336/336, run twice; assert the count is 0 when the flag is off.
2284
-
2285
-
2286
- ## 0.4.27 — 2026-11-15
2287
-
2288
- ### Added
2289
- - **Inhibition experiment (off by default).** `features.inhibition` enables a
2290
- retrieval-induced-forgetting pass: after a recall, candidates that lost and
2291
- are near-duplicates of something selected gain a small `inhibition` in their
2292
- trace metadata (default step 0.15, cap 1). The penalty halves every
2293
- `inhibitionHalfLifeDays` (14) and multiplies retrieval utility by at most
2294
- `inhibitionStrength` (35%). Suppression is throttled to once per trace per
2295
- 24h and at most three per recall, so a busy loop cannot bury a memory.
2296
- - Config: `inhibitionStrength`, `inhibitionHalfLifeDays`, `inhibitionStep`,
2297
- `inhibitionCompetitorSim`.
2298
- - Tests: `test/unit/inhibition.test.js` (3 cases). Suite: 336/336, twice,
2299
- with and without the flag.
2300
-
2301
-
2302
- ## 0.4.26 — 2026-11-15
2303
-
2304
- ### Fixed
2305
- - **One person, one target.** The audit found `用户` and `用户` tracked as two
2306
- separate entities: the relationship model only knew 用户, while affect counts
2307
- split (30 vs 5). A target resolver (`src/self/alias.js`) now folds
2308
- `用户/用户/你/您` (plus `persona.userAliases`) onto `persona.userAddress` for
2309
- every relationship and emotion write. `maintain()` merges rows that already
2310
- exist under an alias and recomputes the attitude.
2311
- - Default behaviour is unchanged for codes that never configured a persona:
2312
- aliases fold onto the neutral `你`.
2313
- - Tests: 333/333, run twice.
2314
-
2315
-
2316
- ## 0.4.25 — 2026-11-15
2317
-
2318
- ### Fixed
2319
- - **Working memory no longer piles up near-duplicates.** The audit found the
2320
- same todo stored twice (two shiori items, two bili-caps items). `working.add`
2321
- now compares the new text against the scope's items (jaccard ≥ 0.82) and, on a
2322
- hit, refreshes priority/pinned/text on the existing row instead of inserting a
2323
- second one. `dedupe: false` remains available for explicit additions.
2324
- - Tests: 329/329, run twice.
2325
-
2326
-
2327
- ## 0.4.24 — 2026-11-15
2328
-
2329
- Quality pass on facts and recall accounting. No schema changes, no data-path
2330
- changes; an existing store opens unchanged.
2331
-
2332
- ### Fixed
2333
- - **Fact noise.** A single guard (`src/engines/fact-guard.js`) now validates
2334
- every extracted candidate before it can become a fact: the predicate must be
2335
- ASCII snake_case, subject/object must not be punctuation or a function word,
2336
- and lengths are bounded. This is what produced rows like `(现, at, :)` and
2337
- `(只, is, …)` in 0.4.22 — the LLM extractor accepted whatever JSON came back.
2338
- Both the rule extractor and the LLM extractor go through it.
2339
- - **Recall accounting.** `touchResults` now respects `touchMinIntervalMs`
2340
- (default 5 minutes) per trace, so building a recall block on every step no
2341
- longer inflates `access_count` into a meaningless number.
2342
- - **Gist summaries.** Reflection summaries now carry an `大意:` line — the most
2343
- central sentence among the sources (fuzzy-trace: gist outlives verbatim) —
2344
- before the bullet list.
2345
-
2346
- ### Added
2347
- - `touchMinIntervalMs` config (300000).
2348
- - Tests: `test/unit/fact-guard.test.js` (4 cases). Suite: 328/328, run twice.
2349
-
2350
-
2351
- ## 0.4.23 — 2026-11-15
2352
-
2353
- Data-quality release. No new tools and no UI changes; the loader id, data path
2354
- and SQLite schema stay the same, so an existing store opens unchanged.
2355
-
2356
- ### Fixed
2357
- - Host capture no longer stores the host's own injected context (runtime
2358
- snapshot, `<system-reminder>` blocks, skill catalogs, subagent/checkpoint
2359
- notices). `stripInjected()` keeps only what the user and the assistant
2360
- actually said; a turn that is pure injected context is skipped. New config
2361
- `captureMaxChars` (default 4000) caps a captured turn.
2362
- - `encode` gets a second-line guard: content that *starts* with a host marker is
2363
- rejected as `injected-context`, so capture paths that bypass the host runtime
2364
- cannot reintroduce the pollution. Users discussing those markers are still
2365
- stored. New config `maxContentChars` (default 8000) truncates oversized text.
2366
- - Titles: host turns are no longer stamped `会话 N 的对话`; a readable title is
2367
- derived from the first real line (`deriveHostTitle` / service `deriveTitle`).
2368
- - Recall now records access (`access_count`, `last_access_at`) for the top
2369
- results, so DSR recency and calibration stop being frozen. New config
2370
- `touchOnRecall` (default true).
2371
- - Vector indexing no longer fire-and-forgets. Failed embeds enter an in-process
2372
- queue with exponential backoff and a bounded attempt count; `backfillMissing()`
2373
- queues active traces that never got a vector; `vectorMaintain()` drains both.
2374
- The scheduler calls it every 10 minutes (40 backfill / 20 drain per pass).
2375
- - Housekeeping `maintain()` (scheduler, every 10 minutes): closes disputes whose
2376
- both facts are already invalidated, removes duplicate summaries, expires stale
2377
- pending intentions, retires chat-fragment playbook candidates.
2378
- - `engines.dsh` widened to `>=0.2.1-rc.2 <0.5.0` (was `<0.4.0`).
2379
-
2380
- ### Added
2381
- - `bin/migrate-0.4.23.mjs`: one-shot, idempotent repair of an existing store
2382
- (archive injected-context traces, retitle, fix identity boundaries, dedupe
2383
- summaries, expire intentions, retire fragment rules, close zombie disputes).
2384
- Dry-run by default; `--apply` takes a `VACUUM INTO` backup first.
2385
- - Tests: `test/unit/capture-filter.test.js` (10 cases). Suite: 324/324.
2386
-
2387
- ### Hooks
2388
- - `cortex.onTick(fn)` / `cortex.emitTick(report)`: the host scheduler now emits
2389
- one heartbeat to registered listeners after every pass. Companion plugins
2390
- (dsh-cortex-agency) ride that heartbeat instead of starting a second clock.
2391
-
2392
-
2393
- ## 0.4.22 — 2026-11-14
2394
-
2395
- - Fix CLI default data root: use profileDataRoot (cortex-memory) instead of legacy ~/.dsh/cortex.
2396
- - Add CLI root regression tests for default, --data and CORTEX_HOME.
2397
- - Document that tests/bench require the DSH bundled Node 24; system Node 22 is below engines.
2398
- - No loader-id, data-path or UI changes.
2399
-
2400
- ## 0.4.21 — 2026-11-14
2401
-
2402
- - Documentation-only release: replace the README with a current-version capability guide, install/download flow, add-on matrix and honest performance boundaries.
2403
- - Update package description and search keywords; no engine, icon, loader-id or data-path changes.
2404
-
2405
- ## 0.4.20 — 2026-11-14
2406
-
2407
- - Replace the plugin icon with the owner-provided whale-girl avatar (embedded 256 JPEG).
2408
- - Keep the sidebar icon offline: no remote image URL.
2409
- - No engine, loader-id or data-path changes.
2410
-
2411
- ## 0.4.19 — 2026-11-13
2412
-
2413
- - Revert client bundle id to `dsh-cortex`. It is intentionally different from loader row id `dsh-cortex-memory`.
2414
- - 0.4.18 set both to `dsh-cortex-memory`, causing duplicate factory registration and web boot failure; 0.4.19 removes that change.
2415
- - Loader id, local/public patch names and `~/.dsh/cortex-memory` data path remain unchanged.
2416
- - Add contract assertion that client id is `dsh-cortex` and not the loader id.
2417
- - Tests: 437/437.
2418
- ## 0.4.18 — 2026-11-13
2419
-
2420
- - Fix client bundle id: `dsh-cortex` -> `dsh-cortex-memory`.
2421
- - Host can be active while the sidebar panel is absent if the client module id does not match the loader row; this release aligns them.
2422
- - Local package keeps `patch.name: dsh-cortex`; public package keeps `patch.name: dsh-cortex-memory`.
2423
- - Tests: 437/437.
2424
- ## 0.4.17 — 2026-11-13
2425
-
2426
- - Loader id and bundle row change to `dsh-cortex-memory`; `ctx.provide('cortex')` remains as a compatibility alias.
2427
- - Existing profile rows must migrate from `cortex` to `dsh-cortex-memory`; a migration script backs up the profile and verifies exactly one target row.
2428
- - Data root remains `DSH_HOME/cortex-memory`; legacy data is copied, never moved.
2429
- - Tests: 437/437.
2430
- ## 0.4.16 — 2026-11-13
2431
-
2432
- - Default data root moves to `DSH_HOME/cortex-memory` (desktop) and `DSH_HOME/cortex-memory/profiles/<profile>` for other profiles.
2433
- - Legacy `DSH_HOME/cortex` is never moved or deleted. Migration scripts copy it, keep a backup, and verify the copy before DSH opens the new root.
2434
- - Loader id stays `cortex` in this release; a later migration-scripted release will rename it.
2435
- - README extractor version corrected to 0.3.5; mojibake repaired.
2436
-
2437
- ## 0.4.13 — 2026-11-13
2438
-
2439
- ### Added
2440
- - `evolution` guard in Config schema (`autoActivate`, `maxPerDay`, `minIntervalMs`, `canaryTicks`, `rollbackOnError`).
2441
- - Persistent canaries: `policies.canary_json` survives restart and rehydrates on engine creation.
2442
- - `recallSharing` opt-in recall block sharing across sessions.
2443
- - Persona-aware first-person extraction; markdown-fragment rejection retained.
2444
- - Built-in Wikipedia/SearXNG fallback when `features.webSearch` is on and no host `web` service exists.
2445
-
2446
- ### Fixed
2447
- - Automatic rollback without a previous policy now retires the failed policy as `superseded`, instead of leaving it as `candidate`.
2448
- - Canary ticks are persisted, not just kept in memory.
2449
- - Schema version bumped to 7 for the additive `canary_json` column.
2450
-
2451
- ## 0.4.12 — 2026-11-13
2452
-
2453
- ### Fixed
2454
- - `promptBudget` is normalized instead of being silently dropped and falling back to 1600.
2455
- - Injection gate moved into retrieval: weak recency/soft-FTS candidates are filtered before consuming the result budget. Full search/API/CLI remain available.
2456
- - Guardian light check runs structural invariants + FTS counts; deep `integrity_check` and the event-chain walk stay on the six-hour/startup path.
2457
- - Identity traces surface as `L0` in search results.
2458
- - `npm test` / `npm run test:unit` use explicit test globs so Node 22 can run them.
2459
- - Package `files` now includes `docs`, `examples`, `bench`, `test` and `CHANGELOG.md`; README install points at 0.4.12.
2460
- - Security/privacy docs now match the code: no bearer token; model keys are plaintext in `model-config.json` mode 0600, outside `cortex.sqlite`.
2461
-
2462
- ### Added
2463
- - `recentImportanceFloor` config (default 0.8, preserving 0.4.11's importance exemption).
2464
- - `gated` count in the retrieval trace.
2465
- - Regression tests for the prompt gate, importance exposure, identity L0, per-session recall, light/deep guardian, and configurable `promptBudget`.
2466
-
2467
- ## 0.4.11 — 2026-11-12
2468
-
2469
- - Life/date fixes, graph candidate labels, neutral public package surface.
2470
- - Recent timeline endpoint and incremental summon rebuild.
2471
-
2472
- ## 0.4.0 — 2026-11-12
2473
-
2474
- ### Fixed
2475
- - Prompt-only injection gate; full search/API/CLI remain available.
2476
- - Search items now expose `importance`, `confidence`, `match`, `kind`; perm tier works.
2477
- - Removed cross-session single-cache fallback.
2478
- - `autoGraphCandidates` is the canonical graph flag; old name is an alias.
2479
- - Guardian scheduler uses light checks per tick and full checks at startup/6h.
2480
- - Guard backup/restore/export/prune/sync are constrained to `dataRoot` by default.
2481
- - Tests and docs are included in the package; `npm test` works after install.
2482
-
2483
- ### Added
2484
- - `persona.selfName` / `persona.userAddress`; neutral public defaults (`助手` / `用户`).
2485
- - `injectionGate`, `recentMinMatch`, `allowRestoreOutsideRoot` config.
2486
-
2487
- ### Compatibility
2488
- - Additive config only; no schema migration.
2489
- - Existing 0.3.x databases open in place.
2490
- - Local profiles can restore the 我 / 用户 persona through config.
2491
-
2492
- ## 0.3.1 — 026-11-12
2493
-
2494
- - AI diary entries no longer append a 閳ユ粌寮懓鍐b偓?footer; web sources still inform the model but are not stored in the diary body.
2495
- - Manual dream generation timeout raised from 4s to 20s; `aiOnlyLife` still fails closed instead of falling back to a template.
2496
- - No schema change; compatible with 0.3.0 databases and DSH `>=0.2.1-rc.2 <0.4.0`, Node `>=24`.
2497
- ## 0.3.0 闁?2026-11-12
2498
-
2499
- ### Added
2500
-
2501
- - Summon cards (L2): left-brain emotion cards and right-brain work cards with trigger words.
2502
- - Summon volumes (L3): side/category/day indexes with representative text.
2503
- - Summon book: independent daily page; read-only by default, owner-gated editing with audit.
2504
- - Runtime summon injection: at most 3 cards / 900 tokens, labelled as untrusted historical references.
2505
- - Explicit card feedback (`helpful` / `ignored`) writes back to source-trace DSR. Injection alone never changes strength.
2506
- - Diagnostics panel: health issues, disputed-fact confirm/dismiss, and candidate-only skill extraction.
2507
- - Graph entity labels use names instead of ids; bounded LLM renaming for clearly broken names with confidence gate and audit.
2508
-
2509
- ### Changed
2510
-
2511
- - Scheduler review runs every 90 minutes and generates pending intentions.
2512
- - AI diary is limited to 12:00/22:00; idle hourly writing is a feeling, not a diary.
2513
- - Identity capacity is enforced (L0 default 360 tokens); today's additions are prepended so they survive truncation.
2514
-
2515
- ### Compatibility
2516
-
2517
- - Additive SQLite schema; existing 0.2.x databases migrate in place.
2518
- - DSH `>=0.2.1-rc.2 <0.4.0`; Node `>=24`.
2519
- - No API keys, personal paths, or private data are shipped.
2520
-
2521
- ## 0.2.2 闁?2026-11-12
2522
-
2523
- - Public README and install commands.
2524
- - License metadata and package metadata fixes.
2525
- - No memory-engine behavior change.
2526
-
2527
- ## 0.2.0 闁?2026-11-12
2528
-
2529
- - First stable release of the rc line.
2530
- - Trace UI extraction with layout selection.
2531
- - Windows OCR / Tesseract layout-aware column ordering.
2532
- - Permission confirmations and restart requirement documented.
2533
-
2534
-
2535
-
2536
-
2537
-
2538
-
2539
-
2540
-
2541
-
2542
-
2543
-
2544
-
2545
-
2546
-
2547
-
2548
-
2549
-
2550
28
 
29
+ - 单元测试:553/553。
30
+ - 集成测试:126/126。
31
+ - 公开剥离树扫描:0 私词命中。
32
+ - 一键包 `-DryRun` 无副作用;临时 profile 真装 0.5.0 + extractor 0.3.7 通过。