Repository navigation
red run: elem_table_frame (B02, do not merge) - #558
Closed
DrunkOnJava wants to merge 1 commit into
Closed
DrunkOnJava wants to merge 1 commit into
DrunkOnJava wants to merge 1 commit into
Conversation
A real-file target from the table's description (STE1200's frame, puzzbobb's measurements on #152): parse_records returns the u32 count at 0x02, ids rise strictly, owners are declared ids with no self-owner or loop, and a family's first record is owned by element 17. Expected red on main: the 2016-2023 families and Einhoven read one record short or one too many, and every 2024+ file ends in a record read from the tail.
Owner
Author
|
Red run captured (run 37115866869); the test lands in the B02 fix PR. |
DrunkOnJava
added a commit
that referenced
this pull request
Oct 3, 2026
`Global/ElemTable` is now read as the table it is (#152). After the `u16` tag and the `u32` record count at `0x02`, the records start at `0x06` and close with their owner: | Releases | Record | Layout | |---|---|---| | 2008 to 2023 | 28 B | `[u32 id][u32 id][16 B][u32 owner]` | | 2024 on | 40 B | `[u64 id][12 B][u64 id][u64 owner][u32]` | This is STE1200's frame. puzzbobb measured it on 30 files from 2008 to 2027 (#152, issuecomment-5939876282 and 5951500722). ## What was wrong `elem_table::parse_records` framed records from `0x1E`, 24 bytes into each record: - It never returned the table's first record. - On every 2024 and later file and on every family, it returned a last record read from the bytes after the table: `(0, 0)` on the projects, and id 18 after 7,259 on the 2016 family. That declared an id 0 that no record holds. - On 28-byte projects it returned one record too few: 2,614 of Einhoven's 2,615. ## What changes - `parse_records` returns exactly the stated count from `0x06`, ids rising over the whole table, each record with its own owner. A family's first record is owned by element 17. - `detect_layout` takes the record size (28 or 40) at which the stated records fit with rising ids, with the shorter tail breaking a tie. That also reads the 2008 to 2012 projects, where the marker scan took an 84-byte stride; no such file is in our corpora. - `revit_global_ids`: the episode is at `+8` of the record on both sizes. These are the same bytes as `+0x18` and `+0x0c` of the old frames, so no GlobalId changes. - `ElemRecord::previous_ids` (from #553, unreleased) is always `None`, because the first record is `records[0]`. - `header.record_count` stays a `u16`, the low half of the count; no measured file has 65,536 records. `parse_records` reads the full `u32`. ## Tests The commits are separate, so each can be reviewed on its own: 1. `test(elem_table)`: the new real-file target `tests/elem_table_frame.rs`, written from the table's description. Its red run on `main` (draft PR #558, run 37115866869) is in the commit message: - 2016 family: `ids rise strictly, but record 1595 has id 18 after 7259 (of 1596)` - Einhoven: `parse_records returns the 2615 records the table states, left: 2614, right: 2615` 2. Five existing tests in `tests/elem_table_corpus.rs` move to the `0x06` reading. The maintainer approved this before the reader changed, and each changed value is listed in the commit. 3. The inline mirror suite of `src/elem_table.rs` is deleted (336 lines; unit-test option (c), B23). One pure-logic test stays. 4. The fix. Reported by puzzbobb and STE1200 (#152, #421). ## One consequence, fixed here `partition_type_parameters::value_blocks` ended a value block at a mark only when the u64 before it was a declared id. The old reader declared a false id 0 on every 2024 and later file, so marks owned by 0 ended blocks. Once 0 is declared only where it is an element, RE1 Architecture's curtain wall type (474504) took the next block's `Type Mark` '2'. Measure run 37116833078 showed this as the only output difference across 6 models, 11 families and 36 samples. Revit's export writes no Type Mark, so it cannot decide the value. A mark owned by 0 now starts an unowned block unless 0 is declared. It still ends the block before it, and its values go to no type. ## Measured Measure run 37117234625 compared head against `main`, with the families and samples: - the IFC of all 6 reference models is byte-identical; - every scorer, `rvt-info` and `diagnostics.json` output is identical on all 6 models, 11 families and 36 sample projects. The new reading's invariants on 54 files (2014 to 2027) are in RE-147 (run 37117029420): every file reads its stated count, ids rise, and every set owner is declared, with no self-owner or loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scratch PR for a red run of the new tests/elem_table_frame.rs on main. Closed and its branch deleted once CI reports.
Note
Low Risk
Test-only change: new integration assertions and CI registration, no library or export behavior changes.
Overview
Adds
tests/elem_table_frame.rs, a real-file integration target that locks in the Global/ElemTable layout from #152: stated record count vsparse_records, strictly rising primary ids, and owner-id rules (in-table, no self-ownership, no cycles). Family corpus samples (2016–2026) also assert the first record’s owner is element 17; MIT project files get the shared checks whenRVT_PROJECT_CORPUS_DIRis set.Corpus behavior matches
elem_table_corpus: optional corpora skip with a message;RVT_REQUIRE_CORPUSfails the gate if the family set is incomplete.tools/ci/test-targets.txtregisterselem_table_frameunder therealclass so CI and the local gate run it with the other corpus-backed tests.Reviewed by Cursor Bugbot for commit 1cad6ac. Configure here.