Analyzer — Operational Protocol
Protocol
1. DISCOVER
- Read inputs from the orchestrator dispatch context:
diff_path: path to the pull request diff file to read.
findings_output_path: path where findings.json must be written.
state_path: path to pipeline-state.json for status updates.
run_id: current run identifier.
root: resolved scope root.
- Verify
diff_path exists and is a readable file. If not: emit NEEDS_CONTEXT with message: "Diff file not found at {diff_path}. Provide a valid path and re-run."
- Read the file content. If the file is empty: emit
DONE_WITH_CONCERNS with message: "Diff file at {diff_path} is empty. Findings file written with zero issues."
2. PROCESS
Analyze the diff content to identify issues in the following three categories:
Null checks: Identify locations where a return value or variable could be null/undefined but is accessed without a guard. Look for patterns such as:
- Direct property access or method call on a value that may be null (e.g.,
obj.prop without null guard).
- Missing optional chaining or null coalescing where the value originates from a function that may return null.
- Record each finding as:
{"category": "null_check", "severity": "high", "location": "{file}:{line}", "description": "{detail}"}
Error handling: Identify locations where errors or rejected promises are not handled. Look for patterns such as:
- Promise chains without
.catch().
async functions without try/catch around await calls that may throw.
- Callbacks that receive an error argument but do not check it.
- Record each finding as:
{"category": "error_handling", "severity": "medium", "location": "{file}:{line}", "description": "{detail}"}
Naming: Identify identifiers that are non-descriptive, misleading, or violate common conventions. Look for patterns such as:
If the diff contains no changed lines (+ or - prefix) outside of the diff header: assemble a zero-issue findings object and emit DONE_WITH_CONCERNS with message: "Diff file at {diff_path} contains no changed lines. Findings file written with zero issues."
Assemble the findings object:
{
"diff_path": "{diff_path}",
"issue_count": 0,
"issues": []
}
3. DELIVER
- Write
findings.json to findings_output_path using the Write tool.
- Update
pipeline-state.json:
- Set
phases[0].status = "completed" (or "completed_with_concerns" if zero issues or empty diff).
- Set
phases[0].outputs = [findings_output_path].
- Emit terminal status:
DONE — findings written successfully; at least one issue identified.
DONE_WITH_CONCERNS — findings written but diff was empty or contained no changed lines, or no issues were found (note reason).
NEEDS_CONTEXT — diff file not found or not accessible.
BLOCKED — findings file could not be written (e.g., path not writable).
1---2name: analyzer-protocol3description: Loaded by the analyzer agent to supply operating protocol and invariants for pull request diff analysis in the parity-test-f pipeline. Not user-invocable.4---56# Analyzer — Operational Protocol78<overview>9The analyzer agent reads a pull request diff file, identifies common code issues across three categories (null checks, error handling, naming), and writes a structured findings JSON file to the pipeline temp directory. It is the first step of the parity-test-f Sequential pipeline (Pattern 1) on Tier 1d (Codex CLI). The quality bar is: findings must be machine-readable JSON that the reviewer and reporter can consume without ambiguity.10</overview>1112## Protocol1314<protocol>1516### 1. DISCOVER17181. Read inputs from the orchestrator dispatch context:19 - `diff_path`: path to the pull request diff file to read.20 - `findings_output_path`: path where `findings.json` must be written.21 - `state_path`: path to `pipeline-state.json` for status updates.22 - `run_id`: current run identifier.23 - `root`: resolved scope root.242. Verify `diff_path` exists and is a readable file. If not: emit `NEEDS_CONTEXT` with message: "Diff file not found at `{diff_path}`. Provide a valid path and re-run."253. Read the file content. If the file is empty: emit `DONE_WITH_CONCERNS` with message: "Diff file at `{diff_path}` is empty. Findings file written with zero issues."2627### 2. PROCESS2829Analyze the diff content to identify issues in the following three categories:30311. **Null checks**: Identify locations where a return value or variable could be null/undefined but is accessed without a guard. Look for patterns such as:32 - Direct property access or method call on a value that may be null (e.g., `obj.prop` without null guard).33 - Missing optional chaining or null coalescing where the value originates from a function that may return null.34 - Record each finding as:35 ```json36 {"category": "null_check", "severity": "high", "location": "{file}:{line}", "description": "{detail}"}37 ```38392. **Error handling**: Identify locations where errors or rejected promises are not handled. Look for patterns such as:40 - Promise chains without `.catch()`.41 - `async` functions without `try/catch` around `await` calls that may throw.42 - Callbacks that receive an error argument but do not check it.43 - Record each finding as:44 ```json45 {"category": "error_handling", "severity": "medium", "location": "{file}:{line}", "description": "{detail}"}46 ```47483. **Naming**: Identify identifiers that are non-descriptive, misleading, or violate common conventions. Look for patterns such as:49 - Single-letter variable names outside of short loops (e.g., `d`, `x`, `tmp`).50 - Names that conflict with well-known conventions (e.g., `data` for a function, `list` for a scalar).51 - Boolean variables or functions whose names do not begin with `is`, `has`, `can`, or `should`.52 - Record each finding as:53 ```json54 {"category": "naming", "severity": "low", "location": "{file}:{line}", "description": "{detail}"}55 ```5657If the diff contains no changed lines (`+` or `-` prefix) outside of the diff header: assemble a zero-issue findings object and emit `DONE_WITH_CONCERNS` with message: "Diff file at `{diff_path}` contains no changed lines. Findings file written with zero issues."5859Assemble the findings object:6061```json62{63 "diff_path": "{diff_path}",64 "issue_count": 0,65 "issues": []66}67```6869### 3. DELIVER70711. Write `findings.json` to `findings_output_path` using the Write tool.722. Update `pipeline-state.json`:73 - Set `phases[0].status` = `"completed"` (or `"completed_with_concerns"` if zero issues or empty diff).74 - Set `phases[0].outputs` = `[findings_output_path]`.753. Emit terminal status:76 - `DONE` — findings written successfully; at least one issue identified.77 - `DONE_WITH_CONCERNS` — findings written but diff was empty or contained no changed lines, or no issues were found (note reason).78 - `NEEDS_CONTEXT` — diff file not found or not accessible.79 - `BLOCKED` — findings file could not be written (e.g., path not writable).8081</protocol>8283<invariants>84- NEVER write findings to a path outside `{ROOT}/superpipelines/temp/parity-test-f/{runId}/`.85- NEVER pass file contents to the orchestrator in the status message — pass only the findings file path.86- NEVER hardcode platform paths — use only the `root` value supplied in the dispatch context.87- ALWAYS validate that `findings_output_path` is writable before attempting write.88- ALWAYS update `pipeline-state.json` after writing findings.89- Emit exactly one terminal status: DONE / DONE_WITH_CONCERNS / NEEDS_CONTEXT / BLOCKED.90</invariants>