{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hogarmas.net/agent-risk-atlas/schema.json",
  "title": "H/M Agent Risk Atlas export packet",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "ruleset", "generatedAt", "input", "analysis", "limitations"],
  "properties": {
    "schema": { "const": "hm.agent-risk-atlas.v1" },
    "ruleset": { "type": "string" },
    "generatedAt": { "type": "string", "format": "date-time" },
    "input": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sha256", "source", "sample", "rawAgentScopePacketIncluded", "toolNamesIncluded", "catalogIncluded"],
      "properties": {
        "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "source": { "enum": ["manual", "preset", "agent-scope"] },
        "sample": { "type": "boolean" },
        "rawAgentScopePacketIncluded": { "const": false },
        "toolNamesIncluded": { "const": false },
        "catalogIncluded": { "const": false }
      }
    },
    "analysis": {
      "type": "object",
      "additionalProperties": false,
      "required": ["profile", "summary", "paths", "controlPlan"],
      "properties": {
        "profile": {
          "type": "object",
          "additionalProperties": false,
          "required": ["source", "capabilities", "declaredControls"],
          "properties": {
            "source": { "enum": ["manual", "preset", "agent-scope"] },
            "capabilities": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/capabilityId" } },
            "declaredControls": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/controlId" } }
          }
        },
        "summary": {
          "type": "object",
          "additionalProperties": false,
          "required": ["activeCapabilities", "declaredControls", "attackPaths", "criticalPaths", "highPaths", "uncoveredPaths", "partialPaths", "declaredCoveredPaths", "missingControls", "highestObservedSeverity"],
          "properties": {
            "activeCapabilities": { "type": "integer", "minimum": 0, "maximum": 12 },
            "declaredControls": { "type": "integer", "minimum": 0, "maximum": 13 },
            "attackPaths": { "type": "integer", "minimum": 0, "maximum": 10 },
            "criticalPaths": { "type": "integer", "minimum": 0, "maximum": 10 },
            "highPaths": { "type": "integer", "minimum": 0, "maximum": 10 },
            "uncoveredPaths": { "type": "integer", "minimum": 0, "maximum": 10 },
            "partialPaths": { "type": "integer", "minimum": 0, "maximum": 10 },
            "declaredCoveredPaths": { "type": "integer", "minimum": 0, "maximum": 10 },
            "missingControls": { "type": "integer", "minimum": 0, "maximum": 13 },
            "highestObservedSeverity": { "enum": ["critical", "high", "elevated", "watch", "no-known-path"] }
          }
        },
        "paths": { "type": "array", "items": { "$ref": "#/$defs/path" } },
        "controlPlan": { "type": "array", "items": { "$ref": "#/$defs/controlPlanItem" } }
      }
    },
    "limitations": {
      "type": "object",
      "additionalProperties": false,
      "required": ["controlsVerified", "runtimeObserved", "authorizationEnforced", "behaviorCertified", "completeThreatModelProduced", "sourceDataUploaded", "toolExecutionPerformed"],
      "properties": {
        "controlsVerified": { "const": false },
        "runtimeObserved": { "const": false },
        "authorizationEnforced": { "const": false },
        "behaviorCertified": { "const": false },
        "completeThreatModelProduced": { "const": false },
        "sourceDataUploaded": { "const": false },
        "toolExecutionPerformed": { "const": false }
      }
    }
  },
  "$defs": {
    "capabilityId": { "enum": ["untrusted-content", "private-data", "external-communication", "code-execution", "persistent-memory", "identity-delegation", "destructive-write", "financial-action", "autonomous-loop", "third-party-oauth", "shared-session", "local-server"] },
    "controlId": { "enum": ["untrusted-data-taint", "egress-allowlist", "task-data-boundary", "execution-sandbox", "immediate-confirmation", "rollback-idempotency", "action-budget", "scoped-tokens", "transaction-ceiling", "memory-provenance", "per-client-consent", "session-binding", "immutable-audit"] },
    "pathId": { "enum": ["lethal-trifecta", "code-egress-bridge", "local-server-compromise", "autonomous-destruction", "autonomous-finance", "memory-poisoning", "confused-deputy", "session-hijack", "privilege-egress", "injected-action-loop"] },
    "path": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "category", "severity", "capabilities", "requiredControls", "declaredControls", "missingControls", "coveragePercent", "controlState", "references"],
      "properties": {
        "id": { "$ref": "#/$defs/pathId" },
        "category": { "type": "string" },
        "severity": { "enum": ["critical", "high", "elevated", "watch"] },
        "capabilities": { "type": "array", "items": { "$ref": "#/$defs/capabilityId" } },
        "requiredControls": { "type": "array", "items": { "$ref": "#/$defs/controlId" } },
        "declaredControls": { "type": "array", "items": { "$ref": "#/$defs/controlId" } },
        "missingControls": { "type": "array", "items": { "$ref": "#/$defs/controlId" } },
        "coveragePercent": { "type": "integer", "minimum": 0, "maximum": 100 },
        "controlState": { "enum": ["uncovered", "partial", "declared-covered"] },
        "references": { "type": "array", "items": { "type": "string" } }
      }
    },
    "controlPlanItem": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "priority", "layer", "pathIds", "protectsPathCount"],
      "properties": {
        "id": { "$ref": "#/$defs/controlId" },
        "priority": { "enum": ["now", "next", "later"] },
        "layer": { "enum": ["runtime", "network", "data", "human", "identity", "finance", "storage", "transport", "audit"] },
        "pathIds": { "type": "array", "items": { "$ref": "#/$defs/pathId" } },
        "protectsPathCount": { "type": "integer", "minimum": 1, "maximum": 10 }
      }
    }
  }
}
