[object Object]

← back to Designerwallcoverings

TK-11226 DTD-A residual: upgrade 10 PR products synth->real mfr# (Xref-B)

72708b7ba32ac50c454857ce76253fca5c8d1328 · 2026-09-04 10:03:24 -0700 · Steve Abrams

The 227-remainder run left 143 PR products on the synth (mfr#=DW SKU) fallback.
DRY-RUN proved the tables first hypothesized as the code source
(studio_printworks_catalog / justindavid_catalog / daisy_bennett_printed_catalog /
flocked_products) join 0 of them; the recoverable real codes live in dw_mfr_crossref
under three prefixes Xref-A's allowlist missed (DWT-/GRS-/DWGB-). Added the Xref-B
source + a surgical reversible overwrite runner.

Applied: 10 collision-free synth->real overwrites (DWT 8 -> PHR-100..800,
GRS 2 -> A41/B22). The other 133 correctly STAY synth per DTD-A: 123 genuinely
code-less (DWRT 113 descriptive-title screen-prints + Flock/PRINT/DWWC/WOOD/DWPX)
and 10 whose real code collides cross-vendor (DWGB 3/DWC 1/DWJJ 6 -> would flip both
products to the canary fake_mfr). Superseded the pending 143->blank REVERSE memo.

Verified live: all 10 carry real custom+dwc codes; PR blank-mfr ACTIVE = 0;
dw-golive-gate WARN 0 FAIL recent_fail=0 (WARN = steady legacy backlog ~1878).
Reversible via rollback.mjs on restore-map-pr-DTDA-real-*.jsonl.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ShbJhX5gUwEvpG3v8E3LWE

Files touched

Diff

commit 72708b7ba32ac50c454857ce76253fca5c8d1328
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Fri Sep 4 10:03:24 2026 -0700

    TK-11226 DTD-A residual: upgrade 10 PR products synth->real mfr# (Xref-B)
    
    The 227-remainder run left 143 PR products on the synth (mfr#=DW SKU) fallback.
    DRY-RUN proved the tables first hypothesized as the code source
    (studio_printworks_catalog / justindavid_catalog / daisy_bennett_printed_catalog /
    flocked_products) join 0 of them; the recoverable real codes live in dw_mfr_crossref
    under three prefixes Xref-A's allowlist missed (DWT-/GRS-/DWGB-). Added the Xref-B
    source + a surgical reversible overwrite runner.
    
    Applied: 10 collision-free synth->real overwrites (DWT 8 -> PHR-100..800,
    GRS 2 -> A41/B22). The other 133 correctly STAY synth per DTD-A: 123 genuinely
    code-less (DWRT 113 descriptive-title screen-prints + Flock/PRINT/DWWC/WOOD/DWPX)
    and 10 whose real code collides cross-vendor (DWGB 3/DWC 1/DWJJ 6 -> would flip both
    products to the canary fake_mfr). Superseded the pending 143->blank REVERSE memo.
    
    Verified live: all 10 carry real custom+dwc codes; PR blank-mfr ACTIVE = 0;
    dw-golive-gate WARN 0 FAIL recent_fail=0 (WARN = steady legacy backlog ~1878).
    Reversible via rollback.mjs on restore-map-pr-DTDA-real-*.jsonl.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01ShbJhX5gUwEvpG3v8E3LWE
---
 scripts/mfr-backfill-tk10162/backfill-mfr.mjs      |  19 +++
 ...map-pr-DTDA-real-2026-09-04T16-59-57-879Z.jsonl |  10 ++
 .../overwrite-real-tk11226.mjs                     | 132 +++++++++++++++++++++
 3 files changed, 161 insertions(+)

diff --git a/scripts/mfr-backfill-tk10162/backfill-mfr.mjs b/scripts/mfr-backfill-tk10162/backfill-mfr.mjs
index 89fe0ba..859322f 100644
--- a/scripts/mfr-backfill-tk10162/backfill-mfr.mjs
+++ b/scripts/mfr-backfill-tk10162/backfill-mfr.mjs
@@ -97,6 +97,25 @@ const VENDORS = {
               AND mfr_sku NOT ILIKE '%DO NOT USE%' AND mfr_sku NOT ILIKE '%.jpg%' AND mfr_sku NOT ILIKE '%.png%'
               AND mfr_sku NOT ILIKE '%.webp%' AND mfr_sku NOT ILIKE '%wallpaper%' AND mfr_sku NOT ILIKE '%install%'
               AND length(split_part(mfr_sku,' ',1)) BETWEEN 3 AND 24` },
+          // TK-11226 residual (DTD-A, 2026-09-04) — the 227-remainder run left 143 products on the
+          // synth (mfr#=DW SKU) fallback. A DRY-RUN proved the tables first hypothesized as the code
+          // source (studio_printworks_catalog / justindavid_catalog / daisy_bennett_printed_catalog /
+          // flocked_products) join 0 of them (their dw_sku scheme is DWPQ-/DWPR-, and flocked_products
+          // Flock-70xx images are hash filenames with no VV code). The genuinely-recoverable real codes
+          // for the remaining PR house sub-labels live in dw_mfr_crossref under three MORE prefixes that
+          // Xref-A's allowlist did not cover: DWT- (Placido pleated grasscloth -> PHR-###), GRS- (Hollywood
+          // abaca grasscloth -> A41/B22), DWGB- (-> 6-digit codes). Same digit-in-first-token + junk filters
+          // as Xref-A, so DWRT descriptive titles ("Agate Place ... Wallpaper") still fall through to synth.
+          // The 6-digit DWGB codes + short DWJJ numerics collide cross-vendor -> the collision guard remaps
+          // them back to synth automatically (never emits a shared code). Verified: resolves DWT 8 + GRS 2
+          // as collision-free real codes; DWGB 3 collide -> synth.
+          { name: 'Xref-B', sql: `SELECT COALESCE(NULLIF(dw_sku_dash,''),dw_sku) AS dw_sku, split_part(mfr_sku,' ',1) AS mfr
+            FROM dw_mfr_crossref
+            WHERE upper(COALESCE(NULLIF(dw_sku_dash,''),dw_sku)) ~ '^(DWT-|DWGB-|GRS-)'
+              AND mfr_sku IS NOT NULL AND mfr_sku<>'' AND split_part(mfr_sku,' ',1) ~ '[0-9]'
+              AND mfr_sku NOT ILIKE '%DO NOT USE%' AND mfr_sku NOT ILIKE '%.jpg%' AND mfr_sku NOT ILIKE '%.png%'
+              AND mfr_sku NOT ILIKE '%.webp%' AND mfr_sku NOT ILIKE '%wallpaper%' AND mfr_sku NOT ILIKE '%install%'
+              AND length(split_part(mfr_sku,' ',1)) BETWEEN 2 AND 24` },
         ],
         // TK-11226 remainder — Bucket B (~136): the rest of the PR flagged set is genuinely
         // code-LESS / DW-house-numbered (DWRT-90xx "Phillipe Romano Screen Prints", WOOD bespoke,
diff --git a/scripts/mfr-backfill-tk10162/out/restore-map-pr-DTDA-real-2026-09-04T16-59-57-879Z.jsonl b/scripts/mfr-backfill-tk10162/out/restore-map-pr-DTDA-real-2026-09-04T16-59-57-879Z.jsonl
new file mode 100644
index 0000000..1bad98f
--- /dev/null
+++ b/scripts/mfr-backfill-tk10162/out/restore-map-pr-DTDA-real-2026-09-04T16-59-57-879Z.jsonl
@@ -0,0 +1,10 @@
+{"id":"gid://shopify/Product/7863152574515","dwsku":"GRS-32041","prev":"GRS-32041","wrote":"A41","src":"Xref-B","ts":"2026-09-04T16-59-57-879Z"}
+{"id":"gid://shopify/Product/7863494344755","dwsku":"GRS-32064","prev":"GRS-32064","wrote":"B22","src":"Xref-B","ts":"2026-09-04T16-59-57-879Z"}
+{"id":"gid://shopify/Product/1496930910320","dwsku":"DWT-54008","prev":"DWT-54008","wrote":"PHR-100","src":"Xref-B","ts":"2026-09-04T16-59-57-879Z"}
+{"id":"gid://shopify/Product/1496931139696","dwsku":"DWT-54009","prev":"DWT-54009","wrote":"PHR-200","src":"Xref-B","ts":"2026-09-04T16-59-57-879Z"}
+{"id":"gid://shopify/Product/1496931336304","dwsku":"DWT-54010","prev":"DWT-54010","wrote":"PHR-300","src":"Xref-B","ts":"2026-09-04T16-59-57-879Z"}
+{"id":"gid://shopify/Product/1496931467376","dwsku":"DWT-54011","prev":"DWT-54011","wrote":"PHR-400","src":"Xref-B","ts":"2026-09-04T16-59-57-879Z"}
+{"id":"gid://shopify/Product/1496931696752","dwsku":"DWT-54012","prev":"DWT-54012","wrote":"PHR-500","src":"Xref-B","ts":"2026-09-04T16-59-57-879Z"}
+{"id":"gid://shopify/Product/1496931795056","dwsku":"DWT-54013","prev":"DWT-54013","wrote":"PHR-600","src":"Xref-B","ts":"2026-09-04T16-59-57-879Z"}
+{"id":"gid://shopify/Product/1496931893360","dwsku":"DWT-54014","prev":"DWT-54014","wrote":"PHR-700","src":"Xref-B","ts":"2026-09-04T16-59-57-879Z"}
+{"id":"gid://shopify/Product/1496932057200","dwsku":"DWT-54015","prev":"DWT-54015","wrote":"PHR-800","src":"Xref-B","ts":"2026-09-04T16-59-57-879Z"}
diff --git a/scripts/mfr-backfill-tk10162/overwrite-real-tk11226.mjs b/scripts/mfr-backfill-tk10162/overwrite-real-tk11226.mjs
new file mode 100644
index 0000000..1937a8c
--- /dev/null
+++ b/scripts/mfr-backfill-tk10162/overwrite-real-tk11226.mjs
@@ -0,0 +1,132 @@
+#!/usr/bin/env node
+/**
+ * TK-11226 residual (DTD-A, 2026-09-04) — surgical synth->real OVERWRITE for the 10
+ * Phillipe Romano remainder products whose genuine manufacturer code was recovered from
+ * dw_mfr_crossref (Xref-B prefixes DWT-/GRS-) and is collision-free cross-vendor.
+ *
+ * WHY a separate runner (not backfill-mfr.mjs --apply): the 227-remainder run already wrote
+ * a synth value (mfr# = DW SKU) to all 143 code-less/other-sublabel products, so they are NOT
+ * blank — backfill-mfr.mjs's fetchFlagged (blank-only) returns 0. DTD-A upgrades the 10 that
+ * have a real code from synth -> real; the other 133 (123 genuinely code-less DWRT/Flock/etc +
+ * 10 whose real code collides cross-vendor: DWGB/DWC/DWJJ) correctly STAY on synth per DTD-A
+ * ("synth mfr# = DW SKU for the genuinely code-less remainder").
+ *
+ * SAFETY / REVERSIBILITY (mirrors backfill-mfr.mjs):
+ *   - DRY-RUN by default; --apply required to write (Steve pre-approved TK-11226 DTD-A).
+ *   - Blast radius = exactly 10 products (20 metafields, one metafieldsSet call, under the 25 cap).
+ *   - Snapshots the LIVE current value (the synth DW SKU) as prev -> restore-map JSONL in the
+ *     exact schema rollback.mjs restores (prev non-null -> put the synth value back on custom+dwc).
+ *   - LIVE re-guards before writing: (a) current custom/dwc value must equal the synth DW SKU
+ *     (== dwsku) — if a product already carries the real code or an unexpected value, SKIP it;
+ *     (b) the real code must not resolve as a manufacturer_sku under any OTHER active vendor —
+ *     if it collides, SKIP (never flip both products to the canary's cross-vendor fake_mfr).
+ *   - Opaque codes only (PHR-### is the DW house brand's own code, A41/B22 grasscloth) — no
+ *     private-label leak; vendor stays 'Phillipe Romano'.
+ *
+ * Usage: node overwrite-real-tk11226.mjs [--apply]
+ */
+import { execFileSync } from 'node:child_process';
+import fs from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const OUT = path.join(__dirname, 'out');
+fs.mkdirSync(OUT, { recursive: true });
+const DB = 'postgresql:///dw_unified?host=/tmp';
+const STORE = process.env.SHOPIFY_STORE || 'designer-laboratory-sandbox.myshopify.com';
+const TOKEN = process.env.SHOPIFY_ADMIN_TOKEN;
+const API = '2024-10';
+const APPLY = process.argv.includes('--apply');
+if (!TOKEN) { console.error('SHOPIFY_ADMIN_TOKEN not set (source ~/Projects/secrets-manager/.env)'); process.exit(1); }
+
+// The 10 collision-free real writes, verified live 2026-09-04 (all currently carry synth = DW SKU).
+const WRITES = [
+  { id: 'gid://shopify/Product/7863152574515', dwsku: 'GRS-32041', mfr: 'A41' },
+  { id: 'gid://shopify/Product/7863494344755', dwsku: 'GRS-32064', mfr: 'B22' },
+  { id: 'gid://shopify/Product/1496930910320', dwsku: 'DWT-54008', mfr: 'PHR-100' },
+  { id: 'gid://shopify/Product/1496931139696', dwsku: 'DWT-54009', mfr: 'PHR-200' },
+  { id: 'gid://shopify/Product/1496931336304', dwsku: 'DWT-54010', mfr: 'PHR-300' },
+  { id: 'gid://shopify/Product/1496931467376', dwsku: 'DWT-54011', mfr: 'PHR-400' },
+  { id: 'gid://shopify/Product/1496931696752', dwsku: 'DWT-54012', mfr: 'PHR-500' },
+  { id: 'gid://shopify/Product/1496931795056', dwsku: 'DWT-54013', mfr: 'PHR-600' },
+  { id: 'gid://shopify/Product/1496931893360', dwsku: 'DWT-54014', mfr: 'PHR-700' },
+  { id: 'gid://shopify/Product/1496932057200', dwsku: 'DWT-54015', mfr: 'PHR-800' },
+];
+
+const psql = sql => execFileSync('psql', [DB, '-tAc', sql], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
+const sleep = ms => new Promise(r => setTimeout(r, ms));
+async function gql(query, variables) {
+  for (let t = 0; t < 5; t++) {
+    const res = await fetch(`https://${STORE}/admin/api/${API}/graphql.json`, {
+      method: 'POST', headers: { 'X-Shopify-Access-Token': TOKEN, 'Content-Type': 'application/json' },
+      body: JSON.stringify({ query, variables }) });
+    const j = await res.json();
+    if (j.errors && /throttl/i.test(JSON.stringify(j.errors))) { await sleep(2000 * (t + 1)); continue; }
+    return j;
+  }
+  throw new Error('gql throttled out');
+}
+
+// cross-vendor collision guard (mirrors backfill-mfr.mjs collisionSet)
+function collisionSet(codes) {
+  if (!codes.length) return new Set();
+  const list = codes.map(c => `'${String(c).replace(/'/g, "''")}'`).join(',');
+  const rows = psql(
+    `SELECT DISTINCT rm FROM (
+       SELECT COALESCE(
+         NULLIF(metafields->'dwc'->'manufacturer_sku'->>'value',''),
+         NULLIF(metafields->'custom'->'manufacturer_sku'->>'value',''),
+         NULLIF(metafields->'global'->'manufacturer_sku'->>'value',''),
+         NULLIF(mfr_sku,'')) AS rm, vendor
+       FROM shopify_products WHERE status ILIKE 'active' AND vendor NOT ILIKE '%phillipe romano%'
+     ) q WHERE rm IN (${list})`).trim().split('\n').filter(Boolean);
+  return new Set(rows.map(r => r.trim()));
+}
+
+const M_SET = `mutation($mf:[MetafieldsSetInput!]!){metafieldsSet(metafields:$mf){userErrors{field message}}}`;
+const Q_CUR = `query($ids:[ID!]!){nodes(ids:$ids){... on Product{id vendor c:metafield(namespace:"custom",key:"manufacturer_sku"){value} d:metafield(namespace:"dwc",key:"manufacturer_sku"){value}}}}`;
+
+(async () => {
+  // 1) live snapshot of current values
+  const j = await gql(Q_CUR, { ids: WRITES.map(w => w.id) });
+  const cur = new Map((j.data?.nodes || []).filter(Boolean).map(n => [n.id, n]));
+
+  // 2) collision re-check
+  const collide = collisionSet([...new Set(WRITES.map(w => w.mfr))]);
+
+  const ok = [], skip = [];
+  for (const w of WRITES) {
+    const n = cur.get(w.id);
+    const prev = (n?.c?.value ?? n?.d?.value ?? null);
+    const reason =
+      !n ? 'product not found' :
+      collide.has(w.mfr) ? `collides cross-vendor (${w.mfr})` :
+      prev !== w.dwsku ? `current value ${JSON.stringify(prev)} != expected synth ${w.dwsku}` : null;
+    if (reason) skip.push({ ...w, prev, reason });
+    else ok.push({ ...w, prev });
+  }
+
+  console.log(`[TK-11226 DTD-A overwrite] candidates=${WRITES.length}  write=${ok.length}  skip=${skip.length}`);
+  for (const w of ok) console.log(`  WRITE ${w.dwsku}  ${w.prev} -> ${w.mfr}`);
+  for (const s of skip) console.log(`  SKIP  ${s.dwsku}  (${s.reason})`);
+
+  if (!APPLY) { console.log(`\nDRY-RUN. Re-run with --apply (Steve-approved TK-11226 DTD-A) to write.`); return; }
+  if (!ok.length) { console.log('nothing to write.'); return; }
+
+  const ts = new Date().toISOString().replace(/[:.]/g, '-');
+  const restoreFile = path.join(OUT, `restore-map-pr-DTDA-real-${ts}.jsonl`);
+  const rfd = fs.openSync(restoreFile, 'a');
+  for (const w of ok) fs.writeSync(rfd, JSON.stringify({ id: w.id, dwsku: w.dwsku, prev: w.prev, wrote: w.mfr, src: 'Xref-B', ts }) + '\n');
+  fs.closeSync(rfd);
+
+  const mf = ok.flatMap(w => ([
+    { ownerId: w.id, namespace: 'custom', key: 'manufacturer_sku', type: 'single_line_text_field', value: w.mfr },
+    { ownerId: w.id, namespace: 'dwc',    key: 'manufacturer_sku', type: 'single_line_text_field', value: w.mfr },
+  ]));
+  const jw = await gql(M_SET, { mf });
+  const ue = jw.data?.metafieldsSet?.userErrors || [];
+  if (ue.length) { console.error('userErrors:', ue); process.exit(1); }
+  console.log(`\nDONE: wrote ${ok.length} products (custom+dwc real codes). restore-map: ${restoreFile}`);
+  console.log(`rollback: node rollback.mjs ${restoreFile} --apply`);
+})().catch(e => { console.error(e); process.exit(1); });

← b5eddda TK-11237: description backfill tooling — grounded generator  ·  back to Designerwallcoverings  ·  auto-data-snapshot: 2026-09-04T10:10:38 (8 data files) — scr 9024a0d →