# R11 — Select and reuse frozen datasets in the workbench Parent epic: E6. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Full-stack market data/research. Scheduling source of truth: [manifest entry R11](../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 - **KEEP-02 — Verified:** Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. [apps/stock/orchestrator/src/data/historical-dataset.ts:98](../../../../apps/stock/orchestrator/src/data/historical-dataset.ts#L98); [apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190](../../../../apps/stock/orchestrator/src/backtest/BacktestRunner.ts#L190). - **DAT-01 — Verified:** Dataset v1 has one bar timestamp and interval in the manifest, without explicit bar-end/availability semantics. Session dates cannot safely be treated as observation times. [libs/core/types/src/historical-data.ts:90](../../../../libs/core/types/src/historical-data.ts#L90); [apps/stock/orchestrator/src/services/StorageService.ts:177](../../../../apps/stock/orchestrator/src/services/StorageService.ts#L177). - **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107). ## Intended behavior and implementation scope Expose metadata-only listing/detail for retained backtest_datasets and add selection by hash to the existing configuration form. Offer either a known frozen dataset or an explicit source request whose data will be prepared asynchronously by the existing runner. Show the eventual pinned hash and coverage; no separate dataset job service. Measurable benefit: Delivers dataset choice and reuse as a real web workflow. ## Exclusions No new storage service, arbitrary truncation, full corporate-action feed, or synchronous API-side historical loading. ## Likely files and ownership - apps/stock/web-api/src/routes/ (dataset endpoints) - apps/stock/web-api/src/services/ (dataset metadata) - apps/stock/web-app/src/features/backtest/components/BacktestConfiguration.tsx - apps/stock/web-app/src/features/backtest/components/CreateBacktestDialog.tsx - apps/stock/orchestrator/src/backtest/BacktestRunner.ts Write locks: dataset-contract, web-backtest-detail, web-backtest-service. Root coordinates shared contracts; backend and frontend owners may use isolated worktrees with disjoint actual files. Lock names do not override actual overlapping files. ## Dependencies and blockers Implementation requires [D01](D01.md), [O01](O01.md) integrated. Architecture decisions: ADR-003, ADR-006. Agents may not independently amend their policies. Feature activation/release gates: [W04](W04.md). These do not block implementing or integrating this component against its own tests. Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries. ## Acceptance criteria - User selects a compatible dataset by hash or requests a new source/date/interval range; mismatch rejects before simulation. - Source-request submission is labelled unpinned/preparing, not reproducible data; the first prepared snapshot is attached atomically before execution and reused on retry. - Listing does not return full bar arrays; missing/corrupt/unknown-coverage datasets show actionable status. ## Mandatory tests - dataset_list_metadata_only, select_hash_compatibility, source_request_freeze_status, retry_reuses_bound_hash. - Browser select existing dataset -> run -> inspect pinned hash; invalid coverage/timeframe feedback. 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 Confusing source-query identity with frozen content identity; maintain legacy v1 snapshots and explicit preparation state. 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: GET dataset metadata/manifest and existing hash-or-source configuration; no new dataset job service. - Backend/data dependencies: D01 and existing retained snapshots. Implementation does not require all W04 browser release work. - Loading/error/empty behavior: Picker empty/loading/retry/incompatible states; source request remains unpinned until atomic preparation. - Release: This flow must pass the shared W04 browser harness before user-facing release; do not build another harness. ## 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. ## Execution contract — 2026-10-23 - Existing web execution remains v1/legacy. Catalog v2 entries are unsupported pending R05; do not adapt them or switch engine defaults. - Metadata-only list/detail includes the v1 manifest, storage key, version, creation time and actionable status. No bar arrays enter API memory. Validate structure/count/key agreement; describe coverage as unknown and full content integrity as not verified by catalog. The durable runner retains full content validation. - Reuse is exact: sorted instruments, full UTC bounds (including intraday milliseconds), interval, adjustment/timestamp policy and hash. No implicit slicing. An explicit source conflicting with retained provenance rejects; omitted/auto allows exact retained reuse. - Optional `dataSource: auto | questdb | eod` reaches existing asynchronous storage loading. Definitions and accepted snapshots retain it. No synchronous provider access in API. - Save/update/new submission checks selected metadata before execution. Idempotent submission receipts are returned before revalidating mutable definitions or current catalog state. - Run dataset projection reads only immutable request snapshot and atomic binding. Pending/source preparation is visibly unpinned; failed runs never become successful merely because a hash is bound. - Reuse one picker in creation and Settings; preserve exact intraday bounds and missing hash selections. Source mode works when catalog is empty/unavailable. Keep existing economics warnings. - Root owns shared contracts/source plumbing/route mount/browser tests/planning; backend and frontend slices own disjoint files. No Rust financial changes, extra storage/queue service, strategy catalog or performance work. ## Validated handoff — 2026-10-23 Integrated exact v1 catalog/selection/source/run-binding flow with unchanged durable content validation and engine defaults. Concurrent definition edits now lock before merge/validation. Independent review accepted; all required metadata/compatibility/source/retry cases and shared browser flows passed. Full PostgreSQL suite: 111 tests / 792 assertions; final browser: 6 / 66; final release-addon focused suite: 94 / 596. Strict test types, scoped lint/format and repository gates passed (see manifest for exact sequencing and evidence). Status, hashes, commands, limitations and acceptance state remain canonical in `manifest.json` → `nineteenth_wave_validation`. R01 is next; performance remains deferred.