fix(geometry): processors read placements and directions through the one reader (F3b X3a, #7779)

Merged
LO
1mo ago
+2926-732

Refs #7779 (F3b X3a) and charter #7670. This is the X3a behaviour layer of the F3b stack (X2 #7877 → X3a #7880 → R2a #7896).

What X3a does

Processor, profile and mapped-origin consumers stop carrying their own copies of the point, direction and axis-placement readers and call the canonical ones (decoder.point3_at / direction3_at, placement::Axis2Placement::{read, read_2d, read_3d}, Axis1Placement::read, one build_axis2_matrix). Each fork is reconciled to the note's decided behaviour in place, and each reconciled drift has its own test (D28). The policy is D3: unreadable authored input refuses the item and is counted once per record in refused_input_elements (D29). Readable but degenerate axes keep build_axis2_matrix's repair unchanged (D25). 2-component points and directions promote with z = 0 (D26).

Valid input is unchanged. Readable placements give the same matrix bits as before; the raw atan2 rotation of valid planar 2D conic placements is preserved; an explicit 3D extrusion direction gives the same solid. What changes is malformed input: an unreadable or $-mandatory value used to become the origin, +X/+Y/+Z, or an identity, and now refuses.

Reconciled drifts and their tests

Note §SiteBase → headTest
3.2, 3.12ExtrudedDirection (extrusion, tapered extrusion)missing Z read as 1.0, so (1,0) extruded along (1,0,1) → leaf reader; z = 0 refused (ValidExtrusionDirection)processors/placement_reader_tests.rs
3.12, D25Revolved-solid Axis$ Axis became +Y; y ratio defaulted to 1.0 → $, zero-length or non-XY Axis refused (AxisDirectionInXY); 2-ratio XY axes promoteprocessors/placement_reader_tests.rs
3.3, 3.12IfcSurfaceOfRevolution AxisPositionunreadable Location/Axis read as origin/+Z → face refused; $ Axis keeps the IFC default +Ztests/surface_of_revolution_axis_refusal.rs
3.4$ Location in get_placement_2d (2D and 3D)origin → refusedprofiles/conic_axis_tests.rs
3.5MappingOrigin (mapped and textured type map)textured read only 3D and returned None for a 2D or wrong-typed origin → one reader; 2D honoured; wrong type is an errorrouter/transforms/mapped.rs tests
3.5Extrusion / CSG primitive Positionwrong type ignored (identity) → refused; $ stays identityprocessors/placement_reader_tests.rs
3.11, 3.4IfcCurveSegment placement in composite curvesraw RefDirection, unreadable or non-Axis2 frame skipped the segment → X projected against Axis; such a frame fails the profileprofiles/curve_segment_placement_tests.rs
3.2 (PROC-AL-10)sectioned_positions linear-placement RefDirectionlenient copy (unwrap_or(0.0), no type check) → direction3_at; zero-length still an errorprocessors/sectioned_positions_tests.rs
PROC-S7conics.rs placement erroridentity frame at the origin → refusedconic tests
3.17planar axes shared by conics and rectanglesper-site epsilons → canonical repairtests/placement_consumer_consistency.rs

The export crate's step_map_rigid.rs now uses Axis2Placement::read_3d(..).matrix(), which is the same matrix as before.

Counted refusals

Every refusal X3a introduces is counted, with the exceptions listed under "Still uncounted" below, through decoder.refuse_malformed / the shared placement reader, deduplicated per record id, so the layer probe and the processor reading the same Position count once. The descriptive geometry error messages are unchanged, except where a site now reads through the canonical leaf reader. There, a wrong-type or malformed point or direction reports the core malformed-record error and is now counted. For example, an ExtrudedDirection that references an IfcCartesianPoint used to fail, uncounted, with the geometry error Expected IfcDirection, got IfcCartesianPoint. It now fails with Core parser error: Entity #<direction id> is malformed geometry input; refused (Error::MalformedRecord), counted once on the direction record (extrusion_plan_tests.rs::malformed_direction_is_refused_before_missing_depth_and_bad_position pins this). Likewise a $ ExtrudedDirection on an IfcExtrudedAreaSolid / IfcExtrudedAreaSolidTapered used to say Failed to resolve ExtrudedDirection and now says ExtrudedAreaSolid ExtrudedDirection is not a reference; that one is still uncounted (see "Still uncounted"). These WR refusals of readable input are counted under D3 by coordinator decision:

  • ExtrudedDirection with z = 0 (ValidExtrusionDirection), counted on the solid.
  • A zero-length ExtrudedDirection, counted on the solid. It breaks the same WR, because its Z is zero.
  • A revolved-solid Axis that is $, zero-length or not in XY (AxisDirectionInXY), counted on the solid. AxisStartInXY is deliberately not enforced, because it rules out no default or promoted value (D25); a comment says so.
  • A MappingOrigin that is not an IfcAxis2Placement, counted on the origin record, the same way Axis2Placement::read counts a wrong-typed placement.

Tests pin a count of 1 for each, and a count of 0 for the valid controls.

Maintainer call-outs

1. CTO LocalOrigin policy, which amends D30. The canonical IfcCartesianTransformationOperator reader (router/transforms/operator.rs) now refuses and counts a $, * or unreadable LocalOrigin, and a record that is not a transformation operator. Before this, IFCCARTESIANTRANSFORMATIONOPERATOR3D($,$,$,$,$) drew the mapped item at the map origin. This came from the #7896 review (comment 4304579830, class absence-reads-as-success). It is not in the note's drift list: §3.4 covers placement Location, and D30's refuse list names only $ mandatory placement attributes and a non-placement PlacementRelTo. This PR therefore extends D30's refuse list to the mandatory CTO LocalOrigin. LocalOrigin is mandatory in EXPRESS, so only invalid input is affected, and an explicitly referenced readable zero origin stays valid. Existing router fixtures that used the old $ shape were rewritten to supply a LocalOrigin, which shows that shape used to be treated as normal. The corpus evidence for X3a is the named-fixture and oracle set below, not a full-fingerprint run, so please confirm the amendment or ask for that run.

2. IfcCurveSegment placements that are not IfcAxis2Placement. In the composite-curve fallback (a parent that is not line, circle or clothoid), a segment Placement that is not IfcAxis2Placement2D/3D used to skip the segment, losing one point. It is now refused as Unsupported and counted, and the whole composite profile fails. IfcCurveSegment.Placement is typed IfcPlacement in IFC4X3, so an IfcAxis1Placement or IfcAxis2PlacementLinear is schema-valid there. The profile sampler is now Axis2-only. Real alignment exports use Axis2Placement2D/3D, so the corpus effect is expected to be nil. a_curve_segment_placement_that_is_not_an_axis2_placement_fails_the_profile pins the refusal and the count. If you would rather keep the old skip for valid non-Axis2 IfcPlacement subtypes, say so and it becomes a follow-up.

3. RefDirection (1e308, 1e308), a pinned known limitation. tests/placement_consumer_consistency.rs pins the canonical frame for this RefDirection as X = (0, −1). The direction is finite and non-degenerate, but its norm() overflows, so build_axis2_matrix treats it as degenerate and takes the −Y fallback. On base, get_placement_2d's raw atan2 gave the correct 45° for conic profiles; head rotates them −90°. Decision: kept as a pin, not fixed. D25 keeps build_axis2_matrix bit-identical, and X3a moves the per-site epsilons onto that one repair (§3.17). Fixing the overflow means scale-normalising before norm() inside build_axis2_matrix, which is a separate decision under D25. The test comment now says the pin records this known limitation, not correct geometry, so a future fix updates the row deliberately. The input is adversarial and no corpus file is affected.

4. Core REAL-parse fast path. rust/core/src/parser/numeric_literal.rs adds a fast path for trailing-dot literals of 1 to 15 digits: they are accumulated in u64 and cast. The grammar walk keeps the INTEGER/REAL kind, and fast_float2::parse becomes parse_partial on the grammar-bounded literal. Results are bit-identical: 15 digits stay below 2^53, the sign is applied after the cast so −0 is preserved, a bare . is rejected, and the grammar admits only forms fast_float consumes whole. numeric_literal_tests.rs compares bits against str::parse across the 15/16-digit boundary, leading zeros, signs, exponents and every delimiter. Although it ships in a geometry X PR, every STEP REAL parse in the product goes through this code. F4's fuzz target G7 is the long-term guard.

5. EntityDecoder::direction3_of is transitional. It is a new public, decoder-less and uncounted direction reader, used only by the void probe's parse_direction until C2. Its doc comment, mirrored in docs/api/rust.md, marks it transitional: C2 removes (to be added to C2's deletion list when its ledger rows are written) it, and callers should use direction3_at. It is on the C2 deletion list.

Performance disposition

Wall time: PASS by maintainer ruling (2026-10-24), non-inferiority. Job 313e11ca measured source 48f1c6c0 against base 61bfa85b in 90 pairs (45 BC / 45 CB). Every fixture's 90% upper bound on the C/B ratio is below 1.02: FZK-Haus [0.977, 1.003], ISSUE_129 [0.985, 1.008], ISSUE_053 [1.005, 1.013]. ISSUE_053 is slightly slower but inside the band, so the verdict is non-inferiority, not "no change". An independent validity check found arms correctly bound to protocol, ratio direction C/B, measured source hash-matched, balanced order, an integrity replay that matched, and mesh fingerprints and counts identical across arms. scripts/perf/README.md records the disposition and keeps the earlier HOLD paragraph as history. No baseline, ceiling, acceptance band or output pin changes.

Commits after 48f1c6c0 touch refusal branches, tests, comments and docs, the merge of current main, and one read-path change: sectioned_positions.rs::read_direction now reads through direction3_at (valid 2- and 3-ratio directions give identical values; the positional-read ratchet row is lowered 17→14). No new timed run was made after 48f1c6c0; the hot placement path is unchanged.

Owned elsewhere

  • X3b / R2b → C1a. F3b stopped at its stop line; C1a takes over X3b's and R2b's sites (note §6).
  • P3 → C5. C5 inherits the symbolic module and decides the broader #2256 revision (unresolved() vs refused() for dangling and cyclic placements).
  • R2a #7896 deletes the reconciled wrappers. The deletions already done here (transform/placement_2d.rs, the router 2D delegate, helpers::parse_cartesian_point / parse_direction, operator.rs parse_direction_ratios) were pure delegates, so #7896 must not claim them. transform.rs's pub readers and the parsers.rs delegates remain for R2a and C2.

Validation

Branch head e78bed46a299fd91d37c14b32b0e18bd32dcdffb merges current main b96e198f614b16b58cfb8aff4bce6a2d66c991f3 (merge 888e88e175, no conflicts). Local PC run under run-heavy admission, job e0185ff3-f141-4f29-9fd0-d44c7a0cc0d4, source clean and unchanged before and after. The fleet was admission-blocked at the time, so this is not a fleet run.

CheckExit
cargo test -p ifc-lite-core -p ifc-lite-geometry -p ifc-lite-processing -p ifc-lite-export -p ifc-lite-wasm --no-fail-fast (5,672 passed, 0 failed, 40 ignored, 344 binaries)0
cargo clippy (same crates) --all-targets -- -D warnings0
node scripts/check-module-size.mjs (0 new over 400)0
check-rust-source-text-assertions, check-source-text-assertions, check-float-sort-comparators, check-rust-api-surface, check-refwalk-guards, check-raw-entity-enumeration0 each

The inline-epsilon ratchet (math::tol_tests::inline_epsilon_literals_only_go_down) and the positional-read ratchet run inside cargo test and pass. The positional-read row for sectioned_positions.rs drops from 17 to 14 because of the direction3_at migration.

Not covered by this run: the whole workspace, the Python crate, WASM/root-Turbo consumers, the oracle and full-fingerprint corpus runs, and hosted CI. Fixture-gated tests skip when their fixture is absent, so this run is not a corpus run.

#7779 stays open until the F3b stop line has merged.

Still uncounted (deliberately, follow-ups)

  • A missing or non-reference ExtrudedDirection on IfcExtrudedAreaSolid / IfcExtrudedAreaSolidTapered. The IfcSurfaceOfLinearExtrusion one is counted.
  • A MappingOrigin reference that does not resolve; on the textured path a MappingOrigin slot holding a non-reference now errors without being counted.
  • A zero-length direction on a linear placement (the same defect is counted for extrusions and revolved solids).
    These keep their errors; only the count is missing.

Mandatory-attribute refusals added in the last fix-up

  • IfcSurfaceOfLinearExtrusion.ExtrudedDirection (mandatory in IFC2X3, IFC4, IFC4X3): a $, * or non-reference value used to sweep along +Z; it is refused and counted on the surface through direction3_at (an absent one was already an error, now counted). Test: processors/surface_plan_tests.rs::a_missing_extruded_direction_is_refused_and_counted.
  • IfcSurfaceOfRevolution.AxisPosition (mandatory): a $, * or non-reference value used to revolve about origin/+Z; it now refuses the face and counts the surface record, before the profile is sampled (a face whose profile could not be sampled used to fall back to a flat boundary polygon and is now refused). A $ Axis inside the Axis1Placement keeps the IFC default +Z. Test: tests/surface_of_revolution_axis_refusal.rs::a_missing_revolution_axis_position_refuses_the_face_and_counts.
  • Analytic export: analytic/extrusion.rs rescales a finite-but-overflowing direction ((1.7E308,0.,1.7E308)) as ExtrusionParams::decode does, so both paths agree. Test: an_extruded_direction_whose_length_overflows_agrees_with_the_mesh_path.
  • helpers::get_direction_by_id lost its last caller and is deleted here; #7896 must not claim it (when it rebases, both surface_plan.rs and placement_reader_tests.rs resolve to this PR's side).
  • Not changed: a $ SweptCurve on a surface of revolution still falls back to the flat boundary uncounted; IFC2X3 IfcSweptSurface.Position $ is read as no placement. Both predate this PR.

Validation (latest run)

Head 3059d4d74c (code) on bcf84d3724: PC fleet job ed67e14b-7856-4e4a-a0da-1bc0e127affa, clean tree: cargo test -p ifc-lite-core -p ifc-lite-geometry -p ifc-lite-processing -p ifc-lite-export -p ifc-lite-wasm 5,688 passed / 0 failed / 40 ignored; cargo clippy --workspace --all-targets -- -D warnings clean. Earlier head a48c9e5daa: workspace tests 6,702 passed (408 suites), 182 fixtures verified, workspace clippy clean. check-rust-semver was not run (cargo-semver-checks is not installed on the local host); the touched items are pub(super)/pub(crate) only and check-rust-api-surface passes.