feat: find_countersinks() — in-house Apache countersink recognizer#350
Merged
Conversation
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>
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.
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
draftwrightdependency).The gap
build123d builds countersinks (
CounterSinkHole) but nothing recognizes them:find_holesreports a countersink only as a plain opening, and build123d's owndetect_primitivesis 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
CONEface with two distinct-radius circular edges (minor = drill, major = opening) that flares outward and is coaxial with aCYLINDERof the drill radius. That signature excludes: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 --checkclean.🤖 Generated with Claude Code