Skip to content
topicPhase: VerifyQuality

QA & AI Guardrails — Automated Quality Only ​


title: QA & AI Guardrails description: Automated quality assurance and guardrails for AI-augmented development and CI. ​

Quality assurance is fully automated for test execution. Humans review test design in PRs and accept staging behavior — see GOVERNANCE.md.

Reference template — no production code in this repo.
Decision guides: Automated testing & QA · Linters & static analysis · AI guardrails · Identity, access & secrets
Procedures to adapt: SOP-005 · SOP-008


Quality Model ​


Static analysis & linters (classic validators) ​

Tests verify behavior; linters and static analyzers verify shape, style, types, and known-bad patterns. Both are required — especially with AI-generated code.

Full tool comparison, CI placement, and pitfalls: Guide: Linters & static analysis

CategoryExamplesRun when
LintersESLint, Ruff, golangci-lintpre-commit + CI
FormattersPrettier, Black, Ruff formatpre-commit + CI
Type checkerstsc, mypy, pyrightpre-commit + CI
SASTSemgrep, CodeQL, BanditCI
SCADependabot, Snyk, InspectorCI on lockfile changes
Secret scangitleaks, GitGuardianpre-commit + CI
IaC scanCheckov, CDK Nag, ConftestCI on IaC changes
Container scanTrivy, ECR scanCI build + deploy
Spec lintSpectralCI on OpenAPI changes

AI PR review does not replace these checks — it stacks on top (static-analysis-linting.md).


Automated Test Pyramid ​

All layers run in CI. No manual test execution.

LayerScopeToolsWhen
UnitFunctions, classespytest, jest, go testEvery PR
ContractAPI vs OpenAPIPact, Schemathesis, DreddEvery PR
IntegrationDB, queues, AWSTestcontainers, LocalStackEvery PR
E2EUser journeysPlaywright, Cypress (headless)PR + nightly
MutationTest effectivenessStryker, mutmut, cargo-mutantsNightly / release
Property-basedEdge casesHypothesis, fast-check, QuickCheckCritical domains
PerformanceLatency budgetsk6, ArtilleryRelease branch
ChaosResilienceAWS FIS, LitmusScheduled

AI Test Enrichment ​

AI test generation rules ​

  1. Generate tests from spec, not from implementation (avoids testing the bug)
  2. Include negative cases: invalid input, auth failure, timeout
  3. Tag tests with OpenAPI operation ID for traceability
  4. Human reviewer spot-checks AI-generated tests in PR (not manual execution)
  5. Mutation score threshold gates merge on critical services (e.g., > 80%)

AI Guardrails (Pre-Merge) ​

Guardrail categories ​

CategoryExamplesBlock merge on
SecretsAWS keys, tokens in diffAny finding
SASTSQL injection, SSRF patternsHigh/Critical
SCAKnown CVE in dependenciesCritical (configurable)
ContainerOS package CVEsCritical
PolicyPublic S3 bucket, open SGAny violation
AI reviewLogic errors, missing error handlingTeam policy (warn or block)
LicenseGPL in proprietary bundlePolicy violation

Policy as Code ​

Store policies in policy/ and evaluate in CI with OPA or Cedar:

rego
# Example: deny public RDS
deny[msg] {
    input.resource_type == "aws_db_instance"
    input.publicly_accessible == true
    msg := "RDS instances must not be publicly accessible (ADR-0012)"
}

Link policies to ADRs in deny messages so developers understand the why.


No manual test execution ​

Manual QA scripts and regression checklists are replaced by CI and synthetics. Humans still:

  • Review AI-generated test quality in PRs (meta-review, not execution)
  • Accept product behavior on staging via demo + green synthetics (SOP-006)
  • Triage production alerts (SOP-007)
RemovedReplaced by
Manual test passE2E + synthetic canaries
Exploratory testing sprintProperty-based + mutation testing
Manual regression checklistFull CI suite on every PR
UAT meetingPO staging sign-off
Per-release manual security reviewSAST/SCA/DAST in pipeline

Quality Gates by Service Tier ​

TierExampleMutation thresholdManual prod approvalChaos frequency
Tier 1Payments, auth85%RequiredWeekly
Tier 2Core business APIs75%Automatic canaryMonthly
Tier 3Internal tools60%AutomaticQuarterly

Metrics ​

MetricTarget
CI pass rate (main)> 95%
Mean time to fix broken main< 2 hours
Mutation score (Tier 1)> 85%
Contract test coverage of OpenAPI ops100%
Critical CVE in prod0
Escaped defects (prod bugs without prior alert)Trending down

Reference template only — no production code. Adapt in your own project.