cogmem 3.6.2 → 3.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,11 +14,16 @@ Belief Graph writes keep ownership and evidence roles. Hermes may record assista
14
14
  ## Install
15
15
 
16
16
  ```bash
17
- COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
18
- cogmem init --yes --agent hermes
19
- cogmem doctor --fix --agent hermes --workspace .
20
- cogmem connect hermes --workspace . --auto
21
- cogmem connect hermes --workspace .
17
+ npm install cogmem@latest --save
18
+ COGMEM="./node_modules/.bin/cogmem"
19
+ "$COGMEM" doctor
20
+ "$COGMEM" connect hermes --workspace . --auto --force --json
21
+ ```
22
+
23
+ Use `cogmem init` only as an interactive operator wizard, not as an unattended agent install step:
24
+
25
+ ```bash
26
+ "$COGMEM" init --agent hermes --scope project
22
27
  ```
23
28
 
24
29
  Hermes integration is currently a skill plus MCP bridge. It does not replace a native Hermes memory provider and it does not patch Hermes runtime internals.
@@ -67,6 +72,19 @@ Import:
67
72
  cogmem import-hermes --workspace . --project hermes
68
73
  ```
69
74
 
75
+ After import:
76
+
77
+ ```bash
78
+ cogmem memory status --project hermes --json
79
+ cogmem episode status --project hermes --json
80
+ cogmem dream status --project hermes --json
81
+ cogmem dream tick --project hermes --mode auto --max-episodes 20 --json
82
+ cogmem memory candidates --project hermes --status candidate --json
83
+ cogmem memory govern --project hermes --limit 100 --json
84
+ cogmem memory candidates --project hermes --status needs_confirmation --json
85
+ cogmem memory review --project hermes --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <user-event-id> --json
86
+ ```
87
+
70
88
  If Hermes stores memory somewhere else:
71
89
 
72
90
  ```bash
@@ -89,7 +107,7 @@ Dream stores explicit user clarification as organizational correction evidence r
89
107
 
90
108
  After upgrades, reload MCP. Rerun `cogmem connect hermes --workspace . --auto --force` when MCP wiring, allow-listed tools, or the installed skill bundle changed.
91
109
 
92
- Cogmem 3.6.2 exposes seven read-only/idempotent Memory Atlas query tools plus explicit `cogmem_graph_touch`, and installs from npm by default. Use explore for broad memory inventory/history, search and node for a known concept, path/neighbors for relations, timeline for ordered reconstruction, and normal recall for a direct fact. Query facets combine the user's actual project, time, topic, entity/target, memory-kind, action, and keyword conditions like table filters, so cold memory can be revived without requiring an entity-time-action tuple. Touch only nodes actually used, and follow returned event IDs to raw evidence before quoting exact wording.
110
+ Cogmem 3.6.4 exposes seven read-only/idempotent Memory Atlas query tools plus explicit `cogmem_graph_touch`, installs from npm by default, and prevents empty imported episodes from blocking Dream. Use explore for broad memory inventory/history, search and node for a known concept, path/neighbors for relations, timeline for ordered reconstruction, and normal recall for a direct fact. Query facets combine the user's actual project, time, topic, entity/target, memory-kind, action, and keyword conditions like table filters, so cold memory can be revived without requiring an entity-time-action tuple. Touch only nodes actually used, and follow returned event IDs to raw evidence before quoting exact wording.
93
111
 
94
112
  ## Runtime
95
113
 
@@ -147,7 +165,7 @@ cogmem memory map --project hermes --json
147
165
  cogmem memory tick --project hermes --json
148
166
  cogmem memory bind --project hermes --json
149
167
  cogmem episode status --project hermes --json
150
- cogmem dream tick --project hermes --mode auto --json
168
+ cogmem dream tick --project hermes --mode auto --max-episodes 20 --json
151
169
  ```
152
170
 
153
171
  `memory map` includes Memory Binding and Graph Recall counters. Bindings attach valuable user raw events to stable topic/entity paths, fuse same-claim evidence into claim-key clusters, and create graph anchors for raw-ledger drill-down; they are not verified long-term facts. If `memory tick` suggests `bind_raw_events`, run `memory bind` to backfill imported Hermes raw user events into the binding graph.
@@ -31,27 +31,56 @@ cogmem prospective due --project <projectId>
31
31
 
32
32
  ## Install
33
33
 
34
- Run from the Hermes workspace root:
34
+ Run from the Hermes workspace root. Prefer a workspace-local npm dependency so Hermes and Cogmem upgrade together:
35
+
36
+ ```bash
37
+ npm install cogmem@latest --save
38
+ COGMEM="./node_modules/.bin/cogmem"
39
+ "$COGMEM" doctor
40
+ "$COGMEM" connect hermes --workspace . --auto --force --json
41
+ ```
42
+
43
+ If the workspace already has Cogmem installed locally, keep using the local binary. If there is no local binary but a global install exists, use global. If neither exists, install first:
44
+
45
+ ```bash
46
+ if [ -x ./node_modules/.bin/cogmem ]; then
47
+ COGMEM="./node_modules/.bin/cogmem"
48
+ elif command -v cogmem >/dev/null 2>&1; then
49
+ COGMEM="cogmem"
50
+ else
51
+ npm install cogmem@latest --save
52
+ COGMEM="./node_modules/.bin/cogmem"
53
+ fi
54
+ ```
55
+
56
+ Global npm is also supported when the operator wants one CLI for every workspace:
57
+
58
+ ```bash
59
+ npm install -g cogmem@latest
60
+ COGMEM="cogmem"
61
+ "$COGMEM" connect hermes --workspace . --auto --force --json
62
+ ```
63
+
64
+ The one-line installer remains available for machines that do not already have Bun. Use `COGMEM_SKIP_INIT=1` for agent-run installs so the installer does not start the interactive wizard:
35
65
 
36
66
  ```bash
37
67
  COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
38
- cogmem init --yes --agent hermes
39
- cogmem doctor
40
- cogmem connect hermes --workspace . --auto --force
68
+ COGMEM="cogmem"
69
+ "$COGMEM" connect hermes --workspace . --auto --force --json
41
70
  ```
42
71
 
43
- Use project-local config only when this workspace needs isolation:
72
+ Do not run `cogmem init` as an unattended agent action. `cogmem init` is an interactive configuration wizard. Use it only when an operator is present or explicitly asks for a guided setup:
44
73
 
45
74
  ```bash
46
- cogmem init --yes --agent hermes --scope project
75
+ "$COGMEM" init --agent hermes --scope project
47
76
  ```
48
77
 
49
- The default install creates:
78
+ Hermes workspaces should normally use project-local config when the workspace owns its memory:
50
79
 
51
80
  ```text
52
- ~/.cogmem/config.toml
53
- ~/.cogmem/memory.db
54
- ~/.cogmem/snapshots/
81
+ .cogmem/config.toml
82
+ .cogmem/memory.db
83
+ .cogmem/snapshots/
55
84
  ```
56
85
 
57
86
  To embed imported memories with a local quantized model, run Ollama locally and configure the kernel before importing:
@@ -98,7 +127,7 @@ cogmem update --yes
98
127
  # Manual equivalent: cogmem migrate --yes --backup
99
128
  ```
100
129
 
101
- `cogmem update --yes` installs `cogmem@latest` from npm, runs the newly installed backed-up migration with the resolved config, and then reports that the Hermes MCP server or agent host must be reloaded. Agents should inspect `cogmem update --dry-run --json` or `cogmem migrate --dry-run --json` when an operator wants a preview. Schema migration preserves Raw Ledger events; it updates governed projections and indexes only.
130
+ `cogmem update --yes` installs `cogmem@latest` from npm, runs the newly installed backed-up migration with the resolved config, and then reports that the Hermes MCP server or agent host must be reloaded. For npm global installs, `cogmem update --yes` resolves to `npm install -g cogmem@latest` instead of writing into the current directory. Agents should inspect `cogmem update --dry-run --json` or `cogmem migrate --dry-run --json` when an operator wants a preview. Schema migration preserves Raw Ledger events; dry-run is read-only and updates governed projections and indexes only during apply.
102
131
 
103
132
  Default Hermes memory contract:
104
133
 
@@ -151,12 +180,20 @@ cogmem import-hermes --workspace . --project hermes --session ./hermes.normalize
151
180
 
152
181
  The importer is idempotent. Re-running it skips records already imported into the same memory database.
153
182
 
154
- Run the curator/governance loop under host supervision after import and during normal use:
183
+ Cogmem 3.6.4 skips import batch sealing for empty episode boundaries and Dream skips legacy empty episode jobs instead of blocking the whole queue. If `episode status` shows `dreamError` beginning with `episode_empty`, inspect the source events and use episode repair instead of editing SQLite rows.
184
+
185
+ Run the maintenance loop under host supervision after import and during normal use. `needs_confirmation` is a human review queue, not the Dream backlog, and `memory govern` promotes only ordinary `candidate` rows:
155
186
 
156
187
  ```bash
188
+ cogmem memory status --project hermes --json
157
189
  cogmem episode status --project hermes --json
158
- cogmem dream tick --project hermes --mode auto --json
159
- cogmem memory govern --project hermes --json
190
+ cogmem dream status --project hermes --json
191
+ cogmem dream tick --project hermes --mode auto --max-episodes 20 --json
192
+ cogmem memory candidates --project hermes --status candidate --json
193
+ cogmem memory govern --project hermes --limit 100 --json
194
+ cogmem memory candidates --project hermes --status needs_confirmation --json
195
+ cogmem memory review --project hermes --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <distinct-user-event-id> --json
196
+ cogmem memory recall --query "<verification question>" --project hermes --agent hermes --json
160
197
  ```
161
198
 
162
199
  A host timer may run this bounded tick periodically. The tick exits after inspecting the backlog and performs no work when no sealed episode is ready.
@@ -296,8 +333,8 @@ Do not edit `~/.hermes/config.yaml` to point `memory.provider` at `cogmem` until
296
333
  ```yaml
297
334
  mcp_servers:
298
335
  cogmem:
299
- command: "/resolved/path/to/cogmem-mcp"
300
- args: []
336
+ command: "/resolved/path/to/cogmem"
337
+ args: ["mcp"]
301
338
  enabled: true
302
339
  tools:
303
340
  include:
@@ -329,7 +366,7 @@ mcp_servers:
329
366
  - cogmem_prospective
330
367
  ```
331
368
 
332
- The command path is resolved by `cogmem connect hermes`: it uses `COGMEM_MCP_BIN` when explicitly set, then a workspace-local `node_modules/.bin/cogmem-mcp` when present, then the globally linked `cogmem-mcp` from the one-line installer.
369
+ The command path is resolved by `cogmem connect hermes`: it uses `COGMEM_BIN` when explicitly set, then a workspace-local `node_modules/.bin/cogmem`, then global `cogmem`, and passes `mcp` as the first argument. `COGMEM_MCP_BIN` and `cogmem-mcp` remain compatibility paths for existing host configs.
333
370
 
334
371
  When Hermes calls `cogmem_recall`, it should pass `projectId: "hermes"` and may omit `agentId`; the MCP bridge infers `agentId` from `projectId`. The returned `items` use the same shape as `cogmem memory recall --project hermes --agent hermes --json`, including `raw_ledger` items, labeled `sourceContext` events, `sourceContext.window`, and `sourceContext.locator.command` when vectors are empty or compiled evidence misses.
335
372
 
@@ -1,4 +1,4 @@
1
- # Cogmem 3.6.2 Operations Reference for Hermes
1
+ # Cogmem 3.6.4 Operations Reference for Hermes
2
2
 
3
3
  Read this file when installing, upgrading, importing, repairing, or operating Cogmem. `SKILL.md` contains the decision rules; this file records the operational commands.
4
4
 
@@ -21,14 +21,35 @@ Read this file when installing, upgrading, importing, repairing, or operating Co
21
21
 
22
22
  ## Install, connect, and reload
23
23
 
24
+ Recommended workspace-local npm install:
25
+
24
26
  ```bash
25
- COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
26
- cogmem init --yes --agent hermes
27
- cogmem doctor
28
- cogmem connect hermes --workspace . --auto --force --json
27
+ npm install cogmem@latest --save
28
+ COGMEM="./node_modules/.bin/cogmem"
29
+ "$COGMEM" doctor
30
+ "$COGMEM" connect hermes --workspace . --auto --force --json
31
+ ```
32
+
33
+ Use this resolver in agent-run scripts:
34
+
35
+ ```bash
36
+ if [ -x ./node_modules/.bin/cogmem ]; then
37
+ COGMEM="./node_modules/.bin/cogmem"
38
+ elif command -v cogmem >/dev/null 2>&1; then
39
+ COGMEM="cogmem"
40
+ else
41
+ npm install cogmem@latest --save
42
+ COGMEM="./node_modules/.bin/cogmem"
43
+ fi
44
+ ```
45
+
46
+ Use `npm install -g cogmem@latest` only when the operator wants a global CLI. The one-line installer is still supported with `COGMEM_SKIP_INIT=1`, but do not run `cogmem init` unattended. `cogmem init` is an interactive wizard; run it only with an operator present:
47
+
48
+ ```bash
49
+ "$COGMEM" init --agent hermes --scope project
29
50
  ```
30
51
 
31
- Then run `/reload-mcp` inside Hermes. `connect --auto` installs this skill bundle and updates the Hermes MCP allow-list; it does not claim a native `memory.provider` integration.
52
+ Then run `/reload-mcp` inside Hermes. `connect --auto` installs this skill bundle and updates the Hermes MCP allow-list; it does not claim a native `memory.provider` integration. New configs start the bridge as `cogmem mcp`; `cogmem-mcp` remains a compatibility bin for older host configs.
32
53
 
33
54
  ## Upgrade and migrate
34
55
 
@@ -38,7 +59,7 @@ For normal upgrades, use one command:
38
59
  cogmem update --yes
39
60
  ```
40
61
 
41
- `cogmem update --yes` installs `cogmem@latest` from npm, then runs post-install work through the newly installed local CLI. With a valid config it runs `cogmem migrate --yes --backup --config <config>` and reports that the Hermes MCP server or agent host must be reloaded.
62
+ `cogmem update --yes` installs `cogmem@latest` from npm, then runs post-install work through the newly installed CLI. For npm global installs it uses `npm install -g cogmem@latest`; for the one-line installer it updates `~/.cogmem/pkg`; for a workspace dependency it updates that workspace. With a valid config it runs `cogmem migrate --yes --backup --config <config>` and reports that the Hermes MCP server or agent host must be reloaded.
42
63
 
43
64
  Preview the package and migration plan without writing:
44
65
 
@@ -53,7 +74,7 @@ cogmem doctor
53
74
  cogmem connect hermes --workspace . --auto --force --json
54
75
  ```
55
76
 
56
- The backed-up command upgrades 3.5.2 schema 24, an existing 3.6.0 schema-26 database, or a pre-release schema-25 test database to the 3.6.2 schema-27 state in one run and preserves Raw Ledger evidence. Reload MCP after reconnecting.
77
+ The backed-up command upgrades 3.5.2 schema 24, an existing 3.6.0 schema-26 database, or a pre-release schema-25 test database to the 3.6.4 schema-27 state in one run and preserves Raw Ledger evidence. `--dry-run` is read-only and does not create `_schema_migrations`. Reload MCP after reconnecting.
57
78
 
58
79
  ## Import Hermes memory
59
80
 
@@ -90,6 +111,22 @@ cogmem episode import --project hermes --session import-2026 --source-agent herm
90
111
 
91
112
  Use stable `externalMessageId` values for MCP append/import. If an MCP batch warns `auto_identity_not_safe_across_split_batches`, assign IDs before splitting or retrying.
92
113
 
114
+ After import, verify semantic maintenance in this exact order:
115
+
116
+ ```bash
117
+ cogmem memory status --project hermes --json
118
+ cogmem episode status --project hermes --json
119
+ cogmem dream status --project hermes --json
120
+ cogmem dream tick --project hermes --mode auto --max-episodes 20 --json
121
+ cogmem memory candidates --project hermes --status candidate --json
122
+ cogmem memory govern --project hermes --limit 100 --json
123
+ cogmem memory candidates --project hermes --status needs_confirmation --json
124
+ cogmem memory review --project hermes --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <distinct-user-event-id> --json
125
+ cogmem memory recall --query "<verification question>" --project hermes --agent hermes --json
126
+ ```
127
+
128
+ `needs_confirmation` is not a Dream backlog. `memory govern` does not approve it. Use `memory review` with explicit evidence. Cogmem 3.6.4 skips import batch sealing for empty episode boundaries and marks legacy empty Dream jobs as skipped so one bad imported episode cannot block the queue. If `episode status` reports `episode_empty_*`, inspect the episode and repair boundaries with the audited episode repair commands.
129
+
93
130
  ## Inspect, recall, and drill down
94
131
 
95
132
  ```bash
@@ -15,12 +15,17 @@ This writes `<workspace>/skills/cogmem-memory/SKILL.md`, which OpenClaw discover
15
15
  Run from the OpenClaw workspace root:
16
16
 
17
17
  ```bash
18
- COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
19
- cogmem init --yes --agent openclaw --scope project
20
- cogmem doctor --fix --agent openclaw --workspace .
21
- cogmem connect openclaw --workspace .
22
- cogmem connect openclaw --workspace . --auto --force
23
- cogmem openclaw diagnose --workspace . --json
18
+ npm install cogmem@latest --save
19
+ COGMEM="./node_modules/.bin/cogmem"
20
+ "$COGMEM" doctor
21
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
22
+ "$COGMEM" openclaw diagnose --workspace . --json
23
+ ```
24
+
25
+ Do not run `cogmem init` as an unattended agent action. It is an interactive wizard. Use it only when an operator is present:
26
+
27
+ ```bash
28
+ "$COGMEM" init --agent openclaw --scope project
24
29
  ```
25
30
 
26
31
  The OpenClaw workspace install creates:
@@ -92,6 +97,22 @@ cogmem import-openclaw --workspace . --project openclaw --json
92
97
  ```
93
98
 
94
99
  Real non-JSON imports print source-level and embedding+ingest progress to stderr. Use `--json --progress` to keep JSON on stdout while streaming progress to stderr, or `--no-progress` when a wrapper needs quiet stderr.
100
+ Cogmem 3.6.4 skips import batch sealing for empty episode boundaries and skips legacy empty Dream jobs so one bad imported episode cannot block the queue.
101
+
102
+ After import, use this order:
103
+
104
+ ```bash
105
+ cogmem memory status --project openclaw --json
106
+ cogmem episode status --project openclaw --json
107
+ cogmem dream status --project openclaw --json
108
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
109
+ cogmem memory candidates --project openclaw --status candidate --json
110
+ cogmem memory govern --project openclaw --limit 100 --json
111
+ cogmem memory candidates --project openclaw --status needs_confirmation --json
112
+ cogmem memory review --project openclaw --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <user-event-id> --json
113
+ ```
114
+
115
+ `needs_confirmation` is not the Dream backlog. `memory govern` does not approve it; use `memory review` with explicit evidence.
95
116
 
96
117
  Import scope:
97
118
 
@@ -9,11 +9,16 @@ Belief Graph writes keep ownership and evidence roles. OpenClaw may record assis
9
9
  ## Install
10
10
 
11
11
  ```bash
12
- COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
13
- cogmem init --yes --agent openclaw --scope project
14
- cogmem doctor --fix --agent openclaw --workspace .
15
- cogmem connect openclaw --workspace .
16
- cogmem connect openclaw --workspace . --auto --force
12
+ npm install cogmem@latest --save
13
+ COGMEM="./node_modules/.bin/cogmem"
14
+ "$COGMEM" doctor
15
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
16
+ ```
17
+
18
+ Use `cogmem init` only as an interactive operator wizard, not as an unattended agent install step:
19
+
20
+ ```bash
21
+ "$COGMEM" init --agent openclaw --scope project
17
22
  ```
18
23
 
19
24
  ## Local Quantized Embeddings
@@ -53,7 +58,7 @@ Then run:
53
58
 
54
59
  ```bash
55
60
  cogmem episode status --project openclaw --json
56
- cogmem dream tick --project openclaw --mode auto --json
61
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
57
62
  cogmem memory govern --project openclaw --json
58
63
  cogmem memory candidates --project openclaw --status candidate --json
59
64
  ```
@@ -78,7 +83,7 @@ cogmem memory tick --project openclaw --json
78
83
  cogmem memory bind --project openclaw --json
79
84
  ```
80
85
 
81
- Cogmem 3.6.2 keeps the 3.6.x Memory Atlas and OpenClaw reliability work, then makes npm the default install and update channel. The auto plugin uses one shared bridge/kernel lifecycle for graph exploration, evidence-bearing node/timeline drill-down, and recall, so OpenClaw does not need MCP for broad inventory/history questions. Atlas combines the query's actual project, time, topic, entity/target, memory-kind, action, and keyword conditions like table filters; no fixed entity-time-action tuple is required.
86
+ Cogmem 3.6.4 keeps the 3.6.x Memory Atlas and OpenClaw reliability work, makes npm the default install and update channel, and prevents empty imported episodes from blocking Dream. The auto plugin uses one shared bridge/kernel lifecycle for graph exploration, evidence-bearing node/timeline drill-down, and recall, so OpenClaw does not need MCP for broad inventory/history questions. Atlas combines the query's actual project, time, topic, entity/target, memory-kind, action, and keyword conditions like table filters; no fixed entity-time-action tuple is required.
82
87
 
83
88
  ```bash
84
89
  cogmem memory graph-explore --project openclaw --query "去年与 Hermes 有关的决定" --json
@@ -118,6 +123,19 @@ Import:
118
123
  cogmem import-openclaw --workspace . --project openclaw
119
124
  ```
120
125
 
126
+ After import:
127
+
128
+ ```bash
129
+ cogmem memory status --project openclaw --json
130
+ cogmem episode status --project openclaw --json
131
+ cogmem dream status --project openclaw --json
132
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
133
+ cogmem memory candidates --project openclaw --status candidate --json
134
+ cogmem memory govern --project openclaw --limit 100 --json
135
+ cogmem memory candidates --project openclaw --status needs_confirmation --json
136
+ cogmem memory review --project openclaw --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <user-event-id> --json
137
+ ```
138
+
121
139
  Single source files and batches can be imported explicitly:
122
140
 
123
141
  ```bash
@@ -206,7 +224,7 @@ To make future OpenClaw turns automatically recall and record memory, run:
206
224
  cogmem connect openclaw --workspace . --auto --force
207
225
  ```
208
226
 
209
- `--auto` installs `<workspace>/extensions/cogmem-auto-memory/`, patches OpenClaw `plugins.load.paths`, and enables a local plugin wrapper with `before_prompt_build` and `agent_end` hooks. The wrapper calls `KernelAgentMemoryBackend` through the public `cogmem` API via a Bun bridge; core still does not import OpenClaw. Plugin 0.6.2 uses singleton queue/spawn locks, stale-lock recovery, and bounded remember batches so queued `agent_end` recording does not hold SQLite open longer than necessary.
227
+ `--auto` installs `<workspace>/extensions/cogmem-auto-memory/`, patches OpenClaw `plugins.load.paths`, and enables a local plugin wrapper with `before_prompt_build` and `agent_end` hooks. The wrapper calls `KernelAgentMemoryBackend` through the public `cogmem` API via a Bun bridge; core still does not import OpenClaw. Plugin 0.6.3 uses singleton queue/spawn locks, stale-lock and stale-processing recovery, and bounded remember batches so queued `agent_end` recording does not hold SQLite open longer than necessary.
210
228
 
211
229
  The wrapper does not rewrite OpenClaw's native prompt, tool instructions, skills, or conversation order. It only prepends Cogmem-owned blocks:
212
230
 
@@ -31,22 +31,51 @@ cogmem prospective due --project <projectId>
31
31
 
32
32
  ## Install
33
33
 
34
- Run from the OpenClaw workspace root:
34
+ Run from the OpenClaw workspace root. Prefer a workspace-local npm dependency so OpenClaw and Cogmem upgrade together:
35
+
36
+ ```bash
37
+ npm install cogmem@latest --save
38
+ COGMEM="./node_modules/.bin/cogmem"
39
+ "$COGMEM" doctor
40
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
41
+ ```
42
+
43
+ If the workspace already has Cogmem installed locally, keep using the local binary. If there is no local binary but a global install exists, use global. If neither exists, install first:
44
+
45
+ ```bash
46
+ if [ -x ./node_modules/.bin/cogmem ]; then
47
+ COGMEM="./node_modules/.bin/cogmem"
48
+ elif command -v cogmem >/dev/null 2>&1; then
49
+ COGMEM="cogmem"
50
+ else
51
+ npm install cogmem@latest --save
52
+ COGMEM="./node_modules/.bin/cogmem"
53
+ fi
54
+ ```
55
+
56
+ Global npm is also supported when the operator wants one CLI for every workspace:
57
+
58
+ ```bash
59
+ npm install -g cogmem@latest
60
+ COGMEM="cogmem"
61
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
62
+ ```
63
+
64
+ The one-line installer remains available for machines that do not already have Bun. Use `COGMEM_SKIP_INIT=1` for agent-run installs so the installer does not start the interactive wizard:
35
65
 
36
66
  ```bash
37
67
  COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
38
- cogmem init --yes --agent openclaw --scope project
39
- cogmem doctor
40
- cogmem connect openclaw --workspace . --auto --force
68
+ COGMEM="cogmem"
69
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
41
70
  ```
42
71
 
43
- This creates project-local kernel config and storage under `.cogmem/`, which is the recommended OpenClaw workspace setup.
72
+ Do not run `cogmem init` as an unattended agent action. `cogmem init` is an interactive configuration wizard. Use it only when an operator is present or explicitly asks for a guided setup:
44
73
 
45
74
  ```bash
46
- cogmem init --yes --agent openclaw --scope project
75
+ "$COGMEM" init --agent openclaw --scope project
47
76
  ```
48
77
 
49
- The install creates:
78
+ OpenClaw workspaces should normally use project-local kernel config and storage:
50
79
 
51
80
  ```text
52
81
  .cogmem/config.toml
@@ -98,7 +127,7 @@ cogmem update --yes
98
127
  # Manual equivalent: cogmem migrate --yes --backup && cogmem doctor --fix --agent openclaw --workspace . --plugin-only
99
128
  ```
100
129
 
101
- `cogmem update --yes` installs `cogmem@latest` from npm, runs the newly installed backed-up migration with the resolved config, refreshes OpenClaw's generated plugin files when the integration is configured, and then reports that the OpenClaw gateway or agent host must be restarted. Agents should inspect `cogmem update --dry-run --json` or `cogmem migrate --dry-run --json` when an operator wants a preview. Schema migration preserves Raw Ledger events; it updates governed projections and indexes only.
130
+ `cogmem update --yes` installs `cogmem@latest` from npm, runs the newly installed backed-up migration with the resolved config, refreshes OpenClaw's generated plugin files when the integration is configured, and then reports that the OpenClaw gateway or agent host must be restarted. For npm global installs, `cogmem update --yes` resolves to `npm install -g cogmem@latest` instead of writing into the current directory. Agents should inspect `cogmem update --dry-run --json` or `cogmem migrate --dry-run --json` when an operator wants a preview. Schema migration preserves Raw Ledger events; dry-run is read-only and updates governed projections and indexes only during apply.
102
131
 
103
132
  After any 3.5.2 -> 3.6.x OpenClaw upgrade, refresh the generated OpenClaw plugin files. Use the plugin-only path first when OpenClaw is misbehaving, because it does not open the Cogmem database:
104
133
 
@@ -147,6 +176,21 @@ cogmem import-openclaw --workspace . --project openclaw --json
147
176
 
148
177
  The importer is idempotent. Re-running it skips records already imported into the same memory database.
149
178
  Real non-JSON imports print source-level and embedding+ingest progress to stderr. Use `--json --progress` to keep JSON on stdout while streaming progress to stderr, or `--no-progress` when a wrapper needs quiet stderr.
179
+ Cogmem 3.6.4 skips import batch sealing for empty episode boundaries and Dream skips legacy empty episode jobs instead of blocking the whole queue. If `episode status` shows `dreamError` beginning with `episode_empty`, inspect the source events and use episode repair instead of editing SQLite rows.
180
+
181
+ After import, run the maintenance loop in this order. `needs_confirmation` is a human review queue, not the Dream backlog, and `memory govern` promotes only ordinary `candidate` rows:
182
+
183
+ ```bash
184
+ cogmem memory status --project openclaw --json
185
+ cogmem episode status --project openclaw --json
186
+ cogmem dream status --project openclaw --json
187
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
188
+ cogmem memory candidates --project openclaw --status candidate --json
189
+ cogmem memory govern --project openclaw --limit 100 --json
190
+ cogmem memory candidates --project openclaw --status needs_confirmation --json
191
+ cogmem memory review --project openclaw --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <distinct-user-event-id> --json
192
+ cogmem memory recall --query "<verification question>" --project openclaw --agent openclaw --json
193
+ ```
150
194
 
151
195
  Imported sources:
152
196
 
@@ -298,7 +342,7 @@ cogmem connect openclaw --workspace . --auto --force
298
342
 
299
343
  `--auto` writes `<workspace>/extensions/cogmem-auto-memory/`, patches `plugins.load.paths`, and enables `hooks.allowPromptInjection=true` and `hooks.allowConversationAccess=true` for the wrapper. The wrapper registers `before_prompt_build` for governed recall and `agent_end` for turn recording, then calls `KernelAgentMemoryBackend` through `cogmem` public API via a Bun bridge. Core does not import OpenClaw.
300
344
 
301
- Queued remember is the default. `agent_end` appends a durable JSONL job under `.cogmem/queue/openclaw-remember.jsonl` and starts a singleton drainer, so Telegram or gateway responses are not blocked by embeddings, SQLite writes, or slow local models. Plugin 0.6.2 acquires the queue lock before opening Cogmem, recovers stale lock directories older than `rememberDrainTimeoutMs`, writes `owner.json` lock metadata, and processes bounded batches controlled by `rememberDrainBatchSize` (default `20`). If a drain fails, the job is retried and then moved to a dead-letter file instead of being silently discarded.
345
+ Queued remember is the default. `agent_end` appends a durable JSONL job under `.cogmem/queue/openclaw-remember.jsonl` and starts a singleton drainer, so Telegram or gateway responses are not blocked by embeddings, SQLite writes, or slow local models. Plugin 0.6.3 acquires the queue lock before opening Cogmem, recovers stale lock directories and stale `.processing` queue files older than `rememberDrainTimeoutMs`, writes `owner.json` lock metadata, and processes bounded batches controlled by `rememberDrainBatchSize` (default `20`). If a drain fails, the job is retried and then moved to a dead-letter file instead of being silently discarded.
302
346
 
303
347
  When automatic memory recording looks stuck, do not delete queue files first. Diagnose the plugin and locks:
304
348
 
@@ -309,6 +353,8 @@ cat .cogmem/queue/openclaw-remember.jsonl.lock/owner.json 2>/dev/null || true
309
353
  cat .cogmem/queue/openclaw-remember.jsonl.spawn.lock/owner.json 2>/dev/null || true
310
354
  ```
311
355
 
356
+ `openclaw diagnose` reports pending queue lines, dead-letter lines, active lock metadata, spawn-lock metadata, and stale `.processing` files. Use that JSON before deleting anything manually.
357
+
312
358
  If `plugin.current=false`, refresh without opening the database:
313
359
 
314
360
  ```bash
@@ -349,7 +395,7 @@ Run curation manually or from a host-owned schedule:
349
395
 
350
396
  ```bash
351
397
  cogmem episode status --project openclaw --json
352
- cogmem dream tick --project openclaw --mode auto --json
398
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
353
399
  cogmem memory govern --project openclaw --json
354
400
  cogmem memory candidates --project openclaw --status candidate --json
355
401
  ```
@@ -385,7 +431,7 @@ Explicit user clarification may create an organizational `correction` record. Do
385
431
 
386
432
  OpenClaw session exports may place the body below an empty `user:` or `assistant:` header and may repeat an assistant block exactly. Import accepts that layout, collapses only adjacent exact export duplicates, and uses the `# Session: ... UTC` heading as the chronological timestamp base. Do not rewrite the file solely to make it importable.
387
433
 
388
- If rejected provider diagnostics mention invalid memory-model output but later curation works, seal or repair the affected episode, run `cogmem dream tick --project openclaw --mode auto --json`, then run `cogmem memory govern --project openclaw --json`; recovered provider runs mark older provider diagnostics as `superseded`.
434
+ If rejected provider diagnostics mention invalid memory-model output but later curation works, seal or repair the affected episode, run `cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json`, then run `cogmem memory govern --project openclaw --json`; recovered provider runs mark older provider diagnostics as `superseded`.
389
435
 
390
436
  After package updates or config drift, repair the host wiring:
391
437
 
@@ -431,9 +477,11 @@ openclaw gateway restart
431
477
  If the OpenClaw environment exposes an MCP client, use the core MCP bridge instead of writing a native plugin first:
432
478
 
433
479
  ```bash
434
- cogmem-mcp
480
+ cogmem mcp
435
481
  ```
436
482
 
483
+ `cogmem-mcp` remains a compatibility bin for older host configs.
484
+
437
485
  Expose these tools to the agent:
438
486
 
439
487
  - `cogmem_remember_turn`
@@ -1,4 +1,4 @@
1
- # Cogmem 3.6.2 Operations Reference for OpenClaw
1
+ # Cogmem 3.6.4 Operations Reference for OpenClaw
2
2
 
3
3
  Read this file when installing, upgrading, importing, repairing, or operating Cogmem. `SKILL.md` contains the decision rules; this file is the command reference.
4
4
 
@@ -26,11 +26,32 @@ Read this file when installing, upgrading, importing, repairing, or operating Co
26
26
 
27
27
  ## Install and connect
28
28
 
29
+ Recommended workspace-local npm install:
30
+
29
31
  ```bash
30
- COGMEM_SKIP_INIT=1 curl -fsSL https://raw.githubusercontent.com/liuqin164/cogmem/main/install.sh | bash
31
- cogmem init --yes --agent openclaw --scope project
32
- cogmem doctor
33
- cogmem connect openclaw --workspace . --auto --force --json
32
+ npm install cogmem@latest --save
33
+ COGMEM="./node_modules/.bin/cogmem"
34
+ "$COGMEM" doctor
35
+ "$COGMEM" connect openclaw --workspace . --auto --force --json
36
+ ```
37
+
38
+ Use this resolver in agent-run scripts:
39
+
40
+ ```bash
41
+ if [ -x ./node_modules/.bin/cogmem ]; then
42
+ COGMEM="./node_modules/.bin/cogmem"
43
+ elif command -v cogmem >/dev/null 2>&1; then
44
+ COGMEM="cogmem"
45
+ else
46
+ npm install cogmem@latest --save
47
+ COGMEM="./node_modules/.bin/cogmem"
48
+ fi
49
+ ```
50
+
51
+ Use `npm install -g cogmem@latest` only when the operator wants a global CLI. The one-line installer is still supported with `COGMEM_SKIP_INIT=1`, but do not run `cogmem init` unattended. `cogmem init` is an interactive wizard; run it only with an operator present:
52
+
53
+ ```bash
54
+ "$COGMEM" init --agent openclaw --scope project
34
55
  ```
35
56
 
36
57
  Restart the OpenClaw Gateway after plugin or config changes. `connect --auto` installs the direct OpenClaw hook bridge; OpenClaw does not need MCP for automatic recall, recording, or Atlas navigation.
@@ -44,7 +65,7 @@ cogmem update --yes
44
65
  openclaw gateway restart
45
66
  ```
46
67
 
47
- `cogmem update --yes` installs `cogmem@latest` from npm, then runs post-install work through the newly installed local CLI. With a valid config it runs `cogmem migrate --yes --backup --config <config>`. When OpenClaw integration is enabled, it also runs `cogmem doctor --fix --agent openclaw --plugin-only --config <config> --workspace <workspace>` so stale generated plugin files are replaced before restart.
68
+ `cogmem update --yes` installs `cogmem@latest` from npm, then runs post-install work through the newly installed CLI. For npm global installs it uses `npm install -g cogmem@latest`; for the one-line installer it updates `~/.cogmem/pkg`; for a workspace dependency it updates that workspace. With a valid config it runs `cogmem migrate --yes --backup --config <config>`. When OpenClaw integration is enabled, it also runs `cogmem doctor --fix --agent openclaw --plugin-only --config <config> --workspace <workspace>` so stale generated plugin files are replaced before restart.
48
69
 
49
70
  Preview the package, migration, and plugin-refresh plan without writing:
50
71
 
@@ -62,7 +83,7 @@ openclaw gateway restart
62
83
  cogmem openclaw diagnose --workspace . --json
63
84
  ```
64
85
 
65
- The second command upgrades 3.5.2 schema 24, an existing 3.6.0 schema-26 database, or a pre-release schema-25 test database to the 3.6.2 schema-27 state in one run. It preserves Raw Ledger evidence. Keep the returned `backupPath` until verification passes.
86
+ The second command upgrades 3.5.2 schema 24, an existing 3.6.0 schema-26 database, or a pre-release schema-25 test database to the 3.6.4 schema-27 state in one run. It preserves Raw Ledger evidence. Keep the returned `backupPath` until verification passes. `--dry-run` is read-only and does not create `_schema_migrations`.
66
87
 
67
88
  After upgrading the package/database, refresh OpenClaw's generated plugin files. `doctor --plugin-only` avoids opening the Cogmem kernel, so it can repair stale `extensions/cogmem-auto-memory/index.js` and `bridge.mjs` even when an old drainer has SQLite busy. Use `connect --auto --force` when intentionally reinstalling the full integration and patching OpenClaw config:
68
89
 
@@ -75,15 +96,16 @@ Use `cogmem openclaw diagnose --workspace . --json` when automatic memory blocks
75
96
  - `plugin.current=false`: generated files are stale; run plugin-only fix and restart gateway.
76
97
  - no `audit.lastBeforePromptBuild`: plugin is not loaded or the hook did not fire.
77
98
  - `audit.lastBeforePromptBuild.action=error`: bridge or DB failure; inspect `reason`, `bridgeCommand`, and `dbLocked`.
78
- - `action=inject` but no visible block: inspect `returnedInjectionShape`. Plugin 0.6.2 returns `prependContext`, `context`, and `promptPrefix`; if OpenClaw still ignores all three, the host hook contract changed and the OpenClaw plugin API must be checked before blaming recall.
99
+ - `action=inject` but no visible block: inspect `returnedInjectionShape`. Plugin 0.6.3 returns `prependContext`, `context`, and `promptPrefix`; if OpenClaw still ignores all three, the host hook contract changed and the OpenClaw plugin API must be checked before blaming recall.
79
100
 
80
- Plugin 0.6.2 queue behavior:
101
+ Plugin 0.6.3 queue behavior:
81
102
 
82
103
  - `agent_end` only appends durable JSONL jobs, then starts at most one drainer through queue/spawn locks.
83
104
  - `drain-remember-queue` acquires the queue lock before opening Cogmem or SQLite. A second drainer exits without opening the DB.
84
- - Stale `.cogmem/queue/openclaw-remember.jsonl.lock` and `.spawn.lock` directories older than `rememberDrainTimeoutMs` are recovered automatically and carry `owner.json` metadata for diagnosis.
105
+ - Stale `.cogmem/queue/openclaw-remember.jsonl.lock`, `.spawn.lock`, and `.processing` files older than `rememberDrainTimeoutMs` are recovered automatically and carry enough metadata for diagnosis.
85
106
  - `rememberDrainBatchSize` defaults to `20`, so a busy workspace drains bounded batches and releases DB handles quickly. Lower it temporarily if OpenClaw shares a slow SQLite disk.
86
107
  - Failed jobs retry up to `rememberMaxAttempts`; exhausted jobs move to `.dead.jsonl`.
108
+ - `cogmem openclaw diagnose --workspace . --json` reports pending queue lines, dead-letter lines, lock owners, spawn-lock owners, and `.processing` files.
87
109
 
88
110
  If the queue is not draining, diagnose before deleting files:
89
111
 
@@ -112,6 +134,22 @@ cogmem import-openclaw --workspace . --project openclaw --dry-run --json
112
134
  cogmem import-openclaw --workspace . --project openclaw --json
113
135
  ```
114
136
 
137
+ After import, verify semantic maintenance in this exact order:
138
+
139
+ ```bash
140
+ cogmem memory status --project openclaw --json
141
+ cogmem episode status --project openclaw --json
142
+ cogmem dream status --project openclaw --json
143
+ cogmem dream tick --project openclaw --mode auto --max-episodes 20 --json
144
+ cogmem memory candidates --project openclaw --status candidate --json
145
+ cogmem memory govern --project openclaw --limit 100 --json
146
+ cogmem memory candidates --project openclaw --status needs_confirmation --json
147
+ cogmem memory review --project openclaw --id <candidate-id> --action approve --actor <operator> --reason "confirmed by user" --confirmation-event <distinct-user-event-id> --json
148
+ cogmem memory recall --query "<verification question>" --project openclaw --agent openclaw --json
149
+ ```
150
+
151
+ `needs_confirmation` is not a Dream backlog. `memory govern` does not approve it. Use `memory review` with explicit evidence. Cogmem 3.6.4 skips import batch sealing for empty episode boundaries and marks legacy empty Dream jobs as skipped so one bad imported episode cannot block the queue. If `episode status` reports `episode_empty_*`, inspect the episode and repair boundaries with the audited episode repair commands.
152
+
115
153
  Pass explicit sources when discovery is not enough:
116
154
 
117
155
  ```bash
@@ -257,6 +295,7 @@ cogmem prospective confirm --project openclaw --id <candidate-id> --evidence <us
257
295
  ## MCP and direct-plugin choice
258
296
 
259
297
  - OpenClaw automatic hooks use the direct bridge installed by `connect --auto`.
298
+ - Start the MCP bridge with `cogmem mcp`; `cogmem-mcp` remains a compatibility bin for older host configs.
260
299
  - Use MCP tools when an agent host supports MCP and needs explicit graph/review operations.
261
300
  - Broad inventory/history: `cogmem_graph_explore`.
262
301
  - Known node: `cogmem_graph_search`, then `cogmem_graph_node`.