Review round (@yoniebans) on #144630:
- Pacing was decided once at start, so a writer that opened state.db after the
run began (Desktop launched, gateway restarted) only got in through SQLite's
own gaps (one append waited 16.7 s with wal_autocheckpoint=0, next to
_execute_write's 20 s patience). _HolderWatch re-runs the same foreign-holder
scan the held-store refusal and --force use (foreign_state_db_holders, ~15 ms)
every 2 s on a side thread (copy_context, HX012); the chunk loop reads the flag
and switches to the paced cycle (~50 ms chunks + max(0.2 s, 4x cost) pause)
while a holder is there, back to unpaced when it leaves. A quiet run still
never sleeps. The CLI's one-shot scan and yield_to_writers go away; progress
lines say "paced: another process is using the database".
- A failed run (chunk kept failing, or "Could not optimize") now returns 1.
- Backfill progress counts messages (rows each window covered, total = rows at or
below the high water), not ids: a 100k id gap no longer reads 0% then 99%.
- The CJK backfill gets its own phase/line ("Building CJK index") instead of
overwriting the base pass's line with a lower percent.
- Teardown skips the per-table COUNT(*) when no progress callback is registered.
- Tests build the legacy store with both inline indexes (base + trigram), so the
trigram rebuild and all 10 reclaimed tables run; exit code 1 is asserted in the
disk-full test; one new test covers a holder appearing mid-run.