Skip to content

test(code_page): prove decode then encode returns the bytes read on the pinned double-byte drawings (#375) - #414

Merged
DrunkOnJava merged 3 commits into
mainfrom
test/dbcs-roundtrip-main
Oct 27, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
test/dbcs-roundtrip-main

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

The double-byte round-trip proof #375 asked for after #382 and #384: examples/probe_code_page.rs decodes every string of every pre-R2007 drawing with CodePage::decode and encodes the text back with CodePage::encode, and fails when a string that decodes cleanly encodes to bytes other than the ones read. It runs over the pinned Shift_JIS and GBK drawings (header shorts 38 and 39), so every row a later change adds is held to it. The change is the probe check and one ARCHITECTURE.md section; no library code moves.

Spec reference

ODA spec v5.4.1 §3.2.5 (the code page short). ARCHITECTURE.md §7av (provisional letter; the train renumbers).

Evidence (probe_code_page over the 61 pinned drawings, 2026-10-27; measured on the same probe merged with #382 and #384, before the repository moved its builds to CI; this PR's Corpus job re-runs it on this head and is the gate):

Header short Strings above ASCII, decoded Encode back to their bytes Hold U+FFFD Differ
38 (ANSI_932, Shift_JIS) 21 21 0 0
39 (ANSI_936, GBK) 16 12 4 0

The 21 Shift_JIS strings are the two Japanese layout names (five two-byte characters and a digit, each as a dictionary entry and as a LAYOUT object name) in the four AC1014 drawings and five more dictionary entries of 3d.dwg; the 12 GBK strings are the two layout names in the same two places. Every string that decodes without an invalid sequence encodes to the bytes it came from, including those whose trail bytes are ASCII letters. The 4 that hold U+FFFD are the four 1,028-byte non-text "descriptions" of the BLOCK_HEADER records that error (#386, the nine errored rows #384's baseline pins): bytes that are not text, counted and not encoded.

Why the round trip is exact on the WHATWG encoders: CodePage::encode_char returns bytes only when they decode back to the character (#382), which keeps extra mappings such as U+00A5 to 0x5C on Shift_JIS out; none of the pinned strings use them.

No decoded, skipped or errored count and no oracle row moves (probe and ARCHITECTURE.md only). README.md and STATUS.md are not touched.

Test plan

  • cargo fmt --all -- --check, python3 tools/ci/spec_coverage.py --check, python3 tools/maintainer/train/arch.py check and tools/streaming/check_invariants.py pass locally on this head; per the repository's new rule nothing was built or run on the maintainer's Mac for this head, so clippy, tests, the probe and the Corpus job run in CI
  • Shown working on real files: the probe numbers above, measured before this head on the merged probe; the Corpus job's probe_code_page step is the repeat
  • No new unit tests. Tests touched: none.

Source-provenance declaration

By submitting this PR I certify that my contribution does not incorporate executable code from any source whose license is incompatible with Apache-2.0. Specifically:

  • No Autodesk DWG SDK source (RealDWG, ObjectARX, ObjectDBX) or NDA-protected Autodesk documentation was consulted or imported.
  • No Open Design Alliance Teigha / Drawings SDK source was consulted or imported. The ODA's public Open Design Specification for .dwg files PDF is explicitly allowed (see CLEANROOM.md).
  • No GPL-licensed DWG implementation source (LibreDWG, etc.) was consulted or imported. This matters because dwg-rs is Apache-2.0 and must remain compatible.

My contribution is based on:

  • The ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1);
  • Public reverse-engineering notes, research papers, or blog posts cited inline;
  • Reading algorithm-description comments (not executable code) in permissively-licensed projects (MIT / Apache / BSD) to resolve spec ambiguities — disclose any such reading in this PR body so it can be recorded in CLEANROOM.md.

See CLEANROOM.md for the full allowed/forbidden source list and the honest scope of what "clean-room" means for this project.

For this PR specifically: the probe reads only pinned public drawings (CLEANROOM.md, 2026-10-27 entries); no source of any other DWG implementation was read.

Developer Certificate of Origin

By submitting this PR, I certify that the contribution complies with the
Developer Certificate of Origin 1.1.
Specifically, I affirm that the contribution is my own work (or rightfully
licensed to me) and that it can be distributed under the project's Apache-2.0
license.

I will sign off commits with git commit -s when asked, which adds a
Signed-off-by trailer to the commit message asserting the DCO.

…he pinned double-byte drawings (#375)

probe_code_page decodes every string of every pre-R2007 drawing and encodes the text back: Shift_JIS 21 of 21 strings return their bytes, GBK 12 of 12 (4 more hold an invalid sequence, the non-text BLOCK_HEADER descriptions of #386, and are counted, not encoded). The probe fails when a string that decodes cleanly encodes to other bytes.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T22:16:49.456593Z ee61911 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 27, 2026 22:21
@DrunkOnJava
DrunkOnJava merged commit 7f4d63c into main Oct 27, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the test/dbcs-roundtrip-main branch October 27, 2026 22:29
DrunkOnJava added a commit that referenced this pull request Oct 27, 2026
DrunkOnJava added a commit that referenced this pull request Oct 28, 2026
…10-27 (#416)

* docs: bring README, ROADMAP and CHANGELOG up to the landings of 2026-10-27

README's code-page and DXF writer text named work in review that has landed
(#371, #380, #382, #384); jev_review.py prose ranked those sentences 0.72 to
0.96. ROADMAP's "where it stands" table was a 2026-10-21 snapshot whose
numbers, CI row and release row were all out of date; it now points to the
rendered numbers instead of repeating them. CHANGELOG gains #371, #380, #382,
#384, #385 and #404.

* docs(changelog): record the CI-only merge train (#408)

* docs: OBJECTS landed (#372): README, ROADMAP and CHANGELOG

* docs: LAYOUT, GROUP and MLINESTYLE (#373), the class map writer (#405) and the double-byte round trip (#414) landed

* docs: VISUALSTYLE landed (#413)

* docs(readme): name the skipped types still in review without per-type counts; MATERIAL landed (#325)

* docs(readme): point to the open decoder PRs instead of a list that each landing makes stale
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