← Back to Pull requests

refactor(web): extract PDP detail resolution #3611

Open
unknown opened this pull request with 439 lines diff across 5 files
View on GitHub
unknown unknown commented on Oct 03, 2026 17:46 UTC
Author

Summary


  • Extract merchant-scoped detailed PDP lookup, legacy redirect fallback, and normalization into a focused 168-line resolver.

  • Reuse canonical category and slug comparison helpers from both compact-hint and full-detail paths.

  • Preserve existing price, image, stock, variant, offer, category, cache, and redirect behavior; route decreases from 1043 to 858 lines.

  • Refresh the canonical source-bound inventory snapshot: 558 rows unchanged, only source hashes/digest changed.
  • Validation


  • 93 focused tests passed: 8 new resolver cases and 85 existing page-route cases.

  • Affected web lint and typecheck passed; 10 pre-existing lint warnings.

  • Complete three-file runtime CodeRabbit review completed with 0 findings. Snapshot-only followup omitted under the user's earlier skip instruction; root reviewed all four hash/digest changes.

  • Repository inventory snapshot regression passed; rerun after snapshot commit recorded before push.

  • Root reviewed extraction, including exact-equivalent shared canonical comparison functions.
  • Review contract


    The current user-supplied repository instructions require one primary responsibility per module, aim at 300 lines for new/substantially rewritten modules, permit supporting type exports, and prohibit artificial file splitting. These override the older generated one-export-per-file rule in this checkout. The resolver owns detailed product resolution and its shared canonical comparison helpers.

    Scope and next gate


    This is slice 4 of the product detail refactor. The overall refactor remains incomplete at 858 route lines. Exact pushed-head Codex review and required CI must pass before authorized merge. A separate Luna must independently audit deterministic actual in-app-browser checks of merged code before the next slice. Previous slice 3 passed this local fixture gate.
    No production deployment, provider calls, payments, orders, or customer data mutation performed. Local fixture verification is distinct from production verification.

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    Refactors the customer-facing PDP resolution and canonical redirect path; behavior is intended to be unchanged but is covered mainly by unit tests rather than end-to-end routing.

    > Overview

    Moves merchant-scoped PDP lookup, legacy slug fallback, and cached snapshot normalization out of the category product page into category-product-detail-resolution, shrinking the route module while keeping the same redirect and commerce shaping rules.

    > The new resolveCategoryProductForMerchant (replacing inline getProductForMerchant) still loads via getCachedProductWithDetails, falls back to getCachedLegacyProductRedirectTarget, and exports shared hasCategoryMismatch / shouldRedirectResolvedProductSlugValue helpers used by both the LCP-hint fast path and the full-detail load in getProductRouteControl.

    > Adds 8 focused Vitest cases covering normalization, category alias vs mismatch, mixed-case slug redirects, missing category/media defaults, legacy redirect, and error propagation without legacy lookup.

    > Updates the checked-in storefront-edge inventory evidence snapshot digests only (558 rows unchanged).

    > <sup>Reviewed by Cursor Bugbot for commit 7570ab73a2d47522c359bb19c724c5a9b8ceac22. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 439 lines (+329 / -110) across 5 files Reviewer: github-actions[bot] Review duration: 1m
    All Vouch review confidence checks passed
    Residual risk 0.37 = Change Risk (0.45) × (1 − Review Confidence (0.17)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 439 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 17% · Reviewer familiarity: 35%
    17%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.364
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3611"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 17.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 17.3% · Lower = rushed or shallow review
    17.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 37.5% · Moderate risk
    37.5%