feat(web): display cited Expert Review sources on Product Detail and API (#2031) #2032
All Vouch review confidence checks passed
Residual risk 0.43 = Change Risk (0.52) × (1 − Review Confidence (0.17)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 29% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #2032"
general
weight: 0.35
claude[bot]
Summary
Implements Phase 1B of the Expert Review architecture (
#2019), connectingrate.vnProduct Detail andGET /api/v1/rate/products/[slug]torate.expert_sourcesandrate.expert_citations(DOS/DOS.Me#2050,PR #2051):apps/web/src/lib/expert-citations.ts: Pure types, stricthttp:/https:URL sanitizer (sanitizeCitationUrl), locale-aware raw score formatter (formatCitationRawScore), row normalizer/deduplicator (normalizeExpertCitationRows), and explicit public column projection (EXPERT_CITATION_PUBLIC_SELECTomitting internalverified_by/metadatato match column-scopedanongrants).apps/web/src/lib/rate-api.ts&apps/web/src/server/rate/index.ts: Cached server readergetCachedMasterProductExpertCitationswith gracefulMISSING_SCHEMA_CODES(42P01,42703,PGRST200,PGRST204,PGRST205) fallback returning[]before migration rollout, while propagating genuine DB outages.apps/web/src/components/reviews/JReviewsSection.tsx&apps/web/src/app/[locale]/smartphones/[slug]/page.tsx: Renders cited source count<Badge>, publication name, raw score, normalized/10score, publication date, and directrel="noopener noreferrer"links inside theĐiểm chuyên giacard, preserving#2009's concise empty state and zero "Rate Lab" branding.apps/web/src/app/api/v1/rate/products/[slug]/route.ts&apps/web/src/server/rate/openapi.ts: Exposesexpert_score_10andexpert_citationscleanly.apps/web/locales/{vi,en,cs}.json: AddsexpertSourcesCountBadge,expertSourceLinkLabel,expertSourceRawLabelwith full placeholder parity and zero em/en-dashes.apps/web/src/lib/__tests__/expert-citations.test.ts+ extendedreview-display.test.tsandspec-scope.test.ts.Verification (Lightweight Local Checks; Cloud CI runs E2E)
pnpm --filter web exec tsc --noEmit: passedpnpm --filter web test: passedpnpm --filter web lint(--max-warnings 0): passedpnpm --filter web build: passed (35/35 static pages)Closes #2031
Refs #2019
Claimant: antigravity:6882bcaf-c72a-491c-9d10-b07094104c2c
---
<!-- dos-pr-summary -->
📌 TL;DR
This PR introduces a new "Expert Citations" feature that displays external expert review sources (e.g., RTINGS, Notebookcheck) on product detail pages and the public API. It includes robust data sanitization (URL validation, schema-migration fallbacks), localized formatting for raw/normalized scores, and comprehensive unit/integration tests.
🎯 Type of Change
🔍 Changes Walkthrough
| File | Summary of Changes |
| :--- | :--- |
|
apps/web/locales/{cs,en,vi}.json| Added i18n keys for source count badges, outbound link labels, and raw score formatting. ||
apps/web/package.json| Registered the newexpert-citations.test.tssuite in thetestscript. ||
apps/web/src/lib/expert-citations.ts| New Core Library: Defines types, explicit SQL column projections, URL sanitization (blockingjavascript:,data:, etc.), score formatting utilities, and row normalization logic (deduplication, filtering inactive/draft sources). ||
apps/web/src/lib/__tests__/expert-citations.test.ts| New Test Suite: Validates URL sanitization, score formatting across locales, row normalization, and integration with the PostgREST API (including schema-migration error handling). ||
apps/web/src/lib/__tests__/review-display.test.ts| Extended existing tests to verify the new citation UI renders correctly, handles unsafe URLs, and preserves empty states. ||
apps/web/src/app/api/v1/rate/products/[slug]/route.ts| Updated the public API endpoint to fetch expert citations and exposeexpert_score_10andexpert_citationsin the response payload. ||
apps/web/src/app/api/v1/rate/__tests__/spec-scope.test.ts| Updated API contract tests to assert the presence of the newexpert_citationsandexpert_score_10fields. ||
apps/web/src/app/[locale]/smartphones/[slug]/page.tsx| Updated the product detail page to fetch expert citations (with timing instrumentation) and pass them to the reviews component. ||
apps/web/src/components/reviews/JReviewsSection.tsx| Updated the reviews UI to render a list of expert citations (max 5), including source name, raw score, normalized score, publication date, and a safe external link. Added a source count badge. |📊 Architectural Flow
<!-- /dos-pr-summary -->