{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kaldenframelabs.com/schemas/attempt-boundary-plan-v1.schema.json",
  "title": "Attempt Boundary plan v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "attempt_id",
    "working_directory",
    "preflight",
    "execution",
    "protected_paths",
    "output_path",
    "limits",
    "boundary"
  ],
  "properties": {
    "schema": { "const": "kaldenframe.attempt-boundary.plan.v1" },
    "attempt_id": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$" },
    "working_directory": { "$ref": "#/$defs/relativePath" },
    "preflight": { "$ref": "#/$defs/command" },
    "execution": { "$ref": "#/$defs/command" },
    "protected_paths": {
      "type": "array",
      "minItems": 1,
      "maxItems": 32,
      "uniqueItems": true,
      "items": { "$ref": "#/$defs/relativePath" }
    },
    "output_path": { "$ref": "#/$defs/relativePath" },
    "limits": {
      "type": "object",
      "additionalProperties": false,
      "required": ["max_output_bytes", "max_snapshot_files", "max_snapshot_file_bytes", "max_snapshot_total_bytes"],
      "properties": {
        "max_output_bytes": { "type": "integer", "minimum": 1024, "maximum": 16777216 },
        "max_snapshot_files": { "type": "integer", "minimum": 1, "maximum": 10000 },
        "max_snapshot_file_bytes": { "type": "integer", "minimum": 1, "maximum": 1073741824 },
        "max_snapshot_total_bytes": { "type": "integer", "minimum": 1, "maximum": 4294967296 }
      }
    },
    "boundary": {
      "const": "This receipt proves only what this wrapper observed and controlled; it is not proof of non-access, safety, correctness, authenticity, or host integrity."
    }
  },
  "$defs": {
    "relativePath": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "pattern": "^(?:\\.|[A-Za-z0-9_][A-Za-z0-9._ -]*(?:/[A-Za-z0-9_][A-Za-z0-9._ -]*)*)$"
    },
    "command": {
      "type": "object",
      "additionalProperties": false,
      "required": ["command", "timeout_ms"],
      "properties": {
        "command": {
          "type": "array",
          "minItems": 1,
          "maxItems": 32,
          "items": { "type": "string", "minLength": 1, "maxLength": 4096 }
        },
        "timeout_ms": { "type": "integer", "minimum": 100, "maximum": 86400000 }
      }
    }
  }
}
