{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:shiin:schema:intent-binding:v1",
  "title": "Shiin intent binding evaluation",
  "type": "object",
  "required": [
    "schema",
    "task",
    "action",
    "result",
    "reason"
  ],
  "properties": {
    "schema": {
      "type": "string",
      "const": "shiin.intent-binding/v1-draft.1"
    },
    "task": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "scope": {
          "type": "object",
          "properties": {
            "paths": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "forbid": {
          "type": "object",
          "properties": {
            "action_types": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "allow": {
          "description": "Hosts the task may reach.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "hosts": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "limits": {
          "description": "Counting limits the task may not exceed.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "files_written": {
              "type": "integer",
              "minimum": 0
            },
            "files_deleted": {
              "type": "integer",
              "minimum": 0
            },
            "commands": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "require_pending_for": {
          "description": "Action types that always need a person's approval within this task.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "action": {
      "type": "object",
      "required": [
        "action_type",
        "effects"
      ],
      "properties": {
        "action_type": {
          "type": "string"
        },
        "effects": {
          "type": "array",
          "items": {
            "$ref": "urn:shiin:schema:common:v1#/$defs/effect"
          }
        }
      },
      "additionalProperties": false
    },
    "result": {
      "type": "string",
      "enum": [
        "deny",
        "pending",
        "pass"
      ]
    },
    "reason": {
      "type": "string"
    }
  },
  "additionalProperties": false
}
