fix(config): serialize preferences writes across processes

Draft
SH
1d ago
+64-22

Two Wally processes could overwrite each other’s preference changes or collide on the shared temporary file.

All three preference writers now hold the same OS lock across the whole read-modify-write operation. The file format and atomic replacement stay the same.

Validation: 12 concurrency rounds preserved the expected settings and 4 MiB of unrelated data. A separate lock probe confirmed the writer waited for the lock. Network filesystems were not tested.

CI and formatting pass. The local full suite had 565 passes and two Windows symlink-privilege failures. Strict Clippy reports four pre-existing lints in untouched files.


Summary by cubic

Serializes preferences writes across processes so concurrent writers no longer lose each other's settings or race on the shared temp file.

Takes an exclusive OS lock on preferences.json.lock around the whole read-modify-write in set_default_model, clear_default_model, and set_decisions_route. Keeps the sibling temp file and atomic rename; lock and I/O failures propagate through the existing error path with no unlocked fallback.