Skip to content

test(streaming): restore a native checkpoint in a wasm32 kernel and the reverse - #301

Merged
DrunkOnJava merged 2 commits into
mainfrom
feat/streaming-wasm-restore
Oct 26, 2026
Merged

DrunkOnJava merged 2 commits into
mainfrom
feat/streaming-wasm-restore

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

A no_std wasm32 kernel built from the identical grammar files restores a checkpoint made by a native build and finishes the walk, and makes a map-walk checkpoint a native build restores; node drives it, verify_wasm.py is the acceptance run and it joins the Streaming E2E job. Refs #207.

Spec reference

ODA v5.4.1 §4.3–§4.6 walks only (no new format feature). Adds R2004SectionWalker::section_id(), which the kernel prints.

Test plan

  • tools/streaming/verify_wasm.py on the canonical R2018 fixture and line_2004, line_2010, line_2013 (plus a built file for the section walk): every native DWGM checkpoint (every step of the fixture, about 40 sampled per real file) restored in the kernel, reading at 1, 7, 64 or 256 bytes, finishes with the lines the native resume prints; the kernel's own checkpoint at the same step is byte-identical to the native one (173, 43, 44, 43 of 173, 43, 44, 43) and the native build resumes it to the uninterrupted run's output; about 90 native DWGS checkpoints per file restored in the kernel finish their section with the native resume's lines and a CRC-32 equal to verify_sections.py's independent assembly; 63 sampled bit flips and a wrong identity per walk are refused by the kernel (code -1).
  • No unit test added. The kernel is compiled by rustc --target wasm32-unknown-unknown inside the verifier, under node (V8), not a browser; the section walk crosses runtimes in one direction only.
  • fmt, clippy, doc, cargo +1.85 check, check_invariants.py, no_std.rs native and wasm32 unchanged.

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);
  • Measurement of the pinned public corpus (no algorithm-description comments of other projects were read for this change).

…he reverse

tools/streaming/wasm_resume.rs is a #![no_std] module built from the
identical grammar files for wasm32-unknown-unknown. A host copies the
source bytes, a checkpoint and the caller's cursors into its scratch
memory and calls resume_maps (a DWGM checkpoint), resume_section (a DWGS
checkpoint, given the section's rows of the caller's page index) or
run_maps (walk some steps, leave a DWGM checkpoint), and reads back the
JSON lines the native examples print. wasm_resume.mjs drives it under
node with a fresh instance per job; verify_wasm.py is the acceptance run.

On the canonical R2018 fixture and three real files: every native
map-walk checkpoint (every step of the fixture, about 40 sampled per real
file) restored in the kernel, reading at 1, 7, 64 or 256 bytes at a time,
finishes with the lines the native resume prints; the kernel's own
checkpoint at the same step is byte-identical to the native one and the
native build resumes it to the uninterrupted run's output. About 90 native
data-page checkpoints per file, around every page, hole and section end,
restored in the kernel finish their section with the native resume's
lines and a CRC-32 equal to the independent assembly. Sampled bit flips
and a wrong identity are refused by the kernel as by the native build.
It runs in the Streaming E2E job.

R2004SectionWalker gains section_id(), which the kernel prints.

Refs #207
@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-26T13:57:55.908669Z 0121fa7 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: d56966c347

ℹ️ 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 tools/streaming/verify_wasm.py Resolved
Comment thread tools/streaming/wasm_resume.rs Resolved
… in the kernel, and split its scratch memory

verify_wasm.py let a kernel that returned empty output pass for a
section checkpoint: an empty list equals the zero-length native prefix and
the completion and CRC assertions were skipped. It now records each saved
checkpoint's stage and requires every one that is not already finished to
run through its section_done, equal to the independent assembly's, and a
finished one to produce nothing; the count of sections the kernel finished
must equal the number of unfinished checkpoints.

wasm_resume.rs made a mutable reference to the whole scratch array on every
helper call while the table and label slices still borrowed it, which
violates Rust's aliasing rules. Each export now splits the scratch memory
once into disjoint source, checkpoint, digest, table and output slices and
passes them to the helpers; the output writer owns its slice.

Reported by the review on #301.
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