Skip to content

test gap: multiple SEQ in same paragraph + state-machine reset / truncation invariants (#104 follow-up) #31

Description

@kiki830621

Problem

From verification of PsychQuant/che-word-mcp#104 (verify report: comment-4346442620):

「Multiple SEQ fields in same paragraph ([..., begin1, instrText1, sep1, cached1, end1, begin2, ...]) untested. State machine appears to reset correctly on second begin, but no explicit verification. Same for mixed-identifier within paragraph.」

— Source: team:logic

parseFiveRunSpan (Sources/OOXMLSwift/Parsing/FieldParser.swift:181-246) is a state machine that resets on each fldCharType="begin". Per code review the reset path is correct, but no test exercises:

  1. Two consecutive SEQ Figure fields in same paragraph[caption, begin1, instrText("SEQ Figure"), separate1, cached1, end1, " ", begin2, instrText("SEQ Figure"), separate2, cached2, end2]. Should return 2 ParsedFields.

  2. Mixed-identifier SEQ in same paragraph[..., begin1, instrText("SEQ Figure"), ..., end1, begin2, instrText("SEQ Table"), ..., end2]. Should return 2 ParsedFields with different identifiers; updateAllFields should increment both counters.

  3. Truncated paragraph (begin without end)[begin, instrText] with no separate / end. State machine should leave current non-nil at loop exit and silently emit nothing. Currently doc-comment doesn't pin this invariant.

Type

test gap (P3)

Acceptance criteria

  • Add 3 sub-tests in Issue104FieldParserCanonicalFormTests (or a new FieldParserStateMachineEdgeCasesTests file) covering the three scenarios above.
  • Document the truncated-paragraph behavior in parseFiveRunSpan doc-comment.

Why low priority

State machine logic appears correct on inspection. Real-world OOXML producers rarely emit multiple SEQ in same paragraph (typical pattern is one caption per paragraph). But pathological documents or future producers might, and the assumption is unverified.

Related: PsychQuant/che-word-mcp#104


Current Status

Phase: implemented
Last updated: 2026-05-02 by idd-implement

Key Decisions

Scope Changes

  • (none)

Blocking

  • Awaiting IDD verify / PR review.

Commits

  • 11860b5 test: cover canonical sequence field edge cases

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions