{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "dd-flow/archived-flow-manifest@1",
  "title": "Archived flow manifest",
  "description": "Manifest for dd-flow files archived from an active project flow pack during Memory Bank upgrade.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_id",
    "archive_id",
    "created_at",
    "target_project_root",
    "source_flow_root",
    "archive_root",
    "items"
  ],
  "properties": {
    "schema_id": {
      "const": "dd-flow/archived-flow-manifest@1"
    },
    "archive_id": {
      "type": "string",
      "minLength": 1
    },
    "created_at": {
      "type": "string",
      "minLength": 1
    },
    "target_project_root": {
      "type": "string",
      "minLength": 1
    },
    "source_flow_root": {
      "type": "string",
      "minLength": 1
    },
    "archive_root": {
      "type": "string",
      "minLength": 1
    },
    "items": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/definitions/item"
      }
    },
    "notes": {
      "type": "string"
    }
  },
  "definitions": {
    "item": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "original_path",
        "archive_path",
        "classification",
        "reason",
        "manual_review_required",
        "replacement"
      ],
      "properties": {
        "original_path": {
          "type": "string",
          "minLength": 1,
          "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*//)[A-Za-z0-9._-]+(?:/[A-Za-z0-9._-]+)*$"
        },
        "archive_path": {
          "type": "string",
          "minLength": 1,
          "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*//)[A-Za-z0-9._-]+(?:/[A-Za-z0-9._-]+)*$"
        },
        "classification": {
          "type": "string",
          "enum": ["canonical_only_obsolete", "old_full_canonical_copy", "project_customization", "unknown_extra", "generated_or_runtime"]
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "manual_review_required": {
          "type": "boolean"
        },
        "replacement": {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind", "hint"],
          "properties": {
            "kind": {
              "type": "string",
              "enum": ["canonical_only_flow", "project_flow_pack_file", "removed", "needs_decision"]
            },
            "hint": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "source_commit": {
          "type": "string",
          "minLength": 7
        },
        "source_hash": {
          "type": "string",
          "minLength": 1
        }
      }
    }
  }
}
