Skip to content

Add analyze_fit_return_risk — Robert Engine return probability (api/fit_engine.py)#113

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-return-risk-analysis-function
Draft

Add analyze_fit_return_risk — Robert Engine return probability (api/fit_engine.py)#113
Copilot wants to merge 2 commits intomainfrom
copilot/add-return-risk-analysis-function

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Implements the Robert Engine physics formula that estimates return risk from fabric elasticity/recovery and the user's shoulder width, returning a risk percentage and size recommendation.

Changes

  • api/fit_engine.py (new)

    • UserAnchors dataclass — biometric anchor point (shoulder width in cm)
    • Named constants replace magic numbers (_SHOULDER_MULTIPLIER, _TENSION_WEIGHT, _MAX_RETURN_RISK, _RISK_THRESHOLD, _PERCENTAGE_DIVISOR)
    • analyze_fit_return_risk(fabric, user_anchors, garment_id) — raises ValueError on elasticityPct ≤ 0 to prevent division-by-zero; caps risk at 95 %
  • tests/test_fit_engine.py (new) — 10 unittest cases covering low/high risk paths, 95 % cap, exact 30 % boundary, response structure, rounding, and invalid-input guards

Usage

from api.fit_engine import UserAnchors, analyze_fit_return_risk

fabric = {"elasticityPct": 10.0, "recoveryPct": 20.0}
anchors = UserAnchors(shoulder_w=60.0)

result = analyze_fit_return_risk(fabric, anchors, "V10-BALMAIN-WHITE-SNAP")
# {
#   "garment_id": "V10-BALMAIN-WHITE-SNAP",
#   "return_risk_pct": 95.0,
#   "recommendation": "Sugerir Talla Superior"
# }

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tryonyou-pilot Error Error Apr 7, 2026 1:43pm

Request Review

Copilot AI changed the title [WIP] Add return risk analysis function for garments Add analyze_fit_return_risk — Robert Engine return probability (api/fit_engine.py) Apr 7, 2026
Copilot AI requested a review from LVT-ENG April 7, 2026 13:44
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.

2 participants