{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/logbrew/json-schema/logbrew-project-doctor-response-schema.json",
  "title": "ProjectDoctorResponse",
  "description": "Canonical, secret-free readiness summary for one active project.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/logbrew-projects-api-openapi.yml#/components/schemas/ProjectDoctorResponse",
  "properties": {
    "first_telemetry_seen_at": {
      "description": "First telemetry timestamp across supported signal types.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "has_active_ingest_key": {
      "description": "Whether at least one project-scoped ingest key can currently ingest.",
      "type": "boolean"
    },
    "last_seen_at": {
      "description": "Most recent telemetry timestamp across supported signal types.",
      "format": "date-time",
      "type": [
        "string",
        "null"
      ]
    },
    "last_signal": {
      "anyOf": [
        {
          "$ref": "#/$defs/ProjectLastSignalResponse"
        },
        {
          "type": "null"
        }
      ],
      "description": "Most recent display-safe telemetry signal summary."
    },
    "next": {
      "description": "Display-safe recovery or investigation step.",
      "type": "string"
    },
    "next_action": {
      "$ref": "#/$defs/ProjectDoctorNextActionResponse",
      "description": "Stable machine-readable action for clients that should not parse `next`."
    },
    "project_id": {
      "description": "Project identifier whose readiness was checked.",
      "format": "uuid",
      "type": "string"
    },
    "setup_acknowledged": {
      "description": "Whether setup-seen was observed or superseded by real telemetry.",
      "type": "boolean"
    },
    "setup_status": {
      "$ref": "#/$defs/ProjectSetupStatus",
      "description": "Backend-owned setup status."
    },
    "state": {
      "$ref": "#/$defs/ProjectDoctorState",
      "description": "Highest-priority readiness state."
    }
  },
  "required": [
    "project_id",
    "state",
    "setup_status",
    "setup_acknowledged",
    "has_active_ingest_key",
    "first_telemetry_seen_at",
    "last_seen_at",
    "last_signal",
    "next",
    "next_action"
  ],
  "type": "object",
  "$defs": {
    "ProjectDoctorNextActionCode": {
      "description": "Stable action codes returned by project doctor.",
      "oneOf": [
        {
          "const": "create_ingest_key",
          "description": "Create a project-scoped ingest key.",
          "type": "string"
        },
        {
          "const": "choose_setup_path",
          "description": "Choose an SDK, CLI, or API setup path.",
          "type": "string"
        },
        {
          "const": "send_first_telemetry",
          "description": "Send one telemetry event.",
          "type": "string"
        },
        {
          "const": "inspect_recent_telemetry",
          "description": "Inspect recent telemetry.",
          "type": "string"
        }
      ]
    },
    "ProjectDoctorNextActionResponse": {
      "description": "Stable machine-readable project doctor action.",
      "properties": {
        "code": {
          "$ref": "#/$defs/ProjectDoctorNextActionCode",
          "description": "Stable action code."
        },
        "target": {
          "$ref": "#/$defs/ProjectDoctorNextActionTarget",
          "description": "Stable product surface that should handle the action."
        }
      },
      "required": [
        "code",
        "target"
      ],
      "type": "object"
    },
    "ProjectDoctorNextActionTarget": {
      "description": "Stable action targets returned by project doctor.",
      "oneOf": [
        {
          "const": "project_ingest_keys",
          "description": "Project ingest-key management.",
          "type": "string"
        },
        {
          "const": "project_setup",
          "description": "Project setup selection.",
          "type": "string"
        },
        {
          "const": "telemetry_ingest",
          "description": "Telemetry ingestion.",
          "type": "string"
        },
        {
          "const": "telemetry_reads",
          "description": "Authenticated telemetry reads.",
          "type": "string"
        }
      ]
    },
    "ProjectDoctorState": {
      "description": "Canonical project readiness states for humans and agents.",
      "oneOf": [
        {
          "const": "needs_ingest_key",
          "description": "Project needs a currently usable project-scoped ingest key.",
          "type": "string"
        },
        {
          "const": "needs_setup",
          "description": "Project exists but has not selected a setup path.",
          "type": "string"
        },
        {
          "const": "needs_telemetry",
          "description": "Setup is in progress but no telemetry has arrived.",
          "type": "string"
        },
        {
          "const": "ready",
          "description": "Project has a usable key and real telemetry.",
          "type": "string"
        }
      ]
    },
    "ProjectLastSignalResponse": {
      "description": "Most recent telemetry signal summary for setup progress.",
      "properties": {
        "id": {
          "description": "Optional signal identifier.",
          "type": [
            "string",
            "null"
          ]
        },
        "kind": {
          "description": "Telemetry signal kind.",
          "type": "string"
        },
        "message": {
          "description": "Optional display-safe signal message.",
          "type": [
            "string",
            "null"
          ]
        },
        "occurred_at": {
          "description": "Signal occurrence timestamp.",
          "format": "date-time",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "id",
        "message",
        "occurred_at"
      ],
      "type": "object"
    },
    "ProjectSetupStatus": {
      "description": "Canonical setup status for project onboarding.",
      "oneOf": [
        {
          "const": "created",
          "description": "Project exists but no setup path has started.",
          "type": "string"
        },
        {
          "const": "setup_started",
          "description": "User selected a setup path or runtime.",
          "type": "string"
        },
        {
          "const": "sdk_seen",
          "description": "SDK or CLI identity was observed without telemetry.",
          "type": "string"
        },
        {
          "const": "first_telemetry_seen",
          "description": "First telemetry was received.",
          "type": "string"
        },
        {
          "const": "active",
          "description": "Project has active telemetry.",
          "type": "string"
        }
      ]
    }
  }
}