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):
- Plane 1 — Sovereign Codebase Lifecycle Engine (
Engine-Maintenance): Knows, operates, fixes, maintains, and improves theAI-Tadpole-OScodebase itself over time (server-rs/,src/,execution/,ADG v2,Agent 99). - 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 fullFR-11enforcement 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 inserver-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 intoexecution/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_SidebarintoCluster_Create_Drawer&Cluster_Card,Action_Ledgerwith portaledParams_Cell,AgentConfigPanelwithuseAgentConfig,Swarm_VisualizerwithuseSwarmTelemetry). 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
.dmgtargetsaarch64-apple-darwinandx86_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.rsprepares 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 MCP2026-07-28Streamable 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 atomicOpenOptions::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-Idtrace ID propagation across asynchronous boundaries. - RFC 9457 UI Remediation: Unified
application/problem+jsonerror 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 --fixauto-corrects drift via Jaro-Winkler similarity.--diffmode 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 matchinginvoke()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, androute-parityverifies Axumrouter.rsAST parity againstdocs/openapi.yamlviasyn. - Rust CAS Aligned Diff & Server-Side LPA Clustering:
services/cas.rscomputes prefix/suffix-trimmed LCS side-by-side diffs (GET /v1/cas/diffand mission dossieraligned_lines),intelligence/graph/synthesis.rsprecomputes deterministic Label Propagation (community) clusters on the server, andProviderConfigzeroes in-memory API keys on drop viazeroize.
🛰️ Core System Topology
The following diagram illustrates the macro-structure of the Tadpole OS lifecycle, from the frontend dashboard to the sandboxed execution environment.
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:
- Registry: Manages the persistent identities and capabilities of agents and providers.
- Gateway: Provides the high-concurrency Axum-based interface for the dashboard and external adapters.
- Runner: A stateful execution loop that manages the mission lifecycle, recruitment of specialists, and integration of findings.
- Security Hub: Enforces CBS and WAL policies across all tool interactions.
📄 Documentation Suite
To maintain high navigability, the architecture is decomposed into focused modules:
- 🛡️ Security Model: Policies, CBS, WAL, and Encryption.
- 🤖 Agent Runner Workflow: Execution lifecycles and Swarm Protocols.
- 🧠 Knowledge & Memory: Hybrid RAG, LanceDB, and Ingestion.
- ⚛️ State Management: Zustand stores, Portals, and React 19.
🤖 Context for AI Assistants
- State Ownership: The Rust engine is the primary source of truth for agent configurations.
- Tool Protocol: All agent tools must implement the
Tooltrait and return aToolExecutionErroron failure. - Sovereignty: Enforce the Zero-Trust pipeline for all tool interactions.
