dsh-layers-hippocampus 1.5.7 → 1.6.2
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.
- package/CHANGELOG.md +192 -4
- package/README.md +190 -333
- package/docs/ARCHITECTURE.zh.md +789 -679
- package/index.js +289 -2
- package/package.json +1 -1
- package/src/compression.js +96 -0
- package/src/config.js +109 -3
- package/src/errors.js +8 -0
- package/src/index/buildIndex.js +21 -3
- package/src/index/indexStore.js +11 -2
- package/src/index/templates.js +84 -0
- package/src/memory.js +48 -0
- package/src/rawArchive.js +235 -0
- package/src/rawIndex.js +134 -0
- package/src/rawStore.js +355 -11
- package/src/retrieval.js +55 -5
- package/src/semantic/semanticStore.js +23 -0
- package/src/webRoutes.js +11 -0
- package/ui/client.js +162 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,170 @@ All notable changes to `dsh-layers-hippocampus` are documented here.
|
|
|
4
4
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
5
|
and the project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [1.6.2] — 2026-11-11
|
|
8
|
+
|
|
9
|
+
**补丁版:修复冷数据归档与保留期的时间冲突,并把“打破日志线性增长”的三层机制并入正式记录。**
|
|
10
|
+
|
|
11
|
+
- **Fixed — 设置页卡在“正在启动…”并报 `MEM_E_NETWORK: HTTP 404`**(2026-11-13):
|
|
12
|
+
1.6.2 的强校验 `archiveAfterDays < retentionDays` 与**旧 profile**(`raw.retentionDays: 30`、
|
|
13
|
+
从未写过 `archiveAfterDays`)冲突,`apply()` 抛 `MEM_E_CONFIG_OUT_OF_RANGE`,插件根本没加载,
|
|
14
|
+
所有 `/api/hippocampus/*` 路由缺失 → UI 永远 404。现在:
|
|
15
|
+
- `archiveAfterDays` **未被显式配置**时按 `retentionDays - 1` 派生,并置
|
|
16
|
+
`raw.archiveAfterDaysDerived: true`(旧 profile 可直接启动);
|
|
17
|
+
- **显式**给出越界的 `archiveAfterDays` 仍然 fail-fast(配置错误不该被静默原谅)。
|
|
18
|
+
- **Fixed — 归档文件不受 retention 约束**:`prune()` 原来只删 `.jsonl` 明文分片,`.jsonl.br`
|
|
19
|
+
归档会永久堆积,等于变相突破保留期。现在整月归档的末日晚于 cutoff 才保留,否则连
|
|
20
|
+
`state/raw-archive.json` 记录一起删除,返回 `removedArchives`。
|
|
21
|
+
|
|
22
|
+
- **修复冷数据归档时间冲突**:冷归档阈值与 TTL 保留期原本互相挤压(`archiveAfterDays` 与
|
|
23
|
+
`retentionDays` 同为 30/90 量级,冷分片常在归档前就被 TTL 删除)。现在默认值上调为
|
|
24
|
+
`archiveAfterDays: 90`、`retentionDays: 365`,并保留 fail-fast 校验
|
|
25
|
+
(`archiveAfterDays` 必须严格小于 `retentionDays`),同时新增 `raw.coldAccessWindowDays: 90`,
|
|
26
|
+
也就是“近 90 天零访问”才允许归档。
|
|
27
|
+
- **实施多档保留策略(含遗忘性保存与全保存)**:raw 层保留谱系落地为
|
|
28
|
+
`raw.mode: off | salience | all` ——
|
|
29
|
+
`off` 为不保存(遗忘性保存,仅保留 L1 之上的记忆)、`salience` 为默认的高价值保存、
|
|
30
|
+
`all` 为全保存(受 `maxTurnKb` / `maxBytesPerDay` / `maxTotalMb` 预算约束);
|
|
31
|
+
另加 `raw.distillPrune`(默认 false):蒸馏产物覆盖第 i 天、且该分片已出
|
|
32
|
+
`raw.hotWindowDays` 热窗时,允许物理清理 raw 原文,**必经 Tombstone 防复活**。
|
|
33
|
+
L2 继续走同类项合并(`l2Merge`),L3 增加硬熔断 `semantic.maxEntries`(默认 100)+ LRU 淘汰,
|
|
34
|
+
语义层随“事件重要性”而非“对话条数”增长。
|
|
35
|
+
- **优化长窗口压缩与高频引用去重**:
|
|
36
|
+
- 冷归档默认改用 **Brotli quality 11**(`.jsonl.br`,极限压缩),`gzip`(9) / `zstd` 仍可选,
|
|
37
|
+
全部来自 Node 内置 `node:zlib`,零外部依赖;读取按扩展名流式解压、命中即停。
|
|
38
|
+
- 高频重复的超长内容(工具 schema / 系统提示块,≥512 字符且出现 ≥2 次)在建索引时
|
|
39
|
+
只存一份到 `templates.json`,事件侧改为 `contentRef` 引用(`src/index/templates.js`),
|
|
40
|
+
索引加载时还原原文;**日志本体不参与替换**,raw 逐行真相、`deep_raw` 与行级游标不受影响。
|
|
41
|
+
- 稀疏行索引(每 64 行采样)继续用于跳过时间窗不重叠的分片并复用 `lineCount`。
|
|
42
|
+
|
|
43
|
+
### 1.6.2 详细变更
|
|
44
|
+
|
|
45
|
+
- **Breaking the linear log curve — three layers** (`test/v162.nonlinear.test.js`, 9 cases):
|
|
46
|
+
- **Compression layer**: cold classification is now MULTI-dimensional (age >
|
|
47
|
+
`raw.archiveAfterDays` **AND** zero access for `raw.coldAccessWindowDays` **AND** no
|
|
48
|
+
`pinned` / `status:handoff` / hot-tag record). Defaults move to
|
|
49
|
+
`archiveAfterDays=90`, `coldAccessWindowDays=90`, `retentionDays=365`. Cold
|
|
50
|
+
archives default to **Brotli quality 11** (`.jsonl.br`, "极限压缩") instead of
|
|
51
|
+
gzip; `gzip`/`zstd` stay selectable and all three are Node built-ins.
|
|
52
|
+
Recently-read old shards stay PLAINTEXT for O(1) cursor scans.
|
|
53
|
+
- **Encoding layer (referential dedup, NOT columnar)**: repeated long content
|
|
54
|
+
(tool schemas / system prompt blocks, ≥512 chars, ≥2 occurrences) is stored ONCE
|
|
55
|
+
in `templates.json` at the INDEX layer; events carry `contentRef` instead of a
|
|
56
|
+
duplicate copy. Index loads resolve refs, so readers always see exact content —
|
|
57
|
+
the log itself is untouched (`src/index/templates.js`).
|
|
58
|
+
- **Semantic layer**: raw stops being the only home of truth. `raw.distillPrune`
|
|
59
|
+
(opt-in) lets `maintain()` physically clean raw shards that are outside
|
|
60
|
+
`raw.hotWindowDays` **and** already covered by an L3 summary — always through the
|
|
61
|
+
tombstone path, so nothing resurrects. L3 gains a hard capacity breaker
|
|
62
|
+
(`semantic.maxEntries`, default 100) with LRU retirement recorded as append-only
|
|
63
|
+
`semantic_retire` events.
|
|
64
|
+
|
|
65
|
+
## [1.6.1] — 2026-11-07
|
|
66
|
+
|
|
67
|
+
**Version fully un-frozen (user directive 2026-11-07): normal semantic versioning
|
|
68
|
+
resumes; 1.6.1 was the release that followed 1.6.0.**
|
|
69
|
+
|
|
70
|
+
- **Archive month detail UI**: the panel's raw section now shows `indexedShards` /
|
|
71
|
+
`archiveCount` StatCards plus a **collapsible month table** (月份 / 引擎 / 归档大小 /
|
|
72
|
+
归档时间, month-DESC, collapsed by default). `panel.raw` carries `archivedBytes`,
|
|
73
|
+
`totalBytes`, `engines:{gzip,zstd}`, `savedBytes`, `compressionRatio` (null when
|
|
74
|
+
unmeasured) and `archiveMonths[]` with `at`/`bytesBefore`/`bytesAfter`; older hosts
|
|
75
|
+
degrade to “—” instead of breaking the panel.
|
|
76
|
+
- **Segment-token audit** (`docs/AUDIT-2026-11-07-segment-token.md`): no P0
|
|
77
|
+
same-segment re-injection exists; the six injection surfaces are documented with
|
|
78
|
+
their dedup mechanisms. Its two P3 items are now IMPLEMENTED:
|
|
79
|
+
- **P3-1** the `[Active Task]` event id also joins the block dedup pool, so one
|
|
80
|
+
event can never be injected both as Active Task and as a recall block;
|
|
81
|
+
- **P3-2** `[Persona & Traits]` is memoized by the L3 shape (`summaryId` +
|
|
82
|
+
`updatedAt` + count); unchanged L3 costs one signature, not a re-render.
|
|
83
|
+
- **Raw cold-tier archiving (zero external deps)**: on `maintain()`, daily shards
|
|
84
|
+
older than `raw.archiveAfterDays` (default **7**) are merged per calendar month
|
|
85
|
+
into one `raw-archive-YYYY-MM.jsonl.gz` via Node's built-in `zlib`, then the
|
|
86
|
+
plaintext shard is removed. Archiving runs at most once per month and SKIPS any
|
|
87
|
+
shard that is recently read (`state/raw-access.json`), `pinned`,
|
|
88
|
+
`status:handoff`, or carries a hot active-set tag. `deep_raw` and hash restore
|
|
89
|
+
stream the archive with `createGunzip()` line-by-line (no full read), report
|
|
90
|
+
`archiveErrors`/`notes: archive-corrupt:<name>` for a corrupt archive, and keep
|
|
91
|
+
plaintext `.jsonl` reads unchanged. `raw.retentionDays` default moves **30 → 90**
|
|
92
|
+
and must stay strictly above `archiveAfterDays` (fail-fast otherwise).
|
|
93
|
+
- **`/stats` panel: archive + index visualization**: `panel.raw` now reports
|
|
94
|
+
`archiveCount`, `archivedBytes`, `totalBytes`, `archiveMonths`, `engines`
|
|
95
|
+
(`{gzip,zstd}`), `savedBytes` (sum of bytesBefore−bytesAfter), `compressionRatio`
|
|
96
|
+
(null when no measured archive) and `indexedShards`. Each archive records
|
|
97
|
+
`bytesBefore`/`bytesAfter` in `state/raw-archive.json`, so the ratio and saved
|
|
98
|
+
bytes are real measurements, not estimates. The panel gains two StatCards
|
|
99
|
+
(“raw 索引覆盖”, “raw 冷归档”) with graceful “—” for an older host, plus a
|
|
100
|
+
collapsible **archive month table** (月份 / 引擎 / 归档大小 / 归档时间, month-DESC,
|
|
101
|
+
collapsed by default); `archiveMonths` rows carry `at`/`bytesBefore`/`bytesAfter`.
|
|
102
|
+
4 cases in `test/v161.stats.test.js` + 2 UI contract cases.
|
|
103
|
+
- **Sparse line index for raw shards** (performance audit item C): one
|
|
104
|
+
`<day>.jsonl.idx.json` per shard, sampled every 64 lines with
|
|
105
|
+
`{line, offset, timestamp}` plus `bytes/mtimeMs/lineCount/minTs/maxTs/sorted`.
|
|
106
|
+
`deep_raw` uses it to SKIP a shard whose time range cannot overlap the window
|
|
107
|
+
(without opening the file) and to reuse `lineCount` for absolute `hit.line`
|
|
108
|
+
numbers (no second pass). Built offline by `maintain()` (50 shards/round,
|
|
109
|
+
progressive), deleted with its shard by `prune()`, and silently bypassed when
|
|
110
|
+
missing, stale (bytes/mtime mismatch), corrupt, or non-monotonic. `stats()`
|
|
111
|
+
reports `indexedShards`. 6 cases in `test/v161.rawIndex.test.js`.
|
|
112
|
+
- **Compression-engine selection (zero install)**: `raw.compressionEngine`
|
|
113
|
+
(`gzip` default | `zstd`) + a settings-page engine picker with an
|
|
114
|
+
enable/disable button. Zstd uses Node's BUILT-IN `node:zlib` zstd — nothing is
|
|
115
|
+
downloaded and there is no package to uninstall; "停用" switches back to gzip.
|
|
116
|
+
Archives are `raw-archive-YYYY-MM.jsonl.gz` / `.jsonl.zst`, dispatch is by
|
|
117
|
+
extension, and a legacy gzip archive stays readable after switching to zstd.
|
|
118
|
+
When the runtime lacks zstd the config silently falls back to gzip and
|
|
119
|
+
`capabilities.compression` reports `{engine, fallback, zstd, node}` for the UI.
|
|
120
|
+
- **Raw retention tiers documented**: the raw layer exposes exactly three modes —
|
|
121
|
+
`off` (keep nothing), `salience` (default: high-value turns/code/stack/errors only),
|
|
122
|
+
`all` (bounded by `maxTurnKb`/`maxBytesPerDay`/`maxTotalMb`) — plus
|
|
123
|
+
`retentionDays` (default 90) and `pinned` never pruned. README/ARCHITECTURE now
|
|
124
|
+
describe these implemented tiers only.
|
|
125
|
+
- **Fixed — settings page rendered blank**: the compression-engine card referenced a
|
|
126
|
+
bare `payload` that only exists in other components' scopes; it now uses the local
|
|
127
|
+
`statsPayload` and the shared `Select` component (not a fake `type:'select'` on
|
|
128
|
+
`Field`). `test/v161.ui.test.js` pins the scope rule so the whole settings page
|
|
129
|
+
cannot be taken down by one card again.
|
|
130
|
+
|
|
131
|
+
- **Recall bound-based early exit** (performance audit item A): every score is
|
|
132
|
+
`salience × decay × tagAffinity(≤3) × lexicalBoost(≤1) × association(≤1) ×
|
|
133
|
+
timeBoost(≤1.3) × handoff(≤1)`, so `salience × 3.9` is a hard upper bound.
|
|
134
|
+
Candidates are visited salience-DESC and scoring stops as soon as that bound
|
|
135
|
+
cannot beat the current k-th score. `pinned` hits bypass the cut, the best-k
|
|
136
|
+
window keeps the bound exact (ties still visited), and the result reports
|
|
137
|
+
`pruned` + `notes: pruned:<n>`. Complexity unchanged in the worst case
|
|
138
|
+
(`O(K log K)` ordering) but the per-candidate decay/similarity work is skipped
|
|
139
|
+
for the long low-salience tail.
|
|
140
|
+
- Regression: pinned decay stays exactly 1 (bypass path), monthly memos unchanged.
|
|
141
|
+
- **456 tests green** (64 files).
|
|
142
|
+
|
|
143
|
+
## [1.6.0] — 2026-11-06
|
|
144
|
+
|
|
145
|
+
> Version note: 1.6.0 was the FIRST release after the temporary 1.5.7 freeze; the
|
|
146
|
+
> 2026-11-07 directive removed all freeze language and resumed normal versioning.
|
|
147
|
+
Cold-start wake-up + user-controlled cold-start injection:
|
|
148
|
+
|
|
149
|
+
- **Anti-"customer service" wake-up** (static `memory:policy` prefix): the model is
|
|
150
|
+
told it has continuous long-term memory, must not open with "how may I help you",
|
|
151
|
+
and should recall the recent topic before replying.
|
|
152
|
+
- **`context.coldStartInjectSummary`** (default **true**): on the first prompt
|
|
153
|
+
assembly of a brand-new conversation, inject `[Cold-Start Summary]` — the handoff
|
|
154
|
+
summary event when present, else the top-3 L3 semantic summaries (≤800 chars).
|
|
155
|
+
- **`context.coldStartInjectRecentTurns`** (default **false**): inject
|
|
156
|
+
`[Previous Context Tail]` with the last ≤5 business episodes (200 chars each).
|
|
157
|
+
- **`[Cold-Start Detected: Active Space=…, Recent Topic=…]`** header when either
|
|
158
|
+
switch is on; the block is volatile-tail only (prompt-cache prefix untouched) and
|
|
159
|
+
is consumed exactly once per new conversation.
|
|
160
|
+
- Both switches off → no historical blocks; the static wake-up policy still ships.
|
|
161
|
+
- UI: two independent toggles in the settings page's session group; HTTP-editable.
|
|
162
|
+
- **416 tests green** (64 files).
|
|
163
|
+
|
|
7
164
|
## [1.5.7] — 2026-11-04
|
|
8
165
|
|
|
9
|
-
|
|
166
|
+
> Historical note: 1.5.7 shipped under a temporary version freeze; the 2026-11-07
|
|
167
|
+
> directive removed ALL freeze language and resumed normal semantic versioning
|
|
168
|
+
> (current version: 1.6.2). The sentence below is the historical 1.5.7 statement.
|
|
169
|
+
|
|
170
|
+
**Version freeze (historical, superseded): 1.5.7 was the shipped release.**
|
|
10
171
|
This release folds in everything added after the 1.5.6 draft — Orchestrator
|
|
11
172
|
federation/dedupe wiring, read-time merge, cross-space recall aggregation (opt-in
|
|
12
173
|
`features.crossSpaceRecall`), durable Orchestrator state, the settings-page GitHub
|
|
@@ -14,14 +175,14 @@ installer, the verified automatic new-conversation handoff (with configurable
|
|
|
14
175
|
once/interval detection), low-valley Dream Phase 2, space deletion, graph
|
|
15
176
|
interaction, and the rest of the 1.5.6 section below. Annotations of the form
|
|
16
177
|
`v1.5.6:` below record the version in which a feature was introduced; they are
|
|
17
|
-
history, not the current version. **
|
|
178
|
+
history, not the current version. **411 tests green** (64 files).
|
|
18
179
|
|
|
19
180
|
## [1.5.6] — 2026-11-03
|
|
20
181
|
|
|
21
182
|
**`deep_raw` now scans by line cursor: a huge day shard is never loaded whole.**
|
|
22
183
|
The black box is read newest-first in fixed chunks; peak memory is one chunk plus
|
|
23
184
|
one partial line (test-locked), not the file size. `hit.line` keeps its absolute
|
|
24
|
-
1-based semantics. **
|
|
185
|
+
1-based semantics. **411 tests green** (was 303).
|
|
25
186
|
|
|
26
187
|
### Changed — raw scan / restore (zero-dependency, O(chunk) memory)
|
|
27
188
|
|
|
@@ -429,12 +590,39 @@ one partial line (test-locked), not the file size. `hit.line` keeps its absolute
|
|
|
429
590
|
configures its timer from the FIRST stats response (`once` clears the recurring
|
|
430
591
|
timer). The workspace-file handoff scheme is no longer needed and stays documented
|
|
431
592
|
only as a fallback.
|
|
593
|
+
- **Fixed — new-conversation failure `tool "subagent" is already registered`**:
|
|
594
|
+
handoff preset inheritance no longer calls `agentPresets.select()` when the new
|
|
595
|
+
session is ALREADY composed with the marker's preset. A redundant recompose
|
|
596
|
+
re-mounted the preset's `@deepseek-ai/dsh-tool-subagent` row and aborted session
|
|
597
|
+
creation; the skip is recorded as `presetInherit.reason='already-composed'` and
|
|
598
|
+
locked by a regression test in `test/v156.preset.test.js`.
|
|
599
|
+
- **Persona section + generic custom decay (v1.5.7)**:
|
|
600
|
+
- `[Persona & Traits]` is its own prompt section (`name:'persona'`, **order 100**),
|
|
601
|
+
rendering the ≤10 highest-confidence L3 semantic summaries (live store read, not
|
|
602
|
+
the recall cache). The memory block/policy/reflection sections keep 2450/2455/2460.
|
|
603
|
+
- `service.remember()` accepts **`customDecayRate`** (finite, 0 < rate ≤ 10) OR
|
|
604
|
+
**`customHalfLifeDays`** (integer 1–36500), never both. The value is normalised to
|
|
605
|
+
`meta.decay_rate`, projected as `decayRate`, and applied as
|
|
606
|
+
`effectiveHalfLife = policyHalfLife / decayRate` for THAT record only. No
|
|
607
|
+
tag-prefix logic exists anywhere in the engine — an emotion plugin decides the
|
|
608
|
+
semantics by passing the parameter.
|
|
609
|
+
- **Cross-plugin `ctx.provide('hippocampus', service)`** (user decision 2026-11-05:
|
|
610
|
+
in-process service only, NO HTTP write surface): `apiVersion=1`, `ready()`,
|
|
611
|
+
`capabilities()` (declares `l3Traits:10` plus per-method support), `remember()`
|
|
612
|
+
(L2-only; non-L2 layers are redirected with a warning; returns
|
|
613
|
+
`{status,eventId,eventTime,duplicate}`), `recall()`, `runMaintenance(source)`
|
|
614
|
+
(never queues: a running pass answers `MEM_E_MAINTENANCE_RUNNING`; manual passes
|
|
615
|
+
are rate-limited to 30 s while `cron` bypasses), `stats()/handoffView()/
|
|
616
|
+
promptState()` read-only snapshots and `onDispose()` hooks. The service disappears
|
|
617
|
+
with its plugin fiber; later calls answer `MEM_E_SERVICE_DISPOSED`. New codes
|
|
618
|
+
`MEM_E_MAINTENANCE_RUNNING`, `MEM_E_SERVICE_DISPOSED`, `MEM_E_FEDERATION_FAILED`
|
|
619
|
+
are registered append-only (8 cases in `test/v157.service.test.js`).
|
|
432
620
|
- **Durable Orchestrator state**: `<root>/state/orchestrator.json` now persists the
|
|
433
621
|
global federation map and the monthly-memo claims (atomic tmp+rename on every
|
|
434
622
|
mutation); it is loaded before the services become observable, and a corrupt file
|
|
435
623
|
is treated as empty instead of failing activation — a restart no longer forgets
|
|
436
624
|
cross-space dedupe.
|
|
437
|
-
- Full suite: **
|
|
625
|
+
- Full suite: **411 tests / 411 pass / 0 fail**, 64 test files. Orchestrator:
|
|
438
626
|
**31/31** (`service` + `spaces` deletion + `persistence` round-trip/corrupt state).
|
|
439
627
|
**Installed locally**: desktop profile gets a `link:` dependency + an ordered patch
|
|
440
628
|
insert BEFORE the hippocampus entries, so the service exists at activation. Two
|