AI Governance & Security · Deep Dive
Quality gates for AI-generated code
When code appears faster than it can be read, automation decides quality. This deep dive describes the minimum set of blocking checks, sensible thresholds, how to handle exceptions – and why a slow gate is eventually worked around.
- Reading time
- approx. 5 minutes
- Last reviewed
- August 2026
- For
- Tech Leads, QA, DevOps
When code appears faster than it can be read, quality assurance necessarily moves into automation. The question is then no longer whether gates are needed but which ones – and how they stay fast enough that nobody works around them.
1. Why gates decide now
A review that used to work implicitly, because somebody had thought about every line, no longer works the same way with generated code. Human attention is the scarcest resource in the process – it should be reserved for intent, architecture and risk. Everything that can be formalised belongs in the pipeline.
In short
A rule that only exists in the team handbook is not a rule under deadline pressure. A gate is the only kind of agreement that cannot be argued away.
2. The minimum set
These checks should block the merge in every project – regardless of who or what produced the code:
build # compiles / packages, no errors
unit-tests # deterministic, fast, no external services
contract-tests # implementation still matches the published API contract
architecture # module boundaries and dependency rules hold
lint + format # no style discussion inside code review
sast # static application security testing
dependency-scan # known vulnerabilities and license policy
secret-scan # no credentials in the diff
What is notable is how little of this is AI-specific. The list is simply what a solid development process should have anyway – AI turns “should” into “must”.
3. Ordering and runtime
Ordering decides acceptance. Cheap checks that fail often belong at the front, so feedback arrives quickly:
- Seconds: formatting, lint, secret scan, commit convention.
- A few minutes: build, unit tests, architecture and contract tests.
- Before the merge: integration tests, SAST, dependency and licence checks.
- After the merge: end-to-end, load and deep security testing.
As a rule of thumb: feedback on a push within ten minutes. Beyond that, context switching sets in – and with it the pressure to allow exceptions. More on this in the deep dive CI/CD for AI-assisted software development.
4. Test quality instead of coverage
Line coverage is a particularly weak signal for generated code: it is trivial to push up and says little about depth of testing. More meaningful indicators are:
- Where the test cases come from. Derived from the requirement, not from the freshly generated implementation.
- Error and authorisation paths, not only the happy path.
- Boundaries and edge cases – empty, null, maximum, concurrent.
- Mutation testing for critical modules where the effort is justified: it measures whether tests actually notice defects.
A sensible gate rule is therefore not “85% coverage” but: no regression against the target branch, plus mandatory tests for new public interfaces.
5. Security checks
Three checks cover the majority of practically relevant cases:
- Secret scanning on the diff – the cheapest gate with the highest hit rate.
- Static analysis with a rule set tailored to the project. An unconfigured tool produces so many false positives that it gets ignored.
- Dependency checking for known vulnerabilities and licence compatibility.
In addition, it is worth reviewing authorisation logic explicitly – this is where generated code most often falls short.
6. Dependencies and licences
New dependencies are more frequent with generated code than with hand-written code – and not always the established ones. Three rules:
- Only packages from a curated source or an internal mirror.
- A licence allow-list, checked automatically.
- Make new dependencies visible – as their own note in the merge request, not buried in the lockfile diff.
7. Setting thresholds
| Check | Blocks on |
|---|---|
| Secret scan | any hit |
| Tests | any failure; no skipped tests without justification |
| SAST | high and critical severity |
| Dependencies | a known critical vulnerability, a disallowed licence |
| Coverage | a regression against the target branch |
8. Exceptions without a floodgate
There will be exceptions – the question is whether they stay visible. What works:
- A justification in the repository, not in chat.
- An expiry date for every exception, after which the gate applies again.
- Approval by a second person, not by the one submitting.
- Regular review of the active exceptions – a growing list is a signal, not a steady state.
9. Running the gates
Gates are software and age accordingly. Running them means keeping rule sets current, reducing false positives instead of ignoring them, fixing or removing flaky tests, and watching runtime. A gate nobody believes is worse than none – it costs time and still provides no assurance.
Checklist: quality gates
- The minimum set runs and blocks the merge – for all changes alike.
- Feedback arrives in under ten minutes.
- Test cases derive from the requirement, error and authorisation paths are covered.
- SAST is configured for the project – little noise, high credibility.
- New dependencies are visible and checked against source and licence.
- Exceptions carry a justification, an expiry date and an approval.
- Flaky tests are fixed or removed, not simply retried.
Conclusion
Quality gates are the point where AI speed turns into delivered value – or does not. They do not have to be sophisticated: the minimum set, executed quickly and enforced without exception, covers the bulk of it.
The rest is operational discipline: reduce noise, keep runtime short, keep exceptions visible. A gate you have to bypass to hit a deadline will be bypassed – and then it is no longer a gate but a delay.
Sources & further standards
-
NIST SP 800-218 – Secure Software Development Framework (SSDF)
Process-oriented practices for secure development, a useful grid for quality gates. csrc.nist.gov -
OWASP Top 10
Reference for the most common vulnerability classes in web applications. owasp.org -
OWASP Application Security Verification Standard (ASVS)
Verifiable security requirements – usable as a checklist for reviews and gates. owasp.org -
CycloneDX
A widely used SBOM format, covering container images and dependencies among others. cyclonedx.org
This article describes technical and procedural relationships. It replaces neither a regulatory assessment nor legal advice.
Further reading
Related deep dives.
AI Software Engineering
AI in software development: from coding agent to engineering process
The pillar article: what AI delivers and which engineering steps remain.
AI Governance & Security
AI coding governance: how teams use AI in a controlled way
Data classes, review duties, responsibility and technical enforcement.
Platform
How CodamAI implements these steps
MCP integration, explicit backend models, the Hub, OpenAPI and your own CI/CD.
Your AI writes code. CodamAI turns it into engineering.
Explicit backend models, roles and validation rules, visual review in the Hub and delivery through your own pipeline.