← back to Dw Retail Halving Preview

README.md

37 lines

# dw-retail-halving-preview

READ-ONLY dry-run tooling for Steve's ambiguous request: *"go and cut the retail
prices in half from online for price…"* on the DW Shopify catalog.

DTD panel committed **verdict B** (2–1, Codex+Claude over Qwen): do the safe,
reversible prep (preview + rollback design + gated memo) now; do NOT guess the
scope or the meaning of "from online" into a live change.

## Files
- `halve-preview.js` — READ-ONLY. Reads the LOCAL `dw_unified` mirror
  (`shopify_products`) via `psql`, never writes anything, never touches Shopify
  or the Kamatera-canonical DB. Emits a CSV: `dw_sku, vendor, current_retail,
  halved_retail, sample_price, excluded_reason`.
  - Excludes every Kravet-umbrella brand (MAP-priced) → `excluded_reason=MAP`.
  - Skips rows where halved price would be 0/null → `excluded_reason=zero_price_guard`.
  - `halved_retail = round(current_retail / 2, 2)` for eligible rows.
- `apply-halving-LIVE.js` — GATED live-write executor. **INERT** in this build;
  refuses `--execute`. Snapshots every targeted variant's live price to a
  rollback CSV BEFORE any update. Implement + run only on Steve's explicit go.

## Usage
```
node halve-preview.js [--status ACTIVE] [--vendor "Thibaut"]... [--limit 50] \
                      [--price-col price|retail_price|min_variant_price] \
                      [--order vendor|random] [--out /abs/path.csv]
```

## Price-source note ("from online")
In the local mirror, the customer-facing online variant price is `price`
(18,541 ACTIVE populated). `retail_price` is sparse (7,650). The tool defaults
to `price`. The live write must re-read the authoritative current price from
Shopify at write-time (ground truth), not this mirror.

## Cost
$0 (local psql + node only; no paid API).