{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "ace://schemas/runtime-executor-session-registry/1.0.0",
  "title": "ACE Runtime Executor Session Registry",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "version",
    "updated_at",
    "sessions"
  ],
  "properties": {
    "version": {
      "type": "integer",
      "const": 1
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "sessions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/session"
      }
    }
  },
  "$defs": {
    "tool_call": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "tool_name",
        "ok",
        "summary",
        "request_path",
        "response_path",
        "started_at",
        "ended_at"
      ],
      "properties": {
        "tool_name": {
          "type": "string",
          "minLength": 1
        },
        "ok": {
          "type": "boolean"
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "request_path": {
          "type": "string",
          "minLength": 1
        },
        "response_path": {
          "type": "string",
          "minLength": 1
        },
        "started_at": {
          "type": "string",
          "format": "date-time"
        },
        "ended_at": {
          "type": "string",
          "format": "date-time"
        },
        "output": {},
        "error": {},
        "validation_errors": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "turn": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "turn_number",
        "task",
        "started_at",
        "ended_at",
        "status",
        "response_status",
        "summary",
        "prompt_path",
        "request_path",
        "response_path",
        "exit_code",
        "stdout",
        "stderr",
        "tool_calls"
      ],
      "properties": {
        "turn_number": {
          "type": "integer",
          "minimum": 1
        },
        "task": {
          "type": "string",
          "minLength": 1
        },
        "started_at": {
          "type": "string",
          "format": "date-time"
        },
        "ended_at": {
          "type": "string",
          "format": "date-time"
        },
        "status": {
          "type": "string",
          "enum": [
            "completed",
            "failed",
            "blocked",
            "stopped"
          ]
        },
        "response_status": {
          "type": "string",
          "enum": [
            "continue",
            "done",
            "blocked",
            "failed"
          ]
        },
        "summary": {
          "type": "string",
          "minLength": 1
        },
        "prompt_path": {
          "type": "string",
          "minLength": 1
        },
        "request_path": {
          "type": "string",
          "minLength": 1
        },
        "response_path": {
          "type": "string",
          "minLength": 1
        },
        "exit_code": {
          "type": [
            "integer",
            "null"
          ]
        },
        "stdout": {
          "type": "string"
        },
        "stderr": {
          "type": "string"
        },
        "tool_calls": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/tool_call"
          }
        }
      }
    },
    "session": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "session_id",
        "status",
        "task",
        "current_task",
        "runtime_profile_path",
        "workspace_session_id",
        "workspace_path",
        "command",
        "max_turns",
        "turn_timeout_ms",
        "turn_count",
        "created_at",
        "updated_at",
        "workspace_cleanup_status",
        "turns"
      ],
      "properties": {
        "session_id": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "enum": [
            "starting",
            "running",
            "completed",
            "failed",
            "blocked",
            "stopped"
          ]
        },
        "task": {
          "type": "string",
          "minLength": 1
        },
        "current_task": {
          "type": "string",
          "minLength": 1
        },
        "runtime_profile_path": {
          "type": "string",
          "minLength": 1
        },
        "workspace_session_id": {
          "type": "string",
          "minLength": 1
        },
        "workspace_path": {
          "type": "string",
          "minLength": 1
        },
        "objective_id": {
          "type": "string"
        },
        "tracker_item_id": {
          "type": "string"
        },
        "command": {
          "type": "string",
          "minLength": 1
        },
        "max_turns": {
          "type": "integer",
          "minimum": 1
        },
        "turn_timeout_ms": {
          "type": "integer",
          "minimum": 1
        },
        "turn_count": {
          "type": "integer",
          "minimum": 0
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        },
        "started_at": {
          "type": "string",
          "format": "date-time"
        },
        "ended_at": {
          "type": "string",
          "format": "date-time"
        },
        "result_summary": {
          "type": "string"
        },
        "last_error": {
          "type": "string"
        },
        "cleanup_error": {
          "type": "string"
        },
        "workspace_cleanup_status": {
          "type": "string",
          "enum": [
            "pending",
            "removed",
            "archived",
            "failed"
          ]
        },
        "turns": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/turn"
          }
        }
      }
    }
  }
}
