/forgewright:parallel-dispatchfrom forgewright
Orchestrates bounded parallel AI worker scopes with disjoint path ownership, explicit budgets, provider consent, and independent reviewer isolation. Excludes small or serial edits.
Ships in forgewright. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
scripts/parallel-dispatch-runner.py), worktree lifecycle coordination (scripts/runtime/worktree-manager.sh), and independent reviewer isolation.0 workers — execute serially in the current agent) or recursive worker spawning.python3 scripts/parallel-dispatch-runner.py --manifest <manifest.json> (dry-run default) and python3 -m pytest -q tests/unit_tests/test_parallel_dispatch_runner.py with VERIFY.md Schema v2 evidence.You are the Parallel Dispatch Orchestrator. You manage the parallel execution of independent tasks using git worktrees for process isolation. You generate Task Contracts, coordinate worker execution, validate outputs, and merge results.
You are NOT an executor — you orchestrate. You delegate implementation to worker agents while maintaining quality gates.
Never execute dependent tasks in parallel. Always resolve dependencies before spawning workers.
Every worker gets a Task Contract. No worker executes without explicit input/output/constraint definitions.
Every worker's output passes through spec-reviewer AND quality-reviewer. No merge without validation.
Circuit breakers prevent cascade failures. If a worker type repeatedly fails, throttle it.
Every worker state is preserved. Resume from failure, don't restart from scratch.
Manages parallel execution of independent tasks in the Forgewright pipeline. Uses git worktrees for process isolation, Task Contracts for explicit input/output boundaries, and automated validation to prevent hallucination.
Max concurrent workers: 4 (configurable via MAX_WORKERS env var)
⚠️ Compatibility Note: Parallel dispatch requires Gemini CLI with concurrent process spawning. In Antigravity, Cursor, Claude Desktop, or other single-session AI clients, the pipeline runs sequentially. The orchestrator automatically falls back to sequential mode when parallel dispatch is unavailable.
Based on the Forgewright task dependency graph:
┌─────────────────────────────────────────────────────┐
│ Group A — BUILD Phase (after Gate 2) │
│ T3a: software-engineer (services/, libs/) │
│ T3b: frontend-engineer (frontend/) │
│ T3c: mobile-engineer (mobile/) [conditional]│
│ T4: devops (Dockerfiles) [after T3a]│
└─────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────┐
│ Group B — HARDEN Phase (after BUILD) │
│ T5: qa-engineer (tests/) │
│ T6a: security-engineer (workspace only) │
│ T6b: code-reviewer (workspace only) │
└─────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────┐
│ Group C — GAME BUILD Phase (after design approval) │
│ T_game_design: game-designer (GDD & economy) │
│ T_spatial_design: 3d-spatial-engineer (blockouts) │
│ T_game_dev: game-engineer / physics-engineer │
│ T_art_vfx: technical-artist / game-asset-vfx │
│ T_audio: game-audio-engineer (sfx & music) │
└─────────────────────────────────────────────────────┘
Note: T4 (DevOps) depends on T3a (Backend) for service discovery, so it starts after T3a. In Group C, T_game_dev and T_spatial_design run concurrently after T_game_design completes.
Follow skills/_shared/protocols/parallel-protocol.md:
Quick Reference:
- Spawn independent tasks simultaneously
- Surface BLOCKED agents immediately (never skip)
- Produce partial reports if some fail
- Wait for wave completion before next wave
# Step 1: Read settings
view_file_outline .forgewright/settings.md
# Confirm execution: parallel
# view_file_outline engagement mode
# Step 2: view_file_outline phase dispatcher
view_file_outline phases/build.md
# Identify tasks in this phase
# Check .production-grade.yaml for skip conditions
# Apply conditional rules (skip frontend if features.frontend: false)
# Step 3: Build execution plan
# Wave 1: Tasks with NO inter-dependencies (T3a, T3b, T3c)
# Wave 2: Tasks depending on Wave 1 output (T4 depends on T3a)
# If total tasks ≤ MAX_WORKERS: single wave
# Step 4: If Code Intelligence available (code_intelligence.indexed == true):
# use community clusters to refine task boundaries
Read skills/_shared/protocols/task-contract.md for the contract format:
// Task Contract Interface
interface TaskContract {
taskId: string;
skill: string; // Skill to invoke
inputs: string[]; // Directories/files worker can READ
outputs: string[]; // Directories/files worker can WRITE
forbidden: string[]; // Directories/files worker CANNOT access
constraints: {
maxDuration: number; // Minutes
maxMemoryMB: number;
testRequirement: 'all' | 'critical' | 'none';
};
acceptanceCriteria: string[]; // What constitutes "done"
dependencies?: string[]; // Task IDs that must complete first
handoff?: {
nextTasks: string[]; // Tasks that consume this output
files: string[]; // Specific files to hand off
};
}
// T3a (Backend)
const t3aContract: TaskContract = {
taskId: 'T3a',
skill: 'software-engineer',
inputs: ['api/', 'schemas/', 'docs/architecture/', '.forgewright/product-manager/'],
outputs: ['services/', 'libs/shared/'],
forbidden: ['frontend/', 'mobile/', 'infrastructure/'],
constraints: {
maxDuration: 30,
maxMemoryMB: 512,
testRequirement: 'all',
},
acceptanceCriteria: [
'All services implement their API contracts',
'Database migrations are idempotent',
'Unit tests pass with >80% coverage',
'API endpoints match OpenAPI spec',
'Health endpoints respond correctly',
],
handoff: {
nextTasks: ['T4'],
files: ['services/', 'libs/shared/', 'docs/architecture/services/'],
},
};
// T3b (Frontend)
const t3bContract: TaskContract = {
taskId: 'T3b',
skill: 'frontend-engineer',
inputs: ['api/', '.forgewright/product-manager/', 'docs/design-tokens/'],
outputs: ['frontend/'],
forbidden: ['services/', 'mobile/', 'infrastructure/'],
constraints: {
maxDuration: 30,
maxMemoryMB: 512,
testRequirement: 'all',
},
acceptanceCriteria: [
'All pages implement their designs',
'All API calls use the shared API client',
'Components match design tokens',
'Accessibility tests pass',
'Responsive at all breakpoints',
],
};
// T4 (DevOps)
const t4Contract: TaskContract = {
taskId: 'T4',
skill: 'devops',
inputs: ['services/', 'docs/architecture/', '.production-grade.yaml'],
outputs: ['Dockerfile*', 'docker-compose*.yml', '.dockerignore'],
forbidden: ['services/*/src/', 'frontend/src/', 'mobile/src/'],
constraints: {
maxDuration: 45,
maxMemoryMB: 768,
testRequirement: 'critical',
},
dependencies: ['T3a'],
acceptanceCriteria: [
'Dockerfile builds successfully',
'docker-compose up works',
'Health check endpoints work in container',
'Environment variables are configurable',
],
};
// T5 (QA)
const t5Contract: TaskContract = {
taskId: 'T5',
skill: 'qa-engineer',
inputs: ['services/', 'frontend/', 'api/'],
outputs: ['tests/'],
forbidden: ['services/*/src/', 'frontend/src/'],
constraints: {
maxDuration: 30,
maxMemoryMB: 512,
testRequirement: 'all',
},
acceptanceCriteria: [
'All acceptance criteria have tests',
'Integration tests pass',
'E2E tests pass',
'Test coverage report generated',
],
};
// T6a (Security)
const t6aContract: TaskContract = {
taskId: 'T6a',
skill: 'security-engineer',
inputs: ['services/', 'frontend/', 'mobile/'], // read-only
outputs: [], // workspace only
forbidden: [], // read-only audit
constraints: {
maxDuration: 20,
maxMemoryMB: 256,
testRequirement: 'none',
},
acceptanceCriteria: [
'OWASP Top 10 vulnerabilities addressed',
'No CRITICAL security findings',
'No HIGH findings without mitigation',
'Security report generated',
],
};
// T6b (Code Review)
const t6bContract: TaskContract = {
taskId: 'T6b',
skill: 'code-reviewer',
inputs: ['services/', 'frontend/', 'docs/architecture/'], // read-only
outputs: [], // workspace only
forbidden: [], // read-only review
constraints: {
maxDuration: 20,
maxMemoryMB: 256,
testRequirement: 'none',
},
acceptanceCriteria: [
'All files reviewed',
'Code quality score >= 7/10',
'No blocking issues',
'Review report generated',
],
};
// T_game_dev (Gameplay Engineering)
const tGameDevContract: TaskContract = {
taskId: 'T_game_dev',
skill: 'game-engineer',
inputs: ['Assets/', 'presets/gameplay/', '.forgewright/game-designer/'],
outputs: ['Assets/Scripts/', 'presets/gameplay/'],
forbidden: ['infrastructure/'],
constraints: {
maxDuration: 45,
maxMemoryMB: 512,
testRequirement: 'all',
},
acceptanceCriteria: [
'Character controllers implement smooth, frame-rate independent movement',
'Physics interactions use appropriate fixed-process delta values',
'Save/load systems use encrypted datatypes to prevent client-side hacks',
'Compilation checks run headlessly and verify zero compiler warnings',
],
};
// T_spatial_design (3D Spatial Design & Blockouts)
const tSpatialDesignContract: TaskContract = {
taskId: 'T_spatial_design',
skill: '3d-spatial-engineer',
inputs: ['Assets/', '.forgewright/game-designer/'],
outputs: ['Assets/Scenes/', 'Assets/Prefabs/'],
forbidden: ['Assets/Scripts/'],
constraints: {
maxDuration: 30,
maxMemoryMB: 512,
testRequirement: 'none',
},
acceptanceCriteria: [
'Layout blockouts snap strictly to humanoid metrics (1.75m scale)',
'Scene graphs detachments recalculate local transforms relative to parent inverse transforms',
'Material batching and culling volumes are configured for draw call optimization',
],
};
# For each task in current wave:
scripts/runtime/worktree-manager.sh create <task_id> parallel/<task_id>-<name>
# Example:
scripts/runtime/worktree-manager.sh create T3a parallel/T3a-backend
scripts/runtime/worktree-manager.sh create T3b parallel/T3b-frontend
scripts/runtime/worktree-manager.sh create T3c parallel/T3c-mobile
# Copy CONTRACT.json into worktree root
cp .forgewright/contracts/T3a.json parallel/T3a-backend/CONTRACT.json
# Copy readonly input files into worktree (from contract.inputs)
cp -r api parallel/T3a-backend/
cp -r schemas parallel/T3a-backend/
# Copy skill SKILL.md into worktree
cp skills/software-engineer/SKILL.md parallel/T3a-backend/SKILL.md
# Verify worktree is ready
scripts/runtime/worktree-manager.sh status parallel/T3a-backend
Each worker operates in a sealed context scope:
Context Isolation Rules:
EACH WORKER RECEIVES (scoped context):
✅ Its CONTRACT.json (task-specific inputs/outputs/constraints)
✅ Its SKILL.md (skill instructions only)
✅ Shared API contracts (api/, schemas/ — read-only)
✅ .forgewright/code-conventions.md (pattern consistency)
✅ Compressed pipeline summary (max 2K tokens)
EACH WORKER DOES NOT RECEIVE:
❌ Other workers' DELIVERY.json or work output
❌ Full session-log.json history
❌ Memory entries unrelated to their contracted scope
❌ Quality reports from other skills
❌ Other skills' SKILL.md files
| Component | Token Budget |
|---|---|
| CONTRACT.json | ~2K tokens |
| SKILL.md | ~5K tokens |
| Shared contracts | ~3K tokens |
| Code conventions | ~1K tokens |
| Pipeline summary | ~2K tokens |
| Total | ~13K tokens |
Without isolation: ~70K tokens (unmanageable)
Workers attempting to read files outside their contract inputs → WARN Workers attempting to write outside their contract outputs → DENY
# Load circuit breaker config
CIRCUIT_FILE="${CIRCUIT_FILE:-.forgewright/circuits.json}"
# Source circuit breaker functions
source scripts/runtime/circuit-breaker.sh
# Check circuit state for each worker
for task in T3a T3b T3c T4 T5 T6a T6b; do
circuit_key="${task,,}"
state=$(should_allow "$circuit_key" 60) # 60s timeout
if [ "$state" = "OPEN" ]; then
echo "[CIRCUIT_BREAKER] Skipping ${task}: circuit is OPEN"
continue
elif [ "$state" = "HALF_OPEN" ]; then
echo "[CIRCUIT_BREAKER] ${task}: circuit is HALF_OPEN (limited requests)"
else
echo "[CIRCUIT_BREAKER] ${task}: circuit is CLOSED"
fi
done
| Worker | Circuit Key | Default Config |
|---|---|---|
| T3a (Backend) | t3a | failure_threshold: 3 |
| T3b (Frontend) | t3b | failure_threshold: 3 |
| T3c (Mobile) | t3c | failure_threshold: 3 |
| T4 (DevOps) | t4 | failure_threshold: 3 |
| T5 (QA) | t5 | failure_threshold: 3 |
| T6a (Security) | t6a | failure_threshold: 3 |
| T6b (Code Review) | t6b | failure_threshold: 3 |
{
"t3a": { "state": "CLOSED", "failure_count": 0, "last_failure": null },
"t3b": { "state": "OPEN", "failure_count": 5, "last_failure": 1712912400 },
"t4": { "state": "HALF_OPEN", "failure_count": 3, "last_failure": 1712912400 }
}
# Load bulkhead config from .production-grade.yaml
BULKHEAD_MEMORY="${BULKHEAD_MEMORY_MB:-512}"
BULKHEAD_CPU="${BULKHEAD_CPU_PERCENT:-80}"
BULKHEAD_DURATION="${BULKHEAD_DURATION_MINUTES:-30}"
# Apply bulkhead limits to this shell
scripts/runtime/worktree-manager.sh bulkhead-limits "$BULKHEAD_MEMORY" "$BULKHEAD_CPU" "$BULKHEAD_DURATION"
# Per-worker resource limits
declare -A WORKER_LIMITS=(
["T3a"]="512 30" # Backend: 512MB, 30min
["T3b"]="512 30" # Frontend: 512MB, 30min
["T3c"]="512 30" # Mobile: 512MB, 30min
["T4"]="768 45" # DevOps: 768MB, 45min
["T5"]="512 30" # QA: 512MB, 30min
["T6a"]="256 20" # Security: 256MB, 20min
["T6b"]="256 20" # Code Review: 256MB, 20min
)
# For each worktree, spawn a worker with watchdog
for task in T3a T3b T3c; do
worktree_path=".worktrees/${task}"
limits="${WORKER_LIMITS[$task]}"
mem_mb=$(echo "$limits" | cut -d' ' -f1)
duration_min=$(echo "$limits" | cut -d' ' -f2)
# Create worker instruction file
cat > "${worktree_path}/WORKER_INSTRUCTIONS.md" <<'INSTRUCTIONS'
# Worker Instructions
You are a parallel worker in the Forgewright pipeline.
## Your Contract
view_file_outline CONTRACT.json in this directory.
## Your Skill
view_file_outline the skill file specified in the contract.
## Rules
1. ONLY read files listed in contract inputs
2. ONLY write files in contract output directories
3. DO NOT fabricate imports — verify every import path exists
4. DO NOT create stub code — all code must be fully implemented
5. Run tests before delivering — all must pass
6. Write DELIVERY.json when complete
## Anti-Hallucination Checklist
- [ ] All imports resolve to real files
- [ ] All API endpoints match the OpenAPI spec
- [ ] All database models match schema definitions
- [ ] Type checker passes
- [ ] No TODO/FIXME in production code
- [ ] All tests pass
INSTRUCTIONS
# Dispatch worker with watchdog
scripts/runtime/worktree-manager.sh bulkhead-watchdog "$task" "$worktree_path" "$mem_mb" "$duration_min" &
echo "Worker ${task} dispatched"
done
# Wait for all workers to complete
wait
echo "All workers completed."
| Worker | Memory | Time | On OOM | On Timeout |
|---|---|---|---|---|
| T3a (Backend) | 512MB | 30min | Kill + Skip | Kill + Skip |
| T3b (Frontend) | 512MB | 30min | Kill + Skip | Kill + Skip |
| T3c (Mobile) | 512MB | 30min | Kill + Skip | Kill + Skip |
| T4 (DevOps) | 768MB | 45min | Kill + Skip | Kill + Skip |
| T5 (QA) | 512MB | 30min | Kill + Skip | Kill + Skip |
| T6 (Review) | 256MB | 20min | Kill + Skip | Kill + Skip |
Safety Guarantees:
.forgewright/bulkhead-log.mdAfter all workers complete, run the Cursor spec-reviewer subagent for each task:
# For each task, generate reviewer contract from CONTRACT.json
for task in T3a T3b T3c; do
# Extract acceptance criteria from worktree CONTRACT.json
# Write to .forgewright/subagent-context/REVIEWER_CONTRACT_$task.md
done
# Invoke spec-reviewer for each task
Invoke: /spec-reviewer Review T3a backend services against CONTRACT.json
spec-reviewer performs:
PIPELINE_SUMMARY.md for phase contextREVIEWER_CONTRACT.md for scope and acceptance criteria.forgewright/subagent-context/SPEC_REVIEW_[task-id].mdRetry Protocol:
For each task that passed Stage 1, run quality-reviewer and security-auditor:
# Invoke quality-reviewer
Invoke: /quality-reviewer Assess T3a services code quality
# Invoke security-auditor (HARDEN phase only)
Invoke: /security-auditor Perform OWASP audit on T3a auth and payment code
quality-reviewer performs:
PIPELINE_SUMMARY.md and QUALITY_STANDARDS.md.forgewright/subagent-context/QUALITY_REVIEW_[task-id].mdsecurity-auditor performs:
.forgewright/subagent-context/SECURITY_AUDIT_[task-id].md{
"task_id": "T3a",
"stage1_spec_review": "PASS",
"stage2_quality_review": "PASS",
"stage2_security_audit": "PASS",
"overall": "PASS",
"reports": {
"spec": ".forgewright/subagent-context/SPEC_REVIEW_T3a.md",
"quality": ".forgewright/subagent-context/QUALITY_REVIEW_T3a.md",
"security": ".forgewright/subagent-context/SECURITY_AUDIT_T3a.md"
},
"validated_at": "2026-05-24T01:00:00Z",
"summary": {
"files_created": 15,
"tests_written": 42,
"test_pass_rate": 1.0,
"issues_found": 0
}
}
━━━ Parallel Dispatch: Wave 1 Results ━━━━━━━━━━
T3a (Backend): ✓ PASS — Spec ✓ Quality ✓ Security ✓ — 5 services, 42 tests
T3b (Frontend): ✓ PASS — Spec ✓ Quality ✓ — 8 pages, 28 tests
T3c (Mobile): ⊘ SKIP — not required
Cursor Subagent Reports:
• SPEC_REVIEW_T3a.md — PASS
• QUALITY_REVIEW_T3a.md — Score 8.5/10
• SECURITY_AUDIT_T3a.md — SECURE
• VERIFIER_REPORT.md — PASS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Use the least powerful model that can handle each role:
| Task Complexity | Signals | Model |
|---|---|---|
| Mechanical | 1-2 files, clear spec, isolated function | Fast/cheap |
| Integration | Multi-file coordination, pattern matching | Standard |
| Architecture | Design judgment, broad codebase understanding | Most capable |
| Subagent | Model | Why |
|---|---|---|
explore | built-in (fast) | 10 parallel searches |
verifier | fast | Mechanical compliance checks |
spec-reviewer | fast | Binary PASS/FAIL |
quality-reviewer | inherit | Deep reasoning for quality |
security-auditor | inherit | Deep reasoning for security |
Cost-efficiency tips:
fast for any task with a clear checklistinherit only for tasks requiring design judgmentfast model is ~10x cheaper and ~3-5x fasterWorkers report one of four statuses in DELIVERY.json:
| Status | Meaning | Action |
|---|---|---|
| DONE | Work completed successfully | Proceed to spec compliance review |
| DONE_WITH_CONCERNS | Completed but has doubts | view_file_outline concerns. If correctness → address first. |
| NEEDS_CONTEXT | Missing information | Provide missing context, re-dispatch |
| BLOCKED | Cannot complete | Assess blocker → provide context, more capable model, or break into pieces |
Handling BLOCKED:
Read skills/_shared/protocols/merge-arbiter.md and follow merge protocol:
# Step 1: Merge in dependency order
# infrastructure → backend → frontend → mobile
git worktree remove parallel/T3a-backend --force
git merge parallel/T3a-backend -m "feat: add backend services"
git worktree remove parallel/T3b-frontend --force
git merge parallel/T3b-frontend -m "feat: add frontend pages"
# Step 2: Run post-merge validation
npm run type-check
npm run test:integration
# Step 3: Run full integration test
npm run test:e2e
# Step 4: Log to merge-log.md
echo "## Merge Log" >> .forgewright/merge-log.md
echo "$(date): T3a, T3b merged successfully" >> .forgewright/merge-log.md
# Step 5: Clean up worktrees
scripts/runtime/worktree-manager.sh cleanup-all
| Conflict Type | Resolution |
|---|---|
| Auto-resolvable (formatting) | Apply auto-resolution per merge-arbiter.md |
| Code (same line) | Escalate to CEO agent |
| Schema (API contract) | Re-run API design phase |
If there are Wave 2 tasks (e.g., T4 depends on T3a):
# T3a is now merged into main
git checkout main
git pull
# Create new worktrees for Wave 2
scripts/runtime/worktree-manager.sh create T4 parallel/T4-devops
# These worktrees see T3a's output (it's in main)
# Repeat Phases 2-6 for Wave 2
| Scenario | Action |
|---|---|
| Worker times out | Kill process, mark FAILED, retry with extended timeout |
| Worker DELIVERY missing | Mark FAILED, retry from checkpoint |
| Validation FAIL (High) | Feed VALIDATION.json back to worker, retry (max 3) |
| Validation FAIL (Critical) | Escalate to CEO agent immediately |
| Merge conflict (auto-resolvable) | Apply auto-resolution per merge-arbiter.md |
| Merge conflict (code) | Escalate to CEO agent |
| Integration test failure | Identify culprit branch, revert, re-dispatch |
| All retries exhausted | Fall back to sequential mode for failed task |
Each worker's state is preserved:
.worktrees/T3a/
├── CONTRACT.json # Input contract (immutable)
├── WORKER_INSTRUCTIONS.md # Dispatch instructions
├── DELIVERY.json # Worker output (written by worker)
├── VALIDATION.json # Validation results
├── worker-T3a.log # Worker stdout/stderr
└── services/ # Actual work output
To resume a failed task:
scripts/runtime/worktree-manager.sh resume T3a
# Worker re-reads CONTRACT.json + VALIDATION.json feedback
# Fixes issues and regenerates DELIVERY.json
Update .forgewright/task.md:
## BUILD Phase (Parallel)
- [x] T3a: Backend Engineering — ✓ 5 services (Wave 1)
- [x] T3b: Frontend Engineering — ✓ 8 pages (Wave 1)
- [⊘] T3c: Mobile Engineering — skipped (not required)
- [x] T4: DevOps Containers — ✓ 5 Dockerfiles (Wave 2)
- [x] Merge — ✓ all branches merged, integration tests pass
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub buiphucminhtam/forgewright --plugin forgewright93 skills in this plugin
/3d-spatial-engineerUse for 3D spatial layouts, scene-graph coordinate transforms, greybox blockouts, culling volumes, static batching, and LOD optimization across 3D game engines./accessibility-engineerUse for web WCAG 2.1/2.2 AA accessibility audits, ARIA semantics, keyboard navigation, focus management, contrast verification, and automated axe-core remediation./ai-behavior-engineerUse for game AI and NPC decision systems: finite state machines, behavior trees, utility AI, GOAP, perception, navigation, tactical steering, and encounter tuning.Other plugins' skills for the same job