{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://local.spot.invalid/task-contract.schema.json",
  "title": "Spotworkers Task Contract",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "runId", "repositoryRoot", "baseRevision", "goal", "allowedPaths", "forbiddenPaths", "constraints", "acceptanceCriteria", "verification", "requiredCapabilities", "risk"],
  "properties": {
    "schemaVersion": { "const": 1 },
    "runId": { "type": "string", "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{2,79}$", "not": { "pattern": "\\.\\.|\\.lock$" } },
    "repositoryRoot": { "type": "string", "minLength": 1 },
    "baseRevision": { "type": "string", "pattern": "^[0-9a-f]{40,64}$" },
    "goal": { "type": "string", "minLength": 10, "maxLength": 4000 },
    "allowedPaths": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
    "forbiddenPaths": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
    "lockedPaths": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
    "constraints": { "type": "array", "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
    "acceptanceCriteria": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "type": "string", "minLength": 1 } },
    "verification": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["argv", "timeoutSeconds"],
        "properties": {
          "argv": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
          "timeoutSeconds": { "type": "integer", "minimum": 1, "maximum": 3600 },
          "env": {
            "type": "object",
            "patternProperties": { "^[A-Z_][A-Z0-9_]*$": { "type": "string", "maxLength": 1000 } },
            "additionalProperties": false
          }
        }
      }
    },
    "requiredCapabilities": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": { "enum": ["text", "code", "tool-use", "vision-input", "image-output"] }
    },
    "risk": { "enum": ["low", "medium", "high"] },
    "difficulty": { "enum": ["low", "medium", "high"] },
    "domain": { "enum": ["frontend", "backend", "systems", "algorithm", "refactor", "docs"] }
  }
}
