{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://whychose.com/extractor/schema.json",
  "title": "DecisionRecord",
  "description": "A single decision surfaced from an AI-assistant chat transcript. The whole point of WhyChose is that this is the durable artifact — not the transcript it was distilled from.",
  "type": "object",
  "required": ["id", "date", "source", "question", "chosen", "snippet"],
  "properties": {
    "id": {
      "type": "string",
      "description": "Stable, content-derived id. Format: `<source>-<yyyymmdd>-<short-hash>`. Stable across re-runs on the same export."
    },
    "date": {
      "type": "string",
      "format": "date",
      "description": "ISO-8601 date the decision was committed to (when the `chosen` message appeared). Local-tz-stripped — the record is a durable artifact, not a precise timestamp."
    },
    "source": {
      "type": "string",
      "enum": ["chatgpt", "claude", "unknown"],
      "description": "Export source the record was extracted from."
    },
    "chat_title": {
      "type": "string",
      "description": "Title the chat platform gave the conversation (ChatGPT auto-titles; Claude uses the first user message)."
    },
    "chat_url": {
      "type": "string",
      "format": "uri",
      "description": "Deep-link back to the original conversation if the export includes one. ChatGPT exports do NOT include public URLs by default; Claude archives sometimes do. Absent when unavailable."
    },
    "question": {
      "type": "string",
      "description": "The decision question, paraphrased from the user's first prompt that triggered the decision thread. ≤ 140 chars."
    },
    "chosen": {
      "type": "string",
      "description": "The option the user committed to. Taken from the commit-language sentence (e.g. \"I'll go with X\" → chosen: X)."
    },
    "rejected": {
      "type": "array",
      "items": {"type": "string"},
      "description": "Options considered but not chosen. Often 1, sometimes 2-3."
    },
    "trade_offs": {
      "type": "array",
      "description": "Pro/con pairs the user worked through before committing. Often empty for quick decisions.",
      "items": {
        "type": "object",
        "required": ["option"],
        "properties": {
          "option": {"type": "string"},
          "pro": {"type": "string"},
          "con": {"type": "string"}
        }
      }
    },
    "confidence": {
      "type": "string",
      "enum": ["low", "medium", "high"],
      "description": "Extractor's confidence that this is actually a decision, not scratch thinking. `high` = explicit commit language + trade-off detected; `medium` = commit language only; `low` = question-shape only, no clear commit."
    },
    "snippet": {
      "type": "string",
      "description": "The ~3-sentence excerpt around the commit, verbatim from the export. Enough context to re-derive the decision without re-opening the original transcript."
    },
    "tags": {
      "type": "array",
      "items": {"type": "string"},
      "description": "Auto-tags derived from content (e.g. [\"architecture\", \"database\", \"pricing\"]). Heuristic keyword match."
    }
  },
  "additionalProperties": false
}
