Repository navigation
Conversation
A stable anchor names a face by (feature, op, occurrence, role/ordinal | topo). In notebook models that leaves several classes ambiguous or silently re-targetable: copies (mirror / translate / pattern) share one birth, operations made by one line in a loop share a key, split pieces are named by position, ordinals follow lists that change, and call-site ids change when another line of the cell is edited. Re-resolving every face on the part it was picked from returned that face for only 73.7 % of 30,365 faces. Add simplecadapi.topology.naming_hints: at pick time scad.ref.of records JSON hints next to the anchor (ElementRef.hints): the execution index of the birth operation and of every copy / repeated operation on the face's history path (stable key, hash of the call's code text, rank among the call's instances, instance count, own-parameter digest), neighbourhood names, ranks and spacings. On resolve each execution index is aligned to the new execution (unique unchanged digest > rank when the count is unchanged > spatial gating within half the old spacing > removed), the C++ history walk runs from the aligned birth, and candidates must pass through exactly the aligned operations (path replay). Ordinals are trusted only while the role's entity count is unchanged; positional anchors get a deeper, role-named birth through splits. History that reports a face deleted is final; nothing is chosen silently. The anchor format, the naming version and the C++ kernel are unchanged; a reference without hints resolves exactly as before. of(hints=True) stores hints only for faces with a known ambiguity class, so plain references read as before; hints="always" also guards against ambiguity a later edit introduces. Held-out evaluation (60 cases, LLM-generated edits): correct / silent wrong 80.4 / 3.3 % -> 98.6 / 0.7 % on normal edits, 76.9 / 7.1 % -> 97.4 / 1.1 % on hard edits. See design-docs/persistent-naming-hints.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
scad.refnames a face by its stable anchor(feature, op, occurrence, role/ordinal | topo)and follows it through the recordedTopoDelta. On notebook models, several classes of faces stay ambiguous or are silently re-targeted after an edit:spliton every copied faceanchor_ambiguous; after a count change a neighbour can stand in (silent wrong pick)trace_to_birthstops at a split and names the piecetopo=face_Nextrusion.side,fillet.patch)callsite_idchanges when another line of the cell is editedMeasured on the notebook corpus: with no edit at all, re-resolving every face on the part it was picked from returned that face for 73.7 % of 30,365 faces (385 cases).
What
New
simplecadapi.topology.naming_hints. In a code-based model an edit is a new execution of the program, so the hints treat naming as aligning two executions:splitorlost: nothing is chosen silently.ref.py:ElementRef.hints: plain JSON, excluded from equality, round-trips throughto_dict()andrepr()/parse().scad.ref.face(..., hints=).scad.ref.of(..., hints=True | "always" | False):True(default) stores hints only for faces that have a known ambiguity class, so plain references such asbox.topread exactly as before;"always"also guards against ambiguity that a later edit introduces (e.g. another op of the same kind inserted in the cell). It is the better choice for generated picks (runtime/live_refs.py), which this PR does not change;Falseis the v2.3.0 behaviour.Unchanged: the C++ kernel, the anchor format,
scad-naming/1, tags,ql, and edge / vertex / solid references. A reference without hints resolves exactly as before.Results
Edit tasks and ground truth were generated by an LLM agent and validated by script. On pure parameter edits the labels agree 99.8 % with an independent continuation-tracking oracle. Held-out test set (60 cases), correct / silent wrong pick:
scad.refof→ JSON →from_dict→resolve)No-edit self-consistency goes from 73.7 % to 97.2 % (
lostfrom 11.7 % to 0 %). Making and resolving a reference costs about 111 ms per face, against 21 ms before. Details, ablations and the CadQuery / build123d / graph-matching comparison are indesign-docs/persistent-naming-hints.md, added with-fbecausedesign-docs/is in.gitignore.Tests
test/test_naming_hints.py(6 tests): mirrored copy, removed loop instance, translated copies, reordered instances, split piece after an upstream insert (asserts the v2.3.0 silent wrong pick), hints round trip.test_naming_hints.py,test_ref_api.pyandtest_element_ref_history.pypass (74 tests). They were run against the v2.3.0 wheel's native module with these Python files overlaid; I have not run the full suite on adevbuild.dev.Not in this PR
runtime/live_refs.pytohints="always".🤖 Generated with Claude Code