Date: 2026-07-22
Status: Accepted
SolidWorks-class sketching is constraint-driven: the user draws roughly, then
coincident/parallel/dimension constraints pull the geometry exact. gitcad
profiles today are explicit coordinates (Profile.line_to(30, 0)), which is
precise but pushes all arithmetic onto the author — and our authors are mostly
agents, who are good at arithmetic but bad at keeping dozens of derived
coordinates consistent when one dimension changes.
The tempting design is a constraint solver in the build loop: store
constraints in the document, solve on every rebuild. That is how interactive
CAD works, and it is wrong for gitcad:
solution multiplicity — mirrored and flipped branches satisfy the same
constraints. Which branch you get depends on the initial guess and solver
internals. A document that builds differently on two machines, or after a
solver upgrade, violates ADR-0004's byte-canonical → geometry-deterministic
chain and makes "a geometry change is a breaking change" (ADR-0006)
unenforceable.
failure surfaces far from the edit that caused it, in a file the agent may
not even be touching.
Constraints are an authoring-time tool; the document format stays
solved-coordinates-only.
gitcad.sketch_solver (mech): a ConstraintSketch builder thataccepts entities (points, lines, arcs) + constraints (coincident,
horizontal/vertical, parallel, perpendicular, tangent, equal, distance,
angle, radius) and emits a plain Profile — the same params dict the
kernel already consumes. 2D-only, Newton–Raphson on the residual vector with
the sketch's drawn coordinates as the initial guess (that choice of guess is
what pins the intended branch).
sketch_solve tool), not in Document.build. What lands in the document is the solved, exact profile —
reviewable, diffable, and rebuilt identically forever.
(params["constraints_src"], ignored by the build) so a later edit can
re-solve from intent instead of hand-editing coordinates. It is
documentation, not input: deleting it changes nothing about the geometry.
errors reported with the residual per constraint — never a build failure.
dof remaining), so anagent can see "under-constrained by 2" and add the missing constraints
instead of trusting a coincidentally-right solution.
intact. Solved profiles from any other tool remain first-class.
source, call sketch_solve, get a new exact profile, diff it. The geometry
change is visible in review, exactly where ADR-0006 wants it.
someone edits coordinates directly. The constraints_src annotation is
best-effort documentation; the solved coordinates are always the truth.
SolidWorks intro curriculum) and grow without touching the kernel or the
document schema.