Skip to content

refactor(migrations): use atomic_write across all config migrations (v003–v009) #1396

@coderabbitai

Description

@coderabbitai

Summary

All config migration functions (v003 through v009) currently use plain fs::write to persist updated config.toml files. If a write is interrupted mid-migration (process kill, power loss, disk full), the config can be left truncated or partially written, causing a broken launch on the next run.

An atomic_write helper already exists at src/session/storage.rs:35. A cross-migration sweep should replace every fs::write(path, content) call in the src/migrations/ directory with the atomic equivalent (write to a temp file alongside the target, then rename into place).

Context

Raised during review of #1386 (comment: #1386 (comment)). The v009 migration intentionally kept fs::write for consistency with the existing migrations; this issue tracks the follow-up sweep.

Acceptance criteria

  • All migration files in src/migrations/ (v003 through v009, and any future migrations) use atomic writes when updating config files.
  • No behaviour change otherwise; existing tests continue to pass.

/cc @Seluj78

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Backlog: real, but not nowarea:infraBuild, release, daemon, internals

    Type

    No fields configured for Task.

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions