{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/rulebase/main/json-schema/rulebase-practice-simulation-attempt-schema.json",
  "title": "PracticeSimulationAttempt",
  "x-generated": "2026-10-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/rulebase-openapi.json#/components/schemas/PracticeSimulationAttempt",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "simulation_id": {
      "type": "string"
    },
    "version": {
      "type": "integer"
    },
    "kind": {
      "type": "string",
      "enum": [
        "assignment",
        "test_run"
      ]
    },
    "assignment_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "agent_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "in_progress",
        "paused",
        "completed",
        "expired"
      ]
    },
    "started_at": {
      "type": "string"
    },
    "paused_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "ended_at": {
      "type": [
        "string",
        "null"
      ]
    },
    "active_seconds": {
      "type": "integer"
    },
    "time_limit_seconds": {
      "type": "integer"
    },
    "brief": {
      "type": "string"
    },
    "log": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "inject",
              "persona",
              "quiet",
              "pause",
              "resume",
              "error",
              "scorecard",
              "summary"
            ]
          },
          "at": {
            "type": "number"
          },
          "rule": {
            "type": "string"
          },
          "persona": {
            "type": "string"
          },
          "app": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "pausedSeconds": {
            "type": "number"
          },
          "error": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "scripted",
              "model"
            ]
          },
          "fallback": {
            "type": "string"
          },
          "patience": {
            "type": "number"
          },
          "band": {
            "type": "string",
            "enum": [
              "patient",
              "strained",
              "frustrated",
              "done"
            ]
          },
          "trackerError": {
            "type": "string"
          },
          "reason": {
            "type": "string",
            "enum": [
              "walked_away",
              "satisfied",
              "chose_silence"
            ]
          },
          "merged": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "type",
          "at"
        ]
      }
    },
    "grade": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "milestones": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "met": {
                "type": "boolean"
              },
              "at": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "title",
              "met"
            ]
          }
        },
        "prohibitedActions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "happened": {
                "type": "boolean"
              },
              "at": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "title",
              "happened"
            ]
          }
        },
        "milestonesMet": {
          "type": "integer"
        },
        "allMilestonesMet": {
          "type": "boolean"
        },
        "anyProhibited": {
          "type": "boolean"
        },
        "worldStartedAt": {
          "type": "string"
        }
      },
      "required": [
        "milestones",
        "prohibitedActions",
        "milestonesMet",
        "allMilestonesMet",
        "anyProhibited"
      ]
    },
    "scorecard_score": {
      "type": [
        "number",
        "null"
      ]
    },
    "scorecard_results": {
      "$ref": "#/$defs/PracticeScorecardResults"
    },
    "scorecard_not_scored_reason": {
      "type": [
        "string",
        "null"
      ]
    },
    "passed": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "debrief_summary": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "second_person": {
          "type": "string"
        },
        "third_person": {
          "type": "string"
        },
        "missed_milestones": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              },
              "at": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "id",
              "reason",
              "at"
            ]
          }
        }
      },
      "required": [
        "second_person",
        "third_person"
      ]
    },
    "grading": {
      "type": "object",
      "properties": {
        "milestones": {
          "type": "string",
          "enum": [
            "pending",
            "done",
            "failed"
          ]
        },
        "scorecard": {
          "type": "string",
          "enum": [
            "pending",
            "done",
            "failed"
          ]
        },
        "summary": {
          "type": "string",
          "enum": [
            "pending",
            "done",
            "failed"
          ]
        }
      },
      "required": [
        "milestones",
        "scorecard",
        "summary"
      ]
    },
    "app_urls": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "string"
      }
    },
    "app_labels": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "shell_url": {
      "type": [
        "string",
        "null"
      ]
    },
    "simulation_title": {
      "type": "string"
    },
    "pass_mark": {
      "type": "integer"
    },
    "agent_name": {
      "type": [
        "string",
        "null"
      ]
    },
    "assigned_by_name": {
      "type": [
        "string",
        "null"
      ]
    },
    "focus": {
      "type": [
        "string",
        "null"
      ]
    },
    "apps": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "url": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "title",
          "url"
        ]
      }
    },
    "attempt_number": {
      "type": [
        "integer",
        "null"
      ]
    },
    "max_attempts": {
      "type": [
        "integer",
        "null"
      ]
    },
    "assignment_attempts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "number": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "in_progress",
              "paused",
              "completed",
              "expired"
            ]
          }
        },
        "required": [
          "id",
          "number",
          "status"
        ]
      }
    }
  },
  "required": [
    "id",
    "simulation_id",
    "version",
    "kind",
    "assignment_id",
    "agent_id",
    "status",
    "started_at",
    "paused_at",
    "ended_at",
    "active_seconds",
    "time_limit_seconds",
    "brief",
    "log",
    "grade",
    "scorecard_score",
    "scorecard_results",
    "scorecard_not_scored_reason",
    "passed",
    "debrief_summary",
    "grading",
    "app_urls",
    "app_labels",
    "shell_url",
    "simulation_title",
    "pass_mark",
    "agent_name",
    "assigned_by_name",
    "focus",
    "apps",
    "sources",
    "attempt_number",
    "max_attempts",
    "assignment_attempts"
  ],
  "$defs": {
    "PracticeScorecardResults": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "scorecardId": {
          "type": "string"
        },
        "scorecardName": {
          "type": "string"
        },
        "score": {
          "type": "integer"
        },
        "scoreCapReason": {
          "type": "string"
        },
        "criteria": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "parentName": {
                "type": "string"
              },
              "optionLabel": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "result": {
                "type": "string",
                "enum": [
                  "pass",
                  "partial",
                  "fail",
                  "auto_fail",
                  "not_applicable"
                ]
              },
              "score": {
                "type": "number"
              },
              "maxScore": {
                "type": "number"
              },
              "reason": {
                "type": "string"
              },
              "citations": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "commentId": {
                      "type": "string"
                    },
                    "at": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "commentId",
                    "at"
                  ]
                }
              }
            },
            "required": [
              "id",
              "name",
              "optionLabel",
              "result",
              "score",
              "maxScore",
              "reason"
            ]
          }
        }
      },
      "required": [
        "scorecardId",
        "scorecardName",
        "score",
        "criteria"
      ]
    }
  }
}