{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "profile": {
          "type": "string",
          "const": "owp-docs-draft/0.1",
          "description": "Draft discriminator. This value is not OWP v0.4 conformance or an alpha wire profile."
        },
        "created_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": "Draft: UTC date-time, second precision, ending in Z."
        },
        "updated_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": "Draft: UTC date-time, second precision, ending in Z."
        },
        "metadata": {
          "type": "object",
          "propertyNames": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          },
          "additionalProperties": {
            "type": "string",
            "maxLength": 500
          },
          "description": "Source metadata dictionary; draft limits keys to 40 and values to 500 characters. Never put secrets here."
        },
        "id": {
          "type": "string",
          "pattern": "^grant_[A-Za-z0-9]{8,64}$",
          "description": "Source defines the prefix; this draft chooses an 8–64 character alphanumeric suffix."
        },
        "job_id": {
          "type": "string",
          "pattern": "^job_[A-Za-z0-9]{8,64}$",
          "description": "Source defines the prefix; this draft chooses an 8–64 character alphanumeric suffix."
        },
        "agent_id": {
          "type": "string",
          "pattern": "^agent_[A-Za-z0-9]{8,64}$",
          "description": "Source defines the prefix; this draft chooses an 8–64 character alphanumeric suffix."
        },
        "agent_version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "user_id": {
          "type": "string",
          "pattern": "^user_[A-Za-z0-9]{8,64}$",
          "description": "Source defines the prefix; this draft chooses an 8–64 character alphanumeric suffix."
        },
        "state": {
          "type": "string",
          "enum": [
            "ISSUED",
            "ACTIVE",
            "ACCESSED",
            "FROZEN",
            "REVOKED"
          ]
        },
        "fields": {
          "minItems": 1,
          "maxItems": 64,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          }
        },
        "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": "Draft: UTC date-time, second precision, ending in Z."
        },
        "consent_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "description": "Draft reference to an independently verified consent record; this string alone proves nothing."
        },
        "sensitivity_tier": {
          "anyOf": [
            {
              "type": "number",
              "const": 1
            },
            {
              "type": "number",
              "const": 2
            }
          ]
        },
        "access_mode": {
          "type": "string",
          "enum": [
            "proxy",
            "sandbox",
            "direct"
          ],
          "description": "Structured fields default to proxy; direct still requires explicit consent."
        }
      },
      "required": [
        "profile",
        "created_at",
        "updated_at",
        "metadata",
        "id",
        "job_id",
        "agent_id",
        "agent_version",
        "user_id",
        "state",
        "fields",
        "expires_at",
        "consent_ref",
        "sensitivity_tier",
        "access_mode"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "profile": {
          "type": "string",
          "const": "owp-docs-draft/0.1",
          "description": "Draft discriminator. This value is not OWP v0.4 conformance or an alpha wire profile."
        },
        "created_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": "Draft: UTC date-time, second precision, ending in Z."
        },
        "updated_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": "Draft: UTC date-time, second precision, ending in Z."
        },
        "metadata": {
          "type": "object",
          "propertyNames": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
          },
          "additionalProperties": {
            "type": "string",
            "maxLength": 500
          },
          "description": "Source metadata dictionary; draft limits keys to 40 and values to 500 characters. Never put secrets here."
        },
        "id": {
          "type": "string",
          "pattern": "^grant_[A-Za-z0-9]{8,64}$",
          "description": "Source defines the prefix; this draft chooses an 8–64 character alphanumeric suffix."
        },
        "job_id": {
          "type": "string",
          "pattern": "^job_[A-Za-z0-9]{8,64}$",
          "description": "Source defines the prefix; this draft chooses an 8–64 character alphanumeric suffix."
        },
        "agent_id": {
          "type": "string",
          "pattern": "^agent_[A-Za-z0-9]{8,64}$",
          "description": "Source defines the prefix; this draft chooses an 8–64 character alphanumeric suffix."
        },
        "agent_version": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "user_id": {
          "type": "string",
          "pattern": "^user_[A-Za-z0-9]{8,64}$",
          "description": "Source defines the prefix; this draft chooses an 8–64 character alphanumeric suffix."
        },
        "state": {
          "type": "string",
          "enum": [
            "ISSUED",
            "ACTIVE",
            "ACCESSED",
            "FROZEN",
            "REVOKED"
          ]
        },
        "fields": {
          "minItems": 1,
          "maxItems": 64,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          }
        },
        "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": "Draft: UTC date-time, second precision, ending in Z."
        },
        "consent_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "description": "Draft reference to an independently verified consent record; this string alone proves nothing."
        },
        "sensitivity_tier": {
          "anyOf": [
            {
              "type": "number",
              "const": 3
            },
            {
              "type": "number",
              "const": 4
            }
          ]
        },
        "access_mode": {
          "type": "string",
          "enum": [
            "proxy",
            "sandbox"
          ],
          "description": "Direct access is forbidden at tiers 3–4. Structured fields use proxy; assets use sandbox."
        }
      },
      "required": [
        "profile",
        "created_at",
        "updated_at",
        "metadata",
        "id",
        "job_id",
        "agent_id",
        "agent_version",
        "user_id",
        "state",
        "fields",
        "expires_at",
        "consent_ref",
        "sensitivity_tier",
        "access_mode"
      ],
      "additionalProperties": false
    }
  ],
  "description": "Grant metadata. Direct access is rejected at tiers 3–4 by the schema. Current consent, owner, purpose and grant state must still be checked at use.",
  "title": "Grant",
  "$comment": "owp-docs-draft/0.1: proposed documentation shape only. Source: https://app.notion.com/p/338ed9cb3201819d96e9fc7b8e88594a §3 · §7 · §8. No production conformance claim."
}
