Skip to content

feat: migrate _composite.py + _segment.py producers to pyx12 codes (PR 3 of 6) - #177

Merged
azoner merged 1 commit into
masterfrom
feat/composite-segment-pyx12-codes-pr3
May 6, 2026
Merged

feat: migrate _composite.py + _segment.py producers to pyx12 codes (PR 3 of 6)#177
azoner merged 1 commit into
masterfrom
feat/composite-segment-pyx12-codes-pr3

Conversation

@azoner

@azoner azoner commented May 6, 2026

Copy link
Copy Markdown
Owner

Third slice of the X12 error code generalization plan. Composite and segment validators now emit pyx12 codes; visitors translate via the ERROR_CODES table so 999/997 ack output is unchanged.

Producer migration

pyx12/map_if/_composite.py (3 sites):

  • Mandatory composite missing: \"1\"COMP_1_MANDATORY_MISSING
  • Composite marked Not Used: \"5\"COMP_5_NOT_USED
  • Too many sub-elements: \"3\"COMP_3_TOO_MANY_SUBELEMENTS

pyx12/map_if/_segment.py (3 sites):

  • Too many elements in segment: \"3\"SEG_3_TOO_MANY_ELEMENTS
  • Too many sub-elements in composite (segment-level check): \"3\"SEG_3_TOO_MANY_SUBELEMENTS
  • Syntax violations: \"10\"SEG_10_SYNTAX_EXCLUSIVE, \"2\"SEG_2_SYNTAX_RELATIONAL

Test updates

4 test_map_if assertions updated to expect pyx12 codes:

  • test_segment_lengthSEG_3_too_many_elements
  • test_comp_required_fail1COMP_1_mandatory_missing
  • test_comp_not_used_fail1COMP_5_not_used
  • test_plb03_composite_missingCOMP_1_mandatory_missing

resJson fixtures

Unchanged. Re-running the regenerator helper made no diff, confirming no existing resJson fixture exercised composite-level or segment-validator-level error paths. The 39 remaining raw X12 codes in resJson are all from walker/parser emissions, which migrate in PR 4.

Test plan

  • pytest pyx12/test/: 579 passed (no count change)
  • mypy --strict pyx12: clean (88 files)
  • ruff check + format --check: clean
  • res997/resAck unchanged
  • resJson unchanged for these paths (no-op regenerator confirms)

Plan reference

~/.claude/plans/radiant-petting-steele.md — see PR 3 section.

🤖 Generated with Claude Code

…R 3 of 6)

Third slice of the X12 error code generalization plan. Composite and
segment validators now emit pyx12 codes (COMP_1_*, SEG_3_*, etc.).
Visitors translate via the ERROR_CODES table (PR 1) so 999/997 ack
output is unchanged. JSON err_cde flips for composite/seg-level errors.

Producer migration:

pyx12/map_if/_composite.py (3 sites):
- Mandatory composite missing: "1" -> COMP_1_MANDATORY_MISSING
- Composite marked Not Used: "5" -> COMP_5_NOT_USED
- Too many sub-elements: "3" -> COMP_3_TOO_MANY_SUBELEMENTS

pyx12/map_if/_segment.py (3 sites):
- Too many elements in segment: "3" -> SEG_3_TOO_MANY_ELEMENTS
- Too many sub-elements in composite (segment-level check): "3"
  -> SEG_3_TOO_MANY_SUBELEMENTS
- Syntax violations: "10" -> SEG_10_SYNTAX_EXCLUSIVE,
  "2" -> SEG_2_SYNTAX_RELATIONAL

Updated 4 test_map_if assertions to expect pyx12 codes:
- test_segment_length: SEG_3_too_many_elements
- test_comp_required_fail1: COMP_1_mandatory_missing
- test_comp_not_used_fail1: COMP_5_not_used
- test_plb03_composite_missing: COMP_1_mandatory_missing

resJson fixtures unchanged: re-running the regenerator helper made no
diff, confirming no existing fixture exercised composite-level or
segment-validator-level error paths. Walker / parser emissions (still
raw X12 codes "1"/"2"/"3"/"4"/"SEG1"/etc.) migrate in PR 4.

Verification:
- pytest pyx12/test/: 579 passed (no count change)
- mypy --strict pyx12: clean (88 files)
- ruff check + format --check: clean

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@azoner
azoner merged commit 6274c56 into master May 6, 2026
16 checks passed
@azoner
azoner deleted the feat/composite-segment-pyx12-codes-pr3 branch May 6, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant