# VRX-URS37-PATCH-002 — GMP Equipment-Qualification Substrate Reconciliation

| Field | Value |
|---|---|
| Patch ID | VRX-URS37-PATCH-002 |
| Affects | URS-37 (Equipment / Calibration / PM), v1.2 → fold-in to v1.3 |
| Type | Controlled corrective patch — factual baseline correction + new corrective requirement (FIX-37-010) |
| Status | **DRAFT — for controlled change (URS-13) by an authorized person. Not approved.** |
| Date | 2026-06-07 |
| Code baseline verified | `verixaai/verixa` · branch **`dev-vimal-deploy`** · HEAD **`d8ccdb97`** (read-only audit, 2026-06-07) |
| Trigger | Independent audit asserted URS-37 is not fully greenfield as an equipment domain; verified true against the repo (see §2). |
| Owners | Engineering + CSV/CSA + GMP module owner (URS-33) + Head of QA |
| Verification method | Direct read of migrations, schema, service, routes on the pinned branch. Every claim line-pinned. No claim is made beyond what was read. |

> **Scope discipline.** This patch corrects ONE verified factual error in URS-37 and adds ONE corrective requirement. It changes nothing else. It does not approve URS-37, does not claim implementation completeness, and does not claim validation. The canonical URS-37 master is updated only by an authorized person folding this patch into v1.3 under change control.

---

## 1. Finding

URS-37 v1.2 states the module is **fully greenfield** — that no Verixa code, UI, API, or schema exists for the capability. **This is materially incorrect** at `dev-vimal-deploy @ d8ccdb97`. An adjacent, consolidated **GMP equipment-qualification substrate already exists** under the `gmp` module. URS-37 is greenfield **only as a dedicated canonical Module 37**, not as an equipment-qualification domain.

Because the existing substrate is tagged **URS-033** (migration 186 header: `URS-033-010`), URS-37 claiming canonical equipment-qualification truth creates a **dual-source-of-truth risk with URS-33**. That must be reconciled before URS-37 is approved for engineering.

## 2. Verified evidence (line-pinned, `dev-vimal-deploy @ d8ccdb97`)

### 2.1 Exists — contradicts the greenfield claim

| Artifact | Evidence (file:line) | What it provides |
|---|---|---|
| `gmp_equipment_qualifications` table | `packages/backend/src/db/migrations/074_gmp_domain_pack.sql:364` | Equipment identity (equipment_id/name/type/manufacturer/model/serial/location); **DQ/IQ/OQ/PQ qualification lifecycle** (`status` CHECK enum: pending→dq/iq/oq/pq_in_progress/complete→qualified/failed/expired/decommissioned; `current_stage` DQ/IQ/OQ/PQ); qualification/expiry/next_review dates, protocol_ref, report_ref; **calibration_status** (calibrated/due/overdue/out_of_tolerance/not_applicable) + dates + certificate_ref; **maintenance** (last/next date, type preventive/corrective/predictive/breakdown); deviation linkage counts; CSV applicable + category. RLS enabled (`gmp_equip_tenant_isolation`); 4 indexes. |
| `gmp_equipment_qualification_exceptions` table | `packages/backend/src/db/migrations/186_gmp_equipment_exceptions.sql:8` (header tag **`URS-033-010`**) | Time-limited qualification exception; FK → `gmp_equipment_qualifications(id)` ON DELETE RESTRICT; `reason`, `valid_until`, `granted_by`, `esig_id` (authority + e-signature); RLS enabled. |
| Service layer | `packages/backend/src/modules/gmp/service.ts:2580–2690+` | `listEquipmentQualifications`, `getEquipmentQualification`, `createEquipmentQualification`, `updateEquipmentQualification`; audit `resourceType: 'gmp_equipment_qualification'`. |
| Route surface | `packages/backend/src/modules/gmp/routes.ts:860+` | `equipmentQualificationsRoutes`; permission `resource: 'gmp_equipment_qualifications'`, actions read/create; Zod schemas. |
| Typed schema | `packages/backend/src/db/schema.ts:434–435` | `GmpEquipmentQualificationsTable`, `GmpEquipmentQualificationExceptionsTable`. |
| Provenance | git | 074 last touched `4fd667e3` (2026-04-04); 186 at `07255bde` (2026-05-07). |

### 2.2 Does NOT exist — genuinely still greenfield (URS-37 canonical scope is correct as target-state)

| URS-37 canonical element | Repo check | Result |
|---|---|---|
| Dedicated `equipment` / `calibration` / `maintenance` modules | `ls modules/` | **Absent** |
| Normalized calibration schedule + calibration record registers | migration grep | **Absent** (calibration is columns on the single consolidated table, not registers) |
| PM schedule + work-order registers | migration grep | **Absent** |
| **EQ-006 equipment-status-gate API** (consumed by URS-33/23/24/25/15) | code grep | **Absent** |

**Net:** the existing substrate is a single consolidated `gmp_equipment_qualifications` row (qualification + calibration-status + maintenance-status as fields) plus an exception route — **not** the normalized register set or the EQ-006 gate URS-37 specifies. Those remain target-state.

## 3. Superseded text (verbatim) → correction

| # | Location | Current text (verbatim, v1.2) | Correction |
|---|---|---|---|
| C-1 | Header → Status | "Greenfield module: no current Verixa code, UI, API, or schema exists for this capability." | "Greenfield **as a dedicated canonical Module 37** (no `equipment`/`calibration`/`maintenance` module, no normalized calibration/PM register set, and no EQ-006 status-gate API exist). **NOT greenfield as an equipment-qualification domain:** an adjacent consolidated GMP equipment-qualification substrate exists under the `gmp` module on `dev-vimal-deploy @ d8ccdb97` (migrations 074 + 186; service + routes + RLS) and **shall** be reconciled per FIX-37-010 before approval." |
| C-2 | Header → Code Modules | "Target binding — greenfield module; no current code exists; implementation evidence required." | "Target binding for the **dedicated** Module 37. Adjacent existing code: `gmp_equipment_qualifications` (074:364), `gmp_equipment_qualification_exceptions` (186:8, URS-033-tagged), `modules/gmp` service+routes. Reconciliation of canonical ownership required (FIX-37-010)." |
| C-3 | §20 Final Quality Gate | "This is a greenfield module: no current Verixa code, UI, API, schema, or migration exists for it." | "This is greenfield **as a dedicated Module 37**. An adjacent GMP equipment-qualification substrate exists (074/186, `modules/gmp`); §20 approval is **blocked** until FIX-37-010 (substrate reconciliation) is closed in addition to the existing FIX-37-001/008/009 items." |

## 4. New corrective requirement

### FIX-37-010 — GMP equipment-qualification substrate reconciliation (P0, pre-approval)
- **Current state (verified):** an adjacent consolidated equipment-qualification substrate exists under `gmp` (URS-033 lineage); URS-37 specifies a dedicated canonical Module 37. Two potential sources of equipment-qualification truth.
- **Requirement:** Before URS-37 approval, Engineering + CSV/CSA + the URS-33/GMP module owner + Head of QA **shall** decide and document the canonical ownership of equipment-qualification truth, choosing one of: (a) **migrate** `gmp_equipment_qualifications` / `_exceptions` into Module 37 as the canonical SoR; (b) **Module 37 consumes/extends** the existing `gmp` substrate (no duplicate store); (c) **deprecate** one in favour of the other; or (d) **bidirectional map** with a defined master. The decision **shall** be recorded under change control (URS-13) with field-level mapping from the existing 074/186 columns to the URS-37 `equipment` / `equipment_qualifications` / EQ-006 model, and a migration/deprecation plan with test cases for legacy GMP qualification records.
- **Acceptance:** exactly **one** canonical source of equipment-qualification truth exists after Module 37 launch; a field-level mapping + migration/deprecation plan with legacy-record test cases exists; URS-33 consumes EQ-006 after Module 37 launch; no duplicate equipment-qualification store remains unreconciled.
- **Basis:** GDocP single-source-of-truth; Annex 11 §4.4 / §10 (change & configuration management); data-integrity (no duplicate regulated truth).

## 5. Approval-readiness adjustment

URS-37 §20 already lists FIX-37-001 (interval-matrix values), FIX-37-008 (URS-05 authority addition), FIX-37-009 (EQ-006 perf threshold) and signature capture as remaining items. **Add FIX-37-010 as a blocking pre-approval item.** URS-37 is **ready for controlled engineering/QA review, not for approval**, until FIX-37-001/008/009/010 are closed and signatures captured. This patch does not change URS-37's existing `Draft — not validation-ready` status; it adds a blocker and corrects a factual claim.

## 6. Disposition & fold-in

- **Disposition:** URS-37 v1.2 contains a verified factual error (greenfield claim) and a newly identified P0 reconciliation blocker. **Corrective patch issued (DRAFT).**
- **Fold-in:** an authorized person folds C-1/C-2/C-3 + FIX-37-010 into URS-37 **v1.3** under URS-13 change control, adding a version-history row referencing VRX-URS37-PATCH-002 and this verified baseline. (Mirrors how v1.2 folded VRX-URS37-PATCH-001.)

| Boundary Check | Result |
|---|---|
| Primary lens | CSV/CSA + Product/Engineering Architect + Data Integrity (single-source-of-truth) |
| Owned deliverable | Factual baseline correction + reconciliation corrective requirement (FIX-37-010) |
| Out-of-scope (deferred) | Final QA approval → Head of QA; detailed migration test protocol → Validation Test Architect; canonical-ownership decision → Engineering + GMP owner + QA (human) |
| Repo | Read-only; no repo files modified |
| Final status | Draft — controlled change required (URS-13); Head of QA decision required |

*Verified read-only against `verixaai/verixa dev-vimal-deploy @ d8ccdb97`. No Verixa repo files modified. No claim of validation, compliance, or approval.*
