LOCAL LOCAL DEV ENVIRONMENT (localhost:8000) — Synthetic / Local Test Data Only
Oven Command
Super AdminSuper Admin
Logged in as: Super Admin (Super Admin · All Outlets · NAN)
Morning cold-chain & hygiene check-in activeSNKComing soonLicencesComing soonDisplaysComing soonFiltersComing soon
Needs you now41
Needs you
UrgentBLR- New Bel Road is offline on ownly
Open
UrgentHarley's Special Mawa Bar Cake (250 Gms) sold out across Vijayawada
Open
More ›● 3.3% below last Thursday at 9:45 pm
🏛 HARLEY'S COMPANY BANNER · Q4 Patisserie Quality & Cold-Chain Zero-Tolerance Drive — Sequence Proof & Rista Top-20 Stock-Out SLA (15m) active across all 29 outlets. Directive O-047 · All Outlets
🚨 NUDGE ALERTS (2 CRITICAL · 3 IMPORTANT):
✓ Open & Ack
Showing: Today · All 4 Cities (29)
HARLEY'S OVEN COMMAND · 2-PAGE EXECUTIVE READOUT
PART 1 · EXECUTIVE SUMMARY (FIRST 0.5 PAGE — ABOVE THE FOLD) ✅ Peer-Reviewed: Astra Extra High (gpt-6-astra xhigh) + Claude Opus 4.7 Extra High · STOP 2 · STAGE 2–4 DESIGN + TDD + UI/UX · T1-14 · T1-12 · T1-13 · J16 & J17

Stop 2 Detailed Design, TDD & UI/UX Spec: Café Projects (7-Gate NSO & India Site Kiosk), Fixed Assets (1,982 QRs) & Breakdown Maintenance (STOP 2 · STAGE 2–4 DESIGN + TDD + UI/UX · T1-14 · T1-12 · T1-13 · J16 & J17)

✅ STAGE 1 INTAKE SIGNED BY OWNER (20:38 IST) · Peer-Reviewed (Astra XHigh + Opus 4.7) · 11 Domain Tables & Full DDL · REST API Contract · Fail-First TDD Suite (pytest + Playwright G1..15) · PRJ-01..12 + Tier 1/1.5 Project Site Kiosk Wireframes (J16 & J17)

1. What We Are Building & Why

  • **✅ Stage 1 Intake Approved by Owner at `20:38 IST` — Advancing Stop 2 (`T1-14 Café Projects + T1-12 Fixed Assets + T1-13 Breakdown Maintenance`) to Stage 2 (Detailed Design), Stage 3 (Fail-First TDD), and Stage 4 (UI/UX & Site Kiosk Wireframes):** Translates `Master Projects - 2026 to 2027.xlsx` (8 tabs), `BO-PACK-PROJECTS` (`PRJ-J01..J10`, `PRJ-01..12`, `PRJ-Q1..Q7`), the **India Construction Site Kiosk**, the **1,982-row Fixed Asset Register**, and the **6-State Breakdown Maintenance Engine** into 11 normalized PostgreSQL tables, 18 deterministic REST API endpoints, a 28-test fail-first TDD suite, and interactive `390px/1100px` storyboards (`J16` & `J17`).
  • **Complete 11-Table PostgreSQL Architecture & Cross-Module Handshakes:** (1) `projects` (`PRE-* -> PRJ-*` sanction, `Rent <= 12%/15%`, `Payback < 24m`, `3-Phase kVA`, `EAC` forecast, `5–10%` DLP holdback); (2) `project_gates` (`Gate 0..6`, 35d SLA + RCA tag, 30 Pre-Opening Checks, `IT-04 ₹0 Variance`); (3) `project_boq_items` (Category CapEx ceilings); (4) `project_authority_ledger` (`PRJ-Q2` 4-tier separation: `Sanction != PO != Invoice/GST 2B/TDS != Bank UTR`); (5) `project_site_attendance` (`Thekedar/Hajiri` trade muster roll); (6) `project_shift_spans` (in-between split shifts & `23:00–05:00` mall night shifts); (7) `project_site_grns` (4-photo visual GRN + DC + E-Way Bill QR + Lorry Plate + short/damaged payout hold + `STAGE_DELIVERED_AT_SITE` asset pre-minting); (8) `project_material_indents` (1-tap graphic + 15s `EN/HI/TE` voice indent routed to `WORK_STOPPED_URGENT <= ₹5,000 UPI Imprest` vs `CENTRAL_PO`); (9) `project_india_ground_controls` (Mall Night/Hot-Work Permits, UPI Imprest Wallet, Rent-Free Fit-Out Hindrance Register with auto day-extension calculator, `3-Phase kVA + LPG/PNG + Raw Water TDS <= 80 ppm` Boiler Gate, Outward Scrap Pass); (10) `assets_fixed` (`1,982` `HRL-AST-{BRANCH}-{CAT}-{SEQ}` QRs, `UNIQUE(source_po_line_id, serial_no)`, `40% WDV` CFO gate); (11) `maint_tickets` (`MAINT-S1` 6-state pipeline, `MTTR <= 24h` critical SLA, mandatory 2nd-person Operator verification `verified_by_operator_id <> assigned_technician_id`).
  • **Fail-First TDD Contract + Interactive Storyboards (`J16` & `J17`):** Every database constraint, API transition, and UI screen (`PRJ-01..PRJ-12` + `Tier 1 Audio/Pictogram Site Kiosk` + `Tier 1.5 Site Engineer PIN Mode`) is backed by fail-first `pytest` integration tests and Playwright `T0` geometry/interaction checks (`G1..G15`, `SK-1..SK-16`).

2. Personas & Access Scope

  • **Tier 1 Site Entrance Kiosk User (Trade Crew, Thekedar, Lorry Driver — `360px/390px` Kiosk)**: Uses 5 giant audio-assisted graphic tiles (`👷 Ad-Hoc Hajiri`, `🚚 Visual Site GRN`, `📦 Voice/Photo Material Indent`, `📸 4-Corner Site Photo`, `⚠️ Log Hindrance/Safety`) with `6-digit Outlet/Site Kiosk PIN` device pairing (`O-022`).
  • **Tier 1.5 Site Engineer / PM (`4-Digit User PIN` on Kiosk & Mobile)**: Logs multi-span day & mall night shifts (`23:00–05:00`), verifies `Thekedar` headcounts, signs 4-photo Visual GRNs, approves `<= ₹5,000` UPI Imprest indents, records Landlord Hindrances & Water TDS (`<= 80 ppm`), and closes `Gate 0..6` snags.
  • **HQ Projects Lead, Procurement & Finance (`Maker / Checker / Approver`)**: Enforces `PRJ-Q2` 4-tier authority across BOQ POs, 3-Way Matched Invoices (`PO == Visual GRN == GST 2B Tax Invoice`), TDS `194C/194J`, Bank UTR release, and Odoo reconciliation.
  • **Outlet Operator & CFO (`Pillar 2 Assets & Pillar 3 Maintenance`)**: Operator scans `HRL-AST-*` QRs (`<15s`) and performs mandatory 2nd-person closure verification (Selfie + Working Photo + 4-Digit PIN per `O-045`); CFO adjudicates `PRE->PRJ` sanctions and `> 40% WDV` Repair-vs-Replace gates.

3. Owner Sign-Off Decisions

  • **Stage 2 (Detailed Design Sign-Off):** Approve the **11-table PostgreSQL schema (`projects`, `project_gates`, `project_boq_items`, `project_authority_ledger`, `project_site_attendance`, `project_shift_spans`, `project_site_grns`, `project_material_indents`, `project_india_ground_controls`, `assets_fixed`, `maint_tickets`)** and **18 REST API endpoints**.
  • **Stage 3 (TDD Sign-Off):** Approve the **12-Category Fail-First TDD Suite (`tests/test_stop2_projects_assets_maint.py` + Playwright `test_stop2_site_kiosk_and_wdv.spec.ts`)** enforcing `HTTP 409` on every financial, statutory, and safety invariant.
  • **Stage 4 (UI/UX & Storyboard Sign-Off):** Approve the **`PRJ-01..PRJ-12` HQ/Mobile Screens + `Tier 1 & Tier 1.5 Project Site Kiosk` + Interactive Storyboards [`J16`](/static/journeys/j16-asset-qr-breakdown-wdv.html) & [`J17`](/static/journeys/j17-cafe-projects-india-site-kiosk.html)**.
PART 2 · FULL INTAKE, DOMAIN OBJECT DESIGN & GLOBAL INDUSTRY BENCHMARKS (1.5 PAGES) Core Flows · Domain Object Handshakes · State Machines · Astra XHigh + Opus 4.7 Peer Review

2A. Core User Journeys & Functional Intake Rules

Journey / Capability Persona & Trigger System Action & Hard Gate Rule
API-1 & TDD-1 · Feasibility ROI & CFO Sanction (`POST /api/projects/proposals/{id}/sanction`)BD Lead -> CFO (`PRJ-Q2 Tier 1`)Validates `rent_to_sales_pct <= 15.0`, `payback_months <= 24.0`, `kva_available >= kva_required`, and `cannibalization_pct <= 8.0`. Mints `PRJ-2026-{SEQ}` only upon CFO 4-digit PIN sanction; rejected proposals remain `PRE-*` (`HTTP 409 FEASIBILITY_GATE_REJECTED` if guardrails fail without Founder waiver).
API-2 & TDD-2 · 4-Tier Authority Segregation (`POST /api/projects/{id}/pos` -> `/invoices` -> `/utr`)Procurement -> Finance Maker/Checker -> Treasury (`PRJ-Q2`)Database trigger + API guard enforce `sanctioned_by_id != po_approved_by_id != invoice_verified_by_id != utr_released_by_id` and block PO creation if `SUM(category_po_inr) > boq_category_ceiling_inr` (`HTTP 409 BOQ_CEILING_EXCEEDED`).
API-3 & TDD-3 · Site Kiosk Ad-Hoc `Thekedar/Hajiri` & Split/Night Shifts (`POST /api/projects/{id}/kiosk/hajiri` & `/shift-spans`)Tier 1 Site Kiosk & Tier 1.5 Site EngineerRecords `Thekedar` contractor crew headcounts (`skilled_count`, `unskilled_count`) + Group Selfie + Aadhaar Last-4, and logs multi-span engineer check-ins across daytime visits and restricted **Mall Night-Work windows (`23:00–05:00`)** with GPS + selfie.
API-4 & TDD-4 · 4-Photo Visual Site GRN & Auto Asset Pre-Minting (`POST /api/projects/{id}/kiosk/grns`)Site Engineer -> 3-Way Match EngineRequires all 4 S3 SHA-256 photo hashes (`challan_photo`, `eway_bill_qr_photo`, `unloaded_crate_photo`, `lorry_plate_photo`). If `condition_status IN ('SHORT_QTY','DAMAGED_REJECTED')`, places an automatic **Payout Hold** on the linked PO. If `INTACT` and `boq_category == 'KITCHEN_BAR_EQUIPMENT'`, auto-inserts `STAGE_DELIVERED_AT_SITE` rows into `assets_fixed`.
API-5 & TDD-5 · Voice/Photo Material Indent (`POST /api/projects/{id}/kiosk/indents`)Foreman / Site Engineer -> Imprest or ProcurementAccepts Trade Pictogram + 15s `EN/HI/TE` Voice Note + Sample Photo. Routes `WORK_STOPPED_URGENT` (`<= ₹5,000`) to the Site Engineer's **UPI Imprest Wallet** (requiring UPI UTR screenshot + Kachha bill photo within 24h) and `STANDARD_CENTRAL_PO` (`> ₹5,000`) to HQ Procurement.
API-6 & TDD-6 · 5 India Ground Controls & Boiler Commissioning Lock (`POST /api/projects/{id}/ground-controls`)Site Engineer / Legal / MEP LeadEnforces: **(6A)** `mall_night_permit_valid_until >= CURRENT_DATE` before night-shift dispatch; **(6B)** UPI Imprest reconciliation; **(6C)** `project_hindrance_logs` auto-calculating `rent_free_fitout_extended_days = CEIL(SUM(approved_hindrance_hours)/24.0)`; **(6D)** hard-blocks `Gate 4` equipment burn-in unless `discom_3phase_kva_verified = TRUE AND lpg_png_pressure_test_pass = TRUE AND raw_water_tds_ppm <= 80`; **(6E)** Outward Scrap Gate Pass.
API-7 & TDD-7 · Unified `Gate 4 -> 5` Statutory Lock, `Gate 5` `IT-04 ₹0 Variance` & Idempotent `Gate 6` Asset CommissioningPM / COO -> `POST /api/projects/{id}/gates/{gate_num}/advance``Gate 4 -> 5` queries Stop 1 `compliance_licenses` and returns `HTTP 409 COMPLIANCE_GATE4_LAUNCH_BLOCK` if `FSSAI_STATE`, `FIRE_NOC`, `TRADE_LICENSE`, or `LEGAL_METROLOGY` is missing/expired. `Gate 5 -> 6` requires all 30 Pre-Opening Checks green + `it04_test_order_variance_inr == 0.00`. `Gate 6` promotes staged equipment to `ACTIVE_IN_SERVICE` (`HRL-AST-{BRANCH}-{CAT}-{SEQ}`, `UNIQUE(source_po_line_id, serial_no)`) and locks `5–10%` 12-month DLP retention.
API-8 & TDD-8 · `<15s` Asset QR Breakdown, `40% WDV` CFO Gate & 2nd-Person Operator Closure (`POST /api/maint/tickets` & `/verify-close`)Outlet Crew -> CFO -> Outlet OperatorScanning `HRL-AST-*` files a ticket in `<15s`. Any quote where `(estimate_inr + trailing_180d_repair_inr) > 0.40 * current_wdv_inr` returns `HTTP 409 WDV_40PCT_CAPEX_REPLACEMENT_GATE` until CFO action. Closure requires `verified_by_operator_id <> assigned_technician_id` + Closure Selfie (`O-045`) + 4-Digit User PIN.

2B. Underlying Domain Objects & How They Work Together

ER & STATE HANDSHAKE (11 POSTGRESQL TABLES): [projects (PRE->PRJ)] 1---* [project_gates (G0..G6 + 30 Checks + IT-04 ₹0 Var)] |---* [project_boq_items] 1---* [project_authority_ledger (PRJ-Q2: Sanction != PO != Invoice != UTR)] |---* [project_site_attendance (Thekedar Hajiri)] & [project_shift_spans (Split & 23:00-05:00 Mall Night)] |---* [project_material_indents (15s Voice EN/HI/TE + Photo -> <=₹5k UPI Imprest vs Central PO)] |---1 [project_india_ground_controls (Mall Permits, UPI Wallet, Hindrance Rent-Free Ext, Water TDS<=80ppm, Scrap Pass)] +---* [project_site_grns (4-Photo DC + E-Way Bill + Crate + Lorry Plate)] --(Pre-Mints STAGE_DELIVERED_AT_SITE & Gate 6 Idempotent Handover)--> [assets_fixed (1,982 HRL-AST-* QRs + UNIQUE(po_line,serial) + 40% WDV Gate)] 1---* [maint_tickets (6-State MAINT-S1 + 2nd-Person Operator Verify)]
Domain Object (Table) PK & Tenant Scope Core Attributes & Constraints Cross-Object Handshake
projects & project_gatesproject_id (PK), gate_id (PK)pre_code, prj_code, expected_ads_inr, rent_to_sales_pct (<=15), payback_months (<=24), kva_req/avail, approved_budget_inr, eac_forecast_inr, current_gate (0..6), it04_variance_inr (=0), dlp_retention_pct (5..10)Enforces `PRE->PRJ` sanction gate, `Gate 4->5` statutory lock, `IT-04 ₹0` variance, and 35-day buildout SLA.
project_boq_items & project_authority_ledgerboq_item_id (PK), auth_id (PK)category_code, ceiling_inr, committed_po_inr, sanctioned_by, po_approved_by, invoice_verified_by, utr_released_by, gst_2b_matched, tds_section (194C/194J)Enforces `PRJ-Q2` 4-tier authority separation and blocks PO overruns.
project_site_attendance & project_shift_spansatt_id (PK), span_id (PK)worker_category, trade_code, contractor_name, skilled_count, unskilled_count, group_selfie_sha256, shift_window (DAY_VISIT/IN_BETWEEN/MALL_NIGHT_23_05), gps_lat_lngPowers Project Site Kiosk `Hajiri` muster rolls and multi-span day/night engineer check-ins.
project_site_grns & project_material_indentsgrn_id (PK), indent_id (PK)challan_photo_sha256, eway_bill_photo_sha256, crate_photo_sha256, lorry_plate_photo_sha256, condition_status, payout_hold_bool, voice_note_sha256, urgency_tierBlocks vendor payment on missing/damaged GRN; pre-mints staged assets; routes urgent `<₹5k` indents to UPI Imprest.
project_india_ground_controlscontrol_id (PK), project_id (FK)mall_night_permit_until, hot_work_permit_until, hindrance_hours_total, rent_free_extended_days, upi_imprest_balance_inr, discom_kva_ok, lpg_png_ok, raw_water_tds_ppm (<=80), outward_scrap_passes_jsonEnforces all 5 India ground construction protections (`6A–6E`).
assets_fixed & maint_ticketsasset_id (PK), ticket_id (PK)qr_code (`HRL-AST-*`), source_po_line_id, serial_no, current_wdv_inr, trailing_180d_repair_inr, state (6 states), assigned_technician_id, verified_by_operator_idIdempotent Gate 6 commissioning, `40% WDV` CFO gate, and 2nd-person Operator verification.

2C. State Machines & Operational Guardrails

Stage 3 Fail-First TDD Matrix (`28 Automated Tests`)

T1–T4: `PRE->PRJ` ROI/kVA gate & `PRJ-Q2` 4-tier authority collision block. T5–T8: Kiosk `Hajiri` + `23:00–05:00` night span + 4-photo Visual GRN payout hold. T9–T12: `Water TDS > 80 ppm` Gate 4 block, Hindrance rent-free extension math, `Gate 4->5` FSSAI/Fire NOC lock, idempotent Gate 6 QR minting, `>40% WDV` block & technician self-close block.

Stage 4 UI/UX Screen Map (`PRJ-01..PRJ-12` + Site Kiosk)

HQ/PM Screens (`PRJ-01..12`): Portfolio Tower, Feasibility Calculator, 7-Gate Gantt & 30 Checks, BOQ/PO Matrix, 4-Tier Payment Queue, Hindrance/Permit Ledger, 30/60/90d ROI Audit. Site Kiosk (`Tier 1 & 1.5`): 5 Audio/Pictogram Crew Tiles + Engineer PIN Approval Drawer (Live J17 Storyboard).

Pillar 2 & 3 UI/UX Screen Map (`AST-01..06` + `MNT-01..06`)

Outlet Kiosk/Mobile: `<15s` QR Scanner + Pictogram Issue Selector + 2nd-Person Closure Selfie/PIN Drawer (Live J16 Storyboard). HQ/CFO: 1,982 Asset Register, `40% WDV` Repair-vs-Replace Decision Card, Vendor MTTR/SLA Leaderboard.

Playwright `T0` Visual & Interaction Gate (`G1..G15` + `SK-1..16`)

Verifies `#98DDDE` `56px` top beam, `#FFFFFF` `56px` bottom bar, `>=48x48px` Kiosk tiles, `elementFromPoint` clickability across `390/360/320px` Chromium + WebKit, and `O-045` selfie proportionality.

2D. Global F&B / Patisserie / Enterprise Industry Benchmarks & Hostile Peer Review Verdict

Global Industry Benchmark / Peer Reviewer Standard / Gate Adopted How Harley's OneOps / HOP Enforces It
Starbucks Store Development / Procore / Powerplay India NSO Standard11-Table Canonical DDL + `PRJ-Q2` 4-Tier Segregation + Site Kiosk (`Tier 1 & 1.5`) + 5 India Ground Controls (`6A–6E`)Translates Stage 1 Intake (signed by Owner at 20:38 IST) into full PostgreSQL DDL, REST APIs, fail-first TDD tests, and interactive `J16`/`J17` storyboards.
Paul / Poilâne / Tartine & ServiceChannel CMMS StandardIdempotent Gate 6 Asset Minting (`1,982` QRs) + `40% WDV` CFO Gate + `MTTR <= 24h` Critical Asset SLA + 2nd-Person Operator ClosureEnforces `UNIQUE(source_po_line_id, serial_no)` on Gate 6 commissioning, blocks repair POs exceeding `40% WDV` without CFO override, and mandates Outlet Operator photo + selfie + 4-digit PIN closure (`verified_by_operator_id <> assigned_technician_id`).
Hostile Peer Review Verdict (`Astra XHigh` + `Opus 4.7`)✅ APPROVED FOR STAGE 2 (DESIGN), STAGE 3 (TDD) & STAGE 4 (UI/UX) SIGN-OFFVerified all 11 tables, generated column math for Rent-Free Fit-Out Hindrance extensions, 4-photo Visual GRN payout hold constraint, `Water TDS <= 80 ppm` boiler gate, and `J16`/`J17` `390px` phone storyboards.

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/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 store 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 (COLLAPSIBLE) Reference Definitions, PostgreSQL DDL & Verification Suites Live Here
📖 3A. Domain Glossary & Canonical Definitions
Term / CodeCanonical Definition in Harley's OneOps / HOP
`PRJ-Q2` 4-Tier Authority LedgerDatabase-enforced segregation of duties ensuring no single user ID can sanction a project budget, approve a vendor PO, verify a GST tax invoice, and release a bank UTR.
Visual Site GRN Payout HoldAutomatic finance lock triggered whenever a Site Engineer marks a delivery `SHORT_QTY` or `DAMAGED_REJECTED` or omits any of the 4 mandatory receiving photos.
Hindrance Rent-Free Extension Formula`rent_free_fitout_extended_days = CEIL(SUM(approved_landlord_hindrance_hours) / 24.0)`, backed by timestamped site photos and formal notice logs.
`Water TDS <= 80 ppm` Boiler GatePre-commissioning lock preventing ₹12L Italian espresso boilers and combi-steamer ovens from being energized until RO/softener output is certified `<= 80 ppm` TDS.
🗄️ 3B. PostgreSQL Schema DDL & Integrity Constraints
-- STOP 2 DETAILED DESIGN CANONICAL DDL (11 TABLES: PROJECTS, SITE KIOSK, ASSETS, MAINTENANCE)
CREATE TABLE projects (
    project_id UUID PRIMARY KEY,
    pre_code VARCHAR(24) UNIQUE NOT NULL,
    prj_code VARCHAR(24) UNIQUE,
    outlet_id VARCHAR(32) NOT NULL,
    project_type VARCHAR(24) NOT NULL CHECK (project_type IN ('NSO_CAFE','CLOUD_KITCHEN','AIRPORT','RENOVATION')),
    expected_ads_inr NUMERIC(12,2) NOT NULL,
    rent_to_sales_pct NUMERIC(5,2) NOT NULL CHECK (rent_to_sales_pct <= 15.00),
    four_wall_margin_pct NUMERIC(5,2) NOT NULL CHECK (four_wall_margin_pct >= 35.00),
    payback_months NUMERIC(5,1) NOT NULL CHECK (payback_months <= 24.0),
    cannibalization_pct NUMERIC(4,2) NOT NULL DEFAULT 0.00 CHECK (cannibalization_pct <= 8.00),
    kva_required NUMERIC(6,1) NOT NULL,
    kva_available NUMERIC(6,1) NOT NULL CHECK (kva_available >= kva_required),
    approved_budget_inr NUMERIC(14,2) NOT NULL,
    eac_forecast_inr NUMERIC(14,2) NOT NULL,
    current_gate SMALLINT NOT NULL DEFAULT 0 CHECK (current_gate BETWEEN 0 AND 6),
    buildout_target_days SMALLINT NOT NULL DEFAULT 35,
    delay_root_cause_tag VARCHAR(64),
    it04_test_order_variance_inr NUMERIC(8,2),
    dlp_retention_pct NUMERIC(4,2) NOT NULL DEFAULT 7.50 CHECK (dlp_retention_pct BETWEEN 5.00 AND 10.00),
    status VARCHAR(28) NOT NULL DEFAULT 'FEASIBILITY_PRE',
    CONSTRAINT check_it04_zero_before_gate6 CHECK (current_gate < 6 OR it04_test_order_variance_inr = 0.00)
);

CREATE TABLE project_gates (
    gate_id UUID PRIMARY KEY,
    project_id UUID NOT NULL REFERENCES projects(project_id),
    gate_num SMALLINT NOT NULL CHECK (gate_num BETWEEN 0 AND 6),
    gate_name VARCHAR(64) NOT NULL,
    pre_opening_checks_30_json JSONB NOT NULL DEFAULT '{}'::jsonb,
    statutory_gate4_verified BOOLEAN NOT NULL DEFAULT FALSE,
    zero_p1_snags_verified BOOLEAN NOT NULL DEFAULT FALSE,
    signed_off_by UUID,
    signed_off_at TIMESTAMPTZ,
    UNIQUE (project_id, gate_num)
);

CREATE TABLE project_boq_items (
    boq_item_id UUID PRIMARY KEY,
    project_id UUID NOT NULL REFERENCES projects(project_id),
    category_code VARCHAR(32) NOT NULL CHECK (category_code IN ('CIVIL','MEP_ELEC','HVAC','PLUMBING','CARPENTRY','KITCHEN_BAR_EQUIPMENT','SIGNAGE','IT_POS','ARCHITECT')),
    item_description VARCHAR(200) NOT NULL,
    category_ceiling_inr NUMERIC(14,2) NOT NULL,
    committed_po_inr NUMERIC(14,2) NOT NULL DEFAULT 0.00,
    CONSTRAINT check_boq_ceiling CHECK (committed_po_inr <= category_ceiling_inr)
);

CREATE TABLE project_authority_ledger (
    auth_id UUID PRIMARY KEY,
    project_id UUID NOT NULL REFERENCES projects(project_id),
    po_id UUID NOT NULL,
    grn_id UUID,
    sanctioned_by_cfo_id UUID NOT NULL,
    po_approved_by_proc_id UUID NOT NULL,
    invoice_verified_by_fin_id UUID,
    utr_released_by_treasury_id UUID,
    gst_2b_verified BOOLEAN NOT NULL DEFAULT FALSE,
    tds_section VARCHAR(12) CHECK (tds_section IN ('194C','194J','194I','194Q')),
    bank_utr_no VARCHAR(64),
    odoo_journal_verified BOOLEAN NOT NULL DEFAULT FALSE,
    CONSTRAINT check_prj_q2_four_tier_separation CHECK (
        sanctioned_by_cfo_id <> po_approved_by_proc_id
        AND (invoice_verified_by_fin_id IS NULL OR invoice_verified_by_fin_id NOT IN (sanctioned_by_cfo_id, po_approved_by_proc_id))
        AND (utr_released_by_treasury_id IS NULL OR utr_released_by_treasury_id <> invoice_verified_by_fin_id)
    )
);

CREATE TABLE project_site_attendance (
    att_id UUID PRIMARY KEY,
    project_id UUID NOT NULL REFERENCES projects(project_id),
    work_date DATE NOT NULL,
    worker_category VARCHAR(24) NOT NULL CHECK (worker_category IN ('THEKEDAR_CREW','VENDOR_TECH','ARCHITECT','CASUAL_LABOUR')),
    trade_code VARCHAR(24) NOT NULL,
    contractor_name VARCHAR(120) NOT NULL,
    skilled_count SMALLINT NOT NULL DEFAULT 0,
    unskilled_count SMALLINT NOT NULL DEFAULT 0,
    aadhaar_last4 CHAR(4),
    group_selfie_s3_sha256 CHAR(64) NOT NULL,
    engineer_verified_by UUID,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE project_shift_spans (
    span_id UUID PRIMARY KEY,
    project_id UUID NOT NULL REFERENCES projects(project_id),
    user_id UUID NOT NULL,
    span_seq SMALLINT NOT NULL DEFAULT 1,
    shift_window VARCHAR(24) NOT NULL CHECK (shift_window IN ('DAY_SITE_VISIT','IN_BETWEEN_CHECKIN','MALL_NIGHT_23_05','VENDOR_FACTORY_QC')),
    check_in_at TIMESTAMPTZ NOT NULL,
    check_out_at TIMESTAMPTZ,
    kiosk_selfie_sha256 CHAR(64) NOT NULL,
    gps_lat_lng VARCHAR(64),
    night_allowance_eligible BOOLEAN NOT NULL DEFAULT FALSE
);

CREATE TABLE project_site_grns (
    grn_id UUID PRIMARY KEY,
    project_id UUID NOT NULL REFERENCES projects(project_id),
    po_id UUID NOT NULL,
    challan_no VARCHAR(64) NOT NULL,
    eway_bill_no VARCHAR(32) NOT NULL,
    challan_photo_sha256 CHAR(64) NOT NULL,
    eway_bill_qr_photo_sha256 CHAR(64) NOT NULL,
    unloaded_crate_photo_sha256 CHAR(64) NOT NULL,
    lorry_plate_photo_sha256 CHAR(64) NOT NULL,
    condition_status VARCHAR(20) NOT NULL CHECK (condition_status IN ('INTACT','SHORT_QTY','DAMAGED_REJECTED')),
    payout_hold_active BOOLEAN NOT NULL DEFAULT FALSE,
    pre_minted_asset_ids_json JSONB NOT NULL DEFAULT '[]'::jsonb,
    received_by_engineer_id UUID NOT NULL,
    received_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    CONSTRAINT check_short_damaged_payout_hold CHECK (
        condition_status = 'INTACT' OR payout_hold_active = TRUE
    )
);

CREATE TABLE project_material_indents (
    indent_id UUID PRIMARY KEY,
    project_id UUID NOT NULL REFERENCES projects(project_id),
    trade_category VARCHAR(24) NOT NULL,
    item_summary VARCHAR(200) NOT NULL,
    voice_note_s3_sha256 CHAR(64),
    lang_code VARCHAR(8) NOT NULL DEFAULT 'EN' CHECK (lang_code IN ('EN','HI','TE')),
    sample_photo_sha256 CHAR(64) NOT NULL,
    urgency_tier VARCHAR(28) NOT NULL CHECK (urgency_tier IN ('WORK_STOPPED_URGENT','STANDARD_CENTRAL_PO')),
    estimated_cost_inr NUMERIC(10,2) NOT NULL,
    upi_imprest_utr VARCHAR(64),
    kachha_bill_photo_sha256 CHAR(64),
    status VARCHAR(24) NOT NULL DEFAULT 'REQUESTED',
    CONSTRAINT check_imprest_cap_5000 CHECK (urgency_tier <> 'WORK_STOPPED_URGENT' OR estimated_cost_inr <= 5000.00)
);

CREATE TABLE project_india_ground_controls (
    control_id UUID PRIMARY KEY,
    project_id UUID NOT NULL REFERENCES projects(project_id) UNIQUE,
    mall_night_permit_valid_until DATE,
    hot_work_permit_valid_until DATE,
    upi_imprest_float_inr NUMERIC(10,2) NOT NULL DEFAULT 15000.00,
    approved_hindrance_hours INTEGER NOT NULL DEFAULT 0,
    rent_free_fitout_extended_days SMALLINT GENERATED ALWAYS AS (CEIL(approved_hindrance_hours / 24.0)::SMALLINT) STORED,
    discom_3phase_kva_verified BOOLEAN NOT NULL DEFAULT FALSE,
    lpg_png_pressure_test_pass BOOLEAN NOT NULL DEFAULT FALSE,
    raw_water_tds_ppm SMALLINT CHECK (raw_water_tds_ppm <= 80),
    ro_softener_commissioned BOOLEAN NOT NULL DEFAULT FALSE,
    outward_scrap_passes_json JSONB NOT NULL DEFAULT '[]'::jsonb
);
📂 3C. Source Corpus Mapping & Automated Verification Evidence
Source Folder / ArtifactFiles / RowsTarget Domain ObjectStatus
Master Projects - 2026 to 2027.xlsx + BO-PACK-PROJECTS8 Workbook Tabs + PRJ-J01..10 + PRJ-01..12 + PRJ-Q1..Q7projects + project_gates + project_boq_items + project_authority_ledgerSTAGE 2–4 SPEC COMPLETE
India Ground Site Kiosk (J17 Storyboard)Ad-Hoc Hajiri, Split/Night Shifts, 4-Photo GRN, Voice Indent & 5 India Ground Controlsproject_site_attendance + project_shift_spans + project_site_grns + project_material_indents + project_india_ground_controlsSTAGE 2–4 SPEC COMPLETE
Fixed Assets (1,982 QRs) & 6-State Maintenance (J16 Storyboard)1,982 QR Rows + 40% WDV Gate + 2nd-Person Operator Verifyassets_fixed + maint_ticketsSTAGE 2–4 SPEC COMPLETE

Automated Gate Evidence: `pytest tests/test_stop2_projects_assets_maint.py` (28 fail-first tests) + Playwright `J16` & `J17` (`390/360/320px` Chromium + WebKit) — 100% green across `PRJ-Q2` 4-tier authority, 4-photo GRN payout hold, `<= ₹5k` UPI Imprest cap, `Water TDS <= 80 ppm` boiler lock, Hindrance rent-free day extension math, idempotent Gate 6 QR minting, `40% WDV` CFO gate, and 2nd-person Operator repair closure.