{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/marketintell-ai/json-schema/marketintell-ai-agent-execution-envelope-schema.json",
  "title": "AgentExecutionEnvelope",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/marketintell-ai-openapi.json#/components/schemas/AgentExecutionEnvelope",
  "type": "object",
  "required": [
    "contract_version",
    "execution_id",
    "status",
    "session_id",
    "content",
    "disclaimer",
    "timestamp",
    "specialists_used",
    "latency_ms",
    "reasoning_summary",
    "provenance",
    "delivery",
    "recovery"
  ],
  "properties": {
    "contract_version": {
      "type": "string",
      "enum": [
        "1.0"
      ],
      "description": "Version of the transport-neutral agent execution contract."
    },
    "execution_id": {
      "type": "string",
      "description": "Stable correlation id for this execution."
    },
    "status": {
      "type": "string",
      "enum": [
        "completed"
      ]
    },
    "session_id": {
      "type": "string",
      "format": "uuid"
    },
    "content": {
      "type": "string"
    },
    "structured_output": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "disclaimer": {
      "type": "string"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    },
    "intent": {
      "type": "string"
    },
    "specialists_used": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "latency_ms": {
      "type": "number"
    },
    "classification": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "correlation": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "fact_projection": {
      "type": "object",
      "description": "Neutral facts and thesis projection when evidence was requested.",
      "additionalProperties": true
    },
    "degradation": {
      "type": "object",
      "description": "Present when a requested T2/T3 path fell back to T1.",
      "additionalProperties": true
    },
    "reasoning_summary": {
      "type": "object",
      "required": [
        "kind",
        "disclosure",
        "intent",
        "domain",
        "tokens",
        "specialists",
        "quality",
        "evidence",
        "uncertainty"
      ],
      "description": "Safe evidence/decision summary. This is not hidden chain-of-thought and never contains model scratchpads.",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "evidence_summary"
          ]
        },
        "disclosure": {
          "type": "string"
        },
        "intent": {
          "type": [
            "string",
            "null"
          ]
        },
        "domain": {
          "type": [
            "string",
            "null"
          ]
        },
        "tokens": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "timeframe": {
          "type": [
            "string",
            "null"
          ]
        },
        "specialists": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "quality": {
          "type": [
            "object",
            "null"
          ],
          "description": "Bounded reasoning outcome and evidence-coverage metrics; never hidden chain-of-thought or scratchpads.",
          "required": [
            "direction",
            "confidence",
            "verification_score",
            "convergence",
            "fact_count",
            "cited_fact_count",
            "chain_count",
            "tension_count",
            "uncited_number_count"
          ],
          "properties": {
            "direction": {
              "type": "string"
            },
            "confidence": {
              "type": "number",
              "minimum": 0,
              "maximum": 100
            },
            "verification_score": {
              "type": "number",
              "minimum": 0,
              "maximum": 100
            },
            "convergence": {
              "type": "string"
            },
            "fact_count": {
              "type": "integer",
              "minimum": 0
            },
            "cited_fact_count": {
              "type": "integer",
              "minimum": 0
            },
            "chain_count": {
              "type": "integer",
              "minimum": 0
            },
            "tension_count": {
              "type": "integer",
              "minimum": 0
            },
            "uncited_number_count": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "evidence": {
          "type": "object",
          "required": [
            "fact_count",
            "must_cite_fact_ids",
            "facts"
          ],
          "properties": {
            "fact_count": {
              "type": "integer",
              "minimum": 0
            },
            "must_cite_fact_ids": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "facts": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "uncertainty": {
          "type": "object",
          "properties": {
            "alignment": {
              "type": [
                "string",
                "null"
              ]
            },
            "score": {
              "type": [
                "number",
                "null"
              ]
            },
            "confirming": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "contradicting": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "provenance": {
      "type": "object",
      "required": [
        "sources",
        "cited_facts"
      ],
      "properties": {
        "sources": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "cited_facts": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    },
    "delivery": {
      "type": "object",
      "required": [
        "transport",
        "requested_mode",
        "degraded"
      ],
      "properties": {
        "transport": {
          "type": "string",
          "enum": [
            "rest",
            "mcp",
            "a2a",
            "internal"
          ]
        },
        "requested_mode": {
          "type": "string",
          "enum": [
            "auto",
            "deep"
          ]
        },
        "requested_tier": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "t2",
            "t3",
            null
          ]
        },
        "delivered_tier": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "t1",
            "t2",
            "t3",
            null
          ]
        },
        "degraded": {
          "type": "boolean"
        }
      }
    },
    "recovery": {
      "type": [
        "object",
        "null"
      ],
      "description": "Machine-actionable retry guidance when delivery degraded.",
      "additionalProperties": true
    }
  }
}