Repository navigation
Lane Nine: Python decoded API, schemas, and rvt-elements CLI - #128
Conversation
Curate Apache-2.0 synthetic fixtures under corpus/tier1/ with license and known-count sidecars for levels/walls/floors/doors/windows, extend project_count_fixtures for fixture_metric inventories, and wire corpus-tier1 (always-on) plus corpus-tier2 (external magnetar) CI jobs. Co-authored-by: DrunkOnJava <[email protected]>
Co-authored-by: DrunkOnJava <[email protected]>
…e link Add a version-gated (Revit 2023/2024) filtered-tag scanner that emits neutral PartitionRecordCandidate records, expresses the existing ArcWall path, and joins recovered ElementIds to Global/ElemTable offsets (M3-03 / M3-04). Includes JSON probe example and tier1/corpus tests. Co-authored-by: DrunkOnJava <[email protected]>
Satisfy clippy::collapsible_if under -D warnings. Co-authored-by: DrunkOnJava <[email protected]>
Harden Level/Wall/Floor/Door/Window/Room/Material wrong-schema rejection and empty-input behavior; add ArcWall typed partition decoder with class/tag rejection; expose decoder_for_class/decode_typed; add tier1 corpus tests that exercise fixture payloads without inventing geometry. Co-authored-by: DrunkOnJava <[email protected]>
Co-authored-by: DrunkOnJava <[email protected]>
Expose typed MVP projections on decoded_elements, add stable JSON schemas for decoded-elements and element-counts, mirror the surface via rvt-elements, and cover the path with always-on tier1 pytest. Co-authored-by: DrunkOnJava <[email protected]>
Co-authored-by: DrunkOnJava <[email protected]>
Co-authored-by: DrunkOnJava <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Partition scanner end-of-buffer panic
- Changed the scan loop's last safe offset from len-3 to len-4 so tag/filter_pad reads never index past the buffer end.
Or push these changes by commenting:
@cursor push f6cb31dd50
Preview (f6cb31dd50)
diff --git a/src/partition_scanner.rs b/src/partition_scanner.rs
--- a/src/partition_scanner.rs
+++ b/src/partition_scanner.rs
@@ -231,7 +231,7 @@
}
let mut out = Vec::new();
- let last = buf.len().saturating_sub(3);
+ let last = buf.len().saturating_sub(4);
for offset in 0..=last {
let tag = u16::from_le_bytes([buf[offset], buf[offset + 1]]);
if !tags.contains(&tag) {You can send follow-ups to the cloud agent here.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0a685c6. Configure here.
| continue; | ||
| } | ||
| // RE-14.2 record-prefix filter: bytes at +2/+3 must be zero. | ||
| if buf[offset + 2] != 0 || buf[offset + 3] != 0 { |
There was a problem hiding this comment.
Partition scanner end-of-buffer panic
High Severity
scan_partition_buffer walks 0..=len-3 and then reads offset+3 whenever the two-byte tag matches. That last offset needs a fourth byte that is not in the slice, so a schema tag in the final two bytes panics the scanner on otherwise valid partition data.
Reviewed by Cursor Bugbot for commit 0a685c6. Configure here.
Co-authored-by: DrunkOnJava <[email protected]>
## Summary Implements Lane Seven (IFC quality) on top of Lane Six geometry recovery: `scaffold` / `typed-no-geometry` / `geometry` / `strict` now shape *emission* as well as post-export validation gates, HostObjAttr proxies stay out of production export, and diagnostics sidecars remain schema-shaped. Depends on Lane Six (`geometry/wall-floor`, PR #129) which includes typed decoders (#127). Aligns with Lane Nine (#128) forward-compatible mode names that fail closed for stronger modes. ## Motivation Quality modes previously acted mainly as validation gates on a single default export. Lane 7 makes mode content real where data allows: typed-only inventory without geometry claims, geometry attachment via Lane Six recovery when present, and strict fail-closed behavior without misleading proxies. Refs M5-01 / M5-02 / M5-04 (TODO.md). Downstream: Lane 8 viewer confidence UI. ## Changes - `src/ifc/export_content.rs` — content policy per quality mode; HostObjAttr/HostObject/Element/Symbol filter; Level → storey via elevation recovery; Wall curve / Floor boundary / Door·Window host attachment; geometry strip helper - `RvtDocExporter::export_with_diagnostics_mode_and_limits` — mode-aware emission - `rvt-ifc --mode` + Python `write_ifc(mode=...)` pass mode into export content - Default/scaffold never emits `HostObjAttr-*` proxies (diagnostic exporter unchanged) - Diagnostics sidecar unchanged schema (`docs/schemas/export-diagnostics.schema.json`); docs note content policy - `tests/ifc_export_modes.rs` — always-on tier1 coverage for all four modes + CLI ### Mode semantics | Mode | Emission | Gate | |------|----------|------| | `scaffold` | Framework + production elements; geometry when recovered; no HostObjAttr proxies | Always accepts valid envelope | | `typed-no-geometry` | Mapped/typed only; geometry fields stripped | Requires typed elements | | `geometry` | Mapped/typed; Lane Six curves/loops/hosts/elevations when present | Requires typed + geometry | | `strict` | Same as geometry | Typed + geometry + metadata/units/storeys + no warnings/unsupported | On synthetic / tier1 fixtures only `scaffold` succeeds — honest scaffold-only, no invented geometry. ## Testing - [x] `cargo test --release --lib ifc::export_content` — 6 passed - [x] `cargo test --release --lib ifc::` — 325 passed - [x] `cargo test --release --test ifc_export_modes` — 8 passed - [x] `cargo test --release --test ifc_synthetic_* --test rvt_ifc_diagnostics_cli --test walker_to_ifc_integration` — passed (corpus tests skip without samples) - [x] `cargo fmt --check` - [x] `cargo clippy --all-targets --all-features -- -D warnings` - [x] `cargo clippy -p rvt-py --all-targets -- -D warnings` - [x] Smoke: `gen-fixture` + `rvt-ifc --mode scaffold|typed-no-geometry|geometry|strict` — HostObjAttr absent; stronger modes fail closed with diagnostics ## Audit-honesty checklist - [x] Tier1/synthetic remain scaffold-only; no invented wall/floor geometry - [x] HostObjAttr proxies absent from default/scaffold; diagnostic path retained - [x] Mode docs do not claim geometry/strict success on scaffold fixtures - [x] No Autodesk samples committed - [x] Commit messages describe what/why ## Legal and contribution hygiene - [x] Apache-2.0 licensable - [x] No Autodesk proprietary / decompiled content - [x] Fixtures remain synthetic (`gen-fixture` / corpus/tier1) ## Breaking changes None for callers of `RvtDocExporter::export` (still scaffold content). New `export_with_*_mode_*` APIs are additive. CLI/Python `--mode` / `mode=` now also shapes content (typed-no-geometry strips geometry). ## Related issues Refs #37 (M5-01), #38-class HostObjAttr (M5-02), #40 (M5-04). Depends on #129 (Lane Six). Aligns with #128 (Lane Nine mode names). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > IFC export behavior changes for non-scaffold modes and production element filtering; broader surface area (partition scanner version gates, committed binaries) but synthetic corpus and fail-closed validation limit blast radius. > > **Overview** > Adds a **two-tier test corpus** (in-repo Apache-2.0 synthetic `corpus/tier1/` plus optional CI-cloned magnetar tier 2), CI jobs `corpus-tier1` / `corpus-tier2`, SHA256 license checks, and known-count manifests—while allowing committed `.rvt` files under `corpus/` via `.gitignore` exceptions. > > Introduces **partition scanning** (`partition_scanner`), a typed **ArcWall** partition decoder, ElemTable linkage helpers, and a `partition_scanner_json` example for JSON diagnostics. > > Adds **Lane Six geometry recovery** (`geometry/recovery`) with fail-closed wall curves, floor boundaries, opening hosts, and level elevations; extends typed **Wall** / **Level** projection for `gen-fixture` fields (`m_height`, location endpoints) and centralizes MVP typed decode via `decode_typed` / `decoder_for_class`. > > Implements **Lane Seven IFC content policy** in `export_content`: `--mode` / Python `mode=` now drives emission (not just validation)—`typed-no-geometry` strips geometry, `geometry`/`strict` attach recovery when present, production export drops **HostObjAttr** proxies, and Levels become storeys from recovered elevations. `RvtDocExporter::export_with_diagnostics_mode_and_limits` wires CLI/Python through to export. > > New integration tests cover tier1 corpus health, geometry honesty on synthetics, and all four IFC export modes (including CLI strict fail-closed on tier1). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6eac930. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: DrunkOnJava <[email protected]>
## Summary Implements Lane Nine (M7-02 / M7-03): expose the decoded-model Python API with Lane Five typed MVP projections, add stable JSON schemas for those payloads, and mirror the surface with a `rvt-elements` CLI. Depends on Lane Five (`elements/typed-decoders`, PR #127) — this branch is based on that work (includes Lanes Three–Five). ## Motivation Downstream automation and the viewer need one Python/CLI contract for production decoded elements, class counts, export diagnostics, and IFC write modes. Lane Five’s typed views must be reachable from Python without inventing geometry on scaffold fixtures. ## Changes - `RevitFile.decoded_elements()` — adds optional `typed` MVP projection (Level/Wall/Floor/Door/Window/Room/Material) - `RevitFile.element_counts()` / `export_diagnostics()` / `write_ifc(mode=...)` — documented + stubbed; modes remain `scaffold` | `typed-no-geometry` | `geometry` | `strict` - `rvt.MVP_TYPED_CLASSES` constant for introspection - `rvt-elements` CLI — JSON dump of elements or `--counts` (same schemas as Python) - Schemas: `docs/schemas/decoded-elements.schema.json`, `docs/schemas/element-counts.schema.json` - Always-on Python tests on `corpus/tier1/` (no Autodesk samples required) ### Mode honesty | Mode | Behavior today | |------|----------------| | `scaffold` | Accepts spec-valid IFC envelope (default) | | `typed-no-geometry` | Requires validated typed elements | | `geometry` | Requires typed + geometry | | `strict` | Geometry + metadata/units/storeys + no warnings | On synthetic / scaffold-only fixtures, only `scaffold` typically succeeds until Lane 7 geometry recovery lands. Stronger modes raise `ValueError` rather than over-claiming. ### Corpus honesty Tier1 `gen-fixture` CFBs are scaffold-oriented. Production walker counts may be zero; tests assert API shape, schema validity, and mode gating — not invented element recovery. ## Testing - [x] `cargo test --release --lib elements::typed_json` — 3 passed - [x] `cargo test --release --test json_schema_contracts` — 3 passed (tier1 elements + counts schemas) - [x] `maturin develop` + `pytest tests/python/test_decoded_api.py` — 5 passed, 1 skipped (`jsonschema` optional) - [x] `cargo clippy -p rvt --all-targets -- -D warnings` - [x] `cargo clippy -p rvt-py --all-targets -- -D warnings` - [x] `cargo fmt --check` (via fmt before push) - [ ] Corpus Autodesk sample pytest (`test_rvt.py`) — skips without `RVT_SAMPLES_DIR` ## Audit-honesty checklist - [x] Mode docs do not claim geometry/strict success on scaffold fixtures - [x] Typed projection omitted (`null`) for non-MVP classes; ArcWall stays partition-path - [x] No Autodesk samples committed; `*.so` not committed - [x] Commit messages describe what/why ## Legal and contribution hygiene - [x] Apache-2.0 licensable - [x] No Autodesk proprietary / decompiled content - [x] Fixtures remain synthetic (`gen-fixture` / tier1) ## Breaking changes None. `decoded_elements()` entries gain an additive `typed` key (`null` or object). ## Related issues Refs M7-02 / M7-03 (TODO.md). Depends on #127 (Lane Five typed decoders). ## Python API signatures ```python rvt.MVP_TYPED_CLASSES: list[str] RevitFile.decoded_elements() -> list[dict] # id, class_name, byte_range, fields, typed RevitFile.element_counts() -> {"total": int, "by_class": dict[str, int]} RevitFile.export_diagnostics() -> dict RevitFile.export_diagnostics_json() -> str RevitFile.write_ifc(mode: str = "scaffold") -> str rvt.rvt_to_ifc(path, mode="scaffold") -> str ``` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Large additive public API (CLI, Python, JSON schemas) and new always-on CI corpus gates; no auth or payment paths, but regressions would break downstream automation contracts. > > **Overview** > Adds a unified **decoded-model export surface** for automation: new **`rvt-elements`** binary dumps production-walker elements or **`--counts`** JSON aligned with **`RevitFile.decoded_elements()`** / **`element_counts()`**, including an optional Lane Five **`typed`** MVP projection (`Level`, `Wall`, `Floor`, `Door`, `Window`, `Room`, `Material`) via **`typed_json`** and **`MVP_TYPED_CLASSES`**. Stable contracts land in **`decoded-elements.schema.json`** and **`element-counts.schema.json`**, with tier1-backed schema tests and always-on Python tests on **`corpus/tier1/`**. > > **Corpus & CI:** Commits redistributable synthetic **`corpus/tier1/`** fixtures (license SHA256 checks, **`generate.sh`**, count manifests) and wires **`corpus-tier1`** / **`corpus-tier2`** jobs; **`.gitignore`** now allows **`corpus/**/*.rvt`**. **`project_count_fixtures`** supports tier1 **`fixture_metric`** class-instance oracles. > > **Decoder / partition work bundled here:** Generic **`partition_scanner`** (2023/2024), **`elements::arc_wall`**, **`decode_typed`**, gen-fixture field aliases (`m_height` → elevation/height), and related integration tests. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 760917f0c2cfb066499a48fcfe7127d01f874494. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: DrunkOnJava <[email protected]>
## Summary Implements Lane Seven (IFC quality) on top of Lane Six geometry recovery: `scaffold` / `typed-no-geometry` / `geometry` / `strict` now shape *emission* as well as post-export validation gates, HostObjAttr proxies stay out of production export, and diagnostics sidecars remain schema-shaped. Depends on Lane Six (`geometry/wall-floor`, PR #129) which includes typed decoders (#127). Aligns with Lane Nine (#128) forward-compatible mode names that fail closed for stronger modes. ## Motivation Quality modes previously acted mainly as validation gates on a single default export. Lane 7 makes mode content real where data allows: typed-only inventory without geometry claims, geometry attachment via Lane Six recovery when present, and strict fail-closed behavior without misleading proxies. Refs M5-01 / M5-02 / M5-04 (TODO.md). Downstream: Lane 8 viewer confidence UI. ## Changes - `src/ifc/export_content.rs` — content policy per quality mode; HostObjAttr/HostObject/Element/Symbol filter; Level → storey via elevation recovery; Wall curve / Floor boundary / Door·Window host attachment; geometry strip helper - `RvtDocExporter::export_with_diagnostics_mode_and_limits` — mode-aware emission - `rvt-ifc --mode` + Python `write_ifc(mode=...)` pass mode into export content - Default/scaffold never emits `HostObjAttr-*` proxies (diagnostic exporter unchanged) - Diagnostics sidecar unchanged schema (`docs/schemas/export-diagnostics.schema.json`); docs note content policy - `tests/ifc_export_modes.rs` — always-on tier1 coverage for all four modes + CLI ### Mode semantics | Mode | Emission | Gate | |------|----------|------| | `scaffold` | Framework + production elements; geometry when recovered; no HostObjAttr proxies | Always accepts valid envelope | | `typed-no-geometry` | Mapped/typed only; geometry fields stripped | Requires typed elements | | `geometry` | Mapped/typed; Lane Six curves/loops/hosts/elevations when present | Requires typed + geometry | | `strict` | Same as geometry | Typed + geometry + metadata/units/storeys + no warnings/unsupported | On synthetic / tier1 fixtures only `scaffold` succeeds — honest scaffold-only, no invented geometry. ## Testing - [x] `cargo test --release --lib ifc::export_content` — 6 passed - [x] `cargo test --release --lib ifc::` — 325 passed - [x] `cargo test --release --test ifc_export_modes` — 8 passed - [x] `cargo test --release --test ifc_synthetic_* --test rvt_ifc_diagnostics_cli --test walker_to_ifc_integration` — passed (corpus tests skip without samples) - [x] `cargo fmt --check` - [x] `cargo clippy --all-targets --all-features -- -D warnings` - [x] `cargo clippy -p rvt-py --all-targets -- -D warnings` - [x] Smoke: `gen-fixture` + `rvt-ifc --mode scaffold|typed-no-geometry|geometry|strict` — HostObjAttr absent; stronger modes fail closed with diagnostics ## Audit-honesty checklist - [x] Tier1/synthetic remain scaffold-only; no invented wall/floor geometry - [x] HostObjAttr proxies absent from default/scaffold; diagnostic path retained - [x] Mode docs do not claim geometry/strict success on scaffold fixtures - [x] No Autodesk samples committed - [x] Commit messages describe what/why ## Legal and contribution hygiene - [x] Apache-2.0 licensable - [x] No Autodesk proprietary / decompiled content - [x] Fixtures remain synthetic (`gen-fixture` / corpus/tier1) ## Breaking changes None for callers of `RvtDocExporter::export` (still scaffold content). New `export_with_*_mode_*` APIs are additive. CLI/Python `--mode` / `mode=` now also shapes content (typed-no-geometry strips geometry). ## Related issues Refs #37 (M5-01), #38-class HostObjAttr (M5-02), #40 (M5-04). Depends on #129 (Lane Six). Aligns with #128 (Lane Nine mode names). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > IFC export behavior changes for non-scaffold modes and production element filtering; broader surface area (partition scanner version gates, committed binaries) but synthetic corpus and fail-closed validation limit blast radius. > > **Overview** > Adds a **two-tier test corpus** (in-repo Apache-2.0 synthetic `corpus/tier1/` plus optional CI-cloned magnetar tier 2), CI jobs `corpus-tier1` / `corpus-tier2`, SHA256 license checks, and known-count manifests—while allowing committed `.rvt` files under `corpus/` via `.gitignore` exceptions. > > Introduces **partition scanning** (`partition_scanner`), a typed **ArcWall** partition decoder, ElemTable linkage helpers, and a `partition_scanner_json` example for JSON diagnostics. > > Adds **Lane Six geometry recovery** (`geometry/recovery`) with fail-closed wall curves, floor boundaries, opening hosts, and level elevations; extends typed **Wall** / **Level** projection for `gen-fixture` fields (`m_height`, location endpoints) and centralizes MVP typed decode via `decode_typed` / `decoder_for_class`. > > Implements **Lane Seven IFC content policy** in `export_content`: `--mode` / Python `mode=` now drives emission (not just validation)—`typed-no-geometry` strips geometry, `geometry`/`strict` attach recovery when present, production export drops **HostObjAttr** proxies, and Levels become storeys from recovered elevations. `RvtDocExporter::export_with_diagnostics_mode_and_limits` wires CLI/Python through to export. > > New integration tests cover tier1 corpus health, geometry honesty on synthetics, and all four IFC export modes (including CLI strict fail-closed on tier1). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f1974e6705096145c37d515b16c39137ac1f4c25. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: DrunkOnJava <[email protected]>



Summary
Implements Lane Nine (M7-02 / M7-03): expose the decoded-model Python API with Lane Five typed MVP projections, add stable JSON schemas for those payloads, and mirror the surface with a
rvt-elementsCLI.Depends on Lane Five (
elements/typed-decoders, PR #127) — this branch is based on that work (includes Lanes Three–Five).Motivation
Downstream automation and the viewer need one Python/CLI contract for production decoded elements, class counts, export diagnostics, and IFC write modes. Lane Five’s typed views must be reachable from Python without inventing geometry on scaffold fixtures.
Changes
RevitFile.decoded_elements()— adds optionaltypedMVP projection (Level/Wall/Floor/Door/Window/Room/Material)RevitFile.element_counts()/export_diagnostics()/write_ifc(mode=...)— documented + stubbed; modes remainscaffold|typed-no-geometry|geometry|strictrvt.MVP_TYPED_CLASSESconstant for introspectionrvt-elementsCLI — JSON dump of elements or--counts(same schemas as Python)docs/schemas/decoded-elements.schema.json,docs/schemas/element-counts.schema.jsoncorpus/tier1/(no Autodesk samples required)Mode honesty
scaffoldtyped-no-geometrygeometrystrictOn synthetic / scaffold-only fixtures, only
scaffoldtypically succeeds until Lane 7 geometry recovery lands. Stronger modes raiseValueErrorrather than over-claiming.Corpus honesty
Tier1
gen-fixtureCFBs are scaffold-oriented. Production walker counts may be zero; tests assert API shape, schema validity, and mode gating — not invented element recovery.Testing
cargo test --release --lib elements::typed_json— 3 passedcargo test --release --test json_schema_contracts— 3 passed (tier1 elements + counts schemas)maturin develop+pytest tests/python/test_decoded_api.py— 5 passed, 1 skipped (jsonschemaoptional)cargo clippy -p rvt --all-targets -- -D warningscargo clippy -p rvt-py --all-targets -- -D warningscargo fmt --check(via fmt before push)test_rvt.py) — skips withoutRVT_SAMPLES_DIRAudit-honesty checklist
null) for non-MVP classes; ArcWall stays partition-path*.sonot committedLegal and contribution hygiene
gen-fixture/ tier1)Breaking changes
None.
decoded_elements()entries gain an additivetypedkey (nullor object).Related issues
Refs M7-02 / M7-03 (TODO.md). Depends on #127 (Lane Five typed decoders).
Python API signatures
Note
Medium Risk
Large additive public API (CLI, Python, JSON schemas) and new always-on CI corpus gates; no auth or payment paths, but regressions would break downstream automation contracts.
Overview
Adds a unified decoded-model export surface for automation: new
rvt-elementsbinary dumps production-walker elements or--countsJSON aligned withRevitFile.decoded_elements()/element_counts(), including an optional Lane FivetypedMVP projection (Level,Wall,Floor,Door,Window,Room,Material) viatyped_jsonandMVP_TYPED_CLASSES. Stable contracts land indecoded-elements.schema.jsonandelement-counts.schema.json, with tier1-backed schema tests and always-on Python tests oncorpus/tier1/.Corpus & CI: Commits redistributable synthetic
corpus/tier1/fixtures (license SHA256 checks,generate.sh, count manifests) and wirescorpus-tier1/corpus-tier2jobs;.gitignorenow allowscorpus/**/*.rvt.project_count_fixturessupports tier1fixture_metricclass-instance oracles.Decoder / partition work bundled here: Generic
partition_scanner(2023/2024),elements::arc_wall,decode_typed, gen-fixture field aliases (m_height→ elevation/height), and related integration tests.Reviewed by Cursor Bugbot for commit 0a685c6. Configure here.