# CGES-CORE-1.0 Semantic Validator Rules

This artifact defines the canonical semantic validation phase required after structural JSON Schema validation.

## Validation Phases

1. Structural validation against `schemas/cges-core-1.0.schema.json`
2. Semantic validation against the rules in this document

## Board Scope

- The top-level payload is one board scope.
- Each `additional_boards[]` entry is a separate board scope.
- Semantic rules below apply independently to the top-level board and to every `additional_boards[]` entry.

## Rules

- `CORE-RULE-001`: If `analysis` is present, `analysis.component_count` must equal the emitted `components` array length.
- `CORE-RULE-002`: If `analysis` is present, `analysis.net_count` must equal the emitted `nets` array length.
- `CORE-RULE-003`: Each emitted component `refdes` must be unique within its board scope.
- `CORE-RULE-004`: Each `nets[].connections[].refdes` must reference an emitted component in the same board scope.
- `CORE-RULE-005`: Each `nets[].connections[].pin` must match an emitted `components[].pins[].pin_number` value for the referenced component in the same board scope. Empty string is permitted only when both sides use the same empty emitted pin identifier for unresolved source data.
- `CORE-RULE-006`: If `metadata.analysis_context.epsa_board` exists, `metadata.extensions` must contain `CGES-EPSA-BOARD-0.1`.
- `CORE-RULE-007`: If any component contains `analysis_modules.epsa`, `metadata.extensions` must contain `CGES-EPSA-COMPONENT-0.1`.
- `CORE-RULE-008`: If any component contains `analysis_modules.fmea`, `metadata.extensions` must contain `CGES-FMEA-0.1`.
- `CORE-RULE-009`: If any component contains `analysis_modules.wcca`, `metadata.extensions` must contain `CGES-WCCA-0.1`.
- `CORE-RULE-010`: If `metadata.extensions` contains `CGES-EPSA-BOARD-0.1`, `metadata.analysis_context.epsa_board` must exist.
- `CORE-RULE-011`: If `metadata.extensions` contains `CGES-EPSA-COMPONENT-0.1`, at least one emitted component must contain `analysis_modules.epsa`.
- `CORE-RULE-012`: If `metadata.extensions` contains `CGES-FMEA-0.1`, at least one emitted component must contain `analysis_modules.fmea`.
- `CORE-RULE-013`: If `metadata.extensions` contains `CGES-WCCA-0.1`, at least one emitted component must contain `analysis_modules.wcca`.
- `CORE-RULE-014`: For `additional_boards[]`, extension declarations are local to that entry. Validators must not inherit top-level `metadata.extensions` into an additional board entry.
- `CORE-RULE-015`: If deprecated `metadata.revision` is present, it must equal `metadata.schematic_revision`.

## Quality Warning Rules

- `CORE-WARN-001`: If deprecated `metadata.revision` is present, validators should report a warning and normalize consumers to `metadata.schematic_revision`.
- `CORE-WARN-002`: Component `role` or `function` values equal to `unspecified` are structurally valid but should be reported as incomplete semantics.
- `CORE-WARN-003`: Transitional legacy EPSA alias keys such as `v_rating`, `i_rating`, and `p_rating` under `components[].analysis_modules.epsa` are accepted for the current contract but should trigger normalization warnings.
- `CORE-WARN-004`: Unnamed nets and other allowed empty-string identifiers that reduce analysis quality should be reported as warnings even when they remain structurally and semantically valid.

## Expected Outcomes

- Violations of `CORE-RULE-001` through `CORE-RULE-015` are `fail`.
- `CORE-WARN-001` through `CORE-WARN-004` are `pass_with_warnings`.

