[object Object]

← back to Japan Enrich

TK-10820: sync pilot-exec.cjs bodyHtmlValid mirror to canonical + add parity suite

c12fdd3747e748845d2b315b3223fc449028ae05 · 2026-08-24 19:24:19 -0700 · Steve Abrams

HOLE 2 (Cody): the inline CJS mirror of bodyHtmlValid in pilot-exec.cjs stripped ONLY
 , diverging from carnegie-reprice/carnegie-mfr-gate.mjs. Cody proved live that
'<p>&thinsp;</p>', '&#160;', and '&#xa0;' PASSED the CJS check but the .mjs REJECTS
them — a blank-desc product would have gone ACTIVE via this path. Synced the CJS
entity-strip to the exact two-pass .mjs regex (named whitespace-like entities incl.
thinsp/ensp/emsp/zwnj/zwj/#xa0/#160/#8203, then drop-all-remaining-entities pass).

Added test-bodyhtml-parity.mjs: extracts the REAL shipped CJS mirror from pilot-exec.cjs
and asserts it matches the canonical .mjs across 14 shapes, including Cody's 3
divergence cases. 14/14 pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit c12fdd3747e748845d2b315b3223fc449028ae05
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon Aug 24 19:24:19 2026 -0700

    TK-10820: sync pilot-exec.cjs bodyHtmlValid mirror to canonical + add parity suite
    
    HOLE 2 (Cody): the inline CJS mirror of bodyHtmlValid in pilot-exec.cjs stripped ONLY
    &nbsp;, diverging from carnegie-reprice/carnegie-mfr-gate.mjs. Cody proved live that
    '<p>&thinsp;</p>', '&#160;', and '&#xa0;' PASSED the CJS check but the .mjs REJECTS
    them — a blank-desc product would have gone ACTIVE via this path. Synced the CJS
    entity-strip to the exact two-pass .mjs regex (named whitespace-like entities incl.
    thinsp/ensp/emsp/zwnj/zwj/#xa0/#160/#8203, then drop-all-remaining-entities pass).
    
    Added test-bodyhtml-parity.mjs: extracts the REAL shipped CJS mirror from pilot-exec.cjs
    and asserts it matches the canonical .mjs across 14 shapes, including Cody's 3
    divergence cases. 14/14 pass.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 carnegie-split/pilot-exec.cjs           |  6 +++-
 carnegie-split/test-bodyhtml-parity.mjs | 56 +++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/carnegie-split/pilot-exec.cjs b/carnegie-split/pilot-exec.cjs
index cb7a60d..36b44ce 100644
--- a/carnegie-split/pilot-exec.cjs
+++ b/carnegie-split/pilot-exec.cjs
@@ -6,7 +6,11 @@ const fs=require("fs"),os=require("os"),path=require("path"),https=require("http
 // Inline mirror of carnegie-mfr-gate.mjs bodyHtmlValid/NEEDS_DESC_TAG (this file is CJS; the canonical
 // guard is ESM). Same logic: strip tags/&nbsp;/whitespace, require non-empty. Keep in sync with the .mjs.
 const NEEDS_DESC_TAG="Needs-Description";
-const bodyHtmlValid=b=>{if(b===null||b===undefined)return false;return String(b).replace(/<[^>]*>/g,"").replace(/&nbsp;/gi," ").trim().length>0;};
+const bodyHtmlValid=b=>{if(b===null||b===undefined)return false;return String(b)
+  .replace(/<[^>]*>/g,"")
+  .replace(/&(nbsp|thinsp|ensp|emsp|zwnj|zwj|#x?0*(a0|160|8203);?|#160|#8203);/gi," ")
+  .replace(/&[a-z]+;|&#x?[0-9a-f]+;/gi,"")
+  .trim().length>0;};
 const env=fs.readFileSync(path.join(os.homedir(),"Projects/secrets-manager/.env"),"utf8");
 const g=k=>{const m=env.match(new RegExp("^"+k+"=(.*)$","m"));return m?m[1].trim().replace(/^["']|["']$/g,""):null};
 const shop="designer-laboratory-sandbox.myshopify.com",tok=g("SHOPIFY_ADMIN_TOKEN")||g("SHOPIFY_ADMIN_API_TOKEN");
diff --git a/carnegie-split/test-bodyhtml-parity.mjs b/carnegie-split/test-bodyhtml-parity.mjs
new file mode 100644
index 0000000..1bee6ee
--- /dev/null
+++ b/carnegie-split/test-bodyhtml-parity.mjs
@@ -0,0 +1,56 @@
+#!/usr/bin/env node
+// test-bodyhtml-parity.mjs — TK-10820 parity suite
+//
+// Proves the CJS inline mirror of bodyHtmlValid in pilot-exec.cjs stays in exact
+// lockstep with the canonical ESM guard in carnegie-reprice/carnegie-mfr-gate.mjs.
+// Cody the Contrarian proved the OLD CJS mirror (strip only &nbsp;) DIVERGED:
+// '<p>&thinsp;</p>', '&#160;', '&#xa0;' PASSED the CJS check but the .mjs rejects
+// them — a blank-desc product would have gone ACTIVE. Those 3 shapes are now
+// explicit cases below so the parity suite actually covers them.
+//
+// Run: node test-bodyhtml-parity.mjs   (exit 0 = parity holds, 1 = divergence)
+
+import { bodyHtmlValid as canonical } from '../carnegie-reprice/carnegie-mfr-gate.mjs';
+import fs from 'node:fs';
+
+// Extract the exact CJS mirror source from pilot-exec.cjs and evaluate it, so the
+// test runs the REAL shipped mirror (not a hand-retyped copy that could drift).
+const cjsSrc = fs.readFileSync(new URL('./pilot-exec.cjs', import.meta.url), 'utf8');
+const m = cjsSrc.match(/const bodyHtmlValid=b=>\{[\s\S]*?\};/);
+if (!m) { console.error('FAIL: could not locate bodyHtmlValid mirror in pilot-exec.cjs'); process.exit(1); }
+// eslint-disable-next-line no-eval
+const mirror = eval('(' + m[0].replace(/^const bodyHtmlValid=/, '').replace(/;\s*$/, '') + ')');
+
+const CASES = [
+  // [input, expectedValid]
+  [null, false],
+  [undefined, false],
+  ['', false],
+  ['   ', false],
+  ['<p></p>', false],
+  ['<p>&nbsp;</p>', false],
+  ['<p>&nbsp;&nbsp;</p>', false],
+  ['<div><span>&nbsp;</span></div>', false],
+  // --- Cody's 3 divergence shapes (were PASS on old CJS, FAIL on .mjs) ---
+  ['<p>&thinsp;</p>', false],
+  ['&#160;', false],
+  ['&#xa0;', false],
+  // --- real descriptions must PASS ---
+  ['<p>A durable upholstery textile.</p>', true],
+  ['Siltech Grain in Slate — 100% polyester.', true],
+  ['<p>Bold &amp; beautiful weave.</p>', true],  // &amp; strips but real words remain
+];
+
+let pass = 0, fail = 0;
+for (const [input, expected] of CASES) {
+  const c = canonical(input);
+  const mir = mirror(input);
+  const label = JSON.stringify(input);
+  if (c !== expected) { console.error(`FAIL canonical(${label}) = ${c}, expected ${expected}`); fail++; continue; }
+  if (mir !== c)      { console.error(`FAIL DIVERGENCE mirror(${label}) = ${mir} but canonical = ${c}`); fail++; continue; }
+  pass++;
+}
+
+console.log(`\nbodyHtml parity: ${pass}/${CASES.length} passed, ${fail} failed`);
+if (fail) { console.error('DIVERGENCE — CJS mirror is out of sync with carnegie-mfr-gate.mjs'); process.exit(1); }
+console.log('PARITY HOLDS — CJS mirror matches canonical .mjs on all shapes (incl. Cody\'s 3).');

← 76f479c Carnegie: widen blank-body_html ACTIVE gate to acapella-goli  ·  back to Japan Enrich  ·  auto-data-snapshot: 2026-08-24T19:34:57 (5 data files) — gov 30f9db1 →