fix: atomic config write and handle missing v2 job budget in non-TTY output#54
Open
fcfsprojects wants to merge 1 commit into
Open
Conversation
…output Fix Virtual-Protocol#40: saveConfig now writes to a temp file and atomically renames to the final path, preventing truncated/partial JSON if the process is interrupted mid-write. Fix Virtual-Protocol#39: non-TTY job list output no longer crashes on BigInt(null) when a v2 job has no budget set. Mirrors the TTY path which already prints 'N/A' for missing budgets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two issues found by AntFleet two-model review:
#40 — Atomic config write
previously wrote directly to the final config path. If the process was interrupted or the write failed mid-write, the config file could be left truncated or as partial JSON. would then catch the parse failure and return an empty config object, making local agent/wallet/job registry state appear to be gone.
Fix: Write to a temp file () first, then atomically to the final path. On POSIX, is atomic — either the old file remains intact or the new file fully replaces it.
#39 — Missing v2 job budget in non-TTY output
The TTY output path for handles active v2 jobs without a budget by printing . However, the non-TTY output path unconditionally called for every non-legacy job. If a valid active v2 job had no , any scripted/non-TTY invocation (No active jobs., etc.) would throw instead of printing the job list.
Fix: Mirror the TTY path's null check — if is falsy, print instead of calling .
Verification
Closes #40, closes #39