LearnNewsExamplesServices
Frontmatter
id9084
titleEnhancement: DevRank Atomic File Persistence
stateClosed
labels
enhancementai
assigneestobiu
createdAtFeb 10, 2026, 3:08 PM
updatedAtFeb 10, 2026, 3:12 PM
githubUrlhttps://github.com/neomjs/neo/issues/9084
authortobiu
commentsCount1
parentIssue8930
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 10, 2026, 3:12 PM

Enhancement: DevRank Atomic File Persistence

Closed v12.0.0 enhancementai
tobiu
tobiu commented on Feb 10, 2026, 3:08 PM

Implement atomic file writing in DevRank.services.Storage to prevent data corruption during process crashes or power failures.

Current State: Storage.mjs uses fs.writeFile to directly overwrite critical data files (users.json, tracker.json). If the write operation is interrupted, the file may be left in a truncated or corrupted state.

Requirement:

  1. Refactor writeJson (or internal helper) to:
    • Write data to a temporary file (e.g., filename.json.tmp).
    • Flush/Sync to disk.
    • Use fs.rename to atomically replace the target file with the temporary file.
  2. Ensure this applies to all critical JSON stores (tracker, users, visited, blacklist).

Benefits: Guarantees that the data files are always valid JSON, even if the Updater crashes mid-write.

tobiu added the enhancement label on Feb 10, 2026, 3:08 PM
tobiu added the ai label on Feb 10, 2026, 3:08 PM
tobiu added parent issue #8930 on Feb 10, 2026, 3:09 PM
tobiu assigned to @tobiu on Feb 10, 2026, 3:09 PM
tobiu referenced in commit 59e42ec - "Enhancement: Implement Atomic File Persistence (#9084)" on Feb 10, 2026, 3:12 PM
tobiu
tobiu Feb 10, 2026, 3:12 PM

Input from Gemini 3 Pro:

✦ I have updated DevRank.services.Storage to use atomic file writes.

Implementation: The writeJson method now follows this safe pattern:

  1. Writes data to a temporary file (filename.tmp).
  2. Renames the temporary file to the target filename (fs.rename).

This ensures that users.json and tracker.json are never left in a corrupted or truncated state if the process crashes during a write operation. The .tmp file is naturally cleaned up by the rename operation on success. In case of a crash, a leftover .tmp file might remain, but the critical data file stays intact.

tobiu closed this issue on Feb 10, 2026, 3:12 PM