Files
stack/apps/orchestrator
Jason Woltje 22dc964503
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/pr/woodpecker Pipeline failed
feat(#329): Add usage budget management and cost governance
Implement BudgetService for tracking and enforcing agent usage limits:
- Daily token limit tracking (default 10M tokens)
- Per-agent token limit enforcement (default 2M tokens)
- Maximum concurrent agent cap (default 10)
- Task duration limits (default 120 minutes)
- Hard/soft limit enforcement modes
- Real-time usage summaries with budget status
  (within_budget/approaching_limit/at_limit/exceeded)
- Per-agent usage breakdown with percentage calculations

Includes BudgetModule for NestJS DI and 23 unit tests.

Fixes #329

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 13:00:26 -06:00
..

Mosaic Orchestrator

Agent orchestration service for Mosaic Stack built with NestJS.

Overview

The Orchestrator is the execution plane of Mosaic Stack, responsible for:

  • Spawning and managing Claude agents
  • Task queue management (Valkey-backed)
  • Agent health monitoring and recovery
  • Git workflow automation
  • Quality gate enforcement callbacks
  • Killswitch emergency stop

Architecture

Part of the Mosaic Stack monorepo at apps/orchestrator/.

Controlled by apps/coordinator/ (Quality Coordinator). Monitored via apps/web/ (Agent Dashboard).

Development

# Install dependencies (from monorepo root)
pnpm install

# Run in dev mode (watch mode)
pnpm --filter @mosaic/orchestrator dev

# Build
pnpm --filter @mosaic/orchestrator build

# Start production
pnpm --filter @mosaic/orchestrator start:prod

# Test
pnpm --filter @mosaic/orchestrator test

# Generate module (NestJS CLI)
cd apps/orchestrator
nest generate module <name>
nest generate controller <name>
nest generate service <name>

NestJS Architecture

  • Modules: Feature-based organization (spawner, queue, monitor, etc.)
  • Controllers: HTTP endpoints (health, agents, tasks)
  • Services: Business logic
  • Providers: Dependency injection

Configuration

Environment variables loaded via @nestjs/config. See .env.example for required vars.

Documentation

  • Architecture: /docs/ORCHESTRATOR-MONOREPO-SETUP.md
  • API Contracts: /docs/M6-ISSUE-AUDIT.md
  • Milestone: M6-AgentOrchestration (0.0.6)