{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dharma-ai.io/schemas/repository-source-resolution.schema.json",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "organizationId", "workspaceId", "repositoryBindingId", "repositoryAgentId", "policyGenerationId", "policyHash", "baselineSnapshotHash", "localSnapshotHash", "publishedFingerprint", "publishedInventoryHash", "createdAt", "expiresAt", "conflicts"],
  "properties": {
    "schema": {"const": "dharma.repository-source-resolution/v1"},
    "organizationId": {"type": "string", "minLength": 1, "maxLength": 200},
    "workspaceId": {"$ref": "#/$defs/uuid"},
    "repositoryBindingId": {"$ref": "#/$defs/uuid"},
    "repositoryAgentId": {"$ref": "#/$defs/uuid"},
    "policyGenerationId": {"$ref": "#/$defs/uuid"},
    "policyHash": {"$ref": "#/$defs/hash"},
    "baselineSnapshotHash": {"$ref": "#/$defs/hash"},
    "localSnapshotHash": {"$ref": "#/$defs/hash"},
    "publishedFingerprint": {"$ref": "#/$defs/hash"},
    "publishedInventoryHash": {"$ref": "#/$defs/hash"},
    "createdAt": {"$ref": "#/$defs/time"},
    "expiresAt": {"$ref": "#/$defs/time"},
    "conflicts": {
      "type": "array", "minItems": 1, "maxItems": 1024,
      "items": {
        "type": "object", "additionalProperties": false,
        "required": ["kind", "path", "baselineHash", "localHash", "publishedHash"],
        "properties": {
          "kind": {"enum": ["file", "skill"]},
          "path": {"type": "string", "minLength": 1, "maxLength": 4096, "pattern": "^[^\\\\\\u0000-\\u001f]+$"},
          "baselineHash": {"$ref": "#/$defs/hash"},
          "localHash": {"$ref": "#/$defs/hash"},
          "publishedHash": {"$ref": "#/$defs/hash"}
        }
      }
    }
  },
  "$defs": {
    "uuid": {"type": "string", "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"},
    "hash": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
    "time": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$"}
  }
}
