Skip to content

solidcore: a curved Setback refuses a corner whose piece of a face holds another edge or loop (#13832 step 1) - #16327

Merged
bherbruck merged 3 commits into
tangency-labs:mainfrom
brett19:setback-piece-13832
Nov 14, 2026
Merged

bherbruck merged 3 commits into
tangency-labs:mainfrom
brett19:setback-piece-13832

Conversation

@brett19

@brett19 brett19 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

This PR makes the curved Setback (a corner of three or more constant rounds beside a cylinder, cone or sphere) refuse a corner when the piece it takes out of one of its faces holds another edge or an inner loop of that face. Today the fill is built over such a loop and the body is wrong. This is step 1 of the plan in #16232 (design and inventory for #13832): item (d) condition 2 of the brief.

Labels: PROVEN = asserted in code (a test, a certificate check, a closed form a test checks). ARGUED = reasoning or code reading. MEASURED = observed by running it.

The defect (MEASURED on main 2654478)

issue_2343's D prism (R 10, flat 8, H 20) with a small bore (R 0.15) through the top at (6.7, 3.0). The chord, upright and arc at V = (8, 6, 20) are rounded 1, 1.5 and 2, asked 7.5 at V. The bore lies wholly inside the corner's piece of the top, 0.08 clear of the spring curve, so condition 1 (#14096) passes. Main builds the corner and check_brep level 2 is clean, but the bore's top circle is gone and its wall meets a fill patch at 1.57 rad: the fill covers the hole. The twin with the bore just outside the piece, at (6.3, 2.7), builds correctly.

What changes

  • blend_setback::FacePlane (pub(crate), new face_plane.rs): the face's rational parameter plane, moved out of spring.rs with the same operations in the same order (frame, to_plane, partials). New: net maps a rational 3-D net on the face to a rational net in the plane. That is degree n on a plane or sphere and 2n on a cylinder or cone (t = u2 / (rho(u3) + u1), h = u3). point maps a point.
  • blend_corner::piece (pub(crate), new): CornerPiece, the piece's closed boundary as rational Bezier sides with positive weights, each held in 3-D and in the plane. The sides are: the blended edge after the face from V to its setback point, that blend's end-section trace on the face, the spring curve's two halves, the end-section trace of the blend before the face, and its edge back to V. Also new: Decision { Clear, Blocked, Undecided }, where Undecided refuses as Blocked does.
  • End-section traces (section_trace): the plane square to the edge at the setback point, cut with the face. It is the conic through both ends, tangent there to the section, with its weight from the shoulder point where the chord-midpoint-to-tangent-crossing line meets the quadric. That is exact on any quadric. It falls back to a straight segment where each end lies within 1e-3 tol of the other's tangent line (a plane, or a ruling).
  • SetbackTooLongWhy::PieceHoldsEdge: a new public variant (#[non_exhaustive] enum; solidcore-ops maps SetbackTooLong { .. } without reading why, so no app change). Its size comes from springs_refusal's search, now largest_clear_scale, generic over the check. Trials check condition 1 and condition 2 together, so the named size passes both. The SpringLeaves refusal keeps its exact messages.
  • Springs::Holds joins Springs. Condition 2 also runs after grow_curved's growth, where a hold refuses as a spring leaving does.
  • fillet_geom::p2::set_back_params (the walk's parameters; set_back_frame now calls it, same numbers) and on_face::bezier_spans (bezier_pieces with knot spans; bezier_pieces returns the same).

Certificate (definitions-and-certificates §7 checklist)

For each other edge of the face (not at V, a seam once):

  1. (a) Bounded, not sampled. Every side except the spring halves (condition 1 checks those with the same gap), and every straight piece closing a gap between one side's end and the next side's start (a blended edge's tolerance lets its restricted curve end up to tol + its own tol off; the closing piece is the one winding uses, and its gap is widened by its length), keeps clear of the edge by more than tol + edge tol + the side's construction rounding. Edges at the vertex are left out, as condition 1 leaves them out: at a Setback corner the face meets the vertex only between its two blended edges, which bound the piece themselves (its sides along them stop at their setbacks, and (a) checks the face's other edges against those sides); a seam ending at the vertex or a third loop edge there is not expected at a Setback corner and is not checked (ARGUED). This is decided on control-point hulls with on_face::clear_of, the test condition 1 uses. PROVEN by the clear_of certificate in code. The other edge is restricted to its own interval (restrict on its knot spans, endpoint-checked; otherwise its whole curve, which is conservative). Using the whole curve made a split circle's other piece count as near V: measured on the sphere and cone corners and fixed.
  2. (b) One point, exact given (a). The edge is connected and meets no side, so it lies wholly inside or wholly outside. Its winding number in FacePlane about any one of its points decides. The winding number is a sum of turning angles over boundary pieces, each shown on its control points to lie in an open half-plane through the point (margins counted). The sum must be within a quarter turn of a whole number. The check is PROVEN in code. That one point suffices is ARGUED (topology given (a)). That the map is injective on the face away from a sphere's pole or a quadric's opposite line is ARGUED. An edge running through that line maps to components that reach infinity, where the winding is 0, so one point still decides (ARGUED). The edge curves lie on the face only to their tolerance, so the plane image of a curve near the face stands for its projection's image (ARGUED; the 3-D clearance exceeds the sum of the tolerances).
  3. Rounding. Higham gamma_k at the corner's scale: the plane map's terms (3-D coordinates, frame origin, radius, slope) times the plane points' size over the least plane weight per 3-D weight, with the halvings' operations. The construction rounding of each side is added to its gap. The bounds are in code; that they cover every operation is ARGUED (counted generously: 32 + 4(n+1) + DEPTH·degree ops). The section trace's shoulder weight is charged 64 ops (ARGUED).
  4. NaN refuses. Every acceptance comparison is written !(x > y) or as a positive test, and a non-finite or non-positive weight fails push/net (PROVEN by the unit test with a NaN side).
  5. No tolerance widened, no expectation changed. No existing assertion, expected value, golden or bound is changed; one test helper is refactored (see Test change below), and the existing curved tests run unchanged (see Validation).
  6. The refusal names the size that fits. The size is the largest common scale of the asked setbacks at which both conditions hold, to the corner's tolerance (bisection on thousandths, then at most REFINE halvings). The named size is always one the check cleared (PROVEN by construction: the search returns only a cleared scale). The search assumes a scale clear stays clear at every smaller one (design Q3; ARGUED, not proved); if that fails, the size named can only be smaller than need be.
  7. Bounded work. No recursion. (a) is clear_of (explicit stack, on_face::DEPTH = 40 halvings, PAIRS = 4096 pairs per call). The winding number uses the same two bounds on its own stack. Cancel is polled in both loops. Deviation from the brief: the brief said "at most GRAPH_DEPTH" (6). That is the fill certificate's depth and far too shallow for clearance at the tolerance scale (a 5-long side would need about 23 halvings to separate at 1e-6). We use the bounds condition 1 already uses, so the work stays bounded and the depth is fit for purpose.
  8. Real-defect test. The bore inside the piece is refused (fails on main, where it builds). The unit tests also cover a loop across the boundary or within the gap (Undecided), a loop 1e-3 inside the boundary (Blocked) and one 1e-3 outside (Clear).

Edges at the vertex are left out of both (a) and (b), as condition 1 leaves them out. At a Setback corner the face meets the vertex only between its two blended edges, which bound the piece themselves; the piece's sides along them stop at their setbacks, and (a) checks the face's other edges against those sides. A seam ending at the vertex, or a third edge of the face's loop there, is not expected at a Setback corner and is not checked (ARGUED).

Tests

  • a_bore_inside_the_corners_piece_of_the_top_is_refused_naming_the_setback_that_leaves_it_out (issue_2343_curved_setback.rs). Asked 7.5: refused SetbackTooLong { why: PieceHoldsEdge } at V. The named size leaves the bore outside the piece and clear, by the piece's closed form (the top is a plane, so the spring is the parabola). It lies within 1e-3 below the closed-form limit (MEASURED: named 4.56085, limit 4.56128). Asked that size, the corner builds, passes graded and kept_definitions, and keeps the bore's top circle. The twin with the bore outside builds, graded the same way. Fails on main (PROVEN: main builds the inside case, MEASURED above).
  • Unit tests: piece::tests (inside, outside, across, within gap, an edge crossing the gap between two sides when a blended edge's tolerance is 1e-4 and the edge's 1e-7 (Undecided), reversed boundary, NaN side, span restriction, a cylinder's section trace on the cylinder and in the section plane to 1e-12), face_plane::tests (net and point against to_plane on all four kinds).

Test change: refactor only, no assertion changed. d_prism_eight_case now delegates to d_prism_eight_bored, which takes the bore centre; existing callers pass (0, 0) and the same names, so they build the same body and assert the same things.

Validation

  • cargo test --profile goldens -p solidcore --test issue_2343_curved_setback: 15 passed, 2 ignored (the slow growth tests, run separately below). MEASURED on server2.
  • Gate on head 33ba30c (server2; --core-only re-run after the closing-piece fix, --craft-only --no-tests from 5e712e0, unchanged public API since), case 2 (a new public variant): sc-gate.sh --changed chose --core-only (fmt, script tests, clippy, panic sites, wasm, nextest 7978 tests, doctests, solids, rig, 25 touched blend golden units): all PASS. Then --craft-only --no-tests (fmt, assets, layers, shared, clippy, wasm): all PASS. MEASURED.
  • The two slow ignored curved tests, which run through the growth and the post-growth condition-2 check (d_prism_asked_too_short_names_the_setback_that_builds, countersink_corner_is_a_setback_no_more_concave_than_its_cone): last passed on head 33ba30c (server2), 560 s. MEASURED.
  • No golden, test input or expectation is changed. The curved Setback is off by default and missing from the rig's fixes, so goldens and the rig never reach it (design R3). Only the touched blend golden units ran, not all goldens.

The curved Setback stays behind fillet_setback_beside_curved_faces (off by default; on in SolidCraft's preset). Retiring the flag is step 4, a separate PR. Results: a refusal replaces a wrong body, so this stays a draft until an independent review is done.

Objections to the shape (types, the three-valued decision, the new public variant, the depth bound) are welcome here or on #16232.

Part of #13832. Design: #16232.

Changes a default: no

🤖 Generated with Claude Code

https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU

Summary by CodeRabbit

  • New Features
    • Added checks to prevent curved-face setbacks from removing regions that contain or may contain another edge or loop. When this condition limits a setback, the result identifies the reason and reports the largest fitting scale.
    • Added support for tracking Bézier knot-span intervals and evaluating corner-piece clearance.
  • Bug Fixes
    • Setbacks now refuse cases where the removed corner region cannot be proven clear of other face edges.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The change adds face parameter mappings and corner-piece geometry checks to curved setback processing. Setback growth now treats blocked or undecidable face pieces as a refusal condition and searches for the largest clear setback scale. Tests cover bore placement inside and outside a corner piece.

Changes: Curved setback face-piece checks

Layer / File(s) Summary
Face mappings and Bézier span inputs
solidcore/crates/solidcore/src/blend/blend_corner/on_face.rs, solidcore/crates/solidcore/src/blend/blend_corner.rs, solidcore/crates/solidcore/src/blend/blend_setback.rs, solidcore/crates/solidcore/src/blend/blend_setback/face_plane.rs, solidcore/crates/solidcore/src/blend/blend_setback/spring.rs
bezier_spans returns Bézier pieces with their parameter intervals. FacePlane provides point, tangent, net, and partial mappings for planes, spheres, cylinders, and cones. Spring construction uses these mappings.
Corner-piece construction and classification
solidcore/crates/solidcore/src/blend/blend_corner.rs, solidcore/crates/solidcore/src/blend/blend_corner/piece.rs
CornerPiece stores rational Bézier sides and classifies other edges as clear, blocked, or undecided using clearance and bounded winding checks. Span restriction and section-trace helpers construct boundary geometry.
Setback checks and scale selection
solidcore/crates/solidcore/src/blend/blend_corner/setback.rs, solidcore/crates/solidcore/src/blend/blend_refusal.rs, solidcore/crates/solidcore/src/blend/fillet_geom/p2.rs, solidcore/crates/solidcore/tests/issue_2343_curved_setback.rs
Curved setback growth checks whether a face piece holds another edge or loop. Blocked or undecidable results cause refusal, and a shared search selects the largest clear scale. The regression test covers bores inside and outside the corner piece.

Estimated code review effort: 4 (Complex) | ~60 minutes

Security architecture risk: Minimal · up to 33ba3

This is a conservative geometry-validation change. The reviewed changes do not establish added security exposure or weaker failure containment.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the main change: a curved Setback now refuses a corner when the piece it removes from a face holds another edge or loop. It matches the raw summary, which adds the piece check, the Pie…
Description check Passed The description follows the template well. It has a Change section that explains the problem and behavior in plain terms, and it links the design issue (#16232) and parent issue (#13832). It includes …
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 passes. The PR changes no UX default. Evidence: - The changed-file inventory (git diff --name-status between the review base and head) lists 10 files, all under `solidcore/crates/solidcore…
Full details: Title check

Explanation

The title names the main change: a curved Setback now refuses a corner when the piece it removes from a face holds another edge or loop. It matches the raw summary, which adds the piece check, the PieceHoldsEdge refusal, and the Clear/Blocked/Undecided decision. The '(#13832 step 1)' suffix is a tracking reference and does not hurt clarity. The title is 109 characters, slightly long for a short title, but it is specific.

Full details: Description check

Explanation

The description follows the template well. It has a Change section that explains the problem and behavior in plain terms, and it links the design issue (#16232) and parent issue (#13832). It includes the required 'Changes a default: no' line. It includes a 'Test change' line that explains the refactor of d_prism_eight_case, as the template requires for kernel test-helper edits. It has a Validation section with commands, measured values, and results. The Screenshots section is missing. The template asks for evidence of observable behavior, and this is a kernel change that refuses a setback, so a screenshot or before/after evidence of the refused corner would strengthen it. The Integration status section is also missing, and the template asks for it. The description is also dense, uses internal jargon such as 'condition 1', 'winding number', and 'PROVEN/ARGUED/MEASURED' labels, and it refers to items outside the PR, such as '#16232 (item (d) condition 2 of the brief)', which a newcomer may not follow.

Resolution

Consider these additions before merge: (1) add the Integration status section that the template requires, recording the upstream commit and PR status checked, any conflicts resolved, and validation after integration; (2) add before/after evidence for the refused corner, such as the bore's top circle on main and on this branch, or state why screenshots cannot show the behavior; (3) define the internal terms (condition 1, condition 2, winding number) on first use so a new contributor can follow the Change section.

Full details: Existing Defaults Unchanged

Explanation

The check passes. The PR changes no UX default. Evidence: - The changed-file inventory (git diff --name-status between the review base and head) lists 10 files, all under solidcore/crates/solidcore/. No settings, preferences, UI, CLI, shortcut, or configuration files changed. - The behavior change is a geometry result. A curved Setback corner whose face piece holds another edge or loop is now refused. The check states that a changed kernel or geometry result, including anything under solidcore/, is not a changed default. - The curved Setback stays behind fillet_setback_beside_curved_faces, which the PR description says is off by default. The PR does not change that flag's value. - The new SetbackTooLongWhy::PieceHoldsEdge variant is additive. The PR description says solidcore-ops matches SetbackTooLong { .. } without reading why, so no app-visible output changes. - The PR description says Changes a default: no. The code changes no UX default, so the mismatch condition does not apply.

Finishing Touches

Generate unit tests (beta)

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

Warning

Review coverage is incomplete: 8 files could not be fully reviewed. Findings from completed review steps are included; see review info for details.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a7468ec and 33ba30c.

Files selected for processing: 10

  • solidcore/crates/solidcore/src/blend/blend_corner.rs
  • solidcore/crates/solidcore/src/blend/blend_corner/on_face.rs
  • solidcore/crates/solidcore/src/blend/blend_corner/piece.rs
  • solidcore/crates/solidcore/src/blend/blend_corner/setback.rs
  • solidcore/crates/solidcore/src/blend/blend_refusal.rs
  • solidcore/crates/solidcore/src/blend/blend_setback.rs
  • solidcore/crates/solidcore/src/blend/blend_setback/face_plane.rs
  • solidcore/crates/solidcore/src/blend/blend_setback/spring.rs
  • solidcore/crates/solidcore/src/blend/fillet_geom/p2.rs
  • solidcore/crates/solidcore/tests/issue_2343_curved_setback.rs
Files not reviewed due to moderation or processing errors: 8

  • solidcore/crates/solidcore/src/blend/blend_corner/on_face.rs
  • solidcore/crates/solidcore/src/blend/blend_setback.rs
  • solidcore/crates/solidcore/src/blend/blend_setback/face_plane.rs
  • solidcore/crates/solidcore/src/blend/blend_setback/spring.rs
  • solidcore/crates/solidcore/src/blend/blend_corner.rs
  • solidcore/crates/solidcore/src/blend/blend_corner/piece.rs
  • solidcore/crates/solidcore/src/blend/fillet_geom/p2.rs
  • solidcore/crates/solidcore/src/blend/blend_corner/setback.rs

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

brett19 and others added 2 commits November 14, 2026 00:31
…ch face and (d) condition 2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU
…lds another edge or loop (tangency-labs#13832 step 1)

Condition 2 of tangency-labs#2343 (d): the piece a Setback beside a curved face takes
out of each face, bounded by its two blended edges to their setbacks, the
end sections' traces and the spring curve, must hold no other edge or loop
of the face. Condition 1 only checked the spring curve, so a bore wholly
inside the piece was covered by the fill.

- FacePlane: the face's rational parameter plane, moved out of spring.rs
  unchanged, with the map of a rational net into it.
- CornerPiece and a three-valued Clear/Blocked/Undecided decision: the
  boundary is proved clear of each other edge on control-point hulls, then
  a winding number at one point of the edge decides inside or outside.
- SetbackTooLongWhy::PieceHoldsEdge, naming the largest setback at which
  both conditions hold, from springs_refusal's search made generic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU
@brett19
brett19 force-pushed the setback-piece-13832 branch from f98cd0e to 5e712e0 Compare November 13, 2026 23:31
…s too (tangency-labs#13832 step 1)

winding closes each gap between one side's end and the next side's start
with a straight piece. A blended edge's tolerance lets its restricted curve
end that far off, so an edge of a smaller tolerance could cross the closing
piece unchecked and lie partly inside. Certificate (a) now checks each
closing piece with clear_of, the gap widened by its length. Also states why
edges at the vertex are left out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdcgEtwSrdwZxqTQp5MfnU
@brett19
brett19 marked this pull request as ready for review November 14, 2026 01:23
@brett19
brett19 requested a review from a team as a code owner November 14, 2026 01:23
@brett19
brett19 requested review from bherbruck and removed request for a team November 14, 2026 01:23
@bherbruck bherbruck added 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 labels Nov 14, 2026
@bherbruck
bherbruck added this pull request to the merge queue Nov 14, 2026
Merged via the queue into tangency-labs:main with commit c6adb44 Nov 14, 2026
151 of 155 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) 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