Skip to content

ci(corpus): measure the reader on public drawings fetched by pinned hash - #225

Merged
DrunkOnJava merged 7 commits into
mainfrom
ci/corpus-measure
Oct 26, 2026
Merged

DrunkOnJava merged 7 commits into
mainfrom
ci/corpus-measure

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

CI now reads real drawings: a Corpus (public DWG) job fetches 102 public files by pinned sha256, runs the five real-file test suites that used to skip, and ratchets every drawing's measurement against a committed per-file baseline; measure.yml compares any ref against a base on the same corpus. It also settles where sample_AC1032.dwg comes from.

Closes #96. Closes #154. Part of #94: #95 (the job is here; it becomes required once the live ruleset lists it, see below), #97 (README/STATUS numbers follow in a second PR that cites this job's run on main) and #98 (dispatch is verified after merge, since a new workflow can only be dispatched from the default branch).

What changed

  • tools/corpus/pins.tsv: one registry row per file: repository, commit, path, licence, authoring application, release, kind, size, sha256, git blob id, DXF twin, and whether the legacy tests use it. 42 DWG and 42 DXF from nextgis/dwg_samples @ ff05d5a8 (AutoCAD 2016, no licence stated); 10 DWG and 8 DXF from DomCR/ACadSharp samples/ @ c30a97ce (MIT): the R14 to R2018 saves of one drawing with their ASCII DXF exports (AutoCAD 2025), plus three more R2018 drawings, geoloc.dwg with its DXF and empty.dwg (AutoCAD 2023) and export_sample.dwg (AutoCAD 2025). Nothing is committed.
  • tools/corpus/fetch.py (stdlib only): downloads each file at its pinned commit from raw.githubusercontent.com, falls back to the git blobs API by blob id, retries each route, and keeps a file only if its size and sha256 match. Exit 0 verified, 1 mismatch or the commit no longer serves the file (fail closed), 69 host unreachable (the job reports NOT MEASURED). Its layout is <dest>/<source>/<file>, DXF twins alongside, so the DXF value oracle (Epic: AutoCAD's own DXF export as the value oracle #99) can read the same tree. --legacy-samples copies the 19 drawings tests/samples.rs and its siblings are written against to ../../samples. --cross-check fails the job unless every file a tools/streaming/*-corpus.json manifest names is pinned here with the same size and sha256, so the streaming E2E's copies of nextgis pins cannot drift; folding those manifests onto this registry is a follow-up after the streaming PRs land.
  • tools/corpus/measure.py: run executes coverage_report --tsv, probe_class_census and probe_reference_closure on every pinned DWG; check compares each file's decoded / skipped / errored / walk skips / handle mismatches / class-census shortfalls / inter-record bytes / decoded, unanswered and hard references with tools/corpus/baseline.tsv and fails on any difference, labelled REGRESSION or IMPROVED OR NEW (a change that moves a number commits the regenerated baseline in the same PR; the job uploads the proposed baseline.tsv as an artifact); diff and report write the Measure summary.
  • .github/workflows/ci.yml: the corpus job (corpus cached by the hash of pins.tsv; the real-file tests fail if any of them prints skipping).
  • .github/workflows/measure.yml: gh workflow run measure.yml -f ref=<ref> -f base=main builds both refs in one job and writes per-release, per-file and per-type differences to the summary; also runs on PRs that touch the measurement. Artifacts hold JSON and logs (corpus paths replaced by <corpus>), never a sample file. DXF oracle scores: NOT MEASURED until Epic: AutoCAD's own DXF export as the value oracle #99 lands.
  • examples/coverage_report.rs: --tsv <path> (per-file counts and per-file, per-type error and unhandled rows) and histograms that name every type instead of the top 10 / 15.
  • CLEANROOM.md: a "Public corpus" entry with both sources' licence, provenance and status; the allowed-sources bullet no longer says nextgis's terms permit redistribution (it states no licence). CONTRIBUTING.md: the fetch / measure / baseline commands replace the hand clone.
  • .github/rulesets/main-protection.json: adds Corpus (public DWG) to the required checks. The live ruleset is not changed by this PR.

Findings

  1. sample_AC1032.dwg is ACadSharp's (Establish the provenance of sample_AC1032.dwg, the one R2018 file #96): 1,081,979 bytes, sha256 0e8faaca…b528, git blob 4cfa790d6719acf3aad9818bacbd693ac3ab71b8, the blob samples/sample_AC1032.dwg holds at c30a97ce and on ACadSharp's master today. ACadSharp's samples/sample_base/save_samples.lsp saves one base drawing through AutoCAD's SAVEAS as R14 to R2018 DWG and as ASCII DXF, and every R2004+ file's AcDb:AppInfo reads build_version="V.162.0.0(x64)" registry_version="25.0". So the corpus now has the same drawing in seven releases, each with AutoCAD's DXF export except R14.
  2. That drawing exposes 285 errored records the old corpus never exercised: on R14 to R2004, TEXT (87), MTEXT (72), ATTDEF (15), ATTRIB (12), TOLERANCE (9); INSERT (12) and seven DIMENSION types on R14 only; DIMSTYLE on R2007 and R2010; and VIEWPORT, MESH and LEADER on every release. Per-type, per-release table in the job summary; issues follow with the CI run linked.
  3. The GitHub contents API's raw media type is not byte-exact: it served sample_AC1009_ascii.dxf with the ANSI_1252 byte 0xD8 re-encoded as UTF-8 C3 98 (596,017 bytes against the pinned 596,016), and the pin rejected it. That is why the routes are raw.githubusercontent.com and the git blobs API.
  4. Three more R2018 drawings: export_sample.dwg errors on 9 VIEWPORT, 4 TEXT and 1 HATCH records, the first TEXT and HATCH errors seen on R2018; geoloc.dwg declares 2 GEODATA and 1 AcGeoBackupObject and the walk reaches 1 and 0 (closure closed), and its 1 GEODATA has no decoder.
  5. ACDB_TEXTOBJECTCONTEXTDATA_CLASS is declared twice and walked zero times on ACadSharp's R2004 and R2007 saves, while probe_reference_closure finds both walks closed: a class-table over-declaration of the kind DICTIONARYVAR / CELLSTYLEMAP under-walk on R2004/R2007/R2010 (18 entries across 9 files) — pre-existing, now pinned by the census ratchet #76 settled, pinned in the baseline.
  6. Reference closure is NOT MEASURED on the eight R14 drawings (no handle-stream boundary, probe_reference_closure is blind on R13/R14 — no locatable handle stream boundary #84); the summary says so instead of counting them closed.

Spec reference

No decoder change. Measurement only.

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings: clean.
  • actionlint on both workflows: no finding in the new jobs.
  • Fetch, from an empty directory, anonymous: 98 of 98 pinned files verified (98 downloaded), 19 legacy files copied. Every downloaded file's git blob id equals the one in its commit's tree.
  • Fetch from a full cache with the network blocked (a dead https_proxy): exit 0, 0 downloaded.
  • A cached file with a byte appended: warned, fetched again, verified, exit 0.
  • A missing file with the host unreachable: exit 69.
  • A pin with a wrong sha256, and a pin naming a commit that does not exist: exit 1 with ::error:: naming each.
  • The blobs API route alone, byte-exact on the ANSI DXF, the 1 MB R2018 DWG and an R14 DWG.
  • The five suites on the fetched 19-file layout: samples 23, r2013_entity_values 15, block_names 5, corpus_roundtrip 5, class_census 1, all passed, and no line contains skipping.
  • measure.py run over 49 drawings: 0 measurement failures; check passes against the committed baseline; a baseline with one decoded count raised, one census entry raised, one errored count raised, one row removed and one ghost row added fails with each named as REGRESSION or IMPROVED OR NEW.
  • measure.py diff on a base with 29 TEXT errors added to one file reports +29 decoded / -29 errored on R2004 and the TEXT row.
  • The legacy 19-file subset reproduces the published local numbers exactly: 3,911 decoded / 525 skipped / 9 errored, 88.0 %.
  • The Corpus (public DWG) job on the first commit, on GitHub's runners (run 40296787615): 98 of 98 verified (restored from the cache the Measure job saved), the five suites passed (49 tests) with no skipping, every one of 49 baseline rows matched.
  • --cross-check with main's header-corpus.json and the walk-corpus.json / lz77-corpus.json on the streaming branches: all 37 entries agree; a manifest with one sha256 changed fails with the file named.
  • The Corpus (public DWG) and Measure jobs on the second commit (linked below).

Measured on 943eaeb plus this branch:

python3 -I tools/corpus/fetch.py --dest <corpus> --legacy-samples ../../samples
cargo build --release --example coverage_report --example probe_class_census --example probe_reference_closure
python3 -I tools/corpus/measure.py run --corpus <corpus> --bin target/release/examples --out results.json
python3 -I tools/corpus/measure.py check --results results.json
Release Files Decoded Skipped Errored Decoded %
R14 (AC1014) 8 1841 1351 105 55.8 %
R2000 (AC1015) 8 2337 145 51 92.3 %
R2004 (AC1018) 8 2218 109 90 91.8 %
R2007 (AC1021) 8 2090 132 15 93.4 %
R2010 (AC1024) 8 2088 85 15 95.4 %
R2013 (AC1027) 8 1693 85 9 94.7 %
R2018 (AC1032) 4 1514 78 23 93.7 %
All 52 13781 1985 308 85.7 %
Legacy 19-file corpus 19 3911 525 9 88.0 %
nextgis 42 7343 1100 0 87.0 %
ACadSharp 10 6438 885 308 84.4 %

The 24 nextgis drawings never measured before (ellipse, point2d, point3d, polyline2d_line in six releases) decode with 0 errors: 4,208 decoded / 632 skipped. They are gated like the rest.

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.

Disclosure: from DomCR/ACadSharp (MIT) only data was read: its sample DWG and ASCII DXF files, LICENSE, the commit history of samples/sample_AC1032.dwg, and samples/sample_base/save_samples.lsp (an AutoCAD command script with no DWG or DXF implementation), to establish provenance. No ACadSharp source code was opened. Recorded in CLEANROOM.md.

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.

A Corpus job in ci.yml fetches 98 public files (49 DWG, 49 DXF) from
nextgis/dwg_samples and DomCR/ACadSharp at pinned commits, verifies each
against its pinned size and sha256 (tools/corpus/pins.tsv), runs the five
real-file test suites that skip without a corpus on the 19 drawings they
are written for, and measures every pinned DWG with coverage_report,
probe_class_census and probe_reference_closure against a per-file
baseline that must match exactly (tools/corpus/baseline.tsv). A mismatched
file fails the job; an unreachable host is reported as NOT MEASURED.

measure.yml builds any ref and a base and reports the difference on the
same corpus, by dispatch or on a PR that changes the measurement.

sample_AC1032.dwg, the corpus's R2018 drawing of unrecorded origin, is
byte-identical to DomCR/ACadSharp samples/sample_AC1032.dwg at c30a97ce
(MIT, AutoCAD 2025 SAVEAS output); CLEANROOM.md records both sources.

coverage_report gains --tsv and prints every type in its histograms.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-26T10:01:34.369656Z 05fd1c4 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.

@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: f3edbc301d

ℹ️ 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 .github/workflows/measure.yml Resolved
Comment thread tools/corpus/fetch.py Resolved
…pins, keep Measure running past an unmeasurable base
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 09:56
… the job's time limit

Every request's timeout and back-off is cut to an overall --deadline (900 s by default), and once three files in a row are unreachable the rest are reported unreachable without being requested. Before, an empty cache behind a host-wide outage made 588 timed-out requests (about 9.8 hours), so the job hit its 40-minute limit and the required check failed instead of reporting NOT MEASURED.

Measured with the real CLI against an empty --dest:
- proxy refusing connections: exit 69 after 36 s, 3 files tried, 99 not requested
- proxy black-holing connections, --deadline 20: exit 69 after 20 s
- normal network: 102 of 102 pinned files verified, exit 0, 25 s
@DrunkOnJava
DrunkOnJava merged commit 2e9f7e2 into main Oct 26, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the ci/corpus-measure branch October 26, 2026 10:07
DrunkOnJava added a commit that referenced this pull request Oct 26, 2026
…es (#246)

* feat(streaming): bounded, resumable LZ77 decoder for R2004-family pages

Lz77Decoder decodes one §4.7 stream from any prefix of its compressed
bytes into an output slice of any size, and can pause between any two
calls. Its only page state is a fixed 0xC000-byte window: with the
crate's measured distance rules (+0x4000 for 0x10-0x1F, +1 otherwise,
bit 3 of 0x12-0x1F as distance bit 14) no back-reference reaches
further, so no page, including a system page with no declared cap,
needs more. The declared decompressed size is a hard ceiling; reserved
opcodes, distances before the first byte, overruns and streams cut
before 0x11 are typed terminal errors. It compiles in the no_std,
no-allocator kernel natively and for wasm32, bounded at WINDOW + 128.

Lz77Checkpoint carries the opcode cursor, pending run, totals and the
last min(produced, 0xC000) output bytes under a CRC-32; restore checks
length, version and CRC before copying and then requires a reachable
state.

stream_lz77 decodes every compressed page of an R2004-family file (page
map, section map, every LZ77 data page). verify_lz77.py runs it on the
four canonical R2004-family fixtures and every R2004, R2010 and R2013
file in the pinned nextgis/dwg_samples commit: 25 files, 266 pages,
6,097,392 bytes, equal to lz77::decompress and to an independent Python
parse (length, CRC-32, bytes consumed through 0x11). Fixed and proptest
schedules down to one byte in and out reproduce the output; fresh-process
resume inside the largest data page leaves no source byte read twice and
no output duplicated; corrupt, truncated and resealed checkpoints and
four stream corruptions end in their named errors. It runs in the
required Streaming E2E job.

Every AutoCAD-written page decompresses to its declared size and every
stream ends 11 00 00; the crate's writer does neither (recorded on #163).

Refs #205, #207

* fix(streaming): typed error, not overflow, for a forged LZ77 input count

A CRC-valid decoder checkpoint may carry any consumed count; restore
only required it to be non-zero. The next literal or opcode byte then
added to it unchecked: a panic in debug builds, a wrapped input position
in release. consumed is now accumulated with checked_add before any
state moves, and the overflow is StreamError::CounterOverflow, terminal
like every other decoder error.

Audit of every restored counter: produced cannot pass its limit, since
restore and each transition keep every pending run within limit -
produced; acc is saturating and bounded by the limit; count and distance
are bounded by consistent(). The walk cursors are bounded by
consistent() against the verified u32 locators, and both header parsers
are rebuilt by replay.

stream_lz77 gains --decode-checkpoint <path> --input <hex>, which feeds a
restored decoder directly, and its own resume check no longer trusts the
caller file's counters. verify_lz77.py now forges consumed = 2^64 - 1 in
a literal run and at an opcode (both end in CounterOverflow, with no
panic) and decodes a literal run that ends exactly at a limit of
2^64 - 1.

Reported by the review on #246.

* docs(streaming): the R2018 sample is now pinned by #225, not local only
This was referenced Oct 26, 2026
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.

A corpus registry and fetch script Establish the provenance of sample_AC1032.dwg, the one R2018 file

1 participant