Cybernetic Safety Layer for Autonomous Code Repair
The only agent that understands code STRUCTURALLY and validates changes DETERMINISTICALLY before execution.
The Problem: AI coding agents (Claude Code, Codex, Copilot, Devin) generate code blindly. They have NO structural understanding of codebases, NO deterministic safety validation, and NO learning from past mistakes. They use grep β not code graphs.
The Solution: Coding Tentacle is a Safety-First Guardian Layer that sits BETWEEN the bug report and the fix engine. It doesn't write code β it controls what code gets written.
ββββββββββββββββββββββββββββββββββββ
β CODING TENTACLE β
β β
Bug Report βββββββΊβ π‘οΈ 5-Layer Safety VETO β
β π 15 Specialized Brains β
β π EvidenceLedger (immutable) β
β π§ Self-Healing Architecture β
β π Causal Code Graph β
β β
β APPROVE / BLOCK / REQUEST_MORE β
ββββββββββββββββ¬ββββββββββββββββββββ
β
ββββββββββββββββΌββββββββββββββββββββ
β FIX ENGINES β
β OpenCode β Claude β Ollama βCodexβ
β (deepseek) (Sonnet) (granite) β
ββββββββββββββββββββββββββββββββββββ
| Brain | Function | Layer |
|---|---|---|
| ReflexLayer | Instant blocks before any analysis | β‘ Reflex |
| VarietyMonitor | Ashby's Law β checks system complexity | β‘ Reflex |
| PromptInjectionBrain | Detects prompt injection in bug reports | π‘οΈ Safety |
| SafetyBrain | Scans code for DROP TABLE, eval(), system() | π‘οΈ Safety |
| RootCauseBrain | Classifies 18 root cause types | π¬ Analysis |
| CausalChainGraph | Maps code structure (who calls what) | π¬ Analysis |
| IssueUnderstandingBrain | Understands WHAT the bug report means | π¬ Analysis |
| ContextAcquisitionBrain | Finds missing context for the fix | π¬ Analysis |
| BugModeRouter | Routes bugs to the right brain pipeline | π§ Routing |
| ReflectionBrain | Meta-analysis: "Did we do the right thing?" | π§ Meta |
| SelfObservationBrain | Second-order observation of system state | π§ Meta |
| EvidenceLedger | Immutable audit trail, every decision tracked | π Audit |
| DeuteroLearningBrain | Learns patterns across multiple runs | π§ Learning |
| SelfHealingBrain | Detects and repairs internal failures | π§ Repair |
| ConsolidationCycle | Sleep/wake cycle for memory consolidation | πΎ Memory |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TENTACLE A: ANALYZE β
β β
β ReflexLayer β PromptInjection β Classifier β RootCause β
β β CausalGraph β SafetyBrain β ImpactAnalyzer β
β β EngineRouter β SkepticBrain β ApprovalGate β
β β
β Meta-Layer: Reflection β SelfObservation β Evidence β
β Learning: DeuteroLearning β Consolidation β
β Repair: SelfHealing β CircuitBreaker β
β β
β CAN block any fix. CAN learn from every run. β
β CANNOT be bypassed. β
ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β controls
ββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ
β TENTACLE B: EXECUTE β
β β
β OpenCode (deepseek-v4) | Claude Code (Sonnet) β
β Ollama (granite3.2) | Codex (disabled) β
β β
β Sandbox β TestRunner β Unified Diff Output β
β β
β CANNOT act without A. CANNOT access files directly. β
β CANNOT commit. CANNOT bypass safety. β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Feature | CT | Claude Code | Codex | Copilot | Devin |
|---|---|---|---|---|---|
| Safety VETO (5 layers) | β | β | β | β | β |
| Code Graph (causal) | β | β grep | β grep | β grep | β grep |
| Immutable Evidence Trail | β | β | β | β | β |
| Second-Order Observation | β | β | β | β | β |
| Self-Healing | β | β | β | β | β |
| Multi-Engine Routing | β | β | β | β | β |
| No Auto-Apply | β | β | β | ||
| Local-First / No Cloud | β | β | β | β | β |
CT is the ONLY system with ALL 8 features.
CT is grounded in 80 years of cybernetics research:
| Researcher | Concept | CT Implementation |
|---|---|---|
| Norbert Wiener (1948) | Feedback Loops | EngineLearning + Trust Calibration |
| W. Ross Ashby (1956) | Requisite Variety | VarietyMonitor |
| Stafford Beer (1972) | Viable System Model | Two-Tentacle Architecture |
| Humberto Maturana (1980) | Autopoiesis | SelfHealingBrain |
| Heinz von Foerster (1974) | Second-Order Cybernetics | SelfObservationBrain |
| Gordon Pask (1975) | Conversation Theory | ReflectionBrain + DeuteroLearning |
| Gregory Bateson (1972) | Learning Levels | DeuteroLearning (Learning III) |
π Full Architecture Paper (PDF)
# Clone
git clone https://github.com/nessos666/coding-tentacle.git
cd coding-tentacle
# Install
pip install -e .
# Run a bug through the pipeline
python3 -c "
from coding_tentacle.orchestrator.shadow_mode import ShadowModeRunner, GitHubIssueRun
from coding_tentacle.orchestrator.metabrain import MetaBrain, SafetyBrain
from coding_tentacle.safety.inhibitory_control import InhibitoryControl
from coding_tentacle.knowledge.security_store import create_seed_security_store
from coding_tentacle.orchestrator.engine_router import EngineRouter
from coding_tentacle.orchestrator.skeptic_brain import SkepticBrain
from coding_tentacle.safety.approval_gate import ApprovalGate
sec = create_seed_security_store()
ic = InhibitoryControl(security_store=sec)
safety = SafetyBrain(ic=ic, security_store=sec)
mb = MetaBrain(safety=safety)
er = EngineRouter(); er.check_health()
sb = SkepticBrain(); ag = ApprovalGate()
runner = ShadowModeRunner(meta_brain=mb, engine_router=er,
approval_gate=ag, skeptic_brain=sb,
safety_brain=safety)
r = runner.analyze_issue(GitHubIssueRun(
'https://github.com/user/repo', '#1',
'NullPointer in views.py',
'NoneType has no attribute at line 42'))
print(f'Bug Type: {r.detected_bug_type}')
print(f'Engine: {r.engine_used}')
print(f'Safety: {\"BLOCKED\" if r.safety_events else \"OK\"}')
print(f'Skeptic: risk={r.skeptic_risk:.2f} {r.skeptic_recommendation}')
print(f'Approval: {r.approval_status}')
"- Python 3.10+
- At least ONE fix engine:
- OpenCode CLI (
opencode) β recommended, deepseek-v4 - Claude Code (
claude) β planning & complex bugs - Ollama (
ollama+granite3.2-vision) β local fallback
- OpenCode CLI (
- No API keys required (all local)
- No cloud dependencies
- No Docker required
| Phase | Status | Goal |
|---|---|---|
| RC52-98 | β Done | 15 Brains, SelfHealing, Cybernetic Foundation |
| RC99 | π Next | SWE-bench Verified Score |
| RC100 | π Planned | Self-Evolving Brain (learns from benchmarks) |
| RC105 | π― Target | CT 2.0 Release |
| CT 3.0 | π Vision | β₯60% SWE-bench with full autonomy |
- β Safety-first guardian layer for LLM-generated code
- β Self-learning bug analysis with 15 specialized brains
- β Engine-agnostic β works with OpenCode, Claude Code, Ollama
- β Cybernetic foundation β feedback loops, homeostasis, second-order observation
- β Evidence-driven β immutable audit trail for every decision
- β Human-in-the-loop β no auto-apply, ever
- β Local-first β zero cloud dependencies, zero API costs
- β Not a replacement for Claude Code, Codex, or Copilot
- β Not an autonomous bug fixer without an LLM engine
- β Not a product β research/shadow release (v1.0.0-rc98)
- β Not a CI/CD pipeline or deployment tool
MIT β free, open source, no restrictions.
Built by David Miko + Hermes Agent Β· July 2026