Skip to content

Fix spec serialization divergences and add conformance tests#87

Merged
gvonness-apolitical merged 2 commits intomainfrom
fix/spec-serialization-compliance
Feb 16, 2026
Merged

Fix spec serialization divergences and add conformance tests#87
gvonness-apolitical merged 2 commits intomainfrom
fix/spec-serialization-compliance

Conversation

@gvonness-apolitical
Copy link
Collaborator

Summary

  • Custom Serialize/Deserialize for Mark and Block enums to match the Codex file format spec wire format
  • Fixes 6 serialization divergences: Math field rename (valuesource), simple marks as strings, extension marks/blocks with colon-delimited types, figcaption lowercase, block_type() returns Cow<str>
  • All old formats accepted on deserialization for backward compatibility
  • Adds 22-test conformance suite (tests/conformance.rs) to prevent future spec drift

Test plan

  • cargo build --workspace --all-features passes
  • cargo test --workspace --all-features passes (973 tests, 0 failures)
  • cargo clippy --workspace --all-features -- -D warnings clean
  • Conformance tests verify round-trip serialization matches spec examples
  • Backward-compatible deserialization verified for all old formats

Custom Serialize/Deserialize for Mark and Block enums to match
the Codex file format spec wire format:

- Rename Mark::Math { value } to { source }
- Simple marks serialize as strings ("bold") not objects
- Extension marks use colon-delimited type ("semantic:citation")
- Extension blocks use colon-delimited type ("academic:theorem")
- FigCaption serializes as "figcaption" (lowercase)
- block_type() returns Cow<str> with "namespace:blockType" for extensions

All old formats accepted on deserialization for backward compatibility.
Adds 22-test conformance suite to prevent future spec drift.
@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 74.55048% with 184 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cdx-core/src/content/block.rs 56.73% 151 Missing ⚠️
cdx-core/src/content/text.rs 83.33% 24 Missing ⚠️
cdx-core/tests/conformance.rs 96.05% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

@gvonness-apolitical gvonness-apolitical merged commit f5eb0eb into main Feb 16, 2026
11 checks passed
@gvonness-apolitical gvonness-apolitical deleted the fix/spec-serialization-compliance branch February 16, 2026 14:37
gvonness-apolitical added a commit that referenced this pull request Feb 16, 2026
The hand-written Serialize/Deserialize impls from PR #87 are the
most complex recent addition. These fuzz targets exercise all type
dispatch paths with arbitrary input to catch panics or unexpected
behavior in the custom deserialization logic.
gvonness-apolitical added a commit that referenced this pull request Feb 16, 2026
The hand-written Serialize/Deserialize impls from PR #87 are the
most complex recent addition. These fuzz targets exercise all type
dispatch paths with arbitrary input to catch panics or unexpected
behavior in the custom deserialization logic.
@gvonness-apolitical gvonness-apolitical mentioned this pull request Feb 16, 2026
3 tasks
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