Skip to content

Continuous Qualification with Pydantic Evals

Overview

In Life Sciences software systems, introducing changes to AI agents or retrieval logic requires continuous qualification. The platform implements an automated continuous evaluation subsystem built on Pydantic Evals (src/evals/).

This framework enforces mathematical accuracy, citation grounding, regulatory tone standards, and OpenTelemetry trace contracts across pull requests and nightly builds.

Specialized GxP Evaluator Suite (src/evals/evaluators.py)

Evaluator ClassTarget Regulatory StandardAssertion Logic
RegulatoryToneEvaluatorFDA/EMA Style GuideProgrammatically fails any response containing emoticons, emojis, or informal decorative symbols.
FmeaArithmeticEvaluatorGAMP 5 & ISO 14971Formally asserts the mathematical equality $RPN = \text{Severity} \times \text{Occurrence} \times \text{Detection}$.
CitationFidelityEvaluatorALCOA+ PrinciplesConfirms that every cited evidence code (e.g. URS-EBR-001#C2) is authentically present in the retrieved pre-flight context.
FiveWhysProgressionEvaluator21 CFR 211.192Verifies that root cause deduction follows a structured, multi-level causal descent with minimum required causal depth (>= 4).
CsaTestingRigorEvaluatorFDA CSA GuidanceAsserts that software testing rigor assignments correlate directly with patient safety impact and software complexity.
SlaLatencyEvaluatorSystem SLA ContractAsserts that agent execution completes within bounded time limits (e.g. sub-second or < 3.0s).
HybridRetrievalSpanEvaluatorOpenTelemetry ContractInspects OpenTelemetry span traces (SpanTree, HasMatchingSpan) to verify that required retrieval operations were executed.

Golden Benchmark Datasets (src/evals/datasets.py)

The evaluation runner tests agents against standardized test suites:

  • DEVIATION_GOLDEN_DATASET: 10 complex pharmaceutical manufacturing deviation scenarios with known ground truth root causes.
  • CSA_GOLDEN_DATASET: Regulated computerized system features requiring CSA critical thinking assessment and testing rigor assignment.
  • TRACEABILITY_GOLDEN_DATASET: Complex multi-tier requirements specifications with known orphaned and unverified items.

Command Line Execution

Terminal window
# Execute deviation benchmark suite
python -m src.evals.cli --suite deviation --enforce-gate
# Execute CSA risk benchmark suite
python -m src.evals.cli --suite csa --enforce-gate
# Execute traceability benchmark suite
python -m src.evals.cli --suite traceability --enforce-gate
# Execute all suites with minimum aggregate score threshold
python -m src.evals.cli --suite all --min-score 0.85 --enforce-gate

Pull Request CI/CD Gate

In the continuous integration pipeline, assert_evaluation_gate() enforces that any pull request that reduces evaluation benchmark scores or fails deterministic regulatory evaluators is blocked from merging.