🏖 Silent Day Active (SILENT-DAY-7 Store Bypass): Manager notified in Alerts · All store alerts bypassing off-duty staff directly to Manager.
🔔 2-Stage CX Escalation Chain (SILENT-DAY-8): CX Head (Silent Day) → Routes to CX Delegate (Config EA) → If Delegate Does Not Act Within SLA (15m/30m) → Auto-Escalates Directly to CEO (
/ceo).← Back to Oven Command
DESIGN-TDD-UIUX-STOP3-NPL-LIFECYCLE.md
# Stop 3 Detailed Design, TDD & UI/UX Spec: 7-Stage NPL Engine — 1 Named Owner/Layer (L1–L7), CK Batch Tracking, Cold-Chain, Last-Mile & Rollout Adoption Roll-Up (`STOP 3 · STAGE 2–4 DESIGN + TDD + UI/UX · T1-10 · L1–L7 NAMED OWNERS · ROLL-UP & HOP NUDGE · J18`)
> **Harley's Executive 2-Page Readout (0.5p Summary + 1.5p Full Design + Collapsible Glossary)** · **✅ Peer-Reviewed by Astra Extra High (`gpt-6-astra xhigh`) + Claude Opus 4.7 Extra High** · ✅ STAGE 1 INTAKE SIGNED BY OWNER (20:43 IST) · Peer-Reviewed (Astra XHigh + Opus 4.7) · Double-Clicked on: (1) 1 Single Named Owner per Layer (L1–L7), (2) CK 200kg Scaling & HRL-LOT-* Crate QR, (3) Cold-Chain +2..+4°C Reefer & Store Probe, (4) Per-Store Ground Enablement & First-10-Orders Last-Mile Gate, (5) Last-Minute Rollout Adoption Roll-Up Summary & 5-Axis Filter Engine, (6) Full HOP Nudge & Accountability Framework Compliance (acct-* / O-022 / O-045)
> **🔒 100% INTAKE & DESIGN GATES LOCKED BY OWNER (`App 0 -> App 6` · `2026-10-22 22:44 IST` — Ratified by `cfo@harleys.com`) · `G1 DESIGN GATE LOCKED & SIGNED OFF BY OWNER (2026-10-22 22:39 IST)` · STEP 2 & 3 BUILD EXECUTION ACTIVE (`App 0 ∥ App 1a -> App 1b -> App 2 -> Apps 3..6`)**
> - **`A1` (`R1` · `App 0 -> App 8` Finalization Sequence — LOCKED):** `App 0 (Shell, Sticky Filters FV-1..12, Bot O-048, CI/CD TC-1..14, Enablement EN-01..19) ∥ App 1a (Identity Spine SP0+SP1: hop.people, user_assignments, master_data_holders, 10 departments)` → `App 1b (People & HR Importer)` → `App 2 (Daily Store Ops, Kiosk & Outlet Summary OS-1..7)` → `App 3 (Legal & Compliance)` → `App 4 (Fixed Assets & Maint)` → `App 5 (Café Projects)` → `App 6 (7-Stage NPL)` → `App 7 (Cross-App UAT Gate)` → `App 8 (Post-Pilot Wave)`.
> - **`A2` (`BS-04 & BS-07` · Shift Swaps, Inter-Outlet Loans & Outlet Master Fields — LOCKED WITH OWNER REFINEMENT):** **"Outlet Manager / Cluster Manager should approve with visibility to City Head"** — Both intra-outlet shift swaps (`staff_shift_rosters`) and inter-outlet crew loans (`staff_inter_outlet_loans`) are approved by **Outlet Manager OR Cluster Manager (`approved_by_role IN ('outlet_manager', 'cluster_manager')`)**, and every approval automatically grants visibility and emits an audit-trail feed notification (`city_head_notified_at TIMESTAMPTZ`) to the **City Head (`city_head`)**. Locks all 12 core `outlets` master fields (`BS-07`).
> - **`A3` (`OV-6 & AD-1..4` · Multi-Outlet Team Rollup Scope — LOCKED):** Aggregate team follow-through counts and outlet rollups (`My Team AD-1..4`) are visible above Outlet Manager (`Cluster Manager`, `City Head`, `HOD`), with **zero individual employee stack-ranking leaderboards** (`Principle #3: Accountability without blame`).
> - **`A4` (`SK-14 / N-11 / OA-06 / OA-07` · Named Reviewers & Template Owners — LOCKED):** Seeds `hindi_reviewer`, `quality_reviewer`, `restricted_item_owner` (`OA-06`), and `fitout_template_owner` (`OA-07`) as configurable role slots inside `master_data_holders` so named individuals can be assigned/updated in the UI without blocking build.
> - **All Remaining App Pillars Combined Intake + Design Gates Locked (`22:44 IST`):** **(1) `App 0` Locked** (`FV-1..12` Sticky 5-Filter Set `Period, Cities, Type, Outlet, Brand`, Left-Rail Foot `Filters` + `280px` Docked Pane, Role-Published Views `R15`, `O-048` 7-Context Sticky Bot Chips); **(2) `App 3` (`Stop 1` Compliance) Locked** (Standalone 4-Pillar Legal App + Embedded `60s` Outlet-Only Inspector Mode hiding leases/litigation, `60/30/14/7d` Expiry Alerts `DF-4`, Masked Licence Numbers `CM-1`, ClamAV `'PENDING'`-default S3 Vault `CM-2`); **(3) `App 4 & App 5` (`Stop 2` Assets, Maintenance & Café Projects) Locked** (`1,982` QR Fixed Assets, `>40% WDV` Repair-vs-Replace CFO Gate, 6-State Maintenance with 2nd-Person Store Operator Verify, 9-Gate Café Projects NSO with `Water TDS <= 80ppm` Boiler Gate, 4-Photo Site GRN & Gate 6 Auto-Asset Minting); **(4) `App 6` (`Stop 3` 7-Stage NPL) Locked** (`L1..L7` single named owner per gate, CK `<=90m` Blast Chill & Probe `<=+5°C` Cold-Chain Gate, First-10-Orders Open-Box Rider Gate, 5-Axis Rollout Adoption Roll-Up, Stage 7 `30/60/90d` Margin Kill/Keep Gate).
---
## PART 1 · EXECUTIVE SUMMARY (0.5 PAGE)
### 1A. What We Are Building & Why
- **✅ Stage 1 Intake Approved by Owner at `20:43 IST` — Advancing Stop 3 (`T1-10 · 7-Stage Patisserie & Beverage NPL Engine`) to Stage 2 (Detailed Design), Stage 3 (Fail-First TDD), and Stage 4 (UI/UX & 9-Frame `J18` Storyboard):** Directly executes the Owner's deep-dive and `20:52 IST` Rollout Adoption Roll-Up & HOP Accountability mandate across Central Kitchen, Cold-Chain Fleet, 32 Café Outlets, and Last-Mile Aggregators.
- **The 6 Operational Execution Pillars:** **(1) 1 Single Named Owner (`person_id`) at Every Layer (`npl_layer_ownership_matrix` — `L1` Chef Vikramaditya `H-000104`, `L2` Dr. Ananya Rao `H-000112`, `L3` Suresh Nair `CK-1 H-000118`, `L4` Mahesh Goud `H-000124`, `L5` Karthik Reddy `H-000129`, `L6` 1 Named Store Mgr per Outlet `Rohit MGR-01 / Priya MGR-02 / Arvind MGR-04`, `L7` 1 Named FOH Dispatch Lead per Outlet `Chimkila S CREW-04`)**; **(2) Central Kitchen (CK) Commercial Scaling & Crate-Level Lot QR (`npl_ck_enablement_runs` & `npl_crate_lots`)**; **(3) Cold-Chain Logistics & Crate-to-Counter Transit Handshake (`npl_logistics_manifests`)**; **(4) Per-Store Ground Enablement -> Last-Mile Rider Handover (`npl_ground_outlet_readiness` & `npl_last_mile_tracking`)**; **(5) Last-Minute Rollout Adoption Roll-Up Summary & 5-Axis Filter Engine (`npl_rollout_adoption_rollup`: `🟢 Adopted 21/32 (65.6%)`, `🟡 Lagging 7/32 (21.9%)`, `🔴 Not Adopted 4/32 (12.5%)`, `👥 Crew Cert 482/540 (89.3%)`, 5-Axis Filters, 4 Group-By Views & 1-Tap Batch HOP Nudge)**; **(6) Full HOP Nudge & Accountability Compliance (`acct-*` / `O-022` / `O-045`: `T-24h -> T-6h -> T-2h -> T-0` Escalation Ladder, M3 2nd-Person Confirm/Return, Snooze Cap `Max 2: +15m/+30m`, and Structured `✕ Cannot` 6-Reason Chips with Automatic Upstream Re-Routing to `L3 CK` / `L4 Logistics`)**.
- **13-Table/View PostgreSQL Schema, 18 REST Endpoints, 30 Fail-First TDD Tests & Refreshed 9-Frame `J18` Storyboard (`/static/journeys/j18-npl-7stage-patisserie.html`):** Every layer handoff, roll-up filter, and HOP Nudge escalation is fail-closed in SQL and verified by Playwright `T0` checks.
### 1B. Personas & Access Scope
- **Founder / COO / Ops Lead (`Rollout Adoption Roll-Up Tower`)**: Uses the **Top Executive Roll-Up KPI Strip**, **5-Axis Filter Matrix** (`Adoption Status`, `Cluster/City/Format`, `Blocking Layer L1–L7`, `Role/Station`, `HOP Escalation Tier 0..3`), **Group-By Toggle** (`By Outlet (32)`, `By Cluster (5)`, `By Blocking Layer`, `By Named Owner / Non-Adopted Staff`), and **`[🔔 1-Tap Batch HOP Nudge to All Non-Adopted Owners]`**.
- **L1 Named R&D Chef (`Chef Vikramaditya · H-000104`) & L2 Named QA/Lab Lead (`Dr. Ananya Rao · H-000112`)**: `L1` signs Stage 1–2 4-Tier BOM (`<=28%` COGS, recipe version invalidation); `L2` signs $a_w/\text{pH}$, Big-9 Allergens, 9-Attribute Blind Panel (`>=4.0`), `T+72h` Decay Curve, and 30-Min Motorbike Vibration/Tilt Test.
- **L3 Named CK Production Head (`Suresh Nair · CK-1 H-000118`) & L4 Named Cold-Chain Controller (`Mahesh Goud · H-000124`)**: `L3` signs 200kg commercial trial batch (`CK-TRIAL-01`), blast-chill pull-down (`<=90m`), and Crate Lot QRs (`HRL-LOT-*`); `L4` signs Reefer `+2..+4°C` pre-cool, BLE logger pairing, and receives automatic re-routed HOP Nudges whenever an `L6` store reports `✕ Cannot: CK Crate Short` or `Cold-Chain Temp Excursion`.
- **L5 Named POS Lead (`Karthik Reddy · H-000129`), L6 Named Store Manager (`NAN: Rohit MGR-01`, `JUB: Priya MGR-02`, `KOK: Arvind MGR-04`) & L7 FOH Dispatch Lead (`NAN: Chimkila S CREW-04`)**: `L6` completes the 4 Store Ground Readiness Gates (or logs a structured `✕ Cannot` upstream block) to unlock POS; Cluster Manager (`CLM-01`) performs **M3 Independent Verification (`✓ Confirm` / `↩ Return`)**; `L7` captures the **First-10-Orders Open-Box Pack Photo**.
### 1C. Owner Sign-Off Decisions Required
- [x] **[RATIFIED & LOCKED BY OWNER · 2026-10-22 22:39/22:44 IST — 100% INTAKE & DESIGN GATES LOCKED (App 0 -> App 6)]** **Stage 2 (Detailed Design Sign-Off):** Approve the **13-Table/View NPL & HOP Accountability Schema** (`npl_skus`, `npl_layer_ownership_matrix`, `npl_subrecipe_bom`, `npl_food_safety_lab`, `npl_sensory_decay_curve`, `npl_packaging_stress_test`, `npl_ck_enablement_runs`, `npl_crate_lots`, `npl_logistics_manifests`, `npl_ground_outlet_readiness`, `npl_last_mile_tracking`, `npl_cannot_block_receipts`, `npl_rollout_adoption_rollup`).
- [x] **[RATIFIED & LOCKED BY OWNER · 2026-10-22 22:39/22:44 IST — 100% INTAKE & DESIGN GATES LOCKED (App 0 -> App 6)]** **Stage 3 (Fail-First TDD Sign-Off):** Approve the **30-Test Fail-First TDD Suite (`tests/test_stop3_npl_end_to_end.py`)** covering `L1..L7` named ownership, CK/Cold-Chain gates, per-store `LOCKED_NOT_ENABLED` POS guard, **5-axis roll-up filtering**, **HOP Nudge `T-24h -> T-6h -> T-2h -> T-0` escalation**, **M3 Confirm/Return (`verified_by_id != completed_by_id`)**, and **`✕ Cannot` upstream re-routing**.
- [x] **[RATIFIED & LOCKED BY OWNER · 2026-10-22 22:39/22:44 IST — 100% INTAKE & DESIGN GATES LOCKED (App 0 -> App 6)]** **Stage 4 (UI/UX & `J18` Storyboard Sign-Off):** Approve the **9-Frame Interactive `390px/1100px` Storyboard ([`j18-npl-7stage-patisserie.html`](/static/journeys/j18-npl-7stage-patisserie.html))** including Frame 7 (Last-Minute Rollout Adoption Roll-Up Summary & 5-Axis Filter Engine).
### 1D. Direct Navigation & Live Pre-Signed-In Routes
- [📋 Jump to Part 2: Full Intake, Domain Design & Industry Benchmarks](#part-2--full-intake--domain-object-design-15-pages) | [📖 Jump to Part 3: Glossary, DDL & Corpus Appendix](#part-3--glossary-schema-ddl--corpus-appendix)
- 🟢 **J18 9-Frame Interactive Storyboard**: `/static/journeys/j18-npl-7stage-patisserie.html`
- 🟢 **Local :8000 NPL 7-Stage Console**: `http://localhost:8000/admin/npl`
- 🟢 **Local :8000 NPL JSON API**: `http://localhost:8000/api/npl/summary`
- 🟢 **Staging HOP NPL Console**: `https://test.hop.harleys.com/admin/npl`
---
## PART 2 · FULL INTAKE & DOMAIN OBJECT DESIGN (1.5 PAGES)
### 2A. Core User Journeys & Functional Intake Rules
| Journey / Flow | Actor & Trigger | System Action & Hard Gate Rule |
| :--- | :--- | :--- |
| **API-1 & TDD-1 (Pillar 1) · 1 Single Named Owner per Layer (`POST /api/npl/skus/{id}/layer-owners`)** | COO / NPL Program Lead -> `npl_layer_ownership_matrix` | Binds `L1_RD_FORMULATION` (`H-000104`), `L2_QA_LAB_PACKAGING` (`H-000112`), `L3_CK_PRODUCTION` (`H-000118`), `L4_COLD_CHAIN_LOGISTICS` (`H-000124`), `L5_POS_AGGREGATOR_SYNC` (`H-000129`), `L6_GROUND_OUTLET_ENABLEMENT` (`1 Store Mgr / Outlet`), and `L7_LAST_MILE_EXECUTION` (`1 FOH Lead / Outlet`). Rejects launch creation (`HTTP 409 MISSING_NAMED_LAYER_OWNER`) if any layer has `person_id IS NULL` or a shared role group. |
| **API-2 & TDD-2 (L1 -> L2) · 4-Tier BOM (`<=28%` COGS), $a_w/\text{pH}$, 72h Decay & 30m Bike Test** | `L1` Chef Vikramaditya -> `L2` Dr. Ananya Rao | Enforces `total_food_cost_pct <= 28.0`, `water_activity_aw <= 0.85` (or `CHILLED_2_4C` lock), `mean_hedonic_score >= 4.0`, `T+4h..72h` decay curve, and 30-min motorbike `25°` tilt test (`board_slide_mm <= 2.0`). Any later BOM edit increments `bom_version` and invalidates `L2..L6` sign-offs. |
| **API-3 & TDD-3 (Pillar 2 — L3: Suresh Nair) · CK 200kg Commercial Scaling & Crate Lot QR (`POST /api/npl/skus/{id}/ck-batches`)** | `L3` CK Production Head (`H-000118`) | Verifies commercial deck-oven steam profile, blast-chiller pull-down (`+65°C -> +3.0°C in <= 90 mins`), and line crew certification (`Sponge, Frosting, Ultrasonic Portioning`) on `CK-TRIAL-01`. Mints Crate Lot QRs (`HRL-LOT-{SKU}-{CK}-{YYYYMMDD}-{BATCH}`) and opens `D-2/D-1/D-0 05:00 AM` automated store indenting. |
| **API-4 & TDD-4 (Pillar 3 — L4: Mahesh Goud -> L6 Store Mgr) · Cold-Chain Reefer & Store Door Probe (`POST /api/npl/crates/{lot_qr}/receive`)** | `L4` Fleet Controller (`H-000124`) -> `L6` Store Manager | Blocks CK dispatch unless reefer cabin is pre-cooled to `+2.0°C..+4.0°C`, BLE logger is paired, and crate stack height `<= max_safe_stack` (dual sign-off: `L3 + Driver`). Fires a P1 alert to `L4` if in-transit temp `> +6.0°C for > 15m`. At café door, `L6` scans `HRL-LOT-*` and probes temp; if `receiving_probe_c > 5.0` or `visual_state == 'CRUSHED'`, auto-quarantines the crate (`HTTP 409 COLD_CHAIN_CRATE_QUARANTINED`). |
| **API-5 & TDD-5 (Pillar 4A — L5: Karthik Reddy & L6: Store Mgr) · Per-Store Ground Enablement Unlocks POS (`POST /api/npl/skus/{id}/outlets/{outlet_id}/enable`)** | `L5` POS Lead (`H-000129`) -> `L6` Store Manager (`NAN: Rohit MGR-01`) | `L5` syncs Rista POS + Swiggy/Zomato SKU in `LOCKED_NOT_ENABLED` state per store. The API refuses to flip a store to `ENABLED_LIVE` (`HTTP 409 STORE_GROUND_ENABLEMENT_INCOMPLETE`) until `L6` signs off with 4-digit PIN on: (1) 60s `EN/HI/TE` BOH Video + **1 Practice Plate Photo**, (2) **`>= 90%` FOH Barista Tasting/Allergen Quiz**, (3) Chiller planogram + FSSAI tent card **Live Showcase Photo**, and (4) Insert box + frozen gel-pack stock count `>= 50`. |
| **API-6 & TDD-6 (Pillar 4B — L7: FOH Dispatch Lead) · First-10-Orders Open-Box Rider Handover Gate (`POST /api/npl/orders/{order_id}/handover`)** | `L7` FOH Dispatch Lead (`NAN: Chimkila S CREW-04`) | For `store_order_seq BETWEEN 1 AND 10`, hard-blocks rider handover (`HTTP 409 FIRST_10_OPEN_BOX_PHOTO_REQUIRED`) unless `open_box_photo_sha256` is uploaded showing collar + 50g frozen gel pack + allergen seal. Continuously tracks per-store Last-Mile Damage (`<= 1.0%`), Prep-to-Handover (`<= 90s`), and Rating (`>= 4.6★`); auto-resets the 10-order photo gate if store transit damage `> 1.5%`. |
| **API-7 & TDD-7 (Pillar 5 — Last-Minute Rollout Adoption Roll-Up & 5-Axis Filter Engine) · `GET /api/npl/skus/{id}/adoption-rollup` & `POST /nudge-non-adopted`** | Founder / COO / Ops Lead / Cluster Mgr | Aggregates live outlet & staff readiness into the **Executive Roll-Up Strip**: `🟢 Adopted & POS Unlocked (21/32 · 65.6%)`, `🟡 Last-Minute Lagging / T-6h Risk (7/32 · 21.9%)`, `🔴 Not Adopted / Gate Locked (4/32 · 12.5%)`, and `👥 Crew Certification Roll-Up (482/540 Crew · 89.3% · 58 Pending across 11 Stores)`. Supports **5-Axis Multi-Select Filtering** (`status`, `cluster_id/city/format`, `blocking_layer L1..L7`, `role_station`, `hop_escalation_tier 0..3`), **4 Group-By modes** (`outlet`, `cluster`, `blocking_layer`, `named_owner`), and **`[🔔 1-Tap Batch HOP Nudge]`** dispatching durable WhatsApp + in-app nudges to all non-adopted owners. |
| **API-8 & TDD-8 (Pillar 6 — HOP Nudge & Accountability Compliance `acct-*` / `O-022` / `O-045`) · `POST /api/npl/readiness/{id}/cannot` & `/m3-verify`** | L6 Store Mgr -> Upstream L3/L4 Owner & Cluster Mgr (`M3`) | Enforces: **(1) Escalation Ladder:** `Named Owner (T-24h) -> HOP Nudge #1 + Store Mgr (T-6h/+15m) -> HOP Nudge #2 + Cluster Mgr (T-2h/+30m) -> City/COO Hard Launch Lock (T-0)` with `snooze_count <= 2`; **(2) M3 Verification:** `✓ Confirm = I checked the work` (`verified_by_id <> completed_by_id`) vs `↩ Return for correction` (`mandatory_reason + revision_count++ + instant re-nudge`); **(3) Structured `✕ Cannot` 6-Reason Chips (`CK_CRATE_SHORT`, `COLD_CHAIN_TEMP_EXCURSION`, `PACKAGING_INSERT_MISSING`, `POS_SKU_MISSING`, `CHILLER_DOWN`, `STAFF_SHORTAGE`)**—selecting `CK_CRATE_SHORT` or `PACKAGING_INSERT_MISSING` records an immutable `BLOCKED` receipt for the store (`npl_cannot_block_receipts`) and **automatically transfers accountability + HOP Nudge upstream to `L3 CK` (`Suresh Nair · H-000118`) or `L4 Logistics` (`Mahesh Goud · H-000124`)**! |
### 2B. Underlying Domain Objects & How They Work Together
```text
END-TO-END NPL EXECUTION, ROLLOUT ADOPTION ROLL-UP & HOP ACCOUNTABILITY PIPELINE (L1 -> L7):
[L1 Chef Vikramaditya (H-000104): BOM <=28%] --> [L2 Dr. Ananya Rao (H-000112): a_w/pH + 72h Decay + 30m Bike Tilt]
--> [L3 Suresh Nair (CK-1 H-000118): 200kg Scaling + <=90m Blast Chill + Crate QR (HRL-LOT-*)]
--> [L4 Mahesh Goud (H-000124): Reefer +2..+4°C + BLE Logger] --(Store Door Probe <=+5°C)--> [L5 Karthik Reddy (H-000129): LOCKED_NOT_ENABLED]
--> [L6 Named Store Mgr (Rohit MGR-01): Practice Plate + >=90% Quiz + Planogram + Box/Gel Stock] --(M3 Cluster Mgr Confirm / Return)--> [UNLOCKS STORE POS]
| +-- (If ✕ Cannot: CK_CRATE_SHORT / PACKAGING_MISSING) --> [Auto-Transfers Accountability & HOP Nudge Upstream to L3 CK / L4 Logistics!]
--> [L7 Named FOH Dispatch Lead (Chimkila S CREW-04): First-10-Orders Open-Box Photo + <=90s Handover]
==> [npl_rollout_adoption_rollup: 🟢 21 Adopted | 🟡 7 Lagging | 🔴 4 Blocked | 👥 482/540 Crew | 5-Axis Filter & 1-Tap Batch HOP Nudge]
```
| Domain Object (`Table`) | Primary Key & Scope | Key Attributes & Constraints | Cross-Object Handshake |
| :--- | :--- | :--- | :--- |
| `npl_layer_ownership_matrix` | `ownership_id (PK), sku_id (FK), layer_code (L1..L7), outlet_id` | named_person_id (FK hop.people NOT NULL), person_code, phone, sla_due_at, signed_via_pin_at, escalation_tier (0..3), snooze_count (<=2) | Eliminates committee ownership; binds 1 single named person to each of `L1..L7` with HOP Nudge timers. |
| `npl_ck_enablement_runs & npl_crate_lots` | `ck_run_id (PK), lot_qr (PK `HRL-LOT-*`)` | ck_facility_id (`CK-1`/`CK-2`), trial_batch_code, pull_down_minutes (<=90), core_temp_c (<=4.0), sponge_baker_id, frosting_baker_id, portion_baker_id, use_by_at | Governs CK 200kg scaling, line certification, and crate-level lot traceability. |
| `npl_logistics_manifests` | `manifest_id (PK), lot_qr (FK), dest_outlet_id` | reefer_vehicle_no, precool_temp_c (2..4), ble_logger_id, max_excursion_c, stack_height_crates (<=3), ck_dispatch_pin_by, driver_sign_by, store_probe_temp_c (<=5.0), store_condition, accepted_by_l6_id | Enforces Crate-to-Counter cold-chain integrity and auto-quarantines warm/crushed crates. |
| `npl_ground_outlet_readiness` | `readiness_id (PK), sku_id (FK), outlet_id` | l6_store_mgr_id, boh_video_watched_pct (=100), practice_plate_photo_sha256, foh_quiz_pass_pct (>=90), showcase_planogram_photo_sha256, box_stock_qty (>=50), gel_pack_stock_qty (>=50), m3_verified_by_id, revision_count, pos_unlock_status | Keeps Rista POS & Swiggy/Zomato `LOCKED_NOT_ENABLED` until all 4 ground gates + M3 verification are green. |
| `npl_cannot_block_receipts & accountability_nudges` | `receipt_id (PK), nudge_id (PK)` | outlet_id, reported_by_l6_id, cannot_reason_chip (6 enum values), evidence_photo_sha256, rerouted_to_layer (`L3_CK`/`L4_LOGISTICS`/`L5_POS`), rerouted_owner_person_id, escalation_tier (0..3), delivery_receipt_status | Implements structured `✕ Cannot` upstream accountability transfer and durable HOP Nudge receipts (`acct-*`). |
| `npl_rollout_adoption_rollup (View) & npl_last_mile_tracking` | `sku_id, outlet_id, dispatch_id (PK)` | adoption_status (`ADOPTED_LIVE`/`LAGGING_RISK`/`NOT_ADOPTED_BLOCKED`), cluster_code, city, outlet_format, blocking_layer_code (`L3..L7`), pending_crew_count, hop_escalation_tier (0..3), open_box_photo_sha256 (seq 1..10) | Powers the Last-Minute Rollout Adoption Roll-Up Summary, 5-Axis Filter Matrix, 4 Group-By modes, and First-10-Orders rider gate. |
### 2C. State Machines & Operational Guardrails
- **Pillar 1 · 1 Single Named Owner (`person_id`) per Layer (`L1–L7`)**: <strong>L1 R&D:</strong> Chef Vikramaditya (`H-000104`) · <strong>L2 QA/Lab:</strong> Dr. Ananya Rao (`H-000112`) · <strong>L3 CK Head:</strong> Suresh Nair (`H-000118`) · <strong>L4 Cold-Chain:</strong> Mahesh Goud (`H-000124`) · <strong>L5 POS/Menu:</strong> Karthik Reddy (`H-000129`) · <strong>L6 Store Ground:</strong> 1 Named Store Mgr/Outlet (`Rohit MGR-01`, etc.) · <strong>L7 Last-Mile:</strong> 1 Named FOH Lead/Outlet (`Chimkila S CREW-04`).
- **Pillar 2, 3 & 4 · CK Crate QR (`HRL-LOT-*`), Cold-Chain & Per-Store POS Unlock**: <code>CK_SCALING_CERTIFIED</code> → <code>CRATE_QR_MINTED</code> → <code>REEFER_2_4C</code> → <code>STORE_PROBE_LE_5C</code> → <code>4_GROUND_GATES_AND_M3_CONFIRM</code> → <code>STORE_POS_UNLOCKED</code> → <code>FIRST_10_OPEN_BOX_RIDER_GATE</code>.
- **Pillar 5 · Last-Minute Rollout Adoption Roll-Up & 5-Axis Filter Matrix**: <strong>Top KPI Strip:</strong> <code>🟢 Adopted (21/32 · 65.6%)</code> · <code>🟡 Lagging T-6h (7/32 · 21.9%)</code> · <code>🔴 Not Adopted/Blocked (4/32 · 12.5%)</code> · <code>👥 Crew Cert (482/540 · 89.3%)</code>. <strong>5 Filter Axes:</strong> Status × Cluster/City/Format × Blocking Layer (`L3–L7`) × Role/Station × HOP Escalation Tier (`Tier 0..3`) + <strong>4 Group-By Toggles</strong> & <strong>1-Tap Batch HOP Nudge</strong>.
- **Pillar 6 · Full HOP Nudge & Accountability Compliance (`acct-*` / `O-022` / `O-045`)**: <strong>Escalation Ladder:</strong> `Named Owner (T-24h) -> Nudge #1 + Store Mgr (T-6h/+15m) -> Nudge #2 + Cluster Mgr (T-2h/+30m) -> City/COO Hard Lock (T-0)` (`Max 2 Snoozes`). <strong>M3 Verify:</strong> `✓ Confirm` (`verified_by != completed_by`) vs `↩ Return` (`revision_count++`). <strong>`✕ Cannot` Upstream Re-Route:</strong> `CK Crate Short` / `Insert Missing` auto-shifts accountability + HOP Nudge to `L3 CK` / `L4 Logistics`!
### 2D. Global F&B / Patisserie / Enterprise Industry Benchmarks & Hostile Peer Review Verdict (`Astra Extra High` + `Opus 4.7 Extra High`)
| Global Benchmark / Peer Reviewer | Standard / Gate Adopted | How Harley's OneOps / HOP Enforces It |
| :--- | :--- | :--- |
| **Starbucks Siren R&D / Pret A Manger / Pierre Hermé Single-Threaded Ownership** | **1 Single Named Owner (`person_id`) per Layer (`L1..L7` — Zero Committee Handoffs)** | Binds `L1` R&D Chef, `L2` QA/Lab Lead, `L3` CK Production Head, `L4` Cold-Chain Controller, `L5` POS/Catalogue Lead, `L6` Store Manager per Outlet, and `L7` FOH Dispatch Lead per Outlet with 4-digit PIN sign-off. |
| **85°C Bakery / Paris Baguette Commissary & Cold-Chain Standard** | **200kg Commercial Scaling + `<=90m` Blast-Chill Curve + `HRL-LOT-*` Crate QR + `+2..+4°C` Reefer & `<=+5°C` Store Door Probe** | Tracks every pastry batch from CK oven deck and ultrasonic cutter through BLE-monitored reefer transit to café door probe verification. |
| **Dominique Ansel / Indian Aggregator Last-Mile Execution Standard** | **Per-Store `LOCKED_NOT_ENABLED` POS Gate + First-10-Orders Open-Box Pack Photo Gate (`<=1.0%` Damage, `<=90s` Handover)** | Prevents premature aggregator activation until `L6` completes BOH practice plate, `>=90%` FOH quiz, planogram photo, and box/gel-pack inventory; mandates open-box photos on the first 10 rider handovers per store. |
| **Last-Minute Rollout Adoption Roll-Up & 5-Axis Filter (`npl_rollout_adoption_rollup`)** | **Real-Time `Adopted (21) / Lagging (7) / Not Adopted (4)` Roll-Up + 5-Axis Filter + Group-By + 1-Tap Batch HOP Nudge** | Gives Founder/COO/Ops Lead an instant chain-wide roll-up of who has adopted and who has not, filterable by Status, Cluster/City, Blocking Layer (`L1–L7`), Role/Station, and HOP Escalation Tier (`Tier 0..3`). |
| **HOP Nudge & Accountability Framework Compliance (`acct-*` / `O-022` / `O-045`)** | **Deterministic `T-24h -> T-6h -> T-2h -> T-0` Escalation + M3 2nd-Person Confirm/Return + `✕ Cannot` Upstream Re-Routing** | Every NPL checklist and gate enforces 1 Named Owner (`person_id`), Snooze Cap (`Max 2: +15m/+30m`), M3 verification (`verified_by_id != completed_by_id`), and structured `✕ Cannot` chips that auto-transfer accountability + HOP Nudge upstream (`L6 Store -> L3 CK / L4 Logistics`). |
| **Hostile Peer Review Verdict (`Astra XHigh` + `Opus 4.7`)** | **✅ APPROVED FOR STAGE 2 (DESIGN), STAGE 3 (TDD) & STAGE 4 (UI/UX) SIGN-OFF** | Verified all 13 NPL tables/views, `L1..L7` single-person constraint, `npl_rollout_adoption_rollup` 5-axis filter, `✕ Cannot` upstream re-routing, and 9-frame `J18` storyboard. |
### 2E. Last-Minute Rollout Adoption Roll-Up Summary & 5-Axis Filter Engine (`npl_rollout_adoption_rollup`)
- **Top Executive Roll-Up KPI Strip (`SKU: N-207 Saffron Pistachio Medovik · D-0 Rollout`):**
- `🟢 Adopted & POS Unlocked: 21 / 32 Outlets (65.6%)`
- `🟡 Last-Minute Lagging / T-6h Risk: 7 / 32 Outlets (21.9%)`
- `🔴 Not Adopted / Gate Locked: 4 / 32 Outlets (12.5%)`
- `👥 Crew Certification Roll-Up: 482 / 540 Crew Certified (89.3% · 58 Pending across 11 Stores)`
- `🔔 [1-Tap Batch HOP Nudge to All 11 Non-Adopted / Lagging Named Owners]`
- **5-Axis Interactive Filter & 4-Mode Group-By Matrix:**
1. **Axis 1 — Adoption Status:** `All (32)` | `🔴 Not Adopted / Blocked (4)` | `🟡 Lagging <100% (7)` | `🟢 Adopted & Live (21)`
2. **Axis 2 — Cluster / City / Format:** `All` | `Hyd West (CLM-01)` | `Hyd Central (CLM-02)` | `Bengaluru` | `Mumbai` | `Cloud Kitchens / Airport`
3. **Axis 3 — Blocking Layer (`L1–L7`):** `L3 CK Production` | `L4 Cold-Chain Transit` | `L5 POS/Swiggy Sync` | `L6 BOH Video+Practice Plate` | `L6 FOH Quiz (<90%)` | `L6 Showcase Planogram` | `L7 Last-Mile Packaging`
4. **Axis 4 — Role / Station:** `Store Managers (L6)` | `FOH Baristas` | `BOH Kitchen` | `Last-Mile Dispatch Leads (L7)`
5. **Axis 5 — HOP Escalation Tier:** `Tier 0 On Track` | `Tier 1 Store Mgr Nudged (T-6h)` | `Tier 2 Cluster Mgr Escalated (T-2h)` | `Tier 3 City/COO Launch Lock (T-0)`
- **Group-By Toggle:** `By Outlet (32)` | `By Cluster (5)` | `By Blocking Layer (L1–L7)` | `By Named Owner / Non-Adopted Staff`
| Outlet / Scope | Cluster & Format | Named Owner (`person_id`) | Adoption Status | Crew Cert (`FOH/BOH`) | Blocking Layer & Reason | HOP Escalation Tier & Action |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| **Nanakramguda (`OUT-NAN`)** | Hyd West (`CLM-01`) · Flagship | Rohit Sharma (`MGR-01 · H-000131`) | `🟢 ADOPTED & POS UNLOCKED` | `18/18 (100%)` | `NONE_LIVE` (All 4 Gates + M3 Confirmed) | `Tier 0 On Track` · First-10 Pack Gate Active |
| **Jubilee Hills (`OUT-JUB`)** | Hyd Central (`CLM-02`) · Flagship | Priya Menon (`MGR-02 · H-000132`) | `🟡 LAGGING (75% · T-6h Risk)` | `14/16 (87.5%)` | `L6_FOH_QUIZ_LT_90` (2 Evening Baristas Pending) | `Tier 1 Store Mgr Nudged (T-6h)` · Snooze `1/2` |
| **Kokapet (`OUT-KOK`)** | Hyd West (`CLM-01`) · Café | Arvind Rao (`MGR-04 · H-000134`) | `🟡 LAGGING (50% · T-2h Risk)` | `11/14 (78.6%)` | `L6_BOH_PRACTICE_PLATE` + `L6_SHOWCASE_PLANOGRAM` | `Tier 2 Cluster Mgr Escalated (T-2h · CLM-01)` |
| **Banjara Hills (`OUT-BAN`)** | Hyd Central (`CLM-02`) · Café | Vikram Das (`MGR-05 · H-000135`) | `🔴 NOT ADOPTED / BLOCKED` | `15/15 (100%)` | `✕ Cannot: CK_CRATE_SHORT` -> **Re-routed to `L3 CK` Suresh Nair (`H-000118`)** | `Tier 2 Upstream Escalated` · Store Cleared of Blame |
| **Madhapur (`OUT-MAD`)** | Hyd West (`CLM-01`) · Cloud Kitchen | Kiran Kumar (`MGR-06 · H-000136`) | `🔴 NOT ADOPTED / BLOCKED` | `12/12 (100%)` | `✕ Cannot: PACKAGING_INSERT_MISSING` -> **Re-routed to `L4 Logistics` Mahesh Goud (`H-000124`)** | `Tier 3 COO Launch Lock (T-0)` · Urgent Van Dispatched |
### 2F. Universal HOP Nudge & Accountability Framework Compliance Contract (`acct-*` / `O-022` / `O-045`)
| HOP Accountability Pillar | Constitutional Rule (`acct-*` / `O-022` / `O-045`) | How Every Checklist & Gate in This Module Enforces It |
| :--- | :--- | :--- |
| **1. Single Named Accountable Owner (`person_id`)** | Zero shared role/committee ownership (`NOT NULL REFERENCES hop.people`) | Every stage gate, checklist item, repair ticket, and store readiness step binds to exactly **1 named human (`person_id`)** who signs with their 4-digit User PIN (`O-022`). |
| **2. Deterministic Escalation Ladder & Timers** | `Named Owner (T-24h) -> HOP Nudge #1 + Shift/Store Mgr (T-6h / +15m) -> HOP Nudge #2 + Cluster Mgr (T-2h / +30m) -> City Head / COO / CFO Hard Gate Lock (T-0)` | Persists durable WhatsApp + in-app delivery receipts in `accountability_nudges`; automatically freezes the downstream gate (`LOCKED_NOT_ENABLED` / `GATE_BLOCKED`) at `T-0`. |
| **3. M3 Independent 2nd-Person Verification** | `✓ Confirm = I checked the work` (`verified_by_id != completed_by_id`) vs `↩ Return for correction` | Database `CHECK (m3_verified_by_id <> m3_completed_by_id)` prevents self-verification; selecting `↩ Return` requires a mandatory reason, increments `revision_count++`, and fires an instant re-nudge. |
| **4. Structured `✕ Cannot` 6-Reason Chips + Upstream Re-Routing** | `CK Crate Short` · `Cold-Chain Excursion` · `Packaging Missing` · `POS SKU Missing` · `Equipment Down` · `Staff Shortage` | Selecting a `✕ Cannot` chip + 1 evidence photo records an immutable `BLOCKED` receipt for the frontline operator and **automatically transfers accountability + HOP Nudge upstream** to the `L3 CK`, `L4 Logistics`, `L5 POS`, or `Procurement/MEP` Named Owner. |
| **5. Snooze Cap (`Max 2`) & `O-045` Evidence Proportionality** | `snooze_count <= 2` (`+15m` then `+30m`) + End-of-Sequence Checklist Proof (`SK-16`) | Hard-caps snoozes at 2 before escalating to Cluster Manager; routine checklists use 1-tap ticks + ONE end-of-sequence summary photo, restricting selfies + 4-digit PIN strictly to Critical/M3, Repair Closure, and Attendance/Spot Audits. |
---
## PART 3 · GLOSSARY, SCHEMA DDL & CORPUS APPENDIX
<details>
<summary><strong>📖 3A. Domain Glossary & Canonical Definitions (Click to Expand)</strong></summary>
| Term / Code | Canonical Definition in Harley's OneOps / HOP |
| :--- | :--- |
| **`L1..L7` Single Named Owner Matrix** | Governance table binding every NPL execution layer to a single `person_id` in `hop.people` (never a shared role title), requiring that person's 4-digit PIN to advance the gate. |
| **`npl_rollout_adoption_rollup` (5-Axis Roll-Up Engine)** | Real-time rollout command view aggregating per-outlet adoption status (`🟢 Adopted`, `🟡 Lagging`, `🔴 Not Adopted/Blocked`), crew quiz/video completion (`482/540`), blocking layer (`L3..L7`), cluster/city, and HOP escalation tier (`Tier 0..3`). |
| **HOP Nudge & Accountability Escalation Ladder (`acct-*`)** | Deterministic timer engine (`T-24h -> T-6h/+15m -> T-2h/+30m -> T-0 Lock`) with durable WhatsApp + in-app delivery receipts (`accountability_nudges`), max 2 snoozes (`+15m / +30m`), and M3 2nd-person verification. |
| **Structured `✕ Cannot` Upstream Re-Routing** | Accountability rule where an outlet selecting `✕ Cannot: CK Crate Short` or `Packaging Insert Missing` gets an immutable `BLOCKED` receipt (`npl_cannot_block_receipts`) and the system automatically transfers the active blocker + HOP Nudge upstream to the `L3 CK` or `L4 Logistics` Named Owner. |
| **`HRL-LOT-{SKU}-{CK}-{YYYYMMDD}-{BATCH}` Crate QR** | Scannable commissary lot label attached to every pastry crate leaving `CK-1/CK-2`, encoding bake timestamp, blast-chill pull-down curve, core temperature, and 48-hour expiry. |
| **First-10-Orders Open-Box Pack Photo Gate** | Last-mile quality gate requiring the FOH Dispatch Lead (`L7`) to snap an open-box photo of the first 10 aggregator orders at their outlet to prove collar + gel-pack compliance before sealing. |
</details>
<details>
<summary><strong>🗄️ 3B. PostgreSQL Schema DDL & Constraints (Click to Expand)</strong></summary>
```sql
-- STOP 3 DETAILED DESIGN CANONICAL DDL (L1-L7 NAMED OWNERS, CK SCALING, COLD-CHAIN, GROUND & LAST-MILE)
CREATE TABLE npl_layer_ownership_matrix (
ownership_id UUID PRIMARY KEY,
sku_id UUID NOT NULL REFERENCES npl_skus(sku_id),
layer_code VARCHAR(32) NOT NULL CHECK (layer_code IN (
'L1_RD_FORMULATION','L2_QA_LAB_PACKAGING','L3_CK_PRODUCTION',
'L4_COLD_CHAIN_LOGISTICS','L5_POS_AGGREGATOR_SYNC',
'L6_GROUND_OUTLET_ENABLEMENT','L7_LAST_MILE_EXECUTION'
)),
outlet_id VARCHAR(32) NOT NULL DEFAULT 'HQ_GLOBAL',
named_person_id INTEGER NOT NULL,
person_code VARCHAR(24) NOT NULL,
full_name VARCHAR(120) NOT NULL,
sla_due_at TIMESTAMPTZ NOT NULL,
signed_via_pin_at TIMESTAMPTZ,
UNIQUE (sku_id, layer_code, outlet_id)
);
CREATE TABLE npl_ck_enablement_runs (
ck_run_id UUID PRIMARY KEY,
sku_id UUID NOT NULL REFERENCES npl_skus(sku_id),
ck_facility_id VARCHAR(16) NOT NULL CHECK (ck_facility_id IN ('CK-1-NAN','CK-2-BLR')),
l3_owner_person_id INTEGER NOT NULL,
trial_batch_code VARCHAR(32) NOT NULL,
batch_size_kg NUMERIC(6,2) NOT NULL CHECK (batch_size_kg >= 50.00),
blast_chill_pull_down_min SMALLINT NOT NULL CHECK (blast_chill_pull_down_min <= 90),
final_core_temp_c NUMERIC(4,2) NOT NULL CHECK (final_core_temp_c <= 4.00),
sponge_baker_certified_id INTEGER NOT NULL,
frosting_baker_certified_id INTEGER NOT NULL,
portioning_baker_certified_id INTEGER NOT NULL,
status VARCHAR(24) NOT NULL DEFAULT 'CK_CERTIFIED'
);
CREATE TABLE npl_crate_lots (
lot_qr VARCHAR(64) PRIMARY KEY,
sku_id UUID NOT NULL REFERENCES npl_skus(sku_id),
ck_run_id UUID NOT NULL REFERENCES npl_ck_enablement_runs(ck_run_id),
baked_at TIMESTAMPTZ NOT NULL,
blast_chilled_at TIMESTAMPTZ NOT NULL,
dispatch_core_temp_c NUMERIC(4,2) NOT NULL CHECK (dispatch_core_temp_c <= 4.00),
use_by_at TIMESTAMPTZ NOT NULL,
slices_count SMALLINT NOT NULL CHECK (slices_count > 0)
);
CREATE TABLE npl_logistics_manifests (
manifest_id UUID PRIMARY KEY,
lot_qr VARCHAR(64) NOT NULL REFERENCES npl_crate_lots(lot_qr),
l4_logistics_owner_id INTEGER NOT NULL,
dest_outlet_id VARCHAR(32) NOT NULL,
reefer_vehicle_no VARCHAR(24) NOT NULL,
precool_cabin_temp_c NUMERIC(4,2) NOT NULL CHECK (precool_cabin_temp_c BETWEEN 1.50 AND 4.00),
ble_logger_id VARCHAR(32) NOT NULL,
max_transit_temp_c NUMERIC(4,2) NOT NULL,
stack_height_crates SMALLINT NOT NULL CHECK (stack_height_crates <= 3),
ck_dispatch_signed_by INTEGER NOT NULL,
driver_signed_by VARCHAR(64) NOT NULL,
store_receiving_probe_c NUMERIC(4,2),
store_visual_condition VARCHAR(24) CHECK (store_visual_condition IN ('INTACT','CONDENSATION_WARN','CRUSHED_QUARANTINED')),
received_by_l6_mgr_id INTEGER,
status VARCHAR(28) NOT NULL DEFAULT 'IN_TRANSIT',
CONSTRAINT check_store_receiving_cold_chain CHECK (
status <> 'ACCEPTED_INTO_CHILLER' OR (
store_receiving_probe_c <= 5.00 AND store_visual_condition = 'INTACT' AND received_by_l6_mgr_id IS NOT NULL
)
)
);
CREATE TABLE npl_ground_outlet_readiness (
readiness_id UUID PRIMARY KEY,
sku_id UUID NOT NULL REFERENCES npl_skus(sku_id),
outlet_id VARCHAR(32) NOT NULL,
l6_store_mgr_person_id INTEGER NOT NULL,
boh_video_completed BOOLEAN NOT NULL DEFAULT FALSE,
practice_plate_photo_sha256 CHAR(64),
foh_quiz_pass_pct NUMERIC(5,2) NOT NULL DEFAULT 0.00,
showcase_planogram_photo_sha256 CHAR(64),
insert_box_stock_qty INTEGER NOT NULL DEFAULT 0,
frozen_gel_pack_stock_qty INTEGER NOT NULL DEFAULT 0,
pos_unlock_status VARCHAR(28) NOT NULL DEFAULT 'LOCKED_NOT_ENABLED' CHECK (pos_unlock_status IN ('LOCKED_NOT_ENABLED','ENABLED_LIVE','SUSPENDED_QUALITY')),
unlocked_via_pin_at TIMESTAMPTZ,
UNIQUE (sku_id, outlet_id),
CONSTRAINT check_four_ground_gates_before_pos_unlock CHECK (
pos_unlock_status <> 'ENABLED_LIVE' OR (
boh_video_completed = TRUE
AND practice_plate_photo_sha256 IS NOT NULL
AND foh_quiz_pass_pct >= 90.00
AND showcase_planogram_photo_sha256 IS NOT NULL
AND insert_box_stock_qty >= 50
AND frozen_gel_pack_stock_qty >= 50
)
)
);
CREATE TABLE npl_last_mile_tracking (
dispatch_id UUID PRIMARY KEY,
sku_id UUID NOT NULL REFERENCES npl_skus(sku_id),
outlet_id VARCHAR(32) NOT NULL,
l7_dispatch_lead_person_id INTEGER NOT NULL,
aggregator_order_id VARCHAR(48) UNIQUE NOT NULL,
store_order_seq INTEGER NOT NULL CHECK (store_order_seq >= 1),
open_box_photo_sha256 CHAR(64),
gel_pack_included BOOLEAN NOT NULL DEFAULT TRUE,
tamper_seal_verified BOOLEAN NOT NULL DEFAULT TRUE,
prep_to_handover_sec SMALLINT NOT NULL,
customer_rating NUMERIC(3,2),
transit_damage_reported BOOLEAN NOT NULL DEFAULT FALSE,
CONSTRAINT check_first_10_orders_open_box_photo CHECK (
store_order_seq > 10 OR open_box_photo_sha256 IS NOT NULL
)
);
CREATE TABLE npl_cannot_block_receipts (
receipt_id UUID PRIMARY KEY,
sku_id UUID NOT NULL REFERENCES npl_skus(sku_id),
outlet_id VARCHAR(32) NOT NULL,
reported_by_l6_person_id INTEGER NOT NULL,
cannot_reason_chip VARCHAR(36) NOT NULL CHECK (cannot_reason_chip IN (
'CK_CRATE_SHORT','COLD_CHAIN_TEMP_EXCURSION','PACKAGING_INSERT_MISSING',
'POS_SKU_MISSING','SHOWCASE_CHILLER_DOWN','STAFF_SHORTAGE'
)),
evidence_photo_sha256 CHAR(64) NOT NULL,
rerouted_to_layer_code VARCHAR(32) NOT NULL CHECK (rerouted_to_layer_code IN (
'L3_CK_PRODUCTION','L4_COLD_CHAIN_LOGISTICS','L5_POS_AGGREGATOR_SYNC','L6_GROUND_OUTLET_ENABLEMENT'
)),
rerouted_owner_person_id INTEGER NOT NULL,
hop_nudge_id UUID NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE accountability_nudges (
nudge_id UUID PRIMARY KEY,
domain_module VARCHAR(32) NOT NULL,
entity_ref VARCHAR(64) NOT NULL,
outlet_id VARCHAR(32) NOT NULL,
target_person_id INTEGER NOT NULL,
escalation_tier SMALLINT NOT NULL DEFAULT 1 CHECK (escalation_tier BETWEEN 0 AND 3),
channel VARCHAR(24) NOT NULL DEFAULT 'WHATSAPP_AND_IN_APP',
snooze_count SMALLINT NOT NULL DEFAULT 0 CHECK (snooze_count <= 2),
m3_verified_by_id INTEGER,
m3_completed_by_id INTEGER,
m3_verdict VARCHAR(24) CHECK (m3_verdict IN ('CONFIRMED','RETURNED_FOR_CORRECTION')),
m3_return_reason TEXT,
revision_count SMALLINT NOT NULL DEFAULT 0,
delivery_receipt_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT check_m3_second_person_independence CHECK (
m3_verified_by_id IS NULL OR m3_verified_by_id <> m3_completed_by_id
)
);
CREATE VIEW npl_rollout_adoption_rollup AS
SELECT
r.sku_id,
r.outlet_id,
o.cluster_code,
o.city_name,
o.outlet_format,
r.l6_store_mgr_person_id,
CASE
WHEN r.pos_unlock_status = 'ENABLED_LIVE' THEN 'ADOPTED_LIVE'
WHEN c.receipt_id IS NOT NULL OR r.pos_unlock_status = 'SUSPENDED_QUALITY' THEN 'NOT_ADOPTED_BLOCKED'
ELSE 'LAGGING_RISK'
END AS adoption_status,
COALESCE(c.rerouted_to_layer_code,
CASE
WHEN NOT r.boh_video_completed OR r.practice_plate_photo_sha256 IS NULL THEN 'L6_BOH_PRACTICE_PLATE'
WHEN r.foh_quiz_pass_pct < 90.00 THEN 'L6_FOH_QUIZ_LT_90'
WHEN r.showcase_planogram_photo_sha256 IS NULL THEN 'L6_SHOWCASE_PLANOGRAM'
WHEN r.insert_box_stock_qty < 50 OR r.frozen_gel_pack_stock_qty < 50 THEN 'L7_LAST_MILE_PACKAGING'
ELSE 'NONE_LIVE'
END
) AS blocking_layer_code,
COALESCE(n.escalation_tier, 0) AS hop_escalation_tier,
r.foh_quiz_pass_pct,
r.pos_unlock_status
FROM npl_ground_outlet_readiness r
LEFT JOIN outlets o ON o.outlet_id = r.outlet_id
LEFT JOIN npl_cannot_block_receipts c ON c.sku_id = r.sku_id AND c.outlet_id = r.outlet_id
LEFT JOIN accountability_nudges n ON n.entity_ref = r.readiness_id::text;
-- HOSTILE PEER REVIEW FIXES (OPUS 4.7 MAX & ASTRA EXTRA HIGH - 2026-10-22):
-- 1. Prevent M*N fan-out in npl_rollout_adoption_rollup via LATERAL LIMIT 1 joins
-- 2. Prevent stale M3 confirm from unlocking POS when an OPEN_BLOCKED Cannot receipt exists
ALTER TABLE npl_cannot_block_receipts ADD COLUMN IF NOT EXISTS resolution_status VARCHAR(24) NOT NULL DEFAULT 'OPEN_BLOCKED'
CHECK (resolution_status IN ('OPEN_BLOCKED','RESOLVED_UPSTREAM'));
ALTER TABLE npl_cannot_block_receipts ADD COLUMN IF NOT EXISTS idempotency_key VARCHAR(64) UNIQUE NOT NULL;
CREATE UNIQUE INDEX IF NOT EXISTS idx_npl_cannot_open_unique
ON npl_cannot_block_receipts (sku_id, outlet_id, cannot_reason_chip)
WHERE resolution_status = 'OPEN_BLOCKED';
ALTER TABLE npl_ground_outlet_readiness ADD COLUMN IF NOT EXISTS m3_verified_by_id INTEGER;
ALTER TABLE npl_ground_outlet_readiness ADD COLUMN IF NOT EXISTS open_cannot_blockers_count SMALLINT NOT NULL DEFAULT 0;
ALTER TABLE npl_ground_outlet_readiness ADD CONSTRAINT check_m3_and_zero_cannot_before_pos_unlock
CHECK (pos_unlock_status <> 'ENABLED_LIVE' OR (m3_verified_by_id IS NOT NULL AND m3_verified_by_id <> l6_store_mgr_person_id AND open_cannot_blockers_count = 0));
CREATE OR REPLACE VIEW npl_rollout_adoption_rollup_v2 AS
SELECT
r.sku_id,
r.outlet_id,
o.cluster_code,
o.city_name,
o.outlet_format,
r.l6_store_mgr_person_id,
CASE
WHEN c.receipt_id IS NOT NULL OR r.open_cannot_blockers_count > 0 OR r.pos_unlock_status = 'SUSPENDED_QUALITY' THEN 'NOT_ADOPTED_BLOCKED'
WHEN r.pos_unlock_status = 'ENABLED_LIVE' THEN 'ADOPTED_LIVE'
ELSE 'LAGGING_RISK'
END AS adoption_status,
COALESCE(c.rerouted_to_layer_code,
CASE
WHEN NOT r.boh_video_completed OR r.practice_plate_photo_sha256 IS NULL THEN 'L6_BOH_PRACTICE_PLATE'
WHEN r.foh_quiz_pass_pct < 90.00 THEN 'L6_FOH_QUIZ_LT_90'
WHEN r.showcase_planogram_photo_sha256 IS NULL THEN 'L6_SHOWCASE_PLANOGRAM'
WHEN r.insert_box_stock_qty < 50 OR r.frozen_gel_pack_stock_qty < 50 THEN 'L7_LAST_MILE_PACKAGING'
ELSE 'NONE_LIVE'
END
) AS blocking_layer_code,
COALESCE(n.escalation_tier, 0) AS hop_escalation_tier,
r.foh_quiz_pass_pct,
r.pos_unlock_status
FROM npl_ground_outlet_readiness r
LEFT JOIN outlets o ON o.outlet_id = r.outlet_id
LEFT JOIN LATERAL (
SELECT c1.receipt_id, c1.rerouted_to_layer_code
FROM npl_cannot_block_receipts c1
WHERE c1.sku_id = r.sku_id AND c1.outlet_id = r.outlet_id AND c1.resolution_status = 'OPEN_BLOCKED'
ORDER BY c1.created_at DESC LIMIT 1
) c ON TRUE
LEFT JOIN LATERAL (
SELECT n1.escalation_tier
FROM accountability_nudges n1
WHERE n1.entity_ref = r.readiness_id::text
ORDER BY n1.created_at DESC LIMIT 1
) n ON TRUE;
-- =============================================================================
-- G1 DESIGN GATE OWNER SIGN-OFF LOCK (2026-10-22 22:39 IST & 22:44 IST · 100% APP 0 -> APP 6 LOCKED)
-- =============================================================================
-- A2: Outlet Manager / Cluster Manager approves Shift Swaps & Inter-Outlet Loans with automatic visibility/notification to City Head
ALTER TABLE staff_shift_rosters
ADD COLUMN IF NOT EXISTS swap_approved_by_id VARCHAR(32) REFERENCES users(id),
ADD COLUMN IF NOT EXISTS swap_approved_by_role VARCHAR(32) CHECK (swap_approved_by_role IN ('outlet_manager', 'cluster_manager')),
ADD COLUMN IF NOT EXISTS city_head_notified_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS visible_to_city_head_bool BOOLEAN NOT NULL DEFAULT TRUE;
ALTER TABLE staff_inter_outlet_loans
ADD COLUMN IF NOT EXISTS approved_by_role VARCHAR(32) CHECK (approved_by_role IN ('outlet_manager', 'cluster_manager')),
ADD COLUMN IF NOT EXISTS city_head_notified_at TIMESTAMPTZ,
ADD COLUMN IF NOT EXISTS visible_to_city_head_bool BOOLEAN NOT NULL DEFAULT TRUE;
-- A4: Seed configurable Governance & Reviewer slots in master_data_holders (SK-14, N-11, OA-06, OA-07)
INSERT INTO master_data_holders (domain_key, primary_department_key, holder_role_code, can_delegate_bool, description) VALUES
('hindi_reviewer', 'academy', 'hindi_reviewer', TRUE, 'SK-14 / N-11 Kiosk Hindi Copy Reviewer-of-Record'),
('quality_reviewer', 'ops', 'quality_reviewer', TRUE, 'BO-FB-TEMPLATES 16 Outlet Round Checklist Template Owner'),
('restricted_item_owner', 'ops', 'restricted_item_owner', TRUE, 'OA-06 Compliance Restricted-Item & Statutory Schedule Owner'),
('fitout_template_owner', 'projects', 'fitout_template_owner', TRUE, 'OA-07 Cafe Projects 42-Day Fit-Out Critical Path Template Owner')
ON CONFLICT (domain_key) DO UPDATE SET
holder_role_code = EXCLUDED.holder_role_code,
description = EXCLUDED.description;
```
</details>
<details>
<summary><strong>📂 3C. Source Corpus Mapping & Automated Verification Suite (Click to Expand)</strong></summary>
| Source Folder / Artifact | Files / Rows | Target Domain Object | Gate Status |
| :--- | :--- | :--- | :--- |
| `npl-layer-ownership-matrix (L1..L7)` | 7 Single Named Layer Owners (H-000104..H-000129 + 32 Store Mgrs & FOH Leads) | `npl_layer_ownership_matrix` | **STAGE 2–4 SPEC COMPLETE** |
| `ck-enablement-and-crate-lots (CK-1 & CK-2)` | 200kg Scaling, <=90m Blast Chill, Line Cert & HRL-LOT-* QRs | `npl_ck_enablement_runs + npl_crate_lots` | **STAGE 2–4 SPEC COMPLETE** |
| `cold-chain-reefer-manifests` | +2..+4°C Reefer Pre-Cool, BLE Logger & <=+5°C Store Door Probe | `npl_logistics_manifests` | **STAGE 2–4 SPEC COMPLETE** |
| `store-ground-and-last-mile-gates (32 Outlets)` | Per-Store POS Unlock Matrix + First-10-Orders Open-Box Pack Photo Gate | `npl_ground_outlet_readiness + npl_last_mile_tracking` | **STAGE 2–4 SPEC COMPLETE** |
| `npl-rollout-adoption-rollup & HOP Nudge (acct-*)` | 32-Outlet Roll-Up (21 Adopted / 7 Lagging / 4 Blocked), 5-Axis Filter & ✕ Cannot Upstream Re-Routing | `npl_rollout_adoption_rollup + npl_cannot_block_receipts + accountability_nudges` | **STAGE 2–4 SPEC COMPLETE** |
**Verification Evidence:** `pytest tests/test_stop3_npl_end_to_end.py` (30 fail-first tests) + Playwright `J18` 9-frame storyboard (`390/360/320px` Chromium + WebKit) — 100% green across `L1..L7` single-person ownership, `<=90m` CK blast-chill gate, `> +5°C` crate receiving quarantine, per-store `LOCKED_NOT_ENABLED` POS guard, First-10-Orders Open-Box Photo lock, 5-Axis Rollout Adoption Roll-Up filtering, M3 2nd-person verification, and `✕ Cannot` upstream re-routing.
</details>

OneOps