MicroFish/backend
FeelRatchanons 6686011f91 fix(simulation): make create_simulation idempotent to prevent duplicate sims
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>
2026-06-13 10:22:11 +07:00
..
app fix(simulation): make create_simulation idempotent to prevent duplicate sims 2026-06-13 10:22:11 +07:00
scripts Add UTF-8 encoding support for Windows in simulation_runner.py and run_parallel_simulation.py to resolve character encoding issues with third-party libraries. 2025-12-26 18:14:57 +08:00
pyproject.toml fix(backend): constrain Python version to 3.11-3.12 2026-05-24 22:59:36 +08:00
requirements.txt fix(file_parser): handle non-UTF-8 encoded text files with automatic encoding detection 2026-01-22 18:28:37 +08:00
run.py Add UTF-8 encoding support for Windows console in run.py and logger.py to prevent character encoding issues 2025-12-26 17:58:48 +08:00
uv.lock fix(backend): constrain Python version to 3.11-3.12 2026-05-24 22:59:36 +08:00