diff --git a/design-docs/stable-refs-design.md b/design-docs/stable-refs-design.md index 590c83b3..d9301155 100644 --- a/design-docs/stable-refs-design.md +++ b/design-docs/stable-refs-design.md @@ -156,7 +156,7 @@ The kernel records one `TopoDelta` per node: witnesses with event `preserved`/`m | Extrude-like creators | extrude, revolve, sweep, loft, twisted sweep | roles (`extrusion.*`, `revolution.*`, `loft.*`, `sweep.*` start/end/side); side faces `Generated` from profile edges | anchor by role; sides by source edge (derived) | **[T]** end caps of all four through a union and a translate, extrude cap through a fillet; loft side correspondence is kernel-matched, not named **[R]** (playbook) | | Booleans | cut, union, intersect, boolean list | `modified` fragments, `preserved`, `deleted`; merged faces get one entry per parent | `ok` / `split` (several fragments) / `merged` (fragment also descends from a foreign face) / `lost(deleted)` | **[T]** all four outcomes | | Blends | fillet, chamfer | trimmed faces `modified`; blended edges `deleted` + patch `generated` (role `fillet.patch`) | face: `ok`; edge: `lost(deleted)` in identity, patch in derived | **[T]** face and edge->patch | -| Shell | shell | removed face -> its rim `modified` (`shell.closing_descendant`); offset faces `generated`; **kept faces: no preserved witness** | opened face: `ok` (the rim); kept face: `lost(replaced)` | **[T]**; fix in 7.2 | +| Shell | shell | removed face -> its rim `modified` (`shell.closing_descendant`); offset faces `generated`; kept faces `preserved` (+ their offset face generated) | opened face: `ok` (the rim); kept face: `ok` | **[T]** (kept faces fixed, 7.2) | | Rigid copies | translate, rotate, mirror, linear/radial pattern | every face `modified`/continuation; a pattern is one translate/rotate node per instance | `ok`; an instance is addressed by its own node | **[T]** translate, rotate, mirror, linear and radial pattern | | Affine / offset / draft | transform_rsolid (rigid and affine), scale (uniform and per axis), offset_rsolid, draft | face and edge witnesses from the retained OCCT history (`modification_delta`): `modified`/continuation; an offset or drafted face (OCCT: generated) continues its source face | `ok` | **[T]** every op, `test_history_through_operations_that_had_none`, the draft test, `test_modification_delta.cpp` (was `no delta` before this branch) | | Helical sweep | helical_sweep_rsolid | in a session it records helix + face + sweep nodes; the sweep is tracked | anchor by `sweep.*` roles | **[T]** | @@ -257,7 +257,7 @@ Probe: box 40x20x10 with the top face tagged by kwarg (`kw.top`) and by `apply_t | union (coplanar) | dies **[R]** | survives **[R]** | **merged** | merge not visible to tags | | intersect | dies | survives | ok | plain tag gate | | fillet / chamfer | dies | **dies** | ok | face-channel gap in tag projection | -| shell, face kept | dies | dies | **lost(replaced)** | kernel: no preserved witness for kept faces | +| shell, face kept | dies | survives (since 7.2) | ok (was lost/replaced) | -- (fixed, 7.2) | | shell, face removed | dies | survives (on the rim) | ok (the rim) | -- | | translate / rotate / mirror | dies | **dies** | ok | tag projection ignores continuation witnesses | | linear pattern (instance 3) / radial pattern (instance 2) | dies | dies | ok | same | @@ -317,15 +317,23 @@ O(hops). Budget [I]: < 1 ms per reference for 200-node histories, memoised per ( recording time (the deltas are recorded already). Resolution is already negligible next to modelling (0.06 % of build time at N = 150). -### 7.2 The shell kept-face gap needs an owner decision -`query_history` (`src/cpp/src/semantic/tracking_core.cpp`) emits `preserved` only when an input has neither -`Modified` nor `Generated` images. A shell's kept outer face is unchanged *and* generates its offset face, so it gets -only the `generated` witness. Emitting `preserved` as well when the input is still in the result is a one-line fix, -but it changes the Python-parity goldens (`tests/cpp/semantic/test_tracking_golden.cpp`: extrude/revolve profile -edges, shell, loft/sweep) and an explicit assertion (`test_tracking_behaviour.cpp:386`, -`count_role(.., "shell.body_face") == 0`) **[R]** (tried and reverted on this branch). Options: (a) accept the new -witnesses and regenerate goldens (changes tag projection: profile edges and kept shell faces gain continuation), or -(b) add a separate `survivors` list to `TopoDelta` read only by the resolver (no projection change). +### 7.2 The shell kept-face gap: option (a), implemented [T] + +`query_history` (`src/cpp/src/semantic/tracking_core.cpp`) emitted `preserved` only when an input had neither +`Modified` nor `Generated` images, so a shell's kept outer face (unchanged *and* the seed of its offset face) had +only the `generated` witness. It now also emits `preserved` when the input is still in the result. Every changed +expectation was reviewed: + +| Expectation | Before | After | Why | +|---|---|---|---| +| golden `shell` (C++ tracking) | 0 preserved | 5 kept faces + 4 rim edges preserved, 5 `shell.body_face` roles | the kept faces and the outer rim edges are IsSame in the result | +| golden `extrude_rect`, `extrude_circle`, `loft`, `loft_ruled` | profile edges: generated only | also preserved | the start cap of a prism / loft is bounded by the very profile edges | +| `test_tracking_behaviour.cpp` loft toward a point | 4 entries | 8 | the four base edges stay as the cap boundary | +| `test_tracking_behaviour.cpp` shell roles | `shell.body_face == 0` ("every kept face was re-created": wrong) | 5 | as above | +| goldens `ops_features_shell`, `ops_features_tag_projection` (Python port) | kept faces untagged | `face.shell.body_face` on the 5 kept faces | the role is now proven | +| golden `ops_features_blend_failures.shell_role` | "requires at least one kernel-proven result" | no failure | same | +| `test_operation_output_roles` | asserted `body_faces_tag` raised | asserts it tags the 5 kept faces | same | +| audit `shell_kept_face` | lost(replaced) | ok; the kwarg tag now survives too | same | ## 8. Risks and non-goals - OCCT history quality bounds everything; a tracker that omits a witness makes a reference `lost`, which is the diff --git a/docs/skill/references/docs/api/shell_rsolid.md b/docs/skill/references/docs/api/shell_rsolid.md index 9fb98f50..94ee64c7 100644 --- a/docs/skill/references/docs/api/shell_rsolid.md +++ b/docs/skill/references/docs/api/shell_rsolid.md @@ -15,3 +15,10 @@ def shell_rsolid(solid, faces_to_remove, thickness, *, result_tag=None, body_fac ## Description Shell a solid, with optional kernel-role-based face tags. + +The kernel roles are ``shell.body_face`` (a face of the input that stays in +the result), ``shell.offset_face`` (the inner face it generates), +``shell.closing_descendant`` (what is left of a removed face: the rim) and +``shell.wall`` (the edges that become the walls of an opening). +``body_faces_tag``, ``offset_faces_tag``, ``closing_faces_tag`` and +``wall_edges_tag`` tag exactly the entities with those roles. diff --git a/examples/SDK_DEFECTS.md b/examples/SDK_DEFECTS.md index 0c548bbf..5fe0d04a 100644 --- a/examples/SDK_DEFECTS.md +++ b/examples/SDK_DEFECTS.md @@ -347,14 +347,15 @@ that surfaced it is in brackets. - **Status:** open (comment only). - **Fix direction:** correct the comment; pin restore of deltas with a test, since stable references rely on it. -## 23. A shell's kept faces have no successor witness [stable-refs research] +## 23. A shell's kept faces had no successor witness [stable-refs research] -- **Symptom:** after `shell_rsolid(box, [bottom], t)`, the untouched top face has only a `generated` witness (its - offset face); history cannot say the top face is still there. -- **Root cause:** `tracking::query_history` emits `preserved` only when an input has neither `Modified` nor +- **Symptom:** after `shell_rsolid(box, [bottom], t)`, the untouched top face had only a `generated` witness (its + offset face); history could not say the top face was still there, and `body_faces_tag` always raised. +- **Root cause:** `tracking::query_history` emitted `preserved` only when an input had neither `Modified` nor `Generated` images; a kept shell face generates its offset face. -- **Status:** open. The one-line fix changes the Python-parity goldens and an explicit assertion - (`test_tracking_behaviour.cpp` `shell.body_face == 0`), so it needs an owner decision (design section 7.2). +- **Status:** fixed (owner decision, option a): `preserved` is also emitted when the input is still in the result. + Goldens and assertions reviewed one by one (design 7.2): shell kept faces and rim edges, and the profile edges + that bound an extrude / loft start cap, gain a preserved witness. ## 24. `transform_rsolid`, `offset_rsolid`, draft and scale recorded no topology delta [stable-refs research] diff --git a/src/cpp/src/semantic/tracking_core.cpp b/src/cpp/src/semantic/tracking_core.cpp index 517af937..33e9c935 100644 --- a/src/cpp/src/semantic/tracking_core.cpp +++ b/src/cpp/src/semantic/tracking_core.cpp @@ -173,6 +173,12 @@ void query_history(HistorySource& history, const TopTools_IndexedMapOfShape& inp emit(input_id, TopoEvent::Preserved, spec.kind, "continuation", pick_role(spec.preserved_role, spec.result_role)); continue; } + // Untouched and still in the result, while also the seed of new entities (a shell's kept face generates its + // offset face, an extrude's profile edge its side face): it stays, as well as what it generated. Without this + // witness the entity has no successor at all and a reference to it is lost although it is still there. + if (!deleted && (modified.empty() || modified_is_self) && !generated.empty() && spec.result != nullptr && + spec.result->contains(sub)) + emit(input_id, TopoEvent::Preserved, spec.kind, "continuation", pick_role(spec.preserved_role, spec.result_role)); if (!modified.empty() && !modified_is_self) { for (const TopoDS_Shape& shape : modified) { diff --git a/src/cpp/tests/cpp/semantic/test_tracking_behaviour.cpp b/src/cpp/tests/cpp/semantic/test_tracking_behaviour.cpp index 200a6e80..56bcf5c9 100644 --- a/src/cpp/tests/cpp/semantic/test_tracking_behaviour.cpp +++ b/src/cpp/tests/cpp/semantic/test_tracking_behaviour.cpp @@ -299,7 +299,8 @@ TEST_CASE("loft toward a point still finds its one cap") { CHECK(count_role(up.delta, "loft.side") == 4); CHECK(count_role(up.delta, "loft.start") == 1); CHECK(count_role(up.delta, "loft.end") == 0); - CHECK(up.delta.entries.size() == 4); + // Four generated side faces, and the four base edges, which stay in the result as the cap's boundary. + CHECK(up.delta.entries.size() == 8); const TrackedResult down = tracked_loft({tip, base}); CHECK(count_role(down.delta, "loft.start") == 0); @@ -383,7 +384,9 @@ TEST_CASE("shell roles: body, offset, closing descendants and walls") { CHECK(count_role(tracked.delta, "shell.offset_face") == 5); CHECK(count_role(tracked.delta, "shell.closing_descendant") == 1); CHECK(count_role(tracked.delta, "shell.wall") == 4); - CHECK(count_role(tracked.delta, "shell.body_face") == 0); // every kept face was re-created + // The five kept faces are still the input's faces (IsSame in the result) while each also generates its offset + // face: they are preserved, with their body role, as well as the seeds of the offset faces. + CHECK(count_role(tracked.delta, "shell.body_face") == 5); } // --------------------------------------------------------------------------- diff --git a/src/cpp/tests/cpp/semantic/tracking_golden.hpp b/src/cpp/tests/cpp/semantic/tracking_golden.hpp index 9d0a1200..9d36eaed 100644 --- a/src/cpp/tests/cpp/semantic/tracking_golden.hpp +++ b/src/cpp/tests/cpp/semantic/tracking_golden.hpp @@ -1,4 +1,8 @@ // Generated by tracking_golden_record.py from the reference SDK; do not edit. +// Deliberate divergence (2026-11, owner decision on the shell kept-face gap): extrude_rect, extrude_circle, shell, +// loft and loft_ruled add a `preserved` witness for every input entity that stays in the result while also +// generating something (kept shell faces and the rim edges; profile edges that bound the start cap). The +// reference SDK emitted only the generated witness; regenerating from it would undo the decision. #pragma once namespace scad::tracking_golden { @@ -113,17 +117,25 @@ E modified|body|continuation|-|False|FACE@(0.0000,5.0000,5.0000)->FACE@(0.0000,5 E modified|body|continuation|-|False|FACE@(5.0000,0.0000,5.0000)->FACE@(-5.0000,0.0000,5.0000) )GOLDEN"}, {"extrude_rect", - R"GOLDEN(counts preserved=0 modified=0 generated=4 deleted=0 section_edges=0 entries=4 roles=6 delta_entries=6 + R"GOLDEN(counts preserved=4 modified=0 generated=4 deleted=0 section_edges=0 entries=8 roles=6 delta_entries=10 +D (-2.5000,0.0000,0.0000)|EDGE|ev=preserved|or=profile|rr=|w=1 D (-2.5000,0.0000,5.0000)|FACE|ev=generated|or=profile|rr=extrusion.side|w=2 +D (0.0000,-1.5000,0.0000)|EDGE|ev=preserved|or=profile|rr=|w=1 D (0.0000,-1.5000,5.0000)|FACE|ev=generated|or=profile|rr=extrusion.side|w=2 D (0.0000,0.0000,0.0000)|FACE|ev=|or=|rr=extrusion.start|w=1 D (0.0000,0.0000,10.0000)|FACE|ev=|or=|rr=extrusion.end|w=1 +D (0.0000,1.5000,0.0000)|EDGE|ev=preserved|or=profile|rr=|w=1 D (0.0000,1.5000,5.0000)|FACE|ev=generated|or=profile|rr=extrusion.side|w=2 +D (2.5000,0.0000,0.0000)|EDGE|ev=preserved|or=profile|rr=|w=1 D (2.5000,0.0000,5.0000)|FACE|ev=generated|or=profile|rr=extrusion.side|w=2 E generated|profile|boundary|extrusion.side|True|EDGE@(-2.5000,0.0000,0.0000)->FACE@(-2.5000,0.0000,5.0000) E generated|profile|boundary|extrusion.side|True|EDGE@(0.0000,-1.5000,0.0000)->FACE@(0.0000,-1.5000,5.0000) E generated|profile|boundary|extrusion.side|True|EDGE@(0.0000,1.5000,0.0000)->FACE@(0.0000,1.5000,5.0000) E generated|profile|boundary|extrusion.side|True|EDGE@(2.5000,0.0000,0.0000)->FACE@(2.5000,0.0000,5.0000) +E preserved|profile|continuation|-|True|EDGE@(-2.5000,0.0000,0.0000)->EDGE@(-2.5000,0.0000,0.0000) +E preserved|profile|continuation|-|True|EDGE@(0.0000,-1.5000,0.0000)->EDGE@(0.0000,-1.5000,0.0000) +E preserved|profile|continuation|-|True|EDGE@(0.0000,1.5000,0.0000)->EDGE@(0.0000,1.5000,0.0000) +E preserved|profile|continuation|-|True|EDGE@(2.5000,0.0000,0.0000)->EDGE@(2.5000,0.0000,0.0000) R extrusion.end|profile|LastShape|FACE@(0.0000,0.0000,10.0000)|- R extrusion.side|profile|Generated|FACE@(-2.5000,0.0000,5.0000)|EDGE@(-2.5000,0.0000,0.0000) R extrusion.side|profile|Generated|FACE@(0.0000,-1.5000,5.0000)|EDGE@(0.0000,-1.5000,0.0000) @@ -132,11 +144,13 @@ R extrusion.side|profile|Generated|FACE@(2.5000,0.0000,5.0000)|EDGE@(2.5000,0.00 R extrusion.start|profile|FirstShape|FACE@(0.0000,0.0000,0.0000)|- )GOLDEN"}, {"extrude_circle", - R"GOLDEN(counts preserved=0 modified=0 generated=1 deleted=0 section_edges=0 entries=1 roles=3 delta_entries=3 + R"GOLDEN(counts preserved=1 modified=0 generated=1 deleted=0 section_edges=0 entries=2 roles=3 delta_entries=4 +D (0.0000,0.0000,0.0000)|EDGE|ev=preserved|or=profile|rr=|w=1 D (0.0000,0.0000,0.0000)|FACE|ev=|or=|rr=extrusion.start|w=1 D (0.0000,0.0000,1.5000)|FACE|ev=generated|or=profile|rr=extrusion.side|w=2 D (0.0000,0.0000,3.0000)|FACE|ev=|or=|rr=extrusion.end|w=1 E generated|profile|boundary|extrusion.side|True|EDGE@(0.0000,0.0000,0.0000)->FACE@(0.0000,0.0000,1.5000) +E preserved|profile|continuation|-|True|EDGE@(0.0000,0.0000,0.0000)->EDGE@(0.0000,0.0000,0.0000) R extrusion.end|profile|LastShape|FACE@(0.0000,0.0000,3.0000)|- R extrusion.side|profile|Generated|FACE@(0.0000,0.0000,1.5000)|EDGE@(0.0000,0.0000,0.0000) R extrusion.start|profile|FirstShape|FACE@(0.0000,0.0000,0.0000)|- @@ -321,17 +335,26 @@ R fillet.patch|contour_edge|Generated|FACE@(4.6366,0.0000,9.6366)|EDGE@(5.0000,0 R fillet.patch|contour_edge|Generated|FACE@(4.6366,4.6366,5.0000)|EDGE@(5.0000,5.0000,5.0000) )GOLDEN"}, {"shell", - R"GOLDEN(counts preserved=0 modified=1 generated=9 deleted=0 section_edges=0 entries=10 roles=10 delta_entries=10 + R"GOLDEN(counts preserved=9 modified=1 generated=9 deleted=0 section_edges=0 entries=19 roles=15 delta_entries=19 D (-4.0000,0.0000,10.0000)|EDGE|ev=generated|or=closing_boundary|rr=shell.wall|w=2 D (-4.0000,0.0000,5.5000)|FACE|ev=generated|or=body|rr=shell.offset_face|w=2 +D (-5.0000,0.0000,10.0000)|EDGE|ev=preserved|or=closing_boundary|rr=|w=1 +D (-5.0000,0.0000,5.0000)|FACE|ev=preserved|or=body|rr=shell.body_face|w=2 D (0.0000,-4.0000,10.0000)|EDGE|ev=generated|or=closing_boundary|rr=shell.wall|w=2 D (0.0000,-4.0000,5.5000)|FACE|ev=generated|or=body|rr=shell.offset_face|w=2 +D (0.0000,-5.0000,10.0000)|EDGE|ev=preserved|or=closing_boundary|rr=|w=1 +D (0.0000,-5.0000,5.0000)|FACE|ev=preserved|or=body|rr=shell.body_face|w=2 +D (0.0000,0.0000,0.0000)|FACE|ev=preserved|or=body|rr=shell.body_face|w=2 D (0.0000,0.0000,1.0000)|FACE|ev=generated|or=body|rr=shell.offset_face|w=2 D (0.0000,0.0000,10.0000)|FACE|ev=modified|or=closing_face|rr=shell.closing_descendant|w=2 D (0.0000,4.0000,10.0000)|EDGE|ev=generated|or=closing_boundary|rr=shell.wall|w=2 D (0.0000,4.0000,5.5000)|FACE|ev=generated|or=body|rr=shell.offset_face|w=2 +D (0.0000,5.0000,10.0000)|EDGE|ev=preserved|or=closing_boundary|rr=|w=1 +D (0.0000,5.0000,5.0000)|FACE|ev=preserved|or=body|rr=shell.body_face|w=2 D (4.0000,0.0000,10.0000)|EDGE|ev=generated|or=closing_boundary|rr=shell.wall|w=2 D (4.0000,0.0000,5.5000)|FACE|ev=generated|or=body|rr=shell.offset_face|w=2 +D (5.0000,0.0000,10.0000)|EDGE|ev=preserved|or=closing_boundary|rr=|w=1 +D (5.0000,0.0000,5.0000)|FACE|ev=preserved|or=body|rr=shell.body_face|w=2 E generated|body|boundary|shell.offset_face|True|FACE@(-5.0000,0.0000,5.0000)->FACE@(-4.0000,0.0000,5.5000) E generated|body|boundary|shell.offset_face|True|FACE@(0.0000,-5.0000,5.0000)->FACE@(0.0000,-4.0000,5.5000) E generated|body|boundary|shell.offset_face|True|FACE@(0.0000,0.0000,0.0000)->FACE@(0.0000,0.0000,1.0000) @@ -342,6 +365,20 @@ E generated|closing_boundary|boundary|shell.wall|True|EDGE@(0.0000,-5.0000,10.00 E generated|closing_boundary|boundary|shell.wall|True|EDGE@(0.0000,5.0000,10.0000)->EDGE@(0.0000,4.0000,10.0000) E generated|closing_boundary|boundary|shell.wall|True|EDGE@(5.0000,0.0000,10.0000)->EDGE@(4.0000,0.0000,10.0000) E modified|closing_face|fragment|shell.closing_descendant|True|FACE@(0.0000,0.0000,10.0000)->FACE@(0.0000,0.0000,10.0000) +E preserved|body|continuation|shell.body_face|True|FACE@(-5.0000,0.0000,5.0000)->FACE@(-5.0000,0.0000,5.0000) +E preserved|body|continuation|shell.body_face|True|FACE@(0.0000,-5.0000,5.0000)->FACE@(0.0000,-5.0000,5.0000) +E preserved|body|continuation|shell.body_face|True|FACE@(0.0000,0.0000,0.0000)->FACE@(0.0000,0.0000,0.0000) +E preserved|body|continuation|shell.body_face|True|FACE@(0.0000,5.0000,5.0000)->FACE@(0.0000,5.0000,5.0000) +E preserved|body|continuation|shell.body_face|True|FACE@(5.0000,0.0000,5.0000)->FACE@(5.0000,0.0000,5.0000) +E preserved|closing_boundary|continuation|-|True|EDGE@(-5.0000,0.0000,10.0000)->EDGE@(-5.0000,0.0000,10.0000) +E preserved|closing_boundary|continuation|-|True|EDGE@(0.0000,-5.0000,10.0000)->EDGE@(0.0000,-5.0000,10.0000) +E preserved|closing_boundary|continuation|-|True|EDGE@(0.0000,5.0000,10.0000)->EDGE@(0.0000,5.0000,10.0000) +E preserved|closing_boundary|continuation|-|True|EDGE@(5.0000,0.0000,10.0000)->EDGE@(5.0000,0.0000,10.0000) +R shell.body_face|body|GeneratedOrModified|FACE@(-5.0000,0.0000,5.0000)|FACE@(-5.0000,0.0000,5.0000) +R shell.body_face|body|GeneratedOrModified|FACE@(0.0000,-5.0000,5.0000)|FACE@(0.0000,-5.0000,5.0000) +R shell.body_face|body|GeneratedOrModified|FACE@(0.0000,0.0000,0.0000)|FACE@(0.0000,0.0000,0.0000) +R shell.body_face|body|GeneratedOrModified|FACE@(0.0000,5.0000,5.0000)|FACE@(0.0000,5.0000,5.0000) +R shell.body_face|body|GeneratedOrModified|FACE@(5.0000,0.0000,5.0000)|FACE@(5.0000,0.0000,5.0000) R shell.closing_descendant|closing_face|GeneratedOrModified|FACE@(0.0000,0.0000,10.0000)|FACE@(0.0000,0.0000,10.0000) R shell.offset_face|body|GeneratedOrModified|FACE@(-4.0000,0.0000,5.5000)|FACE@(-5.0000,0.0000,5.0000) R shell.offset_face|body|GeneratedOrModified|FACE@(0.0000,-4.0000,5.5000)|FACE@(0.0000,-5.0000,5.0000) @@ -354,13 +391,21 @@ R shell.wall|closing_boundary|GeneratedOrModified|EDGE@(0.0000,4.0000,10.0000)|E R shell.wall|closing_boundary|GeneratedOrModified|EDGE@(4.0000,0.0000,10.0000)|EDGE@(5.0000,0.0000,10.0000) )GOLDEN"}, {"loft", - R"GOLDEN(counts preserved=0 modified=0 generated=8 deleted=0 section_edges=0 entries=8 roles=10 delta_entries=6 + R"GOLDEN(counts preserved=8 modified=0 generated=8 deleted=0 section_edges=0 entries=16 roles=10 delta_entries=14 +D (-0.5000,0.0000,2.0000)|EDGE|ev=preserved|or=profile_1|rr=|w=1 D (-0.7778,0.0000,0.8889)|FACE|ev=generated|or=profile_0,profile_1|rr=loft.side|w=4 +D (-1.0000,0.0000,0.0000)|EDGE|ev=preserved|or=profile_0|rr=|w=1 +D (0.0000,-0.5000,2.0000)|EDGE|ev=preserved|or=profile_1|rr=|w=1 D (0.0000,-0.7778,0.8889)|FACE|ev=generated|or=profile_0,profile_1|rr=loft.side|w=4 +D (0.0000,-1.0000,0.0000)|EDGE|ev=preserved|or=profile_0|rr=|w=1 D (0.0000,0.0000,0.0000)|FACE|ev=|or=|rr=loft.start|w=1 D (0.0000,0.0000,2.0000)|FACE|ev=|or=|rr=loft.end|w=1 +D (0.0000,0.5000,2.0000)|EDGE|ev=preserved|or=profile_1|rr=|w=1 D (0.0000,0.7778,0.8889)|FACE|ev=generated|or=profile_0,profile_1|rr=loft.side|w=4 +D (0.0000,1.0000,0.0000)|EDGE|ev=preserved|or=profile_0|rr=|w=1 +D (0.5000,0.0000,2.0000)|EDGE|ev=preserved|or=profile_1|rr=|w=1 D (0.7778,0.0000,0.8889)|FACE|ev=generated|or=profile_0,profile_1|rr=loft.side|w=4 +D (1.0000,0.0000,0.0000)|EDGE|ev=preserved|or=profile_0|rr=|w=1 E generated|profile_0|boundary|loft.side|True|EDGE@(-1.0000,0.0000,0.0000)->FACE@(-0.7778,0.0000,0.8889) E generated|profile_0|boundary|loft.side|True|EDGE@(0.0000,-1.0000,0.0000)->FACE@(0.0000,-0.7778,0.8889) E generated|profile_0|boundary|loft.side|True|EDGE@(0.0000,1.0000,0.0000)->FACE@(0.0000,0.7778,0.8889) @@ -369,6 +414,14 @@ E generated|profile_1|boundary|loft.side|True|EDGE@(-0.5000,0.0000,2.0000)->FACE E generated|profile_1|boundary|loft.side|True|EDGE@(0.0000,-0.5000,2.0000)->FACE@(0.0000,-0.7778,0.8889) E generated|profile_1|boundary|loft.side|True|EDGE@(0.0000,0.5000,2.0000)->FACE@(0.0000,0.7778,0.8889) E generated|profile_1|boundary|loft.side|True|EDGE@(0.5000,0.0000,2.0000)->FACE@(0.7778,0.0000,0.8889) +E preserved|profile_0|continuation|-|True|EDGE@(-1.0000,0.0000,0.0000)->EDGE@(-1.0000,0.0000,0.0000) +E preserved|profile_0|continuation|-|True|EDGE@(0.0000,-1.0000,0.0000)->EDGE@(0.0000,-1.0000,0.0000) +E preserved|profile_0|continuation|-|True|EDGE@(0.0000,1.0000,0.0000)->EDGE@(0.0000,1.0000,0.0000) +E preserved|profile_0|continuation|-|True|EDGE@(1.0000,0.0000,0.0000)->EDGE@(1.0000,0.0000,0.0000) +E preserved|profile_1|continuation|-|True|EDGE@(-0.5000,0.0000,2.0000)->EDGE@(-0.5000,0.0000,2.0000) +E preserved|profile_1|continuation|-|True|EDGE@(0.0000,-0.5000,2.0000)->EDGE@(0.0000,-0.5000,2.0000) +E preserved|profile_1|continuation|-|True|EDGE@(0.0000,0.5000,2.0000)->EDGE@(0.0000,0.5000,2.0000) +E preserved|profile_1|continuation|-|True|EDGE@(0.5000,0.0000,2.0000)->EDGE@(0.5000,0.0000,2.0000) R loft.end|-|LastShape|FACE@(0.0000,0.0000,2.0000)|- R loft.side|profile_0|Generated|FACE@(-0.7778,0.0000,0.8889)|EDGE@(-1.0000,0.0000,0.0000) R loft.side|profile_0|Generated|FACE@(0.0000,-0.7778,0.8889)|EDGE@(0.0000,-1.0000,0.0000) @@ -381,13 +434,21 @@ R loft.side|profile_1|Generated|FACE@(0.7778,0.0000,0.8889)|EDGE@(0.5000,0.0000, R loft.start|-|FirstShape|FACE@(0.0000,0.0000,0.0000)|- )GOLDEN"}, {"loft_ruled", - R"GOLDEN(counts preserved=0 modified=0 generated=8 deleted=0 section_edges=0 entries=8 roles=10 delta_entries=6 + R"GOLDEN(counts preserved=8 modified=0 generated=8 deleted=0 section_edges=0 entries=16 roles=10 delta_entries=14 +D (-0.5000,0.0000,2.0000)|EDGE|ev=preserved|or=profile_1|rr=|w=1 D (-0.7778,0.0000,0.8889)|FACE|ev=generated|or=profile_0,profile_1|rr=loft.side|w=4 +D (-1.0000,0.0000,0.0000)|EDGE|ev=preserved|or=profile_0|rr=|w=1 +D (0.0000,-0.5000,2.0000)|EDGE|ev=preserved|or=profile_1|rr=|w=1 D (0.0000,-0.7778,0.8889)|FACE|ev=generated|or=profile_0,profile_1|rr=loft.side|w=4 +D (0.0000,-1.0000,0.0000)|EDGE|ev=preserved|or=profile_0|rr=|w=1 D (0.0000,0.0000,0.0000)|FACE|ev=|or=|rr=loft.start|w=1 D (0.0000,0.0000,2.0000)|FACE|ev=|or=|rr=loft.end|w=1 +D (0.0000,0.5000,2.0000)|EDGE|ev=preserved|or=profile_1|rr=|w=1 D (0.0000,0.7778,0.8889)|FACE|ev=generated|or=profile_0,profile_1|rr=loft.side|w=4 +D (0.0000,1.0000,0.0000)|EDGE|ev=preserved|or=profile_0|rr=|w=1 +D (0.5000,0.0000,2.0000)|EDGE|ev=preserved|or=profile_1|rr=|w=1 D (0.7778,0.0000,0.8889)|FACE|ev=generated|or=profile_0,profile_1|rr=loft.side|w=4 +D (1.0000,0.0000,0.0000)|EDGE|ev=preserved|or=profile_0|rr=|w=1 E generated|profile_0|boundary|loft.side|True|EDGE@(-1.0000,0.0000,0.0000)->FACE@(-0.7778,0.0000,0.8889) E generated|profile_0|boundary|loft.side|True|EDGE@(0.0000,-1.0000,0.0000)->FACE@(0.0000,-0.7778,0.8889) E generated|profile_0|boundary|loft.side|True|EDGE@(0.0000,1.0000,0.0000)->FACE@(0.0000,0.7778,0.8889) @@ -396,6 +457,14 @@ E generated|profile_1|boundary|loft.side|True|EDGE@(-0.5000,0.0000,2.0000)->FACE E generated|profile_1|boundary|loft.side|True|EDGE@(0.0000,-0.5000,2.0000)->FACE@(0.0000,-0.7778,0.8889) E generated|profile_1|boundary|loft.side|True|EDGE@(0.0000,0.5000,2.0000)->FACE@(0.0000,0.7778,0.8889) E generated|profile_1|boundary|loft.side|True|EDGE@(0.5000,0.0000,2.0000)->FACE@(0.7778,0.0000,0.8889) +E preserved|profile_0|continuation|-|True|EDGE@(-1.0000,0.0000,0.0000)->EDGE@(-1.0000,0.0000,0.0000) +E preserved|profile_0|continuation|-|True|EDGE@(0.0000,-1.0000,0.0000)->EDGE@(0.0000,-1.0000,0.0000) +E preserved|profile_0|continuation|-|True|EDGE@(0.0000,1.0000,0.0000)->EDGE@(0.0000,1.0000,0.0000) +E preserved|profile_0|continuation|-|True|EDGE@(1.0000,0.0000,0.0000)->EDGE@(1.0000,0.0000,0.0000) +E preserved|profile_1|continuation|-|True|EDGE@(-0.5000,0.0000,2.0000)->EDGE@(-0.5000,0.0000,2.0000) +E preserved|profile_1|continuation|-|True|EDGE@(0.0000,-0.5000,2.0000)->EDGE@(0.0000,-0.5000,2.0000) +E preserved|profile_1|continuation|-|True|EDGE@(0.0000,0.5000,2.0000)->EDGE@(0.0000,0.5000,2.0000) +E preserved|profile_1|continuation|-|True|EDGE@(0.5000,0.0000,2.0000)->EDGE@(0.5000,0.0000,2.0000) R loft.end|-|LastShape|FACE@(0.0000,0.0000,2.0000)|- R loft.side|profile_0|Generated|FACE@(-0.7778,0.0000,0.8889)|EDGE@(-1.0000,0.0000,0.0000) R loft.side|profile_0|Generated|FACE@(0.0000,-0.7778,0.8889)|EDGE@(0.0000,-1.0000,0.0000) diff --git a/src/cpp/tests/golden/ops_features_blend_failures.json b/src/cpp/tests/golden/ops_features_blend_failures.json index 75510c05..dc6191dc 100644 --- a/src/cpp/tests/golden/ops_features_blend_failures.json +++ b/src/cpp/tests/golden/ops_features_blend_failures.json @@ -308,16 +308,7 @@ "technical_details": "ValueError: The underlying validation failed; use the structured guidance above to repair the operation.", "what_happened": "Failed to apply the shell operation." }, - "shell_role": { - "how_to_fix": [], - "inventory": [], - "measurements": [], - "operation": "semantic_query", - "possible_causes": [], - "repair": [], - "technical_details": null, - "what_happened": "operation output role 'shell.body_face' requires at least one kernel-proven result" - }, + "shell_role": null, "tangent": { "how_to_fix": [ "Use a positive fillet radius.", diff --git a/src/cpp/tests/golden/ops_features_shell.json b/src/cpp/tests/golden/ops_features_shell.json index 33c440a6..557a8b05 100644 --- a/src/cpp/tests/golden/ops_features_shell.json +++ b/src/cpp/tests/golden/ops_features_shell.json @@ -363,7 +363,9 @@ -0.0, 5.0 ], - [] + [ + "face.shell.body_face" + ] ], [ [ @@ -372,7 +374,9 @@ -5.0, 5.0 ], - [] + [ + "face.shell.body_face" + ] ], [ [ @@ -381,7 +385,9 @@ 0.0, 0.0 ], - [] + [ + "face.shell.body_face" + ] ], [ [ @@ -390,7 +396,9 @@ 5.0, 5.0 ], - [] + [ + "face.shell.body_face" + ] ], [ [ @@ -399,7 +407,9 @@ -0.0, 5.0 ], - [] + [ + "face.shell.body_face" + ] ] ], "faces": 11, diff --git a/src/cpp/tests/golden/ops_features_tag_projection.json b/src/cpp/tests/golden/ops_features_tag_projection.json index 0adc75e9..c3b3cead 100644 --- a/src/cpp/tests/golden/ops_features_tag_projection.json +++ b/src/cpp/tests/golden/ops_features_tag_projection.json @@ -1689,7 +1689,9 @@ -5.0, 5.0 ], - [] + [ + "face.shell.body_face" + ] ], [ [ @@ -1698,7 +1700,9 @@ 0.0, 0.0 ], - [] + [ + "face.shell.body_face" + ] ], [ [ @@ -1707,7 +1711,9 @@ 0.0, 10.0 ], - [] + [ + "face.shell.body_face" + ] ], [ [ @@ -1716,7 +1722,9 @@ 5.0, 5.0 ], - [] + [ + "face.shell.body_face" + ] ], [ [ @@ -1725,7 +1733,9 @@ -0.0, 5.0 ], - [] + [ + "face.shell.body_face" + ] ] ], "faces": 11, diff --git a/src/simplecadapi/_glue/docstrings.json b/src/simplecadapi/_glue/docstrings.json index ba7b93be..3b8d2a77 100644 --- a/src/simplecadapi/_glue/docstrings.json +++ b/src/simplecadapi/_glue/docstrings.json @@ -291,7 +291,7 @@ "select_faces_by_tag": "Select faces by tag.", "set_public_connector_rassembly": "Expose an existing connector on a direct child component.", "sew_faces_rshell": "Sew faces into exactly one connected Shell.", - "shell_rsolid": "Shell a solid, with optional kernel-role-based face tags.", + "shell_rsolid": "Shell a solid, with optional kernel-role-based face tags.\n\nThe kernel roles are ``shell.body_face`` (a face of the input that stays in\nthe result), ``shell.offset_face`` (the inner face it generates),\n``shell.closing_descendant`` (what is left of a removed face: the rim) and\n``shell.wall`` (the edges that become the walls of an opening).\n``body_faces_tag``, ``offset_faces_tag``, ``closing_faces_tag`` and\n``wall_edges_tag`` tag exactly the entities with those roles.", "shells": "Select Shell entities from a Shell or compatible topology scope.", "solve_assembly_constraints_rassembly": "Solve fixed, revolute, and prismatic assembly constraints.\n\nSolving is limit-aware: when a constraint carries a ``ScalarLimit``\n(``angle_limit`` or ``distance_limit``), the drive scalar is clamped\ninto the closed range before placement propagation. When no drive\nscalar is present but a limit exists, the current relative-frame\nscalar is projected into the bounds. Unresolvable closed kinematic\nloops fall back to a golden-section search over the limit bounds.\n\nA ``ConstraintReport`` is recorded on the returned assembly under the\n``constraint_report`` runtime key for later inspection via\n``inspect_assembly_constraints_rassembly``.", "source_binding": "Match a projected local binding by its exact source binding identity.", diff --git a/test/test_element_ref_history.py b/test/test_element_ref_history.py index b0c47459..d78b2291 100644 --- a/test/test_element_ref_history.py +++ b/test/test_element_ref_history.py @@ -132,17 +132,21 @@ def test_a_face_cut_away_is_lost_and_says_where(): assert r.lost_at == cut.get_metadata("graph")["node_id"] -def test_a_shell_kept_face_is_lost_instead_of_guessed(): - # The one remaining kernel gap (design 7.2, owner decision pending): a kept shell face has only a - # generated witness. The resolver says so; it does not pick the offset face or anything else. +def test_a_shell_kept_face_resolves_to_itself(): + # Was the last kernel gap (a kept face had only the generated witness of its offset face); the tracker now + # also records that it stays (owner decision, option a). with scad.GraphSession(): box, anchor = _box_with_top_anchor() shelled = scad.shell_rsolid(box, _faces_at(box, 0), 1.0) r = er.resolve(anchor, shelled) - assert r.status == "lost" - assert r.reason == "replaced" - assert r.entities == [] + assert r.status == "ok" + (face,) = r.entities + assert face.get_center().z == pytest.approx(10.0) + assert face.get_area() == pytest.approx(800.0) + # The offset face it generated is reachable in derived mode, the face itself among the targets. + derived = er.resolve(anchor, shelled, follow="derived") + assert sorted(round(f.get_center().z, 6) for f in derived.entities) == [9.0, 10.0] def test_an_edge_followed_into_its_fillet_patch(): @@ -228,8 +232,7 @@ _AUDIT = { "intersect": (lambda b: scad.intersect_rsolid(b, scad.make_box_rsolid(30, 30, 30, (10, 0, -5))), 0, 1, "ok"), "fillet": (lambda b: scad.fillet_rsolid(b, _edges_at(b, 10), 2.0), 0, 0, "ok"), "chamfer": (lambda b: scad.chamfer_rsolid(b, _edges_at(b, 10), 2.0), 0, 0, "ok"), - # Kept faces of a shell carry only a Generated witness (their offset face), no Preserved one. - "shell_kept_face": (lambda b: scad.shell_rsolid(b, _faces_at(b, 0), 1.0), 0, 0, "lost"), + "shell_kept_face": (lambda b: scad.shell_rsolid(b, _faces_at(b, 0), 1.0), 0, 1, "ok"), "shell_opened_face": (lambda b: scad.shell_rsolid(b, _faces_at(b, 10), 1.0), 0, 1, "ok"), "translate": (lambda b: scad.translate_shape(b, (5, 0, 0)), 0, 0, "ok"), "mirror": (lambda b: scad.mirror_shape(b, (0, 0, 0), (1, 0, 0)), 0, 0, "ok"), diff --git a/test/test_operation_output_roles.py b/test/test_operation_output_roles.py index 88422c00..448c1be2 100644 --- a/test/test_operation_output_roles.py +++ b/test/test_operation_output_roles.py @@ -398,17 +398,21 @@ class TestOperationOutputRoles(unittest.TestCase): start_face_tag="role.start", ) - def test_unavailable_shell_role_fails_instead_of_guessing(self): + def test_shell_body_role_is_kernel_proven_for_the_kept_faces(self): + # The kept faces stay in the result (IsSame) while generating their offset faces; since the shell + # kept-face fix they carry a preserved witness, so shell.body_face is proven for exactly those five. + # (Before it, this role was unavailable and the tag raised "requires at least one kernel-proven result".) box = scad.make_box_rsolid(4.0, 4.0, 4.0) - with self.assertRaisesRegex( - scad.SimpleCADError, "shell.body_face.*kernel-proven" - ): - scad.shell_rsolid( - box, - [box.get_faces(0)], - 0.2, - body_faces_tag="group.body", - ) + shelled = scad.shell_rsolid( + box, + [box.get_faces(0)], + 0.2, + body_faces_tag="group.body", + ) + self.assertEqual(_role_count(shelled, "shell.body_face"), 5) + tagged = [f for f in shelled._iter_faces() if "group.body" in f._list_tags()] + self.assertEqual(len(tagged), 5) + self.assertTrue(all(abs(f.get_area() - 16.0) < 1e-6 for f in tagged)) def test_sweep_rejects_profiles_with_inner_wires(self): outer = scad.make_rectangle_rwire(3.0, 3.0)