{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thruput.se/agents/schemas/review/review.schema.json",
  "title": "Review",
  "description": "What every probe is handed about the review it takes part in, resolved once by the reviewing context: the pull request, the head commit, every changed file as fragments of lines, and where the probe writes its rows of the ledger",
  "type": "object",
  "required": [
    "pullRequest",
    "headCommit",
    "files",
    "ledger",
    "report"
  ],
  "properties": {
    "pullRequest": {
      "$ref": "pull-request.schema.json"
    },
    "headCommit": {
      "$ref": "change-set.schema.json#/$defs/Commit"
    },
    "files": {
      "description": "Every changed file that has surface lines, whole: its fragments in file order at the head commit, then the fragments the change removed",
      "type": "array",
      "items": {
        "$ref": "surface.schema.json"
      }
    },
    "ledger": {
      "$ref": "#/$defs/LedgerFile"
    },
    "report": {
      "$ref": "#/$defs/ReportCommand"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "LedgerFile": {
      "description": "The file the probe writes its rows of the ledger to, by its path on the machine the review runs on. The only file a probe touches",
      "type": "string",
      "minLength": 1
    },
    "ReportCommand": {
      "description": "The command a probe checks its ledger file with before it returns: the skill's check script, run on the probe's own instructions file. It applies every check the review applies to that file, and says what it rejects",
      "type": "string",
      "minLength": 1
    }
  },
  "examples": [
    {
      "pullRequest": {
        "host": {
          "kind": "github",
          "owner": "thruput-io",
          "repository": "agents",
          "number": 12
        },
        "author": "agent-rasmus[bot]",
        "description": "A published site is valid and its links hold. Verify runs html-validate and lychee."
      },
      "headCommit": "e2bde7afe2f2b1ffc23cdb6f0dc00601b4868eb7",
      "files": [
        {
          "path": "scripts/verify.sh",
          "fragments": [
            {
              "kind": "context",
              "lines": {
                "20": "npx --yes @sourcemeta/jsonschema@17.0.0 lint \"$PROJECT_ROOT/schemas\""
              }
            },
            {
              "kind": "surface",
              "side": "head",
              "lines": {
                "21": "npx --yes @sourcemeta/jsonschema@17.0.0 metaschema \"$PROJECT_ROOT/schemas\" || true"
              }
            },
            {
              "kind": "surface",
              "side": "base",
              "lines": {
                "21": "npx --yes @sourcemeta/jsonschema@17.0.0 metaschema \"$PROJECT_ROOT/schemas\""
              }
            }
          ]
        }
      ],
      "ledger": "$WORKDIR/ledger/11-behavior-failure-handling.json",
      "report": "node \"$SKILL_DIR/scripts/check.mjs\" \"$WORKDIR/instructions/11-behavior-failure-handling.yaml\""
    }
  ]
}
