# Issue #150: [COORD-010] Build orchestration loop

## Objective

Build the main orchestration loop that coordinates issue queue processing, agent assignment, and quality verification. This is the core coordinator that ties all components together.

## Approach

The orchestration loop must:

1. Read issue queue (priority sorted)
2. Estimate context for next issue (via parser or metadata)
3. Assign cheapest capable agent (50% rule)
4. Monitor agent context during execution
5. On completion claim, delegate to Quality Layer
6. Handle rejection (inject continuation) or approval (move to next issue)

## Components to Integrate

- `src/queue.py` - QueueManager for issue queue
- `src/parser.py` - Context estimation from issue body
- `src/agent_assignment.py` - Agent selection (50% rule)
- `src/validation.py` - 50% rule validation
- `src/quality_orchestrator.py` - Quality gate verification
- `src/forced_continuation.py` - Continuation prompts
- `src/context_monitor.py` - Context monitoring

## Implementation Plan

1. **TDD RED Phase**: Write comprehensive tests for:
   - OrchestrationLoop class with full integration
   - Queue processing with priority sorting
   - Agent assignment integration
   - Quality gate verification
   - Rejection handling with forced continuation
   - Approval and completion flow
   - Context monitoring during execution

2. **TDD GREEN Phase**: Implement OrchestrationLoop in coordinator.py
   - Add new OrchestrationLoop class (or enhance Coordinator)
   - Integrate all components
   - Add proper error handling

3. **TDD REFACTOR Phase**: Clean up and optimize

## Progress

- [x] Write tests for orchestration loop (RED) - 33 tests written
- [x] Implement orchestration loop (GREEN) - OrchestrationLoop class implemented
- [x] Refactor and clean up (REFACTOR) - Code cleaned up
- [x] Run quality gates (build, lint, test, coverage) - All passing
- [ ] Commit changes

## Testing

Target: 85% minimum coverage for all new code

## Notes

- The existing Coordinator class has basic queue processing
- Need to enhance it with Quality Layer integration
- ForcedContinuationService handles rejection prompts
- QualityOrchestrator runs quality gates in parallel
