brainclaw 1.26.0 → 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.
@@ -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
- reviews, ideation rounds, implementation handoffs
5
+ review, ideation, implementation, research, and debugging
6
6
  into **first-class, persistable, automatable objects**.
7
7
 
8
- Status: design draft v8 (pln#394 step 1). v6 added a hard mutation deadline + consistent opt-out-`open` and unified terminology. v7 made `turn` strictly async and fenced committing writes with `mutation_id` re-reads. v8 applies Codex's follow-up lock-check (cnd#580 / `dec_4ba1a20f`) and introduces the symmetric review-and-fix protocol mode. Codex-authored fixes: the commit protocol now makes **journal replay before CAS normative**, `complete_turn` and any future slot-bound mutation now require the caller's `agentId` to match the slot owner (with `created_by` as the only admin fallback), and lock-heartbeat renewals are written by temp-file + atomic rename so fence reads always observe a coherent JSON blob. Final symmetric-mode integration: `open` accepts `mode: 'asymmetric' | 'symmetric'`, the resolved selection is persisted on the loop thread for deterministic resume/turn handling, and per-turn execution degrades cleanly to asymmetric behavior when a slot cannot safely apply fixes.
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
- Today, recurring multi-agent work is done by hand:
13
- an operator copies a diff, pastes it to a reviewer, collects the findings,
14
- pastes them back to the author, re-asks for a re-review.
15
- Each round is glue work, lost context, and copy-paste errors.
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
- ## Default protocols
295
-
296
- Each `kind` ships a default `phases[]` and `stop_condition`. Users can override either at `open` time.
297
-
298
- | kind | phases | default stop_condition |
299
- |---|---|---|
300
- | `review` | `change_summary` → `findings` → `author_response` → `followup_review` → `verdict` | `reviewer_green` OR `max_iterations: 3` |
301
- | `ideation` | `proposal` → `critique` ↔ `revision` → `synthesis` (with iteration block + per-phase `context_filter` + `advance_gate` ≥3 critique artifacts; see [ideation-loop.md](./ideation-loop.md)) | `artifact_produced { phase: synthesis, type: plan_draft }` |
302
- | `implementation` | `sequence_build` `dispatch` `execute` `self_check` → `handoff_ready` | `artifact_produced { phase: handoff_ready, type: handoff }` |
303
- | `research` / `debug` | user-defined | `manual` |
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
- ## Automation: extending `bclaw_coordinate(intent='review')`
344
+ ## Review automation (one workflow)
321
345
 
322
- This is the user-visible promise of the MVP — manual review round-trips disappear.
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
- - Discussion loops (`review`, `ideation`) route by `slot_id` — the engine writes to the slot's agent inbox via the existing coordinate path.
486
- - Execution loops (`implementation`) route by `claim_id` preserved from the claim-routed model already in use.
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
- ## Next steps
548
+ ## Implementation status
523
549
 
524
- 1. If this final v8 review is green, lock the schema (this doc → `types.ts` in `src/core/loops/`).
525
- 2. Implement the four verbs (`open`, `turn`, `advance`, `close`) with the 2-phase-commit persistence described above.
526
- 3. Wire `bclaw_loop` into the MCP surface (pending pln#392 versioning policy).
527
- 4. Build the `review` protocol end-to-end (pln#395) as the first user-visible loop.
528
- 5. Add the `open_loop` opt-in on the existing `bclaw_coordinate(intent='review')` the first manual-process killer.
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
- ## Loops available today
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
- Custom phase lists (`LoopPhase[]`) and bespoke `StopCondition` logic exist in the loop engine internally, but are **not** exposed through the MCP facade today: `CoordinateRequestSchema` accepts only `open_loop`, `review_mode`, `preflight`, `ref`, and `preset` — no `phases` or `stop_condition` — and the standalone `bclaw_loop` tool does not expose an `open` intent. Programmatic construction of ad-hoc loops is therefore internal / future work until the facade is extended.
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 facade and canonical
28
- grammar tools:
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
@@ -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 ideation_loop design (phases, context_filter, iteration
417
- block, advance_gate, brief assembly, single vs multi-agent UX), see
418
- [docs/concepts/ideation-loop.md](../concepts/ideation-loop.md). For
419
- the underlying loop engine, see
420
- [docs/concepts/loop-engine.md](../concepts/loop-engine.md).
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. We need to wire four
86
- polished entry points for the high-leverage kinds, and document
87
- patterns for the rest as composition variants.
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
- ### Ranked protocols to wire next
94
-
95
- 1. **Ideation Loop** **MVP shipped in v1.5.0** (pln#492). The shipped
96
- shape is single-champion-plus-memory rather than the four-role
97
- framing originally drafted: empirical work in May 2026
98
- (`feedback_ideation_loop_single_agent_method`) showed that one
99
- model produces useful adversarial pressure when the critic phase's
100
- `context_filter` makes it confront only adversarial memory (traps,
101
- feedback, runtime_notes). Multi-agent slots are still supported as
102
- an opt-in for richer diversity. See [docs/concepts/ideation-loop.md](../concepts/ideation-loop.md).
103
- Reframer phase (pln#493) is the next layer covers the
104
- novelty/simplicity/external-pattern blind spot of memory-driven
105
- critique.
106
- 2. **Debug & Root-Cause Loop**. Five phases: symptom hypothesis
107
- test fix verify. Targets the #1 pain point of single-agent
108
- debugging the lack of structure. High daily impact.
109
- 3. **Research & Synthesis Loop**. Researcher → analyzer → synthesizer
110
- → validator. Replaces "the human reads twenty pages" with a
111
- condensed summary of the same sources. Novel utility vs the other
112
- protocols.
113
- 4. **Planning & Breakdown Loop**. Goal decomposer estimator
114
- validator refiner. Compounds with brainclaw's existing Plans and
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 from the brainstorm are compositions of the four
120
- above and do not require separate engine work:
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
- a before/after artifact pair. A convention, not a new protocol.
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 each of the four priority protocols:
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 ideation_loop, then the Debug & Root-Cause Loop.
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).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brainclaw",
3
- "version": "1.26.0",
3
+ "version": "1.26.2",
4
4
  "description": "Shared project memory for humans and coding agents.",
5
5
  "type": "module",
6
6
  "repository": {