# P03 — Reuse validated datasets within bounded native workers Parent epic: E7. Priority/severity: P2 / Medium. Relative complexity: M. Recommended specialization: Performance/infrastructure engineering. Scheduling source of truth: [manifest entry P03](../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 - **PER-01 — Verified:** EventQueue insertion scans prior events; native run is synchronous/one-shot and returns full JSON. Actual end-to-end bottleneck distribution still needs controlled measurements. [apps/stock/engine/src/backtest/mod.rs:138](../../../../apps/stock/engine/src/backtest/mod.rs#L138); [apps/stock/engine/src/api/backtest.rs:194](../../../../apps/stock/engine/src/api/backtest.rs#L194). - **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). ## Intended behavior and implementation scope Load/hash/validate one dataset per worker and create isolated trial sessions over it. Measure object/JSON versus typed columnar buffers; adopt typed buffers only with a demonstrated transfer/allocation benefit. Keep ownership/lifetime explicit and invalidate by dataset/feature version. Measurable benefit: Reduces repeated preparation before adding a DSL. ## Exclusions No speculative distributed infrastructure or weakened correctness gates. ## Likely files and ownership - apps/stock/orchestrator/src/backtest/native-worker-protocol.ts - apps/stock/orchestrator/src/backtest/native-worker.ts - apps/stock/engine/src/api/backtest.rs Write locks: worker-protocol, native-public-api. One agent owns this change. Lock names do not override actual overlapping files. ## Dependencies and blockers Implementation requires [F07](F07.md), [P01](P01.md) integrated. Architecture decisions: ADR-004, ADR-008. Agents may not independently amend their policies. Deferred: Only after measured repeated dataset admission is a material sweep cost; not a prerequisite for parallel trials. Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries. ## Acceptance criteria - N trials sharing a dataset incur one dataset admission per worker, not per trial. - Disposing a trial clears mutable strategy/account state but retains immutable data; worker disposal releases buffers. - Output hashes match uncached runs and sequential trials cannot contaminate one another. ## Mandatory tests - resident_dataset_hit_counter, trial_state_reset, incompatible_version_miss, dispose_memory_plateau. - P01 warmed sweep time/RSS and serialization-byte comparison. 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 Performance measurements can hide semantic changes; require economic hash equivalence. 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. ## 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.