# reactive agent statecharts, blackboards & worker actors

- Status: `experiment`
- Track: [reactive prompt architectures](https://aifoc.us/labs/reactive-prompts/)
- Layer: 6. Peer-to-Peer, Persistent Chrome & Agent Meshes
- Updated: 1 December 2026
- Live demo: https://reactive-agent-machines.kinlan-test.workers.dev
- Source: https://github.com/PaulKinlan/reactive-agent-machines

## Inspired by

- [the projects behind my ai focus posts](https://aifoc.us/projects/)
- [agent-do: my agent loop](https://aifoc.us/agent-do-my-agent-loop/)

## Hypothesis

- **Claim:** Moving cyclic `Agent <-> Human <-> Verifier` control flow out of `effect()` signals into explicit finite statecharts or fixed-point blackboards inside Dedicated Workers eliminates runaway ping-pong loops while keeping UI projection reactive.
- **Confirms it:** Under identical confidence/rejection triggers, cyclic `effect()` exceeds bounded step limits while pure `transition(state, event, ctx)` statecharts reject illegal events deterministically and Worker actors recover cleanly after simulated crashes.
- **Falsifies or bounds it:** Multi-step verification rules grow too rigid in explicit FSM transitions compared to pure tuple-space predicates or unbounded event loops.

> **Why this exists:** Building multi-step workflows with `reactive-agent` mixed data values and workflow control flow inside shared signals (such as passing `##STOP##` sentinel strings), causing cyclic `effect()` ping-pong loops between interviewer, human, and verification steps. Separating workflow control into an explicit statechart or tuple-space blackboard while projecting UI views through read-only signals eliminates illegal state transitions and runaway feedback cycles.


## What this lab tests

[Reactive Agent Machines](https://reactive-agent-machines.kinlan-test.workers.dev) ([GitHub](https://github.com/PaulKinlan/reactive-agent-machines)) runs cyclic `effect()` loops head-to-head against a pure FSM reducer (`transition(state, event, ctx)`) and a Rete/Linda tuple-space blackboard (`runBlackboardToFixedPoint`) executed inside a supervised Dedicated Web Worker pool (`/worker-actor.js`) over `MessageChannel`.

```js
// Control flow sits in a pure reducer; UI reads derived state signals
const { nextState, valid, effects } = transition(machine.state, {
  type: "CONFIDENCE_LOW",
  claimId,
  confidence: 0.42,
});
// Guards reject illegal events rather than firing ambiguous effect() cycles
```


## Open questions to iterate on

- When do tuple-space blackboards (`runBlackboardToFixedPoint`) outperform explicit hierarchical statecharts for opportunistic tool synthesis?
- What supervision protocol cleanly replays unacknowledged Worker mailbox messages across tab reloads using OPFS?

## Iteration log

- **2026-12-01:** Built side-by-side runner pitting cyclic `effect()` loops against deterministic FSM reducers and Worker-supervised blackboard predicates.
- **2026-12-01:** Refined 700px embed flow, added CSP-safe syntax highlighting and live statechart confidence-guard recovery, and routed static assets through the Worker with `no-cache` headers.

## Primitives tested

- `Finite Statecharts`
- `Tuple-Space Blackboard`
- `Dedicated Web Workers`
- `MessageChannel Supervision`

## Connected labs in other tracks

- [webrtc p2p agent swarm](https://aifoc.us/labs/agent-meshes/webrtc-agent-swarm/) — Extends actor state separation across browser peers via CRDT logs.
- [malleable worker plugin shell](https://aifoc.us/labs/agent-meshes/malleable-worker-shell/) — Isolates plugin actors behind typed host slot contracts.

---
Canonical: https://aifoc.us/labs/reactive-prompts/reactive-agent-machines/
