@shadowforge0/aquifer-memory 1.8.1 → 1.9.1

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 (57) hide show
  1. package/.env.example +1 -0
  2. package/README.md +82 -26
  3. package/README_CN.md +33 -23
  4. package/README_TW.md +25 -24
  5. package/aquifer.config.example.json +2 -1
  6. package/consumers/cli.js +587 -33
  7. package/consumers/codex-active-checkpoint.js +3 -1
  8. package/consumers/codex-current-memory.js +10 -6
  9. package/consumers/codex.js +6 -3
  10. package/consumers/default/daily-entries.js +2 -2
  11. package/consumers/default/index.js +40 -30
  12. package/consumers/default/prompts/summary.js +2 -2
  13. package/consumers/mcp.js +56 -46
  14. package/consumers/openclaw-ext/index.js +65 -7
  15. package/consumers/openclaw-ext/openclaw.plugin.json +1 -1
  16. package/consumers/openclaw-ext/package.json +1 -1
  17. package/consumers/openclaw-install.js +326 -0
  18. package/consumers/openclaw-plugin.js +105 -24
  19. package/consumers/shared/compat-recall.js +101 -0
  20. package/consumers/shared/config.js +2 -0
  21. package/consumers/shared/openclaw-product-tools.js +130 -0
  22. package/consumers/shared/recall-format.js +2 -2
  23. package/core/aquifer.js +553 -41
  24. package/core/backends/local.js +169 -1
  25. package/core/doctor.js +924 -0
  26. package/core/finalization-inspector.js +164 -0
  27. package/core/finalization-review.js +88 -42
  28. package/core/interface.js +629 -0
  29. package/core/mcp-manifest.js +11 -3
  30. package/core/memory-bootstrap.js +25 -27
  31. package/core/memory-consolidation.js +564 -42
  32. package/core/memory-explain.js +593 -0
  33. package/core/memory-promotion.js +392 -55
  34. package/core/memory-recall.js +75 -71
  35. package/core/memory-records.js +107 -108
  36. package/core/memory-review.js +891 -0
  37. package/core/memory-serving.js +61 -4
  38. package/core/memory-type-policy.js +298 -0
  39. package/core/operator-observability.js +249 -0
  40. package/core/postgres-migrations.js +22 -0
  41. package/core/session-checkpoint-producer.js +3 -1
  42. package/core/session-checkpoints.js +1 -1
  43. package/core/session-finalization.js +78 -3
  44. package/core/storage.js +124 -8
  45. package/docs/getting-started.md +50 -4
  46. package/docs/setup.md +163 -24
  47. package/package.json +5 -4
  48. package/schema/004-completion.sql +4 -4
  49. package/schema/010-v1-finalization-review.sql +72 -0
  50. package/schema/019-v1-memory-review-resolutions.sql +53 -0
  51. package/schema/020-v1-assistant-shaping-memory.sql +30 -0
  52. package/scripts/backfill-canonical-key.js +1 -1
  53. package/scripts/codex-checkpoint-commands.js +28 -0
  54. package/scripts/codex-checkpoint-runtime.js +109 -0
  55. package/scripts/codex-recovery.js +16 -4
  56. package/scripts/diagnose-fts-zh.js +1 -1
  57. package/scripts/extract-insights-from-recent-sessions.js +4 -4
package/.env.example CHANGED
@@ -11,6 +11,7 @@ AQUIFER_MEMORY_SERVING_MODE=legacy
11
11
  # AQUIFER_MEMORY_SERVING_MODE=curated
12
12
  # AQUIFER_MEMORY_ACTIVE_SCOPE_KEY=project:example
13
13
  # AQUIFER_MEMORY_ACTIVE_SCOPE_PATH=global,project:example
14
+ # AQUIFER_MEMORY_ALLOWED_SCOPE_KEYS=global,project:example
14
15
 
15
16
  # Optional Codex active-session checkpoint heartbeat policy.
16
17
  # AQUIFER_CODEX_CHECKPOINT_CHECK_INTERVAL_MINUTES=10
package/README.md CHANGED
@@ -67,28 +67,67 @@ Claude Code, Claude Desktop, or any MCP-capable client — drop this into `.mcp.
67
67
 
68
68
  Or run it directly: `DATABASE_URL=... EMBED_PROVIDER=ollama npx aquifer mcp`. The MCP server itself stays strict about env; `quickstart` autodetect is the try-it path, not the production one.
69
69
 
70
- Keep `AQUIFER_MEMORY_SERVING_MODE=legacy` for first rollout. Switch to `curated` only when you want `session_recall` and `session_bootstrap` to serve active curated memory; `evidence_recall` stays the explicit audit/debug lane. Rollback is just flipping env or config back to `legacy`.
70
+ Keep `AQUIFER_MEMORY_SERVING_MODE=legacy` for first rollout. Switch to `curated` only when you want compatibility `session_recall` and `session_bootstrap` to serve active curated memory. Use `memory_recall` for explicit current-memory lookup, `historical_recall` for the historical/session plane, and `evidence_recall` for the audit/debug lane. Rollback is just flipping env or config back to `legacy`.
71
+
72
+ Curated serving is scope-bound. `AQUIFER_MEMORY_ACTIVE_SCOPE_PATH` is the ordered inheritance path, while `AQUIFER_MEMORY_ALLOWED_SCOPE_KEYS` is the caller boundary. If `activeScopePath` is omitted, Aquifer defaults it to `global` plus the configured `activeScopeKey`, or to `global` alone when no active scope is configured. If `allowedScopeKeys` is omitted, Aquifer defaults it to that active scope path. Runtime requests outside that boundary are rejected before reading current memory rows.
71
73
 
72
74
  ### Common commands
73
75
 
74
76
  | Goal | Command |
75
77
  |---|---|
76
78
  | Verify setup | `npx aquifer quickstart` |
79
+ | Run read-only governance diagnostics | `npx aquifer doctor --json` |
77
80
  | Inspect selected backend capabilities without DB connection | `AQUIFER_BACKEND=local npx aquifer backend-info --json` |
78
81
  | Start the MCP server | `npx aquifer mcp` |
79
82
  | Search memory manually | `npx aquifer recall "auth middleware"` |
83
+ | Explain current-memory bootstrap selection | `npx aquifer explain bootstrap --active-scope-key project:aquifer --json` |
84
+ | Explain current-memory recall selection | `npx aquifer explain memory --query "serving contract" --active-scope-key project:aquifer --json` |
85
+ | Inspect finalized-session ledger rows | `npx aquifer finalization list --status finalized --json` |
86
+ | Inspect operator ledgers | `npx aquifer operator status --json` |
87
+ | Review current-memory feedback issues | `npx aquifer review queue --scope-key project:aquifer --feedback-type incorrect --json` |
88
+ | Resolve a reviewed memory queue item | `npx aquifer review resolve --memory-id 42 --resolution resolved --reason "verified current" --expected-latest-issue-feedback-id 9 --json` |
80
89
  | Plan curated memory compaction | `npx aquifer compact --cadence daily --period-start 2026-04-27T00:00:00Z --period-end 2026-04-28T00:00:00Z` |
81
90
  | Generate a timer synthesis prompt | `npx aquifer operator compaction daily --include-synthesis-prompt --json` |
82
91
  | Apply reviewed timer synthesis candidates | `npx aquifer operator compaction daily --synthesis-summary-file /tmp/timer-summary.json --apply --promote-candidates --json` |
83
92
  | Generate a finalized-session checkpoint prompt | `npx aquifer operator checkpoint --scope-key project:aquifer --min-finalizations 10 --include-synthesis-prompt --json` |
84
93
  | Heartbeat-check an active Codex session for checkpoint work | `npx aquifer codex-recovery checkpoint-heartbeat --hook-stdin --scope-key project:aquifer` |
94
+ | Inspect pending Codex checkpoint spool files | `npx aquifer codex-recovery checkpoint-spool-status --json --limit 10` |
85
95
  | Preview a Codex UserPromptSubmit heartbeat hook install | `npx aquifer codex-recovery checkpoint-heartbeat-hook --scope-key project:aquifer --hooks-path "$CODEX_HOME/hooks.json" --json` |
86
- | Inspect storage health | `npx aquifer stats` |
96
+ | Check memory readiness | `npx aquifer stats` |
97
+ | Check saved-content preparation | `npx aquifer backlog --json` |
98
+ | Dry-run a saved-content policy decision | `npx aquifer backlog --plan skip --status pending --source openclaw-mcp` |
87
99
  | Enrich pending sessions | `npx aquifer backfill` |
88
100
 
89
- Timer synthesis output is candidate material until an operator applies it with
90
- `--promote-candidates`; it does not become active curated memory from the
91
- prompt or summary file alone.
101
+ `stats`, `backlog`, MCP `memory_stats`, and MCP `memory_pending` default to the
102
+ same public status surface: `Aquifer status` or `Saved content status`, plus
103
+ `Available`, `Attention`, and `Action` where relevant. Use `stats --diagnostics`,
104
+ `backlog --diagnostics`, or MCP `diagnostics: true` for raw counters, buckets,
105
+ guidance, and samples.
106
+
107
+ Reviewed timer synthesis is gated before promotion. Candidate items must carry
108
+ `mergeKey`, `scopeClass`, `durability`, `promotionTarget`, and
109
+ `sourceCanonicalKeys` that reference `sourceCurrentMemory`; runtime state also
110
+ needs `staleAfter` or `validTo`. The temporal distillation gate rejects
111
+ workspace/operator policy, transient material, unsupported promotion targets,
112
+ invalid or missing source lineage, and duplicate merge keys before current
113
+ memory promotion. `assistant_shaping` may target `assistant_behavior_memory`
114
+ only when the item carries behavior-level abstraction metadata:
115
+ `languageLevel=user_behavior`, `appliesBeyondSource=true`, `sourceBound=false`,
116
+ and a `principle`. Project-specific source wording stays lineage/context
117
+ material; serving memory uses the behavior principle.
118
+
119
+ To serve user-level assistant behavior alongside a project, include the user
120
+ scope in the active path, for example
121
+ `AQUIFER_MEMORY_ACTIVE_SCOPE_PATH=global,user:mk,project:aquifer` with matching
122
+ allowed scope keys. Applicable `assistant_shaping` records are pinned ahead of
123
+ ordinary project current memory in bootstrap.
124
+
125
+ Timer synthesis output is candidate material until an operator applies a
126
+ reviewed synthesis summary with `--promote-candidates`; it does not become
127
+ active curated memory from the prompt or summary file alone. The deterministic
128
+ daily/weekly/monthly aggregate proposals in a dry-run are source-rollup
129
+ material for review and ledger lineage only, and are blocked from normal active
130
+ promotion unless a reviewed synthesis summary is attached.
92
131
 
93
132
  Checkpoint output follows the same boundary. `operator checkpoint` plans from
94
133
  finalized session summaries and only writes `checkpoint_runs` when you pass an
@@ -98,6 +137,28 @@ files: it first checks a tiny local scheduler marker, reads the transcript only
98
137
  when the time window is due, then writes local spool process material only when
99
138
  the message threshold is also due. It does not print prompt text by default and
100
139
  does not write DB memory.
140
+ Use `codex-recovery checkpoint-spool-status --json` to inspect pending local
141
+ spool files by session, coverage, byte size, and modified time without printing
142
+ the checkpoint prompt text.
143
+
144
+ Read-only governance commands are diagnostic surfaces. `doctor`,
145
+ `finalization list|inspect`, `explain bootstrap|memory`, and
146
+ `operator status|inspect` do not apply migrations, promote memory, mutate
147
+ finalization status, reclaim operator leases, or add MCP tools. `review
148
+ queue|inspect` is read-only with respect to memory truth, but uses the normal
149
+ Aquifer migration gate because it depends on the resolution ledger schema. It
150
+ derives an operator queue from curated memory feedback such as `incorrect`,
151
+ `stale`, and `scope_mismatch` without printing raw transcripts, feedback notes,
152
+ feedback metadata, or memory payloads. `review resolve` is the narrow write path
153
+ for this surface: it appends a snapshot-bound resolution ledger row
154
+ (`resolved`, `ignored`, or `deferred`) without mutating `memory_records` or
155
+ rewriting feedback history. Newer issue feedback reopens the queue item. Use
156
+ these commands to answer why a session did not finalize, why a current-memory
157
+ row was selected or excluded, which visible memory rows need human review, and
158
+ whether operator ledgers contain stale claims before running write paths.
159
+ Explain output includes stable scope inheritance details for selected and
160
+ excluded rows; non-selected rows redact `title` and `summary` so diagnostics
161
+ cannot become a cross-scope content probe.
101
162
 
102
163
  Need LLM summarization, the knowledge graph, OpenAI embeddings, reranking, or operations details? See [docs/setup.md](docs/setup.md) and [Environment Variables](#environment-variables).
103
164
 
@@ -172,6 +233,7 @@ Sessions, summaries, turn-level embeddings, entity graph — all live in one dat
172
233
  | `AQUIFER_MEMORY_SERVING_MODE` | No | Public serving mode: `legacy` default, or opt-in `curated` | `curated` |
173
234
  | `AQUIFER_MEMORY_ACTIVE_SCOPE_KEY` | No | Default active curated scope for recall/bootstrap | `project:aquifer` |
174
235
  | `AQUIFER_MEMORY_ACTIVE_SCOPE_PATH` | No | Ordered curated scope path for inheritance | `global,project:aquifer` |
236
+ | `AQUIFER_MEMORY_ALLOWED_SCOPE_KEYS` | No | Caller boundary for curated scope requests; defaults to the configured active scope path | `global,project:aquifer` |
175
237
  | `AQUIFER_CODEX_CHECKPOINT_CHECK_INTERVAL_MINUTES` | No | Active Codex checkpoint heartbeat time gate (default: `10`) | `10` |
176
238
  | `AQUIFER_CODEX_CHECKPOINT_EVERY_MESSAGES` | No | Active Codex checkpoint message delta gate (default: `20`) | `20` |
177
239
  | `AQUIFER_CODEX_CHECKPOINT_EVERY_USER_MESSAGES` | No | Optional user-message delta gate | `10` |
@@ -205,7 +267,7 @@ The script is idempotent (`WHERE canonical_key_v2 IS NULL` guard) and race-safe
205
267
 
206
268
  ## Host Integration
207
269
 
208
- MCP is the primary integration surface. Agent hosts connect to the Aquifer MCP server, which exposes eight tools: `session_recall`, `evidence_recall`, `session_feedback`, `memory_feedback`, `feedback_stats`, `session_bootstrap`, `memory_stats`, `memory_pending`.
270
+ MCP is the primary integration surface. Agent hosts connect to the Aquifer MCP server, which exposes ten tools: `memory_recall`, `historical_recall`, `session_recall`, `evidence_recall`, `session_feedback`, `memory_feedback`, `memory_stats`, `memory_pending`, `feedback_stats`, `session_bootstrap`.
209
271
 
210
272
  | Integration | Route | Status | When to use |
211
273
  |-------------|-------|--------|-------------|
@@ -236,7 +298,7 @@ Add to your project's `.claude.json` or user-level MCP config:
236
298
  }
237
299
  ```
238
300
 
239
- Tools appear as `mcp__aquifer__session_recall`, `mcp__aquifer__evidence_recall`, `mcp__aquifer__session_bootstrap`, `mcp__aquifer__session_feedback`, `mcp__aquifer__memory_feedback`, `mcp__aquifer__feedback_stats`, `mcp__aquifer__memory_stats`, `mcp__aquifer__memory_pending`.
301
+ Tools appear as `mcp__aquifer__memory_recall`, `mcp__aquifer__historical_recall`, `mcp__aquifer__session_recall`, `mcp__aquifer__evidence_recall`, `mcp__aquifer__session_feedback`, `mcp__aquifer__memory_feedback`, `mcp__aquifer__memory_stats`, `mcp__aquifer__memory_pending`, `mcp__aquifer__feedback_stats`, `mcp__aquifer__session_bootstrap`.
240
302
 
241
303
  For Codex long sessions, Aquifer exposes a UserPromptSubmit-friendly heartbeat
242
304
  command instead of installing a daemon:
@@ -287,27 +349,21 @@ the heartbeat hook is present.
287
349
 
288
350
  ### OpenClaw
289
351
 
290
- Add to `openclaw.json` under `mcp.servers`:
352
+ Install or update Aquifer inside the OpenClaw host root, then let the installer
353
+ wire both the MCP server and the optional extension from the same package root:
291
354
 
292
- ```json
293
- {
294
- "mcp": {
295
- "servers": {
296
- "aquifer": {
297
- "command": "node",
298
- "args": ["/path/to/aquifer/consumers/mcp.js"],
299
- "env": {
300
- "DATABASE_URL": "postgresql://...",
301
- "AQUIFER_EMBED_BASE_URL": "http://localhost:11434/v1",
302
- "AQUIFER_EMBED_MODEL": "bge-m3"
303
- }
304
- }
305
- }
306
- }
307
- }
355
+ ```bash
356
+ npm install --prefix "$OPENCLAW_HOME" @shadowforge0/aquifer-memory@latest
357
+ node "$OPENCLAW_HOME/node_modules/@shadowforge0/aquifer-memory/consumers/cli.js" install-openclaw --openclaw-home "$OPENCLAW_HOME"
308
358
  ```
309
359
 
310
- Tools materialize as `aquifer__session_recall`, `aquifer__evidence_recall`, `aquifer__session_feedback`, `aquifer__memory_feedback`, `aquifer__feedback_stats`, `aquifer__session_bootstrap`, `aquifer__memory_stats`, `aquifer__memory_pending` (server name prefix added by the host).
360
+ The installer enables `plugins.entries["aquifer-memory"]`, adds the extension
361
+ to `plugins.load.paths`, preserves existing `mcp.servers.aquifer.env` values,
362
+ and backs up `openclaw.json` before writing. Use `--dry-run --json` to inspect
363
+ package version, plugin config, MCP target, and extension link without changing
364
+ files.
365
+
366
+ Tools materialize as `aquifer__memory_recall`, `aquifer__historical_recall`, `aquifer__session_recall`, `aquifer__evidence_recall`, `aquifer__session_feedback`, `aquifer__memory_feedback`, `aquifer__memory_stats`, `aquifer__memory_pending`, `aquifer__feedback_stats`, `aquifer__session_bootstrap` (server name prefix added by the host).
311
367
 
312
368
  The OpenClaw plugin (`consumers/openclaw-plugin.js`) is retained for session capture via `before_reset` but is **not** the recommended tool delivery path. Use MCP.
313
369
 
@@ -722,7 +778,7 @@ Key indexes: `idx_insights_canonical_v2_active` (partial on active rows with can
722
778
 
723
779
  **Recall returns no results** — Make sure you've run `enrich` after `commit`. Raw sessions are not searchable until enriched (summarized + embedded). Check `aquifer stats` to see if summaries and turn embeddings exist.
724
780
 
725
- **OpenClaw tools not visible** — Use `mcp.servers.aquifer` in `openclaw.json`, not the plugin. Tools appear as `aquifer__session_recall` etc. The plugin (`consumers/openclaw-plugin.js`) is for session capture only.
781
+ **OpenClaw tools not visible** — Use `mcp.servers.aquifer` in `openclaw.json`, not the plugin. Tools appear as `aquifer__memory_recall`, `aquifer__historical_recall`, `aquifer__session_recall`, etc. The plugin (`consumers/openclaw-plugin.js`) is for session capture only.
726
782
 
727
783
  **Embedding provider connection refused** — Verify your `AQUIFER_EMBED_BASE_URL` is reachable. For local Ollama, make sure the server is running and the model is pulled (`ollama pull bge-m3`).
728
784
 
package/README_CN.md CHANGED
@@ -109,24 +109,40 @@ Claude Code、Claude Desktop 或任何支持 MCP 的 client——放进 `.mcp.js
109
109
 
110
110
  或直接跑:`DATABASE_URL=... EMBED_PROVIDER=ollama npx aquifer mcp`。(MCP server 本身对 env 严格——`quickstart` 的 autodetect 是试用路径,不是 production 路径。)
111
111
 
112
- 第一轮 rollout 先保持 `AQUIFER_MEMORY_SERVING_MODE=legacy`。只有在你要让 `session_recall` 和 `session_bootstrap` 提供 active curated memory 时,才切到 `curated`;`evidence_recall` 会保留为显式 audit/debug 路径。要 rollback 只要把 env 或 config 切回 `legacy`。
112
+ 第一轮 rollout 先保持 `AQUIFER_MEMORY_SERVING_MODE=legacy`。只有在你要让兼容性 `session_recall` 和 `session_bootstrap` 提供 active curated memory 时,才切到 `curated`;`memory_recall` 是显式 current-memory lookup,`historical_recall` 是 historical/session 平面,`evidence_recall` audit/debug 路径。要 rollback 只要把 env 或 config 切回 `legacy`。
113
113
 
114
114
  ### Common commands
115
115
 
116
116
  | Goal | Command |
117
117
  |---|---|
118
118
  | Verify setup | `npx aquifer quickstart` |
119
+ | Run read-only diagnostics | `npx aquifer doctor --json` |
119
120
  | Start the MCP server | `npx aquifer mcp` |
120
121
  | Search memory manually | `npx aquifer recall "auth middleware"` |
122
+ | Explain current-memory selection | `npx aquifer explain bootstrap --active-scope-key project:aquifer --json` |
123
+ | Review current-memory feedback issues | `npx aquifer review queue --scope-key project:aquifer --json` |
124
+ | Resolve a reviewed memory queue item | `npx aquifer review resolve --memory-id 42 --resolution resolved --reason "verified current" --expected-latest-issue-feedback-id 9 --json` |
121
125
  | Plan curated memory compaction | `npx aquifer compact --cadence daily --period-start 2026-04-27T00:00:00Z --period-end 2026-04-28T00:00:00Z` |
122
126
  | Generate a timer synthesis prompt | `npx aquifer operator compaction daily --include-synthesis-prompt --json` |
123
127
  | Apply reviewed timer synthesis candidates | `npx aquifer operator compaction daily --synthesis-summary-file /tmp/timer-summary.json --apply --promote-candidates --json` |
124
- | Inspect storage health | `npx aquifer stats` |
128
+ | Inspect pending Codex checkpoint spool files | `npx aquifer codex-recovery checkpoint-spool-status --json --limit 10` |
129
+ | Check memory readiness | `npx aquifer stats` |
130
+ | Check saved-content preparation | `npx aquifer backlog --json` |
131
+ | Dry-run a saved-content policy decision | `npx aquifer backlog --plan skip --status pending --source openclaw-mcp` |
125
132
  | Enrich pending sessions | `npx aquifer backfill` |
126
133
 
134
+ `stats`, `backlog`, MCP `memory_stats`, and MCP `memory_pending` default to the
135
+ same public status surface: `Aquifer status` or `Saved content status`, plus
136
+ `Available`, `Attention`, and `Action` where relevant. Use CLI `--diagnostics`
137
+ or MCP `diagnostics: true` when a host needs raw counters, buckets, guidance,
138
+ or samples.
139
+
127
140
  Timer synthesis output is candidate material until an operator applies it with
128
141
  `--promote-candidates`; it does not become active curated memory from the
129
142
  prompt or summary file alone.
143
+ `codex-recovery checkpoint-spool-status --json` reports local spool file
144
+ metadata such as session, coverage, byte size, and modified time without
145
+ printing checkpoint prompt text.
130
146
 
131
147
  需要 LLM 摘要、知识图谱、OpenAI embedding 或 reranker?往下看 [环境变量](#环境变量) 和 [docs/setup.md](docs/setup.md)。
132
148
 
@@ -194,7 +210,7 @@ const results = await aquifer.recall('auth middleware 决定', {
194
210
 
195
211
  ## 宿主集成
196
212
 
197
- MCP 是主要的集成接口。Agent 宿主连接到 Aquifer MCP server,该 server 暴露八个工具:`session_recall`、`evidence_recall`、`session_feedback`、`memory_feedback`、`feedback_stats`、`session_bootstrap`、`memory_stats`、`memory_pending`。
213
+ MCP 是主要的集成接口。Agent 宿主连接到 Aquifer MCP server,该 server 暴露十个工具:`memory_recall`、`historical_recall`、`session_recall`、`evidence_recall`、`session_feedback`、`memory_feedback`、`memory_stats`、`memory_pending`、`feedback_stats`、`session_bootstrap`。
198
214
 
199
215
  | 集成方式 | 路径 | 状态 | 使用场景 |
200
216
  |----------|------|------|----------|
@@ -225,31 +241,25 @@ MCP 是主要的集成接口。Agent 宿主连接到 Aquifer MCP server,该 se
225
241
  }
226
242
  ```
227
243
 
228
- 工具在 Claude Code 中显示为 `mcp__aquifer__session_recall`、`mcp__aquifer__evidence_recall`、`mcp__aquifer__session_bootstrap`、`mcp__aquifer__session_feedback`、`mcp__aquifer__memory_feedback`、`mcp__aquifer__feedback_stats`、`mcp__aquifer__memory_stats`、`mcp__aquifer__memory_pending`。
244
+ 工具在 Claude Code 中显示为 `mcp__aquifer__memory_recall`、`mcp__aquifer__historical_recall`、`mcp__aquifer__session_recall`、`mcp__aquifer__evidence_recall`、`mcp__aquifer__session_feedback`、`mcp__aquifer__memory_feedback`、`mcp__aquifer__memory_stats`、`mcp__aquifer__memory_pending`、`mcp__aquifer__feedback_stats`、`mcp__aquifer__session_bootstrap`。
229
245
 
230
246
  ### OpenClaw
231
247
 
232
- 添加到 `openclaw.json` `mcp.servers` 下:
248
+ Install or update Aquifer inside the OpenClaw host root, then let the installer
249
+ wire both the MCP server and the optional extension from the same package root:
233
250
 
234
- ```json
235
- {
236
- "mcp": {
237
- "servers": {
238
- "aquifer": {
239
- "command": "node",
240
- "args": ["/path/to/aquifer/consumers/mcp.js"],
241
- "env": {
242
- "DATABASE_URL": "postgresql://...",
243
- "AQUIFER_EMBED_BASE_URL": "http://localhost:11434/v1",
244
- "AQUIFER_EMBED_MODEL": "bge-m3"
245
- }
246
- }
247
- }
248
- }
249
- }
251
+ ```bash
252
+ npm install --prefix "$OPENCLAW_HOME" @shadowforge0/aquifer-memory@latest
253
+ node "$OPENCLAW_HOME/node_modules/@shadowforge0/aquifer-memory/consumers/cli.js" install-openclaw --openclaw-home "$OPENCLAW_HOME"
250
254
  ```
251
255
 
252
- 工具显示为 `aquifer__session_recall`、`aquifer__evidence_recall`、`aquifer__session_feedback`、`aquifer__memory_feedback`、`aquifer__feedback_stats`、`aquifer__session_bootstrap`、`aquifer__memory_stats`、`aquifer__memory_pending`(宿主自动添加 server 名称前缀)。
256
+ The installer enables `plugins.entries["aquifer-memory"]`, adds the extension
257
+ to `plugins.load.paths`, preserves existing `mcp.servers.aquifer.env` values,
258
+ and backs up `openclaw.json` before writing. Use `--dry-run --json` to inspect
259
+ package version, plugin config, MCP target, and extension link without changing
260
+ files.
261
+
262
+ 工具显示为 `aquifer__memory_recall`、`aquifer__historical_recall`、`aquifer__session_recall`、`aquifer__evidence_recall`、`aquifer__session_feedback`、`aquifer__memory_feedback`、`aquifer__memory_stats`、`aquifer__memory_pending`、`aquifer__feedback_stats`、`aquifer__session_bootstrap`(宿主自动添加 server 名称前缀)。
253
263
 
254
264
  OpenClaw 插件(`consumers/openclaw-plugin.js`)保留用于通过 `before_reset` 捕获 session,但**不是**推荐的工具分发路径。请使用 MCP。
255
265
 
@@ -649,7 +659,7 @@ opt-in pipeline(`createAquifer({stateChanges: {enabled, whitelist, confidenceT
649
659
 
650
660
  **Recall 没有返回结果** — 确保在 `commit` 之后执行了 `enrich`。原始 session 在丰富化(摘要 + embedding)之前不可搜索。运行 `aquifer stats` 检查摘要和 turn embedding 是否存在。
651
661
 
652
- **OpenClaw 工具不可见** — 在 `openclaw.json` 中使用 `mcp.servers.aquifer`,不要用插件。工具显示为 `aquifer__session_recall` 等。插件(`consumers/openclaw-plugin.js`)仅用于 session 捕获。
662
+ **OpenClaw 工具不可见** — 在 `openclaw.json` 中使用 `mcp.servers.aquifer`,不要用插件。工具显示为 `aquifer__memory_recall`、`aquifer__historical_recall`、`aquifer__session_recall` 等。插件(`consumers/openclaw-plugin.js`)仅用于 session 捕获。
653
663
 
654
664
  **Embedding 提供商连接被拒** — 检查 `AQUIFER_EMBED_BASE_URL` 是否可达。本地 Ollama 需确保服务正在运行且模型已拉取(`ollama pull bge-m3`)。
655
665
 
package/README_TW.md CHANGED
@@ -67,22 +67,33 @@ Claude Code、Claude Desktop 或任何支援 MCP 的 client——放進 `.mcp.js
67
67
 
68
68
  或直接跑:`DATABASE_URL=... EMBED_PROVIDER=ollama npx aquifer mcp`。MCP server 本身對 env 比較嚴格,`quickstart` 的 autodetect 是試用路徑,不是 production 路徑。
69
69
 
70
- 第一輪 rollout 先維持 `AQUIFER_MEMORY_SERVING_MODE=legacy`。只有在你要讓 `session_recall` 跟 `session_bootstrap` 提供 active curated memory 時,才切到 `curated`;`evidence_recall` 會保留為顯式 audit/debug 路徑。要 rollback 只要把 env 或 config 切回 `legacy`。
70
+ 第一輪 rollout 先維持 `AQUIFER_MEMORY_SERVING_MODE=legacy`。只有在你要讓相容性 `session_recall` 跟 `session_bootstrap` 提供 active curated memory 時,才切到 `curated`;`memory_recall` 是顯式 current-memory lookup,`historical_recall` 是 historical/session 平面,`evidence_recall` audit/debug 路徑。要 rollback 只要把 env 或 config 切回 `legacy`。
71
+
72
+ Curated serving 受 scope 邊界保護。`AQUIFER_MEMORY_ACTIVE_SCOPE_PATH` 是 inheritance 的順序路徑,`AQUIFER_MEMORY_ALLOWED_SCOPE_KEYS` 是 caller boundary。若沒有設定 `activeScopePath`,Aquifer 會預設使用 `global` 加上 configured `activeScopeKey`;沒有 active scope 時則只用 `global`。若沒有設定 `allowedScopeKeys`,Aquifer 會預設使用該 active scope path;runtime request 超出這個邊界時,會在讀 current memory rows 前直接拒絕。
71
73
 
72
74
  ### 常用指令
73
75
 
74
76
  | 目標 | 指令 |
75
77
  |---|---|
76
78
  | 驗證 setup | `npx aquifer quickstart` |
79
+ | 執行唯讀治理診斷 | `npx aquifer doctor --json` |
77
80
  | 啟動 MCP server | `npx aquifer mcp` |
78
81
  | 手動查記憶 | `npx aquifer recall "auth middleware"` |
82
+ | 解釋 current-memory 選取 | `npx aquifer explain bootstrap --active-scope-key project:aquifer --json` |
83
+ | 檢查 current-memory feedback issue | `npx aquifer review queue --scope-key project:aquifer --json` |
84
+ | 關閉已人工審查的記憶 queue item | `npx aquifer review resolve --memory-id 42 --resolution resolved --reason "verified current" --expected-latest-issue-feedback-id 9 --json` |
79
85
  | 規劃 curated memory 壓縮 | `npx aquifer compact --cadence daily --period-start 2026-04-27T00:00:00Z --period-end 2026-04-28T00:00:00Z` |
80
86
  | 產生 timer synthesis prompt | `npx aquifer operator compaction daily --include-synthesis-prompt --json` |
81
87
  | 套用已審核的 timer synthesis candidates | `npx aquifer operator compaction daily --synthesis-summary-file /tmp/timer-summary.json --apply --promote-candidates --json` |
82
- | 看儲存狀態 | `npx aquifer stats` |
83
- | 補跑 pending session | `npx aquifer backfill` |
88
+ | 檢查 Codex checkpoint spool 待處理檔 | `npx aquifer codex-recovery checkpoint-spool-status --json --limit 10` |
89
+ | 看記憶是否可用 | `npx aquifer stats` |
90
+ | 檢查已儲存內容準備狀態 | `npx aquifer backlog --json` |
91
+ | 準備已儲存內容 | `npx aquifer backfill` |
92
+
93
+ `stats`、`backlog`、MCP `memory_stats`、MCP `memory_pending` 預設共用同一個 public status surface:`Aquifer status` 或 `Saved content status`,必要時再加 `Available`、`Attention`、`Action`。需要 raw counters、source / agent / status 分桶、guidance 或 samples 時,CLI 用 `--diagnostics`,MCP 傳 `diagnostics: true`。
84
94
 
85
95
  Timer synthesis output 在 operator 用 `--promote-candidates` apply 前都只是 candidate material;光有 prompt 或 summary file 不會變成 active curated memory。
96
+ `codex-recovery checkpoint-spool-status --json` 只列出本機 spool 檔的 session、coverage、大小與修改時間,不會印出 checkpoint prompt 內容。
86
97
 
87
98
  需要 LLM 摘要、知識圖譜、OpenAI embedding、reranker 或維運細節,就往下看 [環境變數](#環境變數) 跟 [docs/setup.md](docs/setup.md)。
88
99
 
@@ -194,7 +205,7 @@ const results = await aquifer.recall('auth middleware 決定', {
194
205
 
195
206
  ## 主機整合(Host Integration)
196
207
 
197
- MCP 是主要的整合介面。Agent 主機連接 Aquifer MCP 伺服器,伺服器提供八個工具:`session_recall`、`evidence_recall`、`session_feedback`、`memory_feedback`、`feedback_stats`、`session_bootstrap`、`memory_stats`、`memory_pending`。
208
+ MCP 是主要的整合介面。Agent 主機連接 Aquifer MCP 伺服器,伺服器提供十個工具:`memory_recall`、`historical_recall`、`session_recall`、`evidence_recall`、`session_feedback`、`memory_feedback`、`memory_stats`、`memory_pending`、`feedback_stats`、`session_bootstrap`。
198
209
 
199
210
  | 整合方式 | 路由 | 狀態 | 使用時機 |
200
211
  |----------|------|------|----------|
@@ -225,31 +236,20 @@ MCP 是主要的整合介面。Agent 主機連接 Aquifer MCP 伺服器,伺服
225
236
  }
226
237
  ```
227
238
 
228
- 工具會以 `mcp__aquifer__session_recall`、`mcp__aquifer__evidence_recall`、`mcp__aquifer__session_bootstrap`、`mcp__aquifer__session_feedback`、`mcp__aquifer__memory_feedback`、`mcp__aquifer__feedback_stats`、`mcp__aquifer__memory_stats`、`mcp__aquifer__memory_pending` 等名稱出現。
239
+ 工具會以 `mcp__aquifer__memory_recall`、`mcp__aquifer__historical_recall`、`mcp__aquifer__session_recall`、`mcp__aquifer__evidence_recall`、`mcp__aquifer__session_feedback`、`mcp__aquifer__memory_feedback`、`mcp__aquifer__memory_stats`、`mcp__aquifer__memory_pending`、`mcp__aquifer__feedback_stats`、`mcp__aquifer__session_bootstrap` 等名稱出現。
229
240
 
230
241
  ### OpenClaw
231
242
 
232
- 加入 `openclaw.json` `mcp.servers` 區段:
243
+ 先把 Aquifer 安裝或更新到 OpenClaw host root,再讓 installer 從同一個 package root 接好 MCP server 與可選的 extension:
233
244
 
234
- ```json
235
- {
236
- "mcp": {
237
- "servers": {
238
- "aquifer": {
239
- "command": "node",
240
- "args": ["/path/to/aquifer/consumers/mcp.js"],
241
- "env": {
242
- "DATABASE_URL": "postgresql://...",
243
- "AQUIFER_EMBED_BASE_URL": "http://localhost:11434/v1",
244
- "AQUIFER_EMBED_MODEL": "bge-m3"
245
- }
246
- }
247
- }
248
- }
249
- }
245
+ ```bash
246
+ npm install --prefix "$OPENCLAW_HOME" @shadowforge0/aquifer-memory@latest
247
+ node "$OPENCLAW_HOME/node_modules/@shadowforge0/aquifer-memory/consumers/cli.js" install-openclaw --openclaw-home "$OPENCLAW_HOME"
250
248
  ```
251
249
 
252
- 工具會以 `aquifer__session_recall`、`aquifer__evidence_recall`、`aquifer__session_feedback`、`aquifer__memory_feedback`、`aquifer__feedback_stats`、`aquifer__session_bootstrap`、`aquifer__memory_stats`、`aquifer__memory_pending` 等名稱出現(主機自動加上伺服器名稱前綴)。
250
+ installer 會啟用 `plugins.entries["aquifer-memory"]`、把 extension 加進 `plugins.load.paths`、保留既有 `mcp.servers.aquifer.env`,並在寫入前備份 `openclaw.json`。可用 `--dry-run --json` 檢查 package 版本、plugin config、MCP 目標與 extension link,不改檔案。
251
+
252
+ 工具會以 `aquifer__memory_recall`、`aquifer__historical_recall`、`aquifer__session_recall`、`aquifer__evidence_recall`、`aquifer__session_feedback`、`aquifer__memory_feedback`、`aquifer__memory_stats`、`aquifer__memory_pending`、`aquifer__feedback_stats`、`aquifer__session_bootstrap` 等名稱出現(主機自動加上伺服器名稱前綴)。
253
253
 
254
254
  OpenClaw plugin(`consumers/openclaw-plugin.js`)保留用於 `before_reset` session 擷取,但**不是**建議的工具傳遞方式。請用 MCP。
255
255
 
@@ -282,6 +282,7 @@ OpenClaw plugin(`consumers/openclaw-plugin.js`)保留用於 `before_reset` s
282
282
  | `AQUIFER_MEMORY_SERVING_MODE` | 否 | 對外 serving mode:預設 `legacy`,可 opt-in `curated` | `curated` |
283
283
  | `AQUIFER_MEMORY_ACTIVE_SCOPE_KEY` | 否 | recall/bootstrap 預設 active curated scope | `project:aquifer` |
284
284
  | `AQUIFER_MEMORY_ACTIVE_SCOPE_PATH` | 否 | curated scope inheritance 的順序路徑 | `global,project:aquifer` |
285
+ | `AQUIFER_MEMORY_ALLOWED_SCOPE_KEYS` | 否 | curated scope request 的 caller boundary,預設為 configured active scope path | `global,project:aquifer` |
285
286
  | `AQUIFER_MIGRATIONS_MODE` | 否 | 啟動 handshake 模式:`apply`(預設)、`check`、`off` | `apply` |
286
287
  | `AQUIFER_MIGRATION_LOCK_TIMEOUT_MS` | 否 | advisory lock 等待上限,逾時拋 `AQ_MIGRATION_LOCK_TIMEOUT`(預設 30000) | `30000` |
287
288
  | `AQUIFER_INSIGHTS_DEDUP_MODE` | 否 | insights 語意去重模式:`off`(預設)、`shadow`、`enforce`——此欄位 env 蓋過程式碼設定,讓 operator 不用重部署就能緊急關閉 | `shadow` |
@@ -657,7 +658,7 @@ opt-in pipeline(`createAquifer({stateChanges: {enabled, whitelist, confidenceT
657
658
 
658
659
  **Recall 沒有回傳結果** — 確認你在 `commit` 之後有執行 `enrich`。未豐富化的 session 無法被搜尋(需要摘要 + embedding)。用 `aquifer stats` 檢查摘要和 turn embedding 是否存在。
659
660
 
660
- **OpenClaw 看不到工具** — 請在 `openclaw.json` 使用 `mcp.servers.aquifer`,不要用 plugin。工具會以 `aquifer__session_recall` 等名稱出現。Plugin(`consumers/openclaw-plugin.js`)僅用於 session 擷取。
661
+ **OpenClaw 看不到工具** — 請在 `openclaw.json` 使用 `mcp.servers.aquifer`,不要用 plugin。工具會以 `aquifer__memory_recall`、`aquifer__historical_recall`、`aquifer__session_recall` 等名稱出現。Plugin(`consumers/openclaw-plugin.js`)僅用於 session 擷取。
661
662
 
662
663
  **Embedding 供應商連線被拒** — 確認 `AQUIFER_EMBED_BASE_URL` 可以連通。若使用本地 Ollama,確保伺服器正在執行且模型已下載(`ollama pull bge-m3`)。
663
664
 
@@ -22,7 +22,8 @@
22
22
  "memory": {
23
23
  "servingMode": "legacy",
24
24
  "activeScopeKey": null,
25
- "activeScopePath": null
25
+ "activeScopePath": null,
26
+ "allowedScopeKeys": null
26
27
  },
27
28
  "codex": {
28
29
  "checkpoint": {