Files
openclaw/src
Peter Steinberger 4eef09dc3f perf(acp): maintain ledger byte budgets at insert time (#104739)
* perf(acp): maintain ledger byte budgets at insert time

estimateSqliteLedgerBytes ran a full SUM(length(...)) scan over every
replay event on every append, and once the 16MB budget was hit the trim
loop rescanned after each single-row delete (#100622). Event rows now
carry estimated_bytes computed at insert, session rows keep a running
footprint aggregate, budget checks sum over at most maxSessions rows,
and eviction deletes bounded batches with RETURNING so aggregates stay
exact. Additive columns backfill once via ensureAdditiveStateColumns.

Fixes #100622

* fix(acp): keep ledger footprint aggregates exact across key changes and conflicts

Session-key/cwd length changes now adjust the aggregate via SET
expressions that read the pre-update row, and the conflict-upsert
recomputes from surviving event rows instead of clobbering to row
overhead. Invariant test now rebinds a provisional key to a longer
canonical key mid-stream.
2026-07-11 15:30:21 -07:00
..