e997435004
Only the initial SELECT of _dedupe_legacy_system_prompts was guarded; a 'database is locked' on any per-row write propagated out, aborted schema init, left the schema version below 25, and made every later SessionDB.__init__ re-enter the same migration against the same contended DB - the second half of the enterprise crash-loop report. The per-row loop now catches OperationalError, logs once, and returns. Partial migration is safe by design: the legacy system_prompt column is the documented read fallback for unmigrated rows, and the next schema init resumes where the contention stopped. Tests prove rows migrated before the failure stay migrated, the remainder stays readable, and a later run completes it.