@jonathangu/openclawbrain 0.3.0 → 0.3.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.
- package/README.md +140 -290
- package/docs/END_STATE.md +106 -94
- package/docs/EVIDENCE.md +71 -23
- package/docs/RELEASE_CONTRACT.md +46 -32
- package/docs/agent-tools.md +65 -34
- package/docs/architecture.md +128 -142
- package/docs/configuration.md +62 -25
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/channels-status.txt +20 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/config-snapshot.json +94 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/doctor.json +14 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/gateway-probe.txt +24 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/gateway-status.txt +31 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/init-capture.json +15 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/logs.txt +357 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/status-all.txt +61 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/status.json +275 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/summary.md +18 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/trace.json +222 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/validation-report.json +1515 -0
- package/docs/evidence/2026-03-16/1fc8ee6fd7892e3deb27d111434df948bca2a66b/workspace-inventory.json +4 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/channels-status.txt +20 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/config-snapshot.json +94 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/doctor.json +14 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/gateway-probe.txt +24 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/gateway-status.txt +31 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/init-capture.json +15 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/logs.txt +362 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/status-all.txt +61 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/status.json +275 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/summary.md +21 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/trace.json +222 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/validation-report.json +4400 -0
- package/docs/evidence/2026-03-16/4ccd71a22418b9170128b8d948f5a95801a10380/workspace-inventory.json +4 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/channels-status.txt +31 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/config-snapshot.json +94 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/doctor.json +14 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/gateway-probe.txt +34 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/gateway-status.txt +41 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/logs.txt +441 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/status-all.txt +60 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/status.json +276 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/summary.md +13 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/trace.json +4 -0
- package/docs/evidence/2026-03-16/d93f09feea123a08d020fcad8a4523b6c1d26507/validation-report.json +387 -0
- package/docs/tui.md +11 -4
- package/index.ts +194 -1
- package/package.json +1 -1
- package/src/brain-cli.ts +12 -1
- package/src/brain-harvest/scanner.ts +286 -16
- package/src/brain-harvest/self.ts +134 -6
- package/src/brain-runtime/evidence-detectors.ts +3 -1
- package/src/brain-runtime/harvester-extension.ts +3 -0
- package/src/brain-runtime/service.ts +2 -0
- package/src/brain-store/embedding.ts +29 -8
- package/src/brain-worker/worker.ts +40 -0
- package/src/engine.ts +1 -0
package/README.md
CHANGED
|
@@ -1,77 +1,90 @@
|
|
|
1
1
|
# OpenClawBrain v2
|
|
2
2
|
|
|
3
|
-
OpenClawBrain
|
|
3
|
+
OpenClawBrain is an OpenClaw plugin that keeps the inherited lossless transcript-memory substrate and adds a learned routing layer on top.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Front doors:
|
|
6
|
+
- Project site: https://openclawbrain.ai
|
|
7
|
+
- GitHub repo: https://github.com/jonathangu/openclawbrain
|
|
8
|
+
- Jonathan Gu's 2016 reinforcement-learning paper: https://openclawbrain.ai/jonathan-gu-2016-reinforcement-learning-paper.pdf
|
|
6
9
|
|
|
7
|
-
The earlier spike
|
|
10
|
+
This repo is the active v2 trunk. The earlier spike lives at [jonathangu/openclawbrain-v1-spike-archive](https://github.com/jonathangu/openclawbrain-v1-spike-archive).
|
|
8
11
|
|
|
9
12
|
## Release truth in 30 seconds
|
|
10
13
|
|
|
11
14
|
| Public label | Status | What it means right now |
|
|
12
15
|
| --- | --- | --- |
|
|
13
|
-
| **paper-faithful core** |
|
|
14
|
-
| **live-path implemented** |
|
|
15
|
-
| **operationally validated** | not yet |
|
|
16
|
+
| **paper-faithful core** | yes | finite-horizon traversal, stochastic policy, terminal reward, full-trajectory REINFORCE updates, learned seed routing, and immutable promoted packs are implemented in the current repo |
|
|
17
|
+
| **live-path implemented** | yes | OpenClaw runtime decisioning, shadow mode, correction-first assembly, immediate `brain_teach` retrieval, and replay-gated promotion are wired into the live path |
|
|
18
|
+
| **operationally validated** | not yet | deterministic runtime proof is real, but the full sterile host-surface harness is still not frozen end to end; bundle-level mutation evaluation, CI-enforced proof gates, and packaging/type hardening remain open |
|
|
16
19
|
|
|
17
20
|
If you want the exact contract rather than the pitch, read [docs/RELEASE_CONTRACT.md](docs/RELEASE_CONTRACT.md).
|
|
18
21
|
|
|
19
|
-
##
|
|
22
|
+
## What OpenClawBrain does
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
- [Quick start](#quick-start)
|
|
23
|
-
- [Configuration](#configuration)
|
|
24
|
-
- [Operator Commands](#operator-commands)
|
|
25
|
-
- [Fallback Behavior](#fallback-behavior)
|
|
26
|
-
- [Operational gaps still open](#operational-gaps-still-open)
|
|
27
|
-
- [Finish path to 1.0](#finish-path-to-10)
|
|
28
|
-
- [Documentation](#documentation)
|
|
29
|
-
- [Development](#development)
|
|
30
|
-
- [License](#license)
|
|
24
|
+
OpenClawBrain has two layers:
|
|
31
25
|
|
|
32
|
-
|
|
26
|
+
1. **LCM / transcript memory**
|
|
27
|
+
- persists conversation history in SQLite
|
|
28
|
+
- compacts older turns into a summary DAG instead of dropping them
|
|
29
|
+
- assembles summaries plus fresh raw turns back into model context
|
|
30
|
+
- exposes recall tools like `lcm_grep`, `lcm_describe`, and `lcm_expand_query`
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
2. **Learned routing layer**
|
|
33
|
+
- decides whether to use learned retrieval, shadow the route, or skip with an explicit reason
|
|
34
|
+
- retrieves from immutable promoted packs only
|
|
35
|
+
- supports immediate `brain_teach` correction retrieval
|
|
36
|
+
- trains in the background from human/self/scanner/teacher evidence
|
|
37
|
+
- gates promotion with replay checks before serving new packs
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
2. **Summarizes chunks** of older messages into summaries using your configured LLM
|
|
38
|
-
3. **Condenses summaries** into higher-level nodes as they accumulate, forming a DAG (directed acyclic graph)
|
|
39
|
-
4. **Assembles context** each turn by combining summaries + recent raw messages
|
|
40
|
-
5. **Provides tools** (`lcm_grep`, `lcm_describe`, `lcm_expand`) so agents can search and recall details from compacted history
|
|
39
|
+
Nothing in the transcript-memory substrate is supposed to be thrown away casually. The point is to keep lossless recall while adding a learned context-routing layer that can improve over time.
|
|
41
40
|
|
|
42
|
-
|
|
41
|
+
## Current reality
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
### True in the repo now
|
|
44
|
+
- paper-faithful traversal/update path exists
|
|
45
|
+
- child-worker mode is a real runtime boundary, with supervisor/protocol/restart truth
|
|
46
|
+
- shadow mode is a real runtime decision rather than a fake `use_brain` variant
|
|
47
|
+
- deterministic session-bound `brain_teach` proof exists
|
|
48
|
+
- deterministic runtime proof exists for immediate teach retrieval and serve-from-last-promoted-pack after worker failure
|
|
49
|
+
- structured raw evidence and worker-side trust-ordered resolution are real
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
### Implemented but not frozen
|
|
52
|
+
- the real OpenClaw host-surface validation lane
|
|
53
|
+
- mutation evaluation at the intended bundle level
|
|
54
|
+
- CI-enforced proof gates
|
|
55
|
+
- clean npm/package boundary for outside operators
|
|
56
|
+
|
|
57
|
+
### Honest current blocker
|
|
58
|
+
The current docs and runtime story should stay aligned with this exact state:
|
|
59
|
+
- sterile preflight/config seam has been repaired
|
|
60
|
+
- deterministic runtime proof is repaired and repeatably passing on fresh isolated roots
|
|
61
|
+
- the full sterile host harness is **still not frozen end to end** because it currently stalls during `openclawbrain init` before the host-turn proof bundle completes
|
|
62
|
+
|
|
63
|
+
That means the remaining pain is mainly host/operator/release-boundary work, not another learning-architecture rewrite.
|
|
51
64
|
|
|
52
65
|
## Quick start
|
|
53
66
|
|
|
54
67
|
### Prerequisites
|
|
55
|
-
|
|
56
|
-
- OpenClaw with plugin context engine support
|
|
68
|
+
- OpenClaw
|
|
57
69
|
- Node.js 22+
|
|
58
|
-
-
|
|
70
|
+
- an LLM provider for transcript summarization
|
|
71
|
+
- an embeddings provider for `openclawbrain init`, learned retrieval, and `brain_teach`
|
|
59
72
|
|
|
60
|
-
### Install
|
|
73
|
+
### Install
|
|
61
74
|
|
|
62
|
-
|
|
75
|
+
Published package:
|
|
63
76
|
|
|
64
77
|
```bash
|
|
65
78
|
openclaw plugins install @jonathangu/openclawbrain
|
|
66
79
|
```
|
|
67
80
|
|
|
68
|
-
|
|
81
|
+
From a local OpenClaw checkout:
|
|
69
82
|
|
|
70
83
|
```bash
|
|
71
84
|
pnpm openclaw plugins install @jonathangu/openclawbrain
|
|
72
85
|
```
|
|
73
86
|
|
|
74
|
-
For local
|
|
87
|
+
For local development, link your working tree instead of copying files:
|
|
75
88
|
|
|
76
89
|
```bash
|
|
77
90
|
openclaw plugins install --link /path/to/openclawbrain
|
|
@@ -79,33 +92,15 @@ openclaw plugins install --link /path/to/openclawbrain
|
|
|
79
92
|
# pnpm openclaw plugins install --link /path/to/openclawbrain
|
|
80
93
|
```
|
|
81
94
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
### Configure OpenClaw
|
|
85
|
-
|
|
86
|
-
In most cases, no manual JSON edits are needed after `openclaw plugins install`.
|
|
87
|
-
|
|
88
|
-
Important current truth: older OpenClaw builds exposed a `plugins.slots.contextEngine` seam, but the current host build used for Phase 1 validation no longer accepts that slot and no longer exposes `api.registerContextEngine`. Until OpenClawBrain adapts to the current plugin/memory seam, do **not** treat old `contextEngine` slot examples as valid host-surface setup guidance.
|
|
89
|
-
|
|
90
|
-
Restart OpenClaw after configuration changes.
|
|
91
|
-
|
|
92
|
-
### Initialize the brain index
|
|
93
|
-
|
|
94
|
-
The lossless transcript path works immediately. Learned retrieval needs an explicit init pass:
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
openclawbrain init /path/to/your/workspace
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
`openclawbrain init` scans the workspace, chunks source material, computes embeddings, builds the initial graph, writes `state.db`, creates pack `v000001`, and promotes it.
|
|
95
|
+
### Important host-seam truth
|
|
101
96
|
|
|
102
|
-
|
|
97
|
+
On current OpenClaw hosts, **do not manually write** `plugins.slots.contextEngine` for OpenClawBrain.
|
|
103
98
|
|
|
104
|
-
|
|
99
|
+
That older seam is no longer the stable installation boundary. OpenClawBrain now includes a hook-based compatibility bridge for hosts where `api.registerContextEngine` is gone, and the plugin installer is the supported path.
|
|
105
100
|
|
|
106
|
-
|
|
101
|
+
If you are debugging an older host build, treat any manual slot/config surgery as version-specific debugging rather than the normal install story.
|
|
107
102
|
|
|
108
|
-
|
|
103
|
+
### Recommended starting config
|
|
109
104
|
|
|
110
105
|
```json
|
|
111
106
|
{
|
|
@@ -118,8 +113,9 @@ Add an `openclawbrain` entry under `plugins.entries` in your OpenClaw config:
|
|
|
118
113
|
"contextThreshold": 0.75,
|
|
119
114
|
"incrementalMaxDepth": -1,
|
|
120
115
|
"brainRoot": "~/.openclaw/openclawbrain",
|
|
121
|
-
"brainEmbeddingProvider": "
|
|
122
|
-
"brainEmbeddingModel": "
|
|
116
|
+
"brainEmbeddingProvider": "ollama",
|
|
117
|
+
"brainEmbeddingModel": "bge-large:latest",
|
|
118
|
+
"brainWorkerMode": "child"
|
|
123
119
|
}
|
|
124
120
|
}
|
|
125
121
|
}
|
|
@@ -127,14 +123,33 @@ Add an `openclawbrain` entry under `plugins.entries` in your OpenClaw config:
|
|
|
127
123
|
}
|
|
128
124
|
```
|
|
129
125
|
|
|
130
|
-
|
|
126
|
+
Why these defaults:
|
|
127
|
+
- `freshTailCount=32` keeps recent turns raw
|
|
128
|
+
- `contextThreshold=0.75` leaves response headroom
|
|
129
|
+
- `incrementalMaxDepth=-1` lets compaction keep cascading when needed
|
|
130
|
+
- `brainWorkerMode=child` is the practical operator boundary
|
|
131
|
+
|
|
132
|
+
### Initialize the graph
|
|
133
|
+
|
|
134
|
+
The transcript-memory layer works immediately after install. The learned layer needs an explicit init pass:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
openclawbrain init /path/to/workspace
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
That creates the initial graph, writes `state.db`, creates pack `v000001`, and promotes it.
|
|
141
|
+
|
|
142
|
+
## Embeddings
|
|
143
|
+
|
|
144
|
+
OpenClawBrain currently targets tested OpenAI-compatible `/v1/embeddings` APIs. That includes local Ollama endpoints and remote OpenAI-compatible services.
|
|
145
|
+
|
|
146
|
+
### Local Ollama
|
|
131
147
|
|
|
132
148
|
```json
|
|
133
149
|
{
|
|
134
150
|
"plugins": {
|
|
135
151
|
"entries": {
|
|
136
152
|
"openclawbrain": {
|
|
137
|
-
"enabled": true,
|
|
138
153
|
"config": {
|
|
139
154
|
"brainEmbeddingProvider": "ollama",
|
|
140
155
|
"brainEmbeddingModel": "bge-large:latest"
|
|
@@ -145,267 +160,102 @@ For local dogfood or other self-hosted installs, Ollama is now a first-class emb
|
|
|
145
160
|
}
|
|
146
161
|
```
|
|
147
162
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
### Environment variables
|
|
151
|
-
|
|
152
|
-
| Variable | Default | Description |
|
|
153
|
-
|----------|---------|-------------|
|
|
154
|
-
| `LCM_ENABLED` | `true` | Enable/disable the plugin |
|
|
155
|
-
| `LCM_DATABASE_PATH` | `~/.openclaw/lcm.db` | Path to the SQLite database |
|
|
156
|
-
| `LCM_CONTEXT_THRESHOLD` | `0.75` | Fraction of context window that triggers compaction (0.0–1.0) |
|
|
157
|
-
| `LCM_FRESH_TAIL_COUNT` | `32` | Number of recent messages protected from compaction |
|
|
158
|
-
| `LCM_LEAF_MIN_FANOUT` | `8` | Minimum raw messages per leaf summary |
|
|
159
|
-
| `LCM_CONDENSED_MIN_FANOUT` | `4` | Minimum summaries per condensed node |
|
|
160
|
-
| `LCM_CONDENSED_MIN_FANOUT_HARD` | `2` | Relaxed fanout for forced compaction sweeps |
|
|
161
|
-
| `LCM_INCREMENTAL_MAX_DEPTH` | `0` | How deep incremental compaction goes (0 = leaf only, -1 = unlimited) |
|
|
162
|
-
| `LCM_LEAF_CHUNK_TOKENS` | `20000` | Max source tokens per leaf compaction chunk |
|
|
163
|
-
| `LCM_LEAF_TARGET_TOKENS` | `1200` | Target token count for leaf summaries |
|
|
164
|
-
| `LCM_CONDENSED_TARGET_TOKENS` | `2000` | Target token count for condensed summaries |
|
|
165
|
-
| `LCM_MAX_EXPAND_TOKENS` | `4000` | Token cap for sub-agent expansion queries |
|
|
166
|
-
| `LCM_LARGE_FILE_TOKEN_THRESHOLD` | `25000` | File blocks above this size are intercepted and stored separately |
|
|
167
|
-
| `LCM_LARGE_FILE_SUMMARY_PROVIDER` | `""` | Provider override for large-file summarization |
|
|
168
|
-
| `LCM_LARGE_FILE_SUMMARY_MODEL` | `""` | Model override for large-file summarization |
|
|
169
|
-
| `LCM_SUMMARY_MODEL` | *(from OpenClaw)* | Model for summarization (e.g. `anthropic/claude-sonnet-4-20250514`) |
|
|
170
|
-
| `LCM_SUMMARY_PROVIDER` | *(from OpenClaw)* | Provider override for summarization |
|
|
171
|
-
| `LCM_AUTOCOMPACT_DISABLED` | `false` | Disable automatic compaction after turns |
|
|
172
|
-
| `LCM_PRUNE_HEARTBEAT_OK` | `false` | Retroactively delete `HEARTBEAT_OK` turn cycles from LCM storage |
|
|
173
|
-
| `OPENCLAWBRAIN_ENABLED` | `true` | Enable/disable the learning layer |
|
|
174
|
-
| `OPENCLAWBRAIN_ROOT` | `~/.openclaw/openclawbrain` | Root directory for `state.db` and immutable packs |
|
|
175
|
-
| `OPENCLAWBRAIN_EMBEDDING_PROVIDER` | `openai` | Embedding provider (`openai`, `openai-resp`, or `ollama`) |
|
|
176
|
-
| `OPENCLAWBRAIN_EMBEDDING_MODEL` | `""` | Embedding model required for `init`, retrieval, and `brain_teach` |
|
|
177
|
-
| `OPENCLAWBRAIN_EMBEDDING_BASE_URL` | `""` | Optional embeddings API base URL override; `ollama` defaults to `http://127.0.0.1:11434/v1` |
|
|
178
|
-
| `OPENCLAWBRAIN_EMBEDDING_API_KEY` | `""` | Optional explicit API key for authenticated embedding proxies / nonstandard OpenAI-compatible endpoints |
|
|
179
|
-
| `OPENCLAWBRAIN_MAX_HOPS` | `8` | Hard traversal cap |
|
|
180
|
-
| `OPENCLAWBRAIN_MAX_SEEDS` | `10` | Max seed nodes per query |
|
|
181
|
-
| `OPENCLAWBRAIN_SEMANTIC_THRESHOLD` | `0.7` | Minimum seed similarity |
|
|
182
|
-
| `OPENCLAWBRAIN_SHADOW_MODE` | `false` | Record brain routes and traces without injecting learned context into the prompt |
|
|
183
|
-
| `OPENCLAWBRAIN_TRAINER_INTERVAL_MS` | `30000` | Background worker interval |
|
|
184
|
-
|
|
185
|
-
## Operator Commands
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
openclawbrain init [workspace]
|
|
189
|
-
openclawbrain status
|
|
190
|
-
openclawbrain trace [traceId]
|
|
191
|
-
openclawbrain replay
|
|
192
|
-
openclawbrain promote
|
|
193
|
-
openclawbrain rollback [version]
|
|
194
|
-
openclawbrain disable
|
|
195
|
-
openclawbrain enable
|
|
196
|
-
openclawbrain doctor
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
## Fallback Behavior
|
|
200
|
-
|
|
201
|
-
- If the brain has not been initialized, the plugin serves LCM-only context.
|
|
202
|
-
- If embeddings are not configured, learned retrieval and `brain_teach` stay disabled.
|
|
203
|
-
- Local loopback embedding endpoints (for example Ollama on `127.0.0.1` / `localhost`) do not require a bearer token; remote OpenAI-compatible endpoints still do unless you provide `OPENCLAWBRAIN_EMBEDDING_API_KEY`.
|
|
204
|
-
- `openclawbrain status` and `openclawbrain doctor` expose the resolved embedding provider / model / base URL / auth mode so operator truth stays visible.
|
|
205
|
-
- If the background worker is unavailable, serving still uses the last promoted pack.
|
|
206
|
-
- `brain_teach` now binds taught corrections to the active conversation when invoked from a live tool session.
|
|
207
|
-
- Seed learning is persisted as explicit per-node seed weights and exposed in traces.
|
|
208
|
-
|
|
209
|
-
## Operational gaps still open
|
|
210
|
-
|
|
211
|
-
This repo is already beyond “foundation only,” but it is **not** yet operationally validated end to end.
|
|
212
|
-
|
|
213
|
-
- Embedding support currently targets tested OpenAI-compatible `/v1/embeddings` APIs, including local Ollama-style endpoints.
|
|
214
|
-
- Child-worker mode now runs behind a dedicated supervisor with explicit protocol messages, restart accounting, reload acknowledgements, and stronger status/doctor truth; the remaining operator-proof gap is on the host-surface seam, not the learner boundary itself.
|
|
215
|
-
- Structured evidence harvesting now exists end to end (raw evidence → resolved labels with explicit episode attribution), harvested completions can now persist multiple concurrent raw signals with extractor metadata before worker resolution, and structured tool-result/function-output parts now feed self-evidence detection before regex fallback; the remaining gap is that source detection still leans on heuristics more than the intended richer human/self/scanner evidence flow.
|
|
216
|
-
- Deterministic session-bound `brain_teach` proof now exists, but the current raw host lane is blocked by stale OpenClaw seam drift (`plugins.slots.contextEngine` / `api.registerContextEngine`) and the final narrow worker-down host claim is still unfrozen.
|
|
217
|
-
- Replay-gated promotion exists, but mutation evaluation has not yet reached the intended bundle-level replay contract.
|
|
218
|
-
- Upstream `openclaw/plugin-sdk` type drift still affects full-repo `npx tsc --noEmit`.
|
|
219
|
-
|
|
220
|
-
## Finish path to 1.0
|
|
221
|
-
|
|
222
|
-
1. **Align repo truth with repo reality** so the README and canonical docs cleanly separate what is true now, implemented-but-not-frozen, and not done yet.
|
|
223
|
-
2. **Finish the real OpenClaw host-surface validation harness** by adapting the stale current-OpenClaw plugin/config seam first, then freezing recurrent routing, static bypass, shadow mode, worker-down fail-open, and explicit skip modes on that repaired boundary.
|
|
224
|
-
3. **Finish the evidence pipeline** so structured evidence tied to exact episodes outruns heuristic-only harvesting.
|
|
225
|
-
4. **Upgrade mutation evaluation to replay-gated bundles** instead of proposal-by-proposal promotion.
|
|
226
|
-
5. **Freeze the proof ladder** with dated artifact bundles under `docs/evidence/`.
|
|
227
|
-
6. **Clean the packaging and type surface** until another OpenClaw operator can install, validate, and recover the plugin without tribal knowledge.
|
|
228
|
-
|
|
229
|
-
### Recommended starting configuration
|
|
163
|
+
Default base URL:
|
|
230
164
|
|
|
165
|
+
```text
|
|
166
|
+
http://127.0.0.1:11434/v1
|
|
231
167
|
```
|
|
232
|
-
LCM_FRESH_TAIL_COUNT=32
|
|
233
|
-
LCM_INCREMENTAL_MAX_DEPTH=-1
|
|
234
|
-
LCM_CONTEXT_THRESHOLD=0.75
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
- **freshTailCount=32** protects the last 32 messages from compaction, giving the model enough recent context for continuity.
|
|
238
|
-
- **incrementalMaxDepth=-1** enables unlimited automatic condensation after each compaction pass — the DAG cascades as deep as needed. Set to `0` (default) for leaf-only, or a positive integer for a specific depth cap.
|
|
239
|
-
- **contextThreshold=0.75** triggers compaction when context reaches 75% of the model's window, leaving headroom for the model's response.
|
|
240
|
-
|
|
241
|
-
### OpenClaw session reset settings
|
|
242
168
|
|
|
243
|
-
|
|
169
|
+
### Remote OpenAI-compatible endpoint
|
|
244
170
|
|
|
245
171
|
```json
|
|
246
172
|
{
|
|
247
|
-
"
|
|
248
|
-
"
|
|
249
|
-
"
|
|
250
|
-
|
|
173
|
+
"plugins": {
|
|
174
|
+
"entries": {
|
|
175
|
+
"openclawbrain": {
|
|
176
|
+
"config": {
|
|
177
|
+
"brainEmbeddingProvider": "openai",
|
|
178
|
+
"brainEmbeddingModel": "text-embedding-3-large",
|
|
179
|
+
"brainEmbeddingBaseUrl": "https://your-endpoint.example/v1"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
251
182
|
}
|
|
252
183
|
}
|
|
253
184
|
}
|
|
254
185
|
```
|
|
255
186
|
|
|
256
|
-
|
|
257
|
-
- `session.reset.idleMinutes` is the actual reset interval in minutes.
|
|
258
|
-
- OpenClaw does **not** currently enforce a maximum `idleMinutes`; in source it is validated only as a positive integer.
|
|
259
|
-
- If you also use daily reset mode, `idleMinutes` acts as a secondary guard and the session resets when **either** the daily boundary or the idle window is reached first.
|
|
260
|
-
- Legacy `session.idleMinutes` still works, but OpenClaw prefers `session.reset.idleMinutes`.
|
|
261
|
-
|
|
262
|
-
Useful values:
|
|
263
|
-
|
|
264
|
-
- `1440` = 1 day
|
|
265
|
-
- `10080` = 7 days
|
|
266
|
-
- `43200` = 30 days
|
|
267
|
-
- `525600` = 365 days
|
|
187
|
+
If the remote endpoint needs auth, set `OPENCLAWBRAIN_EMBEDDING_API_KEY`.
|
|
268
188
|
|
|
269
|
-
|
|
189
|
+
## Operator commands
|
|
270
190
|
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
191
|
+
```bash
|
|
192
|
+
openclawbrain init [workspace]
|
|
193
|
+
openclawbrain status
|
|
194
|
+
openclawbrain trace [traceId]
|
|
195
|
+
openclawbrain replay
|
|
196
|
+
openclawbrain promote
|
|
197
|
+
openclawbrain rollback [version]
|
|
198
|
+
openclawbrain disable
|
|
199
|
+
openclawbrain enable
|
|
200
|
+
openclawbrain doctor
|
|
280
201
|
```
|
|
281
202
|
|
|
282
|
-
##
|
|
203
|
+
## Validation commands
|
|
283
204
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
- [Release contract](docs/RELEASE_CONTRACT.md)
|
|
287
|
-
- [Definitive end-state guide](docs/END_STATE.md)
|
|
288
|
-
- [Evidence ladder](docs/EVIDENCE.md)
|
|
289
|
-
|
|
290
|
-
Supporting docs:
|
|
291
|
-
|
|
292
|
-
- [Configuration guide](docs/configuration.md)
|
|
293
|
-
- [LCM architecture](docs/architecture.md)
|
|
294
|
-
- [Agent tools](docs/agent-tools.md)
|
|
295
|
-
- [TUI Reference](docs/tui.md)
|
|
296
|
-
- [lcm-tui](tui/README.md)
|
|
297
|
-
- [Optional: enable FTS5 for fast full-text search](docs/fts5.md)
|
|
298
|
-
|
|
299
|
-
## Development
|
|
205
|
+
Deterministic runtime proof harness:
|
|
300
206
|
|
|
301
207
|
```bash
|
|
302
|
-
|
|
303
|
-
npx vitest
|
|
304
|
-
|
|
305
|
-
# Type check
|
|
306
|
-
npx tsc --noEmit
|
|
307
|
-
|
|
308
|
-
# Run a specific test file
|
|
309
|
-
npx vitest test/engine.test.ts
|
|
208
|
+
pnpm exec tsx scripts/validate-brain-runtime-behavior.ts
|
|
310
209
|
```
|
|
311
210
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
A disposable host-app validation scaffold now lives at:
|
|
211
|
+
Disposable host-surface harness:
|
|
315
212
|
|
|
316
213
|
```bash
|
|
317
214
|
node scripts/validate-openclaw-install.mjs --setup-only
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
For Phase 1 close-out work, prefer the explicit sterile validation lane instead of a mixed live-machine layout:
|
|
321
215
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
node scripts/validate-openclaw-install.mjs
|
|
216
|
+
OPENCLAWBRAIN_VALIDATION_EMBEDDING_PROVIDER=ollama \
|
|
217
|
+
OPENCLAWBRAIN_VALIDATION_EMBEDDING_MODEL=bge-large:latest \
|
|
218
|
+
OPENCLAWBRAIN_VALIDATION_MODEL=ollama/qwen2.5:7b-instruct \
|
|
219
|
+
node scripts/validate-openclaw-install.mjs
|
|
326
220
|
```
|
|
327
221
|
|
|
328
|
-
|
|
222
|
+
Current honest boundary: the runtime proof harness is a real release signal today; the full sterile host harness is still not a frozen end-to-end release gate.
|
|
329
223
|
|
|
330
|
-
|
|
331
|
-
OPENCLAWBRAIN_VALIDATION_LANE_NAME=ocbphase1 \
|
|
332
|
-
OPENCLAWBRAIN_VALIDATION_GATEWAY_PORT=19031 \
|
|
333
|
-
OPENCLAWBRAIN_VALIDATION_EMBEDDING_MODEL=text-embedding-3-small \
|
|
334
|
-
OPENCLAWBRAIN_VALIDATION_MODEL=openai/gpt-4.1-mini \
|
|
335
|
-
node scripts/validate-openclaw-install.mjs --sterile-lane
|
|
336
|
-
```
|
|
224
|
+
## Fallback behavior
|
|
337
225
|
|
|
338
|
-
|
|
226
|
+
- if the brain has not been initialized, the plugin serves transcript-memory context only
|
|
227
|
+
- if embeddings are not configured, learned retrieval and `brain_teach` stay disabled
|
|
228
|
+
- local loopback embedding endpoints do not require a bearer token by default
|
|
229
|
+
- if the background worker is unavailable, serving still uses the last promoted pack
|
|
230
|
+
- `openclawbrain status` and `openclawbrain doctor` surface resolved embedding and worker truth so operator state is visible
|
|
339
231
|
|
|
340
|
-
|
|
232
|
+
## What is still open
|
|
341
233
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
234
|
+
1. freeze the host-surface proof boundary honestly
|
|
235
|
+
2. move mutation evaluation from proposal-level gating to bundle-level replay decisions
|
|
236
|
+
3. turn the evidence ladder into a real CI/release gate
|
|
237
|
+
4. clean the npm/package boundary and type surface
|
|
238
|
+
5. keep pushing evidence sourcing away from heuristics toward structured signals
|
|
239
|
+
|
|
240
|
+
## Documentation map
|
|
348
241
|
|
|
349
|
-
|
|
242
|
+
- [docs/RELEASE_CONTRACT.md](docs/RELEASE_CONTRACT.md) — exact truth contract: true now vs not frozen vs not done
|
|
243
|
+
- [docs/EVIDENCE.md](docs/EVIDENCE.md) — proof ladder and artifact contract
|
|
244
|
+
- [docs/configuration.md](docs/configuration.md) — practical operator setup
|
|
245
|
+
- [docs/END_STATE.md](docs/END_STATE.md) — maintainer execution guide
|
|
246
|
+
- [docs/architecture.md](docs/architecture.md) — inherited LCM substrate plus product architecture context
|
|
247
|
+
- [docs/agent-tools.md](docs/agent-tools.md) — recall tools vs live brain tools
|
|
248
|
+
- [docs/tui.md](docs/tui.md) — TUI reference
|
|
350
249
|
|
|
351
|
-
|
|
250
|
+
## Development
|
|
352
251
|
|
|
353
252
|
```bash
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
253
|
+
npm test
|
|
254
|
+
npm pack --dry-run
|
|
255
|
+
npx tsc --noEmit
|
|
357
256
|
```
|
|
358
257
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
Current state: install/config wiring + fixture workspace + `openclawbrain init/status/doctor` are wired, and the harness can now target either temp-home isolation or a named sterile lane. The deterministic runtime layer already proves immediate `brain_teach` retrieval plus worker-down fail-open serving, and the session-bound harness now proves `brain_teach` deterministically at the correct seam with 20/20 identical passes. Raw prompt-driven `openclaw agent --local` is **not** the release proof boundary for `brain_teach`; on the current OpenClaw host, the remaining host work is to adapt the stale plugin/config seam and then freeze recurrent/shadow/skip-mode plus the narrow worker-down serving claim on that repaired boundary.
|
|
362
|
-
|
|
363
|
-
### Project structure
|
|
364
|
-
|
|
365
|
-
```
|
|
366
|
-
index.ts # Plugin entry point and registration
|
|
367
|
-
src/
|
|
368
|
-
engine.ts # LcmContextEngine — implements ContextEngine interface
|
|
369
|
-
assembler.ts # Context assembly (summaries + messages → model context)
|
|
370
|
-
compaction.ts # CompactionEngine — leaf passes, condensation, sweeps
|
|
371
|
-
summarize.ts # Depth-aware prompt generation and LLM summarization
|
|
372
|
-
retrieval.ts # RetrievalEngine — grep, describe, expand operations
|
|
373
|
-
expansion.ts # DAG expansion logic for lcm_expand_query
|
|
374
|
-
expansion-auth.ts # Delegation grants for sub-agent expansion
|
|
375
|
-
expansion-policy.ts # Depth/token policy for expansion
|
|
376
|
-
large-files.ts # File interception, storage, and exploration summaries
|
|
377
|
-
integrity.ts # DAG integrity checks and repair utilities
|
|
378
|
-
transcript-repair.ts # Tool-use/result pairing sanitization
|
|
379
|
-
types.ts # Core type definitions (dependency injection contracts)
|
|
380
|
-
openclaw-bridge.ts # Bridge utilities
|
|
381
|
-
db/
|
|
382
|
-
config.ts # LcmConfig resolution from env vars
|
|
383
|
-
connection.ts # SQLite connection management
|
|
384
|
-
migration.ts # Schema migrations
|
|
385
|
-
store/
|
|
386
|
-
conversation-store.ts # Message persistence and retrieval
|
|
387
|
-
summary-store.ts # Summary DAG persistence and context item management
|
|
388
|
-
fts5-sanitize.ts # FTS5 query sanitization
|
|
389
|
-
tools/
|
|
390
|
-
lcm-grep-tool.ts # lcm_grep tool implementation
|
|
391
|
-
lcm-describe-tool.ts # lcm_describe tool implementation
|
|
392
|
-
lcm-expand-tool.ts # lcm_expand tool (sub-agent only)
|
|
393
|
-
lcm-expand-query-tool.ts # lcm_expand_query tool (main agent wrapper)
|
|
394
|
-
lcm-conversation-scope.ts # Conversation scoping utilities
|
|
395
|
-
common.ts # Shared tool utilities
|
|
396
|
-
test/ # Vitest test suite
|
|
397
|
-
scripts/ # Validation harnesses and operator helpers
|
|
398
|
-
openclaw.plugin.json # Plugin manifest with config schema and UI hints
|
|
399
|
-
tui/ # Interactive terminal UI (Go)
|
|
400
|
-
main.go # Entry point and bubbletea app
|
|
401
|
-
data.go # Data loading and SQLite queries
|
|
402
|
-
dissolve.go # Summary dissolution
|
|
403
|
-
repair.go # Corrupted summary repair
|
|
404
|
-
rewrite.go # Summary re-summarization
|
|
405
|
-
transplant.go # Cross-conversation DAG copy
|
|
406
|
-
prompts/ # Depth-aware prompt templates
|
|
407
|
-
.goreleaser.yml # GoReleaser config for TUI binary releases
|
|
408
|
-
```
|
|
258
|
+
Current repo truth: `npm test` and targeted runtime validation are ahead of full-repo `npx tsc --noEmit`, which still has known drift outside the latest runtime slices.
|
|
409
259
|
|
|
410
260
|
## License
|
|
411
261
|
|