Engineering Blog

Technical insights from Grid Dynamics engineers

How Quality Engineering Must Change as AI Stops Being Deterministic

How Quality Engineering Must Change as AI Stops Being Deterministic

Sanjay Kumar · Jun 24, 2026

Many enterprise QA teams are still applying deterministic Quality Engineering practices to AI systems that are not deterministic — writing static test cases, expecting rigid binary outputs, and measuring success with code coverage metrics. That works when a system executes rules a developer explicitly wrote. It fails when the system learns its behavior from data, discovers structure without labels, or generates outputs with no single correct answer.

The basis of trust shifts at each stage of AI maturity: from logic in rule-based systems, to statistical accuracy in supervised learning, to structural stability in unsupervised learning, to behavioral bounds in generative AI. Quality Engineering must change at each stage. This article maps what that means in practice — and where each QE approach breaks down.

Stage 1: Rule-Based AI — Validating Deterministic Logic

Rule-based systems execute explicit, deterministic logic defined by domain experts. Given the same input, the output is always identical. Functional regression suites and automated test-case execution work well here because a binary verdict is always available: either the output matches the predefined criterion or it doesn't.

Common Examples

  • Workflow automation engines
  • Input validation tools
  • Recommendation engines with fixed eligibility criteria
  • Decision-tree chatbots

QE Approach

Correctness and coverage. Every rule must be exercised across all meaningful input combinations. Test matrices map input conditions to expected outputs; any gap is a coverage gap.

Regression safety. Rules are authored by humans and change when requirements change. Regression suites must re-run automatically on every rule update to verify that modifying one rule hasn't silently broken another.

Requirement traceability. Each test case should trace back to a stated business rule so that specification gaps surface before release.

Trust basis: the system is trustworthy when its logic is verified as correct.

Where Rule-Based QE Fails

The approach breaks down at the boundary of the rule set. Rules written for anticipated inputs don't cover unspecified ones — and real-world traffic finds the gaps. When a user presents an input that falls outside defined branches, the system may default silently rather than fail loudly. Testing only the happy path and known error cases misses the combinatorial explosion of edge-state intersections that accumulates in production.

A subtler failure mode is specification drift: the rules in the system diverge from the rules in the test suite over time, and coverage metrics don't catch this because the tests still pass — they're validating yesterday's logic.

Stage 2: Supervised Learning — Auditing Predictive Behavior

Supervised models learn from labeled training data and produce probabilistic predictions. There is no single "correct" output to compare against — only a distribution of outcomes. The QE question shifts from "does the code execute the rule?" to "does the model generalize correctly?"

For a treatment of how determinism and non-determinism interact in these pipelines, see Deterministic Behavior in LLM Pipelines.

Typical Use Cases

  • Recommendation engines
  • NLP text classifiers
  • Fraud detection

Key QE Focus Areas

Data quality validation. A model is only as reliable as the data it trained on. Validate for missing values, duplicates, label consistency, and class balance before training. A mislabeled minority class is a defect — it just lives in the dataset rather than the codebase.

Model performance testing. For balanced classification tasks, accuracy is a reasonable headline metric. For imbalanced domains — fraud detection being the standard example — accuracy is actively misleading: a model that predicts "not fraud" for every transaction achieves 99.9% accuracy while being completely useless. The relevant metrics are precision, recall, F1, and PR-AUC. Establish per-class baselines and alert on regression against them, not aggregate accuracy alone.

Bias and fairness auditing. Test whether prediction accuracy is consistent across demographic subgroups. A model that performs well overall but systematically underperforms for a protected class is a compliance risk regardless of its aggregate score.

Drift monitoring. Models degrade when production data distribution diverges from the training distribution. Automated monitors compare feature distributions over time and alert when statistical distance crosses a threshold.

Where Supervised QE Fails

Drift monitors are not free signal. Tighten the alerting threshold and you trigger false alarms on benign seasonal shifts; loosen it and real concept drift erodes precision silently for weeks. The QE question is not "is there drift?" but "what is the cost of acting on a false drift alarm versus missing a real one?" — and that trade-off is model- and domain-specific. There is no universal threshold.

Cross-validation scores on held-out test sets measure generalization to historical patterns, not robustness to the future. A model can clear all validation gates and still fail when a novel input pattern — a new fraud vector, a product category that didn't exist at training time — enters production.

Stage 3: Unsupervised Learning — Validating Structure Without Ground Truth

Unsupervised models discover latent structure in unlabeled data. The absence of ground-truth labels removes the fundamental precondition for assertion-based testing: there is no reference answer to compare the output against.

Quality Engineering shifts from "does the output match the expected value?" to "is the discovered structure stable, separable, and interpretable?"

Typical Examples

  • Customer segmentation
  • Anomaly detection in large datasets
  • Topic modeling
  • Behavioral cohort analysis

QE Framework for Unsupervised Systems

Cluster stability validation. Run the model multiple times on the same dataset with different random seeds. High variance in cluster membership signals an unstable solution. Silhouette Coefficient measures how well each point fits its assigned cluster versus the nearest alternative; declining values across runs indicate boundary fragility.

Separation quality. Davies-Bouldin Index measures intra-cluster compactness relative to inter-cluster distance. A rising index signals clusters are merging or overlapping — often an early indicator of distribution shift.

Semantic drift monitoring. In embedding-based models, compute the Wasserstein distance between successive embedding distributions over sliding production windows to catch semantic drift before it degrades downstream business logic that consumes the clusters.

Explainability validation. Mathematical cluster structure must translate into verifiable business semantics. If a cluster cannot be described in terms a product team can act on, the model is not operationally useful regardless of its stability score.

Where Unsupervised QE Fails

Silhouette Coefficient and Davies-Bouldin Index assume roughly convex, spherical cluster geometry. Real behavioral data frequently produces non-convex manifolds where both metrics are unreliable: a geometrically clean solution may be semantically incoherent, and a semantically valid segmentation may score poorly because the clusters are elongated or concave. Geometric stability metrics must be paired with qualitative interpretability reviews, not used in isolation.

The second failure mode is circularity: if downstream business logic was designed around the model's initial segmentation, it gradually entrenches that segmentation as "correct" — absorbing drift rather than surfacing it.

Stage 4: NLP and Generative AI — Bounding Non-Deterministic Behavior

NLP spans all three prior stages, and QE inherits a distinct problem from each: classifier metrics and drift monitoring from supervised learning, structural-stability checks from unsupervised topic models, and — the hardest case — behavioral bounding from generative LLMs. This section focuses on the generative case, because that is where conventional assertions break down entirely: with no single correct output, Quality Engineering shifts from asserting answers to bounding behavior.

Conventional test assertions don't port to this domain. "Expected output: X" is undefined when two valid responses to the same prompt look completely different. The testing infrastructure must change accordingly.

Validation Approaches for Generative AI

LLM-as-judge evaluation. Automated evaluation pipelines use a separate model to score responses for factual accuracy, contextual relevance, and instruction adherence. This is the current practical floor for scale — human evaluation doesn't scale to production traffic volumes. For a detailed multi-agent adversarial validation framework, see Objective-Validation Protocols for AI Code. For production observability patterns, see Monitoring Agents with Langfuse.

Hallucination rate monitoring. Where the system generates against a retrieved or provided context, track the proportion of generated claims that cannot be grounded in that context. Note this metric is only defined when a reference context exists — for open-domain generation, "groundedness" must be redefined against an external knowledge source rather than the prompt. Establish a baseline and treat upward drift as a regression.

Temperature and prompt sensitivity testing. Run the same input at multiple inference temperatures and with minor prompt variations. A reliable system should produce outputs within defined semantic bounds regardless of these perturbations.

Security and safety validation. Red-team the system for prompt injection, toxic content generation, and information extraction. For the test-first approach to structuring safety test suites, see TDD in Agentic Workflows. Shift this work left: safety failures are far more expensive to remediate post-deployment.

Component-level testability. Structure LLM calls as pure functions with defined inputs and outputs. Model-as-function patterns make individual LLM calls testable at component level without running full end-to-end pipelines.

Where Generative QE Fails

The LLM-as-judge approach introduces a meta-level problem: a non-deterministic system evaluating a non-deterministic system. The judge itself can hallucinate, drift across model versions, or score inconsistently at different temperatures. A judge calibrated on one model's outputs may be systematically miscalibrated on another's. LLM-as-judge scores should be treated as a signal to investigate, not a final verdict.

The claim that generative AI can be made unconditionally safe through sufficient testing is not supportable. Safety testing reduces the probability of harmful outputs; it cannot eliminate it for an open-ended generative system. Any QE framework that implies complete safety coverage is overstating what current tooling delivers.

How Quality Engineering Evolves Across AI Maturity

AI StageSystem BehaviorQE ApproachBasis of Trust
Rule-Based AIExecutes predefined logicFunctional regression, rule coverageLogic correctness
Supervised LearningPredicts from labeled dataData quality, model metrics, drift monitoringStatistical accuracy
Unsupervised LearningDiscovers hidden structureCluster stability, separation, explainabilityStructural validity
NLP & Generative AIGenerates unconstrained languageBehavioral bounding, LLM-as-judge, red-teamingBounded behavior

The progression across stages is not just a change in tooling — it is a change in what "correct" means. In rule-based systems, correctness is binary. In supervised learning, it is statistical. In unsupervised learning, it is structural and interpretable. In generative AI, it is behavioral: does the output stay within defined bounds across the distribution of inputs?

What Quality Engineering Teams Should Do Differently

The practical implication of this framework is not "add more tests." It is a change in what engineers are responsible for at each stage:

  • Rule-Based AI: Write test matrices that cover unspecified inputs, not just the happy path. Treat rule completeness as an explicit deliverable. Automate regression on every rule change.
  • Supervised Learning: Replace accuracy-as-primary-metric with per-class recall and PR-AUC for imbalanced domains. Document drift monitor thresholds with explicit false-positive cost analysis, not just alerting rules.
  • Unsupervised Learning: Supplement geometric stability metrics with qualitative cluster interpretability reviews. Build feedback loops so that downstream business changes triggered by model output feed back into drift detection.
  • Generative AI: Treat LLM-as-judge as a signal layer, not a verdict layer. Build prompt sensitivity and temperature suites into the evaluation harness from day one. Red-team continuously, not only at release.

Quality Engineering in AI is ultimately an infrastructure problem: the organizations that do it well invest in evaluation pipelines, monitoring dashboards, and feedback loops as first-class engineering artifacts — not as a review step appended to the release cycle.