{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://git.dcserve.ru/SILVER/NDC_xgrids-k1-connector/schemas/session-manifest.schema.json",
  "$comment": "The legacy v1 schema identifier is intentionally immutable after the repository rename to NODEDC_MISSION_CORE.",
  "title": "K1 laboratory session manifest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "session_id",
    "experiment",
    "tool",
    "host",
    "device",
    "network",
    "timeline",
    "artifacts",
    "decision"
  ],
  "properties": {
    "schema_version": { "const": 1 },
    "session_id": {
      "type": "string",
      "pattern": "^[0-9]{8}T[0-9]{6}Z_[a-z0-9_-]+$"
    },
    "experiment": { "type": "string", "minLength": 1 },
    "tool": {
      "type": "object",
      "additionalProperties": false,
      "required": ["version", "git_commit"],
      "properties": {
        "version": { "type": "string" },
        "git_commit": { "type": "string" }
      }
    },
    "host": {
      "type": "object",
      "additionalProperties": false,
      "required": ["macos_version", "machine", "python_version"],
      "properties": {
        "macos_version": { "type": "string" },
        "machine": { "type": "string" },
        "python_version": { "type": "string" },
        "wifi_interface": { "type": ["string", "null"] },
        "vpn_active": { "type": "boolean" }
      }
    },
    "device": {
      "type": "object",
      "additionalProperties": false,
      "required": ["model", "activation_state", "firmware"],
      "properties": {
        "model": { "type": "string" },
        "serial_suffix": { "type": ["string", "null"], "maxLength": 8 },
        "activation_state": {
          "enum": ["unknown", "active", "activation_lock", "fault"]
        },
        "firmware": { "type": ["string", "null"] }
      }
    },
    "network": {
      "type": "object",
      "additionalProperties": false,
      "required": ["topology", "k1_address_redacted"],
      "properties": {
        "topology": {
          "enum": ["unknown", "current_lan", "device_ap", "direct"]
        },
        "k1_address_redacted": { "type": ["string", "null"] }
      }
    },
    "timeline": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["event", "monotonic_seconds"],
        "properties": {
          "event": { "type": "string", "minLength": 1 },
          "monotonic_seconds": { "type": "number", "minimum": 0 },
          "utc": { "type": ["string", "null"], "format": "date-time" },
          "note": { "type": ["string", "null"] }
        }
      }
    },
    "artifacts": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["path", "size_bytes", "sha256", "classification"],
        "properties": {
          "path": { "type": "string", "minLength": 1 },
          "size_bytes": { "type": "integer", "minimum": 0 },
          "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
          "classification": {
            "enum": ["public", "redacted", "sensitive", "secret"]
          }
        }
      }
    },
    "decision": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status", "gate", "reason"],
      "properties": {
        "status": { "enum": ["GO", "PAUSE", "BLOCKED"] },
        "gate": { "type": "string", "minLength": 1 },
        "reason": { "type": "string", "minLength": 1 },
        "next_smallest_experiment": { "type": ["string", "null"] }
      }
    }
  }
}
