The market data feed was wrong. Fill 1 of order 3000 in chapter 4 was recorded at $200.00, but the real price was $190.00. User 42 was charged $10 too much.
You can’t edit or delete
Section titled “You can’t edit or delete”A posting in Torment can never be changed or removed. That’s deliberate: a ledger where history can be rewritten can’t be trusted, by auditors or by you. Every correction is a new posting, and the mistake stays visible next to its fix.
Reverse it, then post it again
Section titled “Reverse it, then post it again”Undo the wrong posting with one that swaps its debit and credit, and post the right one. Put both in one chain, so the user’s balance is never halfway corrected. Use the order’s group_id, so the fix shows up with the order. Give both postings the kind correction, registered like the others with POST /kinds {"name": "correction"}. A correction isn’t a new trade, and its own kind keeps it from looking like one.
{ "chains": [ [ { "id": "00000000-0000-0000-0000-000000009001", "debit": "bank:client-money", "credit": "user:42:cash", "currency": "USD", "amount": "20000", "kind": "correction", "group_id": "00000000-0000-0000-0000-000000003000" }, { "id": "00000000-0000-0000-0000-000000009002", "debit": "user:42:cash", "credit": "bank:client-money", "currency": "USD", "amount": "19000", "kind": "correction", "group_id": "00000000-0000-0000-0000-000000003000" } ] ]}The user gets $10 back, and GET /groups/00000000-0000-0000-0000-000000003000/transfers now shows the original fill, its reversal and the corrected fill.
You could post just the $10 difference instead. A full reversal is clearer on a statement, because each line matches something that really happened: “fill at $200”, “reversal of fill”, “fill at $190”.
Don’t fix by reusing an id
Section titled “Don’t fix by reusing an id”Sending a posting again with the same id but a different amount doesn’t change it. Torment refuses:
{ "chains": [ [{ "id": "00000000-0000-0000-0000-000000001001", "group_id": "00000000-0000-0000-0000-000000001001", "status": "failed", "error": "conflict", "message": "transfer 00000000-0000-0000-0000-000000001001 exists with different fields: TransferExistsWithDifferentAmount" }] ]}That’s the same protection that makes retries safe. A retry must be identical, so a different posting under the same id is a mistake, and Torment says so instead of guessing.
Mistakes that can’t be fixed with a posting
Section titled “Mistakes that can’t be fixed with a posting”Some choices are permanent:
- An account’s type and
allow_negative. If an account was registered with the wrong type, register a new account with the right one, and move the balance across with a posting. - A currency’s precision. Registering
USDagain with a different precision returns 409. Choose precisions carefully, including enough decimals for fractional shares.
Where this leaves us
Section titled “Where this leaves us”The books can be fixed without editing anything. Last, telling users when money moves.