Product Traceability System - Developer Guide
⚠️ CRITICAL ARCHITECTURE NOTICE
Hash-Only Mode (Default since 2024)
The Product Trace API now uses Hash-Only Mode by default, which provides deterministic, millisecond-level matching based on barcode and OCR text hashes:
Hash-Only Mode Pipeline (Default)
├── 🔴 Stage 1: Barcode Exact Match (<10ms)
│ └── Match success → Direct confirm, terminate early
├── 🟡 Stage 2: Text Hash Match (<10ms)
│ └── Text hash 100% match → Direct confirm
└── ❌ No match → Return verified=false
To enable legacy visual similarity matching, set environment variable SCAN_HASH_ONLY_MODE=false.
Legacy Mode (Visual Similarity)
Deprecation Notice
Legacy mode with DINOv2 visual features is deprecated and should only be used when:
- Products have no barcode or OCR text
- Visual similarity matching is specifically required
DINOv2 global features CANNOT be used for final product verification alone.
Test Results (Synthetic Products):
| Metric | Value | Production Requirement |
|---|---|---|
| False Positive Rate | 100% | < 0.1% |
| Same Product Similarity | 0.877 | > 0.9 |
| Different Product Similarity | 0.811 | < 0.5 |
| Classification Margin | 0.066 | > 0.3 |
Root Cause:
DINOv2 extracts global semantic features - products with similar colors/patterns produce highly overlapping feature vectors. The 0.066 margin is insufficient for reliable discrimination.