{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.org/nonprofit-capital-navigator/workflow-schema.json",
  "title": "Nonprofit Capital Navigator portable handoff",
  "description": "Standalone product contract. External orchestrators interact only through versioned adapters and may not mutate their own canonical state from project records without explicit, provenance-linked human approval.",
  "type": "object",
  "required": ["schema", "schemaVersion", "provenance", "workflow", "partnerData", "handoff"],
  "properties": {
    "schema": {"const": "nonprofit-capital-navigator"},
    "schemaVersion": {"type": "string"},
    "provenance": {
      "type": "object",
      "required": ["research", "organizationProfile"],
      "properties": {
        "research": {"type": "object", "description": "Sourced research provenance."},
        "organizationProfile": {"type": "object", "description": "Partner-entered facts and verification status."}
      }
    },
    "workflow": {
      "type": "object",
      "required": ["workflowId", "currentStage", "stages", "validation", "transitions", "approvals"],
      "properties": {
        "workflowId": {"type": "string"},
        "currentStage": {"enum": ["organization_intake", "evidence_provenance", "funding_readiness", "opportunity_matching_inputs", "system_analysis", "advisor_review", "approval_export"]},
        "stages": {"type": "array", "items": {"type": "object", "required": ["key", "status", "requiresHumanApproval"]}},
        "validation": {"type": "object", "required": ["status", "missingRequired", "readinessGaps"]},
        "transitions": {"type": "array", "items": {"type": "object", "required": ["from", "to", "at", "actor"]}},
        "approvals": {"type": "array", "items": {"type": "object", "required": ["gate", "decision", "actor", "at"]}},
        "recommendedNextAction": {"type": "string"}
      }
    },
    "partnerData": {"type": "object", "description": "Provider-neutral organization intake and matching inputs."},
    "analysis": {"type": "object", "description": "Deterministic prototype output; never a live eligibility decision."},
    "advisorReview": {"type": "object", "description": "Human judgment, corrections, and prototype feedback."},
    "handoff": {
      "type": "object",
      "required": ["status", "submissionStatus", "automationPolicy"],
      "properties": {
        "submissionStatus": {"const": "not_submitted"},
        "automationPolicy": {"const": "human_approval_required_for_consequential_actions"}
      }
    },
    "systemBoundary": {
      "type": "object",
      "description": "Boundary policy for external orchestration.",
      "properties": {
        "owner": {"const": "nonprofit_capital_navigator"},
        "adapterContractVersion": {"type": "string"},
        "externalCoreMutation": {"const": "forbidden"},
        "lessonPromotion": {"const": "explicit_approval_and_provenance_required"}
      }
    }
  }
}
