Skip to content

Audit A2 + A3: delete dead format_set, preserve strings in Parcel writer - #24

Merged
ronaldtse merged 1 commit into
mainfrom
fix/audit-a2-a3
Aug 7, 2026
Merged

Audit A2 + A3: delete dead format_set, preserve strings in Parcel writer#24
ronaldtse merged 1 commit into
mainfrom
fix/audit-a2-a3

Conversation

@ronaldtse

Copy link
Copy Markdown
Contributor

Two audit findings from data-private/TODO.full-cdd/17-architecture-audit-2026-06-25.md:

A2 — Dead format_set in CDDAL serializer (lib/opencdd/cddal/serializer.rb)

format_set and set_like? were defined but unreachable. format_value checks string_literal? first, and string_literal? returns true for any string that doesn't match UNQUOTED_VALUE_RE. The regex excludes (, so any parenthesized set-like string already gets routed to quote_string before set_like? is consulted.

Removed both methods. format_value now does quote-or-pass-through only.

A3 — Parcel writer normalizes "001""1" (lib/opencdd/parcel/writer.rb)

Parcel::Writer#add_data_sheets was calling ws.add_row(row) without type hints. caxlsx auto-typed numeric-looking strings ("001", "01") as Integer cells; roo read them back as 1, breaking Database#semantically_equal? for any round-trip involving version/revision codes.

Fix: pass types: :string to add_row. All property values are strings per IEC 61360 wire format, so this is correct semantically — not just a workaround.

New spec spec/parcel_string_preservation_spec.rb verifies version="001" and revision="01" survive a write → reload cycle.

Verification

  • 931 examples pass, 0 failures (full suite)
  • New spec covers A3's specific case
  • Existing scenario 3 in import_pipeline_spec.rb got its TODO updated — the value-normalization gap is fixed for the described case, but a full semantically_equal? round-trip is still blocked by a separate multilingual key normalization gap (MDC_P004_1 vs MDC_P004.en). That's a different audit item; flagged in the spec comment.

Not in scope

  • DET classification importer — investigated but requires deeper work. The export_DETCLASSIFICATION_*.xls files use CLASS_ID:=IECCDD_001 (a non-standard supplier scheme, not an MDC_CNNN meta-class IRDI). Making the importer accept this needs a "synthesize IRDIs from non-standard supplier codes" path that doesn't exist yet. Separate PR.
  • A6 (MDC_P023 vs MDC_P021 alias conflict) — needs VBA lookup to disambiguate. Separate PR.
  • A7 (sharded-dir reader spec weakness) — needs better fixture data. Separate PR.

A2 — delete dead code in CDDAL serializer:
  format_set() and set_like() in lib/opencdd/cddal/serializer.rb were
  unreachable. format_value() calls string_literal?() first, which
  returns true for any string not matching UNQUOTED_VALUE_RE — and
  that regex excludes parenthesized lists, so set_like?() could never
  be reached. Removed both methods; format_value now does
  quote-or-pass-through only.

A3 — preserve leading-zero strings through xlsx round-trip:
  Parcel::Writer::add_data_sheets now passes types: :string to
  ws.add_row. Previously caxlsx auto-typed numeric-looking strings
  ("001", "01") as Integer cells; roo read them back as 1, 1,
  breaking semantically_equal?. Now all property values survive as
  the strings they were stored as.

  New spec/parcel_string_preservation_spec.rb verifies version="001"
  and revision="01" survive a write → reload cycle.

  import_pipeline_spec.rb scenario 3's TODO comment is updated: the
  value-normalization gap is fixed for the specific case it described,
  but a full semantically_equal? round-trip is still blocked by a
  separate multilingual key normalization gap (MDC_P004_1 vs
  MDC_P004.en) — flagged as a separate follow-up.

931 specs pass, 0 failures.
@ronaldtse
ronaldtse merged commit 624c4c0 into main Aug 7, 2026
10 checks passed
@ronaldtse
ronaldtse deleted the fix/audit-a2-a3 branch August 7, 2026 07:44
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