{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://the-platform.invalid/contracts/p010-p011/intake-package-1.0",
  "title": "P010/P011 to P003 Intake Package",
  "type": "object",
  "additionalProperties": false,
  "required": ["packageId","programme","schemaVersion","sequence","exportedAt","approvalAuthority","recordCount","records","packageHash","signature"],
  "properties": {
    "packageId": {"type":"string","pattern":"^PKG-[A-Z0-9-]{6,}$"},
    "programme": {"const":"P010_P011"},
    "schemaVersion": {"const":"1.0"},
    "sequence": {"type":"integer","minimum":1},
    "exportedAt": {"type":"string","format":"date-time"},
    "approvalAuthority": {"type":"string","minLength":1},
    "recordCount": {"type":"integer","minimum":1},
    "packageHash": {"type":"string","pattern":"^[a-f0-9]{64}$"},
    "signature": {"type":"object","additionalProperties":false,"required":["algorithm","keyId","value"],"properties":{"algorithm":{"const":"ED25519"},"keyId":{"type":"string","minLength":1},"value":{"type":"string","minLength":32}}},
    "records": {"type":"array","minItems":1,"items":{"$ref":"#/$defs/record"}}
  },
  "$defs": {
    "record": {
      "type":"object","additionalProperties":false,
      "required":["content_id","content_type","source","approval","visibility","title","slug","summary","body","effective_at","language","metadata"],
      "properties": {
        "content_id":{"type":"string","minLength":1},"content_type":{"enum":["publication","research"]},
        "source":{"type":"object","additionalProperties":false,"required":["programme","record_id","revision","hash"],"properties":{"programme":{"const":"P010_P011"},"record_id":{"type":"string","minLength":1},"revision":{"type":"string","minLength":1},"hash":{"type":"string","pattern":"^[a-fA-F0-9]{64}$"}}},
        "approval":{"enum":["APPROVED_FOR_PUBLICATION","PUBLISHED"]},"visibility":{"const":"PUBLIC"},
        "title":{"type":"string","minLength":1},"slug":{"type":"string","pattern":"^[a-z0-9]+(?:-[a-z0-9]+)*$"},"summary":{"type":"string","minLength":1},"body":{"type":"string","minLength":1},
        "effective_at":{"type":"string","format":"date-time"},"expires_at":{"type":["string","null"],"format":"date-time"},"language":{"type":"string","pattern":"^[a-z]{2}(?:-[A-Z]{2})?$"},"metadata":{"type":"object"}
      }
    }
  }
}
