Gates
Gates are verification checkpoints that determine whether agent-generated code meets your quality standards. They unify all verification mechanisms into a consistent interface: static checks, test execution, CI integration, human approval, and loop detection.What Are Gates
Think of gates as quality control stations. Code must pass through each gate before being considered complete. Gates replace the older L0-L3 verification level concept with a more flexible, configurable system. Each gate defines:- What to check: The verification type and configuration
- What to do on failure: Iterate, stop, or escalate
- When to run: Conditions for gate execution
Gate Check Types
AgentGate supports five types of gate checks:- Verification Levels
- GitHub Actions
- Custom Command
- Approval
- Convergence
Run L0-L3 verification checksThe classic verification levels wrapped in a gate:Verification Levels:
| Level | Name | Checks |
|---|---|---|
| L0 | Contracts | Required files, forbidden patterns, schemas |
| L1 | Tests | Test command execution, exit codes |
| L2 | Blackbox | Fixture-based functional testing |
| L3 | Sanity | Structural validation, coverage rules |
Failure Policies
When a gate fails, the failure policy determines what happens next:Action Types
| Action | Behavior | Use Case |
|---|---|---|
iterate | Generate feedback, run another iteration | Most verification failures |
stop | Stop execution immediately | Critical failures, security issues |
escalate | Notify stakeholders, continue | Warnings, partial failures |
Retry Configuration
Feedback Options
Success Policies
Control what happens when a gate passes:| Action | Behavior |
|---|---|
continue | Process next gate in sequence (default) |
skip-remaining | Skip all remaining gates, consider task complete |
Gate Conditions
Control when gates run:Condition Options
| Option | Values | Description |
|---|---|---|
when | always, on-change, manual | When to run the gate |
skipIf | expression | Condition to skip the gate |
Gate Pipeline
Gates execute in sequence as a pipeline:1
Check Condition
Evaluate if the gate should run based on
condition.when and condition.skipIf.2
Execute Check
Run the gate check (verification, CI, custom command, etc.).
3
Collect Results
Gather pass/fail status, failures, and details.
4
Generate Feedback
If failed with
feedback: auto, create structured feedback for the agent.5
Apply Policy
Execute failure or success policy (iterate, stop, continue).
6
Continue Pipeline
If not stopped, proceed to next gate.
Gate Feedback
When gates fail, AgentGate generates structured feedback for the agent:Feedback Format
Common Gate Patterns
Basic Quality Gates
Security-First Gates
Progressive Gates
Human-in-the-Loop
Verification Levels (L0-L3)
For backward compatibility, here’s what each level checks:L0: Contracts
L0: Contracts
Static checks that don’t execute code:
- Required files: Ensure specific files exist
- Forbidden patterns: Block secrets, keys, credentials
- Schema validation: Validate JSON/YAML against schemas
- Naming conventions: Enforce file/folder naming rules
L1: Tests
L1: Tests
Execute test commands:
- Test execution: Run test suites
- Exit code checking: Verify success/failure
- Output capture: Collect stdout/stderr
- Timeout enforcement: Prevent hanging tests
L2: Blackbox
L2: Blackbox
Functional testing with fixtures:
- Fixture-based testing: Run against test data
- Assertions: Check outputs match expectations
- JSON schema validation: Validate API responses
- File comparison: Compare output files
L3: Sanity
L3: Sanity
Structural validation:
- File existence: Verify expected files created
- Test coverage: Ensure minimum coverage
- Pattern matching: Check code structure
- Size limits: Prevent bloated changes
Best Practices
1
Order Gates by Speed
Run fast gates first to get quick feedback:
- L0 (contracts) - seconds
- L1 (tests) - seconds to minutes
- Custom commands - varies
- L2/L3 (blackbox/sanity) - minutes
- GitHub Actions - minutes to hours
2
Use Appropriate Actions
iteratefor recoverable failuresstopfor critical/security issuesescalatefor warnings that need attention
3
Set Retry Limits
Prevent infinite loops by setting
maxAttempts:- Lint/format: 10+ (usually quick fixes)
- Tests: 5-10 (may need logic changes)
- CI: 2-3 (external system, expensive)
4
Provide Context in Feedback
Custom commands should output helpful error messages that guide the agent to fix issues.