[object Object]

← back to Wallco Ai

fix(learn-and-purge): PG-side vendor-cat safety net

78cd6dfcc0a6f8174311f11fc4b6bd72bfeb2a4c · 2026-05-24 22:29:48 -0700 · Steve Abrams

The flagged.jsonl's 'category' field is set when the scanner runs and can drift
from the PG row's CURRENT category. The 2026-05-24 vendor-unpublish incident
happened because the flagged file tagged ids 86, 108, 110-112, 116, 123 as
'archive' / 'graduate-collection' / 'malibu-wallpaper' — but on PG those same
ids carry 'phillipe-romano', 'maya-romanoff', 'ralph-lauren', 'koroseal',
'coordonn-', 'glitter-walls'. The file-side category scrub missed them.

This patch re-checks every queued row's CURRENT PG category against VENDOR_CATS
right before the apply step and skips any that match. Belt-and-suspenders on top
of the scanner's input-side filter from 67eac74.

Files touched

Diff

commit 78cd6dfcc0a6f8174311f11fc4b6bd72bfeb2a4c
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Sun May 24 22:29:48 2026 -0700

    fix(learn-and-purge): PG-side vendor-cat safety net
    
    The flagged.jsonl's 'category' field is set when the scanner runs and can drift
    from the PG row's CURRENT category. The 2026-05-24 vendor-unpublish incident
    happened because the flagged file tagged ids 86, 108, 110-112, 116, 123 as
    'archive' / 'graduate-collection' / 'malibu-wallpaper' — but on PG those same
    ids carry 'phillipe-romano', 'maya-romanoff', 'ralph-lauren', 'koroseal',
    'coordonn-', 'glitter-walls'. The file-side category scrub missed them.
    
    This patch re-checks every queued row's CURRENT PG category against VENDOR_CATS
    right before the apply step and skips any that match. Belt-and-suspenders on top
    of the scanner's input-side filter from 67eac74.
---
 scripts/learn-and-purge-flagged.js | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/scripts/learn-and-purge-flagged.js b/scripts/learn-and-purge-flagged.js
index 241b09a..37bd4c0 100755
--- a/scripts/learn-and-purge-flagged.js
+++ b/scripts/learn-and-purge-flagged.js
@@ -96,8 +96,27 @@ function main() {
 
   // Filter to rows STILL is_published=TRUE (the actual work).
   let queue = [...rowsById.values()].filter(r => r.is_published === true);
+
+  // SAFETY NET (added 2026-05-24 after the vendor-unpublish incident):
+  // the flagged.jsonl's category metadata is set when the SCAN runs and can
+  // drift from the PG row's CURRENT category. The script must NEVER touch a
+  // vendor SKU regardless of what flagged.jsonl says. Re-check every queued
+  // row's CURRENT PG category against VENDOR_CATS.
+  const VENDOR_CATS = new Set([
+    'thibaut','dolce-gabbana','koroseal','graduate-collection','traditional-whimsy',
+    'phillipe-romano','coordonn-','ralph-lauren','mind-the-gap','designer-wallcoverings',
+    'malibu-wallpaper','maya-romanoff','roberto-cavalli-wallpaper','china-seas',
+    'daisy-bennett','glitter-walls','dw-shopify','archive',
+  ]);
+  const blocked = queue.filter(r => VENDOR_CATS.has((r.category || '').toLowerCase()));
+  if (blocked.length) {
+    console.log(`[learn-purge] BLOCKED ${blocked.length} vendor-category rows from cleanup:`);
+    for (const b of blocked.slice(0, 10)) console.log(`  ✗ id=${b.id}  cat=${b.category}`);
+    queue = queue.filter(r => !VENDOR_CATS.has((r.category || '').toLowerCase()));
+  }
+
   if (LIMIT > 0) queue = queue.slice(0, LIMIT);
-  console.log(`[learn-purge] still-published targets: ${queue.length}`);
+  console.log(`[learn-purge] still-published targets (post-vendor-block): ${queue.length}`);
 
   // Sample the first 5 so you can sanity-check before --apply.
   console.log('[learn-purge] sample (first 5):');

← 1a05f4b joint-fix: surgical seam repair (95%-preserve, edges only)  ·  back to Wallco Ai  ·  scripts: scan-frame-overlay.js — catalog sweep for the new d 641da47 →