{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://law.arxo.io/schema/import-package-plan.schema.json",
  "type": "object",
  "properties": {
    "format": {
      "const": "arxo.import.package-plan/0.1"
    },
    "basis": {
      "enum": [
        "emitted_references/0.1",
        "single_package/0.1"
      ]
    },
    "compiler_check": {
      "const": "not_run"
    },
    "input_hash": {
      "type": "string"
    },
    "mapping_hash": {
      "type": "string"
    },
    "policy_hash": {
      "type": "string"
    },
    "owners": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "packages": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "namespace": {
            "type": "string"
          },
          "boundary": {
            "type": "string"
          },
          "members": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "enum": [
                    "type",
                    "predicate",
                    "reification",
                    "declaration",
                    "fact"
                  ]
                },
                "source": {
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "source"
              ],
              "additionalProperties": false
            }
          },
          "imports": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "version",
          "namespace",
          "boundary",
          "members",
          "imports"
        ],
        "additionalProperties": false
      }
    },
    "existing": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string"
          },
          "namespace": {
            "type": "string"
          },
          "content_hash": {
            "type": "string"
          }
        },
        "required": [
          "version",
          "namespace",
          "content_hash"
        ],
        "additionalProperties": false
      }
    },
    "references": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "from": {
            "type": "object",
            "properties": {
              "kind": {
                "enum": [
                  "type",
                  "predicate",
                  "reification",
                  "declaration",
                  "fact"
                ]
              },
              "source": {
                "type": "string"
              }
            },
            "required": [
              "kind",
              "source"
            ],
            "additionalProperties": false
          },
          "to": {
            "type": "object",
            "properties": {
              "kind": {
                "enum": [
                  "type",
                  "predicate",
                  "reification",
                  "declaration",
                  "fact"
                ]
              },
              "source": {
                "type": "string"
              }
            },
            "required": [
              "kind",
              "source"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "from",
          "to"
        ],
        "additionalProperties": false
      }
    },
    "order": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "outcomes": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "status": {
            "enum": [
              "rule",
              "fact",
              "catalogue",
              "blocked"
            ]
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "target": {
            "type": [
              "string",
              "null"
            ]
          },
          "anchor": {
            "type": "string"
          },
          "journal": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "expression": {
                  "type": "string"
                },
                "action": {
                  "type": "string"
                },
                "target": {
                  "type": "string"
                }
              },
              "required": [
                "expression",
                "action",
                "target"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "status",
          "code",
          "message",
          "target",
          "anchor",
          "journal"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "format",
    "basis",
    "compiler_check",
    "input_hash",
    "mapping_hash",
    "policy_hash",
    "owners",
    "packages",
    "existing",
    "references",
    "order",
    "outcomes"
  ],
  "additionalProperties": false
}
