Skip to content

IMPORTANT

AI Context & Knowledge Heritage

  • Subsystem: Architecture & Documentation / Core Docs / Architecture_Overview
  • Architecture: @docs ARCHITECTURE:Documentation
  • Failure Path: Information drift, legacy terminology, or documentation mismatch.
  • Observability: Traceability via execution/parity_guard.py

🪐 Architecture Overview: Tadpole OS ​

Intelligence Level: High (Sovereign Context)
Status: Architecture overview; verify operational behavior against the current source Version: 1.4.4
Last Hardened: 2026-11-09 (codebase-wide clean code, zero-unwrap sweep, and complexity ratchets)
Classification: Sovereign


🎯 Executive Summary ​

What is AI-Tadpole-OS?
AI-Tadpole-OS is a high-performance, local-first runtime for sovereign multi-agent swarms operating across a Dual-Plane Sovereign Hierarchy (directives/IDENTITY.md):

  1. Plane 1 — Sovereign Codebase Lifecycle Engine (Engine-Maintenance): Knows, operates, fixes, maintains, and improves the AI-Tadpole-OS codebase itself over time (server-rs/, src/, execution/, ADG v2, Agent 99).
  2. Plane 2 — Company-Agnostic SMB AI Digital Twin (SMB-Digital-Twin, planned): Intended business runtime for company workflows and isolated practice workspaces. Company-scoped execution and full FR-11 enforcement remain pending; use synthetic data and stop at preview.

The generic runner's fail-closed check recognizes only the exact stored department Plane 2: SMB-Digital-Twin (case-insensitive); other labels do not activate it.

The current engine enables orchestration of recursive Plane 1 workflows with cost controls and human oversight. Company-scoped Plane 2 workflows are not available yet.

Why was it built this way?
The architecture is rooted in the philosophy of Sovereign Intelligence. Unlike cloud-locked agent frameworks, AI-Tadpole-OS prioritizes resilience and observability. By utilizing a "Gateway-Runner-Registry" pattern in Rust, the system ensures memory safety, sub-millisecond telemetry, and verifiable auditability using cryptographic Merkle trails and Write-Ahead Logging (WAL).

What is new in the current iteration?

  • Codebase-Wide Clean Code, Zero-Unwrap Sweep & Complexity Ratchets (2026-11): Eliminated all 53 production runtime .unwrap() calls across 17 files in server-rs/src/ replacing them with fail-safe error propagation. Decomposed Rust engine hotspots into single-responsibility submodules (agent/outward/customer_catalog/, bin/graph_query/doc_guard/, agent/business/service/, agent/runner/intelligence/). Modularized frontend stores and services (vault_store.ts, settings_store.ts, useStandups.ts, agent_service.ts, system_api_service.ts). Decomposed Python infrastructure tooling into execution/lib/ (parity_router.py, parity_validators.py, ai_context_parser.py, ai_context_resolver.py). Established repository clean code CI ratchets (npm run lint:clean, npm run lint:clean:diff, npm run lint:complexity) enforcing line length, cyclomatic complexity ($\le 15$), nesting depth ($\le 4$), and parameter bundling.
  • Codebase Simplification & Engine Hardening (2026-11): Decomposed frontend monoliths (Cluster_Sidebar into Cluster_Create_Drawer & Cluster_Card, Action_Ledger with portaled Params_Cell, AgentConfigPanel with useAgentConfig, Swarm_Visualizer with useSwarmTelemetry). Standardized Plane 1 worktree sandboxing (execution/plane1_worktree.py), background actor reaper (agent/reaper.rs), model-aware context manager (agent/context_manager.rs), unified Store MCP Blueprints tab (/store?tab=mcp), and linearized the 5-stage continuity executor loop.
  • macOS Universal Desktop Distribution: Universal 2 .dmg targets aarch64-apple-darwin and x86_64-apple-darwin. The shared local/CI helper stages target-specific sidecars for Tauri compilation and a universal engine for bundling, then requires both slices and valid signatures in the resulting app. data_dir.rs prepares Application Support state before sidecar launch. Native validation status is tracked in the macOS blueprint.
  • Modular MCP Subsystem & 2026-07-28 Streamable HTTP: Decomposed MCP host and transports into dedicated leaf modules (authz, config, host, native, types, client/); implemented official stable MCP 2026-07-28 Streamable HTTP client with SSE stream parsing and adaptive stdio backward compatibility.
  • Outward A2A Gateway & Customer Knowledge Catalog: Zero-trust public gateway (/a2a/v1) with rate-limited agent card publishing, RFC 4180 CSV / QuickBooks imports, and real-time PII sanitization.
  • Decomposed Template Store & Transactional FS: Specialized submodules (catalog, source, naming, validate, mcp_store, installed) with atomic OpenOptions::create_new(true) filesystem staging and LIFO rollback.
  • Hierarchical Role-Based Access Control (RBAC): Fine-grained agent-specific and role-based policies resolved hierarchically.
  • Cryptographic Human-in-the-Loop (HITL) Oversight: Digital Ed25519 signatures validating human actions on REST and WS channels.
  • Dynamic Provider Failover & Hot-Swapping: Smart model hot-swapping to cloud/local backups when primary LLMs rate limit or go offline.
  • Distributed Tracing (OTel): Request correlation via X-Request-Id trace ID propagation across asynchronous boundaries.
  • RFC 9457 UI Remediation: Unified application/problem+json error mapping coupled with interactive self-healing dashboard guidance.
  • Zero-Trust Tooling: Transitioned from monolithic execution to a trait-based, decoupled tool architecture.
  • Capability-Based Security (CBS): Replaced ambient authority with non-forgeable permission tokens.
  • Mandatory WAL: Integrated Write-Ahead Logging to persist tool intent before execution (SEC-04).
  • Safe Command Lexer: Whitelist-based shell validation to prevent injection and substitution attacks.
  • Active Documentation Guard (ADG): Symbol graph validates Rustdoc/JSDoc backtick references against live code. graph_query validate --fix auto-corrects drift via Jaro-Winkler similarity. --diff mode restricts scanning to git-modified files for fast pre-commit enforcement.
  • Tauri IPC Boundary Validation: Parser emits tauri_ipc: synthetic symbols for #[tauri::command] functions and matching invoke() calls, enabling cross-language drift detection via the symbol graph.
  • graph_query Modular CLI: The intelligence CLI was decomposed from a monolithic file into 5 single-responsibility modules (main.rs, path_utils.rs, visualizer.rs, query_manager.rs, doc_guard.rs). Blast radius exports now support --format mermaid|html, and route-parity verifies Axum router.rs AST parity against docs/openapi.yaml via syn.
  • Rust CAS Aligned Diff & Server-Side LPA Clustering: services/cas.rs computes prefix/suffix-trimmed LCS side-by-side diffs (GET /v1/cas/diff and mission dossier aligned_lines), intelligence/graph/synthesis.rs precomputes deterministic Label Propagation (community) clusters on the server, and ProviderConfig zeroes in-memory API keys on drop via zeroize.

🛰️ Core System Topology ​

The following diagram illustrates the macro-structure of the Tadpole OS lifecycle, from the frontend dashboard to the sandboxed execution environment.

mermaid
graph TD
    subgraph "Sovereign Layer (Frontend)"
        Dashboard["Ops_Dashboard (React 19)"]
        Registry["Agent_Store (Zustand)"]
        Vault["Neural_Vault (SubtleCrypto)"]
        Visualizer["Swarm_Visualizer (Detachable)"]
    end

    subgraph "Intelligence Layer (Backend)"
        Axum["Axum Gateway (0.8)"]
        State["AppState (state/mod.rs hubs)"]
        Runner["Agent_Runner (runner/mod.rs)"]
        Tools["Zero-Trust_Tools (tools/mod.rs)"]
        CBS["CBS_Guard (capability.rs)"]
        Audit["Audit_Trail (WAL / Merkle)"]
    end

    subgraph "Persistence & Nodes"
        SQLite[("tadpole.db (sqlx)")]
        Bunker["Bunker Nodes (mDNS)"]
        Files["Workspace_FS (SafePath)"]
    end

    Dashboard -- "WS/REST" --> Axum
    Axum --> State
    State --> Runner
    Runner --> Tools
    Tools --> CBS
    Tools --> Audit
    Audit --> SQLite
    Tools -- "I/O" --> Files

🏗️ The "Gateway-Runner-Registry" Pattern ​

Tadpole OS operates as a distributed state machine:

  1. Registry: Manages the persistent identities and capabilities of agents and providers.
  2. Gateway: Provides the high-concurrency Axum-based interface for the dashboard and external adapters.
  3. Runner: A stateful execution loop that manages the mission lifecycle, recruitment of specialists, and integration of findings.
  4. Security Hub: Enforces CBS and WAL policies across all tool interactions.

📄 Documentation Suite ​

To maintain high navigability, the architecture is decomposed into focused modules:


🤖 Context for AI Assistants ​

  1. State Ownership: The Rust engine is the primary source of truth for agent configurations.
  2. Tool Protocol: All agent tools must implement the Tool trait and return a ToolExecutionError on failure.
  3. Sovereignty: Enforce the Zero-Trust pipeline for all tool interactions.

Sovereign Intelligence Architecture.