# CL12 — Simplify retired execution seams while preserving historical reads Parent epic: E10. Priority/severity: P2 / Medium. Complexity: M. Specialization: Compatibility cleanup and execution boundaries. 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 strategy developer, I want the supported execution path to be obvious, so obsolete APIs and impossible fallback branches do not look like alternative financial authorities. Expected benefit: Removes confirmed-unreachable new-run code and sharpens supported-versus-compatibility boundaries without deleting useful history. ## Verified evidence - **Verified — CL-F09:** New run admission rejects non-catalog requests before retaining legacy snapshot fallback branches later in the same method. [apps/stock/web-api/src/services/backtest-v2.service.ts:461](../../../../apps/stock/web-api/src/services/backtest-v2.service.ts#L461). - **Verified — CL-F09:** The legacy runBacktest entry exists only to reject execution. [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:70](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L70). - **Verified — CL-F09:** Legacy and canonical native exports remain adjacent; this alone does not prove legacy exports are unused. [apps/stock/engine/index.mjs:28](../../../../apps/stock/engine/index.mjs#L28). ## Implementation scope - Inventory the callers of touched legacy seams and classify each as supported execution, historical result compatibility, preserved research, or explicit retired-API rejection in the story handoff. - Remove branches proved unreachable after canonical admission and stop carrying their legacy input requirements through current run helpers. - Keep explicit retired-API responses small and truthful. Preserve their current HTTP/status behavior unless a separately approved API change is required. - Extend existing architecture checks so canonical entrypoints cannot regain legacy accounting/fill fallback dependencies. Preserve compatibility result readers and retained artifacts. Likely existing files/modules: - `apps/stock/web-api/src/services/backtest-v2.service.ts` - `apps/stock/web-api/src/services/backtest-result.ts` - `apps/stock/orchestrator/src/backtest/BacktestRunner.ts` - `apps/stock/orchestrator/src/backtest/execution-engine.ts` - `apps/stock/orchestrator/src/api/rest/backtest.ts` - `scripts/test/architecture.test.ts` ## Exclusions - No mass deletion or rewrite of old strategies, calculation APIs, legacy Rust exports, short-trade examples, financial fixtures or stored results. - No changes to historical request/result formats, economic policies, original reproduction artifacts or supported risk controls. ## Dependencies and ownership Implementation prerequisites: [CL08](CL08.md). Write locks: `web-backtest-service`, `legacy-execution-boundaries`. Parallel execution: After CL08. One owner for the affected execution/API seams. This is not authority to remove unrelated code merely because static imports look absent. ## Acceptance criteria 1. Current run submission contains no fallback branch that its admission guard makes impossible. 2. Canonical entrypoint dependency checks forbid legacy financial execution; retired APIs still return their documented rejection rather than starting work. 3. Existing legacy result mapping and historical reads pass unchanged; callers of every removed branch are documented and verified. 4. Native financial output, strategy decisions, fees and equity remain identical on existing deterministic fixtures. 5. No preserved calculation capability, retained artifact or compatibility reader is removed without separate evidence and scope approval. ## Mandatory verification Use existing workspace builds. Tests requiring PostgreSQL/Redis must use explicitly disposable safety fixtures. ```sh bun test scripts/test/architecture.test.ts bun test test/integration/canonical-durable-runner.test.ts test/integration/backtest-result-mapping.test.ts bun test test/integration/canonical-sma.test.ts test/integration/strategy-runtime.test.ts bun run typecheck ``` Required regression cases: retired entry rejection, canonical-only admission, historical result reads, no legacy fallback and unchanged economic fixtures. ## Risks and definition of done Runtime exports and retained artifacts have consumers beyond simple source imports. Keep native exports and preserved algorithms out of this story; distinguish unreachable control flow from merely old code. 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.