{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Alethrai draft policy proposal v1",
  "description": "A non-executable proposal, not an approved policy, identity assertion or compliance verdict. Sanitise text before validation; schema validity cannot establish factual truth or absence of secrets.",
  "type": "object",
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "1"
    },
    "status": {
      "type": "string",
      "const": "draft"
    },
    "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))$"
    },
    "organisation": {
      "type": "object",
      "properties": {
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80
        },
        "source": {
          "type": "string",
          "const": "administrator_supplied"
        }
      },
      "required": ["label", "source"],
      "additionalProperties": false
    },
    "proposals": {
      "minItems": 1,
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[a-z0-9][a-z0-9._-]*$"
          },
          "target": {
            "type": "object",
            "properties": {
              "platform": {
                "type": "string",
                "enum": ["macos", "windows", "linux"]
              },
              "tool": {
                "type": "string",
                "enum": [
                  "claude-code",
                  "codex",
                  "cursor",
                  "copilot-cli",
                  "gemini-cli",
                  "other-process"
                ]
              }
            },
            "required": ["platform", "tool"],
            "additionalProperties": false
          },
          "requirement": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "organisation_profile"
                  },
                  "required": {
                    "type": "boolean",
                    "const": true
                  }
                },
                "required": ["kind", "required"],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "managed_authentication"
                  },
                  "required": {
                    "type": "boolean",
                    "const": true
                  }
                },
                "required": ["kind", "required"],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "optional_data_sharing"
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": ["kind", "enabled"],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "trusted_publisher"
                  },
                  "required": {
                    "type": "boolean",
                    "const": true
                  }
                },
                "required": ["kind", "required"],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "minimum_version"
                  },
                  "version": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 32,
                    "pattern": "^\\d{1,6}\\.\\d{1,6}\\.\\d{1,6}$"
                  }
                },
                "required": ["kind", "version"],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "uncovered_process"
                  },
                  "action": {
                    "type": "string",
                    "const": "review_required"
                  }
                },
                "required": ["kind", "action"],
                "additionalProperties": false
              }
            ]
          },
          "rationale": {
            "type": "string",
            "minLength": 1,
            "maxLength": 400
          },
          "observation": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string",
                    "const": "unknown"
                  },
                  "reason": {
                    "type": "string",
                    "enum": [
                      "identity_unverified",
                      "unsupported_check",
                      "missing_configuration",
                      "permission_denied",
                      "not_inspected",
                      "conflicting_settings"
                    ]
                  }
                },
                "required": ["state", "reason"],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string",
                    "const": "observed"
                  },
                  "observed_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))$"
                  },
                  "summary": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 400
                  },
                  "evidence": {
                    "type": "object",
                    "properties": {
                      "source": {
                        "type": "string",
                        "enum": [
                          "managed_configuration",
                          "user_configuration",
                          "administrator_statement",
                          "synthetic_fixture"
                        ]
                      },
                      "reference": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80,
                        "pattern": "^[a-z0-9][a-z0-9._-]*$"
                      },
                      "strength": {
                        "type": "string",
                        "enum": [
                          "configuration_only",
                          "administrator_assertion",
                          "synthetic"
                        ]
                      }
                    },
                    "required": ["source", "reference", "strength"],
                    "additionalProperties": false
                  }
                },
                "required": ["state", "observed_at", "summary", "evidence"],
                "additionalProperties": false
              }
            ]
          }
        },
        "required": ["id", "target", "requirement", "rationale", "observation"],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "schema_version",
    "status",
    "created_at",
    "organisation",
    "proposals"
  ],
  "additionalProperties": false
}
