Quality Investigation Assistant
Outcome
Drive a quality deviation from detection to closed corrective action by linking inspection data, batch genealogy, and specifications into an evidence-backed root cause that a quality engineer approves before CAPA release.
| Portfolio attribute | Value |
|---|---|
| Primary persona | Quality engineer |
| Primary aggregate | QualityInvestigation |
| Cosmos DB containers | 4 |
| Grounding data | deviations, inspections, CAPAs, specifications |
| Development estimate | USD 60-220 monthly dev estimate |
| Runtime options | Python FastAPI and C# ASP.NET Core |
Productivity hypothesis
These measures reflect the workflow, evidence, decision boundary, and industry risk for this use case.
| Impact type | Measure | Conservative internal assumption | Customer measurement |
|---|---|---|---|
| Productivity | Investigation rework | 6-12% reduction | (baseline repeated or corrected investigation-step rate - assisted rate) / baseline rate * 100 |
| Quality or risk | First-pass acceptance | 6-10 percentage-point improvement | assisted percentage accepted without material rework - baseline percentage accepted without material rework |
Important: Conservative internal pilot assumptions only; not public benchmarks, commitments, or expected customer results. Validate against a comparable baseline or matched control cohort with mandatory human review.
Rationale: Deviation and CAPA investigation workflows benefit from evidence-preserving synthesis and fewer correction loops.
Pilot guardrail: Preserve the evidence chain and require quality approval for root cause, CAPA, and disposition.
Customer validation plan
- Baseline the current workflow with representative users and tasks.
- Run the accelerator on the same task mix with human review retained.
- Measure investigation rework and first-pass acceptance with the documented formulas.
- Replace internal assumptions with customer-observed results before a business case.
Why Azure Cosmos DB
This AI solution needs an operational data plane, not only a vector index:
- Hybrid vector and full-text retrieval combines semantic recall with exact identifiers, codes, names, and domain language.
- Hierarchical partition keys and metadata predicates keep tenant and domain boundaries in the normal query path.
- Operational JSON, source chunks, workflow and agent state, feedback, and audit records remain together for low-latency reads and governed writes.
- Change feed reacts to source and operational updates without polling.
- Autoscale throughput, configurable consistency, and multi-region distribution support variable demand and enterprise availability.
Domain workflow

| Stage | Actor | Input → output | Approval |
|---|---|---|---|
| 1. Log the deviation and classify risk | Quality engineer | Out-of-specification result or operator observation → QualityInvestigation with risk classification | Policy controlled |
| 2. Bound impact through batch genealogy | Genealogy service | Affected lot identifiers → Impacted lot and equipment set for containment | Policy controlled |
| 3. Assemble inspection and specification evidence | Evidence agent | Measurements and specification clauses → Evidence pack showing the breached criteria | Policy controlled |
| 4. Propose root cause and corrective actions | Investigation agent | Evidence pack and prior similar investigations → Ranked root cause with CAPA proposals | Policy controlled |
| 5. Approve CAPA and release the lot decision | Quality manager | Root cause, CAPA plan, and disposition recommendation → Approved CAPA and documented lot disposition | Human required |
Technical architecture

Cosmos DB data model
| Container | Hierarchical partition key | Documents | Search paths |
|---|---|---|---|
qualityInvestigations | /tenantId, /investigationId | QualityInvestigation, InspectionResult, CorrectiveActionItem | /deviationVectorEmbedding, /actionVectorEmbedding, /deviationVector, /actionVector |
batchGenealogy | /tenantId, /lotId | BatchGenealogyNode | Operational fields only |
qualitySpecificationLibrary | /tenantId, /specificationId | SpecificationClause | /clauseVectorEmbedding, /clauseVector |
investigationPrecedentIndex | /tenantId, /rootCauseCode | PriorInvestigationSummary | /summaryVectorEmbedding, /summaryVector |
Query contract
| Query | Container | Scope | Purpose |
|---|---|---|---|
| Investigation evidence assembly | qualityInvestigations | single-partition | Read the investigation, its inspection results, and its corrective actions in a single partition-aligned query. Lot genealogy is read separately from the batchGenealogy container because a lot participates in many investigations and must not be copied into each one. |
| Out-of-specification result scan | qualityInvestigations | single-partition | Isolate measurements that fell outside their specification limits. |
| Recurrence detection | investigationPrecedentIndex | single-partition | Knowledge-container query against investigationPrecedentIndex (partition-aligned to /tenantId + /rootCauseCode): prove or disprove recurrence by reading the precedent index for this root cause code, which is a single partition read rather than a scan of every closed investigation. |
| Overdue CAPA verification | qualityInvestigations | cross-partition-bounded | Bounded cross-partition control-plane query: list corrective actions whose effectiveness check has not been verified in time. It cannot carry the second partition key because the CAPA compliance report covers every open investigation in the quality system, so it runs as a tenant-scoped scheduled sweep off the interactive path, bounded by pending verifications due inside the current quality review period, executed with MaxItemCount paging and continuation tokens. |
Python and C# services route each document type to its declared container and hierarchical partition key. ETag-based writes protect mutable aggregates, while append-only records and bounded cross-partition queries preserve scale.
Azure deployment

Clone the source repository, authenticate with Azure, and run:
Set-Location accelerators/manufacturing/quality-investigation-assistant
az login
./Deploy.ps1 -Runtime python -Location eastus2
Change python to csharp to deploy the .NET implementation.
Explore the implementation
- Launch signed-in demo
- Implementation article
- Domain data model
- Workflow and API contract
- Python application
- C# application
- Domain container Bicep
- Platform Bicep
- Cost and configuration
- Source repository