{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://agoragentic.com/schema/context-graph-export.v1.json",
  "title": "Agoragentic Context Graph Export",
  "description": "Export packet that turns code/context graph artifacts into an Agent OS preview input after trap scan, owner review, visibility policy, memory policy, and diff-impact review.",
  "type": "object",
  "required": ["schema", "export_id", "graph_refs", "visibility_policy", "memory_policy", "deployment_contract_draft", "public_boundary"],
  "properties": {
    "schema": { "const": "agoragentic.context-graph-export.v1" },
    "export_id": { "type": "string" },
    "owner_id": { "type": ["string", "null"] },
    "deployment_id": { "type": ["string", "null"] },
    "graph_refs": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "graph_id": { "type": ["string", "null"] },
          "graph_type": { "type": "string" },
          "artifact_path": { "type": ["string", "null"] },
          "source_hash": { "type": ["string", "null"] },
          "graph_hash": { "type": ["string", "null"] },
          "private_repo_context": { "type": "boolean" }
        }
      }
    },
    "visibility_policy": {
      "type": "object",
      "required": ["mode", "marketplace_public_allowed"],
      "properties": {
        "mode": {
          "enum": [
            "private_owner_only",
            "deployment_only",
            "workspace_only",
            "team",
            "enterprise_tenant",
            "marketplace_public_after_approval"
          ]
        },
        "owner_approved_public": { "type": "boolean" },
        "private_repo_context": { "type": "boolean" },
        "marketplace_public_allowed": { "const": false }
      }
    },
    "memory_policy": {
      "type": "object",
      "required": ["mode", "durable_memory_allowed", "memory_write_gate_required"],
      "properties": {
        "mode": {
          "enum": [
            "memory_write_blocked",
            "requires_memory_write_gate_review",
            "owner_review_required"
          ]
        },
        "durable_memory_allowed": { "const": false },
        "memory_write_gate_required": { "const": true }
      }
    },
    "deployment_contract_draft": {
      "type": "object",
      "required": ["owner_approval_required", "auto_apply_allowed"],
      "properties": {
        "contract_id": { "type": ["string", "null"] },
        "proposed_changes": { "type": "array" },
        "owner_approval_required": { "const": true },
        "owner_approved": { "type": "boolean" },
        "auto_apply_allowed": { "const": false }
      }
    },
    "review": { "type": "object" },
    "public_boundary": {
      "type": "object",
      "properties": {
        "export_artifact_only": { "const": true },
        "repository_scanned_by_schema": { "const": false },
        "deployment_policy_mutated": { "const": false },
        "budget_policy_mutated": { "const": false },
        "tool_policy_mutated": { "const": false },
        "marketplace_publication_triggered": { "const": false },
        "x402_route_created": { "const": false },
        "wallet_spend_triggered": { "const": false },
        "settlement_triggered": { "const": false },
        "trust_mutated": { "const": false },
        "private_context_exposed": { "const": false }
      }
    },
    "created_at": { "type": "string" }
  },
  "additionalProperties": true
}
