# Command Doc → Test Coverage Parity Check

## Context

Module: {{MODULE_NAME}}
Command docs: {{COMMAND_DOCS}}
Test code: {{COMMAND_TEST_CODE}}

## Instructions

1. Read ALL command docs at the paths above
2. Read ALL test code files at the paths above
3. For each command doc, extract process flow branches, error scenarios, and idempotent paths
4. For each test file, extract test case descriptions and assertions
5. Run every parity check below against each command
6. Return results as JSON per the Output Format section

## Extraction: Command Docs

From each command doc, extract:

### Process Flow Branches

From the mermaid flowchart, identify each decision node and its outcomes:

- Decision: "Entity exists?" → Yes path, No path
- Decision: "Status valid?" → Valid path, Invalid path
- Each terminal node = one expected test case

### Error Scenarios

From the Error Scenarios table:

- Error code + condition = one expected error test case

### Idempotent Paths

From the process flow, identify "already exists → return existing" patterns:

- These need explicit test cases

## Extraction: Test Code

From each test file (`command/*.test.ts`), extract:

- **Test descriptions**: `it("...")` or `test("...")` strings
- **Error assertions**: checks for specific error types/codes
- **Happy path tests**: tests that verify successful outcomes
- **Fixture usage**: which fixtures are used

See [testing.md](../../erp-kit-shared/references/testing.md) for canonical testing patterns.

## Parity Checks

For each command:

| Check ID              | Question                                                   |
| --------------------- | ---------------------------------------------------------- |
| process_flow_coverage | Does each branch in process flow have a test case?         |
| error_scenario_tests  | Does each documented error scenario have a test assertion? |
| happy_path_tests      | Are success paths tested?                                  |
| idempotent_path_tests | If doc shows "already exists → return", is this tested?    |

### How to Check

1. Count process flow branches from command doc flowchart
2. Count test cases in corresponding test file
3. Map each branch to a test case by description/assertion
4. Identify any branches without corresponding tests

## Common Gap Patterns

- **Uncovered process branches**: Flowchart branch has no test
- **Missing error tests**: Error scenario has no assertion
- **Missing idempotent tests**: "Return existing" path untested
- **Missing edge cases**: Boundary conditions not tested
- **Test without doc branch**: Test exists but doesn't map to documented flow (potential doc gap)

## Output Format

Return a JSON object:

```json
{
  "check_type": "command-doc-test-parity",
  "module": "{{MODULE_NAME}}",
  "gaps": [...],
  "inconsistencies": [...],
  "summary": { "total_checks": N, "passed": N, "failed": N, "skipped": N }
}
```

See [impl-parity-report-format.md](impl-parity-report-format.md) for field definitions.
