{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agoragentic.com/schema/finance-agent-external-gate-bundle.v1.json",
  "title": "Finance Agent External Gate Bundle V1",
  "description": "Redacted bundle contract for the external Version C finance-agent hard gates: owner-authenticated Robinhood MCP schema proof, owner/legal/commercial/compliance approval, and brokerage-options owner/compliance/legal review evidence. This bundle is evidence packaging only. It does not run probes, collect credentials, dispatch providers, approve live actions, enable options execution, mutate wallet/x402 state, call execute/invoke, publish listings, or publish capabilities.",
  "type": "object",
  "required": [
    "schema",
    "schema_ref",
    "deployment_id",
    "owner_id",
    "bundle_state",
    "read_only",
    "no_live_action_assertion",
    "required_external_gates",
    "evidence_schema_refs",
    "record_routes",
    "gate_evidence",
    "live_authority",
    "redaction_summary"
  ],
  "properties": {
    "schema": {
      "type": "string",
      "const": "agoragentic.agent-os.finance-agent-external-gate-bundle.v1"
    },
    "schema_ref": {
      "type": "string",
      "const": "/schema/finance-agent-external-gate-bundle.v1.json"
    },
    "deployment_id": { "type": "string", "minLength": 1 },
    "owner_id": { "type": "string", "minLength": 1 },
    "bundle_state": {
      "type": "string",
      "enum": [
        "blocked_missing_external_evidence",
        "draft_redacted_refs_only",
        "ready_for_owner_review",
        "submitted_redacted_refs_only"
      ]
    },
    "read_only": { "type": "boolean", "const": true },
    "no_live_action_assertion": { "type": "boolean", "const": true },
    "required_external_gates": {
      "type": "array",
      "minItems": 3,
      "items": {
        "type": "string",
        "enum": [
          "real_owner_authenticated_robinhood_trading_mcp_schema_probe",
          "real_owner_authenticated_robinhood_banking_mcp_schema_probe",
          "real_owner_legal_commercial_compliance_review",
          "real_brokerage_options_approval_review"
        ]
      }
    },
    "evidence_schema_refs": {
      "type": "object",
      "required": [
        "mcp_schema_proof",
        "compliance_approval",
        "options_review_packet",
        "readiness_requirements",
        "version_c_gate_matrix"
      ],
      "properties": {
        "mcp_schema_proof": { "type": "string", "const": "/schema/finance-agent-mcp-schema-proof.v1.json" },
        "compliance_approval": { "type": "string", "const": "/schema/finance-agent-compliance-approval.v1.json" },
        "options_review_packet": { "type": "string", "const": "/schema/finance-agent-options-review-packet.v1.json" },
        "readiness_requirements": { "type": "string", "const": "/schema/finance-agent-readiness-requirements.v1.json" },
        "version_c_gate_matrix": { "type": "string", "const": "/schema/finance-agent-version-c-gate-matrix.v1.json" }
      },
      "additionalProperties": true
    },
    "record_routes": {
      "type": "object",
      "required": [
        "mcp_schema_proofs",
        "compliance_approvals",
        "readiness_requirements"
      ],
      "properties": {
        "mcp_schema_proofs": {
          "type": "string",
          "const": "/api/agent-os/finance/deployments/{deployment_id}/mcp-schema-proofs"
        },
        "compliance_approvals": {
          "type": "string",
          "const": "/api/agent-os/finance/deployments/{deployment_id}/compliance-approvals"
        },
        "readiness_requirements": {
          "type": "string",
          "const": "/api/agent-os/finance/deployments/{deployment_id}/readiness-requirements"
        }
      },
      "additionalProperties": true
    },
    "gate_evidence": {
      "type": "object",
      "required": [
        "trading_mcp_schema_proof",
        "banking_mcp_schema_proof",
        "approved_trading_compliance_approval",
        "approved_card_compliance_approval",
        "options_review_compliance_approval"
      ],
      "properties": {
        "trading_mcp_schema_proof": { "$ref": "#/$defs/gate_ref_summary" },
        "banking_mcp_schema_proof": { "$ref": "#/$defs/gate_ref_summary" },
        "approved_trading_compliance_approval": { "$ref": "#/$defs/gate_ref_summary" },
        "approved_card_compliance_approval": { "$ref": "#/$defs/gate_ref_summary" },
        "options_review_compliance_approval": { "$ref": "#/$defs/gate_ref_summary" }
      },
      "additionalProperties": false
    },
    "live_authority": { "$ref": "#/$defs/live_authority" },
    "redaction_summary": { "$ref": "#/$defs/redaction_summary" }
  },
  "not": {
    "anyOf": [
      { "required": ["raw_schema"] },
      { "required": ["schema_payload"] },
      { "required": ["raw_payload"] },
      { "required": ["raw_approval"] },
      { "required": ["raw_review"] },
      { "required": ["account_values"] },
      { "required": ["card_values"] },
      { "required": ["order_values"] },
      { "required": ["payment_values"] },
      { "required": ["wallet_values"] },
      { "required": ["auth_token"] },
      { "required": ["access_token"] },
      { "required": ["refresh_token"] }
    ]
  },
  "additionalProperties": true,
  "$defs": {
    "gate_ref_summary": {
      "type": "object",
      "required": [
        "gate",
        "status",
        "schema_ref",
        "route_can_run_probe",
        "route_can_collect_credentials",
        "route_can_dispatch_provider",
        "route_can_approve_live_actions",
        "route_can_enable_options_execution"
      ],
      "properties": {
        "gate": {
          "type": "string",
          "enum": [
            "owner_authenticated_robinhood_mcp_schema_probe",
            "finance_agent_owner_legal_commercial_approval",
            "finance_agent_options_review_approval"
          ]
        },
        "status": {
          "type": "string",
          "enum": ["missing", "verified", "failed", "archived"]
        },
        "schema_ref": {
          "type": "string",
          "enum": [
            "/schema/finance-agent-mcp-schema-proof.v1.json",
            "/schema/finance-agent-compliance-approval.v1.json"
          ]
        },
        "proof_id": { "type": ["string", "null"], "maxLength": 256 },
        "approval_id": { "type": ["string", "null"], "maxLength": 256 },
        "evidence_ref": { "$ref": "#/$defs/bounded_ref" },
        "evidence_hash": { "$ref": "#/$defs/bounded_ref" },
        "route_can_run_probe": { "type": "boolean", "const": false },
        "route_can_collect_credentials": { "type": "boolean", "const": false },
        "route_can_dispatch_provider": { "type": "boolean", "const": false },
        "route_can_approve_live_actions": { "type": "boolean", "const": false },
        "route_can_enable_options_execution": { "type": "boolean", "const": false }
      },
      "not": {
        "anyOf": [
          { "required": ["raw_schema"] },
          { "required": ["raw_payload"] },
          { "required": ["raw_approval"] },
          { "required": ["account_values"] },
          { "required": ["card_values"] },
          { "required": ["order_values"] },
          { "required": ["auth_token"] },
          { "required": ["access_token"] },
          { "required": ["refresh_token"] }
        ]
      },
      "additionalProperties": true
    },
    "live_authority": {
      "type": "object",
      "required": [
        "robinhood_provider_dispatch",
        "external_provider_call",
        "order_placement",
        "order_cancellation",
        "card_detail_fetch",
        "card_purchase",
        "options_execution",
        "wallet_mutation",
        "x402_settlement",
        "public_execute_mutation",
        "global_execute_mutation",
        "global_invoke_mutation",
        "marketplace_publication",
        "capability_publication"
      ],
      "properties": {
        "robinhood_provider_dispatch": { "type": "boolean", "const": false },
        "external_provider_call": { "type": "boolean", "const": false },
        "order_placement": { "type": "boolean", "const": false },
        "order_cancellation": { "type": "boolean", "const": false },
        "card_detail_fetch": { "type": "boolean", "const": false },
        "card_purchase": { "type": "boolean", "const": false },
        "options_execution": { "type": "boolean", "const": false },
        "wallet_mutation": { "type": "boolean", "const": false },
        "x402_settlement": { "type": "boolean", "const": false },
        "public_execute_mutation": { "type": "boolean", "const": false },
        "global_execute_mutation": { "type": "boolean", "const": false },
        "global_invoke_mutation": { "type": "boolean", "const": false },
        "marketplace_publication": { "type": "boolean", "const": false },
        "capability_publication": { "type": "boolean", "const": false }
      },
      "additionalProperties": false
    },
    "redaction_summary": {
      "type": "object",
      "required": [
        "raw_schema_excluded",
        "raw_private_values_excluded",
        "raw_account_values_excluded",
        "raw_card_values_excluded",
        "raw_order_values_excluded",
        "raw_payment_values_excluded",
        "raw_wallet_values_excluded",
        "provider_credentials_excluded",
        "private_ecf_excluded",
        "secrets_excluded"
      ],
      "properties": {
        "raw_schema_excluded": { "type": "boolean", "const": true },
        "raw_private_values_excluded": { "type": "boolean", "const": true },
        "raw_account_values_excluded": { "type": "boolean", "const": true },
        "raw_card_values_excluded": { "type": "boolean", "const": true },
        "raw_order_values_excluded": { "type": "boolean", "const": true },
        "raw_payment_values_excluded": { "type": "boolean", "const": true },
        "raw_wallet_values_excluded": { "type": "boolean", "const": true },
        "provider_credentials_excluded": { "type": "boolean", "const": true },
        "private_ecf_excluded": { "type": "boolean", "const": true },
        "secrets_excluded": { "type": "boolean", "const": true }
      },
      "additionalProperties": true
    },
    "bounded_ref": {
      "anyOf": [
        { "type": "null" },
        { "$ref": "#/$defs/redacted_ref" }
      ]
    },
    "redacted_ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256,
      "not": {
        "anyOf": [
          { "pattern": "^[a-z][a-z0-9+.-]*://" },
          { "pattern": "^data:" },
          { "pattern": "^[\\[{]" },
          { "pattern": "[\\r\\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