{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "agreementType", "candidateId", "subjectOrganizationId", "partnerOrganizationId", "legalParties", "governance", "pilotScope", "term", "commercialTerms", "liability", "privacy", "exitAndTermination", "support", "securityAndIncident", "changeControl", "linkedEvidence", "signatories", "subjectExecuted", "partnerExecuted"],
  "properties": {
    "schemaVersion": {"const": "2.0.0"},
    "agreementType": {"const": "executed-pilot-commercial-agreement"},
    "candidateId": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
    "subjectOrganizationId": {"type": "string", "pattern": "^organization:[0-9a-f]{64}$"},
    "partnerOrganizationId": {"type": "string", "pattern": "^organization:[0-9a-f]{64}$"},
    "legalParties": {"type": "array", "minItems": 2, "maxItems": 2, "uniqueItems": true, "items": {"type": "object", "additionalProperties": false, "required": ["organizationId", "legalName", "legalEntityEvidenceId"], "properties": {"organizationId": {"type": "string", "pattern": "^organization:[0-9a-f]{64}$"}, "legalName": {"type": "string", "minLength": 3, "maxLength": 256}, "legalEntityEvidenceId": {"const": "LEGAL-ENTITY"}}}},
    "governance": {"type": "object", "additionalProperties": false, "required": ["governingLaw", "exclusiveVenue", "counselEvidenceId"], "properties": {"governingLaw": {"type": "string", "minLength": 2, "maxLength": 256}, "exclusiveVenue": {"type": "string", "minLength": 2, "maxLength": 256}, "counselEvidenceId": {"const": "COUNSEL-SIGNOFF"}}},
    "pilotScope": {"type": "object", "additionalProperties": false, "required": ["network", "chainId", "pilotType", "activePartnerLimit", "selectedModule", "selectedActionClass", "selectedRouteId", "requiredDeploymentContract", "rolloutStageId", "productionClaim"], "properties": {"network": {"const": "base"}, "chainId": {"const": 8453}, "pilotType": {"const": "single-design-partner"}, "activePartnerLimit": {"const": 1}, "selectedModule": {"type": "string", "minLength": 1}, "selectedActionClass": {"type": "string", "minLength": 1}, "selectedRouteId": {"type": "string", "minLength": 1}, "requiredDeploymentContract": {"type": "string", "minLength": 1}, "rolloutStageId": {"type": "string", "minLength": 1}, "productionClaim": {"const": false}}},
    "term": {"type": "object", "additionalProperties": false, "required": ["effectiveAtUtc", "endsAtUtc", "durationDays", "automaticRenewal"], "properties": {"effectiveAtUtc": {"type": "string", "format": "date-time"}, "endsAtUtc": {"type": "string", "format": "date-time"}, "durationDays": {"type": "integer", "minimum": 1, "maximum": 366}, "automaticRenewal": {"const": false}}},
    "commercialTerms": {"type": "object", "additionalProperties": false, "required": ["currency", "feeAmount", "paymentMode", "rewardsConsumeCollateral"], "properties": {"currency": {"enum": ["USD", "USDC"]}, "feeAmount": {"type": "string", "pattern": "^(0|[1-9][0-9]{0,77})$"}, "paymentMode": {"const": "pull-only"}, "rewardsConsumeCollateral": {"const": false}}},
    "liability": {"type": "object", "additionalProperties": false, "required": ["bounded", "capsArtifactSha256"], "properties": {"bounded": {"const": true}, "capsArtifactSha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}}},
    "privacy": {"type": "object", "additionalProperties": false, "required": ["explicitConsent", "surveillanceRequired", "dataMinimized", "portabilityArtifactSha256"], "properties": {"explicitConsent": {"const": true}, "surveillanceRequired": {"const": false}, "dataMinimized": {"const": true}, "portabilityArtifactSha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}}},
    "exitAndTermination": {"type": "object", "additionalProperties": false, "required": ["convenienceNoticeDays", "maximumWindDownDays", "pauseSafeRefunds", "terminalExitAvailable", "principalSlashAllowed"], "properties": {"convenienceNoticeDays": {"type": "integer", "minimum": 0, "maximum": 90}, "maximumWindDownDays": {"type": "integer", "minimum": 1, "maximum": 90}, "pauseSafeRefunds": {"const": true}, "terminalExitAvailable": {"const": true}, "principalSlashAllowed": {"const": false}}},
    "support": {"type": "object", "additionalProperties": false, "required": ["selectedTier", "supportAcceptanceSha256", "maintenanceAndDeprecationAccepted"], "properties": {"selectedTier": {"enum": ["Evaluation", "Pilot"]}, "supportAcceptanceSha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}, "maintenanceAndDeprecationAccepted": {"const": true}}},
    "securityAndIncident": {"type": "object", "additionalProperties": false, "required": ["securityAcceptanceSha256", "incidentAcceptanceSha256", "privateReportingRequired", "incidentEscalationAccepted"], "properties": {"securityAcceptanceSha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}, "incidentAcceptanceSha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}, "privateReportingRequired": {"const": true}, "incidentEscalationAccepted": {"const": true}}},
    "changeControl": {"type": "object", "additionalProperties": false, "required": ["raciAcceptanceSha256", "candidateRebindingRequired", "moduleByModuleOnly"], "properties": {"raciAcceptanceSha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}, "candidateRebindingRequired": {"const": true}, "moduleByModuleOnly": {"const": true}}},
    "linkedEvidence": {"type": "object", "additionalProperties": false, "required": ["commercialAgreementEvidenceId", "signatureSetSha256", "boundedLiabilityEvidenceId", "privacyEvidenceId", "securityEvidenceId", "incidentEvidenceId", "supportEvidenceId", "changeEvidenceId"], "properties": {"commercialAgreementEvidenceId": {"const": "COMMERCIAL-AGREEMENT"}, "signatureSetSha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}, "boundedLiabilityEvidenceId": {"const": "BOUNDED-LIABILITIES"}, "privacyEvidenceId": {"const": "PRIVACY-CROSS-CHAIN"}, "securityEvidenceId": {"const": "SECURITY-POLICY-ACCEPTANCE"}, "incidentEvidenceId": {"const": "INCIDENT-PLAN-ACCEPTANCE"}, "supportEvidenceId": {"const": "SUPPORT-SLA-SELECTION"}, "changeEvidenceId": {"const": "CHANGE-RACI-ACCEPTANCE"}}},
    "signatories": {"type": "array", "minItems": 2, "maxItems": 2, "uniqueItems": true, "items": {"$ref": "#/$defs/approval"}},
    "subjectExecuted": {"const": true},
    "partnerExecuted": {"const": true}
  },
  "$defs": {
    "approval": {"type": "object", "additionalProperties": false, "required": ["identityId", "organizationId", "roleId", "externalAttestationId", "keyType", "publicKeySha256", "authorityEvidenceId", "signedPayloadSha256", "signatureBase64"], "properties": {"identityId": {"type": "string", "pattern": "^identity:[0-9a-f]{64}$"}, "organizationId": {"type": "string", "pattern": "^organization:[0-9a-f]{64}$"}, "roleId": {"enum": ["authorized-signatory", "partner-authorized-signatory"]}, "externalAttestationId": {"type": "string", "pattern": "^external-attestation:[0-9a-f]{64}$"}, "keyType": {"const": "Ed25519"}, "publicKeySha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}, "authorityEvidenceId": {"type": "string", "pattern": "^[A-Z0-9-]+$"}, "signedPayloadSha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"}, "signatureBase64": {"type": "string", "minLength": 88, "maxLength": 88}}}
  }
}
