Files
Brett Lawson 7b3c9ee508 STEP import runs SMLib's check on each placed part and warns about failures; Repair uses the same check (#17689) (#17697)
* Claim: STEP import check and heal, Repair uses the same check

Empty claim commit for #17689.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdcgEtsWyH5fjgiavRsRdt

* STEP import runs SMLib's full check and names a part it fails; Repair and the feature check say so too

A STEP part SMLib takes but whose full check fails came in silently: the
import only asked whether SMLib takes the part, Repair said "nothing to
repair", and the first boolean on the part was refused with the check's
list and no word about the import (#17689).

- Import: each part is checked once when it is read (on the import's
  workers), and a part the check fails gets a "needs repair" warning that
  names it and summarises the failed tests (each test once, with its count).
- Repair: when nothing it fixes applies, it runs the same check and says
  "nothing to repair" only when the check passes; otherwise it names the
  failed tests.
- Feature check (each_feature, the default): when the result's check
  refuses a body, the bodies the feature replaced are checked too, and the
  error says which of them already failed the check before the feature.

Regression fixture tests/step-regressions/block_edge_off_its_face.step:
a block whose edge curve lies 2 um off its face, which the reader takes
with that gap as the edge's tolerance; SMLib takes the part and its check
fails it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdcgEtsWyH5fjgiavRsRdt

* The new STEP regression fixture gets its attribution row and its export digest

tests/step-regressions/block_edge_off_its_face.step is a new fixture, so
`cargo xtask assets` needs its ATTRIBUTION row (pending file), and
step_export_bytes, which pins the export of every STEP fixture, gets one new
row for it (taken with STEP_EXPORT_BYTES_PRINT=1). No other row changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUqX4Moqx5bbkSocgEbsSV

* Expectations: three imports SMLib's check fails now carry the import's warning

Three tests asserted that an import gave no warnings, for bodies SMLib's
full check fails (the check every boolean runs on its result). The import
now says so, so the assertions move. Each new expectation is derived from
the body's own check in code, not pasted:

- body::planar_sources::tests::rounded_shell_planar_roles_are_exact_distinct_and_transformable:
  both cups pass the check as exported; the 100 x 3 cup read back from
  its STEP export fails it (#17705) and the one warning is that check's;
  the 80 x 2 cup read back still passes it and keeps its no-warnings
  assertion (each case's expectation is a flag in the loop tuple, checked
  against the body's own check).
- step_in::tests::nearly_round_spindle_torus_pin_end_in_halves_imports_whole
  and a_face_winding_two_turns_round_its_cylinder_imports_whole (#17706):
  assert_closed_measures takes `fails_check`. Their bodies fail the check
  and the last warning is that check's; the other four callers now assert
  that their bodies pass it (stronger than before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUqX4Moqx5bbkSocgEbsSV

* Review fixes: blame only a result's own inputs, report a check that cannot run

From one focused adversarial review of #17697:

- eval.rs: a refused result names the bodies that failed the check
  only among its own inputs, meaning its former self (same name) and
  the bodies the feature used up. Before, it named every body the
  feature replaced, so a move of two bodies could blame one body's
  refusal on the other. New test kept_refused_tests covers both cases.
- step_in: a part whose check cannot run (an operation's check would
  refuse it the same way, check_kept) now gets the NeedsRepair warning
  "SMLib's check could not run: ...". Before, it was only logged at
  debug level and came in silently, which is the #17689 symptom.
- check_summary: the "AssertValid skipped" line says why half the
  check did not run; it is not a failed test, so it is no longer
  listed. "1 failed test" is now singular.
- The comment in step_in/mod.rs now says the check is of the part as
  the file defines it, before its (rigid) placement.
- The new tests assert their topology counts: the block (6, 13, 9),
  written with its edge on or off its face, and the box with a moved
  corner (6, 12, 8).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUqX4Moqx5bbkSocgEbsSV

* eval_overlap tests from main call run_kept with no inputs

main added two tests that call run_kept(detached) and expect it to pass;
run_kept now also takes the inputs used to name a refusal, which a
passing check never reads, so they pass an empty list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUqX4Moqx5bbkSocgEbsSV

* Check each STEP part as placed, cancellably, with typed refusals

Review fixes for #17697:

- Import: check each part once per placement class (rigid placements
  share the part's check; a scale, shear or mirror is checked on its own
  instance and labelled so). The check runs on the placed body, as
  smlib_refusal does. Regression: a block whose 0.2 um lifted edge
  passes as defined and fails stretched x100 along z.
- failing_check checks a copy it owns (check_owned), so SMLib's stop
  token stops it; a stopped check cancels the import.
- Typed errors: CheckFailure/FailedTest replace check_summary;
  RepairRefusal { NothingToRepair, CheckFails } via KernelError::Repair.
- kept_refused states what it checks: the input as it was before the
  feature, as it is now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUqX4Moqx5bbkSocgEbsSV

* STEP import: check parts in the background after the design shows

Review (#17697): keep the import check and today's import speed.

- The reader collects one check job per part and placement class (keyed
  on the STEP item, never geometry); rigid repeats count as times (×n).
- ImportReport::checks (ImportChecks) runs the jobs on a kernel thread
  over the import's workers; findings are one list in read order, shown
  only when every check has ended, so the result does not depend on
  thread timing. The run stops when no copy of the report is left.
- step_import / StepReading::finish still wait and fold the findings in;
  with no worker threads the checks run as further reading steps.
- Model::settle_import_checks folds findings into the import's report
  and warning (after evaluate, per engine command, per UI frame);
  take_import_notices raises the status line once per import.
- Model::saved waits for the checks; the import cache writes its entry
  once they end (ImportCache::write_after), and read/clear wait for it.

Board fixture (8500 solids): design shown in 4.40 s vs main's 4.22 s
(was 17.90 s with the check inline); checks end in the background.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUqX4Moqx5bbkSocgEbsSV

* STEP import checks: notices per model, stopped single-mode reads cancel, no lost wakeups

Review fixes for the background check:
- Which check runs a model has told a window of is that model's own
  record (feature id + run), so a scratch copy evaluated beside it can no
  longer take the one status notice; a result restored from the eval
  cache is not told of twice; two imports of one text each get theirs.
- With no worker threads, a check the caller's token stopped stops the
  import ("STEP import cancelled") as a stopped read does, instead of
  keeping a partial list.
- A panic outside the per-check guard ends the run as stopped, so a
  waiter (save, import cache) is always woken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUqX4Moqx5bbkSocgEbsSV

* Keep a caught panic internal in kept-body refusals; let every reader wait for a pending import-cache write

CodeRabbit review on #17697:

- kept_refused turned every check error into KernelError::Failed, so a panic caught while
  checking a kept body (KernelError::Internal, e.g. from the SMLib copy) was cached as an
  ordinary refusal. It now stays Internal, with the body named. Test:
  kept_refused_tests::a_panic_in_the_check_stays_internal.
- ImportCache::join_pending took a pending write's handle out of PENDING before joining it, so
  a second reader, or clear, that came while the first waited found nothing to wait for and
  could read or leave behind an entry that was still being written. Each pending write is now a
  shared completion signal that stays listed until the write returns (or its thread ends), and
  every waiter waits on it. Deterministic test:
  every_reader_waits_for_a_pending_import_cache_write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MNXLXh7c1S97vY2G8GgerR

* Name a kept body's internal check error once, without a doubled prefix

kept_refused built the Internal arm's message from the error's Display, which already starts
with "kernel internal error: ", so the error read "kernel internal error: body `X`: kernel
internal error: ...". Use the inner message, as the evaluation guard does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MNXLXh7c1S97vY2G8GgerR

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:27:35 +00:00
..