Skip to content

feat(diagnostics): count where the element records of a Revit 2008 to 2023 file stop (#1389) - #1397

Merged
DrunkOnJava merged 6 commits into
mainfrom
feat/1389-element-record-stage-counts
Nov 5, 2026
Merged

DrunkOnJava merged 6 commits into
mainfrom
feat/1389-element-record-stage-counts

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

For a Revit 2008 to 2023 record layout, the marker scan and the recovery after it count where element records stop: the markers found, those with a declared ElementId (52 bytes before the marker, the ElementHeader tag 8 bytes after it), the category and box checks, the placed instances, those with volume, then what the recovery keeps, hands to the export, and what the model holds or sets aside. The counts are in decoded.element_record_stages, per partition stream and in total; the frames that stopped are also in skipped as element_record_frame_stopped; with --export-decisions they are listed in the decisions log; an export that wrote no record names the stage in stopped_at. Diagnostics only: the IFC is unchanged.

Motivation

#1389, from hemanth1986's four files on #421 (saved by Revit 2024 to 2026, a 2022 or 2023 schema, no element exported). RevitFile::layout_release routes them correctly, but the "record rejected" counters (element_record_without_element_id, element_record_without_volume) read the 2024 layout and return nothing for 2008 to 2023, so the diagnostics showed only low_confidence_schema_scan_candidate and no one could say which stage lost the elements.

Changes

  • src/research/partition_element_records_2023.rs: scan_records_counted is scan_records with per-stream integer counts; decode_at_marker returns where a frame stopped (Stop) instead of None, with the same decisions. The default path keeps integers only: the streams are found by name without allocating one, and the per-frame list (stopped) is built only when asked for (RevitFile::record_frame_decisions, set from ExportOptions::export_decisions, which drops the memoised walk as value sources do). A stream that does not inflate is counted (stream_not_read).
  • src/research/partition_schema_mvp/records_2023.rs, records.rs, src/walker.rs: select_newest_instance_records and the design option, phase, nested and category steps of recover_2023_records count at the points where they already decide; nested_component_ids is split out of without_nested_components; the walk notes a record element it drops because an earlier reader held the ElementId.
  • src/ifc/element_record_stages.rs: StageCounts, ElementRecordStages (the report), stopped_at; the skipped item is counted from the integers, and the decisions are made only for the log.
  • src/ifc/export_decisions.rs: for element_record_frame_stopped the log keeps 1,000 entries of each of the five stages (the cap of 5,000 shared out), so the stage that sorts first, the frames with no ElementId, does not fill it.
  • src/ifc/mod.rs: decoded.element_record_stages, for every export of a file of the layout, even with every count zero, but a placeholder export's.
  • rvt-ifc prints a line of its own when no record was written, and none for an input named .rfa or .rft (a family reads its elements from Global/Latest).
  • rvt-mcp/src/schema.rs: the doc of SkippedOut.count says that for element_record_frame_stopped it is frames of every category, not lost elements. That changes the MCP output schema's description, so the contract (docs/mcp-tools.json) will need the watcher's sync; no tool description changed.
  • docs/schemas/export-diagnostics.schema.json, docs/export-diagnostics.md (a section "Element record stages"), changelog.d/added/1389-element-record-stages.md.
  • tests/element_record_stages.rs (class real), tools/re/element_stage_counts.py and its step in measure_sample.

What "adds up" means here

Per stream and in total, each step is exactly the sum of what the next step took and left (StageCounts::unbalanced and the scorer check the same five sums), and the streams' counts sum to the file's. The elements handed to the export are written plus set aside, each for one cause: handed_to_export = written_to_model + id_already_held + below_min_confidence + sum(not_written_by_class). written_to_model is counted from the IFC model; id_already_held from the walk's own dedup; below_min_confidence from the walk's confidence floor; the rest, by the Revit class they were handed as (elements the exporter writes nothing for, such as a Mass with no "Export to IFC As"; not attributed further here). exported.building_elements also holds elements other readers write (Areas, ArcWalls, stair and curtain-wall parts), so it is an upper bound for written_to_model, not an equality. no_declared_id can include frames inside loaded families' own documents (RE-135); without_volume is frames of every category. The docs say so.

Review items of the second read (2026-11-04)

  1. Default-path cost: integers only; no String per stopped marker or per record; the per-frame list only for the log; no clone of the list (the decisions are made from a borrow).
  2. The 1 to 6 elements: counted by cause as above. NOT MEASURED on this head until the run below finishes.
  3. The changelog and docs give run 41932213967's figures (head f44b028, before the set-aside causes).
  4. The log's cap: counts complete, log capped, and a share for each stage.
  5. A stream that fails to inflate is counted (stream_not_read) and stopped_at cannot say no_markers for it.
  6. without_volume and the skipped count are labelled frames in the docs, the schema, the MCP SkippedOut.count doc and ExportDecision.class.
  7. rvt-ifc prints the line on its own, and none for a family file, decided by the input's name (checked on the committed tests/fixtures/families/empty.rfa). The first version of this round withheld the report from any file with a PartAtom stream, and CI showed the committed synthetic project corpus/tier1/structural-2023 carries one as a family does (it has no ProjectInformation stream either), so streams cannot tell a family from that project; the all-zero case now has its report.
  8. The stop order is documented (category, then box, then id).

Testing

Nothing was built or run locally (lane rule); the results are CI's and Measure's. This round's Rust was written without a compiler: CI's first run on this head is its first check.

  • cargo fmt --all -- --check, tools/release/changelog.py check, tools/ci/api-doc-ids.py, tools/ci/render-mcp-tools.py --check and python3 -m py_compile tools/re/element_stage_counts.py were clean locally.
  • Measure run 41932213967 (head f44b028, before this round): ifc.sha256 equal to main's on all 37 exports (33 samples of 2015 to 2023, Einhoven, Core Interior, RE1 Architecture, RE1 Electrical), and element_stage_counts.txt ending ok on all 33 samples.
  • Measure run 41935682998 (head 1258ff5, the same inputs): the counts changed shape (the set-aside causes, stream_not_read), so it is run again. Wanted: ifc.sha256 equal on every export, element_stage_counts.txt ok on every sample, and handed_to_export = written + set aside on each. NOT MEASURED until it finishes. The head after it (2ca24f2) differs only in when the report is withheld (a placeholder export alone), the rvt-ifc stderr line, tests and docs; none of the 33 samples, nor Einhoven, has a PartAtom stream (input.has_part_atom false in run 41932213967's diagnostics), so the earlier gate withheld nothing from them and the run's counts stand for the new head.
  • CI at 1258ff5 failed two of this test's own cases (the structural-2023 fixture had no report, from the PartAtom gate above); the Einhoven case passed. Fixed at 2ca24f2; NOT MEASURED until CI reports on it. tests/element_record_stages.rs in Corpus health (Einhoven's markers recounted from the bytes, the sums, the default export against the logged one, the log entries re-read; the structural-2023 fixture's stage and rvt-ifc line; the family fixture's absence of both). NOT MEASURED until CI reports.
  • Not measured: hemanth1986's files (not available to this session).

Audit-honesty checklist

  • README / docs reflect the current state after this PR
  • Changelog fragment changelog.d/added/1389-element-record-stages.md
  • Limitations documented in the PR body and in the docs
  • No emojis, no private paths in committed files
  • Reverse-engineering finding: N/A (diagnostics counts of an existing decode)

Breaking changes

None. A new optional field in decoded and a new skipped reason, for projects of the 2008 to 2023 layout only; the IFC is unchanged.

Related issues

Closes #1389. Closes is justified if run 41935682998 shows the three done-when items: the sums on every public 2015 to 2023 sample with the elements handed to the export equal to written plus set aside, an all-zero export that names its stage (the tier1 test), and a byte-identical IFC.

Measured on 1258ff5 (run 41935682998): the IFC byte-identical on 37 of 37 exports, and element_stage_counts.txt ends ok on all 33 samples of 2015 to 2023, with handed_to_export = written + id_already_held + below_min_confidence + not_written_by_class closing exactly. The later commits change only the family and placeholder gate, the docs and the MCP contract.

… 2023 file stop, stage by stage (#1389)

The rejected-frame reasons read the 2024 layout and counted nothing on 2008 to 2023 files, so a file that exported no element showed only low_confidence_schema_scan_candidate. The marker scan and the recovery that follows now count, per partition stream and in total, the markers, those with a declared ElementId, the records, the placed instances, those with volume, the frames kept, the elements handed to the export and the elements the model holds, each step what the one before it passed on and left. They are in decoded.element_record_stages, the frames that stopped are in skipped as element_record_frame_stopped and in the log of decisions, and an export that wrote no record names the stage in stopped_at. The counts are made where the scan already decides; the IFC is unchanged. tests/element_record_stages.rs re-reads the markers on Einhoven and checks a file with no record; Measure checks the sums on each sample project with tools/re/element_stage_counts.py.
…s record, sums streams from zero, and the docs say what no_declared_id can hold (#1389)
@DrunkOnJava DrunkOnJava added the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 4, 2026
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 4, 2026 23:19
@DrunkOnJava DrunkOnJava removed the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 4, 2026
…th, count what is set aside, and say what a count is (#1389)

The default export keeps integers only: the per-frame list is built when the log of decisions is asked for (RevitFile::record_frame_decisions), the streams are found without allocating a name, and the skipped item is counted from the integers. The elements handed to the export are written plus those set aside for one cause each (an ElementId an earlier reader already held, below the confidence floor, or by Revit class). A stream that does not inflate is counted as stream_not_read. The log keeps a share of its cap for each stage of element_record_frame_stopped. A family file and a placeholder export have no report, and rvt-ifc prints the stage on a line of its own. The stop order is documented, and the MCP count of the item says frames.
@DrunkOnJava DrunkOnJava added ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes and removed ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes labels Nov 4, 2026
…eport, and rvt-ifc leaves a family file out by its name (#1389)

The report was withheld from a file with a PartAtom stream, which the committed synthetic projects carry as a family does, so the all-zero case had no report. Only a placeholder export has none now; rvt-ifc prints no line for a .rfa or .rft input.
@DrunkOnJava DrunkOnJava added the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 4, 2026
@DrunkOnJava DrunkOnJava removed the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
@DrunkOnJava
DrunkOnJava merged commit 240c7d7 into main Nov 5, 2026
38 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/1389-element-record-stage-counts branch November 5, 2026 00:11
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.

Diagnostics: count where 2008 to 2023 element records are dropped (marker, envelope, declared id, instance, volume)

1 participant