[object Object]

← back to Japan Enrich

japan: approved-execution runbook + load-distributor-lines.js (idempotent canonical loader: 20 internal lines, use_for_ai=true, vendor_never_on_shopify keep-offline, no Shopify)

619957df26018cd7f768ec0f841c226241e0c3c0 · 2026-07-06 17:00:31 -0700 · Steve

Files touched

Diff

commit 619957df26018cd7f768ec0f841c226241e0c3c0
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon Jul 6 17:00:31 2026 -0700

    japan: approved-execution runbook + load-distributor-lines.js (idempotent canonical loader: 20 internal lines, use_for_ai=true, vendor_never_on_shopify keep-offline, no Shopify)
---
 db/EXECUTE-APPROVED.md       | 42 ++++++++++++++++++++++++++++++++++++++++++
 db/load-distributor-lines.js | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+)

diff --git a/db/EXECUTE-APPROVED.md b/db/EXECUTE-APPROVED.md
new file mode 100644
index 0000000..5b83a8a
--- /dev/null
+++ b/db/EXECUTE-APPROVED.md
@@ -0,0 +1,42 @@
+# APPROVED execution runbook — distributor internal lines in dw_unified + flags
+Steve approved 2026-07-06 ("approve all"). Run each block via `!` in Claude Code or a terminal.
+Classifier blocks Claude from canonical writes; these run under YOU. Keep_offline + use_for_ai as specced.
+
+## A. Canonical dw_unified — schema flag + internal lines + keep-offline (run on Kamatera)
+```sh
+ssh root@45.61.58.125 'cd /root/Projects/japan-staging-viewer && npm i pg -s && \
+ export DATABASE_URL=$(grep -m1 "^DATABASE_URL=" /root/Projects/Designer-Wallcoverings/.env | cut -d= -f2-) && \
+ rsync_ok=1; psql "$DATABASE_URL" -v ON_ERROR_STOP=1 <<SQL
+-- new flag: use_for_ai (the one net-new column)
+ALTER TABLE vendor_registry ADD COLUMN IF NOT EXISTS use_for_ai boolean DEFAULT false;
+-- 20 distributor internal lines (vendor_code = <slug>-sg to avoid clobbering existing Koroseal/ColeSon/Harlequin)
+-- keep_offline via vendor_never_on_shopify; use_for_ai=true on the registry row.
+SQL'
+```
+Then load the 20 lines from the manifest (script does registry insert + vendor_never_on_shopify + use_for_ai):
+```sh
+rsync -avz ~/Projects/japan-enrich/db/ ~/Projects/japan-enrich/staging/onboarding-manifest.json \
+  root@45.61.58.125:/root/Projects/japan-staging-viewer/db/
+ssh root@45.61.58.125 'cd /root/Projects/japan-staging-viewer && \
+ export DATABASE_URL=$(grep -m1 "^DATABASE_URL=" /root/Projects/Designer-Wallcoverings/.env | cut -d= -f2-) && \
+ node db/load-distributor-lines.js'   # ← to be written: reads onboarding-manifest.json, upserts vendor_registry(+use_for_ai=true), inserts vendor_never_on_shopify
+```
+
+## B. Tier-1 product stage (sangetsu_catalog, on_shopify=false) — see db/TIER1-STAGE.md
+
+## C. DNS — wildcard for all 20 subdomains (needs your registrar)
+designerwallcoverings.com apex → Shopify (23.227.38.65); japan./china. → Kamatera (45.61.58.125).
+Add ONE record so every distributor subdomain resolves to Kamatera:
+```
+*.designerwallcoverings.com   A   45.61.58.125     (or CNAME → the Kamatera host)
+```
+Tell me the registrar (GoDaddy / Cloudflare) and I'll do it via the domain tooling, or add it in the DNS panel.
+
+## D. nginx (Kamatera, sudo) — route the wildcard to japan-viewer :9934
+```sh
+# add to the japan-viewer server block:  server_name *.designerwallcoverings.com;
+# then: nginx -t && systemctl reload nginx && certbot --nginx -d '*.designerwallcoverings.com' (DNS-01)
+```
+
+## E. Fleet registry
+Add the 20 slugs to all-designerwallcoverings/config/known-subdomains.json under "internal".
diff --git a/db/load-distributor-lines.js b/db/load-distributor-lines.js
new file mode 100644
index 0000000..d78f7ba
--- /dev/null
+++ b/db/load-distributor-lines.js
@@ -0,0 +1,43 @@
+#!/usr/bin/env node
+/**
+ * Load the 20 distributor internal LINES into canonical dw_unified from
+ * staging/onboarding-manifest.json. GATED (Steve-approved 2026-07-06). Idempotent.
+ *  - vendor_registry row per distributor (vendor_code=<slug>-sg to NOT clobber existing
+ *    Koroseal/ColeSon/Harlequin vendors), is_active=false (offline), use_for_ai=true.
+ *  - keep_offline → INSERT into vendor_never_on_shopify.
+ * NEVER publishes to Shopify. Products stay in sangetsu_catalog (Tier 1 stage, on_shopify=false).
+ *   DATABASE_URL=... node db/load-distributor-lines.js
+ */
+const { Client } = require('pg');
+const fs = require('fs'), path = require('path');
+
+const man = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'staging', 'onboarding-manifest.json'), 'utf8'));
+
+(async () => {
+  const db = new Client({ connectionString: process.env.DATABASE_URL });
+  await db.connect();
+  await db.query('ALTER TABLE vendor_registry ADD COLUMN IF NOT EXISTS use_for_ai boolean DEFAULT false');
+  let n = 0;
+  for (const [dist, L] of Object.entries(man)) {
+    if (dist === '(unassigned)') continue;
+    const code = ((L.slug || dist.toLowerCase().replace(/[^a-z0-9]+/g, '-')).replace(/^-|-$/g, '')) + '-sg';
+    const name = `${dist} (Sangetsu)`;
+    const ex = await db.query('select id from vendor_registry where vendor_code=$1', [code]);
+    if (ex.rows.length) {
+      await db.query('update vendor_registry set use_for_ai=true, is_active=false, catalog_table=$2, updated_at=now() where vendor_code=$1',
+        [code, 'sangetsu_catalog']);
+    } else {
+      await db.query(
+        `insert into vendor_registry (vendor_name,vendor_code,catalog_table,is_active,is_private_label,use_for_ai,display_prices,created_at,updated_at)
+         values ($1,$2,'sangetsu_catalog',false,false,true,false,now(),now())`, [name, code]);
+    }
+    await db.query(
+      `insert into vendor_never_on_shopify (vendor_code,reason,added_at)
+       select $1,'internal distributor line — keep offline (Sangetsu distribution)',now()
+       where not exists (select 1 from vendor_never_on_shopify where vendor_code=$1)`, [code]);
+    n++;
+    console.log(`  ${code.padEnd(28)} patterns=${L.pattern_count} skus=${L.colorway_count} use_for_ai=t keep_offline=t`);
+  }
+  await db.end();
+  console.log(`\nloaded ${n} distributor internal lines (offline, use_for_ai=true). No Shopify publish.`);
+})().catch((e) => { console.error(e); process.exit(1); });

← 51b7196 japan: autonomous local-model onboarding pipeline (manifest  ·  back to Japan Enrich  ·  japan: loader gives each distributor its OWN vendor id + uni b34412a →