Skip to content

solidcore-ops: say which solid test a body failed, and name a broken port invariant (#15035) - #15164

Merged
bherbruck merged 3 commits into
tangency-labs:mainfrom
brett19:ops-solid-test-15035
Nov 12, 2026
Merged

bherbruck merged 3 commits into
tangency-labs:mainfrom
brett19:ops-solid-test-15035

Conversation

@brett19

@brett19 brett19 commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

This PR makes the kernel say which test a body failed when it is not a closed solid facing out. solidcore-ops can then carry that test, and a broken kernel invariant, as data instead of a bare NotSolid or Exception. It covers part 2 of #15035 and the Error::Invariant variant.

Part 1 (OffsetRefusal::Other) belongs to @MarkusReichart's #15160 and is not touched here. Part 3 (the Unsoundness entities) is not in this PR either, for two reasons. It rewrites the same offset_refused mapping and OffsetRefusal::Unsound that #15160 is rewriting. And no kernel check on main produces any of its new variants yet: KeptEdgeNotClear arrives with #13585. Part 3 will stack on #15160.

Changes a default: no

Kernel (solidcore/crates/solidcore/src/topology/brep.rs)

  • SolidTest, as in the stub on ops refusals: no string catch-all, and say which solid test failed #15035: NotManifold, NotClosedSolids, PointersInvalid, Invalid, LoopOrientationUndecided, VolumeNegative, VolumeUndecided. It is not #[non_exhaustive], so adding a test breaks every exhaustive match downstream.
  • Three functions name the first test a body fails, using the same tests in the same order as before: outward_solid_failure, outward_touching_solids_failure and valid_and_outward_failure. is_outward_solid, is_outward_touching_solids and is_valid_and_outward now call them (.is_none()), so their results are unchanged. PointersInvalid covers both ways the old combined condition could fail on the pointer side: a bad pointer status, or a pointer report that leaves AssertValid unrun.
  • LoopOrientationUndecided is in the stub, but no check returns it yet. Nothing in the solid check decides a loop's orientation from its certified area. The variant is documented as reserved.

solidcore-ops

  • Error::NotSolidBecause(SolidTest), plus a re-export of solidcore_ops::SolidTest. The new Body::check_solid() returns it. The check runs on a copy, so the body is left as it was.
  • Error::NotSolid stays, and every call that returns it today still does. Moving finish and the other result checks over to NotSolidBecause is the "contract" step. That step would change the expected values in existing tests (tests.rs the_result_contract and two more, offset/tests.rs:315, split/tests.rs:224,320). So it is left for a maintainer to decide, and not done here.
  • Error::Invariant { operation, reason }: the kernel's SolidError::PortInvariant maps to it instead of Exception. Exception is still what ops' own consistency checks and PreparationRequired give. No SolidCraft code matches solidcore_ops::Error::Exception or its text.

Tests

  • issue_2972_volume_sign_enclosure.rs::the_solid_test_names_the_test_a_body_fails builds one real case for each test that can fail:
    • a box passes every test;
    • a sheet fails NotManifold, or NotClosedSolids under the touching test;
    • a box with a vertex tolerance 1000 times the body's fails PointersInvalid, and so does a box with every face flipped;
    • the quarter horn torus of Modeling: unexpected result #1954, with internal_pole_row_through_knot off, fails Invalid (AssertValid reports an internal pole after a clean pointer check);
    • the box with its material outside fails VolumeNegative;
    • the quarter shell R 10, t 1e-6 fails VolumeUndecided.
  • solidcore-ops tests.rs:
    • check_solid_names_the_test_a_body_fails covers a box, a sheet, a flipped box and an inside-out box, and checks the .smb bytes are unchanged;
    • a_broken_kernel_invariant_is_named_not_an_exception checks that PortInvariant becomes Invariant and PreparationRequired stays Exception. No input reaches a broken invariant, because each one found is a defect that gets fixed, so the kernel error is built by hand in this test.
  • No existing test expectation or input was changed.

Gate

Gate case 2: the change is solidcore/ only, but it adds public API that SolidCraft compiles against.

  • sc-gate.sh --core-only on the final head (rebased on 9ebf0e9): all PASS. That is fmt, clippy, panic-sites, wasm, tests, doctests, solids, binaries, the rig and every goldens unit, with no golden changes.
  • sc-gate.sh --craft-only --no-tests (checks, clippy, wasm): PASS on the pre-rebase head. The only commit since changes a test argument (&mut k to &k).

Written by Claude Code (Anthropic) on behalf of @brett19.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU

Summary by CodeRabbit

  • New Features
    • Added a solid-check operation that identifies the first failed check, including manifoldness, validity, and volume orientation.
    • Added clearer error classifications for solid-check failures and kernel invariant violations.

@coderabbitai

coderabbitai Bot commented Nov 11, 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 topology checks now report specific solid-validation failures. The ops crate adds Body::check_solid() and distinguishes kernel port-invariant errors from preparation-required errors.

Changes: Solid-check diagnostics

Layer / File(s) Summary
Topology failure categories
solidcore/crates/solidcore/src/topology/brep.rs, solidcore/crates/solidcore/tests/issue_2972_volume_sign_enclosure.rs
The outward-solid checks now report named failure categories. Existing boolean checks use these results, and tests cover the reported categories.
Ops check API and error mapping
solidcore/crates/solidcore-ops/src/error.rs, solidcore/crates/solidcore-ops/src/lib.rs, solidcore/crates/solidcore-ops/src/measure.rs, solidcore/crates/solidcore-ops/src/tests.rs
The ops crate exposes SolidTest and adds Body::check_solid(). It maps PortInvariant to Error::Invariant and retains the PreparationRequired mapping to Exception. Tests check failure results, error mappings, and that checked bodies remain unchanged.

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

Merge Risk: Minimal · previous review 80493

This adds a diagnostic API and a new error variant, and keeps the existing boolean checks and the existing NotSolid error unchanged for current callers. No concrete merge-blocking risk was identified.

Security architecture risk: Low · up to 80493

The changes expose more precise failure information without an identified weakening of validation or body isolation. The main remaining uncertainty is compatibility with downstream callers of the expanded public API.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure change is a package-level diagnostic contract over caller-supplied geometry. The inspected entrypoints return validation categories and error data; they do not introduce an identity or authority transition. Consumers outside the checked workspace remain unverified.

Trust Boundaries and Controls

  • observed — The diagnostic refactor preserves the solid acceptance control: invalid pointers or validity results stop evaluation, unsure regions remain errors, and only a certified positive volume passes. Naming a failure does not turn an undecided or invalid body into an accepted solid.

Resilience and Maintainability Implications

  • inferred — The new operation inherits existing measurement isolation and recovery: validation runs on an independent copy, session access is serialized, and cancellation or panic uses the existing kernel-replacement path. These mechanisms are unchanged from the full PR base; dedicated concurrency and cancellation tests for check_solid were not available in the inspected evidence.
Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the main change: solidcore-ops now reports which solid test a body failed (NotSolidBecause, check_solid) and names a broken kernel port invariant (Error::Invariant). It is specific and…
Description check Passed The description follows the template's main parts: it explains what the change does and the problem it solves, states the 'Changes a default' line, and gives detailed validation with test cases and ga…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Existing Defaults Unchanged Passed The check fails only if the PR changes a UX default (default setting or preference, usual command behaviour, UI layout or behaviour, shortcuts), or if the PR is not purely additive. Kernel or geometry…
Full details: Title check

Explanation

The title names the main change: solidcore-ops now reports which solid test a body failed (NotSolidBecause, check_solid) and names a broken kernel port invariant (Error::Invariant). It is specific and matches the changeset, though the issue reference and the dense wording make it somewhat long.

Full details: Description check

Explanation

The description follows the template's main parts: it explains what the change does and the problem it solves, states the 'Changes a default' line, and gives detailed validation with test cases and gate results. It has no screenshot or recording, but the template says changes with no useful observable behavior may omit that evidence, and this kernel/API change qualifies. The Change section does not explain the feature in plain words for a newcomer; it opens with kernel and solidcore-ops terms. The 'Test change:' line is not needed because no existing test expectation was changed, and the description states this. The Integration status section is not filled in, with no upstream commit or PR status recorded beyond the gate note.

Full details: Existing Defaults Unchanged

Explanation

The check fails only if the PR changes a UX default (default setting or preference, usual command behaviour, UI layout or behaviour, shortcuts), or if the PR is not purely additive. Kernel or geometry changes under solidcore/ are not UX defaults and pass. Evidence: - The changed-file inventory (git diff --name-status against the review base) lists six files, all under solidcore/crates/: solidcore-ops/src/{error,lib,measure,tests}.rs, solidcore/src/topology/brep.rs, and solidcore/tests/issue_2972_volume_sign_enclosure.rs. No CLI, configuration, UI, shortcut, or preference files change. - In solidcore-ops/src/error.rs, the changes are additive: a re-export of SolidTest, new variants Error::NotSolidBecause(SolidTest) and Error::Invariant { operation, reason }, and new Display arms. Error::NotSolid and its callers are unchanged, as the PR description states. - One existing mapping changes. SolidError::PortInvariant now maps to Error::Invariant instead of Error::Exception. This affects how a kernel-invariant error is classified in a Rust library error type. It is not a user-facing default, and the PR says no SolidCraft code matches Exception. - The PR description says Changes a default: no. The code changes no UX default, so the consistency condition is met. No UX default is changed, and the solidcore/ kernel changes fall under the explicit pass rule.

Finishing Touches

Generate unit tests (beta)

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

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 94242dc and 804938996bdebad537557fda3d73700ba175202b.

Files selected for processing: 6

  • solidcore/crates/solidcore-ops/src/error.rs
  • solidcore/crates/solidcore-ops/src/lib.rs
  • solidcore/crates/solidcore-ops/src/measure.rs
  • solidcore/crates/solidcore-ops/src/tests.rs
  • solidcore/crates/solidcore/src/topology/brep.rs
  • solidcore/crates/solidcore/tests/issue_2972_volume_sign_enclosure.rs

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

@brett19
brett19 force-pushed the ops-solid-test-15035 branch from 6cea94e to 6a877c7 Compare November 11, 2026 22:08
@brett19
brett19 force-pushed the ops-solid-test-15035 branch from 6a877c7 to 8049389 Compare November 12, 2026 00:04
@brett19
brett19 marked this pull request as ready for review November 12, 2026 00:04
@brett19
brett19 requested a review from a team as a code owner November 12, 2026 00:04
@brett19
brett19 requested review from bherbruck and removed request for a team November 12, 2026 00:04
@bherbruck bherbruck added the approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) label Nov 12, 2026
@brett19
brett19 marked this pull request as draft November 12, 2026 00:20
@brett19
brett19 marked this pull request as ready for review November 12, 2026 00:29
@bherbruck

Copy link
Copy Markdown
Collaborator

The shape in #15160 is settled now: where the kernel states a failure only in words, the variant carries its class (ErrorKind), a defect flag (the kernel's fault, a bug to report, not a refusal) and the phrase, and the enum is #[non_exhaustive]. Please make Invariant { operation, reason: &'static str } follow that pattern: carry the kernel class and defect: true so callers can tell it is a defect without reading the text, and keep #[non_exhaustive] on anything you add. Everything else here reads fine.

brett19 and others added 3 commits November 12, 2026 02:41
…port invariant (tangency-labs#15035)

The kernel's solid test now names the test a body fails (`SolidTest`:
not manifold, not closed solids, pointer check, AssertValid, volume
negative, volume undecided) through `outward_solid_failure`,
`outward_touching_solids_failure` and `valid_and_outward_failure`; the
bool forms read them, with the same tests in the same order.

solidcore-ops carries it as `Error::NotSolidBecause(SolidTest)`, which
the new `Body::check_solid` returns; `Error::NotSolid` stays for every
call that returns it today. A kernel `PortInvariant` is now
`Error::Invariant { operation, reason }` instead of `Exception`, which
ops' own consistency checks and a missing preparation still give.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU
…ked a defect

Error::Invariant now carries the kernel's class (SolidError::kind, PortInvariant) and
defect: true beside the operation and reason, following the class/defect/phrase shape
of OffsetRefusal::Phrase. Invariant, NotSolidBecause and solidcore's SolidTest are
#[non_exhaustive]; SolidTest says itself through a Display of its own, which ops uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU
@brett19
brett19 force-pushed the ops-solid-test-15035 branch from d4d677c to b2968fb Compare November 12, 2026 02:41
@brett19

brett19 commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator Author

Done in b2968fb (rebased onto main):

  • Error::Invariant is now { class: ErrorKind, defect: bool, operation, reason }, the class/defect order of OffsetRefusal::Phrase in solidcore-ops: every kernel offset refusal has a named reason, no text catch-all (#15035) #15160 (not merged, so mirrored by name and type, no dependency on its branch). class is the kernel error's own SolidError::kind() (ErrorKind::PortInvariant), not hard-coded; defect is true.
  • #[non_exhaustive] on the Invariant and NotSolidBecause variants and on solidcore's SolidTest, everything this PR adds. SolidTest now has its own Display, which ops uses, so ops needs no wildcard text arm.
  • Display shows the class and the defect marker; a_broken_kernel_invariant_is_named_not_an_exception asserts both fields and the message.
  • Gate: --core-only and --craft-only --no-tests pass.

Written by Claude Code (Anthropic) on behalf of @brett19.

@bherbruck bherbruck added the ready to merge reviewed, every ask addressed; merge once CI is green label Nov 12, 2026
@bherbruck
bherbruck added this pull request to the merge queue Nov 12, 2026
Merged via the queue into tangency-labs:main with commit af078d1 Nov 12, 2026
80 checks passed
@brett19
brett19 deleted the ops-solid-test-15035 branch November 24, 2026 11:02
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) 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.

2 participants