docs(research): plan dataset reuse and settings custody

This commit is contained in:
Boki 2026-10-27 01:13:49 -04:00
parent 7f7c07e35f
commit 5319bd1bb2
5 changed files with 88 additions and 3 deletions

View file

@ -0,0 +1,13 @@
# RP05 — Reuse retained datasets beyond the first catalog page
Parent E12. Priority P1 / High workflow defect. Complexity M. Dependencies RP03 and R11. Owner's "commit and continue" authorizes this narrow research follow-up; conditional performance work remains deferred.
Evidence: `backtestApiV2.listCanonicalDatasets` hardcodes `limit=50&offset=0`; `CanonicalSetup` provides only that selector. A fresh template cannot select an older retained dataset or an agent-supplied known hash. The backend already supports pagination and validated exact-hash lookup. Legacy `HistoricalDataSelection` demonstrates the existing load-more interaction. The two canonical transport methods also return unchecked successful JSON, which can crash rendering instead of presenting a recoverable error.
Scope: parameterize the existing canonical catalog request; add explicit load-more and known-hash selection in canonical setup. Preserve loaded pages and the selection on a failed next page; retry that same page, deduplicate overlapping hashes, and reset/fence stale page responses on refresh/retention. The exact-hash action uses the existing detail endpoint and must validate identity/eligibility before saving. A known selected hash remains visible outside the current page. Validate list/detail response envelopes and manifest shape at these existing transport boundaries; preserve valid unavailable entries and v2 manifests with non-null parentDatasetHash (the preparation-only schema currently forbids those). No new backend endpoint, database, generic picker, search service, automatic all-history load or financial changes.
Acceptance: choose and save a dataset beyond the first 50; choose an exact known hash even when absent from the list; malformed hashes do not fetch or submit; missing, unavailable, mismatched or malformed responses show errors and cannot authorize save; a later stale lookup/page cannot replace current state. Loading/empty/error states distinguish no loaded entries from lookup failure; loaded entries survive paging failures; loading controls cannot skip a failed page. Inspecting or typing a hash never submits the enclosing form. Saving uses the verified chosen hash and its exact bounds; no run starts automatically. Refresh after retention includes the new dataset without duplicating rows or losing current selection.
Files/locks: `CanonicalSetup.tsx`, `backtestApiV2.ts`, focused `test/integration/canonical-workbench.test.tsx` (add a focused transport test file if necessary). Root owns the shared browser test and all planning state. Parallel with RP06, which owns only the parent page and its lifecycle tests. Frontend implementation agent; independent transport/UI review.
Required tests: >50 entries and exact hash; appended page failure/retry and overlapping responses; stale refresh/lookup; unavailable/corrupt/malformed entries including valid converted v2 parent hash; final saved input and no unintended submission. Extend real authenticated browser/database workflow. Run focused tests, application/authored-test types, strict lint, production build; root combined repository and browser gates. Risk: stale data changing selection or falsely accepting malformed metadata; existing server admission remains authoritative.

View file

@ -0,0 +1,13 @@
# RP06 — Preserve settings and captured preparation across backtest tabs
Parent E12. Priority P1 / High custody defect. Complexity M. Dependency RP03. Owner continuation authorizes this correction; ADR-006 and financial semantics stay unchanged.
Evidence: `BacktestDetailPageV2.renderTabContent` mounts canonical setup only in the settings case. Any other tab unmounts it and `DatasetPreparation`, destroying a preview or ambiguous retention retry. `useUnsavedWarning` protects browser unload only, so an ordinary same-page tab click silently loses the exact captured input. The page also clears the configure flag on every run-ID change, although the edited template still belongs to the same backtest.
Scope: keep settings lazily mounted after the first visit for the current backtest; hide them accessibly while other tabs render. Preserve policy/strategy drafts, loaded source metadata, captured preview and unconfirmed retention retry across tabs and same-backtest run selections. Scope ownership to the backtest ID; changing it disposes/fences the previous editor and never renders old inputs for the new owner. Explicit close/discard and authoritative saved-definition updates keep their existing semantics. Do not start settings/catalog requests before first visit, duplicate the editor or trigger hidden saves/runs. No persistent browser draft store, global router blocker, framework or financial change. Leaving this backtest/reloading remains outside the in-memory preservation guarantee.
Files/locks: `apps/stock/web-app/src/features/backtest/BacktestDetailPageV2.tsx`, existing `test/integration/backtest-run-controls.test.tsx` and narrowly scoped lifecycle tests. Do not edit CanonicalSetup or its transport (RP05 ownership). Root owns shared browser tests and planning state. React lifecycle implementation agent; independent review.
Acceptance/tests: demonstrate the original loss before changing code; ordinary name/policy changes survive Settings → Runs → Settings; capture and ambiguous-retention retry retain exactly the same input/hash without another source read; late completion while hidden stays owned by the same template; same-backtest run navigation preserves the draft. Other tabs cannot expose/focus hidden settings, and entering a backtest does not eagerly fetch the catalog. Changing backtest ID clears the old editor and fences late completion; explicit discard/save still work. Verify zero unintended template/run writes during navigation, with a real browser retention retry scenario. Existing polling, cancellation, archived and legacy-history behavior must pass.
Gates: focused page/lifecycle tests, application/authored-test types, strict lint, production build; root full repository and Chromium suite. Parallel with RP05 because the parent owns mounting while the child owns dataset choice. No broad navigation refactor; the main regression risks are stale ownership, hidden focusable inputs and newly eager requests.