{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://display.greatruth.cloud/data/schemas/mcp-synthetic-traces.schema.json",
  "title": "GreaTruth MCP Synthetic Trajectory Display Sample",
  "type": "object",
  "required": [
    "schema_version",
    "dataset_id",
    "aggregate",
    "services",
    "tasks"
  ],
  "properties": {
    "schema_version": {
      "const": "1.0"
    },
    "dataset_id": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "source_archive": {
      "type": "string"
    },
    "source_updated_at": {
      "type": "string",
      "format": "date"
    },
    "model": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "clients": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "aggregate": {
      "$ref": "#/$defs/aggregate"
    },
    "services": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/serviceAggregate"
      }
    },
    "tasks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/task"
      }
    }
  },
  "$defs": {
    "aggregate": {
      "type": "object",
      "required": [
        "trajectory_count",
        "passed_trajectories",
        "configured_mcp_services",
        "model_calls",
        "mcp_calls",
        "evaluation_checks",
        "output_count"
      ],
      "additionalProperties": {
        "type": [
          "number",
          "object"
        ]
      }
    },
    "serviceAggregate": {
      "type": "object",
      "required": [
        "name",
        "task_count",
        "calls",
        "successes",
        "failures"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "task_count": {
          "type": "integer",
          "minimum": 0
        },
        "calls": {
          "type": "integer",
          "minimum": 0
        },
        "successes": {
          "type": "integer",
          "minimum": 0
        },
        "failures": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "workspaceFile": {
      "type": "object",
      "required": [
        "path",
        "bytes"
      ],
      "properties": {
        "path": {
          "type": "string"
        },
        "bytes": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "workspaceState": {
      "type": "object",
      "required": [
        "file_count",
        "files"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "captured_at": {
          "type": "string",
          "format": "date-time"
        },
        "file_count": {
          "type": "integer",
          "minimum": 0
        },
        "files": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/workspaceFile"
          }
        }
      },
      "additionalProperties": false
    },
    "serviceUsage": {
      "type": "object",
      "required": [
        "name",
        "runtime_tools",
        "calls",
        "successes",
        "failures",
        "used"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "safe_test_tools": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "runtime_tools": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "calls": {
          "type": "integer",
          "minimum": 0
        },
        "successes": {
          "type": "integer",
          "minimum": 0
        },
        "failures": {
          "type": "integer",
          "minimum": 0
        },
        "used": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "evaluationCheck": {
      "type": "object",
      "required": [
        "name",
        "passed"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "passed": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "mcpCall": {
      "type": "object",
      "required": [
        "index",
        "server",
        "tool",
        "status",
        "input"
      ],
      "properties": {
        "index": {
          "type": "integer",
          "minimum": 1
        },
        "model_call_index": {
          "type": "integer",
          "minimum": 1
        },
        "timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "completed_at": {
          "type": "string",
          "format": "date-time"
        },
        "duration_ms": {
          "type": "integer",
          "minimum": 0
        },
        "server": {
          "type": "string"
        },
        "tool": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "recovered": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "input": {},
        "result_preview": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "trajectoryTurn": {
      "type": "object",
      "required": [
        "index",
        "agent",
        "tools",
        "usage"
      ],
      "properties": {
        "index": {
          "type": "integer",
          "minimum": 1
        },
        "timestamp": {
          "type": "string",
          "format": "date-time"
        },
        "completed_at": {
          "type": "string",
          "format": "date-time"
        },
        "duration_ms": {
          "type": "integer",
          "minimum": 0
        },
        "agent": {
          "type": "string"
        },
        "stop_reason": {
          "type": "string"
        },
        "response_preview": {
          "type": "string"
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "usage": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "additionalProperties": false
    },
    "task": {
      "type": "object",
      "required": [
        "id",
        "title_zh",
        "scenario",
        "prompt",
        "metrics",
        "environment",
        "evaluation",
        "service_usage",
        "mcp_calls",
        "trajectory"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "title_zh": {
          "type": "string"
        },
        "scenario": {
          "type": "string"
        },
        "scenario_label": {
          "type": "string"
        },
        "prompt": {
          "type": "string"
        },
        "prompt_zh": {
          "type": "string",
          "description": "Complete Chinese reading translation; prompt retains the source text."
        },
        "client": {
          "type": "string"
        },
        "model": {
          "type": "string"
        },
        "started_at": {
          "type": "string",
          "format": "date-time"
        },
        "completed_at": {
          "type": "string",
          "format": "date-time"
        },
        "duration_seconds": {
          "type": "number",
          "minimum": 0
        },
        "metrics": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "environment": {
          "type": "object",
          "required": [
            "initial",
            "final",
            "delta",
            "mcp_catalog"
          ],
          "properties": {
            "task_meta": {
              "type": "object"
            },
            "local_tools": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "required_mcp_services": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "initial": {
              "$ref": "#/$defs/workspaceState"
            },
            "final": {
              "$ref": "#/$defs/workspaceState"
            },
            "delta": {
              "type": "object",
              "required": [
                "added",
                "deleted",
                "modified"
              ],
              "additionalProperties": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "mcp_catalog": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/serviceUsage"
              }
            }
          },
          "additionalProperties": false
        },
        "evaluation": {
          "type": "object",
          "required": [
            "passed",
            "checks",
            "mcp_failures",
            "unexpected_tools",
            "outputs"
          ],
          "properties": {
            "passed": {
              "type": "boolean"
            },
            "checks": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/evaluationCheck"
              }
            },
            "errors": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "mcp_failures": {
              "type": "object"
            },
            "unexpected_tools": {
              "type": "object"
            },
            "semantic_quality": {
              "type": "array"
            },
            "outputs": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "path",
                  "checks"
                ]
              }
            }
          },
          "additionalProperties": false
        },
        "service_usage": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/serviceUsage"
          }
        },
        "mcp_calls": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/mcpCall"
          }
        },
        "trajectory": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/trajectoryTurn"
          }
        },
        "title_en": {
          "type": "string"
        },
        "scenario_label_en": {
          "type": "string"
        }
      },
      "additionalProperties": false
    }
  }
}
