{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hogarmas.net/agent-scope/schema.json",
  "title": "H/M Agent Scope export packet",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "ruleset", "generatedAt", "input", "analysis", "limitations"],
  "properties": {
    "schema": { "const": "hm.agent-scope.v1" },
    "ruleset": { "type": "string" },
    "generatedAt": { "type": "string", "format": "date-time" },
    "input": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sha256", "sample", "rawCatalogIncluded", "descriptionsIncluded", "schemaExamplesIncluded"],
      "properties": {
        "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
        "sample": { "type": "boolean" },
        "rawCatalogIncluded": { "const": false },
        "descriptionsIncluded": { "const": false },
        "schemaExamplesIncluded": { "const": false }
      }
    },
    "analysis": {
      "type": "object",
      "required": ["summary", "catalogFindings", "tools"],
      "properties": {
        "summary": { "type": "object" },
        "catalogFindings": { "type": "array", "items": { "$ref": "#/$defs/finding" } },
        "tools": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["name", "gate", "riskLevel", "effectiveAnnotations", "capabilities", "findings", "policy"],
            "properties": {
              "name": { "type": "string" },
              "sourceFormat": { "enum": ["mcp-tool", "function-tool"] },
              "gate": { "enum": ["standard-review", "confirm-each-call", "deny-until-isolated"] },
              "riskLevel": { "enum": ["low-signal", "watch", "elevated", "high", "critical"] },
              "effectiveAnnotations": { "type": "object" },
              "annotationGaps": { "type": "integer", "minimum": 0, "maximum": 4 },
              "capabilities": { "type": "object" },
              "schemaSignals": { "type": "object" },
              "findings": { "type": "array", "items": { "$ref": "#/$defs/finding" } },
              "policy": { "type": "object" }
            }
          }
        }
      }
    },
    "limitations": {
      "type": "object",
      "additionalProperties": false,
      "required": ["annotationsTrusted", "behaviorVerified", "authorizationEnforced", "securityVerdictProduced", "catalogUploadedByAnalyzer", "toolExecutionPerformed"],
      "properties": {
        "annotationsTrusted": { "const": false },
        "behaviorVerified": { "const": false },
        "authorizationEnforced": { "const": false },
        "securityVerdictProduced": { "const": false },
        "catalogUploadedByAnalyzer": { "const": false },
        "toolExecutionPerformed": { "const": false }
      }
    }
  },
  "$defs": {
    "finding": {
      "type": "object",
      "required": ["id", "category", "severity", "evidence", "control"],
      "properties": {
        "id": { "type": "string" },
        "category": { "type": "string" },
        "severity": { "enum": ["critical", "high", "medium", "low"] },
        "evidence": { "type": "string" },
        "control": { "type": "string" }
      }
    }
  }
}
