{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "profile": {
      "type": "string",
      "const": "owp-eval-local/0.1",
      "description": "Exact supported local evaluation profile."
    },
    "job": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "profile": {
              "type": "string",
              "const": "owp-eval-local/0.1",
              "description": "Exact supported local evaluation profile."
            },
            "job_id": {
              "type": "string",
              "pattern": "^job_[a-f0-9]{24}$",
              "description": "job_ followed by 24 lowercase hexadecimal characters."
            },
            "agent_id": {
              "type": "string",
              "pattern": "^agent_[a-f0-9]{24}$",
              "description": "agent_ followed by 24 lowercase hexadecimal characters."
            },
            "agent_version": {
              "type": "string"
            },
            "mode": {
              "type": "string",
              "const": "evaluation"
            },
            "capability": {
              "type": "string",
              "const": "writing/brief"
            },
            "deadline": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:Z))$",
              "description": "UTC date-time at second precision, ending in Z."
            },
            "output_schema": {
              "type": "string",
              "const": "Summary"
            },
            "state": {
              "type": "string",
              "enum": [
                "OFFERED",
                "ACCEPTED",
                "RUNNING"
              ]
            }
          },
          "required": [
            "profile",
            "job_id",
            "agent_id",
            "agent_version",
            "mode",
            "capability",
            "deadline",
            "output_schema",
            "state"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "profile": {
              "type": "string",
              "const": "owp-eval-local/0.1",
              "description": "Exact supported local evaluation profile."
            },
            "job_id": {
              "type": "string",
              "pattern": "^job_[a-f0-9]{24}$",
              "description": "job_ followed by 24 lowercase hexadecimal characters."
            },
            "agent_id": {
              "type": "string",
              "pattern": "^agent_[a-f0-9]{24}$",
              "description": "agent_ followed by 24 lowercase hexadecimal characters."
            },
            "agent_version": {
              "type": "string"
            },
            "mode": {
              "type": "string",
              "const": "evaluation"
            },
            "capability": {
              "type": "string",
              "const": "writing/brief"
            },
            "deadline": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:Z))$",
              "description": "UTC date-time at second precision, ending in Z."
            },
            "output_schema": {
              "type": "string",
              "const": "Summary"
            },
            "state": {
              "type": "string",
              "const": "SCORED"
            },
            "output_id": {
              "type": "string",
              "pattern": "^out_[a-f0-9]{24}$",
              "description": "out_ followed by 24 lowercase hexadecimal characters."
            },
            "score": {
              "type": "object",
              "properties": {
                "passed_checks": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 3
                },
                "total_checks": {
                  "type": "number",
                  "const": 3
                },
                "checks": {
                  "type": "object",
                  "properties": {
                    "garden_name": {
                      "type": "boolean"
                    },
                    "opening_day": {
                      "type": "boolean"
                    },
                    "activity": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "garden_name",
                    "opening_day",
                    "activity"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "passed_checks",
                "total_checks",
                "checks"
              ],
              "additionalProperties": false,
              "description": "Deterministic fixture check: case-insensitive substring matches for Elm Garden, Saturday, and planting workshop. This is not production reputation or a semantic quality assessment."
            }
          },
          "required": [
            "profile",
            "job_id",
            "agent_id",
            "agent_version",
            "mode",
            "capability",
            "deadline",
            "output_schema",
            "state",
            "output_id",
            "score"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "profile": {
              "type": "string",
              "const": "owp-eval-local/0.1",
              "description": "Exact supported local evaluation profile."
            },
            "job_id": {
              "type": "string",
              "pattern": "^job_[a-f0-9]{24}$",
              "description": "job_ followed by 24 lowercase hexadecimal characters."
            },
            "agent_id": {
              "type": "string",
              "pattern": "^agent_[a-f0-9]{24}$",
              "description": "agent_ followed by 24 lowercase hexadecimal characters."
            },
            "agent_version": {
              "type": "string"
            },
            "mode": {
              "type": "string",
              "const": "evaluation"
            },
            "capability": {
              "type": "string",
              "const": "writing/brief"
            },
            "deadline": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:Z))$",
              "description": "UTC date-time at second precision, ending in Z."
            },
            "output_schema": {
              "type": "string",
              "const": "Summary"
            },
            "state": {
              "type": "string",
              "enum": [
                "DECLINED",
                "FAILED",
                "EXPIRED"
              ]
            },
            "reason": {
              "type": "string",
              "enum": [
                "AGENT_DECLINED",
                "UNSUPPORTED_INPUT",
                "EXECUTION_FAILED",
                "DEADLINE_EXCEEDED"
              ]
            }
          },
          "required": [
            "profile",
            "job_id",
            "agent_id",
            "agent_version",
            "mode",
            "capability",
            "deadline",
            "output_schema",
            "state",
            "reason"
          ],
          "additionalProperties": false
        }
      ],
      "description": "Coordinator-owned job. SCORED, DECLINED, FAILED and EXPIRED are terminal. Grant revocation is separate; production and settlement states are invalid."
    },
    "grant": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "profile": {
              "type": "string",
              "const": "owp-eval-local/0.1",
              "description": "Exact supported local evaluation profile."
            },
            "grant_id": {
              "type": "string",
              "pattern": "^grant_[a-f0-9]{24}$",
              "description": "grant_ followed by 24 lowercase hexadecimal characters."
            },
            "job_id": {
              "type": "string",
              "pattern": "^job_[a-f0-9]{24}$",
              "description": "job_ followed by 24 lowercase hexadecimal characters."
            },
            "agent_id": {
              "type": "string",
              "pattern": "^agent_[a-f0-9]{24}$",
              "description": "agent_ followed by 24 lowercase hexadecimal characters."
            },
            "state": {
              "type": "string",
              "enum": [
                "ACTIVE",
                "REVOKED"
              ]
            },
            "scope": {
              "type": "array",
              "prefixItems": [
                {
                  "type": "string",
                  "const": "fixture.brief"
                }
              ]
            },
            "expires_at": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:Z))$",
              "description": "UTC date-time at second precision, ending in Z."
            },
            "synthetic_consent": {
              "type": "string",
              "const": "fixture-owner-approved"
            }
          },
          "required": [
            "profile",
            "grant_id",
            "job_id",
            "agent_id",
            "state",
            "scope",
            "expires_at",
            "synthetic_consent"
          ],
          "additionalProperties": false,
          "description": "Grant receipt, not a bearer credential. The server checks current ownership, state and deadline every time."
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "profile",
    "job",
    "grant"
  ],
  "additionalProperties": false,
  "description": "Result of output or failure: terminal snapshot plus current revoked grant, if one existed.",
  "title": "CompletionResponse",
  "$comment": "owp-eval-local/0.1; synthetic loopback evaluation only."
}
