Repository navigation
refactor: one copy of each byte, GUID, JSON-id, geometry and storey helper, and one ArcWall scan per file - #1136
Merged
Merged
Conversation
…nd quantise helpers dot, sub and cross move from ifc/body_geometry and native_parametric_surface, distance from native_symbol_cuts and native_parametric_mesh, and the shoelace area from geometry/recovery and ifc/from_decoded into the private vector_math module, with the expressions unchanged. polygon_area_sqft keeps its public path and calls the shared function. quantise is shared from partition_element_records.
native_index reads native_extensible_storage::guid_string instead of its own copy. The 22-digit alphabet is one constant in revit_global_ids, and derive_default_ifc_guid calls compress_ifc_guid, which computes the same string.
partition_level_records and partition_ifc_export_overrides use the memchr-backed copy in partition_element_records. All three returned None for an empty needle or a haystack shorter than the needle and the first match otherwise.
partition_arc_walls names a storey through element_record_storeys::elevation_storey_name instead of its own identical format.
…elpers native_json holds element_id (u64 and signed forms), finite_triple and agree, read by native_column_joins, native_connectors, native_element_types, native_mullion_hosts, native_rendered_content, native_stairs, native_symbol_cuts, native_wall_types and native_walls. The readers that differ stay in place: native_walls' triple (no finiteness check), native_stairs' element_id (as_u64), native_family_forms' Option argument and native_saved_mesh's Result point.
…imits The production walk, the partition MVP and the IFC export (twice) each ran scan_partition_arc_walls_with_limits over every Partitions stream. RevitFile now memoises the scan under its release and WalkerLimits, as it does the walk; the public function returns a copy of the memoised scan and the four internal readers share it.
… le_bytes The partition readers, compression and basic_file_info read integers, floats and UTF-16 units at an offset with the same bounds as before and through the one le_bytes module. le_bytes gains i32_at and u16_units for the reads the existing helpers did not cover.
… index and document readers The reads that were bounds-checked by a get or an ensure! before an infallible try_into now use u16_at and u32_at with the same error text, and the UTF-16 unit decodes use u16_units. The walker, ElemTable, partitions and ArcWall trailer readers take the same helpers where the surrounding function already returned None on a short buffer.
…roof_slopes read ElementIds through native_json
…hangelog fragment
…ported Four calls already on main read crate::le_bytes::*_at in files this branch now imports le_bytes into, which the workspace's unused_qualifications lint (an error under -D warnings) rejects.
DrunkOnJava
added a commit
that referenced
this pull request
Oct 30, 2026
…a buffer whose last tag is followed by a zero (#1137) ## Summary `research::partition_scanner::scan_partition_buffer` looped offsets up to `len - 3` and then checked the two bytes after a matching tag. A tag in the last three bytes followed by a zero byte therefore read `buf[len]` and panicked. The loop now ends at `len - 4`, and no output changes. ## Motivation The helper-refactor review (#1136) found this; that PR left it alone because it was behaviour-preserving. Parsing paths take untrusted input and must not panic (CLAUDE.md). No fuzz target reaches this function. ## Changes - `src/partition_scanner.rs`: `let last = buf.len() - 4;`. The function already returns early for buffers under 4 bytes, so this cannot underflow. A candidate needs the tag and the two zero bytes after it, so no offset that could yield one is skipped. - `tests/fuzz_regressions.rs` (hardening, run in CI): replays buffers of 4 to 11 bytes that end with an ArcWall tag (`0x0191`) followed by a zero, on a supported release (2023). Before the fix each one panics, and the test asserts none does. ## Testing CI runs the hardening class. The fix is in a research module and changes no export (`scan_partition_buffer` serves probes, tests and the ElemTable passthrough). ## Breaking changes None. ## Related issues Refs #1136.
DrunkOnJava
commented
Oct 30, 2026
DrunkOnJava
left a comment
Owner
Author
There was a problem hiding this comment.
Maintainer self-review. GitHub does not let a PR's author approve it, so this review stands in for an approval. A side agent wrote the commits, and I reviewed them as a reviewer would.
- Read conversions: a raw read became
?only where a bounds check already in place makes the newNonearm unreachable. Sites whose failure semantics differ stay inline:Resulterrors with messages,InstanceField::Bytesfallbacks and cursor reads.anyhowmessages are unchanged. find_subslice: keeps its empty-needle guard; memchr returnsSome(0)for an empty needle, and the guard keepsNone.vector_mathandnative_json: expressions are token-identical to the copies they replace. Variants that differ stay put: the signed areas, the three point-in-polygon tests andpipe_axes'd*ddistance.- ArcWall memo: keyed by release and
WalkerLimits, so callers passing different limits never share a result. The handle is immutable, so nothing invalidates it. The publicscan_partition_arc_walls_with_limitsis unchanged. - CI fix: the branch's new
use crate::le_bytes;imports made four existingcrate::le_bytes::paths failunused_qualifications, andac976268fixed them before the first CI run. - Verified:
CI passed. Measure is byte-identical on all 32 models; the description explains the office's base-side outage and the cross-check that covers it. - Found and fixed separately: the scanner's past-the-end read is #1137, already merged.
Ready to land.
DrunkOnJava
enabled auto-merge (squash)
October 30, 2026 10:35
5 tasks done
DrunkOnJava
added a commit
that referenced
this pull request
Oct 30, 2026
## Summary Moves the 75 research modules from `src/` into `src/research/`, declared as plain modules in `src/research.rs` instead of one `#[path]` attribute each. Module paths (`crate::partition_schema_mvp`, `rvt::research::*`) do not change, so this is a pure move: 75 R100 renames plus five edited files. Stacked on #1136 (its commits show here until it lands; this PR stays a draft until then and takes an update-branch merge, so only the move remains). ## Motivation The second of the four repository-audit refactors Griffin chose on 2026-10-30. The research readers sat beside the stable modules, so nothing in the tree said which files are outside the semver promise (`RELEASE.md`, "What 1.0 keeps stable"). ## Changes - `src/<m>.rs` → `src/research/<m>.rs` for every module `src/research.rs` declares (75, including `native_json` from #1136, which is `pub(crate)`). - `src/research.rs`: the `#[path]` lines go. - Current-state mentions of the moved paths: `docs/support-matrix.json` evidence (15), `probes/examples/probe_re207_element_parameters.rs`, `tools/re/element_parameters_vs_ifc.py`, and CONTRIBUTING's probe step (a new research reader goes in `src/research/`). Reports, dated notes and the changelog keep the paths they were written with. Checked before pushing: no moved file declares a child module or uses `include_str!`/`include_bytes!`/`include!` with a relative path (both would resolve differently one directory down); the crate's `include` allowlist is `/src/**/*.rs`, so packaging is unchanged. ## Testing Unit tests are banned in this repository. No local builds on this machine: CI is the compile gate. Exports must be byte-identical; a Measure run on the head confirms it before this leaves draft. ## Audit-honesty checklist - [x] Docs name the new paths; no capability changes - [x] No user-visible change, so no changelog fragment - [x] No emojis, private paths or internal jargon ## Legal and contribution hygiene - [x] Apache-2.0 - [x] No Autodesk proprietary content ## Breaking changes None: module paths are unchanged.
9 of 11 tasks
DrunkOnJava
added a commit
that referenced
this pull request
Oct 30, 2026
…sibility (#1141) ## Summary Splits `src/research/partition_schema_mvp.rs` (12,553 lines) into 19 child modules by responsibility, under `src/research/partition_schema_mvp/`. The parent keeps the module doc, `PartitionSchemaMvp`, the `recover_partition_schema_mvp` orchestrator and the helpers every responsibility shares, and re-exports each child with `pub use <child>::*`, so every `partition_schema_mvp::<item>` path used in `src/`, `tests/`, `probes/` and `docs/` resolves as before. It is a pure move: bodies, doc comments, attributes and the relative order of items are unchanged. Stacked on #1136 and #1139, both of which have since landed on main (squash commits f07614f and 580982d); this branch merged main, so only the split remains in the diff. It stays a draft until a Measure run on the head confirms the move is byte-identical. ## Motivation One of the repository-audit refactors Griffin chose on 2026-10-30: one 12.5k-line file held 175 constants and about 200 functions for a dozen unrelated responsibilities. ## Changes - `partition_schema_mvp.rs` (1,130 lines): module doc, imports, `PartitionSchemaMvp`, `recover_partition_schema_mvp`, `element_record_decoded`, `element_record_bbox`, `record_references`, `element_source_stream`, `partition_streams_largest_first`, `rect_openings_from_partitions`, and the `mod` / `pub use` lines. - `fields` (933): all 175 constants. - `types` (961), `parameters` (282): type picks and names, system families, type functions; named parameters, `IsExternal`, phases created, serial numbers. - `openings` (765), `curtain` (399), `materials` (704), `layers` (292). - `walls` (728), `wall_joins` (453). - `stairs` (730), `stair_bodies` (1,111), `framing` (509), `mep` (750), `rooms` (289). - `slabs` (592), `roofs` (862), `levels` (511). - `records` (495), `records_2023` (325): category and instance selection, host binding, design-option and nesting filters; the Revit 2023 record path. The only edits to moved text: - `pub(super)` on the 148 private top-level items that left the parent (the file has no private struct fields or methods). - `fields.rs` has no `use super::*;`, since none of its constants names anything outside it. Five of its doc links named a function that now lives in another child, so they read `[`super::system_family`]`, `[`super::attach_is_external`]`, `[`super::bind_opening_hosts`]`, `[`super::roof_slope_edge_fields`]` and `[`super::roof_slope_plate_offset_field`]`. - The imports only one child uses moved into it (`le_bytes` into `curtain` and `openings`, `partition_arc_walls` / `PartitionArcWall` into `levels`, `NameBucket` / `classify_name` into `materials`, `FRAC_PI_4` into `walls`), so the parent has no unused import. Checked before pushing: every original non-blank line appears in the new files the same number of times, except the added `pub(super)` tokens, the `mod` / `pub use` / `use super::*;` / child `//!` lines, the five doc links and the moved imports; `rustfmt +stable --edition 2024 --check` passes on the parent and every child, and rustfmt's own changes (29 signatures rewrapped by the longer visibility prefix) differ from the unformatted output only in whitespace and trailing commas. Every `partition_schema_mvp::<name>` that code outside the module uses (`src/`, `tests/`, `probes/`, `fuzz/`, `tools/`) names a `pub` item; the non-`pub` names that remain are prose in docs and reports, as before. ## Testing Unit tests are banned in this repository. No local builds on this machine: CI is the compile gate. - [ ] `tools/check-local.sh` passes: not run here (no local compilation); `CI passed` is the gate - [ ] Verified end to end on real Revit files: a Measure run on the head must show byte-identical IFC hashes (`-f base=main -f nordic=true -f r2025=true`) before this leaves draft - [x] Does not touch the IFC exporter's behaviour; the witness verdicts need no refresh - [x] Not a performance change ## Audit-honesty checklist - [x] Docs name no moved line numbers: `docs/support-matrix.json` cites `partition_schema_mvp::<item>` module paths, which still resolve - [x] No user-visible change, so no changelog fragment - [x] No new limitation - [x] No emojis, private paths or internal jargon ## Legal and contribution hygiene - [x] Apache-2.0 - [x] No Autodesk proprietary content - [x] No new test fixtures ## Breaking changes None: the module's public items keep their paths.
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.
Summary
The audit's helper refactor (Griffin, 2026-10-30, "One copy of each helper"): copied helpers become one shared copy each, little-endian reads go through
le_byteswhere the conversion is exactly equivalent, and the partition ArcWall scan runs once per file instead of up to four times. Nothing an export writes should change; Measure checks that.Changes
le_bytes: about 117 of 227 inlinefrom_le_bytesreads now usele_bytes, which gainsi32_atandu16_units. The rest are left because their failure semantics differ:Resulterrors with specific messages,InstanceField::Bytesfallbacks inwalker.rs, cursortake(n)?reads, fixed-size arrays that cannot fail, andsrc/bin. A raw-indexed read behind an explicit bounds check becomes?only where that check makes the newNonearm unreachable. Messages fromanyhowerrors are kept word for word.find_subslice: one copy, memchr, with the empty-needle guard kept. It replaces two wrappers and one scalar loop.guid_string, now used by three readers. One IFC GlobalId alphabet.derive_default_ifc_guidcallscompress_ifc_guid.src/native_json.rs(research):element_id,element_id_i64,finite_tripleandagree, shared by twelvenative_*and partition modules. Variants with different semantics stay.src/vector_math.rs(private):sub,dot,cross,distanceandpolygon_area_xy. Expressions are token-identical to the copies they replace.from_decoded::polygon_area_sqftkeeps its public path. The three point-in-polygon copies and the signed areas differ and stay.elevation_storey_name.RevitFileper release andWalkerLimits(memoised_arc_wall_scan). The production walk, the partition assembler and both IFC-export sites share it. The publicscan_partition_arc_walls_with_limitskeeps its signature.changelog.d/changed/arc-wall-scan-memo.md.No public signature changes.
fuzz/andrvt-probescall public items only.Testing
use crate::le_bytes;imports made fourcrate::le_bytes::paths already onmainredundant, whichunused_qualifications(an error under-D warnings) would have rejected. They are fixed inac976268.-D warnings, MSRV and i686.mainwith nordic and r2025:ifc.sha256, everydiagnostics.jsonand all scorer outputs (1,262 files on the head side).mainside.CI passed, including clippy and rustdoc under-D warnings, MSRV and i686.Found, not changed
partition_scanner.rs:239/449can indexbuf[offset + 3]past the end when a tag matches in a buffer's last three bytes. That is a panic on hostile input, so it will be fixed in its own PR rather than in a behaviour-preserving refactor.Breaking changes
None.
Related issues
None.