Skip to content

test(cli): six CLIs run end to end on real Revit files; rvt-write refuses a patch spanning a checksummed page (B53, B69) - #653

Merged
DrunkOnJava merged 5 commits into
mainfrom
feat/b53-cli-real-files
Oct 4, 2026
Merged

DrunkOnJava merged 5 commits into
mainfrom
feat/b53-cli-real-files

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

B53: tests/cli_real_files.rs gives rvt-elem-table, rvt-history, rvt-analyze, rvt-diff, rvt-ifc-compare and rvt-write their first real-file checks (family corpus and RE1 Architecture with Revit's export). Red with one injected fault per binary on draft #648 (run 37213954071); the outputs are in the test commit.

B69: without faults (draft #650, run 37213958029) the rvt-write test failed on main: an identity patch of a family's Formats/Latest exited 0 and the stream read back as 'unexpected end of file'. Revit stores these streams in 65,249-byte pages, each ending in a 353-byte checksum rvt-rs cannot compute, and the reader strips one at every full page. The writer now refuses (Error::WriteRefused) a patch whose stored bytes reach a full page, instead of writing a stream no reader can decode.


Note

Medium Risk
Changes core write-path behavior for common streams and adds broad CLI corpus tests that gate CI when corpora are present.

Overview
rvt-write (B69) now refuses patches whose framed stored bytes would reach a full 65,249-byte checksummed page on paged streams such as Formats/Latest and Global/Latest, returning Error::WriteRefused (write refused: ...) before any output file is touched. Patches are framed up front via framed_patch_bytes, so a refusal cannot leave a “success” file whose stream no longer decodes.

Testing (B53) adds tests/cli_real_files.rs, running rvt-elem-table, rvt-history, rvt-analyze, rvt-diff, rvt-ifc-compare, and rvt-write end-to-end on the family/project corpora (with skips when fixtures are missing). The rvt-write case identity-patches those two streams and asserts either a clean read-back with unchanged other streams, or a page-related refusal with no output file.

The user guide documents the page limit; tools/ci/test-targets.txt registers cli_real_files under the cli CI class.

Reviewed by Cursor Bugbot for commit 7ed09d3. Configure here.

rvt-elem-table, rvt-history, rvt-analyze, rvt-diff, rvt-ifc-compare and
rvt-write had only --help checks. tests/cli_real_files.rs runs each on the
family corpus (RVT_SAMPLES_DIR) and RE1 Architecture with Revit's export
(RVT_PROJECT_CORPUS_DIR), and checks what each claims about the file: the
ElemTable's record count, the file's own release last in its history, the
identity's release, a file identical to itself and two releases different,
an export that matches itself and differs structurally from Revit's IFC2X3
one, and a patched stream that reads back as its bytes or is refused.

Red, with one fault injected per binary (draft #648, run 37213954071,
"build + real files / ubuntu-latest / stable" and "Corpus health"):

  history_ends_with_the_files_own_release
    2018: releases out of order: [2018, 2017, 2017]
  analyze_identity_is_the_files_release
    2016: rvt-analyze identity ...
      left: Some(2017)
     right: Some(2016)
  elem_table_json_holds_the_tables_records
    rac_basic_sample_family-2016.rfa: parsed records against the table's record_count
      left: Some(1595)
     right: Some(1596)
    Revit_IFC5_Einhoven.rvt: ... left: Some(2614) right: Some(2615)
  diff_finds_a_file_identical_to_itself_and_two_releases_different
    two releases show no differing stream:
  ifc_compare_tells_an_export_from_itself_and_from_revits
    rvt-rs's IFC4 export against Revit's IFC2X3 export differs structurally
      left: Some(0)
     right: Some(2)

Red on main with no fault injected (draft #650, run 37213958029,
"build + real files / ubuntu-latest / stable"), a real defect, B69:

  write_round_trips_or_refuses_a_streams_own_bytes
    2016 Formats/Latest: rvt-write exited 0 but the stream does not decode: unexpected end of file
  test result: FAILED. 5 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.19s
…ed page (B69)

Revit stores Formats/Latest, Global/Latest and the other paged streams in 65,249-byte pages, each ending in a 353-byte checksum rvt-rs cannot compute, and every reader strips those trailers. write_with_patches wrote a re-encoded stream with no trailers and verified it with a decoder that does not strip, so rvt-write exited 0 on a file whose patched stream rvt-rs's own reader cannot decode: an identity patch of a 2016 to 2026 family's Formats/Latest reads back as 'unexpected end of file' (B53's test). Every patch is now framed before the file is touched, and one on a paged stream whose framed bytes reach a stored page is refused with the new Error::WriteRefused. Framed bytes within one page carry no trailer and are written as before.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Write test uses the wrong decoder
    • Post-write verification now uses writer::decompress_stream (inflate_at) instead of native_document::read_single (GzDecoder), matching truncated-gzip output from rvt-write.

Create PR

Preview (c233dbcab1)
diff --git a/tests/cli_real_files.rs b/tests/cli_real_files.rs
--- a/tests/cli_real_files.rs
+++ b/tests/cli_real_files.rs
@@ -343,15 +343,20 @@
                 refused += 1;
                 continue;
             }
-            // rvt-write said it wrote the stream: rvt-rs's reader must read
-            // back the bytes it was given, and nothing else may change.
-            let mut written = rvt::RevitFile::open(&target).expect("open written file");
-            let read_back =
-                rvt::native_document::read_single(&mut written, stream).unwrap_or_else(|e| {
+            // rvt-write re-encodes with truncated gzip; verify like the writer
+            // (bare inflate_at), not native_document::read_single (GzDecoder).
+            let stream_framing = match framing {
+                "RawGzipFromZero" => rvt::writer::StreamFraming::RawGzipFromZero,
+                "CustomPrefix8" => rvt::writer::StreamFraming::CustomPrefix8,
+                other => panic!("unknown framing {other}"),
+            };
+            let read_back = rvt::writer::decompress_stream(&target, stream, stream_framing)
+                .unwrap_or_else(|e| {
                     panic!(
                         "{year} {stream}: rvt-write exited 0 but the stream does not decode: {e:#}"
                     )
                 });
+            let mut written = rvt::RevitFile::open(&target).expect("open written file");
             assert!(
                 read_back == decoded,
                 "{year} {stream}: decodes to other bytes after the round trip"

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 7ed09d3. Configure here.

Comment thread tests/cli_real_files.rs Resolved
…32 and size trailer Revit's streams carry (B69)

With the page refusal in place, #653's run 37214636238 still failed:

  write_round_trips_or_refuses_a_streams_own_bytes
    2016 Global/Latest: rvt-write exited 0 but the stream does not decode: unexpected end of file

That patch fits in one page. The writer encoded patches with
truncated_gzip_encode, which leaves out gzip's CRC32 and ISIZE trailer on
the belief that Revit writes truncated gzip. Revit's own Formats/Latest and
Global/Latest carry the trailer: native_document::read_single, a conforming
gzip reader that checks it, decodes every original stream of the family
corpus, and fails on the writer's. The writer now stores one complete gzip
member (compression::gzip_member_encode, the same header and DEFLATE data
plus the trailer), behind the 8-byte prefix for CustomPrefix8.
truncated_gzip_encode and its callers are unchanged.
@DrunkOnJava
DrunkOnJava merged commit 5a264b2 into main Oct 4, 2026
24 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/b53-cli-real-files branch October 4, 2026 16:45
DrunkOnJava added a commit that referenced this pull request Oct 4, 2026
…64 and B70 in progress, B60 found (#660)

Third session 3 progress update: five items landed, B64 (#659) and B70
in progress, new B70 and B71 rows (MEP sample performance), B68 blocked
on B70, and RE-167's finding for B60.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Documentation-only backlog and session notes; no runtime, CI config,
or exporter behavior changes in this diff.
> 
> **Overview**
> Updates **BACKLOG.md** for maintainer session 3: the ranked table and
progress log reflect landed work and new perf backlog, without any code
changes.
> 
> **Status moves in the ranked table:** **B44**, **B63**, **B66**,
**B53**, and **B69** are marked **done** (with PR refs #651, #645/#656,
#657, #653). **B60** and **B64** move from **committed** to **in
progress** (RE-167 type GlobalId rule; #659 curtain-wall door
aggregation). **B68** is **blocked** on **B70** (MEP sample export
timeout). Two new rows: **B70** (`rvt-ifc` ~33.5 min on MEP samples;
`attach_mep_systems` / `attach_pipe_type_names` scans) and **B71**
(double file walk for export vs diagnostics).
> 
> **Progress log additions** document how each item closed or advanced:
B63’s plan-box overlap rule for medicine cabinet 375441; B53/B69 writer
fixes (refuse checksummed pages, full gzip members); B44’s three-reader
NominalDiameter path; B66 curtain material offsets; B64 curtain-grid
door parts; B70’s one-pass-per-stream improvement (30 s walk,
byte-identical RE1 MEP IFC); B60’s original-symbol GlobalId finding; and
a note that unresolved Bugbot threads block merges until resolved.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
a2c5a15. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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