# W03 — Separate save, submit and repeat-safe run creation Parent epic: E5. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack durable workflow. Scheduling source of truth: [manifest entry W03](../manifest.json). No task is authorized until the plan is approved. Dependencies and decision references below describe the design; the manifest controls current readiness. ## Evidence and root cause - **WEB-03 — Verified:** Definition creation auto-starts by default and catches submission failure; run creation has no client submission key. Re-run uses current definition rather than immutable original input. [apps/stock/web-api/src/services/backtest-v2.service.ts:105](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L105); [apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx:173](../../../../apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx#L173). - **WEB-01 — Verified:** The real backtest list/detail/API/SQL flow already exists. Strategy/project/experiment work should extend it; App strategy/analytics views are placeholders. [apps/stock/web-app/src/app/App.tsx:24](../../../../apps/stock/web-app/src/app/App.tsx#L24); [apps/stock/web-api/src/services/backtest-v2.service.ts:211](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L211). ## Intended behavior and implementation scope Make the web save action explicitly non-running; add an explicit Save and run operation with visible submit failures. Add a principal-scoped submission key plus payload hash so transport retries return the same run. Preserve transactional request snapshot/outbox creation and legacy compatibility explicitly. Measurable benefit: Removes accidental/duplicate runs and hidden submission errors. ## Exclusions No unrelated refactor, new service or broker activation. ## Likely files and ownership - apps/stock/web-api/src/services/backtest-v2.service.ts - apps/stock/web-api/src/routes/backtests-v2.routes.ts - apps/stock/web-app/src/features/backtest/components/CreateBacktestDialog.tsx - apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts - database/postgres/init/ (new additive migration) Write locks: web-backtest-detail, web-backtest-service, sql-migrations. One agent owns this change. Lock names do not override actual overlapping files. ## Dependencies and blockers Implementation requires [O01](O01.md) integrated. No additional economic-policy approval is needed for this narrowly scoped task. Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries. ## Acceptance criteria - Repeated same-key/same-payload submit yields one run and outbox entry; changed payload under same key returns409. - Saving a definition creates no hidden job; submission failure remains visible and retryable. - Concurrent submissions preserve run numbering; non-browser clients use the same endpoint semantics. ## Mandatory tests - idempotent_submission_postgres_race, submission_key_conflict, save_only, save_and_run_failure. - Existing durable-backtest and workflow suites. Apply the relevant [quality gates](../../QUALITY-GATES.md); submit exact commands, outcomes and skipped checks. Named cases above are required regression scenarios, not claims that those tests already exist. ## Regression risks and rollback Compatibility or lifecycle regression; preserve frozen inputs, old results and existing failure tests. Keep migrations additive and previous results readable. Do not add a switch that restores a correctness defect. Versioned cutover/migration is required only when persisted contracts or active engines change; never silently fall back to old economics. ## Web/API contract and user states - API: POST definition with explicit autoStart:false; POST runs with Idempotency-Key, request fingerprint,202/Location;409 conflict. - Backend/data dependencies: Existing definitions/runs/dispatch plus one submission uniqueness constraint. - Loading/error/empty behavior: Submitting disables duplicate clicks; persisted definition survives submit failure; retry reuses the same key; empty strategy list explains unavailable capability. - User-facing completion is demonstrated by the acceptance criteria and interaction tests above; a backend-only implementation is insufficient where a UI is in scope. ## Handoff Report scope changes (if any), fixture expectations, API/schema changes, measurements, remaining limitations and commit/PR references once authorized. Request independent review; only the integration/planning owner may mark the manifest done.