{
  "status": "PROPOSED_OPTIONAL_EXTENSION",
  "release": "2.43.0",
  "base": "../dev_toolkit/12_OPENAPI_CANDIDATE.json",
  "format": "RFC6902",
  "adoption": "Review/apply to the candidate only when adopted. The byte-preserved base contract does not enforce these new guards. No endpoint, provider permission or deployment is added.",
  "patch": [
    {
      "op": "add",
      "path": "/components/schemas/SettlementReceivingDestination",
      "value": {
        "type": "object",
        "required": [
          "snapshotHash",
          "recipientPartyRef",
          "destinationRef"
        ],
        "properties": {
          "snapshotHash": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "recipientPartyRef": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "destinationRef": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          }
        },
        "additionalProperties": false,
        "description": "Exact independently verified receiving snapshot. Fields must match the current server-owned verification registry. A change requires a new verified snapshot and renewed acceptance, never a caller flag."
      }
    },
    {
      "op": "add",
      "path": "/components/schemas/SettlementSafetySnapshot",
      "value": {
        "type": "object",
        "required": [
          "orderId",
          "cashAmount",
          "currency",
          "instrumentId",
          "assetUnits",
          "networkRef",
          "cashDestination",
          "assetDestination",
          "portions"
        ],
        "properties": {
          "orderId": {
            "type": "string",
            "format": "uuid"
          },
          "cashAmount": {
            "type": "string",
            "pattern": "^[0-9]{1,20}(\\.[0-9]{1,18})?$",
            "not": {
              "pattern": "^0+(\\.0+)?$"
            }
          },
          "currency": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "instrumentId": {
            "type": "string",
            "format": "uuid"
          },
          "assetUnits": {
            "type": "string",
            "pattern": "^[0-9]{1,20}(\\.[0-9]{1,18})?$",
            "not": {
              "pattern": "^0+(\\.0+)?$"
            }
          },
          "networkRef": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "cashDestination": {
            "$ref": "#/components/schemas/SettlementReceivingDestination"
          },
          "assetDestination": {
            "$ref": "#/components/schemas/SettlementReceivingDestination"
          },
          "portions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": [
                "id",
                "cashAmount",
                "assetUnits"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "pattern": "\\S"
                },
                "cashAmount": {
                  "type": "string",
                  "pattern": "^[0-9]{1,20}(\\.[0-9]{1,18})?$",
                  "not": {
                    "pattern": "^0+(\\.0+)?$"
                  }
                },
                "assetUnits": {
                  "type": "string",
                  "pattern": "^[0-9]{1,20}(\\.[0-9]{1,18})?$",
                  "not": {
                    "pattern": "^0+(\\.0+)?$"
                  }
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false,
        "description": "Server-built exact accepted obligation snapshot in quote terms.settlementSafety. Both parties accept its enclosing terms hash. Portion IDs are unique, amounts strictly positive, sums exactly equal accepted totals. No tolerance, FX, inferred allocation ratio or rounding. Server checks cross-field/cumulative invariants."
      }
    },
    {
      "op": "replace",
      "path": "/components/schemas/LegEvidence",
      "value": {
        "type": "object",
        "required": [
          "leg",
          "status",
          "sourceRef",
          "amount",
          "unitOrCurrency",
          "occurredAt"
        ],
        "properties": {
          "leg": {
            "type": "string",
            "enum": [
              "cash",
              "asset"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "reported",
              "confirmed",
              "disputed",
              "reversed"
            ]
          },
          "sourceRef": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "providerEventId": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "amount": {
            "$ref": "#/components/schemas/DecimalString"
          },
          "unitOrCurrency": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "evidenceDocumentId": {
            "type": "string",
            "format": "uuid"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "settlementPortionRef": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "destinationSnapshotHash": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "recipientPartyRef": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "destinationRef": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "instrumentId": {
            "type": "string",
            "format": "uuid"
          },
          "networkRef": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          }
        },
        "allOf": [
          {
            "oneOf": [
              {
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "reported",
                      "disputed",
                      "reversed"
                    ]
                  }
                }
              },
              {
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "confirmed"
                    ]
                  },
                  "amount": {
                    "type": "string",
                    "pattern": "^[0-9]{1,20}(\\.[0-9]{1,18})?$",
                    "not": {
                      "pattern": "^0+(\\.0+)?$"
                    }
                  }
                },
                "required": [
                  "providerEventId",
                  "evidenceDocumentId",
                  "settlementPortionRef",
                  "destinationSnapshotHash",
                  "recipientPartyRef",
                  "destinationRef"
                ],
                "oneOf": [
                  {
                    "properties": {
                      "leg": {
                        "type": "string",
                        "enum": [
                          "cash"
                        ]
                      }
                    }
                  },
                  {
                    "properties": {
                      "leg": {
                        "type": "string",
                        "enum": [
                          "asset"
                        ]
                      }
                    },
                    "required": [
                      "instrumentId",
                      "networkRef"
                    ]
                  }
                ]
              }
            ]
          }
        ],
        "description": "On confirmed, source identity and verified evidence are mandatory; adapter or reviewer identity must be authorized server-side. sourceRef/providerEventId is globally unique. Match exact accepted portion, currency or instrument, units, verified destination and asset network; reject overdelivery and replays. Nonconfirmed legs are not settled or fee eligible."
      }
    },
    {
      "op": "add",
      "path": "/paths/~1v1~1quotes/post/requestBody/content/application~1json/schema/properties/terms/properties",
      "value": {
        "settlementSafety": {
          "$ref": "#/components/schemas/SettlementSafetySnapshot"
        }
      }
    },
    {
      "op": "add",
      "path": "/paths/~1v1~1orders~1{orderId}~1leg-evidence/post/description",
      "value": "Adopted extension: server validates evidence authenticity/source identity and current verified receiving snapshot against accepted quote terms.settlementSafety, locks the order for cumulative bounds, enforces one confirmed leg per accepted portion and global source-event deduplication. Reference command.portionId maps to settlementPortionRef; destinationRef maps to SQL receiving_destination_ref. Caller booleans cannot approve evidence/destinations."
    },
    {
      "op": "add",
      "path": "/paths/~1v1~1orders~1{orderId}~1reconciliation/post/description",
      "value": "Adopted extension: whole-order approval requires exact total cash currency/amount and delivered instrument/network/units, both confirmed legs for accepted portions, current approved destinations, independent review and no dispute/reversal. Pending legs are neither settled volume nor fee eligible. Reference partial reconciliation recognizes only independently reviewed accepted portions; it does not implement billing or introduce a partial-reconciliation endpoint."
    }
  ],
  "serverGuards": [
    "Exact immutable accepted terms hash and both party acceptances; source facts originate from authorized adapters/reviewers, not request flags.",
    "Nonempty unique sourceRef/providerEventId and independently verified evidenceDocumentId for each confirmed leg.",
    "Exact receiving snapshot, recipient and destination; changed/revoked destination blocks until reverified and reaccepted. Asset instrument/network must match.",
    "Exact decimal cash/units per explicitly accepted portion; unique IDs, sum equality, atomic cumulative bounds and replay rejection. No invented tolerance.",
    "Fee eligibility only after both independent confirmed legs and a bound independent reconciliation decision. No live fees are collected."
  ],
  "limits": [
    "JSON schema alone cannot enforce authentication, evidence authenticity, accepted hashes, registry checks, cumulative sums, races or independent review.",
    "SQL amendment is proposed and unexecuted against a database; DB concurrency, source adapters, revocation/correction, authorization and deployment remain external acceptance gates.",
    "Hostinger work is explicitly deferred."
  ]
}
