Skip to content

sketch_rect_model: guard against off-plane model_origin (PR #56 follow-up)#58

Open
YLZha wants to merge 2 commits into
mainfrom
guard-and-examples
Open

sketch_rect_model: guard against off-plane model_origin (PR #56 follow-up)#58
YLZha wants to merge 2 commits into
mainfrom
guard-and-examples

Conversation

@YLZha

@YLZha YLZha commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements the helper guard both reviewers of #56 recommended. sketch_rect_model calls modelToSketchSpace to project model_origin onto the sketch plane, then silently dropped the out-of-plane component (sk_o.z) — so an off-plane origin created the body IN the plane, not at model_origin. This was the root cause of 3 of the 4 defects in #56 (back-panel-at-front).

The guard converts that silent wrong-position defect into an immediate, self-explaining error:

sk_o = sk.modelToSketchSpace(Point3D.create(ox, oy, oz))
if abs(sk_o.z) > 1e-4:
    raise ValueError(f"sketch_rect_model('{name}'): model_origin lies {sk_o.z:.4f} cm "
                     f"off the sketch plane — ... sketch on an off_plane at that offset ...")

A correct call (plane at the right offset) has sk_o.z ≈ 0 and is unaffected — only a wrong plane trips it.

Validation

  • cabinet (heavy multi-plane user, including the just-fixed back panel) builds clean — guard does not trip.
  • Broader example sweep pending — Fusion was contended by a concurrent session when I finished, so I couldn't sweep all examples locally. Relying on CI / a follow-up sweep to confirm no currently-green example trips it. By construction it should be safe: a green example has correct geometry → on-plane origins → no trip. Any trip indicates a real latent off-plane bug (which is exactly what the guard is meant to surface).

Risk note

This is a raise in a core helper used by ~every example. If a currently-green example trips, that's a latent position bug to fix (not a guard false-positive — correct calls can't trip). Do not merge until the example sweep is green (CI or manual).

🤖 Generated with Claude Code

YLZha and others added 2 commits May 31, 2026 23:55
modelToSketchSpace flattens the origin onto the sketch plane and the
out-of-plane component (sk_o.z) was silently dropped — so an off-plane
model_origin created the body IN the plane, not at model_origin. This
was the root cause of 3 of the 4 defects in PR #56 (back-panel-at-front).

Now raises an immediate, self-explaining ValueError when the origin lies
>1e-4 cm off the plane, converting a silent wrong-position defect (caught
late by check_interference) into an authoring-time error. A correct call
(plane at the right offset) has sk_o.z ~ 0 and is unaffected.

Validated: cabinet (heavy multi-plane user, incl. the just-fixed back
panel) builds clean — guard does not trip. Broader example sweep pending.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The guard from this branch caught it: KickFront_Sk/KickLeft_Sk sketched
on the bare xZ/yZ planes (y=0 / x=0) but their model_origin set the
recess (y/x = kick_inset). modelToSketchSpace flattened that onto the
case face → the kick was built FLUSH with the front/side instead of
recessed for toe clearance (reanchor only fixes the in-plane x/z dims).

Fix: sketch on off_planes at kick_inset (same pattern as PR #56's back
panels) so the body is correctly recessed and the origin lands on-plane.

Static sweep of all examples confirms sideboard is the ONLY example with
origin-mode off-plane bugs; the other flagged calls (wardrobe kick,
toy-box back, sideboard top) use anchored mode, which handles off-plane
origins correctly (wardrobe verified clean in Fusion).

NOT yet Fusion-validated — connection dropped mid-sweep. Needs: guard
clean + deps/connectivity pass + recessed kick still joins the case.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@YLZha

YLZha commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

Validation complete — guard is safe, found + fixed 1 real bug

Guard live-validated on 6 diverse examples (build clean, no trip)

cabinet, wardrobe, bench, crib, sideboard (after fix), bookshelf — covering bare-construction-plane and offset-plane usage, origin-mode and anchored-mode calls.

Static sweep of ALL examples for the bug pattern

A parser over every sketch_rect_model call (bare construction plane + nonzero out-of-plane origin) found sideboard is the only deps-passing example with the origin-mode off-plane bug. The other flagged calls (wardrobe kick, toy-box back, sideboard top) all use anchored mode, which builds from explicit model corners and handles off-plane origins correctly (wardrobe verified clean live).

The bug the guard caught → fixed in this PR

sideboard's kick was built flush instead of recessed. KickFront_Sk/KickLeft_Sk sketched on the bare xZ/yZ planes (y=0 / x=0) while their model_origin set the recess (kick_inset) — silently flattened to flush. The reanchor only fixes the in-plane x/z dims, so the defect survived (no interference → never caught). Fixed by sketching on off_planes at kick_inset (same pattern as #56).

Live-validated: sideboard now builds clean, guard doesn't trip, 0 real interference, and the recessed kick frame is properly connected (all 4 kick boards → Bottom + to each other). Doors/drawer remain separate clusters by design (hinged/sliding).

Ready to merge

The one example the guard tripped is fixed and validated; the static sweep + 6 live builds confirm no other regression. CI will cover the rest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant