Skip to content

fix(cli): rvt-write decodes unpadded base64 to its bytes, and rvt-dump writes streams whose names Windows refuses (#1845) - #1855

Merged
DrunkOnJava merged 10 commits into
mainfrom
fix/1845-1833-follow-ups
Nov 13, 2026
Merged

DrunkOnJava merged 10 commits into
mainfrom
fix/1845-1833-follow-ups

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Batch 4's CLI auditor read 9 of the 19 binaries. I read the other ten: gen-fixture, rvt-capabilities, rvt-diff, rvt-dump, rvt-elem-table, rvt-ifc-compare, rvt-schedule, rvt-schema, rvt-sheet and rvt-write. None can panic on a file. Two do the wrong thing with one:

  • rvt-write decoded a manifest's unpadded base64 wrong. An unpadded last group came out as three bytes whatever its length, and an = inside the text as zeros, so the stream was patched with bytes the manifest never gave.
  • rvt-dump stopped on Windows at a stream whose name holds a character Windows refuses in a file name or names a device. Two streams whose names became one file name wrote to the same file, so the later one replaced the earlier without a word.

It also takes a follow-up of #1833:

This is the batch's fifth PR.

Motivation

Part of #1845. The scoreboard of batch 4 records the auditor's coverage gap. These two are what reading the rest found.

Changes

  • src/bin/rvt_write.rs decode_base64:

    • = pads only the end, and a group of n characters (2 to 4) holds n − 1 bytes.
    • Text ending in a lone character is refused, as is an = inside it.
    • A padded manifest decodes as before.
  • src/bin/rvt_dump.rs file_stem_for, the file name each stream is written under:

    • A stream name's <>"|?* and control characters become _, as / does.
    • A device name Windows reserves (CON, PRN, AUX, NUL, CONIN$, CONOUT$, COM0–9 and LPT0–9, the superscript COM¹–³ and LPT¹–³, whatever follows the first .) takes a _ in front.
    • A name another stream of the dump already has, compared without case as macOS and Windows file systems compare names, takes ~2, ~3 and so on (rvtReview's two notes).
    • A trailing dot or space cannot end a file name, since .decomp or .raw follows it.
    • The cfb crate already refuses \, : and ! in entry names (direntry.rs validates every name it reads), so no name leaves --out.
    • Revit's own stream names hold none of these and none collide, so their files keep their names.
  • changelog.d/fixed/1845-cli-base64-and-dump-names.md.

  • src/research/partition_mep_systems.rs and src/research/partition_curtain_materials.rs: each stream's objects of the wanted classes come from its listed data objects.

  • budget::stopped at fix(ifc): profile-cut chains are written and meshed by a loop, the scene graph's host depth, wall-top parts, roof envelope points, mullion grid cells and space containment are bounded (#1845) #1848's bounds:

    • src/ifc/export_content/wall_tops.rs: wall_top_pieces (the cut pieces or the pieces held past 4 × MAX_RISERS), wall_top_covered_parts (MAX_COVERED_PARTS), and wall_top_embedded_pieces (the stub test's pieces past 4 × MAX_RISERS).
    • src/ifc/body_geometry.rs: envelope_pieces, where the envelope's pieces, their points or its sides pass their caps.
    • src/ifc/mesh_volume.rs: mullion_end_cells, once per pass, where a grid cell holds more than MAX_ENDS_PER_CELL mullion ends.
    • src/ifc/export_content.rs: space_containment, past SPACE_CONTAINMENT_BUDGET.
    • All six run on the export's own thread, inside the notes export_rvt_doc and run_export_with_limits_and_control open. None runs on a saved-mesh worker, whose threads keep no notes.
    • docs/export-diagnostics.md names them and what each leaves out. With ExportDiagnostics::work_budget_stops, it says a count is how often a reader stopped on the open file, since an export made again adds the stops of a reader it runs again (rvtReview's note on fix(research): pipe connectors, curve fields, room parameters and solids, sketch loops, empty faces, parameter bindings and family mesh checks are read through an index or under a work budget, so a crafted file cannot hang them (#1833) #1849).
    • changelog.d/security/1845-geometry-budget-stops.md.
  • 38cbd20, a stop is a warning:

    • ExportDiagnostics::is_partial covers unread streams alone. work_budget_stops still lists the stops.
    • rvt-ifc and rvt-gltf print warning: N reader(s) stopped at a work budget ... with each reader, then write the model. --allow-partial and exit status 3 are for unread streams alone, and their help says so.
    • Python's write_ifc and rvt_to_ifc give a RuntimeWarning naming the stops (warn_runtime) and raise ValueError only for unread streams.
    • The MCP server's exports no longer refuse on a stop. Their notes say Warning: <reader> stopped N time(s) ....
    • docs/export-diagnostics.md, docs/python.md, python/rvt/__init__.pyi and the 1833 and 1845 fragments follow.

Testing

  • rvt-write: tests/cli_real_files.rs patches real files through the CLI with padded base64, which decodes the same.

    • The new decoding rule was checked in Python against its base64 module: 1,200 padded and 1,200 unpadded random encodings round-trip, and Q, QUJD=Q, Q=QQ and QUJDR are refused.
    • No Rust test is added: the helper sits in a binary, whose unit tests CI does not run.
  • rvt-dump: no export changes. No file in the corpus has such a name.

  • Unfiltered Measure, timed, of b6523d9c against its merge-base 7693fc29 (samples, families, Nordic, Revit 2025, BIMcollab, rac_advanced, held-out): 43332394339. Rows registered before it ran:

    1. Every ifc.sha256 and diagnostics.json equals the base's, with no model missing either. A stop makes the export partial, and rvt-ifc then writes no model (exit 3), so a file that reached one of the new stops would show as a missing ifc.sha256 and a diagnostics file gaining a work_budget_reached item, not as a moved export (rvtReview). One whose MEP system or curtain material came from an object outside the listing would move its export.
    2. Timing: median head/base at or below 1.00 over the 2023 to 2027 samples, and no file above 1.03.
    3. Peak memory is not judged from this run: Snowdon HVAC and Plumbing each land in one of two peaks run by run on the same code (rvtReview's control run 43329577007).
  • Unfiltered Measure, timed, of c88338b1 (38cbd20 with main merged) against its merge-base b411ca46: 43349709171, with the same rows 1 to 3. No corpus file reaches a stop, so the warning path changes no export.

  • 43332394339, read against those rows: both hold.

    1. ifc.sha256 is equal on 146 of 146 models and diagnostics.json on 121 of 121, with none missing and no work_budget_reached item in any. The scorer diff has only output the head alone writes.
    2. Median head/base 0.994 (0.959 to 1.006) over the 29 samples of 2023 to 2027, none above 1.03.
    • Outside row 2's set, 2015 rac_advanced reads 1.038. On 2015 the change adds only a budget::stopped call that never fires, and the other 29 samples of 2015 to 2022 have a median of 1.006. No peak is more than 2% higher.
  • tools/check-local.sh: not run locally (no local builds); CI runs it

  • rustfmt --edition 2024 --check

Audit-honesty checklist

  • No claim beyond what ships
  • Changelog fragment
  • No emojis or private paths

Legal and contribution hygiene

  • Apache-2.0; no Autodesk source

Breaking changes

None released. rvt-write refuses base64 text that ends in a lone character or holds = inside it, which it used to decode wrongly. A work-budget stop no longer makes an export partial: on main since #1849 it refused the export, a behaviour no release shipped.

https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge

… it holds (#1845)

decode_base64 read every group as three bytes once the padding was gone,
so an unpadded last group of two or three characters patched the stream
with one or two zero bytes the manifest never gave, and an `=` inside the
text decoded as zeros. Padding now pads only the end, a group of n
characters holds n - 1 bytes, and text ending in a lone character is
refused. A padded manifest decodes as before (the CLI test's encoder pads);
1,200 padded and 1,200 unpadded random encodings round-trip through the
same algorithm in Python against its base64 module.

Found by reading the ten binaries batch 4's CLI auditor did not reach.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…ws refuses in a file name (#1845)

A stream's name is the file's own, and rvt-dump wrote it as a file name
with only `/` replaced. The cfb crate refuses `\`, `:` and `!` in entry
names, so no name leaves --out, but `<>"|?*` or a control character failed
the write on Windows and stopped the dump at that stream. They become `_`
as `/` does; Revit's own stream names hold none, so their files keep their
names.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…ows accepts, device names and repeats included (#1845)

From rvtReview's read of #1855. A stream named for a device Windows
reserves (CON, NUL, COM1 and the like, whatever follows the first dot)
failed or misbehaved as a file name: it takes a `_` in front. Two stream
names that map to one file name (`a?b`, `a*b`, `a_b`, or names differing
only in case on a case-insensitive file system) wrote the same file, the
later replacing the earlier silently: a repeat takes `~2`, `~3` and so on,
and the dump's listing names each stream's file. A trailing dot or space
cannot end the file name, since `.decomp` or `.raw` follows it. Revit's
own stream names hold none of these and none collide.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…COM and LPT ports Windows reserves (#1845)

rvtReview's note on #1855: the superscript ports are five bytes long, so
the four-byte length test missed them.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…rom the stream's listed data objects, not an Adler-32 of every object around each class-word hit (#1833)

Verifying the object around every place its class word occurs cost a full
Adler-32 of the payload per hit, quadratic on a crafted stream. The listed
objects (memoised_partition_data_objects) are the same ones: a census of
the local corpus (RE1 x4, Einhoven, rac_advanced 2024, Core Interior) finds
349,320 verified data objects, every one in the listing, none nested in
another's payload. The loops keep their order, tag first, then offset, since
the first class and the last material read win.

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
…cells and space containment note their stop, so an export that reaches one says so (#1845)

Each left its shape out or its element uncontained without a word. Each
now calls budget::stopped, as #1849's readers do: the export's
diagnostics list it under work_budget_reached, and rvt-ifc and rvt-gltf
exit 3 unless --allow-partial. All six run on the export's own thread,
inside the notes export_rvt_doc and run_export_with_limits_and_control
open. The diagnostics doc and work_budget_stops say a count is how often a
reader stopped on the open file (rvtReview's note on #1849).

Claude-Session: https://claude.ai/code/session_01L1QUmYwb7cHmeCQU8FD2Ge
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 13, 2026 01:52
…itten, with a warning, and only an unread stream makes it partial (#1833, #1845)

Griffin, 2026-11-12, asked whether an export that trips one of the new
stops should still be written: "Write it, with a warning". #1849 had made
any stop refuse the whole export (rvt-ifc and rvt-gltf exit 3 with no
model, Python raised, the MCP server refused), so one stop on a dense
curtain-wall grid would have blocked a real model.

ExportDiagnostics::is_partial now covers unread streams alone. rvt-ifc and
rvt-gltf print the stops as a warning and write the model; Python's
write_ifc and rvt_to_ifc give a RuntimeWarning; the MCP server's notes name
them. The diagnostics, the docs and the 1833 and 1845 fragments say so.
@DrunkOnJava
DrunkOnJava merged commit 76c57f1 into main Nov 13, 2026
38 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/1845-1833-follow-ups branch November 13, 2026 02:42
DrunkOnJava added a commit that referenced this pull request Nov 13, 2026
## Summary

Release metadata for v0.20.0 (RELEASE.md, steps 4 to 7), cut from `main`
at `925c482d` and merged with `main` up to `58395b62` (#1855, #1860,
#1861, #1863, #1866, #1867 and #1868 among it):
- every version file moves to 0.20.0 (`tools/release/bump_version.py`),
and `CITATION.cff` is dated 2026-11-12;
- the fragments under `changelog.d/` are assembled into a `[0.20.0]`
section, with its introduction and "Upgrading from 0.19" (the
work-budget bullet says a stop warns and the export is still written, as
#1855 settled);
- the README's release lines name v0.20.0;
- Core Interior's two witness observations and verdicts, and the two
synthetic IFC fixtures, are taken from CI's artifacts for `e10580d0`:
only `witness_version`, the verdict hashes, the retired "Unmapped Revit
unit identifiers" warning (RE-445) and an unset transparency (#1820)
differ.

Measured and rehearsed:
- the comparison with 0.19.0 is in the section, from Measure runs
[43357862138](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43357862138)
(unfiltered, `58395b62` against `v0.19.0`'s `09b18bd3`: 49 of 146
exports move, 0 census regressions, 0 body regressions) and
[43357979238](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43357979238)
(timing: no file more than 3% slower except one that reads 0.98 in the
earlier run of the same code, no peak higher by more than 2%, the
samples of 2023 to 2027 at a median 0.76 times the peak memory). The
release adds only notes, witness files, version strings and fixtures to
`58395b62`, so a run of `main` is the run of the release; a run of this
branch would move every export through the header's version string;
- `publish.yml` rehearsal on `d9946f4b`:
[43359414819](https://github.com/DrunkOnJava/rvt-rs/actions/runs/43359414819)
passed. Only the changelog changed since.

**Why now.** `main` holds today's crafted-file and security fixes
(#1815, #1831, #1833, #1845), and neither GlobalId move. #1850 is back
in draft until the tag, and #1854's fix is #1859. Those two ship
together in 0.21.0 (#1854 comment 6841360704).

## Testing

- `python3 tools/release/changelog.py check` passes: no fragment is
left.
- `bump_version.py` checks the version files with the preflight's own
`check_versions`.
- The PII guard runs `release_preflight.py` on this PR.
- Timing against 0.19.0 is in the section, from run 43357979238 on
`58395b62`.

## Related issues

Release 0.20.0. Milestone `0.20.0`.
DrunkOnJava added a commit that referenced this pull request Nov 13, 2026
…ble, not a ValueError (#1855) (#1880)

## Summary

`docs/python.md`'s errors table still listed "a reader stopped at its
work budget" among the causes of `ValueError`. Since #1855 (0.20.0), a
work-budget stop is a `RuntimeWarning` and the export is still written.
The same page's `write_ifc` section (line 136) and
`python/rvt/__init__.pyi` already say so. This PR removes the clause
from the `ValueError` row and adds a `RuntimeWarning` row.

Found by batch 5's Python audit, finding 1 (confirmed by its verifier
and by me against `rvt-py/src/lib.rs`, where a stop goes to
`warn_runtime` and the `ValueError` covers unread streams only).

## Testing

Docs only; no code or output changes, so no Measure. `rg -U
'work\s+budget'` over docs, python, rvt-py, rvt-mcp and src/bin finds no
other place that says a stop refuses or raises.
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