Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bash scripts/verify.sh

# 1. bump every pyproject in lockstep (3 files)
# pick X.Y.Z per SemVer:
# 0.1.4 → 0.1.5 patch (M6 heartbeat workers, joinpoint ADR-0011 + aliases, bridge 26 hooks + runtime observers)
# 0.1.4 → 0.1.5 patch (M6 heartbeat workers, joinpoint ADR-0011 + aliases, bridge 26 hooks + runtime observers) # superseded: 29 hooks as of queue wave
# 0.1.3 → 0.1.4 patch (B.AI LLM, JoinpointDiscovery, AspectJ concerns, OpenClaw bridge verify)
# 0.1.2 → 0.1.3 patch (ConcernBuilder MVP, gpt-5 tokens, OpenClaw bridge)
# 0.1.1 → 0.1.2 patch (ship CLI `service` + PyPI/doc alignment)
Expand Down
2 changes: 1 addition & 1 deletion docs/07-mvp/m6-prerequisites-status.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Re-run automation: `./scripts/verify-m6-prerequisites.sh` from repo root (daemon
| --- | --- | --- | --- |
| **P1** | Joinpoint hot path on `main` | **PASS** | `uv run pytest packages/opencoat-runtime/tests/core` |
| **P2a** | Daemon RPC smoke (`messages[]`, `#msg:`) | **PASS** | `./scripts/verify-m6-prerequisites.sh`; `user-shell-guard` in injections |
| **P2b** | Live OpenClaw gateway + bridge | **PASS** | 2026-05-18 local smoke — bridge README § Verify; 26 hooks + runtime observers (`queue.*` / `reply_run.*` / task poll) per [joinpoint model §4.1](../design/opencoat-openclaw-joinpoint-model-v0.1.md#41-mvp-emit-status-bridge-integrationsopenclaw-opencoat-bridge) |
| **P2b** | Live OpenClaw gateway + bridge | **PASS** | 2026-05-18 local smoke — bridge README § Verify; **29 hooks** + runtime observers; **`queue.before_enqueue` sync veto requires OpenClaw fork** (`queue_before_enqueue`); poll fallback observe-only per [joinpoint model §4.1](../design/opencoat-openclaw-joinpoint-model-v0.1.md#41-mvp-emit-status-bridge-integrationsopenclaw-opencoat-bridge) |
| **P3** | Conflict paths documented | **PASS** | [m6-conflict-paths.md](./m6-conflict-paths.md); [ADR-0010](../adr/0010-concern-aop-syntax.md) |

## M6 implementation
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Documentation is structured per the design (`docs/design/v0.2-system-design.md`

| Section | Folder | Status |
| --- | --- | --- |
| Design (v0.1, v0.2) | [`design/`](design/) | done — includes [OpenClaw joinpoint model v0.1](design/opencoat-openclaw-joinpoint-model-v0.1.md) |
| Design (v0.1, v0.2) | [`design/`](design/) | done — includes [OpenClaw joinpoint model v0.1](design/opencoat-openclaw-joinpoint-model-v0.1.md), [self-built effector & control plane](design/self-built-effector-control-plane.md) |
| Concept primer | [`01-concepts/`](01-concepts/) | M2 |
| Architecture | [`02-architecture/`](02-architecture/) | M2 |
| Protocols | [`03-protocols/`](03-protocols/) | M2 |
Expand Down
27 changes: 18 additions & 9 deletions docs/adr/0011-openclaw-joinpoint-model-v0.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

## Status

Accepted (design + catalog aliases on `main`; bridge runtime observers for MVP
queue/reply_run/task observe paths; synchronous native hooks remain follow-up).
Accepted (design + catalog aliases on `main`; bridge **29** plugin hooks + runtime
observers; **`queue.before_enqueue` / `queue.after_enqueue` sync collaborative
guard on HyperdustLabs fork** — see [joinpoint model §4.1](../design/opencoat-openclaw-joinpoint-model-v0.1.md#41-mvp-emit-status-bridge-integrationsopenclaw-opencoat-bridge)). **In-proc authoritative `ReflexMonitor`** (fail-closed) is v0.3 / [ADR-0012](./0012-self-built-effector-control-plane.md), not this ADR.

## Context

OpenCOAT shipped a flat joinpoint catalog (38 names, 8 levels in
`opencoat_runtime_core/joinpoint/catalog.py`) and an OpenClaw gateway bridge
(26 plugin hooks + runtime observers). OpenClaw’s real behavior control spans
(**29** plugin hooks + runtime observers). OpenClaw’s real behavior control spans
`auto-reply/reply` (queue, `ReplyRunRegistry`, `agent-runner`),
`agents/pi-embedded-runner` (`onAgentEvent`), and `tasks/task-registry` —
not only prompt/tool hooks.
Expand Down Expand Up @@ -38,19 +39,27 @@ task indexes).
6. **Full model:** Documented in
[`docs/design/opencoat-openclaw-joinpoint-model-v0.1.md`](../design/opencoat-openclaw-joinpoint-model-v0.1.md)
(14 domains; **§5 A/B/C availability tiers** for OpenClaw vs catalog). Implementation is phased (P0 catalog aliases → P2 plugin hooks →
P3 bridge runtime observers for observe-only MVP emits).
P3 bridge runtime observers → **P5a fork queue hooks**). **Collaborative → authoritative** staging: [v0.3 §10](../design/v0.3-morphogenetic-architecture.md#10-openclaw--效应器内核改造权威反射监视器), ADR-0012.

## Consequences

- `opencoat inspect joinpoints` lists legacy + v0.1 MVP names.
- Concerns may author `joinpoints: ["tool.before_call"]` or `["before_tool_call"]`.
- Queue / reply-run / task joinpoints are **emitted observe-only** by the bridge
(`onAgentEvent`, queue-depth poll, `runtime.tasks` poll) — not synchronous veto
at `enqueueFollowupRun` / `createTaskRecord` without upstream plugin hooks.
- **Decision path (fork + collaborative bridge):** `queue.before_enqueue` sync
**block** / prompt & summaryLine **rewrite** via `queue_before_enqueue` +
bridge `queue_guard` (daemon RPC). Requires fork gateway — see joinpoint model §5.7.
- **Observe fallback:** queue depth poll still emits `queue.before_enqueue` /
`queue.before_collect` when native hooks are absent (no veto).
- **Still observe-only or partial:** fine-grained `reply_run.phase.*`, generic
non-subagent `task.before_create`, `tool.result.before_emit`, unified
`memory.before_write` on every path.
- **ADR-0012** does not supersede this ADR for **unforked** hosts; cooperative
bridge remains the integration path there.
- Future ADRs may supersede alias table when v0.1 names become canonical on the wire.

## References

- ADR-0003 (host adapter as plugin), ADR-0002 (AOP mechanism)
- [OpenClaw repo](https://github.com/openclaw/openclaw) — `src/auto-reply/reply/`, `src/tasks/`
- ADR-0003 (host adapter as plugin), ADR-0002 (AOP mechanism), ADR-0012 (effector / in-proc TCB)
- [v0.3 morphogenetic architecture §10](../design/v0.3-morphogenetic-architecture.md)
- [OpenClaw fork](https://github.com/HyperdustLabs/openclaw) — branch `opencoat/hooks-v0.1`
- [integrations/openclaw-opencoat-bridge/README.md](../../integrations/openclaw-opencoat-bridge/README.md)
133 changes: 133 additions & 0 deletions docs/adr/0012-self-built-effector-control-plane.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# ADR 0012 — Self-built effector & deterministic control plane (OpenClaw fork)

## Status

Proposed (design). For the **deterministic** subset of joinpoints this supersedes
ADR-0011's "OpenClaw owns state; OpenCOAT owns concern" guest-plugin posture.
ADR-0011's cooperative bridge remains the integration path for **unforked** hosts.

## Context

- ADR-0002 made AOP the activation mechanism; ADR-0003 made the host adapter a
plugin; ADR-0011 mapped OpenClaw's lifecycle into a 14-domain joinpoint model.
- The current OpenClaw integration is a **guest plugin**
(`integrations/openclaw-opencoat-bridge`). Its enforcement is *cooperative*:
the core emits `WeavingOperation` rows (`block`, `rewrite`, `suppress`, …);
the bridge folds them into host decisions (`guardToolCall`,
`messageSendingDecision`, `subagentSpawnDecision`, `queueBeforeEnqueueDecision`);
OpenClaw applies them through public hooks and **retains final state mutation**
(mutation boundary `read_only` / `policy_only` / `host_api_only`).
- Joinpoint model §5 classifies availability A/B/C. The genuinely deterministic
interception points — `tool.before_execute` (mid-flight arg rewrite),
`response.before_final` (verifier before delivery), `memory.before_write` — are
**Tier C** for *in-proc authority*: blocked until `ReflexMonitor` lands in the fork.
**`queue.before_enqueue` is Tier A on the fork** (native `queue_before_enqueue` hook)
and already emits a **collaborative** `queue_guard` via the bridge — block/rewrite,
not observe-only. Tier C still includes `memory.before_write`, `tool.result.before_emit`,
and other sync paths skipped in the bridge. Even Tier A "strong control" today is
cooperative: tool-arg rewrite is explicitly disabled in `injector.ts`
("Notes only — do not overwrite structured params on append advice").
- `WeavingOperation` (12 ops: `INSERT, REPLACE, SUPPRESS, ANNOTATE, WARN, VERIFY,
REWRITE, DEFER, ESCALATE, BLOCK, COMPRESS`) is **undifferentiated** — it carries
no hard/soft distinction and no fail-closed semantics. The 2004 paper's
separation of a deterministic **Reflex layer (RAL ≈ spinal cord)** from the
adaptive **Knowledge-Based layer (KBAL ≈ cortex)** is collapsed into one enum.
- Net: against a *stochastic LLM effector* behind a *cooperative host*, most
weaving degrades to prompt text whose causal effect on behavior is unknowable.
This is both a reliability gap and — per the morphogenetic design §9 — a
**credit-assignment** gap for the aspect-net (you cannot cleanly credit an
advice whose effect you cannot deterministically observe).

## Decision

1. **Build a first-party effector by forking OpenClaw.** The effector is a full
MAN instance (`M = (N, ⇩_fast, ⇩_slow, F, κ, T)`) whose `EffectorKernel`
owns the turn loop: route → `ExcitatoryNeuron.propose` → `InhibitoryReflex.mediate`
→ verify→repair → action execution → deterministic `r_t` emission.
This is a new host class (`opencoat_runtime_host_effector`), not a guest plugin.
Engineering landing: v0.3 architecture §3.5 + §10.

2. **Introduce typed aspect cell kinds** — not two separate "planes" but two cell
types within the same connectome (`N`), unified under one plasticity law:
- **`InhibitoryReflex`** (`A_reflex ⊆ A`). Deterministic, fail-closed, in-proc
`ReflexMonitor` (small trusted core / TCB) at effect boundaries. Decisions are
`Allow | Deny(reason) | Rewrite(action')` — **enforced, not suggested**.
Safety-critical policies: `deny` on miss or error (fail-closed).
`A_reflex` excluded from `⇩_slow` structural rewriting (conserved core /
brainstem invariant). Engineering landing: v0.3 §3.3 + §10.2–10.3.
- **`ExcitatoryNeuron`** (`A_cortex = A \ A_reflex`). Aspect-LLM neurons that
`propose` candidates; weaver composes their advice into prompt injections.
Subject to `⇩_slow` (morphogenesis). Engineering landing: v0.3 §3.2.

3. **Promote Tier C joinpoints to in-proc synchronous interception** in the fork
via `ReflexMonitor.mediate`. OpenClaw hook mapping (v0.3 §10.1):

| Hook | Gate | **Current (2026-05)** |
|---|---|---|
| `before_tool_call` | authority reflex (step 1) | collaborative — daemon RPC `tool_guard` |
| `message_sending` | authority reflex (step 1) | collaborative — outbound cancel |
| `subagent_spawning` | authority reflex (step 1) | collaborative — spawn veto |
| `queue_before_enqueue` | authority reflex (step 1) | **collaborative on fork** — `queue_guard` block/rewrite |
| `before_agent_reply` | verify→repair (step 2) | not wired (bridge uses `message_sending`) |
| `after_tool_call` / `llm_output` / `agent_end` | `r_t` emission (step 3) | observe only — **`r_t` pending** |
| `before_message_write` / `tool_result_persist` | re-admit when in-proc | **skipped** in bridge |

Previously-skipped hooks (`before_message_write`, `tool_result_persist`) can be
re-admitted because the monitor runs in-proc synchronously (no daemon RPC).

4. **Tag the substrate.** Annotate each `WeavingOperation` / `AdviceType` with
`enforcement: hard | soft`, `fail_mode`, and add `neuron_type: excitatory |
inhibitory` to `Concern`. Designate the conserved core `A_reflex` via a
`reflex: true` marker excluded from `PlasticityEngine` rewrites.

5. **Wire the closed loop: `r_t` → `CreditField` → `PlasticityEngine`.** Hard
decisions produce clean credit (causal effect known); soft advice credit is
statistically estimated. The plasticity engine runs at three time scales (fast /
warm / cold) replacing heuristic meta-governance. Engineering landing: v0.3 §3.6
+ §5.

6. **Language/process boundary** (v0.3 §10.4): `ReflexMonitor` (hot path, TCB)
implemented in TypeScript inside the OpenClaw process for synchronous authority;
`PlasticityEngine` and credit field live in the Python daemon (warm/cold path).
Policies are expressed as a portable deterministic spec exported from OpenCOAT.

7. **Keep the cooperative bridge.** For unforked hosts, ADR-0011's bridge remains
the integration path. Fork-based effector is an additional capability; both share
wire protocol and concern semantics.

## Consequences

- `InhibitoryReflex` decisions gain real authority: `Deny` / `Rewrite` are enforced
at the call site and fail-closed, closing the cooperative-enforcement gap.
- **Closed loop established**: `r_t` flows from `EffectorKernel` → `CreditField` →
`PlasticityEngine`. Hard decisions yield clean credit (morphogenetic §9); soft
advice credit remains statistically estimated. First time the system has a
deterministic, measurable learning signal.
- The 2004 RAL/KBAL separation is reinstated as two **typed cell kinds** within one
connectome, unified under one plasticity law — not two separate subsystems.
- The hexagonal seam (ADR-0006) gains an `EffectorReflexPort` so the core stays
host-agnostic; the fork is one adapter behind it.
- The `(i)→(ii)` migration path (v0.3 §7) is non-destructive: start with one
`ExcitatoryNeuron` + reflex ring, then widen (multi-neuron MoE) and deepen
(`lift`: aspect-of-aspect) under the same plasticity law.
- Cost: fork drift vs upstream OpenClaw; TS/Python boundary requires portable policy
spec; `ReflexMonitor` is safety-critical — a buggy TCB can deadlock the agent,
hence the `A_reflex` invariants + JSONL replayability are load-bearing.

## References

- ADR-0002 (AOP as mechanism), ADR-0003 (host adapter as plugin),
ADR-0006 (hexagonal ports), ADR-0008 (meta-concern governance),
ADR-0011 (OpenClaw joinpoint model v0.1).
- **Engineering landing (v0.3 architecture)**:
[`docs/design/v0.3-morphogenetic-architecture.md`](../design/v0.3-morphogenetic-architecture.md) —
cell types §3, one-turn sequencing §4, three time scales §5, existing-package
mapping §6, migration path §7, OpenClaw hook mapping §10.
- Reflex layer spec + interface contract + milestone roadmap:
[`docs/design/self-built-effector-control-plane.md`](../design/self-built-effector-control-plane.md).
- Formal grounding:
[`docs/design/morphogenetic-aspect-agent.md`](../design/morphogenetic-aspect-agent.md)
§1 (`A_reflex` conserved core), §2 (`⇩_fast` turn), §3 (credit field `κ`),
§5 (plasticity grammar), §9 (hard weaving = clean credit).
- 2004 paper (WAOSD'2004): RAL = spinal cord (deterministic reflex),
KBAL = cortex (adaptive / synaptic plasticity).
Loading
Loading