{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://imemory.dev/schemas/imemory-project-manifest/1.0.json",
  "title": "ProjectMind Project Manifest",
  "description": "Versioned imemory.project.yaml schema. Canonical runtime validation lives in @imemory/improvement-contracts. Unknown top-level properties are rejected except under extensions.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "project",
    "repository",
    "commands",
    "deployment",
    "agent",
    "protectedPaths",
    "verification"
  ],
  "properties": {
    "schemaVersion": {
      "const": "1.0",
      "description": "Manifest schema version. Unsupported versions are rejected."
    },
    "project": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "name", "stage"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "name": { "type": "string", "minLength": 1 },
        "domain": { "type": "string", "minLength": 1 },
        "stage": { "type": "string", "minLength": 1 },
        "description": { "type": "string" },
        "defaultEnvironment": { "type": "string", "minLength": 1 }
      }
    },
    "repository": {
      "type": "object",
      "additionalProperties": false,
      "required": ["defaultBranch"],
      "properties": {
        "provider": { "type": "string", "minLength": 1 },
        "owner": { "type": "string", "minLength": 1 },
        "name": { "type": "string", "minLength": 1 },
        "defaultBranch": { "type": "string", "minLength": 1 }
      }
    },
    "commands": {
      "type": "object",
      "additionalProperties": false,
      "required": ["install", "lint", "typecheck", "test", "build", "smokeTest"],
      "properties": {
        "install": { "type": "string", "minLength": 1 },
        "lint": { "type": "string", "minLength": 1 },
        "typecheck": { "type": "string", "minLength": 1 },
        "test": { "type": "string", "minLength": 1 },
        "build": { "type": "string", "minLength": 1 },
        "smokeTest": { "type": "string", "minLength": 1 }
      }
    },
    "deployment": {
      "type": "object",
      "additionalProperties": false,
      "required": ["provider", "previewEnabled"],
      "properties": {
        "provider": { "type": "string", "minLength": 1 },
        "previewEnabled": { "type": "boolean" },
        "project": { "type": "string", "minLength": 1 },
        "projectId": { "type": "string", "minLength": 1 }
      }
    },
    "capabilities": {
      "type": "object",
      "additionalProperties": false,
      "description": "Explicit capability flags. Omitted keys do not override legacy/report/default sources.",
      "properties": {
        "health": { "type": "boolean" },
        "metrics": { "type": "boolean" },
        "observations": { "type": "boolean" },
        "propositionCandidates": { "type": "boolean" },
        "outcomeMetrics": { "type": "boolean" },
        "deployments": { "type": "boolean" },
        "vercelLogs": { "type": "boolean" },
        "codingExecution": { "type": "boolean" },
        "previewVerification": { "type": "boolean" },
        "financialInsights": { "type": "boolean" },
        "financialActions": { "type": "boolean" },
        "operationalActions": { "type": "boolean" }
      }
    },
    "reporting": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "schemaVersion": { "type": "string", "minLength": 1 },
        "intervalMinutes": { "type": "integer", "exclusiveMinimum": 0 }
      }
    },
    "agent": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "instructionsFile",
        "maxChangedFiles",
        "maxDiffLines",
        "allowDependencyChanges",
        "allowDatabaseMigrations",
        "allowProductionDeployment"
      ],
      "properties": {
        "instructionsFile": { "type": "string", "minLength": 1 },
        "maxChangedFiles": { "type": "integer", "exclusiveMinimum": 0 },
        "maxDiffLines": { "type": "integer", "exclusiveMinimum": 0 },
        "allowDependencyChanges": { "type": "boolean" },
        "allowDatabaseMigrations": { "type": "boolean" },
        "allowProductionDeployment": { "type": "boolean" }
      }
    },
    "categories": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "executable": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "product",
              "platform_reliability",
              "test_coverage",
              "documentation",
              "operational_action",
              "user_action",
              "relationship_action",
              "financial_insight",
              "financial_action",
              "security_action",
              "policy_change",
              "credential_change",
              "audit_change",
              "destructive_data_change",
              "production_deployment",
              "external_communication",
              "data_review"
            ]
          }
        },
        "nonExecutable": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "product",
              "platform_reliability",
              "test_coverage",
              "documentation",
              "operational_action",
              "user_action",
              "relationship_action",
              "financial_insight",
              "financial_action",
              "security_action",
              "policy_change",
              "credential_change",
              "audit_change",
              "destructive_data_change",
              "production_deployment",
              "external_communication",
              "data_review"
            ]
          }
        }
      }
    },
    "protectedPaths": {
      "type": "array",
      "minItems": 1,
      "items": { "type": "string", "minLength": 1 }
    },
    "verification": {
      "type": "object",
      "additionalProperties": false,
      "required": ["required"],
      "properties": {
        "required": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "enum": ["lint", "typecheck", "test", "build", "smokeTest"]
          }
        },
        "profile": {
          "type": "string",
          "minLength": 1,
          "description": "Named verification profile (e.g. finance-v1). Not a project name."
        }
      }
    },
    "autonomy": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "template": {
          "type": "string",
          "enum": [
            "observe-only",
            "propose-only",
            "manual-execution",
            "safe-pull-request",
            "low-risk-autonomous",
            "finance-safe",
            "privacy-sensitive"
          ]
        },
        "overrides": {
          "type": "object",
          "additionalProperties": true
        }
      }
    },
    "outcomes": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "supported": { "type": "boolean" },
        "defaultEvaluationWindow": { "type": "string", "minLength": 1 }
      }
    },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "node": { "type": "string" },
        "packageManager": { "type": "string" },
        "notes": { "type": "string" }
      }
    },
    "extensions": {
      "type": "object",
      "additionalProperties": true,
      "description": "Namespaced satellite extensions. Only place unknown keys are allowed."
    }
  }
}
