Structured Deliberation and Verification Control Plane for AI Agents
Fable Mode is an open-source control plane and verification runtime for AI coding agents. It enforces structured deliberation, evidence-backed proof receipts, adversarial red-team review, and persistent engineering memory before agents modify your workspace.
When coding agents rush into premature file edits, Fable Mode provides the missing control framework: time-bounded deliberation, tool execution receipts, closed-loop red-team stress testing, and structured session lineage.
Best for: AI agent developers, MCP adopters, and software engineers seeking reliable, verified AI agent workflows.
Start here: Installation & Client Setup Β· V1 vs V2 Runtime Architecture Β· 6-Phase Lifecycle Β· Testing & Verification
Project status: Fable Mode is an open-source research and engineering project. The stable core consists of the MCP server (
fable-engine), time-locked session state machine, proof receipts, red-team code review swarm, and execution broker (fable-v2-broker). Advanced System 3 meta-cognitive modules infable_v2/system3/are experimental features.
Overview β’ V1 vs V2 Architecture β’ Core Components β’ 6-Phase State Machine β’ MCP Tool Reference β’ Installation & Integration β’ Testing
π Overview: The Deliberation Challenge
Generative language models often attempt code modifications immediately upon receiving a promptβbypassing memory hierarchy modeling, edge case analysis, concurrency hazards, or state invariant verification.
Self-prompting and stochastic searches can suffer from hallucinated confidence scores ($Q$-score drift) when intermediate reasoning steps go unverified.
$$\boxed{\text{Agent Request} \xrightarrow{\quad\text{Time-Lock & Deliberation}\quad} \text{Evidence & Proof Receipts} \xrightarrow{\quad\text{Adversarial Review}\quad} \text{Gated Workspace Write}}$$
Fable Mode establishes an evidence-gated workspace control layer:
- Deliberation Gating: Workspace write execution remains locked until time-budget requirements, refinement cycles, and empirical proof receipts are satisfied.
- Evidence Validation: Claims of testing or verification must be backed by actual tool receipts (
ToolReceipt), AST coordinate bindings, and file hashes. - Adversarial Review: Subagent code implementations are evaluated by a 5-vector red-team review swarm before milestone commits.
π V1 MCP Server vs. V2 Execution Runtime
Fable Mode provides two complementary components designed to support agent harnesses:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI AGENT HARNESS β
β (Claude Code, Antigravity, Cursor, Codex, etc.) β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β FABLE V1 MCP SERVER β β FABLE V2 EXECUTION BROKERβ
β (`fable_engine.server`) β β (`fable_v2.execution_brk`)β
ββββββββββββββββββββββββββββββββββββββββββββββββ€ βββββββββββββββββββββββββββββ€
β β’ Session State Machine & Time-Locks β οΏ½οΏ½οΏ½ β’ Out-of-Process Isolationβ
β β’ Epistemic Ledger ([PROVEN], [HYPOTHESIS]) β β β’ Command & Exec Allowlistβ
β β’ Red Team Swarm & Cortical Memory β β β’ Protected Admin Handle β
β β’ Proof Validation & Lineage Logging β β β’ ToolReceipt & Evidence β
ββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
Fable V1 (
fable-engineMCP Server):- Implements the
fable_sessionMCP tool interface using stdio JSON-RPC 2.0. - Manages session lifecycle, time-locks, epistemic tracking, refinement logs, red-team review cycles, and cortical memory updates.
- Backward-compatible entry point that connects directly to MCP-enabled agent hosts.
- Implements the
Fable V2 (
fable-v2-brokerExecution Broker & Portable Runtime):- Provides a separate process execution boundary (
fable-v2-broker) for workspace operations. - Restricts executable commands via strict allowlists, blocks interactive shell bypasses, and enforces path containment.
- Uses an administrative control pipe (
--admin-fd) separate from model input to manage workspace write permissions. - Implements portable runtime objects (
TaskSpec,ToolReceipt,Evidence,Candidate,VerificationResult) to bind tool outputs directly to candidate verification policies.
- Provides a separate process execution boundary (
π Core Fable Components
1. Adversarial Code Review Swarm (RedTeamSwarm)
Subagents often produce code that passes basic happy-path unit tests but fails under boundary conditions, race conditions, or unexpected inputs.
The RedTeamSwarm conducts automated adversarial stress testing across 5 vectors before code is accepted:
βββββββββββββββββββββββββββββ
β RED TEAM SWARM β
β 5 Attack Personas β
βββββββββββββββ¬ββββββββββββββ
β
βββββββββββββββββββββ¬ββββββββββββββββΌββββββββββββββββ¬ββββββββββββββββββββ
βΌ βΌ βΌ βΌ βΌ
βββββββββββββββββ βββββββββββββββββ βββββββββββββ ββββββββββοΏ½οΏ½οΏ½ββββββ βββββββββββββββββ
β CHAOS β β BYZANTINE β βCONCURRENCYβ β RESOURCE β β STATE β
β ENVIRONMENT β β PAYLOAD β β RACE β β EXHAUSTION β β INVARIANT β
βββββββββββββββββ€ βββββββββββββββββ€ βββββββββββββ€ βββββββββββββββββ€ βββββββββββββββββ€
ββ’ Missing path β ββ’ Null bytes β ββ’ Multi-thrdβ ββ’ Oversized payloadββ’ Non-idempotentβ
ββ’ Denied perms β ββ’ Deep recursionβ β contentionβ ββ’ Rapid churn β execution β
ββ’ Truncated I/Oβ ββ’ None/Type-conβ ββ’ TOCTOU β ββ’ CPU timeout β ββ’ Out-of-order β
ββ’ Corrupt env β ββ’ Extreme valuesβ ββ’ Lock raceβ ββ’ Resource leaksβ lifecycle β
βββββββββββββββββ βββββββββββββββββ βββββββββββββ βββββββββββββββββ βββββββββββββββββ
- Chaos Environment (
chaos_environment): Tests missing paths, unlinked temporary directories, permission denials, and corrupt environment variables. - Byzantine Payload (
byzantine_payload): Injects null bytes (\x00), deeply nested structures, type mismatches (None), and extreme numerical values (NaN,Infinity). - Concurrency Race (
concurrency_race): Simulates multithreaded contention, Time-of-Check to Time-of-Use (TOCTOU) mutations, and reentrancy deadlocks. - Resource Exhaustion (
resource_exhaustion): Evaluates large string payloads, high-frequency churn, resource handle leakage, and CPU timeout bounds. - State Invariant (
state_invariant): Checks non-idempotent execution ($f(f(x)) \neq f(x)$), out-of-order lifecycle calls, and state corruption.
Closed-Loop Remediation Ping-Pong
- Subagent Submission: Coder subagent completes initial task implementation.
- Swarm Stress Test: Main Agent executes
RedTeamSwarm.run_full_review_cycle(). - Breakage Report: If issues are found, a
RedTeamBreakageReportis returned with failure details. - Subagent Remediation: The subagent fixes identified breakages and resubmits.
- Re-Testing: Swarm runs
verify_remediation()to verify fixes without introducing regressions.
from fable_v2.coder_fleet import RedTeamSwarm
swarm = RedTeamSwarm()
report = swarm.run_full_review_cycle(target_callable=my_service, target_name="auth_service")
if not report.passed:
print(f"Swarm identified {report.broken_count} breakages.")
all_fixed, new_report = swarm.verify_remediation(target_callable=hardened_service, prior_report=report)
if all_fixed:
print("All breakages resolved.")
2. Hebbian Cortical Plasticity Engine (HebbianPlasticityEngine)
To prevent agents from repeating past errors across sessions, the Hebbian Plasticity Engine provides persistent domain memory (skills/fable-mode/cortex/<domain>.md) organized across five specialized domain lobes:
rust: Zero-cost abstractions, Pin/Unpin, Tokio bounds, lifetime management.python: Asyncio task groups, GIL-free execution, protocols, slot memory optimization.design_3d: Shader nodes, frame budgets, render loops, smooth interpolation.research: First-principles analysis, causal DAGs, citation grounding, trade-off matrices.concurrency: Lock-free CAS, memory barriers, ABA hazards, TOCTOU prevention.
How Adaptation Works
- Synaptic Weight Updates: Co-activated tools and concepts involved in successful tasks receive positive weight adjustments: $$\Delta W_{ij} = \eta \cdot \text{Score} \cdot (A_i \cdot A_j) \quad (\eta = 0.10)$$
- Homeostatic Bounds: Weights are bounded within $[0.05, 1.00]$ to maintain relative associations without saturation.
- Antibody Records: Breakages identified by
RedTeamSwarmare formatted intoHeuristicAntibodyrecords and cataloged in domain cortex files. - Context Recall:
cortical_recall_contextretrieves relevant antibodies and domain rules to inject into subagent prompts before code generation.
from fable_v2.coder_fleet import CoderFleetDispatcher
fleet = CoderFleetDispatcher()
# 1. Activate domain lobe
fleet.dispatch("cortical_activate_lobe", {"domain": "python", "co_activated_nodes": ["asyncio", "protocols"]})
# 2. Retrieve relevant domain memory for prompt injection
context = fleet.dispatch("cortical_recall_context", {"domain": "python", "max_antibodies": 3})
# 3. Consolidate results after task completion
receipt = fleet.dispatch("cortical_consolidate_task", {
"domain": "python",
"task_id": "async_task_fix",
"final_passed": True,
"co_activated_nodes": ["asyncio", "protocols"],
})
3. Proof Engine & Evidence Validation (DeterministicProofValidator)
Claims made by agents (e.g., "tests pass", "verified code") must be backed by verifiable evidence:
- Cryptographic File Hashes: SHA-256 digests track source code state; modifications invalidate prior proofs.
- AST Coordinate Binding: Binds claims to exact source coordinates (
path/to/file.py:L10-L35, function signature, node type). - Tool Receipt Attestation: Validates execution output from tool runs (
ToolReceiptexit code, test runner output logs). - Anti-Circularity Filtering: Rejects vacuous or circular assertions.
4. Experimental System 3 Modules (fable_v2/system3/)
For advanced meta-cognitive research, fable_v2/system3/ contains experimental reasoning modules:
- Causal Simulation (
causal.py): Pearl's do-calculus DAG interventions and sensitivity analysis. - Modal Model Checking (
kripke.py): Kripke multi-world structures and CTL temporal logic checking ($AG$, $EF$, $AF$). - Active Inference (
free_energy.py): Variational Free Energy minimization and policy selection ($G$). - Proof Oracle (
oracle.py): Curry-Howard type checker and undecidability boundary detector. - Hyperbolic Tree Embeddings (
hyperbolic.py): PoincarΓ© ball tree embeddings for hierarchy representations. - Dialectical Synthesis (
dialectical.py): TRIZ contradiction matrix trade-off resolution. - Pareto Evolution (
evolution.py): 10-dimensional architectural Pareto frontier search.
π How It Works: The 6-Phase State Machine
Fable Mode operates through a sequential six-phase lifecycle. Transitioning from deliberation (Phases 1β3) to workspace execution (Phases 4β6) requires satisfying the mechanical time-lock and proof criteria:
flowchart TD
classDef phase fill:#090d16,stroke:#27272a,color:#f4f4f5,stroke-width:1px;
classDef gate fill:#18181b,stroke:#52525b,color:#fafafa,stroke-dasharray: 4 4,stroke-width:1.5px;
classDef unlocked fill:#0c1322,stroke:#3b82f6,color:#f8fafc,stroke-width:1.5px;
subgraph Deliberation ["PHASE 1β3: DELIBERATION (WORKSPACE LOCKED)"]
direction TB
P1["<b>01 Β· Epistemic Grounding</b><br/>β’ Execute terminal probes via read tools<br/>β’ Catalog [PROVEN], [HYPOTHESIS], [UNKNOWN]<br/>β’ Workspace modifications prohibited"]:::phase
--> P2["<b>02 Β· Invariant Specification</b><br/>β’ Define state bounds & memory layouts<br/>β’ Evaluate engineering trade-offs<br/>β’ Register formal system invariants"]:::phase
--> P3["<b>03 Β· Adversarial Red-Teaming</b><br/>β’ Conduct rethink-refine deliberation cycles<br/>β’ Execute scratch micro-benchmarks<br/>β’ Run red-team review simulations"]:::phase
end
subgraph Barrier ["MECHANICAL TIME-LOCK GATEKEEPER"]
G{"<b>unlock_execution</b><br/>1. Monotonic Clock ≥ Time Budget<br/>2. Refinement Cycles Completed<br/>3. Proofs & Evidence Validated"}:::gate
end
subgraph Execution ["PHASE 4β6: EXECUTION & VERIFICATION (WORKSPACE UNLOCKED)"]
direction TB
P4["<b>04 Β· Subagent Delegation</b><br/>β’ Formulate bounded contracts for subagents<br/>β’ Dispatch subagent execution fleet<br/>β’ Execute atomic file diffs"]:::unlocked
--> P5["<b>05 Β· Multi-Tier Verification</b><br/>β’ Tier 1: AST parsing & linter checks<br/>β’ Tier 2: Unit test suite runs<br/>β’ Tier 3: Concurrency & boundary tests<br/>β’ Tier 4: Invariant validation"]:::unlocked
--> P6["<b>06 Β· Session Reporting</b><br/>β’ Write snapshot to Write-Ahead Log<br/>β’ Record final session lineage<br/>β’ Seal milestone receipt"]:::unlocked
end
Deliberation --> Barrier
Barrier -->|Gate Passed| Execution
Barrier -.->|Time Remaining < Budget| P3
β‘ MCP Quick Reference Table
The fable-engine server exposes the unified fable_session tool adhering to JSON-RPC 2.0 over stdio:
| Action | Category | Arguments | Behavior |
|---|---|---|---|
create_session |
Lifecycle | session_name, objective, time_budget_minutes |
Initializes session Write-Ahead Log (WAL) and sets initial deliberation time budget ($\ge 2.0\text{ min}$). |
set_timer |
Pacing | session_name, time_budget_minutes |
Updates internal sub-timer without reducing the mandatory authority deadline. |
get_status |
Telemetry | session_name |
Returns elapsed time, active phase, gate checklist, and status metrics. |
log_epistemic_item |
Epistemics | session_name, tag, claim, evidence |
Records epistemic items ([PROVEN], [HYPOTHESIS], [UNKNOWN]). [PROVEN] requires tool output evidence. |
record_invariant |
Invariants | session_name, invariant_name, formal_statement, proof_or_rationale, domain? |
Registers formal system constraints and invariant statements. |
log_refinement_cycle |
Refinement | session_name, refinement_type, focus_area, critique_or_bottleneck, architectural_refinement |
Records architectural rethink/refine cycles required before unlock. |
track_file_change |
Lineage | session_name, file_path, change_type, diff_summary, affected_invariants? |
Tracks mutated, created, deleted, or slated files with SHA-256 digests. |
get_session_lineage |
Lineage | session_name |
Returns complete session provenance, epistemic ledger, and proof receipts. |
inspect_plan |
Planning | session_name |
Retrieves active execution plan, gate checklists, and subagent boundaries. |
verify_proof |
Proof Engine | claim, proof_type, evidence, target_resource? |
Validates AST node references, tool receipts, or SHA-256 file hashes. |
unlock_execution |
Gatekeeper | session_name, rationale |
Evaluates time-lock clock and refinement criteria to unlock workspace modifications. |
check_auto_update |
Sync | session_name? |
Probes upstream repository for updates without blocking execution. |
apply_auto_update |
Sync | preserve_cortex? |
Updates skills and configuration while preserving local cortical learning. |
scrape_web |
Research | target, auto_log_epistemic? |
Scrapes web page URL or performs free DuckDuckGo web search returning Markdown. |
scrape_youtube |
Research | target, auto_log_epistemic? |
Scrapes YouTube video metadata and public caption/transcript tracks returning Markdown. |
scrape_reddit |
Research | target, auto_log_epistemic? |
Scrapes Reddit threads, comments, or subreddits via free JSON API returning Markdown. |
scrape_x |
Research | target, auto_log_epistemic? |
Scrapes individual Tweet URLs via Twitter syndication API and best-effort handle lookups returning Markdown. |
scrape_github |
Research | target, auto_log_epistemic? |
Scrapes GitHub repository metadata, READMEs, or repository search returning Markdown. |
scrape_arxiv |
Research | target, auto_log_epistemic? |
Scrapes arXiv academic papers, abstracts, and PDF links returning Markdown. |
π¦ Installation & Client Integration
Fable Mode requires zero third-party dependencies for core operations, using the Python standard library (Python 3.10+).
1. Installation via Agent Prompt
To configure Fable Mode within an AI agent environment (Antigravity, Cursor, Claude Code, Windsurf, Codex, Cline, Roo Code, etc.), run the following setup steps:
Clone the repository:
git clone https://github.com/REX-codebase/fable-mode.git cd fable-modeInstall Skill Files: Copy
skills/fable-modeinto your host agent's skill directory:- Antigravity / Gemini:
~/.gemini/config/skills/fable-mode/ - Claude Code:
~/.claude/skills/fable-mode/ - Cursor:
.cursor/skills/fable-mode/ - Generic / Codex / Roo / Cline:
./skills/fable-mode/
- Antigravity / Gemini:
Register MCP Server: Configure
fable-enginein your agent harness's MCP configuration (mcp_config.json,.cursor/mcp.json, or host settings):{ "mcpServers": { "fable-engine": { "command": "python", "args": ["-m", "fable_engine.server"], "cwd": "/path/to/fable-mode" } } }Install Python Package (Optional for V2 Execution Broker):
pip install -e .
2. Manual Installer Scripts
Optionally run the provided platform installer scripts to set up aliases and host configurations:
Windows (PowerShell)
powershell -ExecutionPolicy Bypass -File .\install.ps1 -Yes -RegisterHosts -Aliases
macOS / Linux (Bash)
chmod +x ./install.sh && ./install.sh --yes
3. MCP Host Configuration Examples
Claude Code CLI
claude mcp add --transport stdio fable-engine -- python -m fable_engine.server
Cursor
Navigate to Cursor Settings $\rightarrow$ Features $\rightarrow$ MCP Servers $\rightarrow$ Add New MCP Server:
- Name:
fable-engine - Type:
command - Command:
python -m fable_engine.server
Antigravity / Gemini
In .agents/mcp_config.json or ~/.gemini/antigravity/mcp/:
{
"mcpServers": {
"fable-engine": {
"command": "python",
"args": ["-m", "fable_engine.server"],
"cwd": "${workspaceFolder}"
}
}
}
π§ͺ Test Verification & Quality Assurance
Fable Mode includes a test suite verifying the MCP server, session state WAL, token compressor, execution broker, and System 3 modules using Python's standard unittest framework.
Running Tests Locally
Test MCP Server Integration:
python fable_engine/test_server.pyRun All Unit Tests:
python -m unittest discover -s tests -p "test_*.py" -v
All core tests run in standard-library isolation without requiring external network connectivity or third-party Python packages.
π Repository Structure
fable-mode/
βββ fable_engine/ # MCP Server & Tool Engine (V1)
β βββ server.py # Pure Python stdlib JSON-RPC 2.0 MCP server
β βββ fable_session.json # Unified MCP tool declaration schema
β βββ test_server.py # Integration test suite for MCP server
βββ fable_v2/ # Deliberative & Verification Architecture (V2)
β βββ execution_broker.py # Isolated execution boundary process
β βββ runtime.py # Verification-guided runtime state machine
β βββ protocol.py # TaskSpec, ToolReceipt, Evidence, Candidate objects
β βββ verifiers.py # Verifier policy implementations
β βββ coder_fleet/ # Red Team Swarm & Coder Fleet Dispatcher
β β βββ red_team_swarm.py # Adversarial review swarm (5 personas)
β β βββ fleet_dispatcher.py # Fleet route manager
β β βββ test_harness.py # Sandboxed scratch test runner
β βββ cortical/ # Hebbian Cortical Plasticity Engine
β β βββ plasticity_engine.py # Hebbian learning & antibody memory
β βββ system3/ # Experimental Meta-Cognitive Modules
β βββ causal.py # Pearl Causal DAGs & do-calculus simulation
β βββ kripke.py # Kripke modal model checker (CTL)
β βββ free_energy.py # Friston Active Inference
β βββ oracle.py # Curry-Howard proof checker
β βββ hyperbolic.py # PoincarΓ© disk hyperbolic tree embeddings
β βββ dialectical.py # TRIZ contradiction resolution
β βββ evolution.py # 10D Pareto frontier search
βββ fable_compressor.py # Content-Addressed Storage & compression
βββ skills/ # Deliberative Agent Protocols & Cortex Lobes
β βββ fable-mode/
β βββ SKILL.md # Core cognitive instructions
β βββ cortex/ # Domain cortex files (rust, python, design, research, concurrency)
βββ docs/ # Architecture & Migration Documentation
β βββ fable-v1-v2-migration.md # V1 to V2 migration guide
β βββ fable-v2-architecture.md # V2 portable verifier runtime design
β βββ system3-architecture.md # System 3 meta-cognitive architecture
βββ tests/ # Unit test suite
βββ LICENSE # MIT License
Built by REX-codebase. Structured Deliberation β’ Evidence Validation β’ Verified AI Workflows
Comments