← back to Ticket System
data/claude-run-11256/evidence/canary.mjs.diff
34 lines
28a29,32
> // Shopify appends a GUID suffix on re-upload of the same asset (e.g. "..._2df9_6aed8978-...-c7bc33a3d68d.jpg");
> // stripping it lets us compare the underlying DAM asset identity, not the re-upload artifact.
> const GUID_RE=/_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(\.[a-zA-Z]+)$/;
> function stripGuid(fn){ return fn.replace(GUID_RE,'$1'); }
49a54,72
> function ownStagingFiles(vendors){
> // Per-SKU precision check (fixes a confirmed false-positive class, TK-11256 2026-09-05:
> // review12_verdicts.jsonl vision-adjudicated 7 "KEEP" cases where the flagged gallery
> // image WAS the SKU's own staging main/gallery asset, but the coarse token() bucket
> // let a DIFFERENT colorway's similarly-prefixed asset claim it in the global home map).
> // Returns {mfr_sku: Set(stripGuid(filename))} — own-file identity, no cross-SKU bucketing.
> const own={};
> for(const v of vendors){ const cfg=STAGING[v]; if(!cfg) continue;
> let rows='';
> try{ rows=execSync(`/opt/homebrew/bin/psql -h /tmp dw_unified -t -A -F'|' -c "SELECT ${cfg.sku}, coalesce(${cfg.main},''), array_to_string(${cfg.gallery},'~~') FROM ${cfg.table};"`,{encoding:'utf8'}); }catch(e){ continue; }
> for(const line of rows.split('\n')){ const p=line.split('|'); if(p.length<3) continue;
> const sku=p[0].trim(); if(!sku) continue;
> const set=own[sku]=own[sku]||new Set();
> if(p[1]) set.add(stripGuid(fname(p[1])));
> for(const g of p[2].split('~~')) if(g.trim()) set.add(stripGuid(fname(g)));
> }
> }
> return own;
> }
88a112,113
> // per-SKU own-file precision map (checked BEFORE the coarse token-bucket fallback below)
> const ownFiles=ownStagingFiles(VENDORS);
106a132,135
> if(c==='skuless'){ // highest-precision check: is this literally the SKU's own staging file?
> const own=ownFiles[psku];
> if(own && own.has(stripGuid(f))) c='own';
> }