Skip to content

feat: find_countersinks() — in-house Apache countersink recognizer#350

Merged
pzfreo merged 3 commits into
mainfrom
feat/countersink-recognizer
Jul 2, 2026
Merged

feat: find_countersinks() — in-house Apache countersink recognizer#350
pzfreo merged 3 commits into
mainfrom
feat/countersink-recognizer

Conversation

@pzfreo

@pzfreo pzfreo commented Jul 2, 2026

Copy link
Copy Markdown
Owner

The first in-house, Apache-licensed feature recognizer — per the plan to build recognizers individually here and repatriate them into a shared permissive package once mature (keeping build123d-mcp off the AGPL draftwright dependency).

The gap

build123d builds countersinks (CounterSinkHole) but nothing recognizes them: find_holes reports a countersink only as a plain opening, and build123d's own detect_primitives is mesh-surface reconstruction, not feature semantics. So a countersunk screw hole was invisible to the conformance loop.

Detection (tools/recognizers/countersink.py)

A countersink = an internal CONE face with two distinct-radius circular edges (minor = drill, major = opening) that flares outward and is coaxial with a CYLINDER of the drill radius. That signature excludes:

  • drill-point cones (a single circle + apex, not flared) — verified
  • external edge chamfers (also cone faces, but no coaxial drilled bore) — verified

Returns {count, countersinks: [{location, axis, major_diameter, drill_diameter, included_angle (82/90/100/120°), depth}]}.

Repatriation-ready: the pure recognise_countersinks(part) uses build123d/OCP only with no session coupling, so it lifts unchanged into the future shared recognition package; find_countersinks(session, …) is the thin MCP wrapper.

Tests & docs

Recognises 2 countersinks (Ø12 major / Ø6 drill / 82°); plain holes → 0; external chamfer → 0 (no false positive); tool JSON + unknown-object error; boundary smoke + classification + inventory. Docs: README, server docstring, CHANGELOG (v0.3.62). 882 passed; ruff + mypy + ruff format --check clean.

🤖 Generated with Claude Code

Paul Fremantle and others added 3 commits July 2, 2026 14:42
First in-house feature recognizer (the plan: build recognizers individually here
under Apache, repatriate into a shared permissive package once mature — keeping
build123d-mcp off the AGPL draftwright dep). build123d builds countersinks
(CounterSinkHole) but neither build123d nor our external find_holes recognizes
them — find_holes reports a countersink only as a plain opening.

Detection (tools/recognizers/countersink.py, build123d/OCP only, no session
coupling in the pure recogniser so it lifts cleanly later): an internal CONE face
with two distinct-radius circular edges (minor=drill, major=opening) that flares
out and is COAXIAL with a CYLINDER of the drill radius. This excludes drill-point
cones (one circle + apex) and external edge chamfers (no coaxial bore) — both
verified by tests. Reports {location, axis, major_diameter, drill_diameter,
included_angle (82/90/100/120°), depth}.

Wiring: tools/recognizers/{__init__,countersink}.py, worker stub, server tool,
boundary smoke + classification, tool inventory. Tests: recognises 2 countersinks
(Ø12 major / Ø6 drill / 82°), plain holes -> 0, external chamfer -> 0 (no false
positive), tool JSON + unknown-object error. Docs: README, server docstring,
CHANGELOG (v0.3.62). 882 passed; ruff + mypy + format clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…stic axis

Adversarial review of find_countersinks found a false positive and an unproven
axis assumption; fixed:

- F1 (confirmed): a near-flat conical relief/draft (~178° included) false-
  positived as a countersink. Reject included_angle > 160° (real countersinks are
  ≤120°; 160° keeps them all with margin, excludes drafts). Test: 178° -> [].
- F2: the reported axis was OCP's raw cone-axis sign (orientation-dependent, not
  provably "into the part"). Now computed from opening->drill centers, so it's
  deterministically into the part and consistent with find_holes' drill direction.
  Test: top-drilled -> -z, bottom-drilled -> +z (both into the part).
- F3: documented the recognised-tier limits (deburr/lead-in chamfers also
  register; clipped-cone countersinks are missed).

885 passed; ruff + mypy + format clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A recognizer that isn't in the gate is only half-done for the conformance loop,
so fold the gate integration into the same PR: verify_spec now accepts a
{kind:"countersink", count, major_diameter_mm, drill_diameter_mm,
included_angle_deg, depth_mm} feature (any subset), matched frame-independently
against find_countersinks output at the recognised tier. Feature numeric
sub-fields are shape-validated (clean error on a string), consistent with the
other feature kinds.

Tests: countersink spec conforms (count+dims+angle), wrong angle FAILs, absent on
a plain-hole part FAILs (found 0), non-numeric field clean error. Docs: server
docstring, llms.md, CHANGELOG (v0.3.62). 889 passed; ruff + mypy + format clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pzfreo pzfreo merged commit 1e9f517 into main Jul 2, 2026
12 checks passed
@pzfreo pzfreo deleted the feat/countersink-recognizer branch July 2, 2026 19:24
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