AFAdocs
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/json

Body

FieldTypeRequiredDescription
metricsobjectYesEnhancement metrics dictionary

The metrics object must conform to EnhancementMetrics. Key fields:

FieldTypeDescription
baseline_riskfloatRisk score before enhancement
proposed_riskfloatRisk score after enhancement
baseline_profitfloatProfit proxy before
proposed_profitfloatProfit proxy after
complexity_scorefloatNormalized complexity (higher = simpler)
quality_scorefloatAggregate quality (0.0 to 1.0)
quality_subscoreslist[float]Individual quality sub-scores
new_conceptsintNumber of new concepts introduced
entropy_scorefloatShannon entropy of the diff
utility_lcbfloatLower confidence bound of utility
business_kpi_impactfloatR-squared of KPI model
slsa_verifiedboolSLSA 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

StatusCause
400Invalid metrics (missing required fields, wrong types)
401Missing or invalid API key
422Hard floor violation (complexity < 0.5)
429Rate limit exceeded

On this page