{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Watchtower Inbox Item",
  "type": "object",
  "required": [
    "schema_version", "id", "project", "project_path", "filed_at",
    "filed_by", "status", "enrichment_status", "category", "urgency",
    "title", "summary", "context_anchor"
  ],
  "properties": {
    "schema_version": { "const": 1 },
    "id": {
      "type": "string",
      "pattern": "^dec-[0-9a-f]{8}$"
    },
    "project": { "type": "string" },
    "project_path": { "type": "string" },
    "project_unresolved": {
      "type": "boolean",
      "default": false,
      "description": "Set when the canonical resolver could not derive a project identity for the filing path — `project` is a basename fallback, not a config key. Fail-loud marker: /inbox groups these under an explicit unresolved section. Additive; absent on items filed before 2026-06."
    },
    "desk": {
      "type": "string",
      "description": "mux desk (tmux session) name at filing time, when filed from a mux context. Display metadata only — never a grouping key (that's `project`). Additive; absent on pre-2026-06 items."
    },
    "filed_at": { "type": "string", "format": "date-time" },
    "filed_by": {
      "type": "string",
      "enum": ["ring1", "ring3-close", "ring2-fast", "ring2-slow", "manual", "pane-close"]
    },
    "status": {
      "type": "string",
      "enum": ["pending", "resolved", "expired", "superseded", "dismissed"]
    },
    "enrichment_status": {
      "type": "string",
      "enum": ["bare", "in-progress", "complete"]
    },
    "category": {
      "type": "string",
      "enum": [
        "deferred-trigger", "routing-decision", "knowledge-extraction", "methodology-capture",
        "upstream-friction", "project-completion", "completion-review", "branch-diverged",
        "stale-project", "pattern-promotion", "watchtower-health", "worktree-unmerged",
        "qa-handoff", "routine", "advisor-finding"
      ]
    },
    "urgency": {
      "type": "string",
      "enum": ["urgent", "normal", "low"]
    },
    "confidence": {
      "type": ["string", "null"],
      "enum": ["high", "medium", "low", null],
      "default": null,
      "description": "Filer's confidence in the signal (e.g. Ring 3 completion-review). Top-level per design doc; feeds the trust ladder."
    },
    "title": { "type": "string" },
    "summary": { "type": "string" },
    "context_anchor": { "type": "string" },
    "evidence": { "type": "object", "default": {} },
    "options": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["key", "label"],
        "properties": {
          "key": { "type": "string" },
          "label": { "type": "string" },
          "description": { "type": "string" }
        }
      }
    },
    "draft_artifact": { "type": ["string", "null"], "default": null },
    "transcript_ref": {
      "type": ["object", "null"],
      "default": null,
      "properties": {
        "path": { "type": "string" },
        "line_range": {
          "type": "array",
          "items": { "type": "integer" },
          "minItems": 2,
          "maxItems": 2
        }
      }
    },
    "plan_fid": {
      "type": ["string", "null"],
      "default": null,
      "description": "pib-db plan/action fid this item relates to, when known at filing time."
    },
    "thread_ids": {
      "type": "array",
      "items": { "type": "string" },
      "default": [],
      "description": "Thread slugs (state/threads/) the originating session touched. Populated by Ring 3 close."
    },
    "enrichment_dir": {
      "type": ["string", "null"],
      "default": null,
      "description": "Absent (not just null) on items filed before this field existed (pre-2026-06 ring1 items) — readers must tolerate both."
    },
    "resolved_at": { "type": ["string", "null"], "format": "date-time", "default": null },
    "resolution": { "type": ["string", "null"], "default": null },
    "resolution_type": {
      "type": ["string", "null"],
      "enum": ["captured-to-memory", "stale", "noise", "acted-on", "deferred", null],
      "default": null,
      "description": "Normalized resolution outcome for trust-ladder keep/dismiss ratios. Sibling to free-text resolution, set at resolve/dismiss time."
    },
    "resolution_notes": { "type": ["string", "null"], "default": null }
  }
}
