[object Object]

← back to Designerwallcoverings

TK-10484: dry-run-default staging script for 8 recovered Jeffrey Stevens codes (gated apply + rollback)

40908be21934c5bf0043ab66738a5698a4e0ec8f · 2026-09-25 11:44:50 -0700 · Steve Abrams

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

Files touched

Diff

commit 40908be21934c5bf0043ab66738a5698a4e0ec8f
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Fri Sep 25 11:44:50 2026 -0700

    TK-10484: dry-run-default staging script for 8 recovered Jeffrey Stevens codes (gated apply + rollback)
    
    Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01RgbJjouBQ3xFfkmBq17Jik
---
 scripts/tk10484-stage-8-recovered.mjs | 53 +++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/scripts/tk10484-stage-8-recovered.mjs b/scripts/tk10484-stage-8-recovered.mjs
new file mode 100644
index 0000000..c3f524d
--- /dev/null
+++ b/scripts/tk10484-stage-8-recovered.mjs
@@ -0,0 +1,53 @@
+// TK-10484: stage the 8 Steve-approved Jeffrey Stevens peel-and-stick rows with
+// their publicly-recovered mfr codes (3-source verified), yorkwall NET cost
+// (live portal pull 2026-09-25), width, and DW retail = cost/0.65/0.85.
+// GATED write to canonical jeffrey_stevens_catalog (Steve ruling 2026-09-24).
+//   node scripts/tk10484-stage-8-recovered.mjs            # dry-run (default)
+//   node scripts/tk10484-stage-8-recovered.mjs --apply    # write + restore map
+//   node scripts/tk10484-stage-8-recovered.mjs --rollback <restore.json>
+import { execFileSync } from 'node:child_process';
+import fs from 'node:fs';
+
+const ROWS = [
+  ['DWAA-504160-Roll', 'JHS5027', 30.00],
+  ['DWAA-504230-Roll', 'JHS5036', 30.00],
+  ['DWAA-504250-Roll', 'LDS4577', 30.00],
+  ['DWAA-504340-Roll', 'LDS4587', 30.00],
+  ['DWAA-509930-Roll', 'RMWS1252', 32.99],
+  ['DWAA-509940-Roll', 'RMWS1253', 32.99],
+  ['DWAA-510580-Roll', 'SCS6059', 30.00],
+  ['DWAA-510590-Roll', 'SCS6060', 30.00],
+];
+const WIDTH = '20.5 Inches Wide', WIDTH_IN = 20.5;
+const COLS = 'sku, recovered_mfr_code, yorkwall_cost, cost, price_retail, width, width_inches';
+const psql = (sql) => execFileSync('psql', ['-h', '/tmp', '-d', 'dw_unified', '-v', 'ON_ERROR_STOP=1', '-At', '-F', '|', '-c', sql], { encoding: 'utf8' });
+const q = (s) => `'${String(s).replace(/'/g, "''")}'`;
+const retail = (c) => Math.round((c / 0.65 / 0.85) * 100) / 100;
+const skus = ROWS.map(r => q(r[0])).join(',');
+
+const mode = process.argv[2] || '--dry-run';
+if (mode === '--rollback') {
+  const snap = JSON.parse(fs.readFileSync(process.argv[3], 'utf8'));
+  const stmts = snap.rows.map(r => `UPDATE jeffrey_stevens_catalog SET recovered_mfr_code=${r.recovered_mfr_code ? q(r.recovered_mfr_code) : 'NULL'}, yorkwall_cost=${r.yorkwall_cost || 'NULL'}, cost=${r.cost || 'NULL'}, price_retail=${r.price_retail || 'NULL'}, width=${r.width ? q(r.width) : 'NULL'}, width_inches=${r.width_inches || 'NULL'} WHERE sku=${q(r.sku)};`);
+  console.log(psql(`BEGIN; ${stmts.join(' ')} COMMIT;`));
+  console.log(`rolled back ${snap.rows.length} rows`);
+  process.exit(0);
+}
+
+const before = psql(`SELECT ${COLS} FROM jeffrey_stevens_catalog WHERE sku IN (${skus}) AND archived_at IS NULL ORDER BY sku;`).trim().split('\n').filter(Boolean)
+  .map(l => { const [sku, recovered_mfr_code, yorkwall_cost, cost, price_retail, width, width_inches] = l.split('|'); return { sku, recovered_mfr_code, yorkwall_cost, cost, price_retail, width, width_inches }; });
+if (before.length !== ROWS.length) { console.error(`ABORT: expected ${ROWS.length} live rows, found ${before.length}`); process.exit(2); }
+for (const b of before) if (b.cost || b.yorkwall_cost || b.recovered_mfr_code) { console.error(`ABORT: ${b.sku} already has cost/code — refusing to overwrite`); process.exit(2); }
+
+console.log('sku | mfr | cost | retail | width');
+for (const [sku, code, cost] of ROWS) console.log(`${sku} | ${code} | ${cost.toFixed(2)} | ${retail(cost).toFixed(2)} | ${WIDTH}`);
+if (mode !== '--apply') { console.log('\nDRY-RUN — nothing written. Re-run with --apply.'); process.exit(0); }
+
+const snapPath = `data/tk10484-stage-8-restore-${new Date().toISOString().replace(/[:.]/g, '-')}.json`;
+fs.writeFileSync(snapPath, JSON.stringify({ ticket: 'TK-10484', rows: before }, null, 2));
+const stmts = ROWS.map(([sku, code, cost]) => `UPDATE jeffrey_stevens_catalog SET recovered_mfr_code=${q(code)}, yorkwall_cost=${cost}, cost=${cost}, price_retail=${retail(cost)}, width=${q(WIDTH)}, width_inches=${WIDTH_IN}, updated_at=now() WHERE sku=${q(sku)} AND archived_at IS NULL;`);
+psql(`BEGIN; ${stmts.join(' ')} COMMIT;`);
+const after = psql(`SELECT count(*) FROM jeffrey_stevens_catalog WHERE sku IN (${skus}) AND yorkwall_cost IS NOT NULL AND price_retail = round((yorkwall_cost/0.65/0.85)::numeric,2) AND width_inches=${WIDTH_IN};`).trim();
+console.log(`verified ${after}/${ROWS.length}; restore map ${snapPath}`);
+console.log(`undo: node scripts/tk10484-stage-8-recovered.mjs --rollback ${snapPath}`);
+if (after !== String(ROWS.length)) process.exit(3);

← d57e691 TK-11483: Phase-2 pre-flight evidence (76 ACTIVE Fentucci du  ·  back to Designerwallcoverings  ·  TK-10484: word-boundary settlement matcher + negative test + 590af0c →