FA-60624 / Loyalty points ledgers / Member archive
Idempotent points event ledger: timestamp tie ordering · case 04
Events with equal timestamps are applied in delivery order, so a redeem can be rejected before its funding earn.
Case contract
Input {events:[{id,ts,type:"earn"|"redeem"|"reverse",pts,ref}]}. Duplicate ids are dropped keeping the first delivery in input order; survivors are applied sorted by (ts,id). Redeem requires balance >= pts or is rejected. Reverse undoes an applied earn or redeem once; unknown, rejected, already reversed, or reverse targets are rejected. Return {balance, rejected, applied}.
Why this case matters
Member point balances, statements and the program liability depend on this ledger rule.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| same timestamp | {"applied": ["a"], "balance": 34, "rejected": ["b"]} | {"applied": ["a", "b"], "balance": 4, "rejected": []} | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗