# V2 Review — Action Tracker

**Review date:** 2026-04-06  
**Focus:** AST/Parser coherence and validator architecture

All v1 Critical issues are resolved. This tracker covers net-new findings from the v2 review.

---

## Finding index

| ID | Severity | File | Topic | Findings doc |
|---|---|---|---|---|
| F-01 | Major | `variableValidator.js` | 3 AST-compensating regex patterns | [F01](findings/F01_variableValidator_ast_compensation.md) |
| F-02 | Major | `returnTypeValidator.js` | RETURN_RE + duplicated type inference | [F02](findings/F02_returnTypeValidator_ast_compensation.md) |
| F-03 | Major | `collectDiagnostics.js` | `parseVarDeclaration` scan vs. AST VarStatement | [F03](findings/F03_collectDiagnostics_var_declaration_scan.md) |
| F-04 | Major | `functionValidator.js` | Skip guards + standalone call detection via regex | [F04](findings/F04_functionValidator_skip_guards.md) |
| F-05 | Design | `executionContext.js` | ECM is a regex-based parallel classification to the AST | [F05](findings/F05_execution_classification_map.md) |
| F-06 | Observation | `expressionParser.js` callers | Capable Pratt parser underused by validators | [F06](findings/F06_expression_parser_underuse.md) |
| F-07a | Minor | `hashModeValidator.js` | Mixed token-stream/regex approach | [F07](findings/F07_minor_findings.md) |
| F-07b | Minor | `executionContext.js` | `ELSEIF` dead entry in `isLikelyExecutableLine` regex | [F07](findings/F07_minor_findings.md) |
| F-07c | Minor | `functionValidator.js` | `ELSEIF` dead entry in `extractStandaloneCallName` | [F07](findings/F07_minor_findings.md) |
| F-07d | Obs. | `macroValidator.js` | Regex for macro name position on known-macro line | [F07](findings/F07_minor_findings.md) |
| F-07e | Obs. | `parser.js` (old) | `parseAssignment` indexOf on raw vs. stripped line | [F07](findings/F07_minor_findings.md) |
| F-07f | Obs. | `hashModeValidator.js` | `INCOMPLETE_ASSIGNMENT` regex is correct current design | [F07](findings/F07_minor_findings.md) |

---

## Remediation tiers

### Tier 1 — Clear wins, narrow scope (recommended next)

| ID | Status | Action | Impact |
|---|---|---|---|
| F-01 (instance 3) | ✅ Done | Replace `getParamModeVariables` regex with `parseExpression` Call node | variableValidator.js only |
| F-01 (instance 1) | ✅ Done | Add `doIteratorsByLine` to documentFacts from AST `DoStatement.iterator` | documentFacts.js + variableValidator.js |
| F-02 (both) | ✅ Done | Replace `RETURN_RE` with AST `ReturnStatement` nodes; replace `inferReturnExpressionType` with `parseExpression` | returnTypeValidator.js only |
| F-03 | ✅ Done | Move `parseVarDeclaration` scan to documentFacts using `VarStatement` AST nodes | documentFacts.js + collectDiagnostics.js |
| F-07b | ✅ Done | Remove `elseif` from `isLikelyExecutableLine` regex | executionContext.js |
| F-07c | ✅ Done | Remove `elseif` from `extractStandaloneCallName` exclusion list | functionValidator.js |

### Tier 2 — Moderate complexity (requires validator signature change or documentFacts extension)

| ID | Status | Action | Impact |
|---|---|---|---|
| F-01 (instance 2) | ✅ Done | Expose `assignmentsByLine` from documentFacts; use `SetStatement`/`AssignStatement` in variableValidator | documentFacts.js + variableValidator.js |
| F-04 (skip guards) | ✅ Done | Add `nodeTypeByLine` to documentFacts; eliminate `shouldSkipFunctionValidationLine` | documentFacts.js + functionValidator.js |
| F-04 (standalone call) | ✅ Done | Use AST `ExpressionStatement` + expressionParser Call for ACU-FNC-008 detection | functionValidator.js |
| F-07a | ✅ Done | Start-of-line regex for HASH-ON/HASH-OFF detection (prevents false matches in comments/strings); mode tracked manually | hashModeValidator.js |

### Tier 3 — Architecture-level (requires broad coordination)

| ID | Status | Action | Impact |
|---|---|---|---|
| F-05 | Open | Rebuild `executionClassificationMap` from AST walk (preserving consuming interface) | executionContext.js + all validators |
| F-04 (validateCodeSnippet) | Open | Port function call scanning from regex to expressionParser Call nodes | functionValidator.js; requires token-aware snippet extraction |

---

## Backlog items

| ID | Status | Notes |
|---|---|---|
| F-01 instance 3 | ✅ Done | |
| F-01 instance 1 | ✅ Done | |
| F-02 | ✅ Done | |
| F-03 | ✅ Done | |
| F-07b | ✅ Done | |
| F-07c | ✅ Done | |
| F-01 instance 2 | ✅ Done | |
| F-04 (skip guards) | ✅ Done | |
| F-04 (standalone call) | ✅ Done | |
| F-07a | ✅ Done | |
| F-05 | Open — Tier 3, after Tier 2 | |
| F-04 (validateCodeSnippet) | Open — Tier 3, after Tier 2 | |
| v1 residual: `parser.js:337` bare include path traversal | ✅ Accepted | F-03 complete; condition met |
| v1 residual: `requireValidator:47` stat cache bypass | ✅ Accepted | Low impact per original assessment |

---

## Positive observations (no action required)

- The Lexer (`lexer.js`) is correct, complete, and clean. No findings.
- The AST parser (`ast/parser.js`) correctly handles all Architect constructs, including nested blocks
  and the CASE/VALUE/OTHERWISE/ENDCASE structure. No findings.
- The expression parser (`ast/expressionParser.js`) is a correct Pratt implementation with proper
  precedence. Validators that use it (`typeValidator`, `argumentTypeValidator`, `doIteratorValidator`,
  `exitStatementValidator`) represent the reference pattern.
- `documentFacts.js` correctly uses the AST for function scopes, catalogs, and duplicate detection.
  The migration path is clear: extend this file with the remaining Tier 1/2 items.
- `hashModeValidator.js` correctly uses the token stream for ACU-SYN-003 (NOTE in HASH-ON context) —
  the token-stream approach gives exact column positions without regex.
- All v1 Critical violations (15× `require('vscode')` in core/) are fixed. The vscodeTypes.js shim is
  deleted. The architecture boundary is now clean.
