# v0.1 Demo Runbook — Retail Inward, Vendor-to-DC

A ~5-minute live demo of v0.1 running on the **real plumbing** (EMQX broker + Postgres), driven by a
workflow-driven Tunnel simulator. Simulation is only at the **device edge** (PRD "approved simulation mode");
everything downstream is the production path.

> **The story:** *configure once, run on the real platform.* A carton is scanned → the platform reconciles,
> encodes, verifies, accepts (or holds) → inventory updates in a durable log → the operator sees it on a screen
> that was **generated from the configuration**, per their role.

---

## 0. One-time setup (do before the demo)

```bash
# infra: the dedicated event-log Postgres (EMQX + the Core stack are already running in Docker)
cd platform/event-log && npm run db:up && npm run migrate

# deps (once)
cd ../ingest && npm install
cd ../device-cli && npm install
cd ../acceptance && npm install
```

Clean slate before you present:
```bash
cd platform/event-log && node --input-type=module -e "import {truncateAll} from './src/test-support.js'; await truncateAll(process.env.GARUDA_EVENTS_DB||'postgres://garuda:garuda_dev_password@localhost:5440/garuda_events'); console.log('clean');"
```

---

## Beat 1 — The two screens (the payoff)

Two audiences, two screens — both **generated from the configuration**, nothing hard-coded.

**1a — The operator runtime** (DC staff *doing* the work). Switch roles (Operator → Manager → Zonal → Auditor):
the navigation, scope and permitted operations reshape, all resolved from the published Workflow.
```bash
cd platform/runtime-ui && node src/snapshot.js && open runtime-ui.html
```

**1b — The customer / manager dashboard** (the business *seeing* the result): cartons accepted, inventory posted,
exceptions to action.
```bash
cd platform/customer-view && node snapshot.js && open customer-view.html
```
*Talking point:* "Same platform, same run — **two role-appropriate views**, each generated from config. A new
customer or role mix is a configuration change, not a new screen."

---

## Beat 2 — Scan a carton, live, on the real plumbing

**Terminal 1 — start the engine (a real service, subscribes to the broker):**
```bash
cd platform/ingest && node src/engine-consumer.js
```
**Terminal 2 — the presenter scans cartons (the Tunnel):**
```bash
cd platform/device-cli
node src/tunnel.js HU-260720-001 happy     # a good carton  → ACCEPTED, inventory +50
node src/tunnel.js HU-260720-004 short     # a short carton → ON HOLD, no stock
node src/tunnel.js shift                    # the whole shipment (4 clean + 2 exceptions) → inventory 200
```
Watch Terminal 1: each scan flows **device → MQTT → engine → durable log**, reconciled live
(`detected 50/50, encoded 50, verified 50 · inventory now …`).

*Talking point:* "The only simulated thing is the device — it **publishes to the real broker**, exactly like a
physical Tunnel. Everything after it is real." Prove it's durable, not memory:
```bash
docker exec garuda_events_db psql -U garuda -d garuda_events -tqc "select count(*) events, count(distinct correlation_id) cartons from events;"
```

---

## Beat 3 — It passes the acceptance test

```bash
cd platform/acceptance && node src/run.js
```
*Talking point:* "**24 checks across all 22 of Amol's runtime acceptance criteria** — correct receipt, exception
safety, exactly-once stock, retry safety, shipment completion, role/scope — end-to-end over the real path, one
command."

---

## The one-line mental model (for questions)

```
Workflow config → device (MQTT) → engine (walks graph) → encoder (SGTIN-96)
   → event log (Postgres, source of truth) → projection (stock) → runtime UI (per role)
```
Full trail: `platform/WALKTHROUGH.md`. Plan for real coexistence next: `../architecture/change-spec/INTEGRATION-PLAN.md`.

## Honest scope (if asked)
Simulated device (PRD-permitted); runtime UI is a generated view (not yet a clicking web app wired to the
web-service); Solution Studio authoring (AC-BP/AC-CFG), physical device wiring, Redis clustering, and the
shadow-parity-then-cut against the live `inward-scanned-worker` are the next tracks — with i-TEK.
