brainclaw 0.23.1 → 0.25.3
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/dist/cli.js +1 -0
- package/dist/commands/accept.js +5 -2
- package/dist/commands/claim.js +7 -5
- package/dist/commands/context-diff.js +62 -4
- package/dist/commands/export.js +40 -2
- package/dist/commands/init.js +41 -0
- package/dist/commands/instruction.js +5 -4
- package/dist/commands/mcp.js +64 -5
- package/dist/commands/prune.js +5 -4
- package/dist/commands/reflect.js +2 -0
- package/dist/commands/release-claim.js +4 -4
- package/dist/commands/release-claims.js +5 -4
- package/dist/commands/runtime-note.js +1 -0
- package/dist/core/ai-surface-tasks.js +3 -2
- package/dist/core/audit.js +3 -2
- package/dist/core/bootstrap.js +7 -6
- package/dist/core/candidates.js +4 -3
- package/dist/core/claims.js +3 -2
- package/dist/core/instructions.js +3 -2
- package/dist/core/io.js +1 -0
- package/dist/core/lock.js +2 -2
- package/dist/core/markdown.js +18 -0
- package/dist/core/mutation-pipeline.js +39 -0
- package/dist/core/runtime.js +4 -3
- package/dist/core/schema.js +8 -0
- package/dist/core/state.js +5 -4
- package/docs/cli.md +7 -5
- package/docs/concepts/memory.md +4 -3
- package/docs/concepts/plans-and-claims.md +10 -0
- package/docs/integrations/agents.md +2 -1
- package/docs/integrations/claude-code.md +1 -1
- package/docs/integrations/codex.md +1 -1
- package/docs/integrations/copilot.md +1 -1
- package/docs/integrations/cursor.md +1 -1
- package/docs/integrations/mcp.md +16 -6
- package/docs/integrations/overview.md +2 -2
- package/docs/quickstart.md +3 -1
- package/docs/storage.md +51 -24
- package/package.json +1 -1
package/docs/storage.md
CHANGED
|
@@ -6,37 +6,62 @@ brainclaw is local-first and workspace-centric.
|
|
|
6
6
|
|
|
7
7
|
```text
|
|
8
8
|
.brainclaw/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
config.yaml ← Project configuration
|
|
10
|
+
project.md ← Derived readable view (best-effort, regenerable)
|
|
11
|
+
events.jsonl ← Append-only event log (agent notifications)
|
|
12
|
+
audit.log ← Append-only audit trail (before/after snapshots)
|
|
13
|
+
memory/
|
|
14
|
+
constraints/ ← Canonical constraint entries (one JSON per entity)
|
|
15
|
+
decisions/ ← Canonical decision entries
|
|
16
|
+
traps/ ← Canonical trap entries
|
|
17
|
+
instructions/ ← Layered shared instructions
|
|
18
|
+
coordination/
|
|
19
|
+
plans/ ← Shared plan items
|
|
20
|
+
claims/ ← Active scope claims
|
|
21
|
+
handoffs/ ← Handoff records
|
|
22
|
+
sessions/ ← Session state
|
|
23
|
+
runtime/ ← Runtime notes (shared, machine, private)
|
|
24
|
+
inbox/ ← Candidate review queue
|
|
25
|
+
discovery/
|
|
26
|
+
bootstrap/ ← Bootstrap profiles and seeds
|
|
27
|
+
agents/ ← Agent registration and identity
|
|
17
28
|
```
|
|
18
29
|
|
|
19
30
|
## Design principles
|
|
20
31
|
|
|
21
32
|
### Canonical state is split
|
|
22
|
-
Each entity is stored as its own JSON file.
|
|
33
|
+
Each entity is stored as its own JSON file (e.g. `memory/decisions/dec_abc123.json`).
|
|
23
34
|
|
|
24
35
|
Benefits:
|
|
25
36
|
|
|
26
|
-
- readable diffs
|
|
37
|
+
- readable diffs in `.brainclaw/.git`
|
|
27
38
|
- easier merges
|
|
28
|
-
- clear provenance
|
|
29
|
-
-
|
|
39
|
+
- clear provenance per entity
|
|
40
|
+
- O(1) lookup by ID (direct file access)
|
|
30
41
|
- no giant monolithic memory blob
|
|
42
|
+
- isolated corruption (one bad file does not affect others)
|
|
31
43
|
|
|
32
|
-
###
|
|
33
|
-
`project.md` is regenerated from canonical state
|
|
44
|
+
### Derived views are best-effort
|
|
45
|
+
`project.md` is a **derived view** regenerated from canonical state via `rebuildProjectMd()`. It is not a write target — it can always be rebuilt from the JSON files using `brainclaw rebuild`.
|
|
34
46
|
|
|
35
|
-
|
|
47
|
+
Failures to regenerate `project.md` are logged but never block mutations. If it gets stale, `brainclaw doctor` detects the drift.
|
|
48
|
+
|
|
49
|
+
### All mutations go through a single pipeline
|
|
50
|
+
Every write to `.brainclaw/` is serialized through `mutate()` (`src/core/mutation-pipeline.ts`):
|
|
51
|
+
|
|
52
|
+
1. **Store-wide lock** — advisory file lock at `.brainclaw/.store-mutation` (5s timeout, 10s expiry)
|
|
53
|
+
2. **Reentrant** — nested mutations within the same process are safe
|
|
54
|
+
3. **Atomic writes** — individual files use temp-file + rename pattern
|
|
55
|
+
4. **Git versioned** — `.brainclaw/.git` tracks all changes for rollback
|
|
56
|
+
|
|
57
|
+
For agents using MCP (the recommended path), mutations are additionally serialized by the MCP server's `McpTaskRunner` — a FIFO queue that runs one task at a time. This provides two layers of write safety:
|
|
58
|
+
|
|
59
|
+
| Layer | Scope | Mechanism |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| **McpTaskRunner** | Single MCP server process | FIFO queue, one active Worker thread |
|
|
62
|
+
| **mutate() file lock** | Cross-process (CLI + MCP) | Advisory `.store-mutation` lock file |
|
|
36
63
|
|
|
37
|
-
|
|
38
|
-
- humans get an inspectable summary
|
|
39
|
-
- the source of truth remains structured
|
|
64
|
+
Agents should always use MCP tools for mutations. The CLI is for human operators, scripting, and fallback workflows.
|
|
40
65
|
|
|
41
66
|
### Topology can vary
|
|
42
67
|
|
|
@@ -57,21 +82,23 @@ Depending on configuration, storage may be:
|
|
|
57
82
|
- handoffs
|
|
58
83
|
- plans
|
|
59
84
|
|
|
60
|
-
## What
|
|
85
|
+
## What stays operational
|
|
61
86
|
|
|
62
87
|
- machine-local runtime notes
|
|
63
88
|
- private notes
|
|
64
|
-
- short-lived observations
|
|
89
|
+
- short-lived observations (with optional TTL)
|
|
65
90
|
- reflective candidates awaiting review
|
|
91
|
+
- event log and audit trail
|
|
66
92
|
|
|
67
93
|
## Why this model matters
|
|
68
94
|
|
|
69
95
|
The storage model is part of the product value:
|
|
70
96
|
|
|
71
|
-
- local-first
|
|
72
|
-
- inspectable
|
|
73
|
-
- Git-friendly
|
|
74
|
-
- reversible
|
|
97
|
+
- local-first — no cloud dependency
|
|
98
|
+
- inspectable — plain text + JSON
|
|
99
|
+
- Git-friendly — entity-per-file, readable diffs
|
|
100
|
+
- reversible — `.brainclaw/.git` history + rollback
|
|
101
|
+
- mutation-safe — serialized writes, atomic file operations
|
|
75
102
|
- suitable for both humans and agents
|
|
76
103
|
|
|
77
104
|
## Related pages
|