Skip to content

πŸ“Š 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:

ModuleCore ResponsibilityPrimary Dependencies
core.identityAbsolute zero-trust verification of current GCP/Mongo environments.Independent (reads os.environ settings).
orchestrator.engineDrives the 11-step pipeline from memory reload to audit logging.debate, execution, validation, memory, core.identity.
debate.roundsCoordinates structured adversarial arguments across multiple passes.agents.factory, debate.aggregator, memory.database.
memory.databaseSQLite storage for localized past decisions, traces, and reputation.core.types, sqlite3.
memory.mongodb_atlasHigh-performance vector retrieval and distributed cloud tracing.pymongo.MongoClient.
execution.managerStepwise execution of approved proposals with automatic rollback logic.execution.runner.
security.token_budgetProtects 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:

  1. No Token Runaways: The TokenBudgetTracker monitors all Gemini API generate requests. If the current thread exceeds 100,000 tokens, further executions are immediately aborted.
  2. Execution Admission Controls: Before executing shell operations or CLI commands, ExecutionRunner in [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.
  3. Determinstic Audits: All transactions are logged using persistent trace_id mappings, permitting security teams to completely reconstruct any multi-agent debate history for inspection.

IzgraΔ‘eno sa Nultim Poverenjem i Adversarial Poravnanjem.