ENGINEERING NOTE 34 / 50 · CARD
Enforce spending budgets under concurrent requests
A read-then-write budget check can approve several requests against the same remaining amount. Reserve capacity atomically before committing work.
Published by OPEN RAMBO. The engineering patterns and pseudocode illustrate designs, not a documented product API. Numerical examples are illustrative.
Reserve rather than observe
Two requests may both see a remaining budget of 100 and each approve 80. Combine the eligibility condition and reservation in one transaction or conditional update. Track reserved capacity separately from settled spend.
Release after known failure
A reservation may be released after authoritative rejection, but not merely after a client disconnect. An uncertain upstream outcome remains pending. Apply an idempotent release operation so retries do not increase available budget more than once.
Align reset boundaries
Monthly or daily budgets need an explicit timezone and carryover policy for pending reservations. A reset must not erase operations still capable of settling. Keep ledger evidence for each reservation, consumption and release.
Illustrative implementation
atomic_reserve(where={"available": {"gte": amount}},
decrement_available=amount, increment_reserved=amount)Acceptance check
Issue simultaneous requests whose sum exceeds the budget. Approved reservations must never exceed the enforceable capacity.