MicroFish/backend/app
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
..
api fix(i18n): replace hardcoded Chinese stage names in simulation prepare SSE 2026-04-01 17:31:00 +08:00
models feat(i18n): replace hardcoded Chinese in backend SSE progress messages 2026-04-01 16:32:10 +08:00
services fix(simulation): make create_simulation idempotent to prevent duplicate sims 2026-06-13 10:22:11 +07:00
utils refactor: add type hints and FileParser.is_supported() helper 2026-05-23 14:57:46 +08:00
__init__.py Implement Report Agent for automated report generation and interaction 2025-12-09 15:10:55 +08:00
config.py refactor: add type hints and FileParser.is_supported() helper 2026-05-23 14:57:46 +08:00