Skip to content

STEP export: each body states its own accuracy, so Insert Design no longer opens a body beside a loose one (#17579) - #18354

Merged
bherbruck merged 1 commit into
tangency-labs:mainfrom
hazardandy:fix/step-per-body-accuracy
Nov 18, 2026
Merged

bherbruck merged 1 commit into
tangency-labs:mainfrom
hazardandy:fix/step-per-body-accuracy

Conversation

@hazardandy

@hazardandy hazardandy commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Change

Insert Design brings a design's bodies into an assembly by writing them to SolidCraft's own STEP and reading it back. The STEP writer stated one accuracy for the whole file: the loosest tolerance of any record, edge or vertex of any body (#11997). The reader reads every solid at its representation's stated tolerance. So one body with loose edges made every other body of the design be read back at that tolerance, and a closed body could lose a face there and come back open. Examples:

Now a body whose accuracy is finer than the file's loosest is written in a representation context of its own that states its accuracy. The reader already reads each representation in its own context. The bodies are written in runs that keep the order SolidCraft's reader met them in before, because a link update keeps body names by position. A file whose bodies are all equally accurate is written byte for byte as before.

Fixes #17579

Changes a default: no

Validation

  • Neutral repro (attached to my comment on Insert Design and STEP export: bodies that import closed come back open (volume 0) #17579): a 30 × 25 × 20 block with a blind diagonal Ø10 bore and a slot cut from a 45°-tilted plane (closed: 15 faces, 12466.133 mm³), beside a one-face sheet whose edges lie 0.15 mm off its plane.
    • After Insert Design on main: 14 faces, open, no volume.
    • Here: 15 faces, closed, 12466.133 mm³.
  • Insert Design and STEP export: bodies that import closed come back open (volume 0) #17579's attached STEP, through Insert Design:
    • main: screws open, 21 faces.
    • Here: screws closed, 30 faces, 34.792 mm³ each. The carriage is unchanged.
  • New tests:
    • solidcore-step write::product::tests::each_body_is_written_in_a_context_of_its_own_accuracy
    • solidcraft-kernel step_out::tests::each_body_reads_back_at_its_own_tolerance_in_order: on main the tight bodies read back at 0.3 mm.
    • solidcraft-engine component_link::tests::insert_design_reads_each_body_at_its_own_accuracy_beside_a_loose_sheet: on main the block comes back with 14 faces, open.
    • Both of the last two fail without the writer change even with the companion import fix in place.
  • Goldens moved: none.

CI notes

Full CI ran on the fork (GitHub-hosted runners, with the WebAssembly and RISC-V checks): https://github.com/hazardandy/solidcraft/actions/runs/44019838620

  • Passed: format and repository checks, Clippy, doc tests, reference tests, GPU path tests, Windows builds, WebAssembly, RISC-V, SolidCore standalone build and wasm checks, and dependency advisories.
  • Native Linux tests and SolidCore checks (tests): the hosted runner was shut down while compiling, on both attempts, so no test ran there. The three new tests pass locally on this branch alone. The local full runs gave 8516 passed and 13 failed in the root workspace, all listed in tests/KNOWN_FAILING_TESTS. In solidcore, 8091 passed and 1 failed for want of upstream/TestFiles.
  • Action matrix: the shards fail the same way on main's nightly run 43818772935.

Screenshots of the behavior

The neutral block after Insert Design, looking into the diagonal bore. Left: 0.43.0, where the bore's wall is missing and the block is open (14 faces). Right: this branch, closed (15 faces, 12466.133 mm³). Captured with solidcraft-cli snapshot.

bore-pair

Integration status

Summary by CodeRabbit

  • Bug Fixes

    • STEP exports now better preserve the individual accuracy of bodies with different tolerances, including bodies with looser edge tolerances. Bodies with matching accuracy can share export context.
    • Reimporting STEP files preserves body names and order, while maintaining the appropriate accuracy for each body.
  • Tests

    • Added coverage for linking a design containing a bored, slotted block and a sheet with loose edge tolerances.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The STEP writer now assigns representation contexts based on body accuracy. New tests check tolerance preservation during STEP round trips and body measurements after linking a design.

Changes: STEP body accuracy

Layer / File(s) Summary
Per-body STEP representation contexts
solidcore/crates/solidcore-step/src/write/product.rs, crates/kernel/src/step_out.rs
The STEP writer sets the file context from the loosest body accuracy and creates or reuses contexts for finer accuracies. It emits solid and sheet representation runs with their associated contexts. Tests check context selection, ordering, and tolerance preservation across export and import.
Linked-design body measurement test
crates/engine/src/cmd/component_link.rs
A new test combines a loose-tolerance sheet with a bored, slotted block, links the saved design, and checks the closed body count, face count, and volume.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Medium

Merge Risk: Minimal · previous review 77805

This change makes STEP export write each body in a context matching its own accuracy, so a loose body no longer causes tighter bodies to reopen open after Insert Design. Files whose bodies all have the same accuracy are written as before. No concrete defect remains from the review. The new tests cover the reported scenario, but they have only been run locally, not on hosted CI.

Architecture risk: Medium · up to 77805

The change affects 2 systems.

Changed systems: crates, solidcore

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — crates (service) was modified; 2 changed files map to changed impact.
  • observed — solidcore (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in crates/engine/src/cmd/component_link.rs: Adds a test fixture that builds a STEP file containing a single open sheet with spline edges offset 0.15 mm from its face.
  • observed — Modified behavior in crates/engine/src/cmd/component_link.rs: Adds a fixture that creates a block, cuts a diagonal bore, then adds and extrudes a slot sketch.
  • observed — Modified behavior in crates/engine/src/cmd/component_link.rs: Adds a helper that returns each measured body’s name, face count, closed status, and optional volume.
  • observed — Modified behavior in crates/engine/src/cmd/component_link.rs: Adds a test that combines the loose-tolerance sheet with the block, links the saved design, and asserts that exactly one linked body is closed and that its face count and volume match the original block.

Reliability and maintainability

  • inferred — Risk-relevant change factors for crates: blast_radius_1; direct_dependents_1
  • inferred — Risk-relevant change factors for solidcore: blast_radius_1; blast_radius_2; direct_dependents_1
Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the main change: STEP export now writes each body with its own accuracy, which stops Insert Design from opening a body beside a loose one. It is specific and matches the raw summary an…
Description check Passed The description follows the template. It has a Change section that explains the problem and behavior in plain words and links issue #17579. It includes the required 'Changes a default: no' line. It ha…
Linked Issues check Passed [#17579] The requirement is that the three bodies of carriage_screws_min.step stay closed on every Insert Design and STEP export path. The cause is one file-wide uncertainty, set from the loosest body…
Out of Scope Changes check Passed All changed code relates to the linked issue. The writer change in product.rs implements the per-body accuracy contexts. Its helpers accuracy() and context() and the updated module documentation s…
Existing Defaults Unchanged Passed The check fails only if the PR changes a UX default: a default setting or preference, usual command behaviour, UI layout or behaviour, or a shortcut. The PR changes three files: `crates/engine/src/cmd…
Full details: Title check

Explanation

The title names the main change: STEP export now writes each body with its own accuracy, which stops Insert Design from opening a body beside a loose one. It is specific and matches the raw summary and objectives. It is long (21 words) and includes an issue number, but it is not off-topic or vague.

Full details: Description check

Explanation

The description follows the template. It has a Change section that explains the problem and behavior in plain words and links issue #17579. It includes the required 'Changes a default: no' line. It has Validation with expected and measured values. It has a Screenshots section with an embedded image. It has an Integration status section. The template's required 'Test change' line is not needed here, because the PR changes no existing test or golden expectation, and the description says 'Goldens moved: none.' The Change section does not define the terms 'SolidCraft' and 'SolidCore' for a newcomer, and it refers to #11997 without context. These are minor gaps. The description is mostly complete.

Full details: Linked Issues check

Explanation

[#17579] The requirement is that the three bodies of carriage_screws_min.step stay closed on every Insert Design and STEP export path. The cause is one file-wide uncertainty, set from the loosest body. The diff in solidcore/crates/solidcore-step/src/write/product.rs fixes this. accuracy() computes each body's own accuracy. A body whose accuracy is finer than the file's gets its own GEOMETRIC_REPRESENTATION_CONTEXT with that uncertainty (context(), cached per accuracy bit pattern). Bodies are grouped into runs that share a context, and the runs keep the reader's body order. The unit test each_body_is_written_in_a_context_of_its_own_accuracy checks the context per representation, the run order, and that uniform files keep one context. The reader already reads each representation in its own context, per the PR description. The author reports that the issue's attached STEP now reads back with closed screws (30 faces, 34.792 mm³ each) and an unchanged carriage. I did not re-run that case. The engine test insert_design_reads_each_body_at_its_own_accuracy_beside_a_loose_sheet is described in the PR but I did not inspect its source. The code change addresses the stated mechanism, so the coding requirement is met.

Full details: Out of Scope Changes check

Explanation

All changed code relates to the linked issue. The writer change in product.rs implements the per-body accuracy contexts. Its helpers accuracy() and context() and the updated module documentation support that change. The new test solids_by_context and the test each_body_is_written_in_a_context_of_its_own_accuracy verify it. The test each_body_reads_back_at_its_own_tolerance_in_order in crates/kernel/src/step_out.rs and the engine test in crates/engine/src/cmd/component_link.rs cover the same behavior through the reader and Insert Design. No unrelated functional change appears in the reviewed diff. Limitation: I reviewed only the product.rs diff and the PR summaries of the other two test files. The reported files-with-changes match the PR description.

Full details: Existing Defaults Unchanged

Explanation

The check fails only if the PR changes a UX default: a default setting or preference, usual command behaviour, UI layout or behaviour, or a shortcut. The PR changes three files: crates/engine/src/cmd/component_link.rs (test only), crates/kernel/src/step_out.rs (test only), and solidcore/crates/solidcore-step/src/write/product.rs (STEP writer). The writer change alters STEP output for files whose bodies differ in accuracy. That is a geometry/kernel result, and the check states that such changes, including anything under solidcore/, are not changed defaults. The keyword scan of the writer diff matched only Header::default() in new test code, not a user-facing default. No settings, preferences, UI, or shortcut files changed. The PR description's Changes a default: no is consistent with the diff. Equal-accuracy files are written byte for byte as before, so existing output is unchanged for those cases.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 47f714a and 7780571.

Files selected for processing: 3

  • crates/engine/src/cmd/component_link.rs
  • crates/kernel/src/step_out.rs
  • solidcore/crates/solidcore-step/src/write/product.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@github-actions github-actions Bot added the area:kernel B-rep kernel, booleans, blends, STEP/IGES label Nov 17, 2026
@hazardandy
hazardandy marked this pull request as ready for review November 17, 2026 15:59
@hazardandy
hazardandy requested a review from a team as a code owner November 17, 2026 15:59
@hazardandy
hazardandy requested review from jyviko and removed request for a team November 17, 2026 15:59
@bherbruck bherbruck added ready to merge reviewed, every ask addressed; merge once CI is green approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) labels Nov 17, 2026
@bherbruck
bherbruck enabled auto-merge November 17, 2026 16:25
…onger opens a body beside a loose one

The STEP writer stated one uncertainty for the whole file, the loosest
tolerance of any record, edge or vertex of any body (tangency-labs#11997). The reader reads
every solid at its representation's stated tolerance, and Insert Design brings
a design's bodies in through SolidCraft's own STEP. So one body with loose
edges (an imported lens whose edges read with 0.37 mm tolerances) made every
other body of the design be read back at that tolerance, and a native block
with a diagonal bore and an angled slot lost its bore face there and came back
open.

A body whose accuracy is finer than the file's loosest is now written in a
representation context of its own that states it. The bodies are written in
runs laid out so that SolidCraft's reader, which meets a product's linked
representations last written first, meets the bodies in the order it did
before (every sheet, then every solid, each in body order): a link update
keeps body names by position. A file whose bodies are all equally accurate is
written byte for byte as before.

Tests:
- solidcore-step write::product::tests::each_body_is_written_in_a_context_of_its_own_accuracy
- kernel step_out::tests::each_body_reads_back_at_its_own_tolerance_in_order
  (before: the tight bodies read back at 0.3 mm)
- engine component_link::tests::insert_design_reads_each_body_at_its_own_accuracy_beside_a_loose_sheet
  (a neutral block beside a sheet with 0.45 mm edges: 15 faces closed in its
  design, 14 faces open after Insert Design before; 15 closed after)
@hazardandy

Copy link
Copy Markdown
Contributor Author

The Native Linux tests failure in run 44121907557 is not from this change. The known-failing check reports one regression, solidcraft-ui-egui::home::tests::library_cache_identity_tracks_replacements_with_preserved_mtime. That is the ctime-granularity flake of #18333, which #18334 fixed. This run's merge commit is based on main at 47f714a, which predates the fix. The other 12 failures are all listed in tests/KNOWN_FAILING_TESTS. The three new tests are unaffected. Rebased locally on current main with no conflicts, and the home test passes there.

auto-merge was automatically disabled November 18, 2026 05:34

Head branch was pushed to by a user without write access

@hazardandy
hazardandy force-pushed the fix/step-per-body-accuracy branch from 7780571 to 74bfd91 Compare November 18, 2026 05:34
@bherbruck
bherbruck added this pull request to the merge queue Nov 18, 2026
Merged via the queue into tangency-labs:main with commit 3126b7a Nov 18, 2026
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) area:kernel B-rep kernel, booleans, blends, STEP/IGES ready to merge reviewed, every ask addressed; merge once CI is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insert Design and STEP export: bodies that import closed come back open (volume 0)

2 participants