Repository navigation
Lane Four: generic PartitionRecordCandidate scanner + ElemTable linkage - #126
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]>
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: Scanner loop reads past buffer
- Changed the scan loop upper bound from len.saturating_sub(3) to len.saturating_sub(4) so tag hits never read buf[offset+3] when offset is len-3.
Or push these changes by commenting:
@cursor push 2c5393fb12
Preview (2c5393fb12)
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 f46e8c7. 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.
Scanner loop reads past buffer
Medium Severity
scan_partition_buffer walks 0..=len-3, then reads buf[offset+3] after a tag hit. The last window therefore indexes buf[len]. A default scan uses every schema tag, so a matching pair in the final three bytes panics instead of finishing the candidate list.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f46e8c7. Configure here.
Co-authored-by: DrunkOnJava <[email protected]>
## Summary Implements Lane Five (typed decoders / M3-05): harden schema-driven Level, Wall, Floor, Door, Window, Room, and Material decoders with wrong-schema rejection and empty-input tests; add a typed ArcWall partition decoder with class/tag rejection; wire `decoder_for_class` / `decode_typed`; add always-on tier1 corpus tests. Depends on Lane Four (`partitions/generic-scanner`, PR #126) — this branch is based on that work (includes Lane Three corpus). ## Motivation Downstream lanes (geometry, IFC, Python) need a stable typed decode surface that fails closed on schema mismatches and exercises redistributable tier1 fixtures without inventing geometry from scaffold CFBs. ## Changes - `src/elements/arc_wall.rs` — typed `ArcWall` view + `decode_at` / `decode_candidate` with wrong-schema / wrong-tag / short-buffer rejection (partition path; **not** added to the 80-entry `all_decoders` registry — wire format is envelope-based) - `src/elements/mod.rs` — `MVP_TYPED_CLASSES`, `decoder_for_class`, `decode_typed` - Hardened unit tests: Level/Wall/Floor/Door/Window/Room empty-input + Window/WallType/FloorType wrong-schema; Level/Wall accept gen-fixture `m_height` - `zones::Room` type alias for `Zone` - `tests/typed_decoders.rs` — registry cross-reject + tier1 payload decode + inventory known counts + no ArcWall-standard false positives on synthetics ### Rejection behavior | Path | Rule | |------|------| | Schema-driven MVP | `schema.name` must equal decoder class or `Error::BasicFileInfo(... wrong schema ...)` | | ArcWall partition | class_name if present must be `ArcWall`; `class_tag` must be `0x0191`; core envelope gates unchanged | ### Corpus honesty Tier1 `gen-fixture` CFBs are scaffold-oriented. Tests assert inventory known counts, successful field walks, Level/Wall `m_height` → typed height/elevation, and **zero** ArcWall-standard partition hits — not full Revit semantic recovery. ## Testing - [x] `cargo test --release --lib elements::` — 205 passed - [x] `cargo test --release --lib elements::arc_wall` — 7 passed - [x] `cargo test --release --test typed_decoders` — 3 passed (all three tier1 fixtures) - [x] `cargo clippy --all-targets --all-features -- -D warnings` - [x] `cargo fmt --check` - [x] New / changed code has unit tests - [ ] `cargo test --all` (full suite; filtered modules above green) - [x] Element decoder: empty tolerance, wrong-schema, happy-path present for MVP set - [ ] N/A: IFC exporter / bench ## Audit-honesty checklist - [x] ArcWall kept out of the 80-decoder registry (documented); docs count unchanged - [x] Tier1 tests do not claim typed geometry from synthetic fixtures - [x] Commit messages describe what/why - [x] No emojis; no private paths - [x] No Autodesk samples committed ## Legal and contribution hygiene - [x] Apache-2.0 licensable - [x] No Autodesk proprietary / decompiled content - [x] Fixtures remain synthetic (`gen-fixture`) ## Breaking changes None. ## Related issues Refs M3-05 (TODO.md). Depends on #126 (Lane Four scanner) / #125 (Lane Three corpus). Downstream: Lane 6 (geometry), Lane 7 (IFC), Lane 9 (Python) should merge from this branch. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Expands public decode and partition-scan APIs and adds always-on CI over committed fixtures; behavior is version-gated and tests emphasize fail-closed rejection, but regressions could affect downstream geometry/IFC lanes. > > **Overview** > Adds **Lane Five (M3-05)** typed decode surface: `MVP_TYPED_CLASSES`, `decoder_for_class`, and `decode_typed` fail closed on schema name mismatches; Level/Wall map gen-fixture `m_height` to elevation/height. **ArcWall** gets a partition-byte decoder (`decode_at` / `decode_candidate`) outside the schema-driven `all_decoders` registry, with class/tag rejection. > > Introduces **`partition_scanner`** (2023/2024 version guard, `PartitionRecordCandidate`, confidence scoring, ElemTable linkage helpers) plus `examples/partition_scanner_json` and `elem_table::link_partition_element_ids`. > > **Corpus / CI (Lane Three):** commits Apache-2.0 synthetic `corpus/tier1/` fixtures with license + recipe sidecars; `.gitignore` allows `corpus/**/*.rvt`; new `corpus-tier1` and `corpus-tier2` jobs; tier1 health tests (SHA256, open/schema/inventory) and tier1 project-count manifests with `fixture_metric` class-instance oracles. `project_count_fixtures` resolves manifests by tier. > > Integration coverage: `tests/typed_decoders`, `tests/partition_scanner`, `corpus_tier1_health`, `corpus_tier2_health`. Dev-deps `sha2`/`hex` for fixture integrity checks. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit aae5b7f. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor Agent <[email protected]> Co-authored-by: DrunkOnJava <[email protected]>
…ge (#126) ## Summary Implements Lane Four (partition scanner): a version-gated generic `PartitionRecordCandidate` scanner over `Partitions/*`, plus `ElementId → PartitionRecordRef` linkage into `Global/ElemTable` (M3-03 / M3-04). Depends on Lane Three (`corpus/project-fixtures`, PR #125) — this branch includes those commits so tier1 fixtures are available for tests. ## Motivation Typed partition decoders (later lanes) need a neutral, confidence-scored candidate stream and a stable id↔offset join before class-specific decode lands in `iter_elements`. ## Changes - `src/partition_scanner.rs` — filtered-tag scanner (RE-14.2 `filter_pad == 0`), version guard, confidence model, ArcWall path expressible via `arcwall_standard_offsets`, ElemTable join helpers - `src/elem_table.rs` — `link_partition_element_ids` wrapper - `examples/partition_scanner_json.rs` — JSON probe for issue attachments (`--arcwall-only`, `--unlocated`) - `tests/partition_scanner.rs` — tier1 health + optional magnetar corpus coverage tests ### Version guard Supported: **Revit 2023 and 2024** only (`PARTITION_SCANNER_SUPPORTED_REVIT_VERSIONS`). Other years return `UnsupportedVersion` with an empty candidate list. ### Confidence model | Score | Meaning | |-------|---------| | 0.55 | Schema tag + filter_pad == 0 | | 0.85 | + ArcWall-standard envelope (2023) | | 0.95 | + validated trailer ElementId | ### ElemTable linkage Candidates with recovered ElementIds build `element_id_partition_index` → join via `link_elem_table_to_partitions` / `elem_table::link_partition_element_ids`. CLI can list declared-but-unlocated ids. ## Testing - [x] `cargo test --release --lib partition_scanner` — 8 passed - [x] `cargo test --release --test partition_scanner` — 7 passed (tier1 exercised; magnetar skips locally) - [x] `cargo fmt --check` - [x] `cargo clippy --all-targets --all-features -- -D warnings` - [ ] CI green on this PR ## Audit-honesty checklist - [x] Scanner does not claim typed elements; candidates are research-grade - [x] Version guard prevents applying 2023 ArcWall envelope to unsupported years - [x] Tier1 synthetic fixtures expected empty (no false positives) ## Legal and contribution hygiene - [x] Apache-2.0 licensable - [x] No Autodesk proprietary / decompiled content ## Breaking changes None. ## Related issues Refs M3-03, M3-04 (TODO.md). Depends on #125 (Lane Three corpus). Later lanes (typed decoders) should merge from this branch. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > New partition-byte scanning and ElementId linkage affect core Revit parsing paths; behavior is gated to 2023/2024 but magnetar integration tests assert real-file wall linkage. Corpus changes are mostly CI/fixture surface area. > > **Overview** > Adds a **version-gated generic partition scanner** (`partition_scanner`) that walks inflated `Partitions/*` buffers for schema class-tag hits with the RE-14.2 `filter_pad == 0` filter, emits confidence-scored `PartitionRecordCandidate` values (including ArcWall-standard paths and trailer ElementIds on 2023), and joins recovered ids to `Global/ElemTable` via `element_id_partition_index` / `link_elem_table_to_partitions` (plus `elem_table::link_partition_element_ids`). Unsupported Revit years return empty candidates. A `partition_scanner_json` example and `tests/partition_scanner.rs` cover tier1 synthetics (no false positives) and optional magnetar parity with `ArcWallRecord::find_all`. > > **Bundled Lane Three corpus work:** commits Apache-2.0 synthetic `.rvt` fixtures under `corpus/tier1/` (license/fixture sidecars, `generate.sh`), relaxes `.gitignore` for that tree, adds tier1/tier2 health integration tests and tier1 project-count manifests with `fixture_metric` class-instance oracles, and wires **`corpus-tier1`** / **`corpus-tier2`** CI jobs (magnetar clone for tier 2). Dev-deps `sha2`/`hex` support tier1 SHA256 checks. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b6b661c96cb142eaa5cbd0f0c78037a62d168262. 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 Five (typed decoders / M3-05): harden schema-driven Level, Wall, Floor, Door, Window, Room, and Material decoders with wrong-schema rejection and empty-input tests; add a typed ArcWall partition decoder with class/tag rejection; wire `decoder_for_class` / `decode_typed`; add always-on tier1 corpus tests. Depends on Lane Four (`partitions/generic-scanner`, PR #126) — this branch is based on that work (includes Lane Three corpus). ## Motivation Downstream lanes (geometry, IFC, Python) need a stable typed decode surface that fails closed on schema mismatches and exercises redistributable tier1 fixtures without inventing geometry from scaffold CFBs. ## Changes - `src/elements/arc_wall.rs` — typed `ArcWall` view + `decode_at` / `decode_candidate` with wrong-schema / wrong-tag / short-buffer rejection (partition path; **not** added to the 80-entry `all_decoders` registry — wire format is envelope-based) - `src/elements/mod.rs` — `MVP_TYPED_CLASSES`, `decoder_for_class`, `decode_typed` - Hardened unit tests: Level/Wall/Floor/Door/Window/Room empty-input + Window/WallType/FloorType wrong-schema; Level/Wall accept gen-fixture `m_height` - `zones::Room` type alias for `Zone` - `tests/typed_decoders.rs` — registry cross-reject + tier1 payload decode + inventory known counts + no ArcWall-standard false positives on synthetics ### Rejection behavior | Path | Rule | |------|------| | Schema-driven MVP | `schema.name` must equal decoder class or `Error::BasicFileInfo(... wrong schema ...)` | | ArcWall partition | class_name if present must be `ArcWall`; `class_tag` must be `0x0191`; core envelope gates unchanged | ### Corpus honesty Tier1 `gen-fixture` CFBs are scaffold-oriented. Tests assert inventory known counts, successful field walks, Level/Wall `m_height` → typed height/elevation, and **zero** ArcWall-standard partition hits — not full Revit semantic recovery. ## Testing - [x] `cargo test --release --lib elements::` — 205 passed - [x] `cargo test --release --lib elements::arc_wall` — 7 passed - [x] `cargo test --release --test typed_decoders` — 3 passed (all three tier1 fixtures) - [x] `cargo clippy --all-targets --all-features -- -D warnings` - [x] `cargo fmt --check` - [x] New / changed code has unit tests - [ ] `cargo test --all` (full suite; filtered modules above green) - [x] Element decoder: empty tolerance, wrong-schema, happy-path present for MVP set - [ ] N/A: IFC exporter / bench ## Audit-honesty checklist - [x] ArcWall kept out of the 80-decoder registry (documented); docs count unchanged - [x] Tier1 tests do not claim typed geometry from synthetic fixtures - [x] Commit messages describe what/why - [x] No emojis; no private paths - [x] No Autodesk samples committed ## Legal and contribution hygiene - [x] Apache-2.0 licensable - [x] No Autodesk proprietary / decompiled content - [x] Fixtures remain synthetic (`gen-fixture`) ## Breaking changes None. ## Related issues Refs M3-05 (TODO.md). Depends on #126 (Lane Four scanner) / #125 (Lane Three corpus). Downstream: Lane 6 (geometry), Lane 7 (IFC), Lane 9 (Python) should merge from this branch. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Expands public decode and partition-scan APIs and adds always-on CI over committed fixtures; behavior is version-gated and tests emphasize fail-closed rejection, but regressions could affect downstream geometry/IFC lanes. > > **Overview** > Adds **Lane Five (M3-05)** typed decode surface: `MVP_TYPED_CLASSES`, `decoder_for_class`, and `decode_typed` fail closed on schema name mismatches; Level/Wall map gen-fixture `m_height` to elevation/height. **ArcWall** gets a partition-byte decoder (`decode_at` / `decode_candidate`) outside the schema-driven `all_decoders` registry, with class/tag rejection. > > Introduces **`partition_scanner`** (2023/2024 version guard, `PartitionRecordCandidate`, confidence scoring, ElemTable linkage helpers) plus `examples/partition_scanner_json` and `elem_table::link_partition_element_ids`. > > **Corpus / CI (Lane Three):** commits Apache-2.0 synthetic `corpus/tier1/` fixtures with license + recipe sidecars; `.gitignore` allows `corpus/**/*.rvt`; new `corpus-tier1` and `corpus-tier2` jobs; tier1 health tests (SHA256, open/schema/inventory) and tier1 project-count manifests with `fixture_metric` class-instance oracles. `project_count_fixtures` resolves manifests by tier. > > Integration coverage: `tests/typed_decoders`, `tests/partition_scanner`, `corpus_tier1_health`, `corpus_tier2_health`. Dev-deps `sha2`/`hex` for fixture integrity checks. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 09b48b03d503c601348fddebbcf4ded1ae408e6c. 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 Four (partition scanner): a version-gated generic
PartitionRecordCandidatescanner overPartitions/*, plusElementId → PartitionRecordReflinkage intoGlobal/ElemTable(M3-03 / M3-04).Depends on Lane Three (
corpus/project-fixtures, PR #125) — this branch includes those commits so tier1 fixtures are available for tests.Motivation
Typed partition decoders (later lanes) need a neutral, confidence-scored candidate stream and a stable id↔offset join before class-specific decode lands in
iter_elements.Changes
src/partition_scanner.rs— filtered-tag scanner (RE-14.2filter_pad == 0), version guard, confidence model, ArcWall path expressible viaarcwall_standard_offsets, ElemTable join helperssrc/elem_table.rs—link_partition_element_idswrapperexamples/partition_scanner_json.rs— JSON probe for issue attachments (--arcwall-only,--unlocated)tests/partition_scanner.rs— tier1 health + optional magnetar corpus coverage testsVersion guard
Supported: Revit 2023 and 2024 only (
PARTITION_SCANNER_SUPPORTED_REVIT_VERSIONS). Other years returnUnsupportedVersionwith an empty candidate list.Confidence model
ElemTable linkage
Candidates with recovered ElementIds build
element_id_partition_index→ join vialink_elem_table_to_partitions/elem_table::link_partition_element_ids. CLI can list declared-but-unlocated ids.Testing
cargo test --release --lib partition_scanner— 8 passedcargo test --release --test partition_scanner— 7 passed (tier1 exercised; magnetar skips locally)cargo fmt --checkcargo clippy --all-targets --all-features -- -D warningsAudit-honesty checklist
Legal and contribution hygiene
Breaking changes
None.
Related issues
Refs M3-03, M3-04 (TODO.md). Depends on #125 (Lane Three corpus).
Later lanes (typed decoders) should merge from this branch.
Note
Medium Risk
New partition-byte scanning and ElementId linkage affect core Revit parsing paths; behavior is gated to 2023/2024 but magnetar integration tests assert real-file wall linkage. Corpus changes are mostly CI/fixture surface area.
Overview
Adds a version-gated generic partition scanner (
partition_scanner) that walks inflatedPartitions/*buffers for schema class-tag hits with the RE-14.2filter_pad == 0filter, emits confidence-scoredPartitionRecordCandidatevalues (including ArcWall-standard paths and trailer ElementIds on 2023), and joins recovered ids toGlobal/ElemTableviaelement_id_partition_index/link_elem_table_to_partitions(pluselem_table::link_partition_element_ids). Unsupported Revit years return empty candidates. Apartition_scanner_jsonexample andtests/partition_scanner.rscover tier1 synthetics (no false positives) and optional magnetar parity withArcWallRecord::find_all.Bundled Lane Three corpus work: commits Apache-2.0 synthetic
.rvtfixtures undercorpus/tier1/(license/fixture sidecars,generate.sh), relaxes.gitignorefor that tree, adds tier1/tier2 health integration tests and tier1 project-count manifests withfixture_metricclass-instance oracles, and wirescorpus-tier1/corpus-tier2CI jobs (magnetar clone for tier 2). Dev-depssha2/hexsupport tier1 SHA256 checks.Reviewed by Cursor Bugbot for commit f46e8c7. Configure here.