stock-bot/docs/development/backlog/tasks/RP09.md

15 lines
3.2 KiB
Markdown

# RP09 — Preserve strategy work before backtest handoff
Parent E12. Priority P1 / High custody defect. Complexity S. Dependencies R02 and A02. Owner continuation authorizes this correction; no authorization or financial policy changes.
Verified baseline: `StrategyDetailPage` enables **Use in backtest** after parameter validation and guards navigation only with `metadataDirty`. Pending and lost-response clone reproductions navigate away with no confirmation, destroying the local retry receipt. `useStrategyClone` owns the frozen body/key for that route; `CandidatePublication` has the same local ownership. **Clone version** also remains enabled while candidate publication owns work, permitting competing operations. Baseline probe: `/tmp/stock-bot-navigation-audit/probe.log`.
Scope: reuse existing publication/clone state and clear/discard/retry controls. Disable and handler-guard **Use in backtest** while a candidate package/publication or clone form/receipt is outstanding; show a concise explanation of how to finish or clear that work. Disable and guard **Clone version** while candidate publication owns work. Normal validated parameter handoff stays unchanged, including the existing metadata-discard confirmation; parameter edits transferred to the backtest are not discarded. No router blocker, persistent receipt store, new state framework or backend API. Other deliberate navigation keeps its current behavior.
Ownership: strategy agent owns `StrategyDetailPage.tsx` and focused existing strategy/publication UI tests; touch a child only if a reproduced ownership gap requires it. Root owns shared Chromium tests/docs/manifest/commits. Independent review required.
Acceptance/tests: pending and ambiguous clones/publications cannot disappear through backtest handoff; retry uses the original exact body/key. Competing clone admission is blocked while publication owns work. Clearing an unpublished package or explicitly discarding a clone restores ordinary handoff. Validated parameters transfer unchanged without a new unnecessary prompt. Late replies after deliberate navigation remain fenced; no extra mutations on blocked actions. Reuse existing fixtures and prove the baseline failure before the fix.
Gates: focused strategy/publication tests, application/authored types, strict lint/build, root full repository check and browser regression through actual catalog/clone routes. No performance, paper/live work or global navigation redesign.
Accepted October 27, 2026. The baseline custody defect was reproduced before the change. Independent review passed 29 focused tests / 199 assertions and also closed the reverse-order competing-write path by disabling publication while a clone form is open. Root full repository check passed, including 1,334 integration and 150 Rust tests. Actual Chromium clone recovery passed with 50 assertions after correcting a fixture count to account for default publication lineage; same body/key/version and exactly one additional child version are proven. [Combined evidence](../../real-data-research.md) records all 21 browser scenarios and the initial fixture failure. Application and authored types, lint, formatting and builds passed; no child contract, backend or financial semantics changed.