Skip to content

feat(elem-table): read the owner ElementId every record carries (#152) (RE-31) - #294

Merged
DrunkOnJava merged 1 commit into
mainfrom
feat/elem-table-owner
Sep 22, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
feat/elem-table-owner

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Every Global/ElemTable record carries the ElementId of the element it belongs to. It sits in the field the layout detector had treated as a 0xFF marker. ElemRecord::owner_id now reads it, and rvt-elem-table, --json and Python expose it. RE-31 documents the measurement. It supports #152's ownership hypothesis at a different field from the one RE-152 falsified.

Motivation

RE-30 (#290) found that this "marker" was absent on some records, and that the values in it looked like ElementIds. RE-152 had seen interior words coincide with declared ids and set that aside for lack of an independent oracle. The partition element record of the same element supplies one.

Evidence (RE-31)

file layout set declared id density in the element's own partition reference list
Revit_IFC5_Einhoven.rvt 28 B, u32 at +0 338 / 2,614 338 0.301 not measured (no 2023 element records)
2024_Core_Interior.rvt 40 B, u64 at +4 22,368 / 26,425 22,368 0.198 19,015 of 21,848 framed (87 %)
Snowdon Towers architectural (local only) 40 B 29,177 / 47,233 29,131 0.019 1,527 of 1,648 (93 %)

By category on Core Interior, using BuiltInCategory names from the public API stubs:

  • OST_CurtainWallMullions, OST_CurtainGridsWall and OST_CurtainWallPanels point to an OST_Walls record 15,989 times.
  • OST_SketchLines points to an uncategorised symbol record 2,944 times.
  • Columns, rooms, doors, walls and panels point to an OST_IOSModelGroups record.

Wall→wall (697), floor→floor (124) and symbol→symbol (128) pairs are recorded, not attributed.

Changes

  • src/elem_table.rs:
    • ElemRecord::owner_id (serde default, skipped when None), decoded at marker_offset with the marker's width.
    • read_layout.
    • Three inflate copies folded into one helper.
    • Two unit tests: 40-byte and 28-byte owners, and no owner on the implicit family layout.
  • src/bin/rvt_elem_table.rs:
    • Prints the detected layout ("8-byte owner field at record +4") instead of looking for 0xFF in record 0, which mislabelled any file whose first record names an owner.
    • Counts records that name an owner.
    • --json adds layout, records_with_owner and owner_id.
  • Python elem_table_records() gains owner_id, with the stub and test updated.
  • tests/elem_table_corpus.rs: pins 338 / 2,614 and 22,368 / 26,425, each set value a declared ElementId.
  • Docs:
    • reports/element-framing/RE-31-elemtable-owner-field.md, with an update note on RE-152.
    • The layout doc.
    • A support-matrix elem-table-owner row (experimental).
    • CHANGELOG.

Testing

  • tools/check-local.sh with both corpora: fmt, clippy -D warnings, rustdoc -D warnings, full test suite
  • cargo +1.85.0 check --profile ci --all-targets (MSRV)
  • Python: maturin develop --release, 64 passed
  • rvt-elem-table on Einhoven, Core Interior and Snowdon prints the layouts and owner counts above

Audit-honesty checklist

  • README / docs reflect the current state after this PR (support matrix experimental; the export does not use the field)
  • If a limitation was resolved, the "Known limitations" / "What works today" section in the relevant docs is updated (N/A)
  • New limitation documented: three pair kinds unattributed; no reference IFC holds curtain-wall aggregation or groups
  • 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
  • Reverse-engineering finding: RE-31 with hashes, densities, the oracle and what is not claimed

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). Category names come from the public API enumeration.
  • Test fixtures: synthetic records; corpora gated, not committed

Breaking changes

ElemRecord gains a public field, so code that builds it with a struct literal must add owner_id. JSON output only adds keys.


Note

Low Risk
Read-only ElemTable decoding and CLI/Python exposure; no IFC or export behavior changes. Struct-literal ElemRecord callers must add owner_id.

Overview
Decodes and surfaces an owner ElementId on each Global/ElemTable record (RE-31 / #152). The bytes the layout detector treated as an all-0xFF marker are the field’s unset value; when set they are a declared ElementId (u32 at record +0 on 28-byte / 2023 layouts, u64 at +4 on 40-byte / 2024).

ElemRecord::owner_id reads it during record parse; implicit family records always get None. read_layout is added and ElemTable inflate is deduplicated behind one helper.

rvt-elem-table reports the detected layout (including “owner field at +N”) instead of inferring from the first record’s 0xFF pattern, prints how many records name an owner, and extends --json with layout, records_with_owner, and per-record owner_id. Python elem_table_records() and stubs gain the same optional field.

Corpus and unit tests pin owner counts and that every set value is a declared id; docs add RE-31, changelog, and an experimental support-matrix row. IFC export does not consume owner_id yet.

Reviewed by Cursor Bugbot for commit 6d16141. Configure here.

… (RE-31)

The run of 0xFF bytes detect_layout anchors on is not a marker. It is an
ElementId field whose unset value is all 0xFF: a u32 at +0 on the 28-byte
2023 layout, a u64 at +4 on the 40-byte 2024 layout. On
2024_Core_Interior.rvt it is set on 22,368 of 26,425 records, and every
value is a declared ElementId (id density 0.198). On Snowdon Towers it is
29,131 of 29,177 at density 0.019, and on Einhoven 338 of 338. The
element's own partition record corroborates it independently: 87% of set
values on Core Interior (93% on Snowdon) appear in that element's counted
reference list.

By category, curtain panels, mullions and grids name their curtain wall,
sketch lines their sketch, and grouped elements their model group. Other
pairs are recorded, not attributed. This supports #152's ownership
hypothesis at a different field from the trailing word RE-152 falsified.

ElemRecord::owner_id reads the field, and elem_table::read_layout returns
the detected layout. rvt-elem-table prints that layout instead of sniffing
the first record for 0xFF, which misread any file whose first record names
an owner. It also counts records that name an owner, and --json adds
layout, records_with_owner and owner_id. Python's elem_table_records()
dicts gain owner_id. tests/elem_table_corpus.rs pins the Einhoven and Core
Interior counts. The support matrix gains an experimental
elem-table-owner row, and the IFC export does not use the field yet.
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) September 22, 2026 20:48
@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_d8c198bd-249a-4cd8-8493-39823619ec25)

@DrunkOnJava
DrunkOnJava merged commit da81472 into main Sep 22, 2026
22 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/elem-table-owner branch September 22, 2026 20:51
DrunkOnJava added a commit that referenced this pull request Sep 22, 2026
## Summary

Prepare the v0.2.0 release: the inspection-focused alpha described in
`docs/release-0.2.0-plan.md`. It ships PyPI wheels, prebuilt CLI
archives for 5 platforms and the multi-arch container image. **crates.io
is not part of this release:** no `CARGO_REGISTRY_TOKEN` is configured,
and publishing is deferred. Merging this PR is **not** the release.
Nothing is published until the draft v0.2.0 GitHub Release (archives
attached from a tagged-name `workflow_dispatch` run) is published, which
creates the tag and runs `publish.yml`. Until then the docs on `main`
say 0.2.0 is prepared and not yet published.

## Changes

- Versions: `rvt` and `rvt-py` go to 0.2.0, along with the
`stream_evidence` pin, both lockfiles and
`.release-please-manifest.json`.
- `CHANGELOG.md`: `[Unreleased]` is promoted to `[0.2.0] — 2026-09-22`,
with an empty `[Unreleased]` stub.
- `publish.yml`: when `CARGO_REGISTRY_TOKEN` is not configured, the
crates.io job now logs a warning and exits successfully, so PyPI and the
release binaries still ship. A crate the registry rejects still fails
the job and blocks PyPI, which keeps the protection against publishing
mismatched Rust and Python versions.
- `docs/install.md`: the publication table keeps PyPI at 0.1.2 and marks
the 0.2.0 archives and the container image **not yet published**.
crates.io and docs.rs stay marked **not published**.
- `release-binaries.yml`: a `workflow_dispatch` `tag` input names
archives for a release without uploading, which is used to stage the
draft.
- `docs/release-0.2.0-plan.md` and the CHANGELOG heading: prepared, not
yet released.

## Testing

- [x] `cargo publish --dry-run -p rvt`: packages and verifies 482 files
(1.7 MiB)
- [x] Full local gate on the constituent PRs (#289–#297); this PR only
bumps versions and changes docs and workflow configuration
- [ ] CI on this PR

## Follow-up

crates.io and docs.rs: add a crates.io API token as the repo secret
`CARGO_REGISTRY_TOKEN`, then publish `rvt` 0.2.0 (or 0.2.1), and update
`docs/install.md`.

## Breaking changes

`ElemRecord` gained `owner_id` (#294); a struct literal of it now needs
that field.
DrunkOnJava added a commit that referenced this pull request Sep 28, 2026
…s it (#152) (RE-31) (#499)

## Summary

`Global/ElemTable`'s records start at `0x06` and each ends with its
owner field. rvt-rs parses a frame starting at `0x1E`, so the owner
field that opens each parsed frame belongs to the record before it.
`ElemRecord::owner_id` (RE-31, #294) paired every owner with the next
element.

STE1200 reported this on #152 (and again in Discussion #112), together
with the test that settles it: an ownership tree has no self-owned
record and no cycle.

## Measured

| file | old pairing: self-owned / in a cycle | new pairing |
|---|---:|---:|
| Core Interior | 304 / 331 | 0 / 0 |
| Snowdon Towers Architectural | 1,342 / 1,356 | 0 / 0 |
| RE1 Architecture | 26 / 28 | 0 / 0 |
| Einhoven | 7 / 7 | 0 / 0 |

RE-31's independent oracle is the element's own partition reference list
naming its owner. `examples/probe_re31_owner_frame.rs` measures it:

| file | old pairing | new pairing |
|---|---:|---:|
| Core Interior | 86.6 % | 21,072 of 21,074 |
| Snowdon Towers | 92.4 % | 1,574 of 1,574 |

The wall→wall, floor→floor and symbol→symbol pairs RE-31 could not
explain were artefacts of the shift, and are gone.

## Change

- `parse_records_from_bytes` gives each record the owner field that
follows it.
- The last record's owner is read from the table's tail, and kept only
when it names a declared element.
- The table's first record, at `0x06`, is still not parsed. Its owner
(the `0x0011` `header_flag` reports on family files) is documented as
such.
- Updated: the corpus test pins (Einhoven 338 → 339 owners, and no
record may name itself), the support matrix entry, RE-31 §6, the
`rvt-elem-table` layout label and the CHANGELOG.

Nothing in the IFC export uses `owner_id`.

## Checks

- Local: fmt, clippy, doc, MSRV 1.85, fuzz check, integration tests, and
the corpus run via `verify-real-files.sh`.

## Clean-room declaration

This finding comes from public byte observations of the corpus files
only. The report and the self-ownership test are from STE1200
(Discussion #112, #152), credited.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes decoded metadata for every explicit-layout ElemTable consumer
(`rvt-elem-table`, Python `elem_table_records()`); behavior is better
validated but is a semantic fix, not a no-op.
> 
> **Overview**
> **Fixes `ElemRecord::owner_id` (RE-31, #152):** `Global/ElemTable`
records begin at `0x06` and end with an owner field, but parsing starts
at `0x1E`, so the marker at each frame's start actually **closes the
previous record**. Owners were previously paired with the **next**
element, which produced hundreds of self-ownerships and weaker agreement
with partition reference lists.
> 
> **`parse_records_from_bytes`** now assigns each record the owner read
from the **following** frame (and reads the last record's owner from the
table tail, only when that id is declared). Docs, corpus tests (no
self-owners; Einhoven owner count 338→339), `probe_re31_owner_frame`,
RE-31 §6, support matrix, and `rvt-elem-table` layout text are updated.
**IFC export still does not use `owner_id`.**
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
e08a591. 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