Skip to content

Typed errors (TE-O-13, part 1 of 5): the deviation measures' and small queries' failures become named causes or reviewed defects (#19846) - #20315

Merged
bherbruck merged 2 commits into
tangency-labs:mainfrom
MarkusReichart:te-19846-queries
Nov 21, 2026
Merged

bherbruck merged 2 commits into
tangency-labs:mainfrom
MarkusReichart:te-19846-queries

Conversation

@MarkusReichart

@MarkusReichart MarkusReichart commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Change

Part of #19846 (TE-O-13, index #19799), part 1 of 5: the 35 counted sites of the deviation measures and the small queries (curve/plane_of.rs, nurbs/crv_deviation.rs, nurbs/srf_deviation.rs, query/contact.rs, query/continuity.rs, query/curve.rs, query/deviation.rs, query/distance_bound.rs, query/face_surface.rs, query/normal.rs). Each keeps its status, so upstream_status(), which most goldens units read, is unchanged; any QueryFailure keeps it. Each ends as one outcome of §6 of solidcore/docs/failure-codes-and-reproduction.md. This part adds the first named causes of QueryFailure, which the later parts reuse:

  • Failed with a name, class failed: BoundOverflows (9 sites: every number given is finite, as each entry point checks first, but the bound or the curves' size overflows the floating range; one condition in three files), NoStationDropped (an empty search, rule 7: no station of the curve dropped onto the other).
  • A kind the routine does not take (rule 8), class unsupported: SurfaceWithoutNurbs, a surface (or an analytic surface's B-spline base) whose NURBS net was never made or could not be made. kind_with_nurb leaves "a NURB that cannot be made" missing, so it is not proved to be the kernel's fault; the neighbouring arm of exact_of ("no control net to enclose the surface on") is Unsupported too.
  • The caller's argument or body (rule 9), class invalid_input: FaceWithoutSurface (status 1006, as before), NoPatchInBox (a UV box within the rounding of the patches' knot range but past every patch: the range check lets it through, and the heap of pieces starts empty).
  • Defects, each with its reason (16): pieces and patches that both curves or surfaces are cut into at the union of their breakpoints and raised to one degree, so they pair up; evaluations that return fewer derivatives than asked; a normal box asked for and not returned; a pair's face index taken from the same enumerated list; a Bézier patch without knots; a blend definition read only for a procedural blend, whose net as_b_spline always returns.
  • Deleted (rule 11, 4 sites): the quarters of a split patch (split returns four), the three axes of a box ([f64; 3]), and the two sides of an edge (a [_; 2] array, each side returning early on None). Each is now a destructuring that cannot fail.
Each site's outcome (lines on main at 9d1194d)
File:line                     Was                                         Outcome, status
curve/plane_of 111            the curves' size overflows the bound        BoundOverflows, 1001
nurbs/crv_deviation 98        no point evaluated                          Defect, 1001
crv_deviation 100, 106, 142,  the bound is not finite                     BoundOverflows, 1001
  236, 252, 303
crv_deviation 212             pieces do not share their spans (Hausdorff) Defect, 1001
crv_deviation 224             a piece without points                      Defect, 1001
crv_deviation 282, 290        pieces do not share their spans             Defect, 1001
crv_deviation 296             pieces are not of one degree                Defect, 1001
nurbs/srf_deviation 86        the surfaces' patches do not match (5 uses) Defect, 1001
srf_deviation 108, 116        the bound is not finite                     BoundOverflows, 1001
query/contact 354             a box has fewer than three axes             deleted (unreachable)
contact 490, 524              a pair's face is not among its faces        Defect, 1001
query/continuity 119, 530     the surface evaluation has fewer partials   Defect, 1001
continuity 407, 494           the curve evaluation has no 1st/2nd deriv.  Defect, 1001
continuity 439                the edge has fewer than two sides           deleted (unreachable)
query/curve 84                the curve has no box                        Defect, 1001
query/deviation 82, 173       no station dropped onto the other           NoStationDropped, 1001
query/distance_bound 167, 178 a split patch has fewer than four quarters  deleted (unreachable)
distance_bound 417            no patch overlaps the UV box                NoPatchInBox, 1001
distance_bound 566            a patch has no knots                        Defect, 1001
query/face_surface 51, 112    the face's surface (missing)                FaceWithoutSurface, 1006
query/normal 213              the B-spline surface's NURBS net            SurfaceWithoutNurbs, 1001
normal 344                    the surface's B-spline form                 Defect, 1001

Why five parts: 146 sites in 23 files. Part 2 takes query/api_queries.rs with query/brep.rs; part 3 query/edge.rs, query/face/p1.rs, p3.rs, p4.rs and query/tess.rs; part 4 the poly B-rep (query/poly.rs, query/poly/copy.rs, query/poly_properties.rs); and part 5, last, query/brep/ray.rs, query/brep/ray/live.rs and query/face/p2.rs, beside @brett19's #20062 and #18065, off their lines. This part touches no line of the open PRs on its files (#13891, #14683 on curve/plane_of.rs; #15375, #18536 on query/distance_bound.rs).

Changes a default: no

Three sites change their class at an unchanged status: face_surface.rs's two (missing to invalid_input, 1006) and distance_bound.rs's empty box (failed to invalid_input, 1001), as rules 2 and 9 ask and as IntersectFailure::FaceWithoutSurface already is; normal.rs's missing net goes from failed to unsupported (1001). No library code matches on these kinds.

Test change: plane_of's curves_too_large_for_the_bound_are_refused_not_read_as_a_plane asserted only Err(Failed(_)); it now asserts BoundOverflows and status 1001. New tests reach BoundOverflows at crv_deviation's largest_gap (from both certified_distance and certified_hausdorff), NoPatchInBox and FaceWithoutSurface (face_surface_feet) at their sites, each with cause, status and class; error/query.rs checks every new cause's status and class. No test reaches NoStationDropped, SurfaceWithoutNurbs, the other BoundOverflows sites or the defects at their sites; their statuses rest on the goldens.

Validation

Full gate at the head 1e180ac (base 9d1194d, sc_gate_v2.sh --full), RESULT pass:

  • cargo fmt --check, the repo checks under scripts/ci, cargo clippy -D warnings, the wasm build: pass.
  • cargo test -p solidcore: 7780 passed, 0 failed, 56 ignored. This includes error::query::tests::the_query_phrase_cause_sites_only_shrink with the ten lines removed, and the new tests above.
  • Goldens: 283 of 283 units pass, nothing re-blessed, so no recorded status moved.
  • Kernel rig as in CI (xtask kernel-cases, all shards): no red case.
  • App tests of kernel, engine and doc as in CI: 9073 passed, 15 failed, all 15 listed in tests/KNOWN_FAILING_TESTS.

Not run: the test suites of crates this change does not touch, doctests and publish dry run, left to CI.

Units: all (these files have no goldens unit of their own; they are reached through the importing units, all 283 run)
In scope: the 35 counted sites of the ten files above, their pin lines, and the QueryFailure causes they need
Out of scope: the other 111 sites of #19846 (parts 2 to 5)

Screenshots of the behavior (when observable)

Nothing to see: the statuses, and so every result, are unchanged; only the error's cause and class are new.

Integration status

Checked against upstream main f37ef57: the whole stack (this part and parts 2 to 5) merges without conflict, and main adds no query phrase site in these files.

Co-written and tested with Claude Code (AI).

Summary by CodeRabbit

  • Bug Fixes
    • Query failures now provide more specific error information for cases such as overflowing bounds, missing surfaces, and unavailable results.
    • Continuity checks now return no result when valid data cannot be obtained for either side, rather than reporting a generic error.
    • Error statuses are more consistent across curve, surface, and face queries.

…s#19846)

Co-Authored-By: Claude Code <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes add named QueryFailure causes and use typed failures across curve and surface deviation calculations and query operations. They also update query evaluation error handling and add tests for selected failure variants, statuses, and kinds.

Changes: Typed query failures

Layer / File(s) Summary
Define named query failures
solidcore/crates/solidcore/src/error/query.rs
QueryFailure adds five named causes with status mappings, kinds, and display messages. Tests cover the new mappings and display text.
Classify curve and surface deviation errors
solidcore/crates/solidcore/src/curve/plane_of.rs, solidcore/crates/solidcore/src/nurbs/*_deviation.rs
Deviation operations use typed failures for bound overflows and defects. The curve deviation tests check overflow failure variants and status.
Use named failures in query operations
solidcore/crates/solidcore/src/query/deviation.rs, solidcore/crates/solidcore/src/query/distance_bound.rs, solidcore/crates/solidcore/src/query/face_surface.rs, solidcore/crates/solidcore/src/query/normal.rs
These query paths return named failure causes for conditions such as no station dropped, no patch in a box, a face without a surface, and a surface without a NURBS net. Tests check selected failure variants, statuses, and kinds.
Classify query evaluation defects
solidcore/crates/solidcore/src/query/contact.rs, solidcore/crates/solidcore/src/query/continuity.rs, solidcore/crates/solidcore/src/query/curve.rs
Contact and curve query paths report defects through typed query errors. Continuity reports incomplete evaluations as defects and returns Ok(None) if either face side lacks a valid result.

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

Merge Risk: Minimal · up to 1e180

This change replaces generic query failures with named causes and defects while keeping the statuses that upstream callers read. I found no concrete behavior regression, and the reported test and golden runs passed. It looks ready to merge.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the main change: typed errors for the deviation measures and small queries, with named causes or reviewed defects. It also identifies the part (1 of 5) and the tracking issue. It is lo…
Description check Passed The description follows the template closely. It has a Change section that explains the purpose, the affected sites, and the status and class outcomes. It includes the required 'Changes a default: no'…
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 covers UX defaults only: default settings or preferences, command behaviour in normal use, UI layout or behaviour, and shortcuts. Kernel or geometry result changes under solidcore/ are expli…
Full details: Title check

Explanation

The title names the main change: typed errors for the deviation measures and small queries, with named causes or reviewed defects. It also identifies the part (1 of 5) and the tracking issue. It is long (137 characters) and uses the internal label TE-O-13, but it matches the changeset, which replaces 35 failure sites in the deviation and small query files with QueryFailure causes or Defect reasons.

Full details: Description check

Explanation

The description follows the template closely. It has a Change section that explains the purpose, the affected sites, and the status and class outcomes. It includes the required 'Changes a default: no' line and a Test change line, which is needed because an existing test assertion in plane_of was changed. It has a Validation section with concrete results and an integration status. The Screenshots section says there is nothing observable to show, which the template allows for changes without observable behavior. The description refers to internal jargon (TE-O-13, rule numbers, goldens) and to a change-scoped document, and it does not fully explain the project terms to a newcomer. These are minor gaps and do not make the description incomplete.

Full details: Existing Defaults Unchanged

Explanation

The check covers UX defaults only: default settings or preferences, command behaviour in normal use, UI layout or behaviour, and shortcuts. Kernel or geometry result changes under solidcore/ are explicitly not changed defaults and pass. The diff inventory (git diff --name-status between the review base and head) lists 11 modified files, all under solidcore/crates/solidcore/src/. No file outside solidcore/ changes. The files are curve/plane_of.rs, error/query.rs, nurbs/crv_deviation.rs, nurbs/srf_deviation.rs, and seven files under query/. The PR changes internal error reporting. It replaces generic query_failed errors with typed QueryFailure causes and classes, and it keeps each site's status. The PR description states that no status moves and that Changes a default: no applies. The changes add public enum variants, which are kernel API surface, not a UX default. No preference, default setting, UI behaviour, or shortcut changes. The description's Changes a default: no agrees with the code. The check does not fail on this PR.

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 ad89d5a and 1e180ac.

Files selected for processing: 11

  • solidcore/crates/solidcore/src/curve/plane_of.rs
  • solidcore/crates/solidcore/src/error/query.rs
  • solidcore/crates/solidcore/src/nurbs/crv_deviation.rs
  • solidcore/crates/solidcore/src/nurbs/srf_deviation.rs
  • solidcore/crates/solidcore/src/query/contact.rs
  • solidcore/crates/solidcore/src/query/continuity.rs
  • solidcore/crates/solidcore/src/query/curve.rs
  • solidcore/crates/solidcore/src/query/deviation.rs
  • solidcore/crates/solidcore/src/query/distance_bound.rs
  • solidcore/crates/solidcore/src/query/face_surface.rs
  • solidcore/crates/solidcore/src/query/normal.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.

… named causes or reviewed defects (TE-O-13 part 1, tangency-labs#19846)

The 35 query phrase-cause sites of curve/plane_of.rs, nurbs/crv_deviation.rs,
nurbs/srf_deviation.rs, query/contact.rs, continuity.rs, curve.rs, deviation.rs,
distance_bound.rs, face_surface.rs and normal.rs become QueryFailure causes
(BoundOverflows, NoStationDropped, NoPatchInBox, FaceWithoutSurface,
SurfaceWithoutNurbs) or Defect { why }, each with the status of the phrase it
replaces; four unreachable sites are deleted by restructuring. Their lines leave
the query pin list.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@MarkusReichart MarkusReichart changed the title [WIP] Typed errors (TE-O-13, part 1 of 5): the deviation measures and small queries' failures become named causes or reviewed defects (#19846) Typed errors (TE-O-13, part 1 of 5): the deviation measures' and small queries' failures become named causes or reviewed defects (#19846) Nov 21, 2026
@MarkusReichart
MarkusReichart marked this pull request as ready for review November 21, 2026 18:14
@MarkusReichart
MarkusReichart requested a review from a team as a code owner November 21, 2026 18:14
@MarkusReichart
MarkusReichart requested review from bherbruck and removed request for a team November 21, 2026 18:14
@brett19 brett19 added the approved-for-ci Reviewed: run the full PR CI (build, tests, goldens, Clippy) label Nov 21, 2026
@bherbruck bherbruck added the ready to merge reviewed, every ask addressed; merge once CI is green label Nov 21, 2026
@bherbruck
bherbruck added this pull request to the merge queue Nov 21, 2026
Merged via the queue into tangency-labs:main with commit 0a505c6 Nov 21, 2026
179 of 183 checks passed
@MarkusReichart
MarkusReichart deleted the te-19846-queries branch November 29, 2026 21:51
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.

3 participants