Skip to content

feat(code_page): name the header shorts 28 to 41 that real drawings prove, and pin three public sources (§3.2.5, #375) - #384

Merged
DrunkOnJava merged 11 commits into
mainfrom
feat/code-page-rows
Oct 27, 2026
Merged

DrunkOnJava merged 11 commits into
mainfrom
feat/code-page-rows

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Names eight more pre-R2007 code pages (#375, "table rows backed by real drawings" and "the new pins"): header shorts 28 (ANSI_1250), 32 (1253), 33 (1254), 36 (1257), 38 (Shift_JIS, 932), 39 (GBK, 936), 40 (EUC-KR, 949) and 41 (Big5, 950). The short is AutoCAD's own enumeration, not a Windows code page number (38 is 932, 39 is 936), so each row is backed by a drawing, not by a number from anywhere. Nine public drawings are pinned (three MIT and Apache-2.0 repositories), tools/corpus/fetch.py percent-encodes the path of a file (spaces and Chinese in the new ones), and examples/probe_code_page.rs gains the checks that prove the rows.

Spec reference

ODA spec v5.4.1 §3.2.5 (the short at 0x13; the spec prints no table of its values). ARCHITECTURE.md §7ar (provisional letter; the integrator renumbers when #382 lands first). CLEANROOM.md 2026-10-27 entry for the new pins and the local evidence.

Corpus measurement: tools/corpus/measure.py over the 61 pinned drawings (52 + 9). The 52 existing rows are unchanged; the nine new rows (tools/corpus/baseline.tsv, regenerated from the corpus-measurement artifact of this PR's first Corpus run, which was red by design) decode 106,189 records, skip 90 and error on 9: all BLOCK_HEADER records of the four Seeed AC1018 drawings (5 in A205_TOP, 1 in A206_BOTTOM, 3 in A206_TOP; build I.18.0.0). The baseline pins them; the cause is outside this PR (below).

Evidence (probe_code_page, 2026-10-27):

Rows Evidence Result
38 the Japanese layout name レイアウト1 decodes in the pinned AC1014 drawings (kurema/BookViewerApp3, MIT) 4 of 4 (the probe fails below that)
39 the Chinese layout name 布局1 decodes in the pinned AC1018 (Seeed-Studio/OSHW-Jetson-Series, Apache-2.0) and AC1015 (huifer/planar_algorithm, Apache-2.0) drawings 5 of 5
28, 33, 36, 41 a DXF twin of the same drawing names the page (local, sha256 in ARCHITECTURE.md) 1, 1, 3 and 2 drawings agree, 0 differ; 41: 8 of 8 distinct Big5 strings occur in the export
32 Greek words decode (local, 14 drawings of five municipalities' open data) 10 of 14 (the other four hold none of the five words probed)
40 the Korean layout name 배치1 decodes (local) 4 distinct drawings of 4
29, 30 on every release the header short of each of the 52 pinned drawings against its export, now R2007 and later too 29: 35 drawings, 30: 7, 0 differ

Caveats, said in ARCHITECTURE.md: rows 28 and 33 rest on the twin alone (no byte above 0x7F in either export); row 36 is the weakest (the DXFs are another save of each drawing, and the only non-ASCII text is a degree sign, equal in 1252 and 1257); the \U+XXXX escape is how an application writes a character outside the page, on R14 as on R2004 (Greek and Chinese drawings), and \M+ appears in none of the strings of the 61 pinned or the local drawings. Left out: Xinyuan-LilyGO/T-Dongle-S3 (its AcDb:AppInfo names Teigha 19.7 as the writer, not AutoCAD), the three icon.dwg of BookViewerApp3 (the corpus keys files by name), and rows 34, 35 and 37 (no pre-R2007 drawing). No file of a GPL-licensed repository is evidence for any row.

Owed: the double-byte round trip over real strings needs CodePage::encode from #382. The nine BLOCK_HEADER errors are a decoder defect the new pins expose, not a code page one: the probe lists their 1,028-byte non-text "descriptions" among the non-ASCII strings, so the R2004 BLOCK_HEADER tail after the insert-count run reads from the wrong place for these blocks (ARCHITECTURE.md, Counts and Owed).

README.md and STATUS.md are not refreshed here: tools/maintainer/readme_status.py is not on main yet (#376 adds it), so the integrator regenerates them after this lands.

Test plan

  • cargo fmt --all -- --check, python3 tools/ci/spec_coverage.py --check, python3 tools/maintainer/train/arch.py check pass locally on this head; clippy, tests, MSRV, wasm, deny and doc run in CI on this head (the local lease queue is long)
  • Shown working on real files: probe_code_page over the pinned corpus (exit 0) and over a directory of the local-evidence drawings (numbers above); tools/corpus/fetch.py --dest ../dwg-corpus downloads and verifies all 111 pinned files (9 new, sha256 checked)
  • tools/corpus/baseline.tsv regenerated (second commit)
  • 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 rows come from the header shorts of public drawings against the $DWGCODEPAGE of their DXF twins, or against known texts (a localized layout name, Greek words); the pins are data files, no source code of the three repositories was read (CLEANROOM.md, 2026-10-27). The bytes of a string are decoded with the encoding_rs crate's WHATWG tables (already a dependency since #374). Local-only drawings are not pinned, vendored or committed; their sha256 and the probe's result are recorded.

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.

…s (§3.2.5, #375)

CodePage::encode is decode's inverse (a character the page holds is its byte, any other the \U+XXXX escape AutoCAD's own R2000 and R2004 saves hold). convert_dwg_to_dxf_bytes and dwg-to-dxf write R12 to R2004 in the drawing's page, the class table writer encodes through the page in force, and the R2004-family header carries the page again, so DwgFile::to_bytes keeps the text readable.
… it (#375)

The WHATWG encoders map a few extra code points onto bytes the decoder reads as another character (U+00A5 to 0x5C and U+203E to 0x7E on Shift_JIS, U+0080 on Shift_JIS, U+20AC on GBK). encode_char now returns the bytes only when decode gives the character back, so those characters take the escape and a written string reads as the text it was. The 128 of 128 round trip of each named page in probe_code_page is the same check over the whole page.
…rove, and pin three public sources (§3.2.5, #375)

The short at 0x13 is AutoCAD's own enumeration, not a Windows code page number. Eight rows are added, each backed by a drawing: 38 and 39 by the localized layout name decoding in the nine newly pinned drawings (kurema/BookViewerApp3 MIT, Seeed-Studio/OSHW-Jetson-Series and huifer/planar_algorithm Apache-2.0), and 28, 32, 33, 36, 40 and 41 by local-only evidence recorded by sha256 in ARCHITECTURE.md (DXF twins that name the page, Greek and Korean text). fetch.py percent-encodes the path of a file. The probe pairs the header short of every release with its export, checks the known texts, counts the strings that occur in the export, and lists the drawings whose strings hold a \U+ or \M+ escape.
@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-27T19:32:11.078695Z d41bb05 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.

… errors included (#375)

Regenerated from the corpus-measurement artifact of the Corpus job: the 52 existing rows are unchanged, the nine new rows decode 106,189 records, skip 90 and error on 9 BLOCK_HEADER records of the four AutoCAD I.18.0.0 drawings, which ARCHITECTURE.md now says.
…section (#375)

The two references said 7aq, which on main is the PERSSUBENTMANAGER section; the rows section is 7ar.
# Conflicts:
#	ARCHITECTURE.md
#	examples/probe_code_page.rs
# Conflicts:
#	ARCHITECTURE.md
#	examples/probe_code_page.rs
…and extended data strings included (#375)

With #380 on main the probe also patches XRECORD and extended data strings, and the R2004 drawings through the DWG writer: 266 strings in 27 kinds, 1,064 of 1,064 reads, 348 of 348 DXF name checks; XRECORD values 24 strings 96 of 96, extended data 3 strings 12 of 12.
…t/code-page-rows

# Conflicts:
#	ARCHITECTURE.md
#	CLEANROOM.md
#	examples/probe_code_page.rs
# Conflicts:
#	ARCHITECTURE.md
#	CLEANROOM.md
#	examples/probe_code_page.rs
DrunkOnJava added a commit that referenced this pull request Oct 27, 2026
…an drawing (#404)

The record-weighted aggregate moves when a source of large drawings is
pinned: #384's nine drawings hold 106,189 records, seven times the 52 on
main, and would lift the headline from 96.7 % to 99.5 % with no decoder
changing. readme_status.py now renders a per-source table and a median
drawing column, and stops rounding a rate with records left undecoded to
100.0 %.
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 27, 2026 19:34
@DrunkOnJava
DrunkOnJava merged commit 203daeb into main Oct 27, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/code-page-rows branch October 27, 2026 19:45
DrunkOnJava added a commit that referenced this pull request Oct 27, 2026
… PRs until retargeted (#408)

* fix(ci): keep the merge train's order when a build gets no lease, and hold stacked PRs

A lease the governor refuses is refused to every build on the machine, so
sending the PR to the end of the queue only reordered it: #384 lost the head
of the queue twice on 2026-10-27 and a PR stacked on it (#388) came up first.
A deferred PR now stays at the front and is retried after TRAIN_LEASE_WAIT
seconds, and a PR whose base is not main waits at the end of the queue until
GitHub retargets it.

* fix(ci): run the merge train on GitHub Actions only, building and testing nothing locally

Griffin, 2026-10-27: "tests and builds should ONLY be running on a github
runner and NEVER on this mac". refresh.sh now only merges main, resolves the
generated files to main's and pushes. land.sh waits for the PR's own CI run;
when the Corpus job fails because the merge decodes other counts than the
committed baseline, ci_baseline.sh downloads that run's corpus-measurement
artifact, refuses any count worse than main's baseline, commits the measured
baseline and waits again. The DRY refresh, which rebuilt locally to decide
whether a PR survived main moving, is gone: main moving refreshes the PR, and
the lease retry is gone with the local build.

* fix(ci): check every CI measurement against main, commit the oracle baseline it measured, re-run cancelled runs

Codex on #408: a Corpus job that passes compares the merge only with the PR's
own baseline, so a PR committing worse counts would land; and a refresh that
took main's oracle TSV on a conflict silently dropped the PR's new rows, or
failed for good on a retired field. ci_baseline.sh now runs on every finished
Corpus job: it refuses any corpus count below main's baseline and any oracle
agreement below main's less the rows the PR retired (oracle_base.py, with the
PR head and merge base refresh.sh records), then commits the corpus baseline,
oracle.tsv and the oracle's coverage notes when they differ. land.sh re-runs a
run that was cancelled to free the runners.

* chore(corpus): commit the baselines CI run 40572161277 measured

* fix(ci): keep README coverage current through the train, and judge a measurement against the main it was refreshed onto

Codex on #408: when main lands an improvement while a PR's CI runs, the older
measurement compared with the newer baseline is refused as a regression and
the PR is dropped. ci_baseline.sh now compares with the main recorded at the
refresh (oracle_base.py takes it too); land.sh's moved-main check refreshes
the PR when main has moved.

With some 25 decoder PRs to land, README.md and STATUS.md would go stale on
every landing: ci_baseline.sh renders their coverage again (readme_status.py,
citing the PR's own CI run) whenever it disagrees with the baselines, and
refresh.sh resolves a README or STATUS conflict to main's when every
conflicting line is rendered coverage text (readme3.py), refusing any other.
DrunkOnJava added a commit that referenced this pull request Oct 27, 2026
….52, #386) (#388)

* feat(writer): write the drawing's code page, not UTF-8 or bare escapes (§3.2.5, #375)

CodePage::encode is decode's inverse (a character the page holds is its byte, any other the \U+XXXX escape AutoCAD's own R2000 and R2004 saves hold). convert_dwg_to_dxf_bytes and dwg-to-dxf write R12 to R2004 in the drawing's page, the class table writer encodes through the page in force, and the R2004-family header carries the page again, so DwgFile::to_bytes keeps the text readable.

* fix(code_page): encode a character only when its bytes decode back to it (#375)

The WHATWG encoders map a few extra code points onto bytes the decoder reads as another character (U+00A5 to 0x5C and U+203E to 0x7E on Shift_JIS, U+0080 on Shift_JIS, U+20AC on GBK). encode_char now returns the bytes only when decode gives the character back, so those characters take the escape and a written string reads as the text it was. The 128 of 128 round trip of each named page in probe_code_page is the same check over the whole page.

* feat(code_page): name the header shorts 28 to 41 that real drawings prove, and pin three public sources (§3.2.5, #375)

The short at 0x13 is AutoCAD's own enumeration, not a Windows code page number. Eight rows are added, each backed by a drawing: 38 and 39 by the localized layout name decoding in the nine newly pinned drawings (kurema/BookViewerApp3 MIT, Seeed-Studio/OSHW-Jetson-Series and huifer/planar_algorithm Apache-2.0), and 28, 32, 33, 36, 40 and 41 by local-only evidence recorded by sha256 in ARCHITECTURE.md (DXF twins that name the page, Greek and Korean text). fetch.py percent-encodes the path of a file. The probe pairs the header short of every release with its export, checks the known texts, counts the strings that occur in the export, and lists the drawings whose strings hold a \U+ or \M+ escape.

* test(corpus): ratchet the nine new pinned drawings, nine BLOCK_HEADER errors included (#375)

Regenerated from the corpus-measurement artifact of the Corpus job: the 52 existing rows are unchanged, the nine new rows decode 106,189 records, skip 90 and error on 9 BLOCK_HEADER records of the four AutoCAD I.18.0.0 drawings, which ARCHITECTURE.md now says.

* docs(code_page): point the module docs at this change's ARCHITECTURE section (#375)

The two references said 7aq, which on main is the PERSSUBENTMANAGER section; the rows section is 7ar.

* fix(tables): read the whole insert-count run of a BLOCK_HEADER (§20.4.52, #386)

* docs(architecture): the merged probe's patched-copy numbers, XRECORD and extended data strings included (#375)

With #380 on main the probe also patches XRECORD and extended data strings, and the R2004 drawings through the DWG writer: 266 strings in 27 kinds, 1,064 of 1,064 reads, 348 of 348 DXF name checks; XRECORD values 24 strings 96 of 96, extended data 3 strings 12 of 12.

* docs(arch): number the BLOCK_HEADER section after the code page sections (#386)

* chore(corpus): commit the baselines CI run 40573732934 measured

* docs(architecture): drop the second copy of section 7au the merge with #384's squash appended

* chore(corpus): commit the baselines CI run 40576136864 measured
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