How wp113department-cell/multi-agent-company works
Purpose and Entry Points
Gridiron is an autonomous multi-agent software-engineering platform: it accepts repository-scoped goals, plans and decomposes work, dispatches specialist agents, enforces safety/approval gates, and returns verified artifacts. The service entry point is FastAPI at backend/app/main.py; the operator UI is a Next.js App Router app rooted at apps/web/app/layout.tsx and apps/web/app/page.tsx. HTTP APIs are organized under backend/app/api/.
Client and API Boundary
The TypeScript frontend provides task, fleet, approval, repository, chat, metrics, and review consoles. It calls the backend through the API client and protects browser routes via its auth/middleware layer.
• apps/web/lib/api.ts
• apps/web/middleware.ts
• apps/web/app/tasks/[id]/page.tsx
Backend routers expose the corresponding control-plane resources: tasks, goals/epics, agent fleet, approvals, streaming chat, artifacts, settings, and repository management.
• backend/app/api/tasks.py
• backend/app/api/specialized_agents.py
• backend/app/api/chat.py
Orchestration Pipeline
The central execution flow is a stateful graph: input task → bootstrap/context → planning stages (PM, architect, decomposer) → dependency-aware dispatch → manager-led implementation, QA, and review. Pipeline state, concurrency, conflict checks, cost control, and queue abstraction isolate orchestration policy from individual agents.
• backend/app/pipeline/graph.py
• backend/app/pipeline/dispatcher.py
• backend/app/pipeline/state.py
Agents share base/graph contracts; individual roles are implemented in Python and paired with role prompt documents. This supports both core pipeline agents and directly invokable specialists.
• backend/app/agents/base.py
• backend/app/agents/base_graph.py
• backend/roles/manager.md
Fleet Governance and Execution Controls
The fleet layer selects capable agents/models, tracks budgets, checkpoints, metrics, events, audit records, failures, and approval requirements. It is the control boundary around execution rather than merely an agent catalog.
• backend/app/fleet/fleet_manager.py
• backend/app/fleet/agent_registry.py
• backend/app/fleet/approval_gate.py
Model providers are routed through the fleet, with Anthropic expected by default and Groq compatibility present.
• backend/app/fleet/model_router.py
• backend/app/agents/groq_adapter.py
Repository Intelligence, Worktrees, and Safety
Agents inspect and modify target repositories through repository tools: scanning/AST and cross-file analysis build context; git worktrees isolate changes. Policy engines and sandboxing guard commands and file mutations; RBAC and encrypted credential storage enforce access boundaries.
• backend/app/repo_tools/context_builder.py
• backend/app/repo_tools/worktree.py
• backend/app/policy/engine_v2.py
• backend/app/policy/sandbox.py
• backend/app/security/credential_vault.py
Destructive operations and publish-like actions are routed through approval gates rather than trusted model decisions.
Persistence, Memory, and Eventing
PostgreSQL is the primary durable store, managed with SQLAlchemy-style models/repositories and Alembic migrations. Project-scoped engineering memory supports retrieval, lifecycle/analytics, and embeddings. Artifacts abstract database versus S3 storage. Runtime activity is emitted through an in-process/Redis Streams event bus; execution can use asyncio or RQ/Redis queues.
• backend/app/db/models.py
• backend/app/memory/store.py
• backend/app/event_bus/bus.py
• backend/app/event_bus/redis_streams.py
• backend/app/artifacts/s3_store.py
Runtime and Infrastructure
Backend requires Python 3.11+, FastAPI, PostgreSQL 16 with pgvector, and Docker for isolated high-risk command execution. Redis is optional for RQ and Redis Streams; S3 is optional for artifacts; Voyage AI may supply embeddings; Sentry and alert webhooks are optional observability integrations. The frontend runs on Node 20+ / pnpm and is deployable separately; Docker Compose coordinates local dependencies.
• backend/Dockerfile
• apps/web/Dockerfile
• docker-compose.yml
• backend/migrations/versions/001_initial_schema.py
Main entry points: fleet_manager.py Fleet manager · tasks.py Control-plane routers · graph.py Execution graph · approval_gate.py Approval gate
Components 18
Operator Client
- Next.js operator UI · Task, fleet, approval, repository, chat, metrics, and review consoles.
apps/web/app/layout.tsx - Route auth middleware
apps/web/middleware.ts - Backend API client
apps/web/lib/api.ts
Control Plane
- FastAPI service
backend/app/main.py - Control-plane routers · Tasks, agents, approvals, chat, artifacts, settings, and repositories.
backend/app/api/tasks.py
Agent Execution
- Execution graph · Bootstraps context, plans work, dispatches dependencies, and coordinates implementation through review.
backend/app/pipeline/graph.py - Dependency dispatcher · Applies concurrency, conflict, cost, and queue controls.
backend/app/pipeline/dispatcher.py - Agent contracts & roles · Shared base and graph contracts support core and directly invoked specialists.
backend/app/agents/base_graph.py - Fleet manager · Selects agents and models while tracking budgets, checkpoints, events, failures, and audit records.
backend/app/fleet/fleet_manager.py - Model router · Routes fleet inference to Anthropic by default with Groq compatibility.
backend/app/fleet/model_router.py
Safety & Repository Access
- Approval gate · Requires operator approval for destructive or publish-like actions.
backend/app/fleet/approval_gate.py - Repository context builder · Builds scan, AST, and cross-file context for agents.
backend/app/repo_tools/context_builder.py - Git worktrees · Isolates agent modifications in target repositories.
backend/app/repo_tools/worktree.py - Policy sandbox · Guards commands and file mutations.
backend/app/policy/sandbox.py
State & Runtime Services
- PostgreSQL + pgvector · Stores SQLAlchemy-managed operational data and migrations.
backend/app/db/models.py - Engineering memory · Project-scoped memory supports retrieval, lifecycle analytics, and embeddings.
backend/app/memory/store.py - Event bus · In-process bus with Redis Streams runtime option.
backend/app/event_bus/bus.py - Artifact storage · Abstracts durable database or S3-backed artifacts.
backend/app/artifacts/s3_store.py
Connections 22
- Next.js operator UI → Route auth middleware: protects routes
- Next.js operator UI → Backend API client: uses
- Backend API client → FastAPI service: HTTP
- FastAPI service → Control-plane routers: mounts
- Control-plane routers → Execution graph: submits tasks
- Control-plane routers → Fleet manager: manages fleet
- Control-plane routers → Approval gate: approval actions
- Execution graph → Dependency dispatcher: dispatches stages
- Execution graph → Repository context builder: builds context
- Dependency dispatcher → Fleet manager: requests execution
- Fleet manager → Agent contracts & roles: runs roles
- Fleet manager → Model router: selects provider
- Fleet manager → Approval gate: gates actions
- Agent contracts & roles → Git worktrees: modifies in isolation
- Git worktrees → Policy sandbox: operations checked by
- Approval gate → Policy sandbox: authorizes restricted actions
- Execution graph → PostgreSQL + pgvector: persists state
- Fleet manager → PostgreSQL + pgvector: records control data
- Repository context builder → Engineering memory: retrieves project knowledge
- Fleet manager → Event bus: emits activity
- Execution graph → Artifact storage: produces verified artifacts
- Control-plane routers → Event bus: streams chat/activity