{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "vaultfire.partner-organizational-readiness.v5.schema.json",
  "title": "Vaultfire partner organizational readiness post-commit envelope",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "schemaVersion",
    "packageKind",
    "status",
    "partnerReady",
    "asOfUtc",
    "subjectOrganizationId",
    "partnerOrganizationId",
    "bondPurpose",
    "scope",
    "releaseCandidate",
    "commitments",
    "decisionInputPolicy",
    "roles",
    "evidence",
    "blockers",
    "attestation"
  ],
  "properties": {
    "$schema": {
      "const": "../schemas/organizational-readiness.schema.json"
    },
    "schemaVersion": {
      "const": "5.0.0"
    },
    "packageKind": {
      "const": "vaultfire-partner-organizational-readiness"
    },
    "status": {
      "enum": [
        "blocked",
        "candidate-bound-ready"
      ]
    },
    "partnerReady": {
      "type": "boolean"
    },
    "asOfUtc": {
      "type": "string",
      "format": "date-time"
    },
    "subjectOrganizationId": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^organization:[0-9a-f]{64}$"
    },
    "partnerOrganizationId": {
      "type": [
        "string",
        "null"
      ],
      "pattern": "^organization:[0-9a-f]{64}$"
    },
    "bondPurpose": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "productClass",
        "bondTypes",
        "supports",
        "flourishingIsNeverAScoreEntitlementOrControlInput"
      ],
      "properties": {
        "productClass": {
          "const": "flourishing-bonds"
        },
        "bondTypes": {
          "const": [
            "AccountabilityBond",
            "PartnershipBond"
          ]
        },
        "supports": {
          "const": [
            "accountable-growth",
            "cooperation",
            "freedom"
          ]
        },
        "flourishingIsNeverAScoreEntitlementOrControlInput": {
          "const": true
        }
      }
    },
    "scope": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "network",
        "chainId",
        "pilotType",
        "activePartnerLimit",
        "productionClaim",
        "selectedModule",
        "selectedActionClass",
        "selectedRouteId",
        "deniedModules"
      ],
      "properties": {
        "network": {
          "const": "base"
        },
        "chainId": {
          "const": 8453
        },
        "pilotType": {
          "const": "single-design-partner"
        },
        "activePartnerLimit": {
          "const": 1
        },
        "productionClaim": {
          "const": false
        },
        "selectedModule": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1
        },
        "selectedActionClass": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            null,
            "read-only-query"
          ]
        },
        "selectedRouteId": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[a-z0-9][a-z0-9._-]{2,127}$"
        },
        "deniedModules": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "releaseCandidate": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "candidateId",
        "envelopeId",
        "sourceCommit",
        "gitTree",
        "selectionCommit",
        "selectionTree",
        "evidenceCommit",
        "evidenceTree",
        "artifactManifest",
        "packageVersion",
        "createdAtUtc",
        "deploymentManifest",
        "canonicalBindings"
      ],
      "properties": {
        "candidateId": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "envelopeId": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "sourceCommit": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-f]{40}$"
        },
        "gitTree": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-f]{40}$"
        },
        "evidenceCommit": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-f]{40}$"
        },
        "evidenceTree": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-f]{40}$"
        },
        "artifactManifest": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "path": {
              "const": "pr10/partner-package/evidence/organizational/artifact-manifest.json"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          },
          "required": [
            "path",
            "sha256"
          ],
          "additionalProperties": false
        },
        "packageVersion": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[a-z0-9][a-z0-9._-]{2,63}$"
        },
        "createdAtUtc": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "deploymentManifest": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "path": {
              "const": "pr8/pilot/base_v3_deployment_manifest.json"
            },
            "sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          },
          "required": [
            "path",
            "sha256"
          ],
          "additionalProperties": false
        },
        "canonicalBindings": {
          "type": [
            "object",
            "null"
          ],
          "properties": {
            "operationsStatus": {
              "$ref": "#/$defs/binding"
            },
            "policyCommitment": {
              "$ref": "#/$defs/binding"
            },
            "readinessSupersession": {
              "$ref": "#/$defs/binding"
            },
            "openSpec": {
              "$ref": "#/$defs/binding"
            },
            "canonicalLedger": {
              "$ref": "#/$defs/binding"
            },
            "partnerPackageSchema": {
              "$ref": "#/$defs/binding"
            },
            "trustedIdentities": {
              "$ref": "#/$defs/binding"
            },
            "scopeRegistry": {
              "$ref": "#/$defs/binding"
            },
            "rolloutPlan": {
              "$ref": "#/$defs/binding"
            },
            "generatedRouteInventory": {
              "$ref": "#/$defs/binding"
            },
            "trustRootPolicy": {
              "$ref": "#/$defs/binding"
            },
            "legalRegistryTrustPolicy": {
              "$ref": "#/$defs/binding"
            },
            "randomnessAuthorityTrustPolicy": {
              "$ref": "#/$defs/binding"
            }
          },
          "required": [
            "operationsStatus",
            "policyCommitment",
            "readinessSupersession",
            "openSpec",
            "canonicalLedger",
            "partnerPackageSchema",
            "trustedIdentities",
            "scopeRegistry",
            "rolloutPlan",
            "generatedRouteInventory",
            "trustRootPolicy",
            "legalRegistryTrustPolicy",
            "randomnessAuthorityTrustPolicy"
          ],
          "additionalProperties": false
        },
        "selectionCommit": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-f]{40}$"
        },
        "selectionTree": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[0-9a-f]{40}$"
        }
      }
    },
    "commitments": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "flourishingCannotSlashPrincipal",
        "flourishingCannotControlPrincipal",
        "flourishingCannotControlCollateral",
        "flourishingCannotControlAnyProtectedDecision",
        "rewardsCannotConsumeCollateral",
        "surveillanceNeverRequired",
        "surveillanceDataNeverPermittedForProtectedDecisions",
        "hashedDerivedAndTransitiveSurveillanceInputsProhibited",
        "explicitConsentRequired",
        "refundsAndTerminalExitsBoundedAndPauseSafe",
        "moduleByModuleGatedRollout",
        "liabilitiesStrictlyBounded",
        "pullPaymentsRequired",
        "failClosedApisRequired",
        "immutableEvidenceBindingRequired",
        "exactCommitTestsRequired",
        "privacyPreservingChainSpecificTrustPortabilityRequired",
        "crossChainValueFlowsExcludedFromPilot"
      ],
      "properties": {
        "flourishingCannotSlashPrincipal": {
          "const": true
        },
        "flourishingCannotControlPrincipal": {
          "const": true
        },
        "flourishingCannotControlCollateral": {
          "const": true
        },
        "flourishingCannotControlAnyProtectedDecision": {
          "const": true
        },
        "rewardsCannotConsumeCollateral": {
          "const": true
        },
        "surveillanceNeverRequired": {
          "const": true
        },
        "surveillanceDataNeverPermittedForProtectedDecisions": {
          "const": true
        },
        "hashedDerivedAndTransitiveSurveillanceInputsProhibited": {
          "const": true
        },
        "explicitConsentRequired": {
          "const": true
        },
        "refundsAndTerminalExitsBoundedAndPauseSafe": {
          "const": true
        },
        "moduleByModuleGatedRollout": {
          "const": true
        },
        "liabilitiesStrictlyBounded": {
          "const": true
        },
        "pullPaymentsRequired": {
          "const": true
        },
        "failClosedApisRequired": {
          "const": true
        },
        "immutableEvidenceBindingRequired": {
          "const": true
        },
        "exactCommitTestsRequired": {
          "const": true
        },
        "privacyPreservingChainSpecificTrustPortabilityRequired": {
          "const": true
        },
        "crossChainValueFlowsExcludedFromPilot": {
          "const": true
        }
      }
    },
    "decisionInputPolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "protectedDecisions",
        "prohibitedClasses",
        "hashedDerivedAndTransitiveFormsProhibited",
        "unknownOrOpaqueInputsProhibited",
        "observedInputClasses"
      ],
      "properties": {
        "protectedDecisions": {
          "const": [
            "access",
            "collateral",
            "custody",
            "disputes",
            "eligibility",
            "pricing",
            "principal",
            "routing",
            "settlement",
            "slashing"
          ]
        },
        "prohibitedClasses": {
          "const": [
            "behavioral-routing",
            "belief",
            "biometric",
            "flourishing",
            "loyalty",
            "profiling",
            "quality",
            "reputation",
            "surveillance",
            "trust-score"
          ]
        },
        "hashedDerivedAndTransitiveFormsProhibited": {
          "const": true
        },
        "unknownOrOpaqueInputsProhibited": {
          "const": true
        },
        "observedInputClasses": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "allowed:bounded-time",
              "allowed:contract-state",
              "allowed:cryptographic-authorization",
              "allowed:explicit-participant-instruction",
              "allowed:objective-onchain-fact"
            ]
          }
        }
      }
    },
    "roles": {
      "type": "array",
      "minItems": 10,
      "maxItems": 10,
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/assignment"
      }
    },
    "evidence": {
      "type": "array",
      "maxItems": 25,
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/evidence"
      }
    },
    "blockers": {
      "type": "array",
      "minItems": 25,
      "maxItems": 25,
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/blocker"
      }
    },
    "attestation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "preparedByIdentityId",
        "reviewedByIdentityId",
        "authorizedByIdentityId",
        "partnerAcceptedByIdentityId",
        "signedAtUtc",
        "signatureEvidenceId",
        "postCommitSignatures"
      ],
      "properties": {
        "preparedByIdentityId": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^identity:[0-9a-f]{64}$"
        },
        "reviewedByIdentityId": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^identity:[0-9a-f]{64}$"
        },
        "authorizedByIdentityId": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^identity:[0-9a-f]{64}$"
        },
        "partnerAcceptedByIdentityId": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^identity:[0-9a-f]{64}$"
        },
        "signedAtUtc": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "signatureEvidenceId": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            null,
            "SIGNATURES"
          ]
        },
        "postCommitSignatures": {
          "type": "array",
          "maxItems": 4,
          "uniqueItems": true,
          "items": {
            "$ref": "#/$defs/postCommitSignature"
          }
        }
      }
    }
  },
  "$defs": {
    "binding": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "path",
        "sha256"
      ],
      "properties": {
        "path": {
          "type": "string",
          "minLength": 1
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      }
    },
    "postCommitSignature": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "identityId",
        "roleId",
        "signedPayloadSha256",
        "signatureBase64"
      ],
      "properties": {
        "identityId": {
          "type": "string",
          "pattern": "^identity:[0-9a-f]{64}$"
        },
        "roleId": {
          "enum": [
            "release-manager",
            "independent-reviewer",
            "authorized-signatory",
            "partner-authorized-signatory"
          ]
        },
        "signedPayloadSha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "signatureBase64": {
          "type": "string",
          "minLength": 88,
          "maxLength": 88
        }
      }
    },
    "assignment": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "roleId",
        "identityId",
        "contactChannelId",
        "evidenceId"
      ],
      "properties": {
        "roleId": {
          "enum": [
            "authorized-signatory",
            "change-approver",
            "commercial-owner",
            "incident-commander",
            "independent-reviewer",
            "legal-reviewer",
            "privacy-reviewer",
            "release-manager",
            "security-contact",
            "support-owner"
          ]
        },
        "identityId": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^identity:[0-9a-f]{64}$"
        },
        "contactChannelId": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^channel:[0-9a-f]{64}$"
        },
        "evidenceId": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "evidence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "claimType",
        "path",
        "sha256",
        "candidateId"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Z0-9-]+$"
        },
        "claimType": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9.-]{2,63}$"
        },
        "path": {
          "type": "string",
          "pattern": "^pr10/partner-package/evidence/organizational/[a-z0-9][a-z0-9._/-]*\\.json$"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "candidateId": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        }
      }
    },
    "blocker": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "status",
        "externalHumanAction"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Z0-9-]+$"
        },
        "status": {
          "enum": [
            "open",
            "satisfied"
          ]
        },
        "externalHumanAction": {
          "type": "boolean"
        }
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "partnerReady": {
            "const": true
          }
        }
      },
      "then": {
        "properties": {
          "status": {
            "const": "candidate-bound-ready"
          },
          "evidence": {
            "minItems": 25,
            "maxItems": 25
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "partnerReady": {
            "const": false
          }
        }
      },
      "then": {
        "properties": {
          "status": {
            "const": "blocked"
          },
          "evidence": {
            "maxItems": 0
          }
        }
      }
    }
  ]
}
