Skip to content

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

Merged
DrunkOnJava merged 21 commits into
mainfrom
fix/block-header-r2004-tail
Oct 27, 2026
Merged

DrunkOnJava merged 21 commits into
mainfrom
fix/block-header-r2004-tail

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #386. A BLOCK_HEADER with more than 257 inserts errored: §20.4.52's "Insert Count" is a run of non-zero RCs ended by a zero, one per insert handle, and the decoder stopped reading it after 257, so the description, the preview size and everything after were read from inside the run. Both decode paths (R2004 and earlier inline, R2007 and later from the data stream) now read the run to its zero, bounded by the record's own bytes. The nine records that #384 pinned as errors, in four Seeed-Studio/OSHW-Jetson-Series drawings (Apache-2.0, saved as R2004 by AutoCAD I.18.0.0), all decode now.

Stacked on #384 (feat/code-page-rows, merged at bd1ef13), whose pins and baseline rows these records are; it goes behind #384 in the train, and the baseline here differs from #384's only in the three drawings' rows.

Spec reference

ODA v5.4.1 §20.4.52 BLOCK HEADER: "Insert Count: a sequence of zero or more non-zero RC's, followed by a terminating 0 RC. The total number of these indicates how many insert handles will be present."

  • src/tables/block_record.rs: the run read to its zero (the 256 cap and its constant are gone).
  • examples/probe_block_header_inserts.rs: the evidence, wired into the Corpus job (.github/workflows/ci.yml).
  • tools/corpus/baseline.tsv: the three drawings' rows regenerated; docs/data/spec-coverage.tsv note for §20.4.52.
  • ARCHITECTURE.md 7av: the finding with its evidence tables.

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • Shown working on real files, no new unit tests: probe_block_header_inserts decodes every BLOCK_HEADER of the pinned corpus and compares the run with the record's own handle stream (block control, reactors, extension dictionary, NULL, the owned entities, ENDBLK, one handle per insert, the layout), a second count of the same run that reads none of its bytes. All 2,953 records of the 49 drawings from R2000 to R2018 decode and agree. Exit 0:
release         records  decoded    agree  run > 256  longest
AC1015 (2000)        51       51       51          0       10
AC1018 (2004)      2715     2715     2715          9    29895
AC1021 (2007)        48       48       48          0       10
AC1024 (2010)        48       48       48          0       10
AC1027 (2013)        48       48       48          0       10
AC1032 (2018)        43       43       43          0       10

The nine runs over 256 are the nine records that errored (insert handles 260 to 29,895; each record's error before the fix, its handle and block are in the ARCHITECTURE table). probe_decode_errors lists no erroring BLOCK_HEADER in any of the four drawings.

  • python3 -I tools/corpus/measure.py run then check against the regenerated baseline: 0 errored in all 61 drawings, exit 0. The baseline changes only A205_TOP (35,002 decoded, 5 errored to 35,007, 0), A206_TOP (50,626, 3 to 50,629, 0) and A206_BOTTOM (13,367, 1 to 13,368, 0).
  • python3 tools/maintainer/train/arch.py check and python3 tools/ci/spec_coverage.py --check: 0 problems.
  • cargo test --release --all-features: 921 passed, 0 failed (26 result lines) on a127bea, before feat(code_page): name the header shorts 28 to 41 that real drawings prove, and pin three public sources (§3.2.5, #375) #384's rebuilt head (bd1ef13) was merged in; the merged head 8a788c2 re-ran the probes, measure.py check and fmt, and CI runs the full suite once the PR targets main.
  • Not measured on the corpus: the values of these nine records against an AutoCAD DXF export (none of the four drawings has one; the boundary and the handle stream are the evidence), and a run over 256 in an R2007 or later drawing (the longest there is 10; the same change applies).

Existing tests and code changed

No existing test changed. MAX_INSERT_COUNT is removed.

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 (v5.4.1) is the source for §20.4.52.
  • No GPL-licensed DWG implementation source (LibreDWG, etc.) was consulted or imported.

The only other inputs are the public corpus. No algorithm-description comments in other projects were read.

Developer Certificate of Origin

I affirm the contribution is my own work and may be distributed under the project's Apache-2.0 license.

…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.
… 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.
@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-27T20:18:25.422764Z 7cb61eb 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.

# 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
DrunkOnJava marked this pull request as draft October 27, 2026 18:48
Base automatically changed from feat/code-page-rows to main October 27, 2026 19:45
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review October 27, 2026 19:46
# Conflicts:
#	ARCHITECTURE.md
#	tools/corpus/baseline.tsv

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9361390e67

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/tables/block_record.rs Resolved
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.
# Conflicts:
#	README.md
#	STATUS.md
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 27, 2026 20:23
@DrunkOnJava
DrunkOnJava merged commit 533fbab into main Oct 27, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/block-header-r2004-tail branch October 27, 2026 20:35
DrunkOnJava added a commit that referenced this pull request Oct 27, 2026
… a stacked PR's ARCHITECTURE.md (#415)

* fix(ci): drop the sections main already holds when the train resolves a stacked PR's ARCHITECTURE.md

A PR stacked on another carries the lower PR's ARCHITECTURE.md sections; once
that PR squash-lands, merging main into the upper one conflicts where both
appended, and arch.py resolve appended main's copy and then the PR's, so the
section came twice and the Spec coverage job's order check failed (#388 had
two §7au on 2026-10-27). resolve now drops each whole section of the PR's side
that main's file already holds word for word.

* fix(ci): drop a stacked PR's section only when it equals one of main's whole sections

Codex on #415: the substring test dropped a PR section whose text is a prefix
of main's ("Decoded records: 10" against main's "100"). resolve now splits
main's file into whole sections, heading to the next heading, and drops only a
PR section equal to one of them; a differing copy is kept, and the order check
then names the repeated suffix for a person to settle.
DrunkOnJava added a commit that referenced this pull request Oct 27, 2026
…ce the Corpus job passes (#418)

* fix(ci): settle a Codex thread that asks for the measured baseline once the Corpus job passes

The train's merge of main carries main's baselines until the PR's own CI run
measures the merge, and Codex reviews that intermediate commit and asks for
the regenerated baseline (#325 and #388 on 2026-10-27). The train then commits
the measured baseline, but the open thread kept the PR from landing until a
person answered it. With the Corpus job green on the current head, whose
ratchet is exactly that check, land.sh replies and resolves such threads; it
touches only the Codex bot's threads that name tools/corpus or
tools/oracle/baseline.tsv.

* fix(ci): settle only a Codex thread whose title asks to regenerate the corpus baseline

Codex on #418: naming a baseline file is not enough; a finding about weakened
or retired oracle comparisons passes a green Corpus job (oracle_base.py lets
the PR's retired rows go) and must keep stopping the train. The thread's title
must now ask to regenerate or re-measure the corpus baseline, its text must
name tools/corpus/baseline.tsv, and it must not mention the oracle.
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.

BLOCK_HEADER errors on 9 R2004 records of AutoCAD I.18 drawings: a 1,028-byte non-text description (§20.4.52)

1 participant