{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://workspai.dev/contracts/workspace-intelligence/agent-framework-ownership-receipt.v1.json",
  "title": "Workspai Agent Framework Ownership Receipt v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "generatedAt",
    "changeId",
    "adapter",
    "framework",
    "target",
    "files"
  ],
  "properties": {
    "schemaVersion": {
      "const": "workspai.agent-framework-ownership-receipt.v1"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "changeId": {
      "type": "string",
      "pattern": "^change-[a-z0-9][a-z0-9-]{7,95}$"
    },
    "adapter": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "version",
        "manifestSha256"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$"
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "manifestSha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      }
    },
    "framework": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "version"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$"
        },
        "version": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "target": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "workspace",
        "project",
        "artifactPrefix",
        "instanceName"
      ],
      "properties": {
        "workspace": {
          "type": "string",
          "minLength": 1
        },
        "project": {
          "type": "string",
          "minLength": 1
        },
        "artifactPrefix": {
          "type": "string",
          "minLength": 1,
          "not": {
            "anyOf": [
              {
                "pattern": "^/"
              },
              {
                "pattern": "^[A-Za-z]:[\\/]"
              },
              {
                "pattern": "(^|[\\/])\\.\\.([\\/]|$)"
              }
            ]
          }
        },
        "instanceName": {
          "type": "string",
          "pattern": "^[a-z0-9](?:[a-z0-9-]{0,46}[a-z0-9])?$"
        }
      }
    },
    "files": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "path",
          "sha256"
        ],
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "not": {
              "anyOf": [
                {
                  "pattern": "^/"
                },
                {
                  "pattern": "^[A-Za-z]:[\\/]"
                },
                {
                  "pattern": "(^|[\\/])\\.\\.([\\/]|$)"
                }
              ]
            }
          },
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          }
        }
      }
    }
  }
}
