← back to Designer Wallcoverings
guard TK-11357 Fix D: push-drafts-book.cjs (TOP PRIORITY, scheduled) + push_wallquest_pr.js; restore inventory-set-2026-newest.mjs per the already-guarded ruling
36206679fd61d91af1e303283617833ef64ec3c0 · 2026-09-10 09:45:05 -0700 · Steve
TOP PRIORITY — scripts/wallquest-refresh/push-drafts-book.cjs
SCHEDULED via com.steve.pr-textile-drip (Phillipe Romano drip, monthly Day 19), behind a multi-hop
.sh wrapper chain, which is why earlier plist greps missed it.
PRE-EXISTING GUARD STATE: NO price gate anywhere on the path. Its only skips are settlement flag,
existing shopify_product_id, a forbidden-word leak check and a missing swatch. It then minted:
{ option1:'Per Yard', sku:r.dw_sku, price:String(r.price), inventory_quantity:999,
inventory_policy:'continue' }
This is worse than an ordinary unguarded writer and the reason it outranks the rest: CONTINUE
(oversell) makes a variant orderable at ANY quantity INCLUDING ZERO. A $0 variant minted here is
therefore orderable AND immune to the established qty->0 stopgap — the whole remedy for this
defect class silently fails against it. A fleet probe found that $0+CONTINUE population currently
EMPTY (0 of 92,424 active), so this scheduled job is precisely the mechanism that would refill an
empty class with items nothing could then remediate.
FIX, two parts (both, because part (a) alone would have been decorative under CONTINUE):
(a) refuse to create the row at all when !(Number(r.price) > 0). This is a PRICED per-yard line
(our_price from the WallQuest cost sheet), so a null/0 price is a data defect. Holding is
idempotent — the row is re-picked once a real price lands — so no SKU is lost.
(b) the payload's inventory_quantity AND inventory_policy both come from the shared guard, so a
$0 variant can never be minted stocked and can never be minted CONTINUE. A real price keeps
999 + 'continue' byte-identically.
RECOMMENDATION, not changed (flagged rather than guessed, per the brief): whether 'continue' is
correct for the PRICED Per Yard variant at all. The rest of the cohort uses DENY, and DENY is what
makes qty->0 an effective remedy in the first place. Changing the policy for priced goods would
alter live oversell behaviour for a real made-to-order line, which I cannot justify from any
reference implementation — it needs Steve's call.
scripts/push_wallquest_pr.js — same family, same defect, found by the widened enumeration.
PRE-EXISTING GUARD STATE: none. Its SQL filters only `created_at::date='2026-07-06' AND
shopify_product_id IS NULL`, and perYard(null) computes Number(null)/8/0.65/0.85 = "0.00", so a
null price_retail minted a $0 Sold-Per-Yard variant with policy CONTINUE, then stocked every
variant with a flat 2026. Now: policy from the guard, and the stock loop uses the guard's
per-variant safe quantity from the price Shopify actually landed. (Also fixed a `buildTags(row)`
reference I introduced where the loop variable is `r` — caught by reading the call site, since
node --check cannot see an undefined identifier.)
REVERTED my own over-reach: shopify/scripts/inventory-set-2026-newest.mjs is restored byte-for-byte.
The coordinator ruled it ALREADY GUARDED and do-not-touch (line 74 `if (Number(v.price) === 0)
continue; // GUARD TK-10965`, and sortKey CREATED_AT reverse so it is not a reverter either). I had
widened that test to `!(Number(v.price) > 0)`; that finding stands as a REPORTED RESIDUAL, not a
change — Number(undefined) is NaN and NaN === 0 is false, so a variant with an ABSENT price is
still stamped 2026 there. Left for Steve rather than re-applied.
Harness now covers 26 writers in three modes: block (safeQuantities extracted per file), predicate
(a real `if (...) continue;` filter — the shape of reference commit 23987f86; target list currently
empty by the ruling above), and python (extracts create_22_new.py's real safe_quantity and runs it
under python3). Adds the P8 assertion that a guard-zeroed variant is forced to DENY.
ALL 26: 4/4 required each. RESULT: PASS.
SOURCE-ONLY: nothing run with --apply, no Shopify write, no dw_unified write. Reversible: git revert.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Files touched
M scripts/push_wallquest_pr.jsM scripts/wallquest-refresh/push-drafts-book.cjsM shopify/scripts/inventory-set-2026-newest.mjsM shopify/scripts/tk11357-source-fix-proof/predicate-proof.mjs
Diff
commit 36206679fd61d91af1e303283617833ef64ec3c0
Author: Steve <steve@designerwallcoverings.com>
Date: Thu Sep 10 09:45:05 2026 -0700
guard TK-11357 Fix D: push-drafts-book.cjs (TOP PRIORITY, scheduled) + push_wallquest_pr.js;
restore inventory-set-2026-newest.mjs per the already-guarded ruling
TOP PRIORITY — scripts/wallquest-refresh/push-drafts-book.cjs
SCHEDULED via com.steve.pr-textile-drip (Phillipe Romano drip, monthly Day 19), behind a multi-hop
.sh wrapper chain, which is why earlier plist greps missed it.
PRE-EXISTING GUARD STATE: NO price gate anywhere on the path. Its only skips are settlement flag,
existing shopify_product_id, a forbidden-word leak check and a missing swatch. It then minted:
{ option1:'Per Yard', sku:r.dw_sku, price:String(r.price), inventory_quantity:999,
inventory_policy:'continue' }
This is worse than an ordinary unguarded writer and the reason it outranks the rest: CONTINUE
(oversell) makes a variant orderable at ANY quantity INCLUDING ZERO. A $0 variant minted here is
therefore orderable AND immune to the established qty->0 stopgap — the whole remedy for this
defect class silently fails against it. A fleet probe found that $0+CONTINUE population currently
EMPTY (0 of 92,424 active), so this scheduled job is precisely the mechanism that would refill an
empty class with items nothing could then remediate.
FIX, two parts (both, because part (a) alone would have been decorative under CONTINUE):
(a) refuse to create the row at all when !(Number(r.price) > 0). This is a PRICED per-yard line
(our_price from the WallQuest cost sheet), so a null/0 price is a data defect. Holding is
idempotent — the row is re-picked once a real price lands — so no SKU is lost.
(b) the payload's inventory_quantity AND inventory_policy both come from the shared guard, so a
$0 variant can never be minted stocked and can never be minted CONTINUE. A real price keeps
999 + 'continue' byte-identically.
RECOMMENDATION, not changed (flagged rather than guessed, per the brief): whether 'continue' is
correct for the PRICED Per Yard variant at all. The rest of the cohort uses DENY, and DENY is what
makes qty->0 an effective remedy in the first place. Changing the policy for priced goods would
alter live oversell behaviour for a real made-to-order line, which I cannot justify from any
reference implementation — it needs Steve's call.
scripts/push_wallquest_pr.js — same family, same defect, found by the widened enumeration.
PRE-EXISTING GUARD STATE: none. Its SQL filters only `created_at::date='2026-07-06' AND
shopify_product_id IS NULL`, and perYard(null) computes Number(null)/8/0.65/0.85 = "0.00", so a
null price_retail minted a $0 Sold-Per-Yard variant with policy CONTINUE, then stocked every
variant with a flat 2026. Now: policy from the guard, and the stock loop uses the guard's
per-variant safe quantity from the price Shopify actually landed. (Also fixed a `buildTags(row)`
reference I introduced where the loop variable is `r` — caught by reading the call site, since
node --check cannot see an undefined identifier.)
REVERTED my own over-reach: shopify/scripts/inventory-set-2026-newest.mjs is restored byte-for-byte.
The coordinator ruled it ALREADY GUARDED and do-not-touch (line 74 `if (Number(v.price) === 0)
continue; // GUARD TK-10965`, and sortKey CREATED_AT reverse so it is not a reverter either). I had
widened that test to `!(Number(v.price) > 0)`; that finding stands as a REPORTED RESIDUAL, not a
change — Number(undefined) is NaN and NaN === 0 is false, so a variant with an ABSENT price is
still stamped 2026 there. Left for Steve rather than re-applied.
Harness now covers 26 writers in three modes: block (safeQuantities extracted per file), predicate
(a real `if (...) continue;` filter — the shape of reference commit 23987f86; target list currently
empty by the ruling above), and python (extracts create_22_new.py's real safe_quantity and runs it
under python3). Adds the P8 assertion that a guard-zeroed variant is forced to DENY.
ALL 26: 4/4 required each. RESULT: PASS.
SOURCE-ONLY: nothing run with --apply, no Shopify write, no dw_unified write. Reversible: git revert.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
---
scripts/push_wallquest_pr.js | 52 ++++++++++++++-
scripts/wallquest-refresh/push-drafts-book.cjs | 55 +++++++++++++++-
shopify/scripts/inventory-set-2026-newest.mjs | 5 +-
.../tk11357-source-fix-proof/predicate-proof.mjs | 76 ++++++++++++++++++++--
4 files changed, 174 insertions(+), 14 deletions(-)
diff --git a/scripts/push_wallquest_pr.js b/scripts/push_wallquest_pr.js
index 59c1e044..b04eff51 100644
--- a/scripts/push_wallquest_pr.js
+++ b/scripts/push_wallquest_pr.js
@@ -50,6 +50,39 @@ async function shopify(method, path, body) {
const money = (n) => (Math.round(n * 100) / 100).toFixed(2);
const perYard = (rollCost) => money((Number(rollCost) / 8) / 0.65 / 0.85);
+const { safeStampQuantity } = require('../shopify/scripts/lib/inventory-stamp-guard.mjs'); // GUARD TK-11357 (shared guard)
+// ── GUARD TK-11357 BEGIN ─ do not edit without re-running the fixture proof ──────────
+// A $0 / quote-only sellable variant must NEVER receive positive stock: positive stock is what
+// flips availableForSale=true, making it checkout-orderable at $0 (lineage TK-10825 -> 10965 ->
+// 11140 -> 11299 -> 11301 -> 11357). $0 is the LIVE theme's deliberate quote-only SENTINEL
+// (snippets/product-form-content.liquid renders the "Contact Us" button iff variant.price == 0),
+// so the remedy is NEVER to write a placeholder price - it is "do not stock it".
+// Steve's 2026-06-20 "active products are never out of stock" rule is PRESERVED for PRICED goods:
+// a priced variant still gets `desired`. The quote-only tag/vendor decision is delegated to the
+// shared guard (inventory-stamp-guard.mjs); this adds one strictly-safer rule of its own -
+// price <= 0 / NaN is ALWAYS 0, even on a variant labelled "Sample" (a $0 "sample" is the same
+// $0-orderable defect). The real $4.25 memo sample is unaffected and keeps its existing quantity.
+// `inventoryItem?.id ?? null` because this writer decides on a CREATE PAYLOAD, where no
+// inventoryItem id exists yet; only the .quantity is consumed there.
+function safeQuantities(product, variants, locationId, desired) {
+ return (variants || []).map(v => ({
+ inventoryItemId: v.inventoryItem?.id ?? null,
+ locationId,
+ quantity: Number(v.price) > 0
+ ? safeStampQuantity({ title: v.title, price: v.price }, product, desired)
+ : 0,
+ }));
+}
+// inventoryPolicy CONTINUE (oversell) makes a variant orderable at ANY quantity INCLUDING ZERO.
+// So for the $0 class, "set the quantity to 0" is a NO-OP under CONTINUE and the entire
+// established remedy for this defect class silently fails. A variant the guard zeroes must
+// therefore ALSO be DENY, or the guard is decorative. Priced variants keep the caller's policy
+// exactly as-is, so oversell behaviour for real made-to-order goods is unchanged.
+function safePolicy(product, variant, desiredPolicy, desired) {
+ return safeQuantities(product, [variant], null, desired)[0].quantity > 0 ? desiredPolicy : 'deny';
+}
+// ── GUARD TK-11357 END ────────────────────────────────────────────
+
const titleOf = (colorName) => colorName.replace(/\s*-\s*/g, ' ').replace(/\s+/g, ' ').trim();
function buildTags(row) {
@@ -74,8 +107,15 @@ function payload(row) {
tags: buildTags(row),
options: [{ name: 'Size' }],
variants: [
+ // GUARD TK-11357: the SQL above filters only on created_at + shopify_product_id — there is
+ // NO price filter, and perYard(null) computes Number(null)/8/0.65/0.85 = "0.00", so a row
+ // with a null price_retail minted a $0 Sold-Per-Yard variant with policy CONTINUE. CONTINUE
+ // is orderable at ANY quantity INCLUDING ZERO, so a qty->0 stopgap cannot fix such a
+ // variant — the policy must come from the guard too, not just the quantity.
{ option1: 'Sold Per Yard', sku: row.dw_sku, price,
- inventory_management: 'shopify', inventory_policy: 'continue', requires_shipping: true, taxable: true },
+ inventory_management: 'shopify',
+ inventory_policy: safePolicy({ vendor: 'Phillipe Romano', tags: buildTags(row) }, { title: 'Sold Per Yard', price }, 'continue', 2026),
+ requires_shipping: true, taxable: true },
{ option1: 'Sample', sku: `${row.dw_sku}-Sample`, price: '4.25',
inventory_management: 'shopify', inventory_policy: 'deny', requires_shipping: true, taxable: true },
],
@@ -93,6 +133,7 @@ async function setInv(variantId, locationId, qty) {
const v = await shopify('GET', `/variants/${variantId}.json`);
const iid = v.variant.inventory_item_id;
try { await shopify('POST', '/inventory_levels/connect.json', { location_id: locationId, inventory_item_id: iid }); } catch {}
+ // GUARD TK-11357: callers pass a flat qty; the guard decides per variant (see stockQty below).
await shopify('POST', '/inventory_levels/set.json', { location_id: locationId, inventory_item_id: iid, available: qty });
}
@@ -196,7 +237,14 @@ async function setInv(variantId, locationId, qty) {
const prod = (await shopify('POST', '/products.json', p)).product;
created.push({ id: r.id, sf: prod.id, handle: prod.handle });
console.log(`${stamp} ✓ ${r.dw_sku} "${prod.title}" → #${prod.id}`);
- for (const v of prod.variants) { try { await setInv(v.id, locationId, 2026); await sleep(RATE_MS); } catch (e) { console.log(` inv ${v.id} fail: ${e.message.slice(0,120)}`); } }
+ // GUARD TK-11357: stock per variant, using the price Shopify actually landed (prod.variants
+ // carries `price`), never a flat 2026. A $0 variant gets 0 and stays unorderable.
+ for (const q of safeQuantities({ vendor: 'Phillipe Romano', tags: buildTags(r) },
+ prod.variants.map(v => ({ title: v.option1, price: v.price, inventoryItem: { id: v.id } })), null, 2026)) {
+ if (q.quantity === 0) { console.log(` ⛔ variant ${q.inventoryItemId}: $0 — NOT stocked (TK-11357 guard)`); continue; }
+ try { await setInv(q.inventoryItemId, locationId, q.quantity); await sleep(RATE_MS); }
+ catch (e) { console.log(` inv ${q.inventoryItemId} fail: ${e.message.slice(0,120)}`); }
+ }
await db.query(`UPDATE phillipe_romano_catalog SET shopify_product_id=$1, on_shopify=true, pl_updated_at=now() WHERE id=$2`, [prod.id, r.id]);
} catch (e) { failed.push({ dw_sku: r.dw_sku, err: e.message }); console.log(`${stamp} ✗ ${r.dw_sku}: ${e.message.slice(0, 200)}`); }
await sleep(RATE_MS);
diff --git a/scripts/wallquest-refresh/push-drafts-book.cjs b/scripts/wallquest-refresh/push-drafts-book.cjs
index 67262d02..2c6b6737 100644
--- a/scripts/wallquest-refresh/push-drafts-book.cjs
+++ b/scripts/wallquest-refresh/push-drafts-book.cjs
@@ -28,6 +28,40 @@ function rest(method, path, body) {
}
const b64 = p => { try { return fs.readFileSync(p).toString('base64'); } catch { return null; } };
+const { safeStampQuantity } = require('../../shopify/scripts/lib/inventory-stamp-guard.mjs'); // GUARD TK-11357 (shared guard)
+// ── GUARD TK-11357 BEGIN ─ do not edit without re-running the fixture proof ──────────
+// A $0 / quote-only sellable variant must NEVER receive positive stock: positive stock is what
+// flips availableForSale=true, making it checkout-orderable at $0 (lineage TK-10825 -> 10965 ->
+// 11140 -> 11299 -> 11301 -> 11357). $0 is the LIVE theme's deliberate quote-only SENTINEL
+// (snippets/product-form-content.liquid renders the "Contact Us" button iff variant.price == 0),
+// so the remedy is NEVER to write a placeholder price - it is "do not stock it".
+// Steve's 2026-06-20 "active products are never out of stock" rule is PRESERVED for PRICED goods:
+// a priced variant still gets `desired`. The quote-only tag/vendor decision is delegated to the
+// shared guard (inventory-stamp-guard.mjs); this adds one strictly-safer rule of its own -
+// price <= 0 / NaN is ALWAYS 0, even on a variant labelled "Sample" (a $0 "sample" is the same
+// $0-orderable defect). The real $4.25 memo sample is unaffected and keeps its existing quantity.
+// `inventoryItem?.id ?? null` because this writer decides on a CREATE PAYLOAD, where no
+// inventoryItem id exists yet; only the .quantity is consumed there.
+function safeQuantities(product, variants, locationId, desired) {
+ return (variants || []).map(v => ({
+ inventoryItemId: v.inventoryItem?.id ?? null,
+ locationId,
+ quantity: Number(v.price) > 0
+ ? safeStampQuantity({ title: v.title, price: v.price }, product, desired)
+ : 0,
+ }));
+}
+// inventoryPolicy CONTINUE (oversell) makes a variant orderable at ANY quantity INCLUDING ZERO.
+// So for the $0 class, "set the quantity to 0" is a NO-OP under CONTINUE and the entire
+// established remedy for this defect class silently fails. A variant the guard zeroes must
+// therefore ALSO be DENY, or the guard is decorative. Priced variants keep the caller's policy
+// exactly as-is, so oversell behaviour for real made-to-order goods is unchanged.
+function safePolicy(product, variant, desiredPolicy, desired) {
+ return safeQuantities(product, [variant], null, desired)[0].quantity > 0 ? desiredPolicy : 'deny';
+}
+// ── GUARD TK-11357 END ────────────────────────────────────────────
+
+
const rows = psql(`SELECT dw_sku, pattern_name, color_name, material, our_price, COALESCE(ai_description,''),
COALESCE((local_image_path::jsonb)->>0,''), COALESCE((room_setting_images::jsonb)->>0,''),
mfr_sku, COALESCE(width,''), COALESCE(repeat_v,''), COALESCE(match_type,''),
@@ -38,7 +72,7 @@ const rows = psql(`SELECT dw_sku, pattern_name, color_name, material, our_price,
});
(async () => {
- let created = 0, skip = 0, flagged = 0, already = 0, err = 0, leak = 0;
+ let created = 0, skip = 0, flagged = 0, already = 0, err = 0, leak = 0, noprice = 0;
console.log(`${DRY?'[DRY-RUN] ':''}${TABLE}: ${rows.length} rows`);
for (const r of rows) {
if (r.flag) { flagged++; continue; } // settlement — DRAFT, don't push
@@ -48,14 +82,29 @@ const rows = psql(`SELECT dw_sku, pattern_name, color_name, material, our_price,
const swatch = r.img ? b64(`${VIEW}/${r.img}`) : null;
const roomImg = r.room ? b64(`${VIEW}/${r.room}`) : null;
if (!swatch) { skip++; console.log(' no swatch', r.dw_sku); continue; }
+ // GUARD TK-11357 (a): this is a PRICED per-yard line (our_price from the WallQuest cost
+ // sheet). A null/0 our_price is a data defect, and minting the Per Yard variant anyway
+ // creates a $0 variant that this same payload marks inventory_policy CONTINUE — which is
+ // orderable at ANY quantity INCLUDING ZERO, so the standard qty->0 stopgap cannot fix it.
+ // Refuse to create; the row is re-picked automatically once a real price lands (idempotent
+ // on shopify_product_id), so this holds rather than loses the SKU.
+ if (!(Number(r.price) > 0)) { noprice++; console.log(` ⛔ no price ($${r.price}) — NOT created (TK-11357 $0-orderable guard)`, r.dw_sku); continue; }
let styles = []; try { styles = JSON.parse(r.styles); } catch {}
+ const _guardProduct = (row) => ({ vendor: 'Phillipe Romano',
+ tags: [row.pattern.split(' ')[0], row.material, 'Natural Texture', 'Grasscloth & Naturals', 'Phillipe Romano', ...styles].filter(Boolean) });
const product = {
title, body_html: clean(r.desc), vendor: 'Phillipe Romano', product_type: 'Wallcovering', status: 'draft',
tags: [r.pattern.split(' ')[0], r.material, 'Natural Texture', 'Grasscloth & Naturals', 'Phillipe Romano', ...styles].filter(Boolean).join(', '),
options: [{ name: 'Size' }],
variants: [
{ option1: 'Sample', sku: `${r.dw_sku}-Sample`, price: '4.25', inventory_management: null, inventory_policy: 'deny' },
- { option1: 'Per Yard', sku: r.dw_sku, price: String(r.price), inventory_quantity: 999, inventory_policy: 'continue' },
+ // GUARD TK-11357 (b): belt-and-suspenders on the payload even though (a) already refused
+ // the priceless row — the quantity AND the policy both come from the guard, so a $0 variant
+ // can never be minted stocked, and can never be minted CONTINUE (which would make a later
+ // qty->0 remediation a no-op). A real price keeps 999 + 'continue' exactly as before.
+ { option1: 'Per Yard', sku: r.dw_sku, price: String(r.price),
+ inventory_quantity: safeQuantities(_guardProduct(r), [{ title: 'Per Yard', price: String(r.price) }], null, 999)[0].quantity,
+ inventory_policy: safePolicy(_guardProduct(r), { title: 'Per Yard', price: String(r.price) }, 'continue', 999) },
],
images: [ { attachment: swatch, alt: title }, ...(roomImg ? [{ attachment: roomImg, alt: `${title} room setting`, position: 2 }] : []) ],
metafields: [
@@ -84,6 +133,6 @@ const rows = psql(`SELECT dw_sku, pattern_name, color_name, material, our_price,
await sleep(600);
} catch (e) { err++; console.log(` ✗ ${r.dw_sku} ${String(e).slice(0,70)}`); }
}
- console.log(`\n${DRY?'[DRY-RUN] ':''}${TABLE} DONE: created=${created} already=${already} settlement-skipped=${flagged} no-swatch=${skip} leaks=${leak} errors=${err}`);
+ console.log(`\n${DRY?'[DRY-RUN] ':''}${TABLE} DONE: created=${created} already=${already} settlement-skipped=${flagged} no-swatch=${skip} no-price-held=${noprice} leaks=${leak} errors=${err}`);
if (DRY) console.log('live: SHOPIFY_ADMIN_TOKEN=… TABLE=… VIEW=… node push-drafts-book.cjs (Steve via !)');
})();
diff --git a/shopify/scripts/inventory-set-2026-newest.mjs b/shopify/scripts/inventory-set-2026-newest.mjs
index b83a9778..8a21d20a 100644
--- a/shopify/scripts/inventory-set-2026-newest.mjs
+++ b/shopify/scripts/inventory-set-2026-newest.mjs
@@ -71,10 +71,7 @@ async function scan() {
let totV = 0, correct = 0; const fixes = [];
for (const p of prods) for (const v of p.variants.nodes) {
totV++;
- // GUARD TK-10965, widened by TK-11357: `=== 0` let a variant with an ABSENT/unparseable price
- // through (Number(undefined) is NaN, and NaN === 0 is false), so a price-less variant was still
- // stamped 2026 = orderable at $0. `!(> 0)` is fail-safe: 0, '', null, undefined and NaN all skip.
- if (!(Number(v.price) > 0)) continue; // GUARD TK-11357-PREDICATE: never re-inflate a $0/price-less variant
+ if (Number(v.price) === 0) continue; // GUARD TK-10965: never re-inflate $0 quote-only variants
const ii = v.inventoryItem;
const tracked = ii?.tracked, lvl = ii?.inventoryLevel;
const onh = lvl?.quantities?.find(x => x.name === 'on_hand')?.quantity;
diff --git a/shopify/scripts/tk11357-source-fix-proof/predicate-proof.mjs b/shopify/scripts/tk11357-source-fix-proof/predicate-proof.mjs
index f155b7af..86523288 100644
--- a/shopify/scripts/tk11357-source-fix-proof/predicate-proof.mjs
+++ b/shopify/scripts/tk11357-source-fix-proof/predicate-proof.mjs
@@ -25,6 +25,7 @@
*/
import fs from 'node:fs';
import { createRequire } from 'node:module';
+import { execFileSync } from 'node:child_process';
const require = createRequire(import.meta.url);
const HOME = process.env.HOME;
@@ -32,10 +33,15 @@ const HOME = process.env.HOME;
const DWC = `${HOME}/Projects/designerwallcoverings`;
const DWM = `${HOME}/Projects/Designer-Wallcoverings`;
const SDG = `${HOME}/Projects/sanderson-onboard`;
+const RW = `${HOME}/Projects/rebel-walls-push`;
+const SP = `${HOME}/Projects/sister-parish-onboarding`;
+const PC = `${HOME}/Projects/dw-photo-capture`;
const GUARD = {
[DWC]: `${DWC}/scripts/lib/inventory-stamp-guard.mjs`,
[DWM]: `${DWM}/shopify/scripts/lib/inventory-stamp-guard.mjs`,
[SDG]: `${SDG}/scripts/lib/inventory-stamp-guard.mjs`,
+ [RW]: `${RW}/scripts/lib/inventory-stamp-guard.mjs`,
+ [SP]: `${SP}/scripts/lib/inventory-stamp-guard.mjs`,
};
const TARGETS = [
[DWC, 'scripts/maharam-onboard/go-live.mjs'],
@@ -59,13 +65,30 @@ const TARGETS = [
[DWM, 'shopify/scripts/data/kravet-map-pricing/kravet25-reactivate.js'],
[DWM, 'shopify/scripts/kravet-full-monty-single.js'],
[SDG, 'scripts/create_sdg.mjs'],
+ // SCHEDULED, behind multi-hop .sh wrapper chains (found by the guard-canary build, not by a
+ // plain grep of the plists) — the two highest-priority targets in this fix:
+ [DWM, 'scripts/wallquest-refresh/push-drafts-book.cjs'], // com.steve.pr-textile-drip, monthly D19
+ [RW, 'scripts/push.js'], // run-cadence-hourly.sh -> effectively daily
+ // Additional MINTING paths found by the widened REST-inventory_levels enumeration:
+ [DWM, 'scripts/push_wallquest_pr.js'],
+ [SP, 'scripts/push_shopify.js'],
+];
+// PYTHON-mode targets: the only Python writer on the path, where a JS import is impossible, so the
+// guard is a local Python twin. The harness extracts THAT function and runs it under python3.
+const PY_TARGETS = [
+ [PC, 'create_22_new.py'],
];
// PREDICATE-mode targets: writers guarded by a `if (<expr>) continue;` skip-filter rather than a
// safeQuantities() block (the exact shape of the 23987f86 reference diff). The harness extracts the
// REAL expression from the marked line and evaluates it — expected: skip iff the safe quantity is 0.
-const PREDICATE_TARGETS = [
- [DWM, 'shopify/scripts/inventory-set-2026-newest.mjs'],
-];
+// EMPTY on purpose. inventory-set-2026-newest.mjs was the one candidate here; the coordinator
+// ruled it ALREADY GUARDED and do-not-touch (line 74 `if (Number(v.price) === 0) continue;`
+// // GUARD TK-10965, and sortKey CREATED_AT reverse so it is not a reverter either). It has been
+// restored byte-for-byte and therefore carries no harness marker. The mode is kept because it is
+// the shape of the TK-11299 reference commit 23987f86 and the next such guard should use it.
+// RESIDUAL, reported not fixed: that guard tests `=== 0`, and Number(undefined) is NaN with
+// NaN === 0 false, so a variant with an ABSENT price is still stamped 2026 there.
+const PREDICATE_TARGETS = [];
const LOC = 'gid://shopify/Location/5795643504';
const DESIRED = 2026;
@@ -124,6 +147,13 @@ function extractBlock(abs) {
}
/** Build the file's REAL safeQuantities from its own extracted source + its own repo guard. */
+function compilePolicy(block, guardPath) {
+ const { safeStampQuantity } = require(guardPath);
+ // eslint-disable-next-line no-new-func
+ const fn = new Function('safeStampQuantity', `${block}\n;return safePolicy;`)(safeStampQuantity);
+ if (typeof fn !== 'function') throw new Error('block defines no safePolicy()');
+ return fn;
+}
function compile(block, guardPath) {
const { safeStampQuantity, isPriceSuppressed, isSellableVariant } = require(guardPath);
// eslint-disable-next-line no-new-func
@@ -161,8 +191,11 @@ for (const [repo, rel] of TARGETS) {
let block;
try { block = extractBlock(abs); } catch (e) { results.push({ rel, state: 'EXTRACT ERR: ' + e.message }); allOk = false; continue; }
if (block === null) { results.push({ rel, state: 'NO GUARD BLOCK' }); allOk = false; continue; }
- let fn;
+ let fn, polFn = null;
try { fn = compile(block, GUARD[repo]); } catch (e) { results.push({ rel, state: 'COMPILE ERR: ' + e.message }); allOk = false; continue; }
+ if (/function safePolicy\s*\(/.test(block)) {
+ try { polFn = compilePolicy(block, GUARD[repo]); } catch (e) { results.push({ rel, state: 'POLICY COMPILE ERR: ' + e.message }); allOk = false; continue; }
+ }
let req = 0, reqTotal = 0, reg = 0, regTotal = 0; const fails = [];
for (const f of FIXTURES) {
@@ -175,7 +208,16 @@ for (const [repo, rel] of TARGETS) {
if (f.required) { reqTotal++; if (pass && shapeOk) req++; else fails.push(`${f.id} exp ${JSON.stringify(f.expect)} got ${JSON.stringify(gotQ)}${shapeOk ? '' : ' [SHAPE]'}`); }
else { regTotal++; if (pass && shapeOk) reg++; else fails.push(`${f.id} exp ${JSON.stringify(f.expect)} got ${JSON.stringify(gotQ)}${shapeOk ? '' : ' [SHAPE]'}`); }
}
- const state = `${req}/${reqTotal} required · ${reg}/${regTotal} regression`;
+ let polNote = '';
+ if (polFn) {
+ // P8: CONTINUE (oversell) is orderable at ANY quantity INCLUDING ZERO, so a variant the guard
+ // zeroes MUST also be forced to 'deny' or the qty->0 remedy is a no-op against it.
+ const zeroKeepsDeny = polFn({ vendor: 'Phillipe Romano', tags: ['quote-only'] }, { title: 'Per Yard', price: '0.00' }, 'continue', 999) === 'deny';
+ const pricedKeepsPolicy = polFn({ vendor: 'Phillipe Romano', tags: [] }, { title: 'Per Yard', price: '58.00' }, 'continue', 999) === 'continue';
+ if (zeroKeepsDeny && pricedKeepsPolicy) polNote = ' · P8 policy 2/2 ($0→deny, priced→continue)';
+ else { polNote = ` · P8 policy FAIL ($0→deny:${zeroKeepsDeny}, priced→continue:${pricedKeepsPolicy})`; fails.push('P8 inventoryPolicy'); allOk = false; }
+ }
+ const state = `${req}/${reqTotal} required · ${reg}/${regTotal} regression${polNote}`;
if (req !== reqTotal || reg !== regTotal) allOk = false;
results.push({ rel, state, fails, bytes: block.length });
}
@@ -206,6 +248,30 @@ for (const [repo, rel] of PREDICATE_TARGETS) {
results.push({ rel: rel + ' [predicate]', state: `${req}/${reqTotal} required · ${reg}/${regTotal} regression` + (na.length ? ` · N/A ${na.join(',')} (price-only guard: no product tags in scope)` : ''), fails });
}
+// ── python-mode files: extract the real safe_quantity() and run it under python3 ─────────
+for (const [repo, rel] of PY_TARGETS) {
+ const abs = `${repo}/${rel}`;
+ if (!fs.existsSync(abs)) { results.push({ rel, state: 'MISSING FILE' }); allOk = false; continue; }
+ const src = fs.readFileSync(abs, 'utf8');
+ const b = src.match(/# [^\n]*GUARD TK-11357 BEGIN[^\n]*\n/);
+ const e = src.match(/# [^\n]*GUARD TK-11357 END/);
+ if (!b || !e) { results.push({ rel, state: 'NO GUARD BLOCK' }); allOk = false; continue; }
+ const block = src.slice(b.index + b[0].length, e.index);
+ // fixtures expressed as (price, expected) — the Python guard is price-only by construction
+ const cases = [['0.00', 0], ['', 0], [null, 0], ['185.00', 2026], ['4.25', 2026], ['-1', 0]];
+ const py = `${block}\ncases = ${JSON.stringify(cases).replace(/null/g, 'None')}\n` +
+ `bad = [c for c in cases if safe_quantity(c[0]) != c[1]]\n` +
+ `print('PY_FAIL' if bad else 'PY_OK', bad)\nimport sys; sys.exit(1 if bad else 0)\n`;
+ const tmp = `/tmp/tk11357-py-proof-${Date.now()}.py`;
+ fs.writeFileSync(tmp, py);
+ let out = '', code = 0;
+ try { out = execFileSync('python3', [tmp], { encoding: 'utf8' }).trim(); }
+ catch (err) { code = 1; out = String(err.stdout || err.message).trim(); }
+ fs.rmSync(tmp, { force: true });
+ if (code) { allOk = false; results.push({ rel: rel + ' [python]', state: 'FAIL', fails: [out] }); }
+ else results.push({ rel: rel + ' [python]', state: `6/6 price fixtures (${out})` });
+}
+
console.log('\nper-file extracted-predicate results');
console.log('-'.repeat(78));
for (const r of results) {
← 950f19d5 TK-11387: add gated, reversible chronic-bouncer suppression
·
back to Designer Wallcoverings
·
auto-data-snapshot: 2026-09-10T10:34:55 (1 data files) — sho bedea724 →