﻿{
  "$schema": "https://json-schema.org",
  "$id": "https://ai-project-mark.org",
  "title": "Multi-Party Bounded-Compute Project Agreement",
  "description": "Cryptographically co-signed economic split between Human Creator (developer/artist), AI Operator, and optional Buyer.",
  "type": "object",
  "required": ["agreement_version", "terms", "canonical_terms_sha256", "signatures"],
  "properties": {
    "agreement_version": { "type": "string", "const": "0.3.0" },
    "terms": {
      "type": "object",
      "required": [
        "project_id",
        "title",
        "human_initiator_did",
        "buyer_id",
        "project_fee_micros",
        "compute_multiplier_bps",
        "compute_cap_bps",
        "royalty_schedule",
        "eu_ai_act_compliance_mode"
      ],
      "properties": {
        "project_id": { "type": "string", "minLength": 1 },
        "title": { "type": "string", "minLength": 1 },
        "human_initiator_did": { "type": "string", "pattern": "^did:[a-z0-9]+:.+" },
        "ai_operator_did": { "type": ["string", "null"], "pattern": "^did:[a-z0-9]+:.+" },
        "buyer_id": { "type": "string", "minLength": 1 },
        "project_fee_micros": { "type": "integer", "minimum": 1, "description": "Upfront project fee in integer micro-dollars (1 USD = 1,000,000 micros)." },
        "compute_multiplier_bps": { "type": "integer", "minimum": 10000, "description": "AI compute cost recovery multiplier in basis points (10000 = 1.0x, 30000 = 3.0x)." },
        "compute_cap_bps": { "type": "integer", "minimum": 1, "maximum": 10000, "description": "Maximum share of project fee allocable to AI compute (4000 = 40.00%)." },
        "royalty_schedule": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["start_year", "end_year", "rate_bps"],
            "properties": {
              "start_year": { "type": "integer", "minimum": 0 },
              "end_year": { "type": ["integer", "null"], "minimum": 0 },
              "rate_bps": { "type": "integer", "minimum": 0, "maximum": 10000 }
            },
            "additionalProperties": false
          }
        },
        "royalty_termination_cap_bps": { "type": ["integer", "null"], "minimum": 10000, "description": "Cumulative AI royalty cap as multiple of original verified compute (100000 = 10.0x)." },
        "eu_ai_act_compliance_mode": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "canonical_terms_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "signatures": {
      "type": "object",
      "properties": {
        "human_creator": { "$ref": "#/$defs/partySignature" },
        "ai_operator": { "$ref": "#/$defs/partySignature" },
        "buyer": { "$ref": "#/$defs/partySignature" }
      },
      "additionalProperties": false
    }
  },
  "$defs": {
    "partySignature": {
      "type": "object",
      "required": ["signer_did", "alg", "public_key_hex", "signature_base64", "signed_at_utc"],
      "properties": {
        "signer_did": { "type": "string", "pattern": "^did:[a-z0-9]+:.+" },
        "alg": { "type": "string", "const": "ES256" },
        "public_key_hex": { "type": "string", "pattern": "^[0-9a-fA-F]{66,130}$" },
        "signature_base64": { "type": "string", "minLength": 1 },
        "signed_at_utc": { "type": "string", "format": "date-time" }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
