Foundry V2 is a parallel, safety-first industrial control plane. It enforces strict role separation: no module may cross responsibilities.
Where the human injects initial goals, tasks, and issues HALT / RESUME commands. Also available via the UI Dashboard. (src/infrastructure/tooling/project-cli/cli.ts)
src/infrastructure/tooling/project-cli/cli.ts
The brain. In V2, the monolithic control loop splits into two components:
src/application/services/scheduler/index.ts
src/application/workers/workerPool.ts
Constructs task prompts and dispatches them to external Agents/Providers (Gemini, Copilot, Cursor, Claude). Provider selection via ProviderStrategy with circuit breaker and automatic fallback. (src/domain/agents/promptBuilder.ts, src/infrastructure/connectors/agents/providers/*)
src/domain/agents/promptBuilder.ts
src/infrastructure/connectors/agents/providers/*
Uses DragonflyDB (Redis-compatible) for read/write. State is fully overwritten on every loop, making crash recovery seamless. (src/application/services/persistence.ts)
src/application/services/persistence.ts
V2 replaces the single FIFO queue with a dual-queue system:
Fast, non-AI pre-checks. Uses regex, semver, and safety caps (file size, byte limits). If confidence is high, it skips expensive AI validation entirely. (src/application/services/validator.ts)
src/application/services/validator.ts
A deterministic middleware between agents and tool execution. Includes command sanitization (blocks destructive operations like rm -rf, dd), path confinement (enforces sandbox boundaries), and read-only command whitelisting.
rm -rf
dd
Only invoked on validation gaps. Helper sessions are isolated per project to save context tokens.
Two adapters per strategy: primary (TaskExecutor, GoalChecker, Retry) and secondary (Validation helpers). Each ProviderEntry carries { provider, agentMode }. Three built-in strategies:
ProviderEntry
{ provider, agentMode }
Custom strategies can be created via the UI Settings page. Circuit breaker + automatic fallback per adapter independently.