src/lib/region-classifier.ts is orphan code - never wired into digitize pipeline (and has a px-vs-mm bug in validateClassification) #88
Labels
No labels
blocked:commit-ready-failed
blocked:gate-fetch
blocked:gate-lint
blocked:gate-plan
blocked:gate-research
blocked:needs-attention
blocked:needs-decision
blocked:needs-human
blocked:no-changes
blocked:verify-failed
bug
deferred
feature-request
in-progress
needs-decompose
needs-triage
quickfix
security/medium
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/Kimi_Agent_Brother_10_Digitizing_App#88
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Where:
src/lib/region-classifier.ts,src/lib/region-classifier.test.ts.Bug: This is a TS port of donor
easystitch/src/embroidery_converter/classifier.pyandeasystitch/src/svg_annotation/element_classifier.pythat has zero production callers in this repo:grep -rln 'region-classifier|classifyStitch|@/lib/region-classifier' src/returns only the test file.src/components/workspace/useWorkspace.ts->src/lib/easystitch-client.ts-> easystitch-service HTTP/v1/digitize) returnsstitchTypefrom the service; the client maps viamapServiceStitchTypeToWorkspace(src/lib/digitize-adapters.ts:158-172). The service does classification server-side.IMPLEMENTATION_PLAN.mdPhase D row #7 ("Decompose: auto-digitize P2 - Region Classification",triage-approved) is the work that was supposed to wire this in. It never landed.So the module is "Phase 2 work" that exists as tests + a clean port but was never connected. While it is orphan code, two bugs are present in the code path it would take:
Bug 1 -
validateClassificationcompares pixels against mm (lines 329-335).shape.pointsare workspace pixels (src/components/workspace/types.tsPoint).calculateDimensionsreturns pixels.SATIN_MAX_DIMENSION_MM = 10.0is in mm. So at the defaultMM_TO_PX ~ 3.78 px/mm, ANY satin shape larger than ~2.6 mm in pixels (i.e. larger than ~10 px on screen) triggers a "satin on a large area" warning. In practice this fires on every non-tiny satin shape, so the warning is effectively noise.The header comment (lines 13-19) explicitly tells callers to convert:
const pxThreshold = DEFAULT_WIDTH_THRESHOLD_MM * MM_TO_PX; classifyStitchType(shape, pxThreshold);.validateClassificationaccepts awidthThresholdparameter (line 326) but never applies it tomaxDimension(line 330void widthThreshold;). Donor_classify_*callers operate in mm throughout (calculate_dimensions(path_data.coordinates)-> mm), so the bug is a porting-only error.Bug 2 - dead code in
classifyStitchSequence(lines 309, 312).role: shape.fill ? 'original' : 'original'- both arms identical. Either drop the ternary (always'original') or pick a real'fill' | 'stroke' | 'original'value based on the shape's actual primary feature.warnings.length = 0;after aresults.push(...)that already used thewarningsarray. It's clearing a stale local with no effect; only reachable in the non-split branch (the split branchcontinues before reaching it).Tests: 30/30 currently pass - but every test feeds points whose pixel-count equals mm-count, so Bug 1 is invisible to the suite. The test fixtures
rect(w, h)(line 18) construct points in user-supplied units with no scale, masking the mismatch.Fix consistent with existing patterns: Three acceptable paths; pick one and the rest follow:
Wire it in (the original Phase D intent):
maxDimensionin mm by dividing byMM_TO_PXinsidevalidateClassification(or accept ammToPxparameter and divide).useWorkspace.ts:runAutoDigitize(post-easystitch-service response), applyclassifyStitchSequenceto the regions returned for any shape missing a service-assignedstitchType. HonorembroideryTypemanual override first.roleternary with a real branch onprimaryFeature(shape).warnings.length = 0;clear.Make it honest (cheaper, matches Path 2 of #83 / #84):
src/lib/region-classifier.tsand its test file. The actual classifier lives server-side in easystitch-service (pipeline_runner.py).IMPLEMENTATION_PLAN.mdrow #7 todeferredwith a one-line rationale.Keep the module, fix the bugs only (cheapest, but leaves it orphan): apply Bug 1 + Bug 2 fixes and leave the integration to Phase D when it actually ships.
Recommended: Path 2. The service has working classification. The TS port is un-wired code with no caller. Tests passing don't justify keeping it. If Phase D ever restarts, the port can be regenerated from the (now stable) donor.
Severity: medium-low. No user-facing bug today (no caller), but the orphan module confuses future contributors about which side owns classification, and the unit bug will bite the moment anyone wires it in.