Skip to content

feat(metadata): read worksharing, last save and document identity, and inventory folders with rvt-info - #284

Merged
DrunkOnJava merged 2 commits into
mainfrom
feat/basic-file-info-properties
Sep 22, 2026
Merged

DrunkOnJava merged 2 commits into
mainfrom
feat/basic-file-info-properties

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Every Revit file records who saved it last, when, whether it is workshared and where its central model lives; rvt-rs now reads all of it, and rvt-info inventories whole folders (table / CSV / JSON / JSON Lines) by reading only each file's two small identity streams.

Motivation

The first question anyone asks about a Revit file they cannot open is "which release saved this, is it workshared, who touched it last?" — and the most common BIM-manager task before an upgrade is answering that for a whole project archive. The data was already in every file (BasicFileInfo's Key: value block, 2016-2026) but the regex scan never read it.

Changes

  • src/basic_file_info.rs: parse_properties recovers the text block at either byte alignment (odd on 2026 and both magnetar projects), restores the narrow-packed IsSingleUserCloudModel boolean, and recovers the tail after a narrow "True\0" alignment flip. BasicFileInfo::properties + typed accessors (worksharing, username, central_model_path, last_save_path, document_guid, document_increments, is_single_user_cloud_model, …). locale / guid now prefer the text block (the old ENU-anywhere scan could match inside a path).
  • src/project_information.rs (new): the project-file ProjectInformation stream is a one-entry ZIP with an Atom project.xml; parsed for the save timestamp. The entry name embeds the saving machine's user folder and is never surfaced.
  • src/part_atom.rs: entry_title = the Atom entry's own title. title keeps its last-title-wins value (the Python API documents "0610 x 0915mm"); on project files that value is a parameter-group name ("Other"), which is why the new field exists.
  • src/metadata.rs (new): FileMetadata, RevitFile::metadata(), read_metadata(path) / read_metadata_from(reader) (identity streams only), redact() (also scrubs the user inside local-copy names <central>_<user>.rvt).
  • src/reader.rs: project_information(), document_atom(); open errors name the file and report directories (ErrorKind preserved).
  • src/bin/rvt_info.rs: Document section; several files / folders → inventory (recursive, --no-recurse, -f csv|json|jsonl, --json), backup copies marked, error rows + exit 1.
  • Python: RevitFile.metadata(redact=False), rvt.read_metadata(path, redact=False) (FileNotFoundError / OSError / ValueError). Wasm: fileMetadata(bytes). Viewer: File status "Saved" and "Worksharing" rows.
  • Schemas: file-metadata.schema.json, inventory-row.schema.json; summary.schema.json gains document (additive).
  • Docs: README, user guide ("Inventory A Folder Of Revit Files"), python.md, viewer-api.md, status.md, support matrix row, CHANGELOG. Also fixes the README's second CLI-count sentence ("Seventeen" → "Eighteen").

Testing

  • tools/check-local.sh (fmt, clippy -D warnings, rustdoc -D warnings, workspace tests: 1,327 passed), plus the corpus tests with RVT_SAMPLES_DIR pointing at the 11-release phi-ag corpus
  • cargo +1.85.0 check --profile ci --all-targets (MSRV)
  • New unit tests: basic_file_info (even/odd alignment, narrow True flip, unknown keys, header strings not mistaken for properties, no-panic sweep), project_information (deflated / stored / size-less entries, nested A:title not taken as the entry title, inflate limit, malformed input), metadata (redaction, non-CFB rejection, missing path named)
  • tests/samples.rs::basic_file_info_properties_read_on_every_release — worksharing, save counter (59 on 2016 → 70 on 2026), locale, Format / Revit Build, cloud flag, Author, ClientAppName on all 11 releases
  • tests/rvt_info_cli.rs (tier-1 fixtures only): folder table + error row + exit 1, --no-recurse, CSV header + backup flag, argument order, missing-file message, --extract-preview refuses a folder
  • tests/json_schema_contracts.rs: tier-1 single-file summary + folder inventory validate; the embedded metadata schema cannot drift from the standalone one
  • Python: maturin develop + pytest tests/python — 62 passed (5 new)
  • Viewer: wasm-pack build, npm run typecheck, npm run build, wasm network-import audit PASS, Playwright 14 passed (the Einhoven project test now asserts the Saved and Worksharing rows)
  • N/A: IFC exporter output unchanged; no element decoder added; not a performance change

Audit-honesty checklist

  • README / docs reflect the current state after this PR — no claims of features that are not actually shipped in this PR
  • If a limitation was resolved, the "Known limitations" / "What works today" section in the relevant docs is updated
  • If a new limitation was introduced, it is documented in the PR body and in-code: workshared values other than Not enabled are read verbatim — no workshared sample is in the redistributable corpus, so Central / Local handling is covered by synthetic tests only (stated in the support-matrix row)
  • 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 partition/element reverse-engineering finding; the text block is plain UTF-16LE observed in the public sample files

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). Based solely on public byte observations of the phi-ag/rvt and magnetar-io/revit-test-datasets sample files.
  • Any new test fixtures use synthetic values (testuser, etc.) and contain no real-world PII

Breaking changes

BasicFileInfo gains a public properties field and PartAtom a public entry_title field, so struct literals outside the crate need the new field (or ..Default::default() for PartAtom). Serde input is backward-compatible (#[serde(default)]). JSON outputs only gain keys.

Screenshots or output samples

$ rvt-info _corpus _project_corpus
VERSION  WORKSHARING  LAST SAVED (UTC)          SIZE  FILE
2016     Not enabled  2015-01-14 15:07:16  264.0 KiB  _corpus/examples/Autodesk/rac_basic_sample_family-2016.rfa
...
2026     Not enabled  2025-03-13 07:19:49  408.0 KiB  _corpus/examples/Autodesk/racbasicsamplefamily-2026.rfa
2024     Not enabled  2023-09-07 12:50:35   32.2 MiB  _project_corpus/Revit/2024_Core_Interior.rvt
2023     Not enabled  2024-06-02 13:14:32  892.0 KiB  _project_corpus/Revit/Revit_IFC5_Einhoven.rvt

13 files · by release: 2016 ×1, ..., 2023 ×2, 2024 ×2, 2025 ×1, 2026 ×1 · workshared: 0 · unreadable: 0

$ rvt-info 2024_Core_Interior.rvt
...
Document ·
  title:          2024_Core_Interior
  last saved:     2023-09-07 12:50:35 UTC
  worksharing:    Not enabled
  save counter:   66
  cloud model:    no

Related issues

None


Note

Low Risk
Read-only metadata and CLI inventory on user-supplied files; stream reads are capped and redaction is extended, with no changes to write paths or IFC export logic.

Overview
Adds document identity beyond the old regex skim: BasicFileInfo now parses the full Key: value text block (2016–2026), including odd-byte alignment and the narrow-packed IsSingleUserCloudModel flag, with typed accessors and verbatim properties.

rvt::metadata merges that with the document Atom (PartAtom or new ProjectInformation ZIP → project.xml) into FileMetadata, exposed via read_metadata (identity streams only), RevitFile::metadata(), and stronger --redact (paths, usernames, local-copy filenames).

rvt-info gains a Document section for one file and folder/multi-file inventory (table, CSV, JSON, JSONL, --no-recurse, backup detection, error rows → exit 1). Single-file JSON adds a document field; PartAtom::entry_title distinguishes the real document name from legacy title.

Python (read_metadata, RevitFile.metadata), wasm (fileMetadata), and the viewer File status panel show last saved and worksharing early in the worker summary. New file-metadata / inventory-row schemas and corpus-backed tests pin behavior across releases.

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

…d inventory folders with rvt-info

BasicFileInfo carries a block of `Key: value` lines on every release
2016-2026 (Worksharing, Username, Central Model Path, Last Save Path,
Unique Document GUID, Unique Document Increments, IsSingleUserCloudModel,
Author, ClientAppName, ...) that the regex scan never read: the block
starts at an odd byte offset on 2026 and both magnetar projects, and
IsSingleUserCloudModel is a narrow "False\0" packed into wide text.
parse_properties decodes both alignments, restores narrow booleans and
recovers the tail after a narrow "True\0" alignment flip. Pinned on all 11
phi-ag releases (tests/samples.rs) plus synthetic odd/even/flip cases.

ProjectInformation, the one-entry ZIP project files carry instead of
PartAtom, is parsed for its Atom entry (save timestamp); the entry name
embeds the saving machine's user folder and is never surfaced.
PartAtom::entry_title is the entry's own title; `title` keeps its
last-title-wins value, which the Python API documents.

rvt::metadata::FileMetadata combines both; read_metadata(path) reads only
those two streams from disk. rvt-info gains a Document section and takes
several files or folders (recursive, --no-recurse) as an inventory:
table, -f csv, -f json, -f jsonl, backup copies marked, unreadable files
as error rows with exit status 1, --json shorthand. --redact also scrubs
the last-saved-by user inside local-copy names (<central>_<user>.rvt).

Python: RevitFile.metadata(), rvt.read_metadata(). Wasm: fileMetadata().
Viewer: Saved and Worksharing rows in File status. Open errors name the
file and report directories. Schemas: file-metadata, inventory-row;
summary gains `document`.
@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_010cc59b-6410-4bc8-8182-8096e512872c)

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) September 22, 2026 19:06
@DrunkOnJava
DrunkOnJava merged commit 34365d0 into main Sep 22, 2026
21 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/basic-file-info-properties branch September 22, 2026 19:08
DrunkOnJava added a commit that referenced this pull request Sep 22, 2026
…#286)

## Summary

The 18 CLIs now take input, write output and report errors the same way:
positional input with a sensible default output, one `error: <message>`
line that names the file, `--json` everywhere a JSON format exists,
worked examples in every `--help`, and no panic backtrace when output is
piped into `head`.

## Motivation

The CLIs grew one at a time and a first-time user trips over the seams:

- The README shows `rvt-gltf my-project.rvt -o out.glb` and `rvt-sheet
my-project.rvt -o out.svg`; both binaries rejected that and demanded
`--src` / `--dst`.
- `rvt-ifc`, `rvt-doc` and `rvt-elements` returned `anyhow::Result` from
`main`, so failures printed Rust's Debug form (`Error: …`); `rvt-gltf`
printed `rvt-gltf: open …`; the rest `error: …`.
- JSON output was `--json` on some tools and `-f json` on others.
- `rvt-schema model.rfa --json | head` (or any large output into a
closed pipe) ended in `failed printing to stdout: Broken pipe` plus a
`RUST_BACKTRACE` hint.

## Changes

- `rvt-gltf`, `rvt-sheet`: positional `INPUT`, `-o/--output` defaulting
to the input with `.glb` / `.svg`; `--src`/`-s` (hidden) and
`--dst`/`-d` (alias of `--output`) still work; refuse to overwrite the
input.
- `rvt-ifc`, `rvt-doc`, `rvt-elements`: `main` returns `ExitCode` and
prints `error: <message>` (exit 1). Open errors name the file once (the
path comes from the library since #284).
- `--json` shorthand on `rvt-schema`, `rvt-history`, `rvt-corpus` (+
`doctor`), `rvt-elem-table`, `rvt-capabilities`; combining it with
`--format` is a usage error (exit 2).
- `src/cli.rs` (new): `exit_quietly_on_broken_pipe()` — a panic hook
that turns exactly `println!`'s closed-pipe panic (`os error 32` Unix,
`os error 232` Windows) into exit 141 and leaves every other panic,
including a full disk behind a redirect, to the default report. Called
first in all 18 `main`s. Safe code, no new dependency.
- Every `--help` ends with an `Examples:` block; each example was run
against the phi-ag family corpus before being written down (that run
caught one wrong example: `rvt-write --dry-run` still needs `--dst`).
- `rvt-history` / `rvt-elem-table` document their positional `FILE`.
- CHANGELOG entry under Fixed.

## Testing

- [x] `tools/check-local.sh` with `RVT_SAMPLES_DIR`: fmt, clippy -D
warnings, rustdoc -D warnings; workspace tests 1,291 passed, 1 failed —
the failure is
`rvt_ifc_diagnostics_cli::rvt_ifc_cli_strict_mode_fails_before_writing_ifc_but_keeps_diagnostics`,
which fails identically on `main` and on the commit before #284 whenever
the family corpus is present (it expects confidence `scaffold`, the 2024
sample now yields `typed_no_geometry`). CI never runs that file, so it
went unnoticed; the follow-up PR fixes it together with the CI gap that
hid it.
- [x] `cargo +1.85.0 check --profile ci --all-targets` (MSRV)
- [x] New `tests/cli_ergonomics.rs` (7 tests): positional input +
default output, `-o`, legacy `--src/--dst` and `-s/-d`, overwrite
refusal, one `error:` line naming the missing file exactly once for five
CLIs, `--json` == `--format json` and the clash is exit 2, every
`--help` has examples, closed stdout pipe exits 141 without "panicked"
(corpus-gated)
- [x] Unit tests for the closed-pipe matcher (Unix / Windows messages
recognised; disk-full and unrelated panics left alone)
- [x] N/A: IFC / glTF / SVG output unchanged

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR — the
README's positional examples now actually work
- [x] N/A: no capability-status change
- [x] No new limitation
- [x] Commit messages describe WHAT changed and WHY
- [x] No emojis in code, docs, or commit messages
- [x] No private paths, personal email addresses, or internal jargon in
committed files
- [x] N/A: not a reverse-engineering finding

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0 (see
`CONTRIBUTING.md`)
- [x] This PR contains no Autodesk proprietary source, decompiled
internals, or NDA'd SDK content (see `CLEANROOM.md`)
- [x] Test fixtures: tier-1 synthetic files only (plus the phi-ag family
sample, gated, for the pipe test)

## Breaking changes

None for invocations: every previous flag still parses. `rvt-ifc`,
`rvt-doc` and `rvt-elements` print `error: …` instead of `Error: …`
(exit code unchanged, 1).

## Screenshots or output samples

```
$ rvt-gltf model.rvt --verbose
rvt-gltf: wrote 860 bytes (0 building elements) to model.glb
$ rvt-gltf model.rvt -o model.rvt
error: refusing to overwrite the input model.rvt; pass -o <path>
$ rvt-ifc nope.rvt
error: I/O error: nope.rvt: No such file or directory (os error 2)
$ rvt-ifc --help
...
Examples:
  rvt-ifc model.rvt                     writes model.ifc next to the input
  rvt-ifc model.rvt -o out.ifc --diagnostics out.diagnostics.json
  rvt-ifc model.rvt --mode geometry
```

## Related issues

None

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> User-facing CLI parsing and error/pipe handling only; export and
decode paths are untouched aside from clearer error messages.
> 
> **Overview**
> Standardizes how the shipped binaries accept input, write output,
report failures, and behave when stdout is closed early—without changing
IFC, glTF, or SVG export logic.
> 
> **`rvt-gltf` and `rvt-sheet`** now match the README: positional model
path, default **`model.glb` / `model.svg`** beside the input, **`-o`**,
and hidden legacy **`--src` / `--dst`** (aliases still work). Shared
**`resolve_paths`** refuses to overwrite the input. Errors use **`error:
…`** instead of tool-prefixed lines.
> 
> **`rvt-ifc`, `rvt-doc`, and `rvt-elements`** return **`ExitCode`**
from **`main`** and print a single **`error: <message>`** (exit 1)
instead of anyhow’s **`Error:`** debug form.
> 
> Several tools gain **`--json`** as shorthand for **`--format json`**
(conflicts with **`-f`** → usage error exit 2). Every **`--help`** adds
an **`Examples:`** block.
> 
> New **`rvt::cli::exit_quietly_on_broken_pipe`** (in **`src/cli.rs`**)
is invoked first in all shipped **`main`** functions so piping into
**`head`** exits **141** without a broken-pipe panic; other panics are
unchanged. **`tests/cli_ergonomics.rs`** locks in positional/legacy
flags, overwrite refusal, error shape, **`--json`**, help examples, and
the quiet pipe exit.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
17b8896. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
DrunkOnJava added a commit that referenced this pull request Sep 22, 2026
## Summary

CI now runs every `tests/*.rs` file. Until this PR, 21 of the 37
integration-test files ran in no CI job at all, including the honesty
gates the docs describe as CI-enforced.

## Motivation

The test matrix runs `cargo test --lib --bins` (unit tests only) and
then a few integration targets by name (`samples`, `ifc_roundtrip`,
`field_type_coverage`, `elem_table_corpus`); the tier-2 job runs its own
name list. A target on neither list never executes. Confirmed against
the log of the latest successful `main` run — only these 16 test
binaries ran: `arc_wall_corpus`, `cfb_roundtrip_delta`,
`corpus_tier1_health`, `corpus_tier2_health`, `elem_table_corpus`,
`field_type_coverage`, `ifc_roundtrip`, `ifc_synthetic_project`,
`iter_elements_typed`, `partition_scanner`, `project_corpus_smoke`,
`project_count_fixtures`, `re15_geometry_invariants`,
`re19_door_window_wall_negative`, `samples`,
`walker_to_ifc_integration`.

Never run anywhere: `support_matrix`, `witness_registry`,
`witness_verdict`, `binary_inventory`, `json_schema_contracts`,
`fuzz_regressions`, `proptest_parsers`, `typed_decoders`,
`graceful_degradation`, `control_cancellation`, `checksum_page_framing`,
`cfb_patch_corpus`, `es_remap_golden`, `gen_fixture_roundtrip`,
`geometry_recovery`, `ifc_export_modes`, `ifc_synthetic_structural`,
`rvt_ifc_diagnostics_cli`, `rvt_inspect_cli`, `rvt_info_cli`,
`cli_ergonomics`.

The #206 comment in the tier-2 job already records this failure mode
once (`elem_table_corpus` hid a real decoder bug while off the list); a
hand-kept list keeps reproducing it.

## Changes

- `ci.yml` test matrix: the named `samples` / `ifc_roundtrip` steps
become one `Integration tests (every tests/*.rs)` step, `cargo test
--profile ci --no-fail-fast --test '*'`, on every OS, with
`RVT_SAMPLES_DIR` set where the job fetched the family corpus. The
`RVT_REQUIRE_CORPUS=1` gates (`field_type_coverage`,
`elem_table_corpus`) stay as they are.
- `ci.yml` tier 2: the three named steps and the seven-target
decoder-gate list become one step running every target against the
magnetar project corpus (`RVT_CORPUS_TIER2_LIMIT=8` kept).
- `tests/rvt_ifc_diagnostics_cli.rs`: the one stale assertion the newly
run files surfaced (details below).
- `CONTRIBUTING.md`: says every `tests/` file runs in CI and that
corpus-reading tests must skip cleanly without their variable.
- `CHANGELOG.md` entry.

### The stale assertion


`rvt_ifc_cli_strict_mode_fails_before_writing_ifc_but_keeps_diagnostics`
asserted `confidence.level == "scaffold"` for the strict-mode rejection
of the 2024 sample family. The family has exported at
`typed_no_geometry` for a while — verified identical on `main` and on
`a779122` (before #284) — so the test has been red whenever the family
corpus is present, unseen because nothing ran it. The test is about
strict mode rejecting an incomplete export, not about which
below-geometry level it lands on, so it now accepts any below-geometry
level.

## Testing

- [x] Locally, every integration target against both corpora:
`RVT_SAMPLES_DIR=… RVT_PROJECT_CORPUS_DIR=… cargo test --profile ci
--no-fail-fast --test '*'` — 65 s wall clock; the only failures were the
stale assertion above (fixed) and `project_count_fixtures` needing
magnetar's two reference IFCs that my local corpus lacked (fetched;
passes; CI's full clone has them)
- [x] `actionlint` — no new findings (the only report is the
pre-existing SC1003 info note in the PII guard)
- [x] This PR's own CI is the proof on macOS / Windows / MSRV, where
these files have never run before
- [x] N/A: no source, IFC output or performance change

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR —
`docs/status.md` / `docs/verification-protocol.md` describe the
support-matrix and witness-registry tests as CI-enforced; after this PR
that is true
- [x] N/A: no capability limitation changed
- [x] No new limitation
- [x] Commit messages describe WHAT changed and WHY
- [x] No emojis in code, docs, or commit messages
- [x] No private paths, personal email addresses, or internal jargon in
committed files
- [x] N/A: not a reverse-engineering finding

## Legal and contribution hygiene

- [x] I agree this work is licensable under Apache-2.0 (see
`CONTRIBUTING.md`)
- [x] This PR contains no Autodesk proprietary source, decompiled
internals, or NDA'd SDK content (see `CLEANROOM.md`)
- [x] N/A: no test fixtures added

## Breaking changes

None.

## Screenshots or output samples

N/A

## Related issues

Refs #206 (the same failure mode, fixed then for one target).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Changes are limited to CI workflow wiring, contributor docs, and a
test assertion loosened to match current export behavior; no library or
runtime behavior changes.
> 
> **Overview**
> **CI now runs every `tests/*.rs` integration target** instead of
naming a few binaries per job. The cross-OS test matrix replaces
separate `samples` / `ifc_roundtrip` steps with one `cargo test
--profile ci --no-fail-fast --test '*'` step; `RVT_SAMPLES_DIR` is set
only when that runner fetched the family corpus. The tier-2 job
collapses its named health/smoke/decoder lists into the same wildcard
run against the magnetar project corpus (keeping
`RVT_CORPUS_TIER2_LIMIT=8`). Corpus-required gates like
`field_type_coverage` and `elem_table_corpus` stay as dedicated steps.
> 
> That coverage caught a **stale strict-mode assertion** in
`rvt_ifc_diagnostics_cli`: strict rejection is still required, but
`confidence.level` is no longer pinned to `scaffold`—it accepts any
below-geometry level as decoders improve.
> 
> **Docs:** `CHANGELOG.md` and `CONTRIBUTING.md` document the new gating
model and the requirement that corpus-dependent tests skip cleanly when
env vars are unset.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7618722. 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