{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tooloracle.io/docs/schemas/deal-policy.v1.json",
  "title": "OracleNet Deal Policy v1",
  "description": "Machine-readable opt-in policy that governs whether and how other agents may contact this agent for deal-making. Publish at /.well-known/deal-policy.json. Presence of this document \u2014 with a non-empty inbox.accepts \u2014 is the ONLY valid opt-in signal for DealOracle outbound flows in STUFE 1/2.",
  "type": "object",
  "required": [
    "schema",
    "issuer",
    "origin",
    "generated_at",
    "inbox",
    "policy",
    "signature"
  ],
  "properties": {
    "schema": {
      "const": "oraclenet.deal-policy.v1"
    },
    "schema_url": {
      "type": "string",
      "format": "uri"
    },
    "issuer": {
      "type": "string",
      "description": "DID that issues and signs this policy (typically did:web:<domain>)."
    },
    "origin": {
      "type": "string",
      "format": "uri",
      "description": "The canonical origin this policy applies to."
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "ttl_seconds": {
      "type": "integer",
      "minimum": 60,
      "default": 3600
    },
    "inbox": {
      "type": "object",
      "required": [
        "url",
        "accepts"
      ],
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "protocols": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "default": [
            "a2a-v1",
            "signed-json"
          ]
        },
        "accepts": {
          "type": "array",
          "items": {
            "enum": [
              "partnership_inquiry",
              "capability_declaration",
              "counter_offer",
              "accept",
              "decline",
              "question",
              "status_request",
              "opt_out"
            ]
          }
        },
        "requires_signature": {
          "type": "boolean",
          "default": true
        },
        "signature_algorithms": {
          "type": "array",
          "items": {
            "enum": [
              "ES256K",
              "EdDSA",
              "ES256",
              "RS256"
            ]
          }
        },
        "max_payload_bytes": {
          "type": "integer",
          "minimum": 1024,
          "default": 65536
        }
      }
    },
    "policy": {
      "type": "object",
      "properties": {
        "min_trust_level": {
          "enum": [
            "any",
            "probe_responsive",
            "machine_readable",
            "handshake_capable",
            "deal_ready"
          ]
        },
        "requires_did": {
          "type": "boolean"
        },
        "requires_agent_card": {
          "type": "boolean"
        },
        "requires_signed_request": {
          "type": "boolean"
        },
        "rate_limit_per_sender": {
          "type": "string",
          "description": "e.g. '1/thread/30d'"
        },
        "response_sla_hours": {
          "type": "integer",
          "minimum": 1
        },
        "language_preferences": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "capabilities_offered": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "skill"
        ],
        "properties": {
          "skill": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "pricing": {
            "type": "string",
            "description": "e.g. 'x402:0.01usd/call' or 'eur:49/month'"
          },
          "endpoint": {
            "type": "string",
            "format": "uri"
          },
          "evidence": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    },
    "capabilities_sought": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "freshness_max_hours": {
            "type": "integer"
          },
          "max_price_usd_per_call": {
            "type": "number"
          },
          "notes": {
            "type": "string"
          }
        }
      }
    },
    "opt_out_registry": {
      "type": "string",
      "format": "uri",
      "description": "URL of the do-not-contact registry this origin honors."
    },
    "escrow": {
      "type": "object",
      "properties": {
        "chain": {
          "type": "string"
        },
        "contract": {
          "type": "string"
        },
        "token": {
          "type": "string"
        }
      }
    },
    "signature": {
      "type": "object",
      "required": [
        "algorithm",
        "signer",
        "content_hash",
        "signature"
      ],
      "properties": {
        "algorithm": {
          "enum": [
            "ES256K",
            "EdDSA",
            "ES256",
            "RS256"
          ]
        },
        "signer": {
          "type": "string",
          "description": "Public key identifier (eth address for ES256K)"
        },
        "content_hash": {
          "type": "string",
          "description": "SHA256 over canonical JSON with 'signature' field removed"
        },
        "signature": {
          "type": "string"
        },
        "verify": {
          "type": "string",
          "format": "uri"
        }
      }
    }
  }
}