🛡️ Gate Pipeline
DISPATCH GATE SEQUENCE
Is the target gateway online? Blocks if offline. Warns if degraded.
Is the agent dispatchable? Blocks if paused, terminated, or in error.
Within concurrent step limit? Skipped for delegated runs.
Exceeded dispatch rate limit? Sliding window check.
Monthly budget exhausted? Role-derived or agent-level ceiling.
All budget envelopes within limits? Global, gateway, agent scopes.
Agent trust meets gateway minimum? Default trust level 1.
Source class, freshness, and environment eligibility checks.
Evaluate conditions against agent, gateway, run, and role fields.
Approval needed by policy? Check for existing approval grant.
Pass all 10 gates = Allow | Any gate blocks = Block | Gate 10 hold = Hold for approval
🔍 Gate Details
1. Gateway Health
Verifies that the target gateway is operational before attempting dispatch.| Outcome | Condition |
|---|---|
| Pass | Gateway status is healthy or degraded |
| Block | Gateway status is offline |
| Skip | Never skipped — always evaluated first |
- Error Code:
gateway_unreachable - Retryable: No. An offline gateway requires infrastructure intervention.
- Degraded Behavior: A
degradedgateway logs a warning but allows dispatch. This lets operations continue during partial outages while maintaining visibility.
gateway_unreachable before evaluating any other gates.2. Agent Status
Checks the agent’s lifecycle status to ensure it is in a dispatchable state.| Outcome | Condition |
|---|---|
| Pass | Agent status is idle, running, or any status other than paused/terminated/error |
| Block | Agent status is paused, terminated, or error |
| Skip | Agent document not found (all remaining gates are also skipped) |
- Error Code:
agent_unavailable - Retryable: Only when the agent is
paused— a human can unpause it. Terminated and error states require manual intervention.
3. Concurrency
Enforces the maximum number of concurrent steps an agent can execute simultaneously.| Outcome | Condition |
|---|---|
| Pass | Running step count below max concurrent limit |
| Block | Running step count at or above max concurrent limit |
| Skip | Dispatch type is delegated_run (delegated runs manage sub-step concurrency independently) |
- Error Code:
agent_busy - Retryable: Yes. Running steps will eventually complete, freeing capacity.
- Limit Resolution: The effective limit comes from the agent’s resolved authority bounds (role-derived), falling back to
maxConcurrentStepson the agent definition, defaulting to1.
4. Rate Limit
Enforces per-agent dispatch rate limits using a sliding window mechanism.| Outcome | Condition |
|---|---|
| Pass | Agent is within its rate limit window |
| Block | Agent has exceeded the allowed dispatch rate |
- Error Code:
RATE_LIMITEDorrate_limit_exceeded - Retryable: Yes. Rate limit windows are time-based and will naturally reset.
- Pre-check: A token-based rate limit pre-check runs before the full pipeline. If the agent’s LLM rate limit window is exceeded, the pipeline short-circuits immediately.
5. Agent Budget
Checks whether the agent has exhausted its monthly spend ceiling.| Outcome | Condition |
|---|---|
| Pass | Agent’s spent cents below budget limit, or no budget is configured |
| Block | Agent’s spent cents at or above budget limit |
- Error Code:
budget_exceededorbudget_insufficient - Retryable: No. Budget limits require an operator to increase the ceiling or wait for period reset.
- Delegated Run Behavior: For delegated runs with
maxCostCentsguardrails, the gate also checks whether the agent’s remaining budget can cover the run ceiling. This prevents launching runs that would inevitably exceed the budget mid-execution.
6. Envelope Budgets
Checks all applicable budget envelopes from thebudgets table. Multiple envelopes may apply to a single dispatch (global + gateway-scoped + agent-scoped), and the tightest constraint wins.
| Outcome | Condition |
|---|---|
| Pass | All applicable envelopes have remaining budget |
| Block | Any single envelope is exhausted |
- Error Code:
budget_exceeded - Retryable: No.
- Message Format: Includes the scope, period, and spend ratio (e.g.,
agent:agent-123 daily budget exhausted (500/500 cents)).
7. Trust Level
Verifies that the agent’s trust level meets the minimum required by the target gateway.| Outcome | Condition |
|---|---|
| Pass | Agent trust level at or above gateway minimum, or gateway has no minimum set |
| Block | Agent trust level below gateway minimum |
- Error Code:
trust_level_insufficient - Retryable: No. Trust levels are configured by operators.
- Defaults: Agents default to trust level
1(most restrictive) when no trust level is explicitly set. Gateways with nominTrustLevelallow all agents.
8. Context Trust
Validates that the dispatch context provenance meets the requirements defined by the agent’s assigned role.| Outcome | Condition |
|---|---|
| Pass | No role trust config, or context meets all requirements |
| Block | Source class not accepted, context is stale, or environment not eligible |
| Skip | No role assigned to the agent (permissive default) |
Source Class Acceptance
Source Class Acceptance
internal_verified). If the dispatch context’s source class is not in the accepted list, the gate blocks.- Error Code:
context_source_rejected - Retryable: No.
Freshness Requirements
Freshness Requirements
requireFreshness: true), the gate checks:-
Context freshness must not be
staleorunknown -
If
collectedAtis available, the context age must be within the role’smaxFreshnessMinutes(default: 30 minutes) -
Error Code:
context_freshness_blocked - Retryable: Yes. Context can be refreshed.
Environment Eligibility
Environment Eligibility
- Error Code:
environment_not_eligible - Retryable: No.
9. Policy Rules
Evaluates all enabled declarative policies scoped to the target gateway. Policies are evaluated by category (trust_boundary, budget, run_creation) and matched against the dispatch context.
| Outcome | Condition |
|---|---|
| Pass | No matching policies, or matched policies are warn/log only |
| Block | A policy with action: block and enforcement: hard matches |
- Error Code:
policy_blocked - Retryable: No. Policy conditions are deterministic.
- See Policies for full details on the policy engine.
10. Approval Required
Determines whether human approval is required and whether one has already been granted.| Outcome | Condition |
|---|---|
| Pass | No approval required, or an existing approval has been granted |
| Hold | Approval required by policy but no approval exists yet |
- Error Code:
approval_required - Retryable: No. Requires human action.
- Disposition: This gate produces a
holddisposition (notblock), which pauses execution and creates an approval request. See Approvals for the full approval lifecycle.
🔄 Dispatch-Level Retries
When a gate returns a retryable block (concurrency or rate limit), the dispatch layer retries the full governance evaluation up to 3 times with exponential backoff:| Attempt | Delay |
|---|---|
| 1 | 1 second |
| 2 | 2 seconds |
| 3 | 4 seconds |
🎯 Action Type Variations
The governance engine supports three action types, each with slightly different gate behavior:- Step Dispatch
- Delegated Run Dispatch
- Workflow Run Launch
- Concurrency gate is active — enforces per-agent step limits
- Agent budget checks monthly ceiling against
spentMonthlyCents - All policy categories are evaluated
🔒 Edge Agent Governance
Convex-native agents (Factory Manager, Task Manager, Copilot) that run inside Convex rather than through an external gateway use a variant of the governance pipeline:- When no real gateway is provided, a synthetic healthy gateway is used so the gateway health gate passes trivially
- Gateway-scoped policies are skipped (no real gateway to scope against)
- Budget, concurrency, agent lifecycle, role trust, and context provenance gates run unchanged
- Rate limit pre-checks still apply
🏗️ Gate Architecture
All gate functions inconvex/lib/gates.ts are pure functions — they take pre-fetched context and return a result with no side effects or database access. This design provides:
- Testability: Every gate can be unit tested with synthetic inputs
- Composability: Gates can be combined into different sequences for different action types
- Performance: No database queries during gate evaluation (all data is pre-fetched)
In Burgundy: Gate failures appear in the run detail timeline with error codes, retry status, and unblock hints.

