Skip to content

feat: preserve element/composite errors and trigger SEG_8 once per segment - #182

Merged
azoner merged 1 commit into
masterfrom
feat/composite-errors-trigger-seg8
May 6, 2026
Merged

feat: preserve element/composite errors and trigger SEG_8 once per segment#182
azoner merged 1 commit into
masterfrom
feat/composite-errors-trigger-seg8

Conversation

@azoner

@azoner azoner commented May 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Element errors (ELE_*) and composite errors (COMP_*) are now preserved in err_ele.errors with their specific pyx12 codes AND trigger exactly one SEG_8_HAS_DATA_ELEMENT_ERRORS in err_seg.errors.
  • SEG-validator errors (those with map_node is None) collapse to that same single SEG_8 per PR fix: route seg-level validation errors through errh.seg_error #161 spec correctness.
  • Exactly one SEG_8 per segment regardless of how many child errors fired (composite emissions now set map_node=self so they flow through the ele_error path).
  • Ack output (997/999) is byte-for-byte identical (visitor dedup keeps IK3-048 / AK3-048 single-emission). Six resJson fixtures gain SEG_8 entries on segments that previously had empty seg-level error arrays.

Test plan

  • pytest pyx12/test/ — 600 passed (3 new ApplySegmentErrorsRouting cases: single element error, multiple element errors on one segment, no-error case)
  • mypy --strict pyx12 — clean (89 files)
  • ruff check + ruff format --check — clean
  • All res997 / resAck fixtures unchanged (verified by green _test_997 / _test_999 cases)
  • Six resJson fixtures regenerated and validated against the in-process pipeline

🤖 Generated with Claude Code

…gment

Previously, SEG-validator errors and seg-level errors emitted by the
composite validator (COMP_*) were collapsed to SEG_8 with their err_str
preserved, while element errors emitted SEG_8 inline per error. This
mixed two concerns: (1) which pyx12 codes survive in the err_handler
tree, and (2) when SEG_8 fires.

Refactor apply_segment_errors with a clearer routing rule:

  * Element errors (ELE_*) and composite errors (COMP_*) — both carry
    map_node — are preserved in err_ele.errors with their specific
    pyx12 code AND trigger a single SEG_8_HAS_DATA_ELEMENT_ERRORS in
    err_seg.errors.
  * SEG-validator errors (map_node is None) collapse to that same
    single SEG_8 (their specific codes are dropped per PR #161 spec
    correctness). The first SEG-validator error's err_str / err_val is
    preserved on the SEG_8 emission.
  * Exactly one SEG_8 per segment regardless of how many child errors
    fired.

Composite emissions in _composite.py now set map_node=self so the
composite error flows through the ele_error path (composite_if has
data_ele/name/seq — the right shape for err_ele).

Ack output (997/999) is byte-for-byte identical: the visitor dedup logic
emits IK3-04*8 / AK3-04*8 once per segment whether SEG_8 arrives once or
many times. Six resJson fixtures gain SEG_8 entries in their seg-level
errors arrays where they previously had empty arrays.

Adds three new ApplySegmentErrorsRouting tests covering single element
error, multiple element errors on one segment, and the no-error case.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@azoner
azoner merged commit b15d55c into master May 6, 2026
16 checks passed
@azoner
azoner deleted the feat/composite-errors-trigger-seg8 branch May 6, 2026 20:34
azoner added a commit that referenced this pull request May 6, 2026
…-layer testing, resJson regen)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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