← back to Harlequin Sample Price Analysis
README.md
35 lines
# harlequin-sample-price-analysis (TK-10870)
Read-only analysis + tooling for the Harlequin (Sanderson Design Group) missing-sample
and per-roll price question. **This repo never writes to Shopify or dw_unified.**
## What's here
- `scripts/pricing.mjs` — pure, dependency-free DW pricing + row-classification logic
(`retail = cost / 0.65 / 0.85`; MAP-floor + gap flags). No I/O.
- `scripts/integrity.mjs` — pure, reusable catalog-integrity detectors (product-id collisions,
mfr_sku mis-stamps, junk mfr_sku, cost gaps) — generalises the TK-10870 findings to ANY vendor.
- `scripts/integrity-report.mjs` — read-only runner:
`node scripts/integrity-report.mjs <catalog_table> "<shopify_filter>"` → PASS/WARN/FAIL verdict.
Verified against live Harlequin: 1 collision, 2 mis-stamps, 3 junk, 1 cost-gap → FAIL.
- `scripts/analyze-harlequin.mjs` — read-only harness: reads the on-Shopify cohort from
the `dw_unified` mirror via `psql` (forced `default_transaction_read_only=on`), applies
`pricing.mjs`, writes `artifacts/harlequin-analysis.{json,md}`.
- `tests/pricing.test.mjs` — `node --test` unit tests for the money math (no DB, no network).
- `FINDINGS.md` — the corrected findings that supersede the stale "COST=UNKNOWN" premise.
- `artifacts/` — generated analysis snapshot (JSON + markdown).
## Run
```sh
node --test # prove the pricing math (11 tests)
node scripts/analyze-harlequin.mjs # live read-only analysis → artifacts/
```
Override the source with `PGHOST` / `PGDATABASE`, or run offline:
`node scripts/analyze-harlequin.mjs --from-json artifacts/harlequin-analysis.json`
## Safety
- The harness asserts its SQL is SELECT-only and forces a read-only Postgres session
(server rejects any write). Verified: `CREATE TABLE` fails with
`cannot execute CREATE TABLE in a read-only transaction`.
- The 32 Sample-variant adds were done by a prior gated pass; this repo does not repeat them.
- Any live Shopify sell-price write remains Steve-gated.