# 33 — Pharma CMO Domain Addendum: What the Client Did Not Say

> Companion to the client-workflow addendum (Cycle 1 Exploratory Costing + Cycle 2 Production/MTO,
> toll/"تصنيع للغير"). The client described his commercial flow (R&D draft BOM → Accounting quote →
> trial batch → deposit → reserve → MO → issue → manufacture → FG). This file lists what a regulated
> **pharmaceutical contract-manufacturing (CMO/toll)** operation will ALSO require, so management is
> not surprised in execution or audit. Scope: **high-confidence pharma-domain items only**, each
> flagged اختياري (optional/nice) or لاحق (deferred phase) with a phase suggestion against the
> published roadmap (`md/23-roadmap.md`).
>
> Method: each item is cross-checked against the published gap analysis (`md/21-gaps.md`) and the
> definitive mapping (`md/20-mapping.md`) to label it **ALREADY-LISTED** (the published analysis
> already carries it — pharma only re-prioritises it) or **NEW** (genuinely not in the published
> docs). Sources cited inline.

---

## 0. Why this addendum exists

The Manufacturing spec (`files/manufacturing_spec/markdown`) is **deliberately industry-generic** —
its melamine-tableware worked example, its `quality_status ∈ {Released, OnHold, Rejected}` enum
(`03_execution.md:209`) and its free-text `batch_no/lot_no` fields (`03_execution.md:81, 207`) are
the entire extent of its regulated-manufacturing coverage. The spec EXPLICITLY defers the quality
layer (`md/21-gaps.md` excluded-candidates table: *"Quality layer — Spec defers it; Moon QMS already
supplies it"*) and never states a lot-traceability rule (`md/21-gaps.md` B2). For a **pharma** CMO
this generic posture is insufficient: several items the spec treats as optional become **regulatory
hard requirements** (GMP / batch-record / release-control), and a few have no home anywhere in the
published analysis. This addendum closes that interpretation gap **before** the board signs the
client addendum.

The reclassification principle: **pharma does not add many new tables — it changes the SEVERITY and
the DEFAULT of items the published analysis already sized as deferrable.** The single largest example:
GR `quality_status` defaults to **Auto-Released** for Phases 1–5 (`md/23-roadmap.md` D-21). For a
pharma line that default is **non-compliant** — FG must be held QC-pending and may not move to
sellable FG stock until a Qualified-Person/QC release exists.

---

## 1. The pharma considerations (cross-checked)

| # | Item | Published status | Verdict | Severity for pharma | Flag + phase |
|---|---|---|---|---|---|
| P1 | **Batch Manufacturing Record (BMR) + batch numbering** | Partially: `SequenceService` numbering exists; per-event docs (Issue/Confirmation/GR) exist as `mfg_*` tables — but no consolidated *batch record* artifact | **NEW (assembly is new)** | CRITICAL (GMP core) | لاحق — Phase 2→6 |
| P2 | **QC release hold before FG transfer** | ALREADY-LISTED — `quality_status` enum (mapping row 22), QMS `qms_inspections.production_order_id` exists; default Auto-Released (D-21) | **ALREADY-LISTED — default flip** | CRITICAL | لاحق — Phase 6 (pull QC-gate config earlier for pharma) |
| P3 | **Mandatory lot + expiry tracking, FEFO** | ALREADY-LISTED — gap **A4** (batch not first-class) + **B2** (no traceability rule); roadmap Phase 6, D-14 | **ALREADY-LISTED — now CRITICAL** | CRITICAL (recall/expiry law) | لاحق — Phase 6 (candidate to pull forward) |
| P4 | **Artwork / packaging spec per customer** | NEW — not in `md/20`/`md/21` | **NEW** | IMPORTANT | اختياري/لاحق — Phase 6+ |
| P5 | **Retained / reference samples** | NEW — not in published docs | **NEW** | IMPORTANT (GMP retention) | لاحق — Phase 6 |
| P6 | **Cleaning / changeover between products on shared lines** | Partially: `setup_time` exists (mapping row 5); downtime/pause undefined (**B15**); cleaning as a costed/validated step is NEW | **NEW (cleaning step) / capacity impact** | IMPORTANT (cross-contamination) | لاحق — Phase 2 (cost) / Phase 4 (capacity) |
| P7 | **Regulatory dossier / registration linkage** | NEW — not in published docs | **NEW** | IMPORTANT (market-authorisation) | اختياري/لاحق — Phase 6+ |
| P8 | **Yield reconciliation requirement** | Partially: `yield% = Σgrades/input` exists (`04_costing.md`/`03_execution.md:152`); reconciliation *as a mandatory accountability gate* is NEW | **NEW (mandatory gate)** | IMPORTANT (GMP material balance) | لاحق — Phase 2 (capture) / Phase 6 (gate) |

Net: of the 8 items, **2 are already in the published gap analysis** (P2 release-control, P3 lot/expiry
— pharma only re-prioritises them), **1 is partially covered** (P1 numbering/event-docs exist;
the consolidated record is new), and the remaining **4–5 are genuinely new** (artwork, retained
samples, cleaning-as-step, dossier linkage, and yield reconciliation as a hard gate).

---

## 2. Item detail

### P1 — Batch Manufacturing Record (BMR) & batch numbering — لاحق (Phase 2 capture → Phase 6 assembly), CRITICAL
- **What pharma needs:** every manufactured batch carries one auditable **Batch Manufacturing Record**
  — a single document tying the released order to: the frozen BOM/routing snapshot, every material
  issue (with the RM lot numbers consumed), in-process checks, operator/equipment/line, deviations,
  yield, and the QC release signature. Batch numbering must be a controlled, gap-free, per-product
  sequence (often year/line-encoded), distinct from the order number.
- **Published status:** the *ingredients* of a BMR already exist in the mapping — frozen snapshot in
  `production_order_materials/_operations` (mapping rows 14–15), `mfg_material_issues` /
  `mfg_confirmations` / `mfg_goods_receipts` event documents, and `SequenceService` numbering
  (`md/20-mapping.md` §3). What is **NEW** is the *consolidated, immutable batch-record assembly/print*
  over those rows, plus a dedicated batch-number sequence key.
- **Remedy:** a `production` batch-number sequence (`SequenceService::generateNext(company,'production','batch')`),
  a `batch_no` stamped at Release onto the order and propagated to every child document, and a
  BMR assembly view/print that gathers the existing event rows. No new transactional engine — a
  reporting/print layer (analogous to the travel-card gap **A21** in `md/21-gaps.md`).
- **Phase:** capture the `batch_no` link in **Phase 1/2** (cheap, additive); the formal BMR
  print/assembly with deviations + signatures in **Phase 6** alongside QMS gates and batch genealogy.

### P2 — QC release hold before FG transfer — لاحق (Phase 6; pull config earlier for pharma), CRITICAL
- **What pharma needs:** finished goods may NOT become sellable stock on goods-receipt. They land in
  a **QC-pending / quarantine** state and are released only after a QC/QP decision. This is the single
  most important pharma deviation from the generic plan.
- **Published status: ALREADY-LISTED.** The GR line already carries
  `quality_status ∈ {Released, OnHold, Rejected}` (`md/20-mapping.md` row 22; `03_execution.md:209`),
  QMS `qms_inspections`/`qms_inspection_plans` already carry `production_order_id`, and the roadmap
  schedules QMS gates in **Phase 6**. The catch is **D-21**: *"GR `quality_status` defaults to
  **Released** until the QMS gates land in Phase 6."* For pharma that default is non-compliant.
- **Remedy (no new schema):** for pharma companies flip the default to **OnHold**, and either
  (a) route OnHold FG into a quarantine warehouse (reuse the warehouse-as-state pattern, like the
  `is_consignment` flag in **A15**/D-15), or (b) block sellable availability until
  `qms_inspections.result = Released`. The `GoodsReceiptPosted` event already has a *"QMS GR-gate
  follow-up for OnHold lines"* consumer in the contracts (`md/22-contracts.md` §2). Cleanest
  early win: a per-company setting `production.gr_default_quality_status` so the pharma client
  gets OnHold-by-default without waiting for full Phase 6.
- **Phase:** the gate logic is **Phase 6**; the **default flip + quarantine warehouse** can be
  delivered as a small Phase 1 configuration item for this client.

### P3 — Mandatory lot + expiry tracking + FEFO — لاحق (Phase 6, candidate to pull forward), CRITICAL
- **What pharma needs:** lot and **expiry date** are mandatory, not free-text. Issue must be
  **FEFO** (first-expiry-first-out); full **genealogy** (which RM lots entered which FG lot) is a
  legal recall prerequisite; expiry must block issue/sale of expired stock.
- **Published status: ALREADY-LISTED as a CRITICAL gap** — this is gap **A4** (*"Batch/lot is not
  first-class… `batch_number`/`expiry_date` are free-text strings… no FEFO"*) plus the spec-side
  **B2** (*"Lot/batch traceability absent as a rule"*) in `md/21-gaps.md`, and decision **D-14**
  (*"Full batch dimension, feature-flagged per company"*), scheduled in roadmap **Phase 6**. The
  spec itself only carries `batch_no/lot_no` as free-text (`03_execution.md:81, 207`).
- **Pharma reclassification:** A4 is already CRITICAL; pharma confirms it is **non-deferrable for
  this client** — a pharma line cannot legally go live without lot+expiry+FEFO+genealogy. This is
  the strongest candidate to **pull forward** from Phase 6 (or to ship A4's batch-master subset in
  the same release that makes the client operational).
- **Remedy:** as A4/D-14 — `inventory_batches` master (with `expiry_date`), batch-keyed balances,
  FEFO pick on issue, and the genealogy link written at Material Issue ↔ Goods Receipt.

### P4 — Artwork / packaging specification per customer — اختياري/لاحق (Phase 6+), IMPORTANT
- **What pharma needs:** in toll/CMO work the **labelling and packaging artwork** are
  customer-and-market-specific and version-controlled; using the wrong/obsolete artwork is a
  recall-class error. Packaging materials are themselves controlled BOM components with their own
  lot control.
- **Published status: NEW.** Neither `md/20-mapping.md` nor `md/21-gaps.md` mentions artwork or
  packaging-spec control. The spec models packaging only as ordinary BOM components.
- **Remedy:** an artwork/label-version master keyed to (customer, product, market) with an
  effective/approved version (reuse `Attachment` rails + the BOM-versioning pattern, **A9**); the
  packaging BOM line references the approved artwork version. Lightweight; can ride the Phase 6
  toll-deepening work.

### P5 — Retained / reference samples — لاحق (Phase 6), IMPORTANT
- **What pharma needs:** GMP requires **retained samples** of each batch kept for the product's
  shelf-life + margin, logged and retrievable. Often a small reserved quantity of FG (and sometimes
  RM) per batch.
- **Published status: NEW.** Not present in any published doc.
- **Remedy:** a retained-sample register linked to `batch_no` (depends on P1/P3), optionally a
  small auto-reservation of FG at goods-receipt into a "retained-samples" warehouse (warehouse-as-state
  pattern again). Schedule with QMS/batch work in **Phase 6**.

### P6 — Cleaning / changeover between products on shared lines — لاحق (Phase 2 cost / Phase 4 capacity), IMPORTANT
- **What pharma needs:** on shared equipment, a validated **cleaning/changeover** between products is
  mandatory (cross-contamination control). It consumes real capacity and real cost, and gates the
  next product's start.
- **Published status: PARTIAL/NEW.** `setup_time` exists on routing operations (mapping row 5) and
  could absorb changeover time, but cleaning **as a distinct, validated, costed step** is not
  modelled; the broader downtime/pause taxonomy is an open spec gap (**B15** in `md/21-gaps.md`).
  Its **capacity impact** is genuinely new for CRP.
- **Remedy:** model changeover/cleaning as a routing operation type or a sequence-dependent setup on
  the work center; feed its duration into CRP effective-capacity (Phase 4 calendar/CRP work, **A8/B4**)
  and its cost into conversion costing (Phase 2). For v1 it can be approximated by `setup_cost_rate` +
  `setup_time`; a true validated-cleaning step is a later refinement.
- **Phase:** cost capture **Phase 2**; capacity/CRP impact **Phase 4**.

### P7 — Regulatory dossier / product registration linkage — اختياري/لاحق (Phase 6+), IMPORTANT
- **What pharma needs:** each manufactured product is tied to a **market-authorisation / registration
  dossier** (e.g. local MoH/EDA registration). The approved master BOM/routing must match the
  registered dossier; production of an unregistered or registration-expired product must be flagged.
- **Published status: NEW.** No dossier/registration concept anywhere in the published analysis.
- **Remedy:** a lightweight registration master (product, market, registration_no, validity dates,
  linked approved BOM version) with a check at order Release. Reuses BOM versioning (**A9**) +
  `Attachment`. Optional for v1; advisory flag is enough to start.

### P8 — Yield reconciliation as a mandatory accountability gate — لاحق (Phase 2 capture / Phase 6 gate), IMPORTANT
- **What pharma needs:** GMP requires a **material balance / yield reconciliation** per batch — inputs
  must reconcile to outputs + scrap + samples within validated limits, and out-of-limit yields must
  be explained and signed off **before** release.
- **Published status: PARTIAL.** The spec computes `yield% = Σgrades / input` (`03_execution.md:152`)
  and `mfg_confirmation_yields`/`_details` capture grade/scrap quantities (mapping rows 19–20). What
  is **NEW** is yield reconciliation **as a hard gate** (limit bands + mandatory explanation +
  block-release-on-breach), analogous to how variance tolerance bands work in costing
  (`md/23-roadmap.md` Phase 3) but applied to physical material balance for batch release.
- **Remedy:** reuse the tolerance-band pattern (Normal/Investigate) on the yield computation; an
  out-of-limit yield raises a deviation and blocks QC release (ties to P2). Capture exists from
  **Phase 2**; the release-blocking gate lands with QMS in **Phase 6**.

---

## 3. Cross-reference summary (published vs new)

**Already in the published gaps/mapping (pharma only re-prioritises):**
- P2 QC release hold → `md/20-mapping.md` row 22 + **D-21** (default flip is the only change).
- P3 lot/expiry/FEFO/genealogy → gap **A4** + spec-gap **B2** + **D-14** (already CRITICAL;
  pharma makes it non-deferrable for this client).
- P1 (partial) numbering + event documents + frozen snapshot → mapping rows 14–15, §3.
- P6 (partial) `setup_time` → mapping row 5; downtime taxonomy → **B15**.
- P8 (partial) `yield%` + `mfg_confirmation_yields` → `04_costing.md`, mapping rows 19–20.

**Genuinely NEW (no home in the published analysis):**
- P1 — consolidated **BMR assembly/print** + dedicated batch-number sequence.
- P4 — **artwork / packaging-spec** version control per customer/market.
- P5 — **retained / reference samples** register.
- P6 — **cleaning/changeover as a distinct validated, costed, capacity-consuming step** (+ its CRP impact).
- P7 — **regulatory dossier / registration** linkage.
- P8 — **yield reconciliation as a mandatory release gate** (vs the existing yield % metric).

**Phase placement (suggested, against `md/23-roadmap.md`):**
- Phase 1: P1 batch-number link (additive); P2 default-flip config + quarantine warehouse (this client).
- Phase 2: P1 capture continues; P6 cleaning cost; P8 yield capture.
- Phase 4: P6 cleaning capacity into CRP.
- Phase 6: P2 full QC gate, P3 lot/expiry/genealogy/FEFO (pull-forward candidate), P5 retained samples,
  P8 yield release gate, P1 BMR print, plus P4/P7 as optional add-ons.

---

## 4. One-line guidance for management
Pharma adds **no large new engine** to the published plan; it **upgrades the severity and changes the
defaults** of release-control (P2) and lot/expiry traceability (P3 = gap A4/B2 — already in the
analysis, now non-negotiable for go-live), and adds a small set of GMP artifacts (BMR, retained
samples, artwork/packaging versions, dossier linkage, yield-reconciliation gate). Recommend pulling
**A4 (batch+expiry+FEFO+genealogy)** forward to land with this client's first operational release, and
flipping **GR quality_status to OnHold-by-default** for the pharma company immediately.
</content>
</invoke>
