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 Class | Target Regulatory Standard | Assertion Logic |
|---|---|---|
RegulatoryToneEvaluator | FDA/EMA Style Guide | Programmatically fails any response containing emoticons, emojis, or informal decorative symbols. |
FmeaArithmeticEvaluator | GAMP 5 & ISO 14971 | Formally asserts the mathematical equality $RPN = \text{Severity} \times \text{Occurrence} \times \text{Detection}$. |
CitationFidelityEvaluator | ALCOA+ Principles | Confirms that every cited evidence code (e.g. URS-EBR-001#C2) is authentically present in the retrieved pre-flight context. |
FiveWhysProgressionEvaluator | 21 CFR 211.192 | Verifies that root cause deduction follows a structured, multi-level causal descent with minimum required causal depth (>= 4). |
CsaTestingRigorEvaluator | FDA CSA Guidance | Asserts that software testing rigor assignments correlate directly with patient safety impact and software complexity. |
SlaLatencyEvaluator | System SLA Contract | Asserts that agent execution completes within bounded time limits (e.g. sub-second or < 3.0s). |
HybridRetrievalSpanEvaluator | OpenTelemetry Contract | Inspects 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
# Execute deviation benchmark suitepython -m src.evals.cli --suite deviation --enforce-gate
# Execute CSA risk benchmark suitepython -m src.evals.cli --suite csa --enforce-gate
# Execute traceability benchmark suitepython -m src.evals.cli --suite traceability --enforce-gate
# Execute all suites with minimum aggregate score thresholdpython -m src.evals.cli --suite all --min-score 0.85 --enforce-gatePull 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.