-- +goose Up -- What the BOOK had already cost before this attempt started. -- -- The engine's `committed_usd` is a lifetime total per BOOK — `SELECT SUM(committed_usd) FROM spend -- WHERE book_id = ?` — not the cost of the run that just ended. Settling with it verbatim charges an -- account for every earlier run of the same book again, every time. So the attempt records where the -- meter stood when it began, and settlement charges the DIFFERENCE. -- -- Null means the baseline was never captured, which is not a state any current path produces: the -- spawn refuses to start an attempt whose baseline it could not read, precisely because a paid run -- that cannot be billed correctly is worse than a run that starts a sweep later. It stays nullable -- for the rows that predate this column. alter table run_attempts add column spend_baseline_micro_usd bigint; -- +goose Down alter table run_attempts drop column spend_baseline_micro_usd;