Skip to content

Re #421 schema marker - #1033

Merged
DrunkOnJava merged 1 commit into
DrunkOnJava:mainfrom
puzzbobb:re421-schema-marker
Oct 26, 2026
Merged

DrunkOnJava merged 1 commit into
DrunkOnJava:mainfrom
puzzbobb:re421-schema-marker

Conversation

@puzzbobb

Copy link
Copy Markdown
Contributor

Acceptance item 1 of #421: "bbox_marker derives the marker from RevitFile::schema_classes and is cross-checked against the 2024 and 2025 constants". On all 84 2024 to 2027 files I have, the marker from each file's own schema equals the release's constant.

What changes. Every scan that needs the bbox marker now gets it from file_bbox_marker(rf, release):

  • The marker is the one the file's schema gives (schema_bbox_marker, RE-80: [tag of Outline][0xFF x4][tag of ElementParents]).
  • The release's measured constant (bbox_marker) is the cross-check. If the schema and the constant disagree, the file isn't scanned (fail closed).
  • If the schema doesn't parse, the constant is used. A release with no constant needs the schema.
  • supports_revit_version no longer depends on a constant being recorded. It is only the proven-shape list (2024 to 2027).

file_bbox_marker already existed, but it returned the constant, and only some scans called it. Before this patch, these callers read the per-release table directly:

  • partition_names::compute_element_names
  • partition_schema_mvp::attach_stair_names
  • partition_type_records::scan_type_records
  • partition_level_records::level_records (64-bit path)
  • partition_type_parameters / partition_type_materials, which only use it as a "supported?" test and now call supports_revit_version

The BBOX_MARKER* constants and bbox_marker stay as the cross-check table. The 2024-only legacy helpers that take &BBOX_MARKER are left alone.

Measurement. The probe below, on 93 files (the phi-ag/Autodesk samples, Core Interior, the RE1 set, Einhoven and 68 2025 projects):

release files schema marker ElementHeader = constant = file_bbox_marker
2024 5 46 01 ff ff ff ff ab 05 1439 ✓ ✓
2025 68 59 01 ff ff ff ff d3 05 1479 ✓ ✓
2026 4 61 01 ff ff ff ff f1 05 1509 ✓ ✓
2027 7 64 01 ff ff ff ff 10 06 1540 ✓ ✓

On every one of the 84 files, record_prologue_constant(schema marker) (ElementParents x12) is the schema's ElementHeader tag, the u16 that each record chain header carries (RE-35).

One finding for older releases. That a 12 rule doesn't hold before 2019:

release ElementParents ElementHeader difference
2016 1210 1201 9
2017 1227 1218 9
2018 1268 1259 9
2019–2023 12

This is harmless today, because the 32-bit path (partition_element_records_2023) takes the header tag from the schema. But record_prologue_constant shouldn't be used for a 2016 to 2018 file. The patch says so in its doc comment, and the test below pins the gap on each 2016 to 2023 family.

Test. tests/schema_bbox_marker.rs (registered in tests/integration/main.rs and tools/ci/test-targets.txt) asserts three things on each file:

  • schema marker == bbox_marker(release);
  • file_bbox_marker returns it;
  • the prologue == ElementHeader.

It runs on the 2024 to 2026 phi-ag families (RVT_SAMPLES_DIR, so CI runs it) and on every project in RVT_PROJECT_CORPUS_DIR. A third test checks the ElementParents − ElementHeader gap on the 2016 to 2023 families: 9 on 2016 to 2018, 12 from 2019. All three skip absent files.

Checks, on 3d2df24, with the changelog fragment changelog.d/changed/re421-schema-marker.md:

  • rustfmt --check: clean;
  • clippy --all-features -D warnings (lib, integration, probe): clean;
  • cargo check with -D warnings -D unnameable_types: clean;
  • cargo test -p rvt --lib --test integration on the local corpora: 134 + 290 passed, the one failure being the stale test below;
  • tools/check-local.sh: all gates passed.

Also in this PR: a stale test. On the full suite one test failed, on unpatched 3d2df24 too: elem_table_corpus::declared_element_ids_returns_sorted_deduped_set. Since #553 and #559 the declared ids include the table's first record, at 0x06, which on Einhoven is id 0, but the test still expected the first id to be 1. CI hadn't caught it because tools/ci/test-targets.txt skipped the test by name (added in #428, before the fix). The second commit makes the test expect ids 0 and 1 first and removes the skip, so CI runs it again. All six elem_table_corpus tests pass.

Still per-release tables:

  • elevation_marker;
  • the Level record_marker(revit_version) table. level_records no longer uses it on the 64-bit path, but it's still pub.

schema_elevation_marker exists, so the same change could be made for those. Also, schema_classes isn't memoised, so each scan re-reads the schema. That costs about 0.1 s per file in a debug build (Core Interior 0.10 s, Snowdon 0.14 s), which is small, but caching it on RevitFile would be a tidy follow-up.

Probe: examples/probe_421_schema_marker.rs (one JSON line per file)
//! #421, item 1: the element-record marker each file's schema gives, against
//! the release's measured constant.
//!
//! One JSON object per file: `release`, `schema` (the marker from
//! `Outline` and `ElementParents`, RE-80), `constant` (`bbox_marker`),
//! `header_tag` (the schema's `ElementHeader`) and `prologue`
//! (`record_prologue_constant` of the schema's marker), and `scanned`, the
//! marker `file_bbox_marker` hands the scans.
//!
//! Usage:
//!   cargo run --profile ci --example probe_421_schema_marker -- FILE.rvt ...

use rvt::RevitFile;
use rvt::research::partition_element_records as per;
use rvt::research::partition_element_records_2023::record_marker;

fn hex(marker: Option<[u8; 8]>) -> String {
    marker.map_or_else(
        || "null".into(),
        |m| format!("\"{}\"", m.map(|b| format!("{b:02x}")).join(" ")),
    )
}

fn main() {
    for path in std::env::args().skip(1) {
        let file = std::path::Path::new(&path)
            .file_name()
            .map(|n| n.to_string_lossy().into_owned())
            .unwrap_or_default();
        let mut rf = match RevitFile::open(&path) {
            Ok(rf) => rf,
            Err(e) => {
                println!("{{\"file\":{file:?},\"error\":{:?}}}", e.to_string());
                continue;
            }
        };
        let release = rf.basic_file_info().map(|i| i.version).unwrap_or(0);
        let schema = record_marker(&mut rf);
        let marker = schema.map(|(m, _)| m);
        println!(
            "{{\"file\":{file:?},\"release\":{release},\"schema\":{},\"constant\":{},\
             \"header_tag\":{},\"prologue\":{},\"scanned\":{}}}",
            hex(marker),
            hex(per::bbox_marker(release)),
            schema.map_or_else(|| "null".into(), |(_, t)| t.to_string()),
            marker.map_or_else(
                || "null".into(),
                |m| per::record_prologue_constant(&m).to_string()
            ),
            hex(per::file_bbox_marker(&mut rf, release)),
        );
    }
}

@puzzbobb
puzzbobb requested a review from DrunkOnJava as a code owner October 26, 2026 11:52
@DrunkOnJava

Copy link
Copy Markdown
Owner

Thank you, this closes #421's first item cleanly: the marker comes from each file's schema, the constant is the cross-check, and a disagreement fails closed.

CI failed only because main moved under the branch: #980 (square hollow-section columns, RE-221) added type_hollow_sections in partition_type_parameters.rs, which still asked bbox_marker(revit_version).is_none(), and this branch removes that import. I merged main into the branch and changed that one guard to supports_revit_version, as you did for the five readers beside it (f82916a0). Nothing else of yours is touched.

I've dispatched Measure on the new head against main at 8bc87a5, which the branch now contains (run 40322858460): the reference models, the BIM4LCA office, the R2025 models, Autodesk's 2015 to 2027 samples and the family corpus. Since the schema's marker equals each constant on every file you measured, every export and rvt-info output should be byte-identical; I'll post the result here.

One note, not a blocker: RevitFile::schema_classes is not memoised, so each file_bbox_marker call re-reads and parses Formats/Latest. With this change it runs once per scan that needs the marker, a handful per export; I'll measure the cost on the office with timing and memoise it in a follow-up if it shows.

@DrunkOnJava DrunkOnJava left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Measure 40322858460 on f82916a0 against main at 8bc87a5: all 89 exports (the reference models, the BIM4LCA office, the 23 R2025 models and Autodesk's 58 samples from 2015 to 2027) byte-identical, all 70 rvt-info outputs (the families included) and the 58 samples' diagnostics identical, and Core Interior's witness observations unchanged. So on every file we can measure, the schema's marker is the constant, as your probe found on your 84. Thank you; it lands once CI passes.

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 12:45
… file's own schema, cross-checked against the measured constant (DrunkOnJava#421)

Every scan that needs the bbox marker (element names, stair names, type
records, Level records) now takes it from file_bbox_marker, which returns
the marker the file's schema gives (RE-80) and checks it against the
release's measured constant: a file whose schema gives another marker is
not scanned, one whose schema does not parse keeps the constant.
supports_revit_version no longer depends on a constant being recorded.

On all 84 2024 to 2027 files measured (5, 68, 4 and 7) the schema's marker
equals the constant, and its ElementParents tag less 12 is the schema's
ElementHeader tag. On 2016 to 2018 that gap is 9, so
record_prologue_constant holds only from 2019; its doc says so.

tests/schema_bbox_marker.rs pins both on the phi-ag families and the
project corpus; examples/probe_421_schema_marker.rs prints the per-file
measurement. The hollow-section reader (DrunkOnJava#980) asks supports_revit_version
too.
@DrunkOnJava

Copy link
Copy Markdown
Owner

Thanks for this. The branch's two commits weren't signed, and main's ruleset only merges signed commits, so I've replaced the branch with one signed commit (964fc57) that has the same tree and keeps you as its author; the squash merge will credit you the same way. Nothing in the change itself moved. It will land in 0.9.0 once CI passes again.

@DrunkOnJava
DrunkOnJava merged commit ca49933 into DrunkOnJava:main Oct 26, 2026
28 checks passed
@DrunkOnJava DrunkOnJava mentioned this pull request Oct 26, 2026
7 tasks done
DrunkOnJava added a commit that referenced this pull request Oct 26, 2026
## Summary

Prepares the 0.9.0 release (RELEASE.md steps 4 to 8): the version in
every file that carries it, the changelog's `[0.9.0]` section assembled
from the 30 fragments with its introduction and "Upgrading from 0.8",
`CITATION.cff`'s version and date, the release-please manifest, and the
README's release section. Merging this is not the release: the signed
`v0.9.0` tag on its squash commit is.

## Changes

- Version 0.9.0: `Cargo.toml`, `rvt-py/Cargo.toml` and its `=` pin,
`rvt-wasm/Cargo.toml`, `tools/stream_evidence/Cargo.toml`'s pin,
`CITATION.cff`, `.release-please-manifest.json`, `viewer/package.json`,
and the rvt crates' entries in `Cargo.lock` and `fuzz/Cargo.lock`.
- `CHANGELOG.md`: `python3 tools/release/changelog.py assemble`, then
the `[0.9.0] — 2026-10-26` section, crediting puzzbobb (#1033).
- `README.md`: `## Release 0.9.0 and main`.
- Core Interior's witness observations and verdicts from this PR's CI
run (the IFC header carries the version), in a follow-up commit.

## Testing

- `python3 tools/release/changelog.py check` and
`tools/ci/api-doc-ids.py` pass locally; CI runs the rest.
- Nothing else changes: every export on `main` was measured in its own
PR.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR (install.md,
status.md and python.md move after the channels are verified, as
RELEASE.md's Post-release says)
- [x] Changelog assembled; no fragment left
- [x] No emojis in code, docs, or commit messages
- [x] No private paths, personal email addresses, or internal jargon in
committed files

## Legal and contribution hygiene

- [x] Apache-2.0
- [x] No Autodesk proprietary content
- [x] No fixtures

## Breaking changes

None.
@DrunkOnJava

Copy link
Copy Markdown
Owner

This shipped in v0.9.0, credited in its changelog. Thanks again.

@puzzbobb
puzzbobb deleted the re421-schema-marker branch October 26, 2026 18:07
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.

2 participants