{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://grip.foxora.dev/schema/1.0-draft.2/stop.schema.json",
  "title": "GRIP Stop",
  "description": "Suspends a specific act until a designated human decides. Act-bound and single-use unless an explicit multi-use envelope is declared. §4.3.4.",
  "allOf": [{ "$ref": "common.schema.json#/$defs/envelope" }],
  "type": "object",
  "required": ["grip", "type", "id", "parents", "iss", "act_digest", "reason", "approver", "mode", "iat", "exp", "sig"],
  "properties": {
    "type": { "const": "stop" },
    "act_digest": { "$ref": "common.schema.json#/$defs/digest", "description": "Digest of the act this Stop gates. MUST equal the act's input_digest. §4.6 rule 5." },
    "reason": { "type": "string", "minLength": 1, "description": "Human-legible description, rendered from verified chain objects by a conformant approval surface." },
    "approver": { "$ref": "common.schema.json#/$defs/keyref" },
    "mode": { "enum": ["signature", "token"] },
    "token_digest": { "$ref": "common.schema.json#/$defs/digest", "description": "Token mode only: SHA-256 of the 32-byte completion token. The token itself is never stored. §4.3.4." },
    "envelope": {
      "type": "object",
      "required": ["count", "budget"],
      "properties": {
        "count": { "type": "integer", "minimum": 1 },
        "budget": { "$ref": "common.schema.json#/$defs/budget" }
      },
      "additionalProperties": false,
      "description": "Explicit multi-use envelope. Absent means one approval is one act. The approval surface MUST display it."
    }
  },
  "allOf": [
    { "if": { "properties": { "mode": { "const": "token" } }, "required": ["mode"] },
      "then": { "required": ["token_digest"] } },
    { "if": { "properties": { "mode": { "const": "signature" } }, "required": ["mode"] },
      "then": { "not": { "required": ["token_digest"] } } }
  ]
}
