Gate4 Risk Policy Controls
Objective
Define a machine-readable risk policy contract and enforce it before execution side effects, then halt runtime execution on drawdown breaches.
Schema Contract
Schema artifact:
/contracts/schemas/risk-policy.v1.schema.json
Required top-level fields:
versionmodelimitskillSwitchactionsOnBreach
Validation Boundaries
- Only schema version
risk-policy.v1is accepted in this wave. - Unknown versions fail validation.
- Invalid enums, malformed limits, and incompatible notional bounds fail validation.
- Policy validation is deterministic and backed by contract tests.
Active Pre-Trade Enforcement (AG-RISK-02)
Pre-trade checks are mandatory gates before side effects:
- Deployment creation is blocked when policy limits would be exceeded.
- Order placement is blocked on max-position/max-notional breaches.
- Volatility forecasts adjust deployment/order sizing limits through deterministic multipliers.
- Triggered kill-switch blocks deployment/order side effects.
- Invalid or unsupported policy fails closed (no side effects).
Active Drawdown Kill-Switch Runtime Handling (AG-RISK-03)
Runtime drawdown checks are enforced during deployment status refresh:
latestPnlis evaluated against deployment capital andlimits.maxDrawdownPct.- Breach sets
killSwitch.triggered=truewith timestamp and breach reason. - Active deployments are sent to adapter stop flow immediately after breach detection.
- Once triggered, pre-trade side-effecting commands remain blocked.
Active Risk Audit Trail (AG-RISK-04)
Risk decisions now persist to runtime audit storage for both allow and block outcomes:
- Pre-trade deployment and order checks record
approved/blockeddecisions. - Runtime drawdown checks record approval decisions and breach-triggered blocks.
- Records include request identity (
request_id,tenant_id,user_id), policy version/mode, and outcome code. - Invalid policy/version paths fail closed and emit blocked audit records.
Risk Control Point Matrix
| Control Point | Behavior | Side-Effect Policy |
|---|---|---|
| Deployment pre-trade check | Validate notional bounds + kill-switch state + volatility-adjusted sizing | Block on breach (422/423) before adapter call |
| Order pre-trade check | Validate symbol/portfolio notional, daily loss, reference price, volatility-adjusted sizing | Block on breach (422/423) before adapter call |
| Runtime drawdown monitor | Evaluate latestPnl vs drawdown limit | Trigger kill-switch and halt deployment path |
| Policy validation | Enforce schema/version compatibility | Fail closed on invalid policy (500) |
Risk Decision and Audit Evidence Model
Audit entries capture deterministic decision metadata:
| Field | Description |
|---|---|
decision | approved or blocked |
check_type | Risk control category (pretrade_deployment, pretrade_order, runtime_drawdown) |
request_id / tenant_id / user_id | Identity and correlation |
policy_version / policy_mode | Evaluated policy context |
outcome_code | Deterministic failure/signal code (RISK_LIMIT_BREACH, RISK_KILL_SWITCH_ACTIVE, etc.) |
reason | Human-readable rationale |
metadata | Structured context (notional, drawdown, symbol, deployment references) |
Volatility metadata keys (ML-03):
volatilityForecastPctvolatilityForecastConfidencevolatilitySizingMultipliervolatilityForecastSourcevolatilityFallbackReasonvolatilityFallbackUsed
Gate4 Scope Boundary
- AG-RISK-01 schema + validator, AG-RISK-02 pre-trade enforcement, AG-RISK-03 drawdown kill-switch handling, and AG-RISK-04 risk audit trail are active.
Migration Notes
- All new side-effecting execution paths must call risk gates before command dispatch.
- Runtime additions should extend risk audit coverage rather than introducing non-audited checks.
- Policy schema changes must be versioned and validated before rollout.
Traceability
- Schema:
/contracts/schemas/risk-policy.v1.schema.json - Runtime validator:
/backend/src/platform_api/services/risk_policy.py - Pre-trade gate runtime:
/backend/src/platform_api/services/risk_pretrade_service.py - Drawdown kill-switch runtime:
/backend/src/platform_api/services/risk_killswitch_service.py - Risk audit runtime:
/backend/src/platform_api/services/risk_audit_service.py - Contract tests:
/backend/tests/contracts/test_risk_policy_schema.py/backend/tests/contracts/test_risk_pretrade_checks.py/backend/tests/contracts/test_risk_killswitch_drawdown.py/backend/tests/contracts/test_risk_audit_trail.py
- Interface definition:
/docs/architecture/INTERFACES.md - Related epics/issues:
#77,#138,#106