{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/mmerterden/multi-agent-pipeline/pipeline/schemas/worktrees.schema.json",
  "title": "Run worktrees",
  "description": "What `worktrees.mjs --json` prints: one entry per run that owns a worktree, with its size when --measure was passed. --redact removes every x-sensitivity local field.",
  "type": "object",
  "additionalProperties": false,
  "required": ["contractVersion", "worktrees"],
  "properties": {
    "contractVersion": {
      "type": "string",
      "pattern": "^1\\.[0-9]+\\.[0-9]+$",
      "x-sensitivity": "none"
    },
    "worktrees": {
      "type": "array",
      "x-sensitivity": "none",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["taskId", "exists", "sizeBytes", "measuredAt"],
        "properties": {
          "taskId": { "type": "string", "minLength": 1, "x-sensitivity": "none" },
          "project": { "type": ["string", "null"], "x-sensitivity": "none" },
          "worktreePath": {
            "type": "string",
            "x-sensitivity": "local",
            "description": "Absolute path on this machine."
          },
          "exists": {
            "type": "boolean",
            "x-sensitivity": "none",
            "description": "The directory is on disk. false: removed by Phase 4 or by hand, and the run still names it."
          },
          "sizeBytes": {
            "type": ["integer", "null"],
            "minimum": 0,
            "x-sensitivity": "none",
            "description": "Disk usage from du -sk. null unless --measure ran and the directory exists."
          },
          "measuredAt": {
            "type": ["string", "null"],
            "format": "date-time",
            "x-sensitivity": "none",
            "description": "When sizeBytes was taken; null when it was not."
          }
        }
      }
    }
  }
}
