{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.monarchagents.ai/product-graph.schema.json",
  "title": "Monarch Product Graph Concept Schema",
  "description": "Public conceptual schema for describing Product Graph surfaces, actions, permissions, validation, and drift. This is an explanatory schema for agents and answer engines, not a complete product API contract.",
  "type": "object",
  "required": ["application", "surfaces", "actions"],
  "properties": {
    "application": {
      "type": "object",
      "required": ["name", "category"],
      "properties": {
        "name": { "type": "string" },
        "category": { "type": "string" },
        "environment": { "type": "string", "enum": ["saas", "internal_tool", "legacy_system", "system_of_record", "other"] }
      },
      "additionalProperties": true
    },
    "surfaces": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "type", "description"],
        "properties": {
          "id": { "type": "string" },
          "type": {
            "type": "string",
            "enum": ["public_api", "undocumented_api", "ui_path", "permission", "business_logic", "schema", "drift"]
          },
          "description": { "type": "string" },
          "observed_inputs": { "type": "array", "items": { "type": "string" } },
          "observed_outputs": { "type": "array", "items": { "type": "string" } }
        },
        "additionalProperties": true
      }
    },
    "actions": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "name", "route", "validation"],
        "properties": {
          "id": { "type": "string" },
          "name": { "type": "string" },
          "route": {
            "type": "string",
            "enum": ["api", "undocumented_api", "ui_fallback", "hybrid"]
          },
          "required_permissions": {
            "type": "array",
            "items": { "type": "string" }
          },
          "preconditions": {
            "type": "array",
            "items": { "type": "string" }
          },
          "validation": {
            "type": "array",
            "items": { "type": "string" }
          },
          "drift_watch": {
            "type": "array",
            "items": { "type": "string" }
          }
        },
        "additionalProperties": true
      }
    }
  },
  "additionalProperties": true
}
