Skip to content

fix(rvt-dump): write exactly the bytes the parsers read - #291

Merged
DrunkOnJava merged 1 commit into
mainfrom
fix/rvt-dump-canonical-decode
Sep 22, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
fix/rvt-dump-canonical-decode

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

rvt-dump now writes exactly the bytes the parsers read. Before this, multi-page streams failed or lost data, and partition offsets never lined up with the offsets used by the scanners and by the reports/ write-ups.

Motivation

rvt-dump is the reverse-engineering entry point: dump the streams, then hex-dump or diff them. It inflated every stream without stripping Revit's per-page checksum trailers (65,249-byte pages carrying a 64,896-byte payload). That caused three problems:

  • Snowdon Towers' Global/ElemTable (275,077 bytes stored) failed to inflate and was reported as "no gzip magic found".
  • Its Partitions/68 lost every gzip member that straddled a page boundary and came out 10.5 MB short (431,609,166 bytes including separators, against 442,153,012 real).
  • Partitions were joined with 16-byte 0xFF separators, so no offset in a dump matched RevitFile::inflated_partition.

Changes

  • src/bin/rvt_dump.rs:
    • Non-partition streams go through compression::prepare_stream_for_inflate (page-aware) before inflating.
    • Partitions_NN.decomp is RevitFile::inflated_partition verbatim, and the gzip member count is printed.
    • Empty, uncompressed and failed streams are each reported as such, instead of all showing "no gzip magic found".
  • tests/rvt_dump_cli.rs (new): byte equality with the library view on the tier-1 fixture. Corpus-gated on 2024_Core_Interior.rvt: every partition matches and ElemTable is 1,057,030 bytes, the length the parser reads.
  • CHANGELOG.

Testing

  • cargo test --profile ci --test rvt_dump_cli --test cli_ergonomics with RVT_PROJECT_CORPUS_DIR (9 passed)
  • cargo clippy --all-targets --all-features -D warnings, cargo +1.85.0 check --all-targets (MSRV)
  • Local-only: Snowdon Towers architectural ElemTable now dumps 1,889,350 bytes (matches rvt-elem-table), and Partitions/68 dumps 442,153,012 bytes in 4,604 members

Audit-honesty checklist

  • README / docs reflect the current state after this PR
  • If a limitation was resolved, the "Known limitations" / "What works today" section in the relevant docs is updated (N/A: rvt-dump had no documented limitation)
  • Commit messages describe WHAT changed and WHY
  • No emojis in code, docs, or commit messages
  • No private paths, personal email addresses, or internal jargon in committed files
  • N/A: not a reverse-engineering finding

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0 (see CONTRIBUTING.md)
  • This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content (see CLEANROOM.md)
  • Test fixtures: tier-1 synthetic; the magnetar project (MIT) is corpus-gated, not committed

Breaking changes

Partitions_NN.decomp no longer contains 16-byte 0xFF separators between gzip members. Offsets now match the library and the reports.


Note

Medium Risk
Changes decompression semantics and partition .decomp layout (offset compatibility improves but old separator-based tooling breaks); behavior is regression-tested against the library view.

Overview
rvt-dump now emits the same decompressed bytes the library parsers consume, instead of raw gzip inflation that ignored Revit’s paged-stream framing.

Non-partition streams go through compression::prepare_stream_for_inflate before inflate; Partitions/* use RevitFile::inflated_partition directly, so .decomp output is a straight concatenation of gzip members with no 16-byte 0xFF separators (breaking change for anyone who relied on the old layout). CLI logging distinguishes empty, not compressed, and inflate-failed streams, and prints gzip member counts when relevant.

tests/rvt_dump_cli.rs runs rvt-dump on the tier-1 fixture and (when RVT_PROJECT_CORPUS_DIR is set) on Core Interior, asserting partition dumps match the library and Global_ElemTable.decomp length matches the ElemTable header. CHANGELOG documents the fix.

Reviewed by Cursor Bugbot for commit 6bc6198. Configure here.

rvt-dump inflated every stream without stripping Revit's per-page
checksum trailers. A multi-page stream either failed outright (Snowdon
Towers' Global/ElemTable was reported as "no gzip magic found") or lost
every gzip member straddling a page boundary (that file's Partitions/68
came out 10.5 MB short), and partitions were joined with 16-byte 0xFF
separators, so dump offsets never matched the scanners' or the reports'.

Non-partition streams now go through prepare_stream_for_inflate before
inflating; Partitions_NN.decomp is RevitFile::inflated_partition verbatim,
with the gzip member count printed. Empty, uncompressed and failed
streams are reported as such. tests/rvt_dump_cli.rs pins byte equality
with the library view on the tier-1 fixture and, corpus-gated, on
2024_Core_Interior.rvt (ElemTable 1,057,030 bytes).
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) September 22, 2026 20:14
@cursor

cursor Bot commented Sep 22, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_02bf09d8-ee72-40be-a04f-b63b2d9559c7)

@DrunkOnJava
DrunkOnJava merged commit 15ac56a into main Sep 22, 2026
22 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/rvt-dump-canonical-decode branch September 22, 2026 20:17
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