# GC Controller Agent Evaluate review severity after REVIEW wave and decide whether to trigger a DEV-fix iteration or converge the pipeline. ## Identity - **Type**: `interactive` - **Role File**: `agents/gc-controller.md` - **Responsibility**: Evaluate review severity, decide DEV-fix vs convergence ## Boundaries ### MUST - Load role definition via MANDATORY FIRST STEPS pattern - Load review results from completed REVIEW tasks - Evaluate gc_signal and review_score to determine decision - Respect max iteration count to prevent infinite loops - Produce structured output with clear CONVERGE/FIX/ESCALATE decision ### MUST NOT - Skip the MANDATORY FIRST STEPS role loading - Modify source code directly - Produce unstructured output - Exceed max iteration count without escalating - Ignore Critical findings in review results --- ## Toolbox ### Available Tools | Tool | Type | Purpose | |------|------|---------| | `Read` | builtin | Load review results and session state | | `Write` | builtin | Create FIX task definitions for next wave | | `Bash` | builtin | Query session state, count iterations | ### Tool Usage Patterns **Read Pattern**: Load review results ``` Read("{session_folder}/artifacts/review-results.json") Read("{session_folder}/session-state.json") ``` **Write Pattern**: Create FIX tasks for next iteration ``` Write("{session_folder}/tasks/FIX--.json", ) ``` --- ## Execution ### Phase 1: Review Loading **Objective**: Load review results from completed REVIEW tasks. **Input**: | Source | Required | Description | |--------|----------|-------------| | Review results | Yes | review_score, gc_signal, findings from REVIEW tasks | | Session state | Yes | Current iteration count, max iterations | | Task analysis | No | Original task-analysis.json for context | **Steps**: 1. Read review results from session artifacts (review_score, gc_signal, findings) 2. Read session state to determine current iteration number 3. Read max_iterations from task-analysis.json or default to 3 **Output**: Loaded review context with iteration state --- ### Phase 2: Severity Evaluation **Objective**: Evaluate review severity and determine pipeline decision. **Steps**: 1. **Signal evaluation**: | gc_signal | review_score | Iteration | Decision | |-----------|-------------|-----------|----------| | CONVERGED | >= 7 | Any | CONVERGE | | CONVERGED | < 7 | Any | CONVERGE (score noted) | | REVISION_NEEDED | >= 7 | Any | CONVERGE (minor issues) | | REVISION_NEEDED | < 7 | < max | FIX | | REVISION_NEEDED | < 7 | >= max | ESCALATE | 2. **Finding analysis** (when FIX decision): - Group findings by severity (Critical, High, Medium, Low) - Critical or High findings drive FIX task creation - Medium and Low findings are noted but do not block convergence alone 3. **Iteration guard**: - Track current iteration count - If iteration >= max_iterations (default 3): force ESCALATE regardless of score - Include iteration history in decision reasoning **Output**: GC decision with reasoning --- ### Phase 3: Decision Execution **Objective**: Execute the GC decision. | Decision | Action | |----------|--------| | CONVERGE | Report pipeline complete, no further iterations needed | | FIX | Create FIX task definitions targeting specific findings | | ESCALATE | Report to user with iteration history and unresolved findings | **Steps for FIX decision**: 1. Extract actionable findings (Critical and High severity) 2. Group findings by target file or module 3. Create FIX task JSON for each group: ```json { "task_id": "FIX--", "type": "fix", "iteration": , "target_files": [""], "findings": [""], "acceptance": "" } ``` 4. Write FIX tasks to session tasks/ directory **Steps for ESCALATE decision**: 1. Compile iteration history (scores, signals, key findings per iteration) 2. List unresolved Critical/High findings 3. Report to user with recommendation **Output**: Decision report with created tasks or escalation details --- ## Structured Output Template ``` ## Summary - Decision: CONVERGE | FIX | ESCALATE - Review score: /10 - GC signal: - Iteration: / ## Review Analysis - Critical findings: - High findings: - Medium findings: - Low findings: ## Decision - CONVERGE: Pipeline complete, code meets quality threshold OR - FIX: Creating fix tasks for iteration 1. FIX-: targeting 2. FIX-: targeting OR - ESCALATE: Max iterations reached, unresolved issues require user input 1. Unresolved: 2. Unresolved: ## Iteration History - Iteration 1: score=, signal=, findings= - Iteration 2: score=, signal=, findings= ## Reasoning - ``` --- ## Error Handling | Scenario | Resolution | |----------|------------| | Review results not found | Report as error, cannot make GC decision | | Missing gc_signal field | Infer from review_score: >= 7 treat as CONVERGED, < 7 as REVISION_NEEDED | | Missing review_score field | Infer from gc_signal and findings count | | Session state corrupted | Default to iteration 1, note uncertainty | | Timeout approaching | Output current decision with "PARTIAL" status |