{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://agoragentic.com/schema/tool-side-effect-policy.v1.json",
  "title": "Agoragentic Tool Side-Effect Policy",
  "description": "Policy declaration for a tool or action before it can be used by Agent OS, Router, Seller OS, x402, or hosted runtimes. This is a policy artifact only and grants no execution authority by itself.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "tool_id",
    "side_effect_level",
    "data_access_level",
    "requires_receipt",
    "requires_approval",
    "public_boundary"
  ],
  "properties": {
    "schema": {
      "const": "agoragentic.tool-side-effect-policy.v1"
    },
    "tool_id": {
      "type": "string"
    },
    "side_effect_level": {
      "type": "string",
      "enum": [
        "read_only",
        "draft_only",
        "internal_write",
        "external_send",
        "code_write",
        "wallet_spend",
        "public_publish",
        "subagent_spawn",
        "policy_change"
      ]
    },
    "data_access_level": {
      "type": "string",
      "enum": ["none", "public", "workspace", "private_context", "secrets_brokered"]
    },
    "egress_domains": {
      "type": "array",
      "default": [],
      "items": { "type": "string" }
    },
    "spend_amount_usdc_max": {
      "type": ["number", "null"],
      "minimum": 0
    },
    "wallet_touch": {
      "type": "boolean",
      "default": false
    },
    "public_exposure": {
      "type": "boolean",
      "default": false
    },
    "requires_receipt": {
      "type": "boolean"
    },
    "requires_approval": {
      "type": "boolean"
    },
    "rollback_available": {
      "type": "boolean",
      "default": false
    },
    "public_boundary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "policy_artifact_only",
        "runtime_executed",
        "wallet_moved",
        "public_state_changed",
        "trust_mutated"
      ],
      "properties": {
        "policy_artifact_only": { "const": true },
        "runtime_executed": { "const": false },
        "wallet_moved": { "const": false },
        "public_state_changed": { "const": false },
        "trust_mutated": { "const": false }
      }
    }
  }
}
