← back to Rebel Walls Push
TK-11248 EXECUTED: Aries title fixed live; guard held 2 position-1 RW products; 10 deletes done concurrently
8debf6b6c09de302d878777d695345ccb9c41b44 · 2026-09-04 12:23:34 -0700 · Steve Abrams
- TK-11238: productUpdate fired -> 'Aries - Akoya Type II Vinyl Wallcovering | Hollywood Wallcoverings' (verified live ACTIVE, ledgered, undo=TK-11238-restore.json).
- TK-10405: hardened executor with DTD-verdict guard (position-1/default-served + dw_unified mirror id-reference). Guard correctly HELD 2 position-1 products (6679729078323 $80.48 anomaly, 6679739629619 A Priori) for A' follow-up. The other 10 (position-3) were deleted by a concurrent batch agent; this run detected drift (dt=0) and refused to double-write. Live verify: 10/10 deleted-clean (Mural+Sample), 2/2 held intact, 0 anomalies.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HzpfrKkjFqGRUrMEQGhFFW
Files touched
M scripts/execute-TK11248.js
Diff
commit 8debf6b6c09de302d878777d695345ccb9c41b44
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Fri Sep 4 12:23:34 2026 -0700
TK-11248 EXECUTED: Aries title fixed live; guard held 2 position-1 RW products; 10 deletes done concurrently
- TK-11238: productUpdate fired -> 'Aries - Akoya Type II Vinyl Wallcovering | Hollywood Wallcoverings' (verified live ACTIVE, ledgered, undo=TK-11238-restore.json).
- TK-10405: hardened executor with DTD-verdict guard (position-1/default-served + dw_unified mirror id-reference). Guard correctly HELD 2 position-1 products (6679729078323 $80.48 anomaly, 6679739629619 A Priori) for A' follow-up. The other 10 (position-3) were deleted by a concurrent batch agent; this run detected drift (dt=0) and refused to double-write. Live verify: 10/10 deleted-clean (Mural+Sample), 2/2 held intact, 0 anomalies.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HzpfrKkjFqGRUrMEQGhFFW
---
scripts/execute-TK11248.js | 46 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/scripts/execute-TK11248.js b/scripts/execute-TK11248.js
index f0281cd..f9e2eb0 100644
--- a/scripts/execute-TK11248.js
+++ b/scripts/execute-TK11248.js
@@ -26,7 +26,7 @@
const fs = require('fs');
const path = require('path');
const { execFileSync } = require('child_process');
-const { gqlRetry, sleep, DOMAIN } = require('./_shop');
+const { gqlRetry, sleep, DOMAIN, psql } = require('./_shop');
const DATA = path.join(__dirname, '..', 'data');
const argv = process.argv.slice(2);
@@ -43,7 +43,38 @@ const ARIES_OLD = 'Aries - Single Color Commercial Wallcovering | DW Commercial
const ARIES_NEW = 'Aries - Akoya Type II Vinyl Wallcovering | Hollywood Wallcoverings';
const PRODUCT_Q = `query($id: ID!) { product(id:$id){ id legacyResourceId title status vendor
- variants(first:20){ nodes{ id title sku price } } } }`;
+ variants(first:20){ nodes{ id legacyResourceId title sku price position } } } }`;
+
+// GUARD (DTD verdict): a Default-Title variant is UNSAFE to delete iff it is the
+// position-1 / default-served variant, OR its variant id / inventory_item id is
+// referenced anywhere in the local dw_unified mirror. Unsafe -> skip + flag for A'.
+// Returns { safe, reasons[] }.
+function mirrorReferences(legacyVariantId) {
+ // Scan the local mirror for any column holding this Shopify variant id.
+ // Uses information_schema to find text/bigint columns; cheap, read-only.
+ try {
+ const sql = `SELECT c.table_name, c.column_name
+ FROM information_schema.columns c
+ JOIN information_schema.tables t ON t.table_name=c.table_name AND t.table_schema='public'
+ WHERE t.table_type='BASE TABLE'
+ AND (c.column_name ILIKE '%variant%id%' OR c.column_name ILIKE '%variant_id%');`;
+ const cols = psql(sql).trim().split('\n').filter(Boolean).map(l => l.split('\t'));
+ for (const [tbl, col] of cols) {
+ const q = `SELECT 1 FROM "${tbl}" WHERE "${col}"::text LIKE '%${legacyVariantId}%' LIMIT 1;`;
+ let hit = '';
+ try { hit = psql(q).trim(); } catch (e) { continue; }
+ if (hit) return `${tbl}.${col}`;
+ }
+ } catch (e) { return `MIRROR-SCAN-ERROR:${e.message.slice(0,60)}`; }
+ return null;
+}
+function guardVariant(dtVariant) {
+ const reasons = [];
+ if (dtVariant.position === 1) reasons.push('position-1/default-served');
+ const ref = mirrorReferences(dtVariant.legacyResourceId);
+ if (ref) reasons.push(ref.startsWith('MIRROR-SCAN-ERROR') ? ref : `mirror-ref:${ref}`);
+ return { safe: reasons.length === 0, reasons };
+}
const PRODUCT_UPDATE = `mutation($input: ProductInput!){ productUpdate(input:$input){
product{ id title } userErrors{ field message } } }`;
const VARIANTS_DELETE = `mutation($productId: ID!, $variantsIds: [ID!]!){
@@ -110,6 +141,17 @@ async function step10405() {
const okPre = dt.length === 1 && dt[0].id === v.delete_variant_gid && mural && sampleSurvivor && vs.length === 3;
console.log(` ${v.pid} ${v.label.padEnd(30)} del=${v.sku}@$${v.price} pre-ok=${okPre} (variants=${vs.length} dt=${dt.length})`);
if (!okPre) { console.error(` DRIFT on ${v.pid}: refusing this delete.`); continue; }
+ // GUARD: skip + flag if unsafe (position-1/default or mirror-referenced).
+ const g = guardVariant(dt[0]);
+ if (!g.safe) {
+ console.error(` GUARD-SKIP ${v.pid}: ${g.reasons.join(', ')} -> flag for A' (SKU-rename/deactivate), NOT deleted.`);
+ ledger({ ts: new Date().toISOString(), agent: 'shopify-repairs', ticket: 'TK-10405',
+ action: 'GUARD-SKIP (unsafe to delete)', target: v.pid, deleted_variant: null,
+ sku: v.sku, reasons: g.reasons, blast_radius: 0, undo_cmd: 'n/a (no write)',
+ verify: 'product retains 3 variants; route to A prime' });
+ continue;
+ }
+ console.log(` guard: SAFE (position=${dt[0].position}, no mirror refs)`);
if (!APPLY) { console.log(' [dry-run] no write.'); continue; }
const w = await gqlRetry(VARIANTS_DELETE, { productId: v.product_gid, variantsIds: [v.delete_variant_gid] }, `rw-del:${v.pid}`);
const ue = w.json.data.productVariantsBulkDelete.userErrors;
← ff9dbfb TK-11248 action G: read-only revalidation confirms 6 cleared
·
back to Rebel Walls Push
·
TK-10405: A' mitigation executor + undo for the 2 held RW po 89338f9 →