{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://elnazkarami.github.io/N-DOS/schemas/manifest/0.2.json",
  "title": "NDOS File Manifest",
  "description": "A read-only inventory of files observed below an NDOS scan root. A manifest records what was seen, when, and by what tool; it never implies that anything was changed.",
  "type": "object",
  "required": [
    "manifest_version",
    "generated_at",
    "generator",
    "source_root",
    "checksums",
    "file_count",
    "total_bytes",
    "files",
    "skipped"
  ],
  "properties": {
    "manifest_version": {
      "const": "0.2"
    },
    "generated_at": {
      "description": "UTC timestamp at which the scan completed.",
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"
    },
    "generator": {
      "description": "Tool that produced this manifest, for provenance.",
      "type": "object",
      "required": ["name", "version"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "version": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "source_root": {
      "description": "Absolute path that was scanned. Paths in 'files' are relative to it.",
      "type": "string",
      "minLength": 1
    },
    "checksums": {
      "description": "Whether sha256 digests were computed. When false, duplicate detection is unavailable.",
      "type": "boolean"
    },
    "file_count": {
      "type": "integer",
      "minimum": 0
    },
    "total_bytes": {
      "type": "integer",
      "minimum": 0
    },
    "files": {
      "type": "array",
      "items": { "$ref": "#/$defs/file" }
    },
    "skipped": {
      "description": "Entries deliberately or unavoidably left out, so that an inventory never silently under-reports.",
      "type": "array",
      "items": { "$ref": "#/$defs/skipped" }
    },
    "extensions": {
      "description": "Namespaced escape hatch for tool- or lab-specific additions. Core properties stay strict; anything non-standard belongs here.",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "file": {
      "type": "object",
      "required": ["path", "name", "extension", "size_bytes", "modified", "role"],
      "properties": {
        "path": {
          "description": "POSIX-style path relative to source_root. Never absolute, never containing '..'.",
          "type": "string",
          "minLength": 1,
          "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$)).+$"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "extension": {
          "description": "Lowercased final suffix including the leading dot, or an empty string.",
          "type": "string",
          "pattern": "^(|\\.[a-z0-9][a-z0-9._-]*)$"
        },
        "size_bytes": {
          "type": "integer",
          "minimum": 0
        },
        "modified": {
          "description": "UTC modification time reported by the filesystem.",
          "type": "string",
          "format": "date-time",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"
        },
        "role": {
          "description": "Evidence role. 'unknown' is the honest default for an unannotated scan and must not be inferred silently.",
          "type": "string",
          "enum": ["unknown", "raw", "derived", "metadata", "documentation"]
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "extensions": {
          "type": "object"
        }
      },
      "additionalProperties": false
    },
    "skipped": {
      "type": "object",
      "required": ["path", "reason"],
      "properties": {
        "path": { "type": "string", "minLength": 1 },
        "reason": {
          "type": "string",
          "enum": ["excluded", "symlink", "unreadable-file", "unreadable-directory"]
        },
        "detail": { "type": "string" }
      },
      "additionalProperties": false
    }
  }
}
