# R-SWEEP — Reconciliation Context

> **Document type:** frozen planning artifact from 2026-04-29.
> **Verified 2026-05-02:** the sweep was overtaken by the OpenAPI snapshot (`docs/openapi/openapi.yaml`) and the per-module SCREENS-INVENTORY refresh. Steps (a)–(h) below were never run as a unified pass; equivalent reconciliation now lives inline in each `SCREENS-INVENTORY-*.md` "Backend status" column and in `FLOW-INVENTORY.md`.
> **Kept for context** so future readers understand why `BACKEND-MAPPING.md`, `POSTMAN-SURFACE.md`, and the `R-SWEEP-A-MOCK-INVENTORY.md` exist and what problem they were responding to.

> **Status:** queued, not started.
> **Trigger:** real Postman collection landed 2026-04-29; revealed prototype mocks have drifted from real backend surface.
> **Owner:** Mohamed (manager) → next session.

---

## Why we're doing this

R1 (Products) shipped successfully — pattern proven. R2 (Purchasing) was about to ship when the real Postman collection arrived. Cross-checking immediately revealed:

| Surface | Mocks I built | Real backend |
|---|---|---|
| Suppliers | `GET, POST` | `GET, POST` ✅ |
| Purchase Orders | `GET, POST, send, update, receive, close, cancel` (7) | **Does not exist** ❌ |
| RFQs | `GET, POST, award, cancel` (4) | **Does not exist** ❌ |
| Supplier Invoices | (none) | `POST` 🆕 missing |
| Supplier Payments | (none) | `POST` 🆕 missing |
| Debit Notes | (none) | `POST` 🆕 missing |

Net: **11 invented mocks, 3 missing mocks, 2 matches** — in a single small module. Without sweeping, every R-phase risks the same drift.

---

## Source of truth

Two files now permanent in `docs/handoff/postman/`:
- `DALSEEN.postman_collection.json` — 316 endpoints across 33 folders
- `DALSEEN.postman_environment.json` — local dev fixture (baseUrl, token, IDs)

**Critical observation from environment file:** `tenantId = 12`, `branchId = 1` — both **integers**. Our mocks generate ULIDs. This is a real schema mismatch we must resolve in step `R-SWEEP-c`.

`docs/handoff/POSTMAN-SURFACE.md` has the flat list, generated from the JSON. Use this for spot-checks.

---

## The sweep

Eight steps, ordered:

| Step | Action | Output |
|---|---|---|
| **a** | Inventory all ~80 mocks across `front/api/api-namespace.js` (path, method, body shape, response shape) | spreadsheet/markdown table |
| **b** | For each, classify against `POSTMAN-SURFACE.md`: ✅ matches · ⚠️ shape-drift · ❌ invented · 🆕 real-but-unmocked | classified table |
| **c** | Audit ID format — ULID (mock) vs integer (real backend) — decide compat strategy | decision in `DECISIONS.md` |
| **d** | Update `BACKEND-MAPPING.md` so every row has a verdict + evidence (Postman folder ref or "invented") | rewritten doc |
| **e** | Decide per ❌ row: keep prototype-only, drop, or push backend to add | annotated doc |
| **f** | For ⚠️ rows, fix mock shapes to match real Postman bodies | code edits in `api-namespace.js` |
| **g** | For 🆕 rows that prototype screens need, add new mocks | code edits in `api-namespace.js` |
| **h** | Re-base R2/R3/R4/R5 plans on the corrected mapping | update `RETAIL-MIGRATION.md` |

---

## What R1 work is safe

R1 (Products) was done before this discovery, so it carries the same risk. **Spot-check needed in step (a):**
- `GET, POST, PATCH, DELETE /catalog/products` — real backend has these (folder `03 — Catalog`)
- `POST /catalog/products/:id/archive`, `restore`, `adjust`, `bulk-reprice`, `bulk-tag`, `import` — almost certainly **invented**, treat as ❌

If invented, the R1 façade still works for the prototype but the mocks need a `legacy_id`-style annotation marking them as frontend-only convenience layers.

---

## What R2 work to leave in place vs. revert

R2a added 13 mock endpoints (suppliers create + 7 PO + 4 RFQ + …). Right now they're all dormant — only `RetailHooks.suppliers.add` and the products-side mirrors actually fire `_api()` calls. R2b's PO/RFQ façade calls were **not yet wired**, so we're at a clean break point.

Per the manager's call (Path C), we leave the R2a code in place untouched, mark it as `⛔ frontend-only` in the next-pass mapping, and move on to the sweep.

---

## When to come back

Open the next session with: **"Begin R-SWEEP — start with step (a): inventory all mocks."**

Reference docs: `POSTMAN-SURFACE.md`, `BACKEND-MAPPING.md`, this file.
