Accepted.
The approved NCR/CAPA workflow already owns lifecycle transitions, QA authority, contractor response limits, optimistic concurrency, audit events, and evidence linkage. The enhancement adds drafting assistance only; it must not replace deterministic values or human approval.
DataCenterIQ stores NCR/CAPA AI output in ncr_ai_drafts, separate from authoritative NCR and CAPA records. Source facts are loaded server-side from compliance checks/findings, failed mandatory commissioning tests, or existing NCRs. Gemini receives only a factual context object and authorised evidence excerpts.
The prompt version is ncr-capa-v1. The prompt states that project records are untrusted evidence, not instructions, and forbids fabricated facts, citations, approvals, workflow state, cost/schedule values, and confirmed root cause claims. Gemini may draft only narrative and recommendation fields. The server validates strict JSON with Zod, verifies evidence IDs against the source context, stores the original generated payload immutably, and stores human edits separately.
QA Managers and organisation administrators can generate, approve, reject, regenerate, and issue from reviewed drafts. Engineers can view and propose edits. Auditors can view approved draft metadata. Contractors cannot access internal AI draft generation.
- COMPLEX: Deterministic facts and generated narrative are deliberately separated, which adds storage and validation work but preserves predictable quality authority.
- COMPLEX: Regeneration supersedes prior draft state rather than overwriting generated output.
- FRAGILE: Gemini availability, quota, latency, safety refusal, and structured-output behavior can prevent live generation. The deterministic fallback preserves manual NCR creation.
- FRAGILE: Production validation depends on hosted Supabase, Vercel, browser automation, and Gemini network availability.
Live local validation against hosted Supabase and Gemini generated a structured draft from a nonconforming UPS compliance source, persisted two evidence references, preserved human-review requirement, saved a reviewer edit, approved the draft, created an NCR from the approved version, and recorded audit events for generation, edit, approval, issuance, and NCR creation.