@tokenoftrust/cli 7.4.2 → 7.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/cli",
3
- "version": "7.4.2",
3
+ "version": "7.4.4",
4
4
  "description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Token of Trust",
@@ -24,6 +24,7 @@ import { validateManifest } from "../../vendor/private-apps-devkit.mjs";
24
24
 
25
25
  export const DEFAULT_APP_ENV = "test";
26
26
  const OPTION_VERBS = new Set(["install", "update", "rotate", "list", "replay", "test-order", "candidate", "suspend", "resume", "uninstall", "validate"]);
27
+ const TEST_ORDER_TRANSITIONS = new Map([["release", "released"], ["hold", "held"], ["cancel", "canceled"]]);
27
28
 
28
29
  export const ADMIN_USAGE = `tot app — manage Private App installs on your store
29
30
 
@@ -38,12 +39,17 @@ export const ADMIN_USAGE = `tot app — manage Private App installs on your stor
38
39
  tot app rotate <installId> issue a new client secret (printed ONCE); the old one stops working
39
40
  tot app list your store's installs: id, app, version, env, status, scopes (never secrets)
40
41
  tot app replay <deliveryId> re-send a webhook delivery to its install
41
- tot app test-order bind <installId>
42
+ tot app test-order bind <installId> [--location <id>]
42
43
  bind your test install as the store's preview processor
43
44
  (it must be active, with a webhook endpoint and fulfillment:process)
44
- tot app test-order create write one synthetic preview order
45
+ tot app test-order create [--location <id>] [--line <sku>:<qty> ... | --quantity <n>] [--region <state>]
46
+ write one synthetic preview order (--quantity sets the amount of synthetic-sku)
45
47
  tot app test-order release <orderId>
46
48
  claim and release one synthetic preview order
49
+ tot app test-order hold <orderId>
50
+ put a synthetic preview order on hold
51
+ tot app test-order cancel <orderId>
52
+ cancel a synthetic preview order
47
53
  (test orders always act on the store's preview stage, at
48
54
  ${DEFAULT_STOREFRONT_ORIGIN}/<tenant>; no --url needed)
49
55
  tot app candidate status this store's candidates: id, app, version, status
@@ -66,12 +72,17 @@ Options (all online commands):
66
72
  /** Parse the online `tot app` argv. Pure — unit-tested. @param {string[]} argv */
67
73
  export function parseAdminArgs(argv) {
68
74
  /** @type {{ verb: string|null, positional: string[], app: string|null, env: string|null, tenant: string|null,
69
- * url: string|null, webhookEndpoint: string|null|undefined, jwksUri: string|null, jwks: string|null, requestConsent: boolean, json: boolean, help: boolean, unknown: string[] }} */
75
+ * url: string|null, webhookEndpoint: string|null|undefined, jwksUri: string|null, jwks: string|null,
76
+ * location: string|null, lines: string[], quantity: string|null, region: string|null,
77
+ * requestConsent: boolean, json: boolean, help: boolean, unknown: string[] }} */
70
78
  const a = { verb: null, positional: [], app: null, env: null, tenant: null, url: null,
71
- webhookEndpoint: undefined, jwksUri: null, jwks: null, requestConsent: false, json: false, help: false, unknown: [] };
79
+ webhookEndpoint: undefined, jwksUri: null, jwks: null, location: null, lines: [], quantity: null, region: null,
80
+ requestConsent: false, json: false, help: false, unknown: [] };
72
81
  const valueOf = (i, t) => {
73
82
  const eq = t.indexOf("=");
74
- return eq >= 0 ? { value: t.slice(eq + 1), next: i } : { value: argv[i + 1], next: i + 1 };
83
+ if (eq >= 0) return { value: t.slice(eq + 1), next: i };
84
+ const value = argv[i + 1];
85
+ return value === undefined || value.startsWith("--") ? { value: "", next: i } : { value, next: i + 1 };
75
86
  };
76
87
  for (let i = 0; i < argv.length; i++) {
77
88
  const t = argv[i];
@@ -80,7 +91,8 @@ export function parseAdminArgs(argv) {
80
91
  else if (t === "--request-consent") a.requestConsent = true;
81
92
  else if (t === "--help" || t === "-h") a.help = true;
82
93
  else if (flag === "--app" || flag === "--env" || flag === "--tenant" || flag === "--url" || flag === "--webhook-endpoint"
83
- || flag === "--jwks-uri" || flag === "--jwks") {
94
+ || flag === "--jwks-uri" || flag === "--jwks" || flag === "--location" || flag === "--line"
95
+ || flag === "--quantity" || flag === "--region") {
84
96
  const { value, next } = valueOf(i, t);
85
97
  i = next;
86
98
  const v = value === undefined || value.startsWith("--") ? "" : value;
@@ -90,6 +102,10 @@ export function parseAdminArgs(argv) {
90
102
  else if (flag === "--url") a.url = v;
91
103
  else if (flag === "--jwks-uri") a.jwksUri = v;
92
104
  else if (flag === "--jwks") a.jwks = v;
105
+ else if (flag === "--location") a.location = v;
106
+ else if (flag === "--line") a.lines.push(v);
107
+ else if (flag === "--quantity") a.quantity = v;
108
+ else if (flag === "--region") a.region = v;
93
109
  else a.webhookEndpoint = v === "none" ? null : v;
94
110
  } else if (t.startsWith("--")) a.unknown.push(t);
95
111
  else if (a.verb === null) a.verb = t;
@@ -112,18 +128,25 @@ function processorReasonsOf(body) {
112
128
  /** Verbs whose request addresses one install by id, so a bare 404 `not_found` means that install. */
113
129
  const INSTALL_VERBS = new Set(["update", "rotate", "suspend", "resume", "uninstall"]);
114
130
 
115
- /** Plain wording for the not-found, processor and entitlement refusals; null when none applies. */
116
- function plainRefusal(status, body, verb) {
131
+ function refusalCode(status, body, verb, action) {
117
132
  const code = typeof body?.code === "string" ? body.code : "";
118
- if (status === 404 && (code === "install_not_found" || (code === "not_found" && INSTALL_VERBS.has(verb)))) {
119
- return "install_not_found: this store has no install with that id";
133
+ const installAddressed = INSTALL_VERBS.has(verb) || (verb === "test-order" && action === "bind");
134
+ if (status === 404 && installAddressed && (code === "not_found" || (!code && body?.error === "not_found"))) {
135
+ return "install_not_found";
120
136
  }
137
+ if (status === 403 && !code) return "not_entitled";
138
+ return code;
139
+ }
140
+
141
+ /** Plain wording for the not-found, processor and entitlement refusals; null when none applies. */
142
+ function plainRefusal(status, body, code) {
143
+ if (status === 404 && code === "install_not_found") return "install_not_found: this store has no install with that id";
121
144
  if (status === 404 && code === "order_not_found") return "order_not_found: this store has no synthetic preview order with that id";
122
145
  if (code === "install_not_processor") {
123
146
  const says = processorReasonsOf(body).map((r) => PROCESSOR_REASONS[r]?.says ?? r);
124
147
  return `install_not_processor: that install cannot be the preview processor${says.length ? ` — ${says.join("; ")}` : ""}`;
125
148
  }
126
- if (code === "owner_required_for_production_app" || (status === 403 && missingGrantsOf(body).length)) {
149
+ if (code === "owner_required_for_production_app" || code === "not_entitled" || (status === 403 && missingGrantsOf(body).length)) {
127
150
  return "not_entitled: your sign-in is not allowed to do this on this store";
128
151
  }
129
152
  return null;
@@ -131,18 +154,18 @@ function plainRefusal(status, body, verb) {
131
154
 
132
155
  /**
133
156
  * The next step for a refused call: the server's `code` first, then the generic admission hint.
134
- * @param {number} status @param {any} body @param {{ tenant: string, urlOverridden: boolean }} target
157
+ * @param {number} status @param {any} body @param {string} code
158
+ * @param {{ tenant: string, urlOverridden: boolean, verb: string, action: string }} target
135
159
  */
136
- function nextForRefusal(status, body, target) {
137
- const code = typeof body?.code === "string" ? body.code : "";
160
+ function nextForRefusal(status, body, code, target) {
138
161
  if (code === "owner_required_for_production_app") {
139
162
  return "ask the store owner to install the production app, or install with --env=test";
140
163
  }
141
164
  if (status === 401) return "run `tot login`, then re-run";
142
165
  if (code === "scope_denied") return "remove the refused scopes from tot-app.json, then re-run";
143
166
  if (code === "already_installed") return "run `tot app list` for its installId, then `tot app update <installId>`";
144
- if (code === "not_found" || code === "install_not_found") return "run `tot app list` to see this store's installs";
145
- if (code === "order_not_found") return "create one with `tot app test-order create`, then release the orderId it prints";
167
+ if (code === "install_not_found") return "run `tot app list` to see this store's installs";
168
+ if (code === "order_not_found") return `run \`tot app test-order create\`, then use the orderId it prints with \`tot app test-order ${target.action} <orderId>\``;
146
169
  if (code === "install_not_processor") {
147
170
  const fixes = processorReasonsOf(body).map((r) => PROCESSOR_REASONS[r]?.fix).filter(Boolean);
148
171
  return `${fixes.length ? fixes.join("; then ") : "run `tot app list` to check the install"}; then re-run \`tot app test-order bind <installId>\``;
@@ -154,7 +177,7 @@ function nextForRefusal(status, body, target) {
154
177
  : `${preview} has not yet been redeployed with host-free test orders; re-run after its next deploy, or report it with \`tot feedback\``;
155
178
  }
156
179
  if (code === "test_install_required") return "bind an install with env test: `tot app list`, then `tot app test-order bind <installId>`";
157
- if (code === "invalid_state") return "run `tot app list` to check the install's status";
180
+ if (code === "invalid_state" && INSTALL_VERBS.has(target.verb)) return "run `tot app list` to check the install's status";
158
181
  if (status === 403) return refusalHint(status, missingGrantsOf(body));
159
182
  if (status === 429) return "wait a minute, then re-run";
160
183
  if (status >= 500) return "retry shortly; if it persists, report it with `tot feedback`";
@@ -177,6 +200,15 @@ export async function runAdmin(argv, ctx, deps = {}) {
177
200
  }
178
201
  if (args.unknown.length) return fail(`unknown option ${args.unknown[0]}`, "tot app --help");
179
202
  const verb = args.verb;
203
+ const testOrderOptions = [
204
+ [args.location !== null, "--location"],
205
+ [args.lines.length > 0, "--line"],
206
+ [args.quantity !== null, "--quantity"],
207
+ [args.region !== null, "--region"],
208
+ ].filter(([present]) => present).map(([, flag]) => flag);
209
+ if (verb !== "test-order" && testOrderOptions.length) {
210
+ return fail(`unknown option ${testOrderOptions[0]}`, "tot app --help");
211
+ }
180
212
 
181
213
  if (verb === "validate") return runValidateManifest(args, ctx, out, err);
182
214
 
@@ -223,17 +255,41 @@ export async function runAdmin(argv, ctx, deps = {}) {
223
255
  } else if (verb === "list") {
224
256
  request = { method: "GET", path: "/api/apps/admin/list" };
225
257
  } else if (verb === "test-order") {
226
- const action = args.positional[0];
227
- const id = args.positional[1];
228
- if (action !== "bind" && action !== "create" && action !== "release") {
229
- return fail("test-order needs an action: bind, create or release", "tot app test-order bind <installId> | create | release <orderId>");
258
+ const [action, id, extra] = args.positional;
259
+ if (action !== "bind" && action !== "create" && !TEST_ORDER_TRANSITIONS.has(action)) {
260
+ return fail("test-order needs an action: bind, create, release, hold or cancel", "tot app test-order --help");
230
261
  }
231
262
  if (action === "bind" && !id) return fail("no install to bind", "tot app test-order bind <installId> (find it with `tot app list`)");
232
- if (action === "release" && !id) return fail("no order to release", "tot app test-order release <orderId>");
233
- request = {
234
- method: "POST", path: "/api/apps/admin/test-orders",
235
- body: action === "bind" ? { action, installId: id } : action === "release" ? { action, orderId: id } : { action },
236
- };
263
+ if (TEST_ORDER_TRANSITIONS.has(action) && !id) return fail(`no order to ${action}`, `tot app test-order ${action} <orderId>`);
264
+ if (extra || (action === "create" && id)) return fail("unexpected test-order argument", "tot app test-order --help");
265
+ const misplaced = testOrderOptions.find((flag) => action !== "create" && (action !== "bind" || flag !== "--location"));
266
+ if (misplaced) return fail(`test-order ${action} does not accept ${misplaced}`, "tot app test-order --help");
267
+ if (args.location !== null && !args.location.trim()) return fail("--location needs a location id");
268
+ if (args.region !== null && !args.region.trim()) return fail("--region needs a state");
269
+ const location = args.location ? { locationId: args.location.trim() } : {};
270
+ let body;
271
+ if (action === "bind") {
272
+ body = { action, installId: id, ...location };
273
+ } else if (action === "create") {
274
+ if (args.quantity !== null && args.lines.length) return fail("use --quantity or --line, one at a time");
275
+ const lines = [];
276
+ for (const entry of args.lines) {
277
+ const match = /^(.+):(\d+)$/.exec(entry);
278
+ const sku = match?.[1].trim();
279
+ const quantity = Number(match?.[2]);
280
+ if (!sku || !Number.isSafeInteger(quantity) || quantity < 1) return fail("--line needs <sku>:<positive integer>");
281
+ lines.push({ sku, quantity });
282
+ }
283
+ if (args.quantity !== null) {
284
+ const quantity = Number(args.quantity);
285
+ if (!/^\d+$/.test(args.quantity) || !Number.isSafeInteger(quantity) || quantity < 1) return fail("--quantity needs a positive integer");
286
+ lines.push({ sku: "synthetic-sku", quantity });
287
+ }
288
+ body = { action, ...location, ...(lines.length ? { lines } : {}), ...(args.region ? { region: args.region.trim() } : {}) };
289
+ } else {
290
+ body = { action, orderId: id };
291
+ }
292
+ request = { method: "POST", path: "/api/apps/admin/test-orders", body };
237
293
  } else if (verb === "suspend" || verb === "resume" || verb === "uninstall") {
238
294
  const installId = args.positional[0];
239
295
  if (!installId) return fail(`no install to ${verb}`, `tot app ${verb} <installId> (find it with \`tot app list\`)`);
@@ -304,8 +360,10 @@ export async function runAdmin(argv, ctx, deps = {}) {
304
360
  ? `\n refused scopes: ${data.denials.map((d) => d?.scope ?? d?.id ?? JSON.stringify(d)).join(", ")}` : "";
305
361
  const storefrontUrl = String(args.url || env.TOT_STOREFRONT_URL || "").trim().replace(/\/+$/, "");
306
362
  const urlOverridden = storefrontUrl !== "" && storefrontUrl !== DEFAULT_STOREFRONT_ORIGIN;
307
- const plain = plainRefusal(res.status, data, verb);
308
- err(`✗ tot app ${verb}: ${plain ? `${plain} (${reason})` : reason}${denials}\n\n → next: ${nextForRefusal(res.status, data, { tenant, urlOverridden })}`);
363
+ const action = args.positional[0];
364
+ const code = refusalCode(res.status, data, verb, action);
365
+ const plain = plainRefusal(res.status, data, code);
366
+ err(`✗ tot app ${verb}: ${plain ? `${plain} (${reason})` : reason}${denials}\n\n → next: ${nextForRefusal(res.status, data, code, { tenant, urlOverridden, verb, action })}`);
309
367
  return res.status === 401 || res.status === 403 ? 1 : (res.status >= 500 ? 1 : 2);
310
368
  }
311
369
 
@@ -432,11 +490,13 @@ function renderTestOrder(data, args, out) {
432
490
  const action = args.positional[0];
433
491
  if (action === "bind") {
434
492
  const p = data?.processor;
435
- out(`✓ bound ${p?.installId ?? args.positional[1]} as the preview processor (notifiable: ${p?.notifiable}, consent granted: ${p?.consentGranted})`);
493
+ const locationId = p?.locationId ?? args.location?.trim();
494
+ out(`✓ bound ${p?.installId ?? args.positional[1]} as the preview processor${locationId ? ` for ${locationId}` : ""} (notifiable: ${p?.notifiable}, consent granted: ${p?.consentGranted})`);
436
495
  } else if (action === "create") {
437
496
  out(`✓ created synthetic order ${data?.order?.orderId ?? ""} (${data?.order?.stage ?? "preview"})`);
438
497
  } else {
439
- out(`✓ released ${data?.order?.orderId ?? args.positional[1]} (${data?.order?.fulfillment ?? ""}, assigned to ${data?.order?.assignedInstallId ?? "no install"})`);
498
+ const order = data?.order;
499
+ out(`✓ ${TEST_ORDER_TRANSITIONS.get(action)} ${order?.orderId ?? args.positional[1]} (${order?.fulfillment ?? ""}, assigned to ${order?.assignedInstallId ?? "no install"})`);
440
500
  }
441
501
  return 0;
442
502
  }
package/src/validate.mjs CHANGED
@@ -114,7 +114,120 @@ export function catalogSkuFindings(products) {
114
114
  return out;
115
115
  }
116
116
 
117
- function validateCatalogSkus(contentDir, rel) {
117
+ const GENERIC_PRODUCT_TYPES = new Set(["physical", "digital", "gift_certificate"]);
118
+ const CATALOG_FLAVOR_FIELDS = new Set(["flavor", "flavour", "flavors", "flavours"]);
119
+ const CATALOG_CATEGORY_FIELDS = new Set(["compliance category", "product category", "product_category"]);
120
+ const CATALOG_NICOTINE_FORMAT_LABELS = new Set([
121
+ "nicotine salt", "nicotine salts", "salt nicotine", "salt nic", "nic salt", "nic salts", "salt", "salts",
122
+ "freebase", "free base", "freebase nicotine", "free base nicotine", "synthetic", "synthetic nicotine",
123
+ "tfn", "tobacco free nicotine", "tobacco-free nicotine",
124
+ ]);
125
+ const CATALOG_NICOTINE_HINTS = [
126
+ "nicotine", "vape", "vapor", "vaping", "e-liquid", "eliquid", "e-juice", "ejuice",
127
+ "e liquid", "salt nic", "nic salt", "pod", "disposable", "ends", "cig",
128
+ ];
129
+ const CATALOG_ACCESSORY_HINTS = ["battery", "coil", "charger", "case", "lanyard"];
130
+
131
+ function readCatalogMetafield(product, namespace, keys) {
132
+ const mfs = Array.isArray(product?.metafields) ? product.metafields : [];
133
+ const found = mfs.find((m) => m && m.namespace === namespace && typeof m.key === "string" && keys.has(m.key.trim().toLowerCase()));
134
+ return typeof found?.value === "string" && found.value.trim() ? found.value.trim() : undefined;
135
+ }
136
+
137
+ function collectCatalogFlavorLabels(product, variant) {
138
+ const labels = new Set();
139
+ const add = (raw) => {
140
+ const v = String(raw ?? "").trim().toLowerCase();
141
+ if (v && !CATALOG_NICOTINE_FORMAT_LABELS.has(v)) labels.add(v);
142
+ };
143
+ const addList = (raw) => {
144
+ for (const part of String(raw ?? "").split(/[,;|]/)) add(part);
145
+ };
146
+ for (const tag of Array.isArray(product?.tags) ? product.tags : []) {
147
+ if (typeof tag === "string" && tag.startsWith("F: ")) add(tag.slice(3));
148
+ }
149
+ for (const mf of Array.isArray(product?.metafields) ? product.metafields : []) {
150
+ if (!mf || typeof mf.key !== "string") continue;
151
+ const key = mf.key.trim().toLowerCase();
152
+ if (mf.namespace === "compliance" && key === "flavor") addList(mf.value);
153
+ if (mf.namespace === "bigcommerce_custom" && CATALOG_FLAVOR_FIELDS.has(key)) addList(mf.value);
154
+ }
155
+ const opts = variant && typeof variant.option_values === "object" && variant.option_values ? variant.option_values : {};
156
+ for (const [name, value] of Object.entries(opts)) {
157
+ if (CATALOG_FLAVOR_FIELDS.has(name.trim().toLowerCase()) && value) add(value);
158
+ }
159
+ return [...labels];
160
+ }
161
+
162
+ function productClassificationGaps(product) {
163
+ if (!product || typeof product !== "object") return [];
164
+ const category =
165
+ readCatalogMetafield(product, "compliance", new Set(["product_category"])) ??
166
+ readCatalogMetafield(product, "bigcommerce_custom", CATALOG_CATEGORY_FIELDS);
167
+ const productType = typeof product.product_type === "string" ? product.product_type.trim().toLowerCase() : "";
168
+ const merchantType = GENERIC_PRODUCT_TYPES.has(productType) ? "" : productType;
169
+ const categoryClassified = Boolean(category) || merchantType.length > 0;
170
+ const haystack = [
171
+ merchantType,
172
+ (category ?? "").toLowerCase(),
173
+ typeof product.title === "string" ? product.title.toLowerCase() : "",
174
+ ...(Array.isArray(product.tags) ? product.tags : []).map((t) => String(t ?? "").toLowerCase()),
175
+ ].join(" ");
176
+ const isAccessory =
177
+ CATALOG_ACCESSORY_HINTS.some((n) => haystack.includes(n)) &&
178
+ !["e-liquid", "eliquid", "juice", "salt"].some((n) => haystack.includes(n));
179
+ const variants = Array.isArray(product.variants) && product.variants.length > 0 ? product.variants : [null];
180
+ const gaps = new Set();
181
+ if (!categoryClassified) gaps.add("category");
182
+ for (const variant of variants) {
183
+ const nicStrength = typeof variant?.option_values?.["Nicotine strength"] === "string"
184
+ ? variant.option_values["Nicotine strength"].toLowerCase()
185
+ : undefined;
186
+ const nicOptionSaysZero = nicStrength !== undefined && /^0\s*mg\b/.test(nicStrength);
187
+ const nicOptionSaysNonZero = nicStrength !== undefined && /\d/.test(nicStrength) && !nicOptionSaysZero;
188
+ const containsNicotine =
189
+ !isAccessory &&
190
+ (nicOptionSaysNonZero || (!nicOptionSaysZero && CATALOG_NICOTINE_HINTS.some((n) => haystack.includes(n))));
191
+ const flavorClassified = collectCatalogFlavorLabels(product, variant).length > 0;
192
+ if ((containsNicotine || !categoryClassified) && !flavorClassified) gaps.add("flavor");
193
+ }
194
+ return ["category", "flavor"].filter((g) => gaps.has(g));
195
+ }
196
+
197
+ /**
198
+ * Per-tenant compliance classification audit for regulated stores: reports how many catalog
199
+ * products still lack a compliance category or flavour (which checkout refuses in flavour-ban states).
200
+ * @param {Array<{ file: string, record: any }>} products
201
+ * @param {Record<string, any> | null | undefined} config
202
+ * @returns {Finding[]}
203
+ */
204
+ export function catalogComplianceFindings(products, config) {
205
+ if (!isRegulatedCompliance(config?.compliance) || !Array.isArray(products) || products.length === 0) return [];
206
+ const unclassified = [];
207
+ let missingCategory = 0;
208
+ let missingFlavor = 0;
209
+ for (const { file, record } of products) {
210
+ const gaps = productClassificationGaps(record);
211
+ if (gaps.length === 0) continue;
212
+ if (gaps.includes("category")) missingCategory += 1;
213
+ if (gaps.includes("flavor")) missingFlavor += 1;
214
+ const handle = typeof record?.handle === "string" && record.handle.trim() ? record.handle.trim() : file;
215
+ unclassified.push(handle);
216
+ }
217
+ if (unclassified.length === 0) return [];
218
+ const sample = unclassified.slice(0, 5).join(", ") + (unclassified.length > 5 ? ", ..." : "");
219
+ return [
220
+ mk(
221
+ WARN,
222
+ "catalog-compliance-unclassified",
223
+ "content/catalog/products",
224
+ `${unclassified.length} of ${products.length} catalog product(s) are not classified for compliance (${missingCategory} missing category, ${missingFlavor} missing flavour; e.g. ${sample}) — checkout refuses unclassified products in flavour-ban states`,
225
+ "classify at the source (BigCommerce \"Compliance Category\" and \"Flavor\" custom fields) or run `node agency-kit/tools/classify-catalog.mjs --store <checkout> --suggest <review.csv>`, review every row with the merchant, and apply with `--apply <review.csv> --write` (devbook://storefront-devbook-compliance-classification)",
226
+ ),
227
+ ];
228
+ }
229
+
230
+ function validateCatalogSkus(contentDir, rel, config = null) {
118
231
  const dir = join(contentDir, "catalog", "products");
119
232
  if (!existsSync(dir)) return [];
120
233
  /** @type {Finding[]} */
@@ -126,7 +239,7 @@ function validateCatalogSkus(contentDir, rel) {
126
239
  if (error) parseErrors.push(mk(ERROR, "catalog-parse", rel(path), `invalid JSON: ${error}`));
127
240
  else products.push({ file: rel(path), record: value });
128
241
  }
129
- return [...parseErrors, ...catalogSkuFindings(products)];
242
+ return [...parseErrors, ...catalogSkuFindings(products), ...catalogComplianceFindings(products, config)];
130
243
  }
131
244
 
132
245
  // --- canonical `.tot/config.json` shape (the #24/#25 regression guard) --------
@@ -995,6 +1108,11 @@ export const LOUD_ADVISORY_RULES = [
995
1108
  "a previously-declared data-tot-el changed value",
996
1109
  "The page still works, but everything already recorded under the old id is now orphaned — this identity is supposed to be permanent.",
997
1110
  ],
1111
+ [
1112
+ "catalog-compliance-unclassified",
1113
+ "regulated catalog products missing compliance category or flavour classification",
1114
+ "Checkout fails closed in flavour-ban states (CA, MA, NJ, NY, RI) and refuses every unclassified product — including tobacco and unflavoured items — until category and flavour are recorded (see agency-kit/tools/classify-catalog.mjs and devbook://storefront-devbook-compliance-classification).",
1115
+ ],
998
1116
  ];
999
1117
 
1000
1118
  /**
@@ -1399,7 +1517,7 @@ export function validateTenant(tenantDir, opts = {}) {
1399
1517
  }
1400
1518
  }
1401
1519
 
1402
- findings.push(...validateCatalogSkus(contentDir, rel));
1520
+ findings.push(...validateCatalogSkus(contentDir, rel, config));
1403
1521
 
1404
1522
  const capabilitiesPath = located("capabilities.json");
1405
1523
  if (existsSync(capabilitiesPath)) {