{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://imemory.dev/schemas/project-report/1.0.json",
  "title": "ProjectMind Project Report",
  "description": "Versioned project status report ingested by the ProjectMind Project Reports HTTPS API.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "reportId", "generatedAt", "project"],
  "properties": {
    "schemaVersion": {
      "type": "string",
      "description": "Report schema version. Currently only \"1.0\" is accepted.",
      "const": "1.0"
    },
    "reportId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "description": "Client-generated idempotency key for this report. Prefer UUIDv4.",
      "pattern": "^[A-Za-z0-9._:-]+$"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO-8601 timestamp when the report was generated."
    },
    "project": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "name", "environment", "status"],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "description": "ProjectMind project UUID (or stable external id mapped to a project)."
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "environment": {
          "$ref": "#/$defs/environment"
        },
        "status": {
          "$ref": "#/$defs/projectStatus"
        },
        "slug": {
          "type": "string",
          "maxLength": 128
        },
        "description": {
          "type": "string",
          "maxLength": 4096
        },
        "version": {
          "type": "string",
          "maxLength": 128,
          "description": "Application or release version string."
        },
        "url": {
          "type": "string",
          "maxLength": 2048,
          "description": "Primary public URL for the project."
        }
      }
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "headline": { "type": "string", "maxLength": 512 },
        "body": { "type": "string", "maxLength": 16000 },
        "highlights": {
          "type": "array",
          "maxItems": 50,
          "items": { "type": "string", "maxLength": 512 }
        }
      }
    },
    "health": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "score": {
          "type": "number",
          "minimum": 0,
          "maximum": 100,
          "description": "Optional self-reported health score (0–100). ProjectMind does not compute this."
        },
        "status": { "$ref": "#/$defs/projectStatus" },
        "checkedAt": { "type": "string", "format": "date-time" },
        "components": {
          "type": "array",
          "maxItems": 100,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["name", "status"],
            "properties": {
              "name": { "type": "string", "maxLength": 256 },
              "status": { "$ref": "#/$defs/projectStatus" },
              "message": { "type": "string", "maxLength": 2048 }
            }
          }
        }
      }
    },
    "metrics": {
      "type": "array",
      "maxItems": 500,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["key", "value"],
        "properties": {
          "key": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[A-Za-z0-9._:-]+$"
          },
          "value": { "type": "number" },
          "unit": { "type": "string", "maxLength": 64 },
          "timestamp": { "type": "string", "format": "date-time" },
          "labels": {
            "type": "object",
            "additionalProperties": { "type": "string", "maxLength": 256 },
            "propertyNames": { "maxLength": 64 },
            "maxProperties": 32
          }
        }
      }
    },
    "deployments": {
      "type": "array",
      "maxItems": 100,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "status", "timestamp"],
        "properties": {
          "id": { "type": "string", "minLength": 1, "maxLength": 128 },
          "status": { "$ref": "#/$defs/deploymentStatus" },
          "timestamp": { "type": "string", "format": "date-time" },
          "environment": { "$ref": "#/$defs/environment" },
          "version": { "type": "string", "maxLength": 128 },
          "url": { "type": "string", "maxLength": 2048 },
          "commitSha": { "type": "string", "maxLength": 64 },
          "message": { "type": "string", "maxLength": 2048 }
        }
      }
    },
    "issues": {
      "type": "array",
      "maxItems": 500,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title", "severity"],
        "properties": {
          "id": { "type": "string", "minLength": 1, "maxLength": 128 },
          "title": { "type": "string", "minLength": 1, "maxLength": 512 },
          "severity": { "$ref": "#/$defs/issueSeverity" },
          "status": {
            "type": "string",
            "enum": ["open", "acknowledged", "resolved", "ignored"],
            "default": "open"
          },
          "description": { "type": "string", "maxLength": 8000 },
          "detectedAt": { "type": "string", "format": "date-time" },
          "resolvedAt": { "type": ["string", "null"], "format": "date-time" },
          "source": { "type": "string", "maxLength": 128 },
          "url": { "type": "string", "maxLength": 2048 },
          "category": {
            "$ref": "#/$defs/observationCategory",
            "description": "product → coding loop; relationship_action / financial_insight / financial_action → non-coding workflows only."
          },
          "kind": {
            "type": "string",
            "enum": [
              "follow_up",
              "upcoming_event",
              "overdue_commitment",
              "data_review",
              "other",
              "cash_flow",
              "spend_anomaly",
              "recurring_bill",
              "safe_to_spend",
              "liability",
              "investment",
              "coverage_gap",
              "review_bill",
              "reconnect_account",
              "dispute_charge",
              "cancel_subscription",
              "transfer",
              "payment",
              "trade",
              "apply_credit"
            ],
            "description": "Optional subtype for relationship_action, financial_insight, or financial_action issues."
          },
          "priority": {
            "type": "string",
            "enum": ["low", "medium", "high", "urgent"]
          },
          "dueAt": { "type": "string", "format": "date-time" },
          "personRef": {
            "type": "string",
            "maxLength": 128,
            "description": "Opaque internal person reference. Never a production person record payload."
          },
          "suggestedTaskTitle": { "type": "string", "maxLength": 512 },
          "explanation": { "type": "string", "maxLength": 8000 },
          "insightType": {
            "type": "string",
            "enum": [
              "cash_flow",
              "spend_anomaly",
              "recurring_bill",
              "safe_to_spend",
              "liability",
              "investment",
              "coverage_gap",
              "other"
            ]
          },
          "factKind": {
            "type": "string",
            "enum": ["observed_fact", "inference", "recommendation", "incomplete_data"]
          },
          "coveragePeriodStart": { "type": "string", "format": "date-time" },
          "coveragePeriodEnd": { "type": "string", "format": "date-time" },
          "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
          "supportingDataRef": { "type": "string", "maxLength": 512 },
          "briefingEligible": { "type": "boolean" },
          "voiceEligible": { "type": "boolean" },
          "actionType": {
            "type": "string",
            "enum": [
              "review_bill",
              "reconnect_account",
              "dispute_charge",
              "cancel_subscription",
              "transfer",
              "payment",
              "trade",
              "apply_credit",
              "data_review",
              "other"
            ]
          },
          "supportingInsightRef": { "type": "string", "maxLength": 512 },
          "dataCoverageStatement": { "type": "string", "maxLength": 2000 },
          "estimatedEffect": { "type": "string", "maxLength": 512 },
          "risk": {
            "type": "string",
            "enum": ["low", "medium", "high", "critical"]
          },
          "requiresConfirmation": { "type": "boolean" },
          "deepLink": { "type": "string", "maxLength": 2048 }
        }
      }
    },
    "relationshipActions": {
      "type": "array",
      "maxItems": 500,
      "description": "My People relationship-action candidates. Never enter the coding-agent lifecycle.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title"],
        "properties": {
          "id": { "type": "string", "minLength": 1, "maxLength": 128 },
          "title": { "type": "string", "minLength": 1, "maxLength": 512 },
          "description": { "type": "string", "maxLength": 8000 },
          "suggestedTaskTitle": { "type": "string", "maxLength": 512 },
          "priority": {
            "type": "string",
            "enum": ["low", "medium", "high", "urgent"]
          },
          "dueAt": { "type": "string", "format": "date-time" },
          "personRef": {
            "type": "string",
            "maxLength": 128,
            "description": "Opaque internal person reference only."
          },
          "evidenceRef": { "type": "string", "maxLength": 512 },
          "kind": {
            "type": "string",
            "enum": ["follow_up", "upcoming_event", "overdue_commitment", "data_review", "other"]
          },
          "source": { "type": "string", "maxLength": 128 }
        }
      }
    },
    "financialInsights": {
      "type": "array",
      "maxItems": 500,
      "description": "MoneySprout financial-insight summaries. Aggregated only — never enter the coding-agent lifecycle.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title"],
        "properties": {
          "id": { "type": "string", "minLength": 1, "maxLength": 128 },
          "title": { "type": "string", "minLength": 1, "maxLength": 512 },
          "explanation": { "type": "string", "maxLength": 8000 },
          "insightType": {
            "type": "string",
            "enum": [
              "cash_flow",
              "spend_anomaly",
              "recurring_bill",
              "safe_to_spend",
              "liability",
              "investment",
              "coverage_gap",
              "other"
            ]
          },
          "factKind": {
            "type": "string",
            "enum": ["observed_fact", "inference", "recommendation", "incomplete_data"]
          },
          "coveragePeriodStart": { "type": "string", "format": "date-time" },
          "coveragePeriodEnd": { "type": "string", "format": "date-time" },
          "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
          "supportingDataRef": { "type": "string", "maxLength": 512 },
          "briefingEligible": { "type": "boolean" },
          "voiceEligible": { "type": "boolean" },
          "deepLink": { "type": "string", "maxLength": 2048 },
          "source": { "type": "string", "maxLength": 128 }
        }
      }
    },
    "financialActions": {
      "type": "array",
      "maxItems": 500,
      "description": "MoneySprout financial-action suggestions. Never execute money movement; never enter the coding-agent lifecycle.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title"],
        "properties": {
          "id": { "type": "string", "minLength": 1, "maxLength": 128 },
          "title": { "type": "string", "minLength": 1, "maxLength": 512 },
          "explanation": { "type": "string", "maxLength": 8000 },
          "actionType": {
            "type": "string",
            "enum": [
              "review_bill",
              "reconnect_account",
              "dispute_charge",
              "cancel_subscription",
              "transfer",
              "payment",
              "trade",
              "apply_credit",
              "data_review",
              "other"
            ]
          },
          "supportingInsightRef": { "type": "string", "maxLength": 512 },
          "dataCoverageStatement": { "type": "string", "maxLength": 2000 },
          "estimatedEffect": { "type": "string", "maxLength": 512 },
          "risk": {
            "type": "string",
            "enum": ["low", "medium", "high", "critical"]
          },
          "requiresConfirmation": { "type": "boolean" },
          "deepLink": { "type": "string", "maxLength": 2048 },
          "source": { "type": "string", "maxLength": 128 }
        }
      }
    },
    "capabilities": {
      "type": "array",
      "maxItems": 100,
      "description": "Self-reported project capabilities (e.g. contact-sync, reminders).",
      "items": { "type": "string", "maxLength": 128 }
    },
    "tasks": {
      "type": "array",
      "maxItems": 500,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "title", "status"],
        "properties": {
          "id": { "type": "string", "minLength": 1, "maxLength": 128 },
          "title": { "type": "string", "minLength": 1, "maxLength": 512 },
          "status": { "$ref": "#/$defs/taskStatus" },
          "priority": {
            "type": "string",
            "enum": ["low", "medium", "high", "urgent"]
          },
          "assignee": { "type": "string", "maxLength": 256 },
          "dueAt": { "type": "string", "format": "date-time" },
          "url": { "type": "string", "maxLength": 2048 }
        }
      }
    },
    "agent": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "maxLength": 128 },
        "name": { "type": "string", "maxLength": 256 },
        "kind": {
          "type": "string",
          "enum": [
            "mac-agent",
            "coding-agent",
            "background-worker",
            "mobile-app",
            "saas",
            "ci",
            "other"
          ]
        },
        "version": { "type": "string", "maxLength": 128 },
        "platform": { "type": "string", "maxLength": 128 },
        "hostname": { "type": "string", "maxLength": 256 }
      }
    },
    "links": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "dashboard": { "type": "string", "maxLength": 2048 },
        "repository": { "type": "string", "maxLength": 2048 },
        "docs": { "type": "string", "maxLength": 2048 },
        "logs": { "type": "string", "maxLength": 2048 },
        "extra": {
          "type": "object",
          "additionalProperties": { "type": "string", "maxLength": 2048 },
          "propertyNames": { "maxLength": 64 },
          "maxProperties": 32
        }
      }
    },
    "extensions": {
      "type": "object",
      "description": "Vendor-specific or experimental fields. Unknown keys inside extensions are accepted.",
      "additionalProperties": true
    }
  },
  "$defs": {
    "projectStatus": {
      "type": "string",
      "enum": ["healthy", "degraded", "unhealthy", "unknown", "maintenance"]
    },
    "environment": {
      "type": "string",
      "enum": ["production", "staging", "development", "test", "preview"]
    },
    "issueSeverity": {
      "type": "string",
      "enum": ["critical", "high", "medium", "low", "info"]
    },
    "observationCategory": {
      "type": "string",
      "enum": ["product", "relationship_action", "financial_insight", "financial_action"]
    },
    "taskStatus": {
      "type": "string",
      "enum": ["todo", "in_progress", "blocked", "done", "cancelled"]
    },
    "deploymentStatus": {
      "type": "string",
      "enum": ["pending", "building", "deploying", "success", "failed", "rolled_back", "cancelled"]
    }
  }
}
