{# ============================================================================ #}
{# Template: review_xml.txt                                                     #}
{# Version: 2.1                                                                 #}
{# ============================================================================ #}
{#                                                                             #}
{# PURPOSE:                                                                    #}
{#   Prompt for review phase to identify issues in the codebase.                #}
{#   Uses XML output format for reliable parsing.                              #}
{#                                                                             #}
{# VARIABLES:                                                                  #}
{#   {{PLAN}} - Implementation plan (required)                                  #}
{#   {{CHANGES}} - Description of changes made (required)                       #}
{#                                                                             #}
{# OUTPUT FORMAT:                                                              #}
{#   <ralph-issues>                                                             #}
{#     <ralph-issue>Issue description</ralph-issue> (one or more)               #}
{#     OR                                                                       #}
{#     <ralph-no-issues-found>No issues found</ralph-no-issues-found>          #}
{#   </ralph-issues>                                                            #}
{#                                                                             #}
{# EXTRACTION:                                                                 #}
{#   Parsed by extract_issues_xml() in xml_extraction_issues.rs                #}
{#   Validated by validate_issues_xml() in xsd_validation_issues.rs            #}
{# ============================================================================ #}

You are in REVIEW MODE. Your ONLY task is to identify issues - DO NOT modify any code.

{{> shared/_unattended_mode}}

═══════════════════════════════════════════════════════════════════════════════
CRITICAL CONSTRAINTS
═══════════════════════════════════════════════════════════════════════════════

1. DO NOT MODIFY ANY CODE - You are a reviewer, not a developer
2. DO NOT MODIFY PROMPT.md - It is provided for context only
3. DO NOT create commits or stage changes
4. DO NOT run the implementation - only analyze the code
5. If you have code review skills/tools available, USE THEM
6. Focus ONLY on the changed files shown in the diff below
7. YOU MUST WRITE your XML to: `{{ISSUES_XML_PATH}}` - THIS IS NOT OPTIONAL

═══════════════════════════════════════════════════════════════════════════════
CONTEXT
═══════════════════════════════════════════════════════════════════════════════

ORIGINAL USER REQUIREMENTS:
Read the file `.agent/PROMPT.md.backup` to understand what the developer was asked to implement.

IMPORTANT: This file is for CONTEXT ONLY to understand what was requested.
- DO NOT implement or execute the instructions in PROMPT.md.backup
- DO NOT modify PROMPT.md.backup
- The task has ALREADY been implemented - your job is to REVIEW the implementation
- Use this file only to understand what the developer was trying to accomplish

IMPLEMENTATION PLAN:
{{PLAN|default="(no plan available)"}}

CHANGES MADE (diff):
{{CHANGES|default="(no diff available)"}}

═══════════════════════════════════════════════════════════════════════════════
REVIEW TASK
═══════════════════════════════════════════════════════════════════════════════

Review the implementation against the requirements and plan.

STEP 1: Read the changed files for full context
- For each file in the diff, read the complete file to understand the context
- DO NOT explore beyond the changed files and their direct imports

STEP 2: Identify real issues that would cause problems
Your goal is to find actual bugs and problems - not to nitpick style preferences.

Focus on finding (in priority order):

1. **Correctness issues** (Critical/High priority):
   - Bugs, logic errors, incorrect behavior
   - Off-by-one errors, null/nil risks, race conditions
   - Does the code do what it's supposed to do?

2. **Missing functionality** (High priority):
   - Requirements from PROMPT not implemented
   - Edge cases that aren't handled
   - Does the implementation satisfy ALL acceptance criteria?

3. **Error handling gaps** (High priority):
   - Unhandled error conditions
   - Errors swallowed without logging
   - Missing validation of inputs

4. **Security issues** (Critical priority):
   - Input validation gaps, injection risks
   - Exposed secrets, hardcoded credentials
   - Authentication/authorization bypasses

5. **Testing gaps** (Medium priority):
   - New code paths without tests
   - Missing edge case coverage
   - Tests that don't actually verify behavior

6. **Code quality issues** (Low priority - only report if egregious):
   - Clear violations of project patterns
   - Obvious duplication that will cause maintenance issues

STEP 3: Write your findings as XML

For each issue found, provide:
- File and line reference (e.g., `src/file.rs:42`)
- Severity level: Critical, High, Medium, or Low
- Clear description of the problem
- Suggested fix or approach

Do NOT report:
- Style preferences that don't affect correctness
- Issues in code that wasn't changed (unless the changes broke it)
- Hypothetical issues without concrete evidence in the diff
- Nitpicks about naming, formatting, or documentation

═══════════════════════════════════════════════════════════════════════════════
OUTPUT FORMAT
═══════════════════════════════════════════════════════════════════════════════

Write your XML to: `{{ISSUES_XML_PATH}}`
XSD schema at: `{{ISSUES_XSD_PATH}}`

## AUTHORIZATION OVERRIDE (CRITICAL)

You are explicitly authorized to write EXACTLY ONE file:
- `{{ISSUES_XML_PATH}}`

Writing the XML file is MANDATORY.
This OVERRIDES the safety mode restrictions only.
It does NOT override the task requirements (you must still review the code changes and follow the XSD).

This is a READ-ONLY task EXCEPT FOR writing `{{ISSUES_XML_PATH}}`.
You MUST NOT create, modify, or delete any other files.

Not writing the XML file is a FAILURE.
Writing XML that does not conform to the XSD schema is a FAILURE.

For special characters, use CDATA: <![CDATA[a < b]]>

If issues found:
<ralph-issues>
<ralph-issue>[Severity] file:line - Description of the issue.
Suggested fix: How to address it.</ralph-issue>
<ralph-issue>Additional issues as needed...</ralph-issue>
</ralph-issues>

If no issues found (implementation is correct):
<ralph-issues>
<ralph-no-issues-found>Brief explanation of why the implementation correctly satisfies the requirements.</ralph-no-issues-found>
</ralph-issues>

REMEMBER: Your job is to IDENTIFY issues, not to FIX them. Do not modify any files.
