[object Object]

← back to Dw Unbuyable Recovery Pilot

Remove hardcoded Meilisearch credential from Momentum audit

e31ba0892d32ba0048f962ca84b2bd5cc05a43db · 2026-09-02 16:19:12 -0700 · Steve Abrams

Files touched

Diff

commit e31ba0892d32ba0048f962ca84b2bd5cc05a43db
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Sep 2 16:19:12 2026 -0700

    Remove hardcoded Meilisearch credential from Momentum audit
---
 tk11040-momentum-reconcile/measure-match.mjs | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/tk11040-momentum-reconcile/measure-match.mjs b/tk11040-momentum-reconcile/measure-match.mjs
new file mode 100644
index 0000000..863cc45
--- /dev/null
+++ b/tk11040-momentum-reconcile/measure-match.mjs
@@ -0,0 +1,28 @@
+// TK-11040 unblock: measure how many of the 199 PR-Momentum non-joiners produce a
+// HIGH-CONFIDENCE feed match (exact pattern_name + exact color). READ-ONLY.
+import { execSync } from 'node:child_process';
+const HOST='https://ms-e886719d86e7-4256.sfo.meilisearch.io';
+const KEY=process.env.MEILISEARCH_API_KEY;
+if(!KEY) throw new Error('MEILISEARCH_API_KEY is required');
+const norm=s=>(s||'').toUpperCase().replace(/[^A-Z0-9]/g,'');
+const rows=JSON.parse(execSync(`psql -h /tmp -d dw_unified -tA -c "
+  select json_agg(json_build_object('pid',regexp_replace(shopify_id,'.*/',''),'mfr',mfr_sku,'title',title))
+  from shopify_products sp
+  where sp.vendor='Phillipe Romano' and sp.status='ACTIVE' and not coalesce(sp.has_product_variant,false) and sp.supplier_name ~* 'mom'
+    and not exists (select 1 from momentum_colorways m where (upper(m.alt_sku)=upper(sp.mfr_sku) or upper(m.momentum_sku)=upper(sp.mfr_sku) or upper(m.dw_sku)=upper(sp.dw_sku)) and m.hw_price>0)"`,{encoding:'utf8'}).trim());
+async function feed(q){const r=await fetch(`${HOST}/indexes/redesign-colors/search`,{method:'POST',headers:{Authorization:`Bearer ${KEY}`,'Content-Type':'application/json'},body:JSON.stringify({q,limit:20})});return (await r.json()).hits||[];}
+let confident=0, ambiguous=0, none=0; const samples=[];
+for(const r of rows){
+  // title: "<Pattern>-<Colorway> <Type/DurableVinyl...> | Phillipe Romano"
+  const base=r.title.split('|')[0].replace(/\b(Durable Vinyl|Vinyl|Type 2|Natural|Wallcovering|Memo Sample)\b/gi,'').trim();
+  const seg=base.split('-').map(s=>s.trim()).filter(Boolean);
+  const pat=seg[0]||'', col=seg.slice(1).join(' ')||'';
+  const hits=await feed(`${pat} ${col}`);
+  // high-confidence: exactly one hit whose (pattern_name matches pat) AND (preferred_color_name matches col), with a price
+  const exact=hits.filter(h=>(norm(h.pattern_name)===norm(pat) && norm(h.preferred_color_name)===norm(col) && h.price>0));
+  if(exact.length===1){confident++; if(samples.length<8)samples.push(`OK  ${r.mfr}  "${pat}"/"${col}" -> ${exact[0].pattern_name}/${exact[0].preferred_color_name} #${exact[0].number} $${exact[0].price}`);}
+  else if(hits.some(h=>h.price>0)){ambiguous++; if(samples.filter(s=>s.startsWith('AMB')).length<4)samples.push(`AMB ${r.mfr}  "${pat}"/"${col}" -> ${hits.length} hits, ${exact.length} exact`);}
+  else {none++;}
+}
+console.log(`total=${rows.length}  CONFIDENT(exact 1)=${confident}  AMBIGUOUS=${ambiguous}  NO-MATCH=${none}`);
+console.log(samples.join('\n'));

← defc1cb TK-10978: Rebel Walls RS-orphan archive complete — 455/455 (  ·  back to Dw Unbuyable Recovery Pilot  ·  Record E2E proof for credential containment c3a2933 →