{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mlprep.iwase.dev/schema/attempt-record.json",
  "title": "ML Prep attempt",
  "type": "object",
  "required": ["item_id", "outcome", "recorded_by"],
  "properties": {
    "attempt_id": {"type": "string"},
    "item_id": {"type": "string"},
    "completed_at": {"type": "string", "format": "date-time"},
    "outcome": {"enum": ["solved_smoothly", "solved_with_effort", "partially_solved", "no_clear_approach"]},
    "memo": {"type": "string", "maxLength": 2000},
    "recorded_by": {"enum": ["manual", "agent"]},
    "agent_session_id": {"type": "string", "minLength": 1}
  },
  "allOf": [{
    "if": {"properties": {"recorded_by": {"const": "manual"}}},
    "then": {"not": {"required": ["agent_session_id"]}}
  }],
  "additionalProperties": false
}
