{
  "spec_id": "cain-38.0-economic-action-spec",
  "generated_at": "2026-09-18T00:46:00Z",
  "implementation": "platform-gateway/cain_economic_action_38.py",
  "intent_schema": {
    "agent_id": "str", "tenant": "str", "counterparty": "str", "purpose": "str",
    "amount_cents": "int", "budget_id": "Optional[str]", "delegation_token": "Optional[CryptographicDelegationToken]",
    "currency": "str (default USD)", "conditions": "Dict[str, Any] (Phase 18 ALLOW-IF: max_price_cents, max_risk, allowed_counterparties)",
    "idempotency_key": "Optional[str]", "intent_id": "auto-generated"
  },
  "pipeline_stages_in_order": [
    "IDENTITY (agent_identity_attestation.get_attestation, must exist and not be REVOKED)",
    "DELEGATION (DelegationSecurityValidator.validate_delegation, action+resource+tenant+expiration+depth+SPEND CAP)",
    "POLICY_CONDITIONS (evaluate_conditions -- Phase 18 conditional/ALLOW-IF authorization)",
    "RISK_BLAST_RADIUS (economic_blast_radius -- Phase 17, amount-tiered required_authorization_strength vs caller-supplied risk_score)",
    "BUDGET_RESERVE (cain_budget.BudgetEngine.reserve -- real SQLite atomic reservation)",
    "AUTHORIZATION (mint authorization_id only after every prior gate passed)",
    "CONSENSUS (optional -- pbft_submit_fn hook; SKIPPED and labeled as such when not wired, never silently claimed)",
    "EXECUTION (SimulatedPaymentAdapter ONLY -- no real payment provider)",
    "BUDGET_COMMIT (converts the reservation to a spent transaction)",
    "OUTCOME (OUTCOME_VERIFIED only if the simulated settlement itself reports success; OUTCOME_UNVERIFIED otherwise)"
  ],
  "denial_is_fail_closed": "Any stage returning false immediately returns DENY with the specific reason and the full pipeline trace up to that point -- no stage is skipped silently on the ALLOW path, and no later stage runs after a DENY.",
  "what_this_is_not": [
    "NOT a payment processor -- SimulatedPaymentAdapter makes no network calls and moves no real value",
    "NOT autonomous trading -- one EconomicIntent produces exactly one authorize-or-deny decision; no loop, no repeated unattended execution, no market-making",
    "NOT unrestricted agent financial authority -- every action requires a presented delegation token with an enforced spend cap (this session's fix) AND a real budget reservation; absence of either is an automatic DENY"
  ],
  "known_gaps": [
    "No real counterparty identity verification (allowlist string match only, if conditions.allowed_counterparties is set at all)",
    "No settlement-outcome verification beyond the simulated adapter's own self-report (no independent, third-party outcome check)",
    "CONSENSUS step is optional and untested against the live PBFT cluster in the default pytest suite (see CAIN_38_LIMITATIONS.md for the one manual live run that WAS performed)",
    "Delegation token forgery is not actually preventable in the current wiring -- see CAIN_38_DELEGATION_SPEC.json"
  ]
}
