Creating a simulation was not idempotent: each POST /api/simulation/create minted a fresh sim_<uuid>. The frontend wraps createSimulation in requestWithRetry(..., 3, 1000), so a slow/timed-out first request triggers a retry that creates a second identical simulation for the same project+graph (observed: two sims created ~2s apart). Guard against this by reusing an existing, not-yet-run simulation for the same project_id + graph_id (and matching platform flags) when status is CREATED/PREPARING/READY and current_round == 0. A force_new=True escape hatch preserves the ability to intentionally create a fresh simulation. Verified: repeated /create calls now return the same simulation_id instead of spawning duplicates. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| app | ||
| scripts | ||
| pyproject.toml | ||
| requirements.txt | ||
| run.py | ||
| uv.lock | ||