- balance.py: reserve_balance/finalize_balance/refund_balance with Lua - utils.py: get_model_max_cost from llmusage history, update_model_max_cost - init.py: register reserve_balance, finalize_balance, refund_balance on env - chat/completions/index.dspy: reserve before inference, refund on exception - DB migration: llm.max_cost DECIMAL(10,4) for historical max charge