{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sealgate-ai/json-schema/sealgate-ai-session-detail-schema.json",
  "title": "SessionDetail",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sealgate-ai-dashboard-openapi.json#/components/schemas/SessionDetail",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id",
      "description": "Session identifier"
    },
    "correlation_id": {
      "type": "string",
      "title": "Correlation Id",
      "description": "Correlation ID linking related events"
    },
    "session_token": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Session Token",
      "description": "SealGate session token the LLM client holds in context for token-based sessions (from builtin_obtain_session_token); null otherwise"
    },
    "user_id": {
      "type": "string",
      "title": "User Id",
      "description": "Authenticated user ID"
    },
    "user_email": {
      "type": "string",
      "title": "User Email",
      "description": "User email address"
    },
    "agent_name": {
      "type": "string",
      "title": "Agent Name",
      "description": "Name of the AI agent"
    },
    "agent_type": {
      "type": "string",
      "title": "Agent Type",
      "description": "Type/category of the agent"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "Session start timestamp"
    },
    "last_activity_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Activity At",
      "description": "Timestamp of the last tool call activity"
    },
    "duration_ms": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Duration Ms",
      "description": "Total session duration in milliseconds"
    },
    "tool_call_count": {
      "type": "integer",
      "title": "Tool Call Count",
      "description": "Number of tool calls in this session"
    },
    "status": {
      "type": "string",
      "title": "Status",
      "description": "Session status (active, completed, error)"
    },
    "trifecta_flags": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Trifecta Flags",
      "description": "Trifecta security flags triggered"
    },
    "trifecta_disposition": {
      "type": "string",
      "title": "Trifecta Disposition",
      "description": "Worst outcome (denied > expired > approved) of any trifecta write gated for approval this session; 'pending' is a transient in-flight state. One of: none, pending, approved, expired, denied",
      "default": "none"
    },
    "trifecta_block_count": {
      "type": "integer",
      "title": "Trifecta Block Count",
      "description": "Number of trifecta writes gated for approval this session",
      "default": 0
    },
    "block_severity": {
      "type": "string",
      "title": "Block Severity",
      "description": "Severity of trifecta blocks for dashboard colouring: none, low, medium, high",
      "default": "none"
    },
    "acl_level": {
      "type": "string",
      "title": "Acl Level",
      "description": "Highest ACL level (PUBLIC, PRIVATE, SECRET)",
      "default": "PUBLIC"
    },
    "tool_names": {
      "items": {
        "type": "string"
      },
      "type": "array",
      "title": "Tool Names",
      "description": "Distinct tool names invoked in this session"
    },
    "tool_calls": {
      "items": {
        "$ref": "#/$defs/ToolCallSchema"
      },
      "type": "array",
      "title": "Tool Calls",
      "description": "Ordered list of tool calls in this session"
    },
    "data_access_summary": {
      "additionalProperties": true,
      "type": "object",
      "title": "Data Access Summary",
      "description": "Summary of data access patterns during session"
    },
    "risk_analysis": {
      "items": {
        "$ref": "#/$defs/RiskAnalysisEntry"
      },
      "type": "array",
      "title": "Risk Analysis",
      "description": "History of trifecta block analyses (the approval-popup explanations)"
    }
  },
  "type": "object",
  "required": [
    "id",
    "correlation_id",
    "user_id",
    "user_email",
    "agent_name",
    "agent_type",
    "created_at",
    "tool_call_count",
    "status",
    "trifecta_flags",
    "tool_calls",
    "data_access_summary"
  ],
  "$defs": {
    "RiskAnalysisEntry": {
      "properties": {
        "timestamp": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Timestamp",
          "description": "When the block fired"
        },
        "kind": {
          "type": "string",
          "title": "Kind",
          "description": "Element kind: tool, resource, or prompt",
          "default": "tool"
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "Prefixed name of the blocked element",
          "default": ""
        },
        "reason": {
          "type": "string",
          "title": "Reason",
          "description": "Block reason, e.g. trifecta or trifecta_prevent",
          "default": ""
        },
        "risk": {
          "$ref": "#/$defs/RiskInfo",
          "description": "The plain-language risk explanation"
        }
      },
      "type": "object",
      "required": [
        "risk"
      ],
      "title": "RiskAnalysisEntry",
      "description": "One trifecta block's analysis, as persisted in the session history."
    },
    "RiskInfo": {
      "properties": {
        "title": {
          "type": "string",
          "title": "Title",
          "description": "Short action description, e.g. 'Agent wants to send email'",
          "default": ""
        },
        "headline": {
          "type": "string",
          "title": "Headline",
          "description": "One-line risk headline",
          "default": ""
        },
        "summary": {
          "type": "string",
          "title": "Summary",
          "description": "Plain-language explanation of why this was risky",
          "default": ""
        },
        "legs": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "string"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Legs",
          "description": "Trifecta legs (private/untrusted/external) with their sources"
        },
        "server_name": {
          "type": "string",
          "title": "Server Name",
          "description": "Server the blocked element belongs to",
          "default": ""
        },
        "acl_level": {
          "type": "string",
          "title": "Acl Level",
          "description": "Highest ACL level touched this session",
          "default": ""
        },
        "risk_level": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Risk Level",
          "description": "Severity: low, medium, high, or critical"
        },
        "policy_rule": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Policy Rule",
          "description": "Name of the policy rule that required approval (policy_approval blocks only)"
        },
        "source": {
          "type": "string",
          "title": "Source",
          "description": "How the summary was produced: template or llm",
          "default": "template"
        }
      },
      "type": "object",
      "title": "RiskInfo",
      "description": "Plain-language risk explanation for a blocked action (matches the SSE risk block)."
    },
    "ToolCallSchema": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id",
          "description": "Unique tool call identifier"
        },
        "tool_name": {
          "type": "string",
          "title": "Tool Name",
          "description": "Name of the MCP tool invoked"
        },
        "parameters": {
          "additionalProperties": true,
          "type": "object",
          "title": "Parameters",
          "description": "Parameters passed to the tool"
        },
        "timestamp": {
          "type": "string",
          "format": "date-time",
          "title": "Timestamp",
          "description": "When the tool call was made"
        },
        "duration_ms": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Duration Ms",
          "description": "Execution time in milliseconds"
        },
        "status": {
          "type": "string",
          "title": "Status",
          "description": "Outcome status (e.g. success, blocked, error)"
        },
        "result": {
          "anyOf": [
            {},
            {
              "type": "null"
            }
          ],
          "title": "Result",
          "description": "Tool call result payload"
        },
        "block_reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Block Reason",
          "description": "Which gate refused a blocked call: policy_block, policy_approval, trifecta, trifecta_prevent, acl_downgrade, disabled, approval_egress, lease or quota. Null when not blocked or not recorded."
        },
        "read_private_data": {
          "type": "boolean",
          "title": "Read Private Data",
          "description": "Tool reads private/sensitive data",
          "default": false
        },
        "read_untrusted_public_data": {
          "type": "boolean",
          "title": "Read Untrusted Public Data",
          "description": "Tool reads untrusted external data",
          "default": false
        },
        "write_operation": {
          "type": "boolean",
          "title": "Write Operation",
          "description": "Tool performs external communication/write",
          "default": false
        },
        "acl": {
          "type": "string",
          "title": "Acl",
          "description": "Tool ACL level (PUBLIC, PRIVATE, SECRET)",
          "default": "PUBLIC"
        }
      },
      "type": "object",
      "required": [
        "id",
        "tool_name",
        "parameters",
        "timestamp",
        "status"
      ],
      "title": "ToolCallSchema"
    }
  }
}