Skip to content

fix: atomic config write and handle missing v2 job budget in non-TTY output#54

Open
fcfsprojects wants to merge 1 commit into
Virtual-Protocol:mainfrom
fcfsprojects:fix/atomic-config-write-and-missing-budget
Open

fix: atomic config write and handle missing v2 job budget in non-TTY output#54
fcfsprojects wants to merge 1 commit into
Virtual-Protocol:mainfrom
fcfsprojects:fix/atomic-config-write-and-missing-budget

Conversation

@fcfsprojects

Copy link
Copy Markdown

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

@virtuals-protocol/acp-cli@1.0.19 build
npm run clean && esbuild bin/acp.ts --bundle --platform=node --format=esm --target=node18 --outfile=dist/bin/acp.js --packages=external

@virtuals-protocol/acp-cli@1.0.19 clean
node -e "require('fs').rmSync('dist', { recursive: true, force: true })" passes with no errors

  • Both changes are minimal and follow existing patterns in the codebase
  • No new dependencies added

Closes #40, closes #39

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write ACP config atomically to avoid corrupting local agent state Handle missing v2 job budgets in non-TTY job list output

1 participant