π Codebase Analysis & System Footprint β
This document provides a comprehensive architectural and structural audit of the AI Workflow Orchestrator repository.
The entire system is designed as a modular Python monorepo with strictly separated layers of responsibility, emphasizing zero-trust security and persistent execution auditability.
π Directory Structure (System Footprint) β
The diagram below represents the repository's directory structure and the core purpose of each component:
ai-workflow-orchestrator/
βββ main.py # CLI entry point (enforce_identity + WorkflowOrchestrator run)
βββ requirements.txt # External dependencies (FastAPI, google-genai, pymongo, sqlite3)
βββ prd.md # Product Requirements Document
βββ SUBMISSION.md # Rapid Agent Hackathon Submission Package
β
βββ core/ # Shared core types and security utilities
β βββ types.py # Shared Enums: AgentRole, AgentMode, DebateOutcome, Argument
β βββ identity.py # IdentityGuard (Zero-trust verify for sixth-hawk-492717-m1)
β βββ key_manager.py # KeyManager for API key rotation & failover
β
βββ orchestrator/ # Central Orchestration Engine
β βββ engine.py # WorkflowOrchestrator (11-step execution pipeline)
β βββ router.py # ModelRouter for Vertex AI / Gemini models (gemini-2.5-flash)
β
βββ debate/ # Multi-Agent Debate Arena (Adversarial Layer)
β βββ rounds.py # DebateManager (Round logic, Rule-of-3 refinement loops)
β βββ aggregator.py # DebateAggregator (Consensus, conflict points, ELO updates)
β
βββ agents/ # Specialized agent entities
β βββ base_agent.py # BaseAgent (supports EXECUTION and DEBATE modes)
β βββ factory.py # AgentFactory (dynamic runtime instantiation)
β βββ [specialized].py # Analyst, Solution, Critic, Security, Optimizer, Aggregator agents
β
βββ memory/ # Multi-tier memory layer (SQLite & MongoDB Atlas)
β βββ database.py # Database (SQLite perzistencija, decision history, ELO rankings)
β βββ mongodb_atlas.py # MongoDB Atlas (Vector search conflicts & global trace logs)
β
βββ execution/ # Secure execution sandbox
β βββ manager.py # ExecutionManager (coordinated steps & reverse-rollback)
β βββ runner.py # ExecutionRunner (sandboxed CLI / database command execution)
β
βββ validation/ # Post-execution verification layer
β βββ checker.py # ValidationChecker (assert outcome results & build verification reports)
β
βββ security/ # System hardening
β βββ token_budget.py # TokenBudgetTracker & Middleware (100k token session circuit breaker)
β
βββ observability/ # Monitoring and reliability
β βββ self_heal_hook.py # Autonomously intercept & repair execution failures at system level
β
βββ api/ # FastAPI HTTP Server Layer
β βββ routes.py # Endpoint routing (triggering workflow, memory vector retrieval)
β βββ status_manager.py # JobStatusManager (streaming real-time pipeline events via SSE)
β
βββ dashboard/ # Frontend User Interface
β βββ index.html # Rich Glassmorphism Web Dashboard (Tailwind + CSS animations)
β
βββ tests/ # Verification test suite (PyTest)
βββ test_agents.py # Verification of LLM models generating valid agent outputs
βββ test_elo.py # Elo simulation and score updates during agent arguments
βββ test_circuit_breaker.py # Assert session termination on budget boundariesβοΈ Core Modules and Dependencies β
The orchestration pipeline strictly ensures unidirectional data transfers to prevent circular dependency problems:
| Module | Core Responsibility | Primary Dependencies |
|---|---|---|
core.identity | Absolute zero-trust verification of current GCP/Mongo environments. | Independent (reads os.environ settings). |
orchestrator.engine | Drives the 11-step pipeline from memory reload to audit logging. | debate, execution, validation, memory, core.identity. |
debate.rounds | Coordinates structured adversarial arguments across multiple passes. | agents.factory, debate.aggregator, memory.database. |
memory.database | SQLite storage for localized past decisions, traces, and reputation. | core.types, sqlite3. |
memory.mongodb_atlas | High-performance vector retrieval and distributed cloud tracing. | pymongo.MongoClient. |
execution.manager | Stepwise execution of approved proposals with automatic rollback logic. | execution.runner. |
security.token_budget | Protects API limits by halting runaway agent debate cycles. | Singleton pattern shared across the pipeline session. |
π Codebase Security Hardening β
To ensure production-grade safety, the code complies with key security policies:
- No Token Runaways: The
TokenBudgetTrackermonitors all Gemini API generate requests. If the current thread exceeds100,000tokens, further executions are immediately aborted. - Execution Admission Controls: Before executing shell operations or CLI commands,
ExecutionRunnerin [runner.py:30-56](file:///home/kizabgd/.gemini/extensions/ai-workflow-orchestrator/execution/runner.py#L30-L56) enforces structural checks that actively reject SQL Injections, hostPath volumes, Docker socket mounting, and unauthorized root logins. - Determinstic Audits: All transactions are logged using persistent
trace_idmappings, permitting security teams to completely reconstruct any multi-agent debate history for inspection.