Evidence
src/CodeIndex/Cli/ActiveWorkspace.cs writes active workspace state directly:
File.WriteAllText(StatePath, JsonSerializer.Serialize(payload, ProgramRunner.CreateDefaultJsonOptions()));
Other small persistent files also use direct File.WriteAllText, while SuggestionStore.SaveUnlocked already has a temp-file, flush-to-disk, rename pattern.
Impact
Interrupted writes can leave persistent state files truncated or partially written. Some readers recover by returning null, but that still loses state and makes behavior harder to explain.
Requested behavior
Introduce or reuse a small atomic JSON write helper for user-visible persistent state: write to a temp file in the same directory, flush, then rename over the target. Keep best-effort cleanup for orphaned temp files.
Evidence
src/CodeIndex/Cli/ActiveWorkspace.cswrites active workspace state directly:Other small persistent files also use direct
File.WriteAllText, whileSuggestionStore.SaveUnlockedalready has a temp-file, flush-to-disk, rename pattern.Impact
Interrupted writes can leave persistent state files truncated or partially written. Some readers recover by returning null, but that still loses state and makes behavior harder to explain.
Requested behavior
Introduce or reuse a small atomic JSON write helper for user-visible persistent state: write to a temp file in the same directory, flush, then rename over the target. Keep best-effort cleanup for orphaned temp files.