REST API
POST /v1/gate-check
Evaluate a set of metrics against all nine quantitative gates.
POST /v1/gate-check
Evaluate a set of enhancement metrics against all nine quantitative gates. Use this to check whether metrics would pass without running the full analysis and enhancement pipeline.
Request
POST /v1/gate-check
Authorization: Bearer uk_afa_...
Content-Type: application/jsonBody
| Field | Type | Required | Description |
|---|---|---|---|
metrics | object | Yes | Enhancement metrics dictionary |
The metrics object must conform to EnhancementMetrics. Key fields:
| Field | Type | Description |
|---|---|---|
baseline_risk | float | Risk score before enhancement |
proposed_risk | float | Risk score after enhancement |
baseline_profit | float | Profit proxy before |
proposed_profit | float | Profit proxy after |
complexity_score | float | Normalized complexity (higher = simpler) |
quality_score | float | Aggregate quality (0.0 to 1.0) |
quality_subscores | list[float] | Individual quality sub-scores |
new_concepts | int | Number of new concepts introduced |
entropy_score | float | Shannon entropy of the diff |
utility_lcb | float | Lower confidence bound of utility |
business_kpi_impact | float | R-squared of KPI model |
slsa_verified | bool | SLSA provenance valid |
{
"metrics": {
"baseline_risk": 0.08,
"proposed_risk": 0.02,
"baseline_profit": 0.85,
"proposed_profit": 0.95,
"complexity_score": 0.75,
"quality_score": 0.82,
"quality_subscores": [0.85, 0.80, 0.75, 0.90],
"new_concepts": 4,
"entropy_score": 0.45,
"utility_lcb": 3.2,
"business_kpi_impact": 0.72,
"slsa_verified": true
}
}Response
{
"gate_results": {
"overall": "PASS",
"gates": {
"complexity": {"status": "PASS", "score": 0.75, "threshold": 0.5},
"risk": {"status": "PASS", "delta": 4.0, "threshold": 2.0},
"profit": {"status": "PASS", "delta": 1.12, "threshold": 2.0},
"novelty": {"status": "PASS", "score": 0.88, "threshold": 0.8},
"quality": {"status": "PASS", "score": 0.82, "threshold": 0.7},
"utility": {"status": "PASS", "lcb": 3.2, "threshold": 1.5},
"entropy": {"status": "PASS", "score": 0.45, "threshold": 0.25},
"supply_chain": {"status": "PASS"},
"kpi": {"status": "PASS", "r2": 0.72, "threshold": 0.6}
}
},
"overall": "PASS",
"recommendation": "All gates pass. Enhancement is safe to commit."
}Hard floor violation
If the complexity score is below 0.5, the gate engine raises a hard floor error:
HTTP/1.1 422 Unprocessable Entity
{
"error": "Hard floor violation",
"detail": "Hard floor violation: complexity_score 0.35 < 0.5"
}This is the only non-overridable gate. No configuration or override can bypass it.
Examples
curl
curl -X POST https://api.afa.undercurrentholdings.com/v1/gate-check \
-H "Authorization: Bearer uk_afa_..." \
-H "Content-Type: application/json" \
-d '{
"metrics": {
"baseline_risk": 0.08,
"proposed_risk": 0.02,
"complexity_score": 0.75,
"quality_score": 0.82,
"quality_subscores": [0.85, 0.80, 0.75, 0.90],
"new_concepts": 4,
"entropy_score": 0.45,
"utility_lcb": 3.2,
"business_kpi_impact": 0.72,
"slsa_verified": true
}
}'Errors
| Status | Cause |
|---|---|
| 400 | Invalid metrics (missing required fields, wrong types) |
| 401 | Missing or invalid API key |
| 422 | Hard floor violation (complexity < 0.5) |
| 429 | Rate limit exceeded |