There’s at least one part of the answer. For small retail speculators, others will ultimately step in and handle their obligations for them one way or another, leaving them ultimately just with a large negative balance in their brokerage account, which the brokerage will then try to collect.
Higher up the food chain there would be bigger responsibilities and bigger consequences. All the way up to “too big to fail”.
(Heh, I remember when gold was less than $300 - taking delivery wouldn’t cost you your house, only a nice car…)
The original buyer and seller of the contract have no further direct relationship, true. However in the rare case either one of them holds the position until contract expiry, they are then assigned by (the clearinghouse on behalf of) the exchange a specific short/long with whom to do physical settlement directly. The short must deliver the specified quantity of gold to an exchange-approved depository (which verifies that it meets contract specs), if they don’t already have it there, then settlement is via transfer of ownership of a so called warrant from the short to the long, in exchange for payment in $'s to the short at the final contract price. The exchange doesn’t directly deliver or receive gold.
In case the short doesn’t deliver the gold to the depository by the end of July (June contract per earlier example, last trading day third last business day in June), the long is entitled to go out into the market and buy the specified amount of gold. They are entitled to compensation for any cost of doing that over what they’d have paid to transfer the warrant at the contract price. That payment again becomes like any other payment between longs/shorts through the exchange: it’s the short’s responsibility to pay the exchange, the exchanges will take it out of short’s maintenance margin if short doesn’t pay, the exchange itself is on the hook if maintenance margin doesn’t cover it.