brainclaw 1.26.1 → 1.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -12
- package/dist/brainclaw-vscode.vsix +0 -0
- package/dist/core/agent-files.js +21 -21
- package/dist/core/protocol-tool-policy.js +44 -0
- package/dist/facts.js +6 -6
- package/dist/facts.json +5 -5
- package/docs/PROTOCOL.md +6 -4
- package/docs/cli.md +1 -1
- package/docs/concepts/loop-engine.md +60 -34
- package/docs/integrations/hermes.md +42 -3
- package/docs/integrations/mcp.md +17 -5
- package/docs/product/agent-first-model.md +33 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ It sits alongside your coding agents and gives them a shared state layer they ca
|
|
|
46
46
|
| **Agent-ready context** | compact, prompt-sized context built from real workspace state instead of stale instructions |
|
|
47
47
|
| **Code Map** | a Tree-sitter symbol + import index (11 languages — JS/TS, Python, PHP, Java, Go, Rust, C#, Ruby, C, C++) so agents ask "where is X / what should I read first" before editing, with related decisions/traps attached — `bclaw_code_find` / `bclaw_code_brief`, see [code map](docs/code-map.md) |
|
|
48
48
|
| **Native agent files** | auto-writes `CLAUDE.md`, `AGENTS.md`, `GEMINI.md`, `.cursor/rules/`, `.windsurfrules`, and similar local guidance |
|
|
49
|
-
| **Multi-turn loops** | review and
|
|
49
|
+
| **Multi-turn loops** | review, ideation, implementation, research, and debug workflows with structured phases, iteration semantics, verification gates, and per-phase memory filters — see [loop engine](docs/concepts/loop-engine.md) |
|
|
50
50
|
| **Machine AI surface discovery** | detects local coding agents plus desktop AI work surfaces such as ChatGPT Desktop and Gemini CLI |
|
|
51
51
|
| **Queued surface tasks** | stores project-scoped requests for other local AI surfaces, such as visual generation, drafting, summaries, or research |
|
|
52
52
|
| **Local-first storage** | plain text + JSON, Git-friendly, no mandatory cloud, no telemetry by default |
|
|
@@ -263,14 +263,29 @@ bclaw_loop({ intent: "get", loop_id: "lop_abc" }); // inspect status any time
|
|
|
263
263
|
|
|
264
264
|
## The Loop Engine (Multi-Turn Workflows)
|
|
265
265
|
|
|
266
|
-
Brainclaw's Loop Engine
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
266
|
+
Brainclaw's Loop Engine formalizes repeated multi-turn work so agents can
|
|
267
|
+
resume, automate, and audit it rather than relying on manual ping-pong. It is
|
|
268
|
+
one engine with five shipped default workflows: **review, ideation,
|
|
269
|
+
implementation, research, and debug**.
|
|
270
|
+
|
|
271
|
+
| Workflow | Typical outcome | Normal entry point |
|
|
272
|
+
| --- | --- | --- |
|
|
273
|
+
| Review | accepted verdict or bounded fix cycle | `bclaw_coordinate(intent="review", open_loop=true)` |
|
|
274
|
+
| Ideation | memory-confronted plan draft or synthesis | `bclaw_coordinate(intent="ideate")` |
|
|
275
|
+
| Implementation | green verification and handoff | `bclaw_loop(intent="open", kind="implementation", allow_orphan=true)`, then `bind` |
|
|
276
|
+
| Research | evidence-backed synthesis | `bclaw_loop(intent="open", kind="research", allow_orphan=true)` |
|
|
277
|
+
| Debug | reproduced, verified fix and handoff | `bclaw_loop(intent="open", kind="debug", allow_orphan=true)` |
|
|
278
|
+
|
|
279
|
+
Every loop has structured phases, bounded iteration, explicit artifacts, and
|
|
280
|
+
per-phase memory filters. The shared controls are `open`, `turn`,
|
|
281
|
+
`complete_turn`, `advance`, `add_artifact`, `pause`, `resume`, and `close`;
|
|
282
|
+
implementation also adds `bind` and `verify`. `request_input` /
|
|
283
|
+
`provide_input` are cross-cutting clarification primitives for any workflow.
|
|
284
|
+
|
|
285
|
+
Review is a useful specialized path, not the definition of the engine. It has
|
|
286
|
+
asymmetric and symmetric modes and can auto-close on an approved verdict; the
|
|
287
|
+
other workflows use the same lifecycle to converge on a plan, synthesis,
|
|
288
|
+
handoff, or verified fix. See the [Loop Engine guide](docs/concepts/loop-engine.md).
|
|
274
289
|
|
|
275
290
|
## Enterprise Ready: Mono-repo & Micro-services
|
|
276
291
|
|
|
@@ -310,7 +325,7 @@ Recent releases have moved a lot of multi-agent parallel work from "risky" to "s
|
|
|
310
325
|
|
|
311
326
|
- **Per-claim auto-worktree** — each dispatched lane gets its own isolated git worktree; the coordinator integrates with an octopus merge.
|
|
312
327
|
- **Sequenced parallel execute** — `bclaw_dispatch(intent="execute")` fans out independent lanes across several agent instances and integrates the result.
|
|
313
|
-
- **
|
|
328
|
+
- **Loop Engine protocols** — review, ideation, implementation, research, and debug workflows share a persisted lifecycle. Review offers a symmetric auto-fix shortcut; implementation and debug bind verification to the work; ideation and research converge on durable syntheses.
|
|
314
329
|
- **Cross-platform spawn** — OS-aware prompt delivery (stdin pipe / inline arg) plus a brief-ack file handshake, so spawned workers can be detected and timed out reliably on Windows and Unix.
|
|
315
330
|
- **Worktree GC is scope-bounded** — symlinks and junctions are no longer followed during cleanup, so post-merge sweeps can't wipe `node_modules` or other neighboring directories.
|
|
316
331
|
- **MCP runtime self-heal** — when the runtime is corrupted, the server logs an actionable repair pointer; `brainclaw doctor --repair` rebuilds dist in one step.
|
|
@@ -327,8 +342,9 @@ Recommended use today:
|
|
|
327
342
|
|
|
328
343
|
1. for parallel work, dispatch a sequence with `bclaw_dispatch(intent="execute")` — each lane gets its own worktree
|
|
329
344
|
2. for sequential work in the same project, let one agent claim at a time and rely on handoffs
|
|
330
|
-
3.
|
|
331
|
-
4.
|
|
345
|
+
3. choose the loop by outcome: ideation for a plan, implementation or debug for a verified handoff, research for a synthesis, and review for a verdict
|
|
346
|
+
4. when reviewing or fixing across agents, prefer symmetric review loops over manual ping-pong
|
|
347
|
+
5. keep multi-machine workflows on a single source of truth until federation lands
|
|
332
348
|
|
|
333
349
|
---
|
|
334
350
|
|
|
Binary file
|
package/dist/core/agent-files.js
CHANGED
|
@@ -3,7 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { spawnSync } from 'node:child_process';
|
|
5
5
|
import yaml from 'yaml';
|
|
6
|
-
import { MCP_HEADLESS_AUTO_TOOL_NAMES, MCP_CANONICAL_GRAMMAR_TOOL_NAMES, REMOVED_IN_V1_TOOLS } from './protocol-tool-policy.js';
|
|
6
|
+
import { MCP_HEADLESS_AUTO_TOOL_NAMES, MCP_CANONICAL_GRAMMAR_TOOL_NAMES, MCP_HERMES_WORKFLOW_TOOL_NAMES, REMOVED_IN_V1_TOOLS } from './protocol-tool-policy.js';
|
|
7
7
|
import { renderToml, tomlArrayTableHasEntry } from './toml-writer.js';
|
|
8
8
|
import { PROTOCOL_SKILLS, renderProtocolSkill } from './protocol-skills.js';
|
|
9
9
|
import { getInstalledBrainclawVersion } from './brainclaw-version.js';
|
|
@@ -364,7 +364,6 @@ export const LOCAL_ONLY_AGENT_WORKSPACE_FILES = [
|
|
|
364
364
|
KILOCODE_MCP_RELATIVE_PATH,
|
|
365
365
|
KILOCODE_CONFIG_RELATIVE_PATH,
|
|
366
366
|
MISTRAL_VIBE_CONFIG_RELATIVE_PATH,
|
|
367
|
-
HERMES_CONFIG_RELATIVE_PATH,
|
|
368
367
|
CONTINUE_CONFIG_RELATIVE_PATH,
|
|
369
368
|
OPENCODE_CONFIG_RELATIVE_PATH,
|
|
370
369
|
WINDSURF_MCP_RELATIVE_PATH,
|
|
@@ -1553,25 +1552,22 @@ export function ensureMistralVibeMcpConfig(cwd) {
|
|
|
1553
1552
|
relativePath: MISTRAL_VIBE_CONFIG_RELATIVE_PATH,
|
|
1554
1553
|
};
|
|
1555
1554
|
}
|
|
1556
|
-
// Hermes' MCP `tools.include` array — narrow canonical-grammar surface. Derived
|
|
1557
|
-
// from MCP_CANONICAL_GRAMMAR_TOOL_NAMES (which is itself ALL_TOOLS-derived) so
|
|
1558
|
-
// new facade tools or canonical grammar verbs propagate without a manual edit
|
|
1559
|
-
// here (pln#546 step 2). REMOVED_IN_V1_TOOLS are stripped so deprecated names
|
|
1560
|
-
// don't reappear in user-facing configs.
|
|
1561
|
-
//
|
|
1562
|
-
// LAZY (pln#564 coordinator fix): computed on first call, NOT at module init.
|
|
1563
|
-
// agent-files.ts ↔ commands/mcp.ts form an import cycle; reading the imported
|
|
1564
|
-
// MCP_CANONICAL_GRAMMAR_TOOL_NAMES at module-eval time threw a TDZ
|
|
1565
|
-
// ("Cannot access 'MCP_CANONICAL_GRAMMAR_TOOL_NAMES' before initialization")
|
|
1566
|
-
// when agent-files loaded mid-mcp-init — which broke the MCP server. tsc does
|
|
1567
|
-
// not catch this (runtime-only). Deferring the read to call time fixes it.
|
|
1568
|
-
let hermesBrainclawMcpToolsCache;
|
|
1569
1555
|
function getHermesBrainclawMcpTools() {
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
return
|
|
1556
|
+
return MCP_HERMES_WORKFLOW_TOOL_NAMES
|
|
1557
|
+
.filter((name) => !REMOVED_IN_V1_TOOLS.has(name));
|
|
1558
|
+
}
|
|
1559
|
+
function hasExactMcpToolList(value, expected) {
|
|
1560
|
+
return Array.isArray(value)
|
|
1561
|
+
&& value.length === expected.length
|
|
1562
|
+
&& value.every((tool, index) => tool === expected[index]);
|
|
1563
|
+
}
|
|
1564
|
+
function isLegacyHermesBrainclawMcpTools(value) {
|
|
1565
|
+
// The original Hermes writer emitted precisely the canonical seven-tool
|
|
1566
|
+
// list. Upgrade that known managed value, but preserve every other list as
|
|
1567
|
+
// an explicit user customization.
|
|
1568
|
+
const legacyTools = MCP_CANONICAL_GRAMMAR_TOOL_NAMES
|
|
1569
|
+
.filter((name) => !REMOVED_IN_V1_TOOLS.has(name));
|
|
1570
|
+
return hasExactMcpToolList(value, legacyTools);
|
|
1575
1571
|
}
|
|
1576
1572
|
export function ensureHermesMcpConfig(homeDir, workspacePath) {
|
|
1577
1573
|
if (!homeDir)
|
|
@@ -1617,6 +1613,8 @@ export function ensureHermesMcpConfig(homeDir, workspacePath) {
|
|
|
1617
1613
|
}
|
|
1618
1614
|
}
|
|
1619
1615
|
const mcpCmd = getBrainclawMcpCommand();
|
|
1616
|
+
const existingInclude = currentTools.include;
|
|
1617
|
+
const managedInclude = getHermesBrainclawMcpTools();
|
|
1620
1618
|
const desiredEntry = {
|
|
1621
1619
|
...current,
|
|
1622
1620
|
command: typeof current.command === 'string' ? current.command : mcpCmd.command,
|
|
@@ -1627,7 +1625,9 @@ export function ensureHermesMcpConfig(homeDir, workspacePath) {
|
|
|
1627
1625
|
},
|
|
1628
1626
|
tools: {
|
|
1629
1627
|
...currentTools,
|
|
1630
|
-
include: Array.isArray(
|
|
1628
|
+
include: Array.isArray(existingInclude) && !isLegacyHermesBrainclawMcpTools(existingInclude)
|
|
1629
|
+
? existingInclude
|
|
1630
|
+
: managedInclude,
|
|
1631
1631
|
prompts: typeof currentTools.prompts === 'boolean' ? currentTools.prompts : false,
|
|
1632
1632
|
resources: typeof currentTools.resources === 'boolean' ? currentTools.resources : false,
|
|
1633
1633
|
},
|
|
@@ -86,6 +86,50 @@ export const MCP_CANONICAL_GRAMMAR_TOOL_NAMES = [
|
|
|
86
86
|
'bclaw_update',
|
|
87
87
|
'bclaw_transition',
|
|
88
88
|
];
|
|
89
|
+
/**
|
|
90
|
+
* Curated MCP workflow surface for Hermes. Hermes receives the shared Tier B
|
|
91
|
+
* instructions, which prescribe session/claim closure, inbox coordination,
|
|
92
|
+
* step updates, and Code Map discovery in addition to the canonical memory
|
|
93
|
+
* grammar. Keep this list aligned with that instruction contract; it is an
|
|
94
|
+
* advertised-tool policy, not a headless auto-approval policy.
|
|
95
|
+
*/
|
|
96
|
+
export const MCP_HERMES_WORKFLOW_TOOL_NAMES = [
|
|
97
|
+
...MCP_CANONICAL_GRAMMAR_TOOL_NAMES,
|
|
98
|
+
'bclaw_remove',
|
|
99
|
+
'bclaw_move',
|
|
100
|
+
'bclaw_session_start',
|
|
101
|
+
'bclaw_session_end',
|
|
102
|
+
'bclaw_claim',
|
|
103
|
+
'bclaw_release_claim',
|
|
104
|
+
'bclaw_add_step',
|
|
105
|
+
'bclaw_complete_step',
|
|
106
|
+
'bclaw_update_step',
|
|
107
|
+
'bclaw_delete_step',
|
|
108
|
+
'bclaw_list_sequences',
|
|
109
|
+
'bclaw_create_sequence',
|
|
110
|
+
'bclaw_update_sequence',
|
|
111
|
+
'bclaw_delete_sequence',
|
|
112
|
+
'bclaw_read_inbox',
|
|
113
|
+
'bclaw_ack_message',
|
|
114
|
+
'bclaw_send_message',
|
|
115
|
+
'bclaw_correct_handoff',
|
|
116
|
+
'bclaw_write_note',
|
|
117
|
+
'bclaw_quick_capture',
|
|
118
|
+
'bclaw_search',
|
|
119
|
+
'bclaw_setup',
|
|
120
|
+
'bclaw_bootstrap',
|
|
121
|
+
'bclaw_switch',
|
|
122
|
+
'bclaw_release_notes',
|
|
123
|
+
'bclaw_coordinate',
|
|
124
|
+
'bclaw_dispatch',
|
|
125
|
+
'bclaw_loop',
|
|
126
|
+
'bclaw_dispatch_status',
|
|
127
|
+
'bclaw_assignment_update',
|
|
128
|
+
'bclaw_code_find',
|
|
129
|
+
'bclaw_code_brief',
|
|
130
|
+
'bclaw_code_status',
|
|
131
|
+
'bclaw_code_refresh',
|
|
132
|
+
];
|
|
89
133
|
/**
|
|
90
134
|
* Tools removed from the MCP surface at the v1.0 cut (Phase 3 slice 3i).
|
|
91
135
|
* Hidden from every `tools/list` response; direct `tools/call` still works
|
package/dist/facts.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Generated by scripts/emit-site-facts.mjs at build time. Do not edit manually.
|
|
2
|
-
// Source: brainclaw v1.26.
|
|
2
|
+
// Source: brainclaw v1.26.2 on 2026-08-22T12:18:05.969Z
|
|
3
3
|
export const FACTS = {
|
|
4
|
-
"version": "1.26.
|
|
5
|
-
"generated_at": "2026-08-
|
|
4
|
+
"version": "1.26.2",
|
|
5
|
+
"generated_at": "2026-08-22T12:18:05.969Z",
|
|
6
6
|
"tools": {
|
|
7
7
|
"count": 70,
|
|
8
8
|
"published_count": 68,
|
|
@@ -477,7 +477,7 @@ export const FACTS = {
|
|
|
477
477
|
},
|
|
478
478
|
"bench": {
|
|
479
479
|
"schema": "brainclaw.bench.v1",
|
|
480
|
-
"generated_at": "2026-08-
|
|
480
|
+
"generated_at": "2026-08-22T12:18:03.871Z",
|
|
481
481
|
"node_version": "v24.19.0",
|
|
482
482
|
"platform": "linux-x64",
|
|
483
483
|
"repeats": 3,
|
|
@@ -486,7 +486,7 @@ export const FACTS = {
|
|
|
486
486
|
"name": "cold_onboard",
|
|
487
487
|
"volume": "empty",
|
|
488
488
|
"description": "fresh machine → init → first useful context. Baseline for time-to-first-value.",
|
|
489
|
-
"duration_ms_median":
|
|
489
|
+
"duration_ms_median": 76,
|
|
490
490
|
"payload_chars_median": 1640,
|
|
491
491
|
"payload_tokens_est_median": 410
|
|
492
492
|
},
|
|
@@ -494,7 +494,7 @@ export const FACTS = {
|
|
|
494
494
|
"name": "warm_work",
|
|
495
495
|
"volume": "medium",
|
|
496
496
|
"description": "bclaw_work consult over a real-shaped store (~200 plans / 500 handoffs / 450 claims).",
|
|
497
|
-
"duration_ms_median":
|
|
497
|
+
"duration_ms_median": 123,
|
|
498
498
|
"payload_chars_median": 2626,
|
|
499
499
|
"payload_tokens_est_median": 657
|
|
500
500
|
},
|
package/dist/facts.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.26.
|
|
3
|
-
"generated_at": "2026-08-
|
|
2
|
+
"version": "1.26.2",
|
|
3
|
+
"generated_at": "2026-08-22T12:18:05.969Z",
|
|
4
4
|
"tools": {
|
|
5
5
|
"count": 70,
|
|
6
6
|
"published_count": 68,
|
|
@@ -475,7 +475,7 @@
|
|
|
475
475
|
},
|
|
476
476
|
"bench": {
|
|
477
477
|
"schema": "brainclaw.bench.v1",
|
|
478
|
-
"generated_at": "2026-08-
|
|
478
|
+
"generated_at": "2026-08-22T12:18:03.871Z",
|
|
479
479
|
"node_version": "v24.19.0",
|
|
480
480
|
"platform": "linux-x64",
|
|
481
481
|
"repeats": 3,
|
|
@@ -484,7 +484,7 @@
|
|
|
484
484
|
"name": "cold_onboard",
|
|
485
485
|
"volume": "empty",
|
|
486
486
|
"description": "fresh machine → init → first useful context. Baseline for time-to-first-value.",
|
|
487
|
-
"duration_ms_median":
|
|
487
|
+
"duration_ms_median": 76,
|
|
488
488
|
"payload_chars_median": 1640,
|
|
489
489
|
"payload_tokens_est_median": 410
|
|
490
490
|
},
|
|
@@ -492,7 +492,7 @@
|
|
|
492
492
|
"name": "warm_work",
|
|
493
493
|
"volume": "medium",
|
|
494
494
|
"description": "bclaw_work consult over a real-shaped store (~200 plans / 500 handoffs / 450 claims).",
|
|
495
|
-
"duration_ms_median":
|
|
495
|
+
"duration_ms_median": 123,
|
|
496
496
|
"payload_chars_median": 2626,
|
|
497
497
|
"payload_tokens_est_median": 657
|
|
498
498
|
},
|
package/docs/PROTOCOL.md
CHANGED
|
@@ -92,9 +92,11 @@ surface stays small; richer ergonomic helpers are facades on top.
|
|
|
92
92
|
The reference implementation surfaces these as MCP tools named
|
|
93
93
|
`bclaw_work`, `bclaw_context`, `bclaw_find`, `bclaw_get`, `bclaw_create`,
|
|
94
94
|
`bclaw_update`, `bclaw_transition`. The same names appear in
|
|
95
|
-
`src/
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
`src/core/protocol-tool-policy.ts:MCP_CANONICAL_GRAMMAR_TOOL_NAMES`; the
|
|
96
|
+
catalog derivation is checked against that static core policy in tests. This is
|
|
97
|
+
the minimum grammar, not a universal agent allowlist. Hermes receives the
|
|
98
|
+
broader `MCP_HERMES_WORKFLOW_TOOL_NAMES` surface because its generated
|
|
99
|
+
instructions also require lifecycle, inbox, coordination, and Code Map tools.
|
|
98
100
|
|
|
99
101
|
### 4.1 Coordination verbs (experimental — protocol v0.2 candidates)
|
|
100
102
|
|
|
@@ -197,7 +199,7 @@ the wire format for cross-project signaling.
|
|
|
197
199
|
| Protocol concept | Reference implementation in brainclaw |
|
|
198
200
|
|-------------------------------|-----------------------------------------------------------------------|
|
|
199
201
|
| Entity schemas | [`src/core/schema.ts`](../src/core/schema.ts) |
|
|
200
|
-
| Canonical grammar tool set | [`src/
|
|
202
|
+
| Canonical grammar tool set | [`src/core/protocol-tool-policy.ts`](../src/core/protocol-tool-policy.ts) — `MCP_CANONICAL_GRAMMAR_TOOL_NAMES` |
|
|
201
203
|
| MCP tool catalog | [`src/commands/mcp.ts`](../src/commands/mcp.ts) — `ALL_TOOLS` |
|
|
202
204
|
| Per-agent writer wiring | [`src/core/agent-files.ts`](../src/core/agent-files.ts) — `AGENT_WIRING_REGISTRY` |
|
|
203
205
|
| Capability profiles | [`src/core/agent-capability.ts`](../src/core/agent-capability.ts) |
|
package/docs/cli.md
CHANGED
|
@@ -1984,7 +1984,7 @@ The default catalog is intentionally small and centred on the canonical grammar.
|
|
|
1984
1984
|
|---|---|
|
|
1985
1985
|
| `bclaw_coordinate(intent)` | Assign, consult, review, reroute, or summarize across agents. Pass `open_loop: true` on `intent="review"` to also dispatch the reviewer turn. |
|
|
1986
1986
|
| `bclaw_dispatch(intent)` | Parallelize execute across a sequence's lanes (analysis / execute / review). |
|
|
1987
|
-
| `bclaw_loop(intent)` |
|
|
1987
|
+
| `bclaw_loop(intent)` | Open, inspect, or drive a multi-turn loop. The public lifecycle is `open`, `get`, `list`, `turn`, `complete_turn`, `advance`, `add_artifact`, `pause`, `resume`, and `close`; implementation loops also add `bind` and `verify`, and any kind may use `request_input` / `provide_input`. `bclaw_coordinate` / `bclaw_dispatch` remain the ergonomic review and ideation shortcuts. A direct `open` must include `allow_orphan: true` to acknowledge that the caller will dispatch or drive it. |
|
|
1988
1988
|
|
|
1989
1989
|
**Sequences**:
|
|
1990
1990
|
|
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
brainclaw coordinates many agents against shared state.
|
|
4
4
|
The Loop engine turns repetitive multi-turn workflows
|
|
5
|
-
—
|
|
5
|
+
— review, ideation, implementation, research, and debugging —
|
|
6
6
|
into **first-class, persistable, automatable objects**.
|
|
7
7
|
|
|
8
|
-
Status:
|
|
8
|
+
Status: **shipped**. `bclaw_loop` exposes the persistent engine and its five
|
|
9
|
+
built-in protocols; `bclaw_coordinate` and `bclaw_dispatch` add ergonomic
|
|
10
|
+
shortcuts for ideation and review. This document retains the RFC-level
|
|
11
|
+
concurrency contract and implementation history where it explains an
|
|
12
|
+
invariant, but its operational sections describe the surface available today.
|
|
9
13
|
|
|
10
14
|
## Why
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
an operator
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
Without a loop, recurring work is easy to reduce to manual ping-pong:
|
|
17
|
+
an operator relays a proposal and its critique, asks an implementer to retry a
|
|
18
|
+
failed check, gathers research findings, or forwards review feedback. Each
|
|
19
|
+
round is glue work, lost context, and copy-paste errors.
|
|
16
20
|
|
|
17
21
|
A Loop captures the whole cycle as state:
|
|
18
22
|
*participants, phases, current position, artifacts, stop criteria*.
|
|
@@ -291,16 +295,36 @@ type NextExpectedHint =
|
|
|
291
295
|
|
|
292
296
|
> **Caller note.** For `request_hash` to match on retry, the caller must replay the request body byte-for-byte, including any volatile fields it chose to include (timestamps, generated ids in the payload). Retries that differ in such fields will be treated as distinct requests and rejected with the reuse error. Practical rule: build the request once, snapshot it, and resend that exact snapshot on retry. The caller envelope itself (agent, agentId, client_request_id) is excluded from the hash.
|
|
293
297
|
|
|
294
|
-
##
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
|
303
|
-
|
|
298
|
+
## Supported workflows
|
|
299
|
+
|
|
300
|
+
The engine is one control plane, not a review feature with a few extensions.
|
|
301
|
+
All five `LoopKind` values below ship a default protocol in
|
|
302
|
+
`src/core/loops/types.ts`; callers may override phases and stop conditions when
|
|
303
|
+
opening a loop. Review has the most automated coordinator shortcut, but it is
|
|
304
|
+
one workflow among the five.
|
|
305
|
+
|
|
306
|
+
| kind | default progression | normal entry point | converges on |
|
|
307
|
+
|---|---|---|---|
|
|
308
|
+
| `review` | `change_summary` → `findings` → `author_response` → `followup_review` → `verdict` | `bclaw_coordinate(intent="review", open_loop=true)` or `bclaw_dispatch(intent="review", openLoop=true)` | an accepted verdict or the bounded iteration cap |
|
|
309
|
+
| `ideation` | `proposal` → `critique` ↔ `revision` → `synthesis` | `bclaw_coordinate(intent="ideate")`; `preset="bootstrap"` selects the onboarding variant | a `plan_draft` synthesis; see [ideation-loop.md](./ideation-loop.md) |
|
|
310
|
+
| `implementation` | `bind` → `execute` ↔ `verify` → `handoff_ready` | `bclaw_loop(intent="open", kind="implementation", allow_orphan=true)`, then `bind` | a handoff after a green verification command, or a bounded blocked result |
|
|
311
|
+
| `research` | `investigate` ↔ `synthesize` → `conclude` | `bclaw_loop(intent="open", kind="research", allow_orphan=true)` | a synthesis after at least one finding per investigation round |
|
|
312
|
+
| `debug` | `reproduce` → `hypothesize` ↔ `isolate` ↔ `fix` → `handoff` | `bclaw_loop(intent="open", kind="debug", allow_orphan=true)` | a handoff after the reproducing command is green, or a bounded blocked result |
|
|
313
|
+
|
|
314
|
+
`allow_orphan=true` is an explicit acknowledgement for direct opens: the caller
|
|
315
|
+
will drive or dispatch the resulting loop rather than creating an inert thread.
|
|
316
|
+
The shared lifecycle verbs are `turn`, `complete_turn`, `advance`,
|
|
317
|
+
`add_artifact`, `pause`, `resume`, and `close`. Implementation loops additionally
|
|
318
|
+
use `bind` to dispatch their linked sequence and `verify` to run their declared
|
|
319
|
+
command.
|
|
320
|
+
|
|
321
|
+
### Clarification is a cross-cutting primitive
|
|
322
|
+
|
|
323
|
+
Clarification is deliberately not a sixth protocol. Any workflow can call
|
|
324
|
+
`request_input` to record an evidence-backed operator question, pause either a
|
|
325
|
+
slot or the whole loop, and resume through `provide_input`. This keeps a missing
|
|
326
|
+
decision from being confused with a review finding or a failed implementation
|
|
327
|
+
check.
|
|
304
328
|
|
|
305
329
|
## Relation to existing primitives
|
|
306
330
|
|
|
@@ -317,9 +341,11 @@ The Loop engine is a **control plane**; existing primitives remain the **data pl
|
|
|
317
341
|
|
|
318
342
|
A Loop never copies these objects — it links them. Deleting the linked primitive does not break the loop; the reference just becomes dangling, surfaced in diagnostics.
|
|
319
343
|
|
|
320
|
-
##
|
|
344
|
+
## Review automation (one workflow)
|
|
321
345
|
|
|
322
|
-
|
|
346
|
+
Review is the most automated convenience path: manual review round-trips can
|
|
347
|
+
disappear. Its special handling below does not change the general Loop Engine
|
|
348
|
+
model described in [Supported workflows](#supported-workflows).
|
|
323
349
|
|
|
324
350
|
The existing `review` intent in `bclaw_coordinate` already creates a review candidate. We extend it — **strictly backward-compatible** — with an optional flag `open_loop?: boolean` that **defaults to `false`**. Every existing `review` call behaves exactly as today; a caller must explicitly opt in by passing `open_loop: true`. The coordinate enum was extended in v1.5.0 to add `ideate` (memory-confrontation ideation_loop driver — see [ideation-loop.md](./ideation-loop.md) for the full design and §[Automation: extending `bclaw_coordinate(intent='ideate')`](#automation-extending-bclaw_coordinateintentideate) below for a summary). The current vocabulary is `assign | consult | review | reroute | summarize | ideate`. A future minor version may flip the `open_loop` default after telemetry confirms adoption, but such a flip will be gated by MCP schema versioning (pln#392) and surfaced in the changelog.
|
|
325
351
|
|
|
@@ -482,8 +508,8 @@ The three rules are independent: `hard_deadline` bounds pathological "heartbeat
|
|
|
482
508
|
|
|
483
509
|
## Routing and multi-instance
|
|
484
510
|
|
|
485
|
-
-
|
|
486
|
-
- Execution loops (`implementation`) route by `claim_id
|
|
511
|
+
- Collaborative loops (`review`, `ideation`, and `research`) route turns by `slot_id` — the engine writes to the slot's agent inbox via the existing coordinate path.
|
|
512
|
+
- Execution-oriented loops (`implementation` and `debug`) can route work by `claim_id`, preserving the claim-routed model already in use.
|
|
487
513
|
- `session_id` is not a routing key; it remains observability-only. This is consistent with `architecture_session_centric_identity` in memory.
|
|
488
514
|
|
|
489
515
|
### Project resolution gate (pln#521 P1)
|
|
@@ -519,13 +545,13 @@ Status after Codex schema review (cnd#574 / `dec_be66ccbf`, verdict `needs_revis
|
|
|
519
545
|
4. **Reopening a closed loop** — **Deferred.** `close` is terminal in MVP. Fixup reuse is done by opening a new loop that `linked` references the original.
|
|
520
546
|
5. **Artifact size cap** — **Resolved: 4 KB inline `body`, else force `ref`.** Encoded in the `LoopArtifact` contract. Above 4 KB the handler rejects and suggests creating a `message` or `handoff` to reference.
|
|
521
547
|
|
|
522
|
-
##
|
|
548
|
+
## Implementation status
|
|
523
549
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
550
|
+
The historical acceptance items in this RFC are complete: the verbs are exposed
|
|
551
|
+
through `bclaw_loop`, built-in protocols are defined in
|
|
552
|
+
`src/core/loops/types.ts`, and review/ideation receive coordinator shortcuts.
|
|
553
|
+
Future protocol work should extend the shared engine and update the workflow
|
|
554
|
+
table above rather than treating review as the default abstraction.
|
|
529
555
|
|
|
530
556
|
## Related
|
|
531
557
|
|
|
@@ -537,12 +563,12 @@ Status after Codex schema review (cnd#574 / `dec_be66ccbf`, verdict `needs_revis
|
|
|
537
563
|
- pln#395 `feat/review-loop-protocol`
|
|
538
564
|
- pln#392 `doc/mcp-versioning-and-surface-governance` (prerequisite)
|
|
539
565
|
|
|
540
|
-
##
|
|
541
|
-
|
|
542
|
-
The loop surface exposed over MCP is intentionally narrow:
|
|
543
|
-
|
|
544
|
-
- **Review loops** — `bclaw_coordinate(intent="review", open_loop=true, review_mode="asymmetric"|"symmetric", targetAgents=[…])` opens the loop and dispatches the first turn. The reviewer's verdict is then harvested from `LANE-RESULT.json` (`review_verdict`) and **auto-advances/closes the loop on approve** — no manual driving needed for the approve path (pln#628 Focus 4B). `bclaw_loop(intent="turn"|"complete_turn"|"advance"|"close")` remains available to drive turns by hand (e.g. the `request_changes` fix cycle, or a human-operated slot).
|
|
545
|
-
- **Turn-owned exactly-once fix cycle (default, pln#630).** The autonomous `request_changes` fix-cycle re-dispatch runs through the turn-owned attempt state machine (immutable attempt record + atomic launch fence → spawned at most once; `reconcileTurn` finalizes from read-strict, turn-keyed evidence — the ack-wrapper's completion sentinel). It falls back to the legacy closer when a reviewer resolves to inbox/manual (no sentinel) so the loop still converges. **Kill-switch:** set `BRAINCLAW_TURN_OWNED_REVIEW=0` (also `false`/`off`/`no`) to revert review finalization to the legacy presence-based closer.
|
|
546
|
-
- **Ideation loops** — `bclaw_coordinate(intent="ideate", preset="bootstrap")` opens an ideation loop from a preset.
|
|
566
|
+
## Review-specific reliability notes
|
|
547
567
|
|
|
548
|
-
|
|
568
|
+
Review loops retain an extra exactly-once fix-cycle implementation because they
|
|
569
|
+
can automatically redispatch after `request_changes`. A reviewer writes
|
|
570
|
+
`review_verdict` and `review_summary` to `LANE-RESULT.json`; harvest maps this
|
|
571
|
+
to the loop, auto-closes on approval, and boundedly redispatches fix work when
|
|
572
|
+
appropriate. This is review-specific automation, not a limit on the other
|
|
573
|
+
workflow kinds. Set `BRAINCLAW_TURN_OWNED_REVIEW=0` (also `false`/`off`/`no`)
|
|
574
|
+
only to fall back to the legacy review finalizer.
|
|
@@ -24,8 +24,9 @@ The machine setup writes `~/.hermes/config.yaml`. The project enable step writes
|
|
|
24
24
|
the universal Brainclaw skill into `.agents/skills/brainclaw/SKILL.md` and
|
|
25
25
|
adds the project `.agents/skills` directory to Hermes `skills.external_dirs`.
|
|
26
26
|
|
|
27
|
-
The generated MCP entry is intentionally filtered to the
|
|
28
|
-
|
|
27
|
+
The generated MCP entry is intentionally filtered to the workflow tools Hermes
|
|
28
|
+
is instructed to use. This controls tool discovery only; it does not grant
|
|
29
|
+
headless approval for writes.
|
|
29
30
|
|
|
30
31
|
```yaml
|
|
31
32
|
skills:
|
|
@@ -40,17 +41,55 @@ mcp_servers:
|
|
|
40
41
|
BRAINCLAW_AGENT: hermes
|
|
41
42
|
tools:
|
|
42
43
|
include:
|
|
43
|
-
- bclaw_work
|
|
44
44
|
- bclaw_context
|
|
45
|
+
- bclaw_work
|
|
45
46
|
- bclaw_find
|
|
46
47
|
- bclaw_get
|
|
47
48
|
- bclaw_create
|
|
48
49
|
- bclaw_update
|
|
50
|
+
- bclaw_remove
|
|
49
51
|
- bclaw_transition
|
|
52
|
+
- bclaw_move
|
|
53
|
+
- bclaw_session_start
|
|
54
|
+
- bclaw_session_end
|
|
55
|
+
- bclaw_claim
|
|
56
|
+
- bclaw_release_claim
|
|
57
|
+
- bclaw_add_step
|
|
58
|
+
- bclaw_complete_step
|
|
59
|
+
- bclaw_update_step
|
|
60
|
+
- bclaw_delete_step
|
|
61
|
+
- bclaw_list_sequences
|
|
62
|
+
- bclaw_create_sequence
|
|
63
|
+
- bclaw_update_sequence
|
|
64
|
+
- bclaw_delete_sequence
|
|
65
|
+
- bclaw_read_inbox
|
|
66
|
+
- bclaw_ack_message
|
|
67
|
+
- bclaw_send_message
|
|
68
|
+
- bclaw_correct_handoff
|
|
69
|
+
- bclaw_write_note
|
|
70
|
+
- bclaw_quick_capture
|
|
71
|
+
- bclaw_search
|
|
72
|
+
- bclaw_setup
|
|
73
|
+
- bclaw_bootstrap
|
|
74
|
+
- bclaw_switch
|
|
75
|
+
- bclaw_release_notes
|
|
76
|
+
- bclaw_coordinate
|
|
77
|
+
- bclaw_dispatch
|
|
78
|
+
- bclaw_loop
|
|
79
|
+
- bclaw_dispatch_status
|
|
80
|
+
- bclaw_assignment_update
|
|
81
|
+
- bclaw_code_find
|
|
82
|
+
- bclaw_code_brief
|
|
83
|
+
- bclaw_code_status
|
|
84
|
+
- bclaw_code_refresh
|
|
50
85
|
prompts: false
|
|
51
86
|
resources: false
|
|
52
87
|
```
|
|
53
88
|
|
|
89
|
+
When Brainclaw revisits an existing config, it upgrades the exact historical
|
|
90
|
+
seven-tool managed list. Any other `tools.include` array is treated as a user
|
|
91
|
+
customization and is preserved unchanged.
|
|
92
|
+
|
|
54
93
|
## Memory Boundary
|
|
55
94
|
|
|
56
95
|
Hermes skills are procedural memory: reusable ways to perform work. Brainclaw
|
package/docs/integrations/mcp.md
CHANGED
|
@@ -409,15 +409,27 @@ bclaw_coordinate({
|
|
|
409
409
|
targetAgents: ['codex'],
|
|
410
410
|
})
|
|
411
411
|
|
|
412
|
+
// Open a direct implementation loop. The caller owns subsequent bind/turn
|
|
413
|
+
// actions, which is why allow_orphan is explicit.
|
|
414
|
+
bclaw_loop({
|
|
415
|
+
intent: 'open',
|
|
416
|
+
kind: 'implementation',
|
|
417
|
+
title: 'Implement the extracted dispatcher',
|
|
418
|
+
allow_orphan: true,
|
|
419
|
+
linked: { plan_ids: ['pln_abc'], sequence_ids: ['seq_abc'] },
|
|
420
|
+
verify: { command: ['npm', 'test'] },
|
|
421
|
+
})
|
|
422
|
+
|
|
412
423
|
// Correct a handoff instead of mutating it
|
|
413
424
|
bclaw_correct_handoff({ originalId: 'hnd_xyz', reason: 'wrong contract', text: '...' })
|
|
414
425
|
```
|
|
415
426
|
|
|
416
|
-
For the full
|
|
417
|
-
|
|
418
|
-
[docs/concepts/ideation-loop.md](../concepts/ideation-loop.md).
|
|
419
|
-
the
|
|
420
|
-
|
|
427
|
+
For the full ideation loop design (phases, context filters, iteration block,
|
|
428
|
+
advance gate, brief assembly, single vs multi-agent UX), see
|
|
429
|
+
[docs/concepts/ideation-loop.md](../concepts/ideation-loop.md). The underlying
|
|
430
|
+
engine supports the five built-in `review`, `ideation`, `implementation`,
|
|
431
|
+
`research`, and `debug` workflows, plus cross-cutting `request_input` /
|
|
432
|
+
`provide_input`; see [docs/concepts/loop-engine.md](../concepts/loop-engine.md).
|
|
421
433
|
|
|
422
434
|
#### Deprecation status
|
|
423
435
|
|
|
@@ -82,42 +82,41 @@ The Loop engine (pln#394) was designed as a generic control plane —
|
|
|
82
82
|
one engine, many protocols. Review & Fix Loop (pln#395) was the first
|
|
83
83
|
shipped protocol. The strategic reflection clarifies that:
|
|
84
84
|
|
|
85
|
-
- We do **not** need to code eight protocols.
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
- We do **not** need to code eight protocols. The five shipped defaults
|
|
86
|
+
cover the high-leverage kinds; future work should polish their entry
|
|
87
|
+
points and document further patterns as composition variants.
|
|
88
88
|
- The engine already supports everything required: `open`, `turn`,
|
|
89
89
|
`advance`, `complete_turn`, `add_artifact`, `pause`, `resume`,
|
|
90
90
|
`close`, with per-phase `advance_when`, composite `StopCondition`,
|
|
91
91
|
idempotency, and CAS.
|
|
92
92
|
|
|
93
|
-
###
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
Sequences — makes plan creation less naive.
|
|
93
|
+
### Supported protocol families
|
|
94
|
+
|
|
95
|
+
The runtime ships **five default protocols**, not just a review loop:
|
|
96
|
+
|
|
97
|
+
| Protocol | What it structures | Public entry point |
|
|
98
|
+
|---|---|---|
|
|
99
|
+
| `review` | change summary → findings → response → verdict | `bclaw_coordinate(intent="review", open_loop=true)` or `bclaw_dispatch(intent="review", openLoop=true)` |
|
|
100
|
+
| `ideation` | proposal → adversarial critique ↔ revision → synthesis | `bclaw_coordinate(intent="ideate")`, with the optional `bootstrap` preset |
|
|
101
|
+
| `implementation` | bind a plan/sequence → execute ↔ verify → handoff | direct `bclaw_loop(intent="open", kind="implementation", allow_orphan=true)`, then `bind` |
|
|
102
|
+
| `research` | investigate ↔ synthesize → conclude | direct `bclaw_loop(intent="open", kind="research", allow_orphan=true)` |
|
|
103
|
+
| `debug` | reproduce → hypothesize ↔ isolate ↔ fix → handoff | direct `bclaw_loop(intent="open", kind="debug", allow_orphan=true)` |
|
|
104
|
+
|
|
105
|
+
The direct entry point requires `allow_orphan=true` because the caller is
|
|
106
|
+
responsible for driving or dispatching the loop. It does not mean the loop is
|
|
107
|
+
unsupported: `bclaw_loop` publicly exposes `open`, `turn`, `complete_turn`,
|
|
108
|
+
`advance`, `add_artifact`, `pause`, `resume`, `close`, and the
|
|
109
|
+
implementation-specific `bind` and `verify` actions.
|
|
110
|
+
|
|
111
|
+
**Clarification is cross-cutting.** Any protocol may use `request_input` and
|
|
112
|
+
`provide_input` to pause for a bounded, evidence-backed operator decision.
|
|
113
|
+
Treating it as a shared primitive avoids inventing a review-shaped loop for a
|
|
114
|
+
simple missing decision.
|
|
116
115
|
|
|
117
116
|
### Variants, not new protocols
|
|
118
117
|
|
|
119
|
-
The following items
|
|
120
|
-
|
|
118
|
+
The following items are compositions of the shipped protocols and do not
|
|
119
|
+
require separate engine work:
|
|
121
120
|
|
|
122
121
|
- **Reflection / Self-Critique** = ideation loop with `mode:
|
|
123
122
|
'symmetric'` and all slots assigned to the same agent. The engine
|
|
@@ -125,12 +124,12 @@ above and do not require separate engine work:
|
|
|
125
124
|
- **Validation & Approval Multi-Audience** = review loop with N
|
|
126
125
|
reviewer slots (one per audience) plus a consolidator slot. Purely
|
|
127
126
|
a slot-configuration pattern.
|
|
128
|
-
- **Optimization / Refactoring** = implementation loop framed around
|
|
129
|
-
|
|
127
|
+
- **Optimization / Refactoring** = implementation loop framed around a
|
|
128
|
+
before/after artifact pair. A convention, not a new protocol.
|
|
130
129
|
|
|
131
130
|
### What "wiring" means concretely (per protocol)
|
|
132
131
|
|
|
133
|
-
For
|
|
132
|
+
For a new protocol or a material protocol extension:
|
|
134
133
|
|
|
135
134
|
- Polished `DEFAULT_PROTOCOLS` entry (phases, stop_condition, default
|
|
136
135
|
roles) in `src/core/loops/types.ts`.
|
|
@@ -165,8 +164,9 @@ sections toward visible-to-human items.
|
|
|
165
164
|
|
|
166
165
|
## 5. Practical implications
|
|
167
166
|
|
|
168
|
-
- Next implementation move: reframer phase (pln#493) on top of the
|
|
169
|
-
shipped
|
|
167
|
+
- Next implementation move: a reframer phase (pln#493) on top of the
|
|
168
|
+
shipped ideation loop, then improved ergonomics and examples for the
|
|
169
|
+
already-shipped debug and research protocols.
|
|
170
170
|
- Parallel track: the cockpit needs dedicated planning once the engine
|
|
171
171
|
emits enough signals (event streaming, reputation exposure, audit
|
|
172
172
|
narrative generation, cost attribution).
|