# CL10 — Separate experiment modes and make draft/submission state explicit Parent epic: E10. Priority/severity: P2 / Medium. Complexity: M. Specialization: React experiment workflow state. Scheduling metadata: [manifest](../manifest.json). Read the [cleanup execution contract](../../CLEANUP.md#execution-contract). Implementation and validated commits were authorized after planning; scheduling and completion evidence live in the manifest. ## User story and outcome As a researcher configuring experiments, I want parameter sweeps, cost studies and validation recipes to have clear action ownership, so switching modes cannot lose or duplicate work. Expected benefit: Makes the 623-line ExperimentEditor easier to maintain while retaining its important receipt and race protections. ## Verified evidence - **Verified — CL-F07:** The editor combines multiple experiment kinds, template loading, candidate state, preview revisions and mutually exclusive submission owners. [apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx:49](../../../../apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx#L49). - **Verified — CL-F07:** Chronological and walk-forward preflight components share draft fields and submission ownership through the same parent. [apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx:589](../../../../apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx#L589). ## Implementation scope - Extract focused template/candidate selection, ordinary/cost preview-submission, and validation recipe composition at coherent state boundaries. - Represent each action as an explicit draft/preview/submitting/uncertain/accepted state where that replaces coupled refs and Booleans. Keep concurrency coordination local to this workspace. - Retain a single coordinator for mutually exclusive submissions and exact frozen key/body custody after an ambiguous response. - Keep current response parsers, reset-segment validation semantics, invalidation rules and unsaved-change behavior. Likely existing files/modules: - `apps/stock/web-app/src/features/experiments/components/ExperimentEditor.tsx` - `apps/stock/web-app/src/features/experiments/components/ChronologicalValidationPreflight.tsx` - `apps/stock/web-app/src/features/experiments/components/WalkForwardPreflight.tsx` - `test/integration/experiments-ui.test.tsx` Proposed new files/modules (names may be adjusted within this scope): - `apps/stock/web-app/src/features/experiments/hooks/useExperimentSubmission.ts` - `apps/stock/web-app/src/features/experiments/components/ExperimentDraftForm.tsx` ## Exclusions - No new optimizer, validation policy, data model or financial behavior. - No HTTP client/transport edits owned by CL07 and no global workflow/state-machine framework. ## Dependencies and ownership Implementation prerequisites: None. Write locks: `web-experiment-editor`. Parallel execution: Ready independently. Can run alongside CL07 only with disjoint authored client/test files and preserved public client contracts. Integration checks must cover their combination. ## Acceptance criteria 1. The parent composes coherent workflows and owns one explicit submission coordinator; it no longer manages all request and form transitions inline. 2. Changing template, candidate, grid or mode invalidates only the matching preview and cannot submit stale data. 3. An uncertain accepted request keeps its exact body/key and blocks conflicting ordinary/chronological/walk-forward submission until resolved or explicitly abandoned. 4. Late responses after navigation or newer edits cannot overwrite current preview, errors or receipts. 5. Saved experiment IDs, validation reports, failed-trial visibility and current comparison links remain unchanged. ## Mandatory verification Use existing workspace builds. Tests requiring PostgreSQL/Redis must use explicitly disposable safety fixtures. ```sh bun test test/integration/experiments-ui.test.tsx test/integration/cost-sensitivity-ui.test.tsx bun test test/integration/chronological-validation-durable-ui.test.tsx test/integration/walk-forward-ui.test.tsx bun test test/integration/experiment-retries-ui.test.tsx bun run typecheck ``` Required regression cases: mode switching, edited-after-preview, candidate parameter changes, concurrent clicks, ambiguous response, exact receipt retry, navigation races and explicit discard. ## Risks and definition of done A visually cleaner form can accidentally weaken mutual exclusion or regenerate a receipt. Preserve the current race tests and test transitions rather than only rendered snapshots. Done means the acceptance criteria and relevant checks pass, an independent review accepts the focused diff, and the integrator records exact test results and a commit/reference in the manifest. Preserve the compatibility and financial invariants in the cleanup execution contract.