{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "profile": {
      "type": "string",
      "const": "owp-market-local/0.2"
    },
    "match_id": {
      "type": "string",
      "allOf": [
        {
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        {
          "pattern": "^[a-f0-9-]+$"
        }
      ]
    },
    "agent_id": {
      "type": "string",
      "pattern": "^agent_[a-f0-9]{24}$"
    },
    "subscription_id": {
      "type": "string",
      "allOf": [
        {
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        {
          "pattern": "^[a-f0-9-]+$"
        }
      ]
    },
    "job": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "profile": {
              "type": "string",
              "const": "owp-market-local/0.2"
            },
            "job_id": {
              "type": "string",
              "allOf": [
                {
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                {
                  "pattern": "^[a-f0-9-]+$"
                }
              ]
            },
            "round_id": {
              "type": "string",
              "allOf": [
                {
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                {
                  "pattern": "^[a-f0-9-]+$"
                }
              ]
            },
            "state": {
              "type": "string",
              "enum": [
                "OPEN",
                "CLOSED"
              ]
            },
            "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))$"
            },
            "candidate_slots": {
              "type": "number",
              "const": 2
            },
            "reward": {
              "type": "object",
              "properties": {
                "unit": {
                  "type": "string",
                  "const": "TEST_CREDIT"
                },
                "amount": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 25
                },
                "redeemable": {
                  "type": "boolean",
                  "const": false
                }
              },
              "required": [
                "unit",
                "amount",
                "redeemable"
              ],
              "additionalProperties": false,
              "description": "Fictional, non-redeemable credits. No currency, funds, wallet, fees or payment processor."
            },
            "output_contract": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "media_type": {
                      "type": "string",
                      "const": "text/plain"
                    },
                    "max_bytes": {
                      "type": "number",
                      "const": 4096
                    },
                    "schema_id": {
                      "type": "null"
                    }
                  },
                  "required": [
                    "media_type",
                    "max_bytes",
                    "schema_id"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "media_type": {
                      "type": "string",
                      "const": "text/markdown"
                    },
                    "max_bytes": {
                      "type": "number",
                      "const": 4096
                    },
                    "schema_id": {
                      "type": "null"
                    }
                  },
                  "required": [
                    "media_type",
                    "max_bytes",
                    "schema_id"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "media_type": {
                      "type": "string",
                      "const": "application/json"
                    },
                    "max_bytes": {
                      "type": "number",
                      "const": 4096
                    },
                    "schema_id": {
                      "type": "string",
                      "const": "GardenFacts"
                    }
                  },
                  "required": [
                    "media_type",
                    "max_bytes",
                    "schema_id"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "capability": {
              "type": "string",
              "const": "writing/brief"
            },
            "input": {
              "type": "object",
              "properties": {
                "title": {
                  "type": "string",
                  "const": "Elm Garden"
                },
                "opening_day": {
                  "type": "string",
                  "const": "Saturday"
                },
                "activity": {
                  "type": "string",
                  "const": "planting workshop"
                },
                "instruction": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 500
                }
              },
              "required": [
                "title",
                "opening_day",
                "activity",
                "instruction"
              ],
              "additionalProperties": false
            },
            "selection_policy": {
              "type": "string",
              "const": "most-facts-first-submission-v1"
            }
          },
          "required": [
            "profile",
            "job_id",
            "round_id",
            "state",
            "deadline",
            "candidate_slots",
            "reward",
            "output_contract",
            "capability",
            "input",
            "selection_policy"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "profile": {
              "type": "string",
              "const": "owp-market-local/0.2"
            },
            "job_id": {
              "type": "string",
              "allOf": [
                {
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                {
                  "pattern": "^[a-f0-9-]+$"
                }
              ]
            },
            "round_id": {
              "type": "string",
              "allOf": [
                {
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                {
                  "pattern": "^[a-f0-9-]+$"
                }
              ]
            },
            "state": {
              "type": "string",
              "enum": [
                "OPEN",
                "CLOSED"
              ]
            },
            "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))$"
            },
            "candidate_slots": {
              "type": "number",
              "const": 2
            },
            "reward": {
              "type": "object",
              "properties": {
                "unit": {
                  "type": "string",
                  "const": "TEST_CREDIT"
                },
                "amount": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 25
                },
                "redeemable": {
                  "type": "boolean",
                  "const": false
                }
              },
              "required": [
                "unit",
                "amount",
                "redeemable"
              ],
              "additionalProperties": false,
              "description": "Fictional, non-redeemable credits. No currency, funds, wallet, fees or payment processor."
            },
            "output_contract": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "media_type": {
                      "type": "string",
                      "const": "text/plain"
                    },
                    "max_bytes": {
                      "type": "number",
                      "const": 4096
                    },
                    "schema_id": {
                      "type": "null"
                    }
                  },
                  "required": [
                    "media_type",
                    "max_bytes",
                    "schema_id"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "media_type": {
                      "type": "string",
                      "const": "text/markdown"
                    },
                    "max_bytes": {
                      "type": "number",
                      "const": 4096
                    },
                    "schema_id": {
                      "type": "null"
                    }
                  },
                  "required": [
                    "media_type",
                    "max_bytes",
                    "schema_id"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "media_type": {
                      "type": "string",
                      "const": "application/json"
                    },
                    "max_bytes": {
                      "type": "number",
                      "const": 4096
                    },
                    "schema_id": {
                      "type": "string",
                      "const": "WeatherFacts"
                    }
                  },
                  "required": [
                    "media_type",
                    "max_bytes",
                    "schema_id"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "capability": {
              "type": "string",
              "const": "weather/current"
            },
            "audience": {
              "type": "string",
              "const": "private"
            },
            "input": {
              "type": "object",
              "properties": {
                "instruction": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 500
                }
              },
              "required": [
                "instruction"
              ],
              "additionalProperties": false
            },
            "context_requirements": {
              "type": "array",
              "prefixItems": [
                {
                  "type": "string",
                  "const": "location.current"
                }
              ]
            },
            "selection_policy": {
              "type": "string",
              "const": "weather-facts-first-submission-v1"
            }
          },
          "required": [
            "profile",
            "job_id",
            "round_id",
            "state",
            "deadline",
            "candidate_slots",
            "reward",
            "output_contract",
            "capability",
            "audience",
            "input",
            "context_requirements",
            "selection_policy"
          ],
          "additionalProperties": false
        }
      ],
      "description": "Weather previews contain no location. Use the encrypted, job-bound context channel. Only the job owner can read selected weather content."
    },
    "state": {
      "type": "string",
      "enum": [
        "MATCHED",
        "WAITING_CONTEXT",
        "SUBMITTED",
        "SELECTED",
        "NOT_SELECTED",
        "FAILED",
        "EXPIRED"
      ]
    },
    "output_id": {
      "anyOf": [
        {
          "type": "string",
          "allOf": [
            {
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            {
              "pattern": "^[a-f0-9-]+$"
            }
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "score": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0,
          "maximum": 3
        },
        {
          "type": "null"
        }
      ]
    },
    "reason": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "MOST_FACTS",
            "EARLIER_SUBMISSION",
            "LOWER_RANK",
            "BELOW_THRESHOLD",
            "EXECUTION_FAILED",
            "DECLINED",
            "DEADLINE_EXCEEDED"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "payment": {
      "type": "object",
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "PENDING_SELECTION",
            "SIMULATED_PAID",
            "NOT_PAYABLE"
          ]
        },
        "reward": {
          "type": "object",
          "properties": {
            "unit": {
              "type": "string",
              "const": "TEST_CREDIT"
            },
            "amount": {
              "type": "integer",
              "minimum": 0,
              "maximum": 25
            },
            "redeemable": {
              "type": "boolean",
              "const": false
            }
          },
          "required": [
            "unit",
            "amount",
            "redeemable"
          ],
          "additionalProperties": false,
          "description": "Fictional, non-redeemable credits. No currency, funds, wallet, fees or payment processor."
        },
        "receipt_id": {
          "anyOf": [
            {
              "type": "string",
              "allOf": [
                {
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                {
                  "pattern": "^[a-f0-9-]+$"
                }
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "state",
        "reward",
        "receipt_id"
      ],
      "additionalProperties": false,
      "description": "Server-owned simulated payment status. Only SELECTED receives 25 TEST_CREDIT and a single receipt; every other final outcome gets zero."
    }
  },
  "required": [
    "profile",
    "match_id",
    "agent_id",
    "subscription_id",
    "job",
    "state",
    "output_id",
    "score",
    "reason",
    "payment"
  ],
  "additionalProperties": false,
  "description": "Owned assignment and fresh outcome. Submission receipts are historical; poll matches for selection and simulated payment.",
  "title": "Match",
  "$comment": "owp-market-local/0.2; fictional loopback market, non-redeemable test credits only."
}
