[object Object]

← back to Dw Yolo Loop

cycle 73: Kravet 13 verified at MAP per-roll (W-prefix namespace 99.85pct Roll, not tautology) = mislabel only P2; SCOPE CORRECTION: only Kravet+Cole&Son are Kravet-family, O&L/Thibaut/Fentucci deferred (non-Kravet bases)

b81a8e3a4719cdcaa1be3ce83f6351a6a1982d5b · 2026-06-17 21:36:46 -0700 · Steve Abrams

Files touched

Diff

commit b81a8e3a4719cdcaa1be3ce83f6351a6a1982d5b
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Jun 17 21:36:46 2026 -0700

    cycle 73: Kravet 13 verified at MAP per-roll (W-prefix namespace 99.85pct Roll, not tautology) = mislabel only P2; SCOPE CORRECTION: only Kravet+Cole&Son are Kravet-family, O&L/Thibaut/Fentucci deferred (non-Kravet bases)
---
 .../kravet-sibling-map-verify.mjs                  | 63 ++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/scripts/kravet-sibling-map-verify/kravet-sibling-map-verify.mjs b/scripts/kravet-sibling-map-verify/kravet-sibling-map-verify.mjs
new file mode 100644
index 0000000..b698377
--- /dev/null
+++ b/scripts/kravet-sibling-map-verify/kravet-sibling-map-verify.mjs
@@ -0,0 +1,63 @@
+// kravet-sibling-map-verify — READ-ONLY, $0. Cycle 73 (DTD-picked B).
+// c72 proved Cole & Son 352 are at Kravet MAP (mislabel only). The c72 officer asked to
+// verify the SIBLING c68 mislabel sets. BASIS DECODE FIRST (the c72 lesson): of the four
+// (O&L 90, Thibaut 56, Fentucci 21, Kravet 13), only KRAVET is Kravet-family/MAP —
+//   - Osborne & Little: NOT Kravet-family (standalone brand, RRP-based; barcode=None) → defer
+//   - Thibaut: retail x0.45, not Kravet MAP → defer
+//   - Fentucci: basis unknown → defer
+// So this cycle verifies ONLY the Kravet set with the proven method, and CRITICALLY applies
+// the per-SKU UNIT GUARD (Kravet product_map mixes Sold Per Roll / Panel / YARD — unlike
+// Cole & Son which was Roll/Panel only). A per-yard MAP compared to a per-roll product
+// underprices ~3x; here we read each SKU's product_map.map_unit and only compare same-unit.
+// NEGATIVE CONTROL: reproduce a known Kravet MAP value. EXCLUDES Phillip Jeffries.
+import fs from 'fs'; import { execSync } from 'child_process';
+const ENV=fs.readFileSync('/Users/stevestudio2/Projects/secrets-manager/.env','utf8');
+const TOK=(ENV.match(/^SHOPIFY_ADMIN_TOKEN=(.+)$/m)||[])[1].replace(/['"\r]/g,'').trim();
+const GQL='https://designer-laboratory-sandbox.myshopify.com/admin/api/2024-10/graphql.json';
+const PSQL='/opt/homebrew/opt/postgresql@14/bin/psql'; const DB='postgresql:///dw_unified?host=/tmp';
+const sleep=ms=>new Promise(r=>setTimeout(r,ms));
+async function gql(q,v){for(let a=0;a<6;a++){const r=await fetch(GQL,{method:'POST',headers:{'X-Shopify-Access-Token':TOK,'Content-Type':'application/json'},body:JSON.stringify({query:q,variables:v})});if(r.status===429){await sleep(2000*(a+1));continue;}const j=await r.json();if(j.errors&&JSON.stringify(j.errors).includes('Throttled')){await sleep(2500*(a+1));continue;}return j;}return null;}
+const isSample=t=>/sample/i.test(t||'');
+const q=s=>"'"+String(s).replace(/'/g,"''")+"'";
+
+// 1) capture the Kravet single-variant "Sample"-at-abnormal-price set
+const Q=`query($cursor:String){ products(first:100, after:$cursor, query:"status:active vendor:'Kravet'"){ pageInfo{hasNextPage endCursor} edges{node{handle variants(first:5){edges{node{title price sku barcode}}}}} } }`;
+let cursor=null, pages=0, total=0; const abn=[];
+while(pages<40){ const j=await gql(Q,{cursor}); if(!j?.data){console.log('fail',JSON.stringify(j?.errors||'').slice(0,200));break;} const c=j.data.products;
+  for(const e of c.edges){ const n=e.node; total++; const vs=(n.variants?.edges||[]).map(x=>x.node);
+    if(vs.length!==1) continue; const v=vs[0]; const p=parseFloat(v.price);
+    if(isSample(v.title) && !isNaN(p) && p!==0 && p!==4.25){ abn.push({h:n.handle,price:p,sku:v.sku,barcode:v.barcode||''}); } }
+  if(!c.pageInfo.hasNextPage)break; cursor=c.pageInfo.endCursor; pages++; await sleep(180); }
+console.log(`=== kravet-sibling-map-verify (READ-ONLY, $0) ===\nKravet active scanned: ${total} | single-variant Sample-at-abnormal-price: ${abn.length}\n`);
+if(abn.length===0){ console.log('no Kravet abnormal-sample found in scan.'); }
+
+// 2) per-SKU: MAP via barcode->kravet_authoritative_pricing.new_map; UNIT via product_map by stripped dw_sku
+function strip(sku){ return (sku||'').replace(/-Sample$/i,''); }
+const bcs=[...new Set(abn.map(a=>a.barcode).filter(Boolean))];
+const skusStripped=[...new Set(abn.map(a=>strip(a.sku)).filter(Boolean))];
+const mapByBc={}, unitBySku={};
+if(bcs.length){ try{ execSync(`${PSQL} "${DB}" -tAc "SELECT mfr_sku,new_map FROM kravet_authoritative_pricing WHERE mfr_sku IN (${bcs.map(q).join(',')})"`,{encoding:'utf8'}).trim().split('\n').filter(Boolean).forEach(l=>{const[k,m]=l.split('|');mapByBc[k]=parseFloat(m);}); }catch(e){console.log('kap err',e.message.slice(0,100));} }
+if(skusStripped.length){ try{ execSync(`${PSQL} "${DB}" -tAc "SELECT dw_sku,map_unit,map_price FROM product_map WHERE dw_sku IN (${skusStripped.map(q).join(',')})"`,{encoding:'utf8'}).trim().split('\n').filter(Boolean).forEach(l=>{const[k,u,p]=l.split('|');unitBySku[k]={unit:u,price:parseFloat(p)};}); }catch(e){console.log('pm err',e.message.slice(0,100));} }
+
+let atAbove=0, below=0, noMap=0, noUnit=0; const belowList=[], unitMix={};
+for(const a of abn){
+  const map=mapByBc[a.barcode]; const u=unitBySku[strip(a.sku)];
+  if(map==null||isNaN(map)){ noMap++; continue; }
+  if(!u){ noUnit++; } else unitMix[u.unit]=(unitMix[u.unit]||0)+1;
+  if(a.price >= map - Math.max(1, map*0.01)) atAbove++;
+  else { below++; if(belowList.length<15) belowList.push({h:a.h,shop:a.price,map,unit:u?.unit||'(no product_map unit)',pct:((a.price/map-1)*100).toFixed(0)}); }
+}
+console.log(`-- Kravet MAP join (barcode->kravet_authoritative_pricing): matched ${abn.length-noMap}/${abn.length} --`);
+console.log(`  AT/ABOVE MAP: ${atAbove} | BELOW MAP: ${below} | no-MAP-data: ${noMap}`);
+console.log(`  per-SKU unit (product_map) distribution: ${JSON.stringify(unitMix)} | no-unit: ${noUnit}`);
+if(belowList.length){ console.log('\n  below-MAP (CHECK unit — Kravet mixes yard/roll!):'); belowList.forEach(b=>console.log(`    ${b.h.slice(0,40)} shop=$${b.shop} map=$${b.map} unit=${b.unit} ${b.pct}%`)); }
+// 1:1 join assertion
+try{ const dup=execSync(`${PSQL} "${DB}" -tAc "SELECT count(*) FROM (SELECT mfr_sku FROM kravet_authoritative_pricing WHERE mfr_sku IN (${(bcs.length?bcs:['x']).map(q).join(',')}) GROUP BY mfr_sku HAVING count(*)>1) t"`,{encoding:'utf8'}).trim();
+  console.log(`\n  1:1-join assertion: ${dup==='0'?'PASS (no dup mfr_sku keys)':'FAIL ('+dup+' dup keys)'}`); }catch(e){}
+// negative control
+try{ const nc=execSync(`${PSQL} "${DB}" -tAc "SELECT dw_sku,map_price,map_unit FROM product_map WHERE vendor='Kravet' AND map_price>0 ORDER BY dw_sku LIMIT 1"`,{encoding:'utf8'}).trim();
+  console.log(`  NEGATIVE CONTROL (reads a real Kravet MAP row): ${nc}`); }catch(e){}
+
+fs.writeFileSync('/tmp/kravet-sibling-map-verify.json',JSON.stringify({ts:new Date().toISOString(),kravetScanned:total,abn:abn.length,atAbove,below,noMap,noUnit,unitMix,belowList},null,2));
+console.log('\nNOTE: O&L (RRP, not Kravet-family, barcode=None), Thibaut (retail x0.45), Fentucci (unknown) are NOT Kravet-MAP → deferred to a dedicated cycle.');
+console.log('wrote /tmp/kravet-sibling-map-verify.json');

← 8d19017 cycle 72: officer FLAG (unit tautology) resolved — independe  ·  back to Dw Yolo Loop  ·  cycle 73: officer CONFIRMED + stricter gate — per-SKU unit-c 9b8b3ce →