{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "@context": [
    "https://schemas.meta-aiml.org/v3.0.0/context.jsonld"
  ],
  "@id": "https://schemas.meta-aiml.org/v3.0.0/archetypes/mediated_exchange.json",
  "@type": [
    "Thing",
    "ArchetypeSchema",
    "MediatedExchange"
  ],
  "schemaVersion": "3.0.0",
  "aimlVersion": "3.0.0",
  "title": "MediatedExchange Interaction Archetype",
  "description": "Archetype for transaction mediation where a platform orchestrates exchanges between distinct participant roles, controls matching and settlement flow, and enforces trust mechanisms such as escrow and dispute handling.",
  "type": "object",
  "properties": {
    "interactionArchetype": {
      "type": "array",
      "description": "MediatedExchange archetype",
      "contains": {
        "const": "MediatedExchange"
      },
      "items": {
        "type": "string",
        "enum": [
          "DirectService",
          "MediatedExchange",
          "NetworkGraph",
          "BroadcastPublisher",
          "ProtocolSystem"
        ]
      },
      "minItems": 1,
      "maxItems": 1
    },
    "structuralMetadata": {
      "type": "object",
      "description": "Structural characteristics of MediatedExchange",
      "required": [
        "topology",
        "roles",
        "valueSource",
        "transactionFlow"
      ],
      "properties": {
        "topology": {
          "type": "string",
          "const": "triadic",
          "description": "Buyer ↔ Platform ↔ Seller topology"
        },
        "roles": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "buyer",
              "seller",
              "platform"
            ]
          },
          "minItems": 3,
          "maxItems": 3,
          "description": "Three fixed roles in triadic exchange",
          "const": [
            "buyer",
            "seller",
            "platform"
          ]
        },
        "valueSource": {
          "type": "string",
          "const": "transaction_mediation",
          "description": "Value from facilitating transactions"
        },
        "transactionFlow": {
          "type": "string",
          "enum": [
            "escrow",
            "direct_settlement"
          ],
          "description": "Transaction settlement model",
          "const": "escrow"
        },
        "networkEffects": {
          "type": "string",
          "const": "cross_side",
          "description": "Cross-side network effects (supply meets demand)"
        },
        "trustModel": {
          "type": "string",
          "const": "dual_rating",
          "description": "Both sides rate each other"
        }
      }
    },
    "marketplaceCharacteristics": {
      "type": "object",
      "description": "Marketplace-specific semantic features (not operational flags)",
      "properties": {
        "intermediaryRole": {
          "type": "string",
          "const": "broker_between_parties",
          "description": "Platform is intermediary, not primary participant"
        },
        "supplyDemandMatching": {
          "type": "string",
          "enum": [
            "passive_listing",
            "active_matching",
            "algorithmic_matching"
          ],
          "description": "How supply meets demand"
        },
        "ratingModel": {
          "type": "string",
          "const": "bidirectional",
          "description": "Both sides rate each other for trust/reputation"
        },
        "liquidityDependency": {
          "type": "string",
          "const": "critical",
          "description": "Network effects require critical mass on both sides"
        },
        "marketClearing": {
          "type": "string",
          "enum": [
            "instant",
            "batch",
            "scheduled"
          ],
          "description": "How transactions are matched and executed"
        },
        "priceMechanism": {
          "type": "string",
          "enum": [
            "fixed",
            "seller_posted",
            "buyer_posted",
            "negotiated",
            "auction"
          ],
          "description": "How prices are determined"
        }
      }
    },
    "requiredCapabilities": {
      "type": "array",
      "description": "Mandatory capability groups for MediatedExchange",
      "items": {
        "type": "string"
      },
      "uniqueItems": true,
      "minItems": 3,
      "contains": {
        "const": "commerce"
      },
      "allOf": [
        {
          "contains": {
            "const": "financial"
          }
        },
        {
          "contains": {
            "const": "interaction"
          }
        }
      ]
    },
    "commerceRequirements": {
      "type": "object",
      "description": "E-commerce functional requirements (semantic, not operational flags)",
      "required": [
        "matching",
        "search",
        "vendorManagement"
      ],
      "properties": {
        "matching": {
          "type": "string",
          "const": "buyer_seller_matching",
          "description": "Match buyers with sellers"
        },
        "search": {
          "type": "string",
          "const": "product_discovery",
          "description": "Search and discovery for listings"
        },
        "filtering": {
          "type": "string",
          "const": "advanced_filtering",
          "description": "Advanced filtering on product attributes"
        },
        "vendorManagement": {
          "type": "string",
          "const": "vendor_onboarding_management",
          "description": "Manage vendor/seller listings"
        }
      }
    },
    "financialRequirements": {
      "type": "object",
      "description": "Financial transaction requirements (semantic, not operational flags)",
      "required": [
        "payments",
        "settlement"
      ],
      "properties": {
        "payments": {
          "type": "string",
          "const": "payment_processing",
          "description": "Process payments between parties"
        },
        "settlement": {
          "type": "string",
          "enum": [
            "immediate",
            "escrow",
            "periodic_settlement"
          ],
          "description": "How funds are settled"
        },
        "refunds": {
          "type": "string",
          "const": "refund_handling",
          "description": "Refund policies and processing"
        },
        "commissionModel": {
          "type": "string",
          "enum": [
            "percentage",
            "flat_fee",
            "hybrid"
          ],
          "description": "Platform commission structure"
        }
      }
    },
    "interactionRequirements": {
      "type": "object",
      "description": "Interaction and communication requirements (semantic, not operational flags)",
      "properties": {
        "messaging": {
          "type": "string",
          "const": "buyer_seller_communication",
          "description": "Buyer-seller direct messaging"
        },
        "rating": {
          "type": "string",
          "const": "bidirectional_rating",
          "description": "Both parties rate each other"
        },
        "reviews": {
          "type": "string",
          "const": "written_reviews",
          "description": "Written reviews and feedback"
        },
        "dispute_resolution": {
          "type": "string",
          "const": "conflict_mediation",
          "description": "Platform-mediated dispute handling"
        }
      }
    },
    "philosophyAndComparison": {
      "type": "object",
      "description": "Conceptual positioning of MediatedExchange",
      "properties": {
        "definition": {
          "type": "string",
          "const": "MediatedExchange is the archetype where platform acts as trusted intermediary between supply and demand. Unlike DirectService (platform→consumer), MediatedExchange connects peer to peer. Unlike NetworkGraph (peer←→peer direct), the platform controls transaction flow."
        },
        "vs_DirectService": {
          "type": "string",
          "const": "DirectService delivers platform-controlled service directly to user. MediatedExchange connects users to each other via platform (platform is transaction intermediary, not direct service provider)."
        },
        "vs_NetworkGraph": {
          "type": "string",
          "const": "NetworkGraph enables peer-to-peer direct connections with platform as social infrastructure. MediatedExchange maintains platform control over transactions (escrow, payments, settlement)."
        },
        "vs_BroadcastPublisher": {
          "type": "string",
          "const": "BroadcastPublisher is one-to-many distribution (publisher→audience). MediatedExchange is many-to-many transaction matching (buyer↔seller via platform)."
        }
      }
    },
    "examples": {
      "type": "array",
      "description": "Example platforms using MediatedExchange",
      "items": {
        "type": "string"
      },
      "examples": [
        "Uber (riders ↔ drivers)",
        "Airbnb (guests ↔ hosts)",
        "eBay (buyers ↔ sellers)",
        "Upwork (clients ↔ freelancers)",
        "Facebook Marketplace (sellers)",
        "Dating platforms (matches)"
      ]
    }
  },
  "required": [
    "interactionArchetype",
    "structuralMetadata"
  ],
  "validationMetadata": {
    "schemaVersion": "3.0.0",
    "phase": "phase_1",
    "status": "draft",
    "lastValidated": "2026-02-19",
    "validator": "META-AIML QA"
  },
  "$id": "https://schemas.meta-aiml.org/v3.0.0/archetypes/mediated_exchange.json",
  "allOf": [
    {
      "if": {
        "properties": {
          "interactionArchetype": {
            "contains": {
              "const": "MediatedExchange"
            }
          }
        }
      },
      "then": {
        "required": [
          "capabilities"
        ],
        "properties": {
          "capabilities": {
            "type": "object",
            "required": [
              "commerce",
              "financial",
              "interaction"
            ],
            "properties": {
              "commerce": {
                "$ref": "../components/capability_groups.json#/$defs/CommerceCapabilities"
              },
              "financial": {
                "$ref": "../components/capability_groups.json#/$defs/FinancialCapabilities"
              },
              "interaction": {
                "$ref": "../components/capability_groups.json#/$defs/InteractionCapabilities"
              }
            }
          }
        }
      }
    }
  ],
  "semanticAnnotations": {
    "classificationRationale": "MediatedExchange archetype schema aligned with META-AIML v3 structural completeness rules.",
    "disambiguationNotes": "Ontology and archetype constraints are encoded for machine-verifiable validation."
  },
  "governanceMetadata": {
    "schemaVersion": "3.0.0",
    "stabilityLevel": "draft",
    "sdkValidationRules": [
      "RULE-AR-MEDIAT-001: interactionArchetype MUST contain MediatedExchange",
      "RULE-AR-MEDIAT-002: structuralMetadata const fields MUST match archetype definition",
      "RULE-AR-MEDIAT-003: capabilities MUST include commerce, financial, interaction"
    ]
  },
  "examples": [
    {
      "scenario": "MediatedExchange archetype reference usage #1",
      "note": "Demonstrates canonical structure and required constraints."
    },
    {
      "scenario": "MediatedExchange archetype reference usage #2",
      "note": "Demonstrates compliant alternative while preserving ontology/archetype semantics."
    }
  ]
}
