altimate-code
altimate-code copied to clipboard
fix: CI failure — concurrent trace file writes produce corrupted JSON
Description
The test Concurrent sessions > concurrent traces to same session ID overwrite cleanly is failing on main with:
SyntaxError: JSON Parse error: Unterminated string
Root cause: FileExporter.export() uses fs.writeFile() (non-atomic), while the snapshot() method uses atomic writes (tmp + rename). When concurrent sessions write to the same trace file, a snapshot rename can race with a non-atomic writeFile, producing truncated JSON.
CI run: https://github.com/AltimateAI/altimate-code/actions/runs/23985613053/job/69956978499