{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://grip.foxora.dev/schema/1.0-draft.2/settlement.schema.json",
  "title": "GRIP Settlement",
  "description": "Closes a Mandate against its own acceptance criteria. §4.3.5.",
  "allOf": [{ "$ref": "common.schema.json#/$defs/envelope" }],
  "type": "object",
  "required": ["grip", "type", "id", "parents", "iss", "state", "criteria", "totals", "iat", "sig"],
  "properties": {
    "type": { "const": "settlement" },
    "state": { "enum": ["settled", "cancelled"] },
    "criteria": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["code", "verdict", "evidence", "validator"],
        "properties": {
          "code": { "type": "string", "minLength": 1 },
          "verdict": { "enum": ["accepted", "rejected"] },
          "evidence": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/digest" }, "minItems": 1 },
          "validator": { "$ref": "common.schema.json#/$defs/keyref" },
          "validator_sig": { "$ref": "common.schema.json#/$defs/sig", "description": "Detached JWS over the criterion entry. REQUIRED where the Mandate marks the criterion independent. §4.6 rule 6." }
        },
        "additionalProperties": false
      }
    },
    "totals": { "$ref": "common.schema.json#/$defs/budget", "description": "MUST match the verifier's rule-4 recomputation. §4.6." },
    "predicate": {
      "enum": ["identity-inequality", "distinct-principal", "distinct-organization"],
      "default": "identity-inequality",
      "description": "Independence predicate this Settlement satisfies. Verifiers report it. §4.3.5."
    }
  }
}
