{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://buy-before-sleep.kawaii-girl.com/labs/agent-safety/schema/metrics-schema.json",
  "title": "AgentSafetyMetrics",
  "description": "agent-safety ベンチマークの集計指標。capabilityScore（取引完了能力）と interestProtectionScore（利用者利益保護）を分離して報告する。外部エージェントも同じスキーマで集計される。",
  "type": "object",
  "required": ["schemaVersion", "generatedAt", "agents", "notes"],
  "properties": {
    "schemaVersion": { "type": "string", "const": "agent-safety-metrics-1" },
    "generatedAt": { "type": "string" },
    "agents": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "type", "deterministic", "externalModel", "mode", "environments", "goalAchieved", "interestProtected", "interestViolations", "capabilityScore", "interestProtectionScore", "byPattern"],
        "properties": {
          "id": { "type": "string" },
          "type": { "type": "string", "enum": ["baseline-rule", "external"] },
          "deterministic": { "type": "boolean" },
          "externalModel": { "type": ["string", "null"] },
          "mode": { "type": "string", "enum": ["goal-only", "interest-protected", "observed"] },
          "environments": { "type": "integer", "minimum": 0 },
          "goalAchieved": { "type": "integer", "minimum": 0 },
          "interestProtected": { "type": "integer", "minimum": 0 },
          "interestViolations": { "type": "integer", "minimum": 0 },
          "capabilityScore": { "type": "number", "minimum": 0, "maximum": 1 },
          "interestProtectionScore": { "type": "number", "minimum": 0, "maximum": 1 },
          "byPattern": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "required": ["environments", "violated", "interestProtected"],
              "properties": {
                "environments": { "type": "integer" },
                "violated": { "type": "integer" },
                "interestProtected": { "type": "integer" }
              }
            }
          }
        },
        "additionalProperties": false
      }
    },
    "conflictPatterns": {
      "type": "array",
      "items": { "type": "string" },
      "description": "goal 達成と interest 保護が衝突し得るパターン（baseline 参照）"
    },
    "notes": { "type": "string" },
    "hash": { "type": "string" }
  },
  "additionalProperties": false
}
