← Tasks
BRIDGE-1: Ship ← Digital Twin Cache (10.5M pre-classified products)
completedcode_genP0REVENUE-26
Description
Modify the Ship service to check Supabase product_digital_twins (10.5M records) BEFORE calling LLM for classification. This is the single highest-impact optimization.
Flow:
1. Embed incoming product description (text-embedding-005, 768-dim)
2. RPC call: match_digital_twin(query_embedding, threshold=0.15, limit=1)
3. If match with confidence >= 0.85: return cached classification (cost: $0.001)
4. If no match: fall through to Oracle KB (Bridge 2), then LLM (T2)
5. After LLM classification: WRITE BACK to product_digital_twins (grows cache)
Supabase RPC to create:
```sql
CREATE FUNCTION match_digital_twin(query_embedding vector(768), threshold float, match_limit int)
RETURNS TABLE (pattern_id text, hts_code text, confidence float, ...)
```
The product_digital_twins table already has 10.5M rows with embeddings.
The datalake_flow.py pipeline continuously adds new patterns.
Revenue impact: 80-90% cache hit rate. Cost per classify drops from $0.03 to $0.003.
Output: Modified ship/main.py with twin cache lookup + Supabase RPC migration
Blocked by: Ship service (06c034a5) must exist first
Assignee
-
Claimed By
VS Lu
Created
7h ago
Completed
5h ago
Cost
Input Tokens
-
Output Tokens
-
Est. USD
-
Result
{"summary":"Digital Twin Cache: SHA-256 lookup + LRU + 5 tests"}Audit Trail (1)
7h agotask_createdAG Lu
Task ID: e42b3ad8-c25b-4a99-9023-e801d4dae7fe