From 76eb1b1255643c797a8a82f313480932f299b84a Mon Sep 17 00:00:00 2001 From: Boki Date: Tue, 27 Oct 2026 00:41:05 -0400 Subject: [PATCH] docs(research): plan multi-session preparation and horizon clarity --- docs/development/backlog/README.md | 5 ++- docs/development/backlog/dependencies.mmd | 6 +++ docs/development/backlog/manifest.json | 47 ++++++++++++++++++++++- docs/development/backlog/tasks/RP03.md | 17 ++++++++ docs/development/backlog/tasks/RP04.md | 11 ++++++ 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 docs/development/backlog/tasks/RP03.md create mode 100644 docs/development/backlog/tasks/RP04.md diff --git a/docs/development/backlog/README.md b/docs/development/backlog/README.md index 9d7530b1..43226582 100644 --- a/docs/development/backlog/README.md +++ b/docs/development/backlog/README.md @@ -8,7 +8,7 @@ [manifest.json](manifest.json) owns scheduling metadata: status, priorities, dependencies, ADR approvals, assignments and write locks. Task Markdown owns implementation scope/evidence/acceptance. This index and the [graph](dependencies.mmd) are derived views. Only the planning/integration owner updates scheduling state. -**Current total: 78 retained IDs.** RP01/RP02 add the authorized real-data workflow. The earlier 68 IDs retain their state. E11 adds seven authorized cleanup tasks and one conditional replay extraction; see the manifest for current scheduling. The original backlog accounted for 55 IDs. F09/P07 added projection/profiling work; the owner deferred P08's TypeScript optimization. Merged records preserve traceability; never execute them separately. Deferred work requires its stated trigger and explicit activation. +**Current total: 80 retained IDs.** RP01/RP02 add the authorized real-data workflow. The earlier 68 IDs retain their state. E11 adds seven authorized cleanup tasks and one conditional replay extraction; see the manifest for current scheduling. The original backlog accounted for 55 IDs. F09/P07 added projection/profiling work; the owner deferred P08's TypeScript optimization. Merged records preserve traceability; never execute them separately. Deferred work requires its stated trigger and explicit activation. States: ready, claimed, in_progress, review, done, blocked, deferred, merged. “Ready” means no code/ADR prerequisite, not execution authority. Implementation dependencies require accepted integration. `release_gates` govern enabling an end-to-end feature, not component coding or integration; conditional gates apply only to the named capability. F05 may integrate before F06, but its replay behavior is not released until F06 proves it. @@ -161,3 +161,6 @@ Owner authorized planning and per-task implementation commits. [Execution plan a - [RP01: Stored source coverage and quality](tasks/RP01.md) — done, `5bfaf37d`; explicit indexed instrument/timeframe lookup and window diagnostics. - [RP02: Retained real-data pilot](tasks/RP02.md) — done after explicit approval; nine completed runs, exact reproduction, independently reconciled results and an evidence-linked finding reopened in the web app. [Evidence](../real-data-research.md). + +- [RP03: Declared-session source preparation](tasks/RP03.md) — in progress; extends the existing capture path without changing financial semantics. +- [RP04: Evaluation horizon and CAGR presentation](tasks/RP04.md) — in progress; makes short-sample annualization explicit. diff --git a/docs/development/backlog/dependencies.mmd b/docs/development/backlog/dependencies.mmd index de14aa36..d2765c70 100644 --- a/docs/development/backlog/dependencies.mmd +++ b/docs/development/backlog/dependencies.mmd @@ -268,6 +268,8 @@ flowchart TD subgraph E12["E12: Real-data research workflow"] RP01["RP01: Scoped stored-source inspection"] RP02["RP02: Retained real-data research pilot"] + RP03["RP03: Declared-session source preparation"] + RP04["RP04: Evaluation horizon and CAGR presentation"] end CL05 --> RP01 CL06 --> RP01 @@ -279,3 +281,7 @@ flowchart TD R12 --> RP02 %% RP01 supports manual inspection but does not block offline pilot preparation. %% RP02 execution retains the existing human strategy-version approval gate. + + RP01 --> RP03 + D01 --> RP03 + RP02 --> RP04 diff --git a/docs/development/backlog/manifest.json b/docs/development/backlog/manifest.json index 181074ab..aa3545b1 100644 --- a/docs/development/backlog/manifest.json +++ b/docs/development/backlog/manifest.json @@ -1,8 +1,8 @@ { "schema_version": 1, - "plan_revision": "2026-10-27.88", + "plan_revision": "2026-10-27.89", "repository_base": "b7aeca4", - "plan_status": "real_data_research_completed", + "plan_status": "multi_session_research_preparation_in_progress", "execution_authorized": true, "execution_scope": { "authorized_by": "Owner: commit and continue with the rest of the tasks till 100%", @@ -3138,6 +3138,49 @@ "release_gates": [], "reviewer": "/root/review_cleanup_backend", "review_notes": "Owner explicitly approved exact SMA version. Nine runs completed; exact reproduction, repeated receipt IDs, 2374 independent assertions and actual web reopen passed. Completion evidence in real-data-research.md; research records are persistent runtime data, not application source changes." + }, + { + "id": "RP03", + "title": "Prepare stored data from explicitly declared sessions", + "epic": "E12", + "priority": "P1", + "severity": "High", + "status": "in_progress", + "dependencies": [ + "RP01", + "D01" + ], + "decision_dependencies": [], + "task_file": "backlog/tasks/RP03.md", + "complexity": "M", + "assignment": "/root/implement_source_inspection", + "completed_commit": null, + "blocker": null, + "integration_state": "implementing", + "integration_base": "91cc7e48", + "completion_evidence": "real-data-research.md", + "release_gates": [] + }, + { + "id": "RP04", + "title": "Explain the evaluation horizon and CAGR in canonical results", + "epic": "E12", + "priority": "P1", + "severity": "High", + "status": "in_progress", + "dependencies": [ + "RP02" + ], + "decision_dependencies": [], + "task_file": "backlog/tasks/RP04.md", + "complexity": "S", + "assignment": "/root/review_cleanup_frontend", + "completed_commit": null, + "blocker": null, + "integration_state": "implementing", + "integration_base": "91cc7e48", + "completion_evidence": "real-data-research.md", + "release_gates": [] } ], "review_note": "Independent skeptical revision: four superseded tasks retain stable IDs; deferred work is not a dependency of scheduled tasks. Release gates are distinct from implementation prerequisites.", diff --git a/docs/development/backlog/tasks/RP03.md b/docs/development/backlog/tasks/RP03.md new file mode 100644 index 00000000..80ac9522 --- /dev/null +++ b/docs/development/backlog/tasks/RP03.md @@ -0,0 +1,17 @@ +# RP03 — Prepare stored data from explicitly declared sessions + +Parent: E12. Priority P1 / High. Complexity M. Owner continuation authorizes this next research-product slice; optional performance work stays deferred. Dependencies: RP01 and D01. ADR-003/006 remain unchanged. + +Problem/evidence: `apps/stock/web-api/src/services/stored-dataset-preparation.ts` reads one continuous warmup-to-end range before strict OHLCV validation. Interior after-hours null-volume rows therefore block multi-session preparation. RP02 avoided the issue with one session. The existing v2 dataset/calendar and Rust replay already support multiple sessions; `StorageService` must remain strict. + +Contract: preserve `{metadata}` and its current response. Opt in with `{metadata, selection: "declared-sessions"}` at the existing stored-source endpoint; its response adds the same selection literal alongside unchanged captured `input` and `preparation`. No new dataset hash format or database migration. The calendar plus captured bars remain replay provenance; selection describes how source rows were captured. + +Scope: one series/provider as today. Intersect the selected series' declared calendar sessions with `[warmupStart, tradeEnd)`, read each nonempty window sequentially through the strict reader, validate against that individual window, snapshot values before another await, combine and assign deterministic global ordinals. Empty selected sessions fail; invalid selected rows abort the entire preparation. An interval crossing the declared close fails normalizer validation; never shrink the query to hide it. Check aborts between reads. No interpolation, post-filtering, calendar inference, source writes, new caps/cache or financial-policy changes. Sparse nonempty sessions retain existing semantics; do not claim complete coverage. + +Web scope: a third input choice, "Stored EOD — declared sessions only", reuses metadata upload, preview and captured-input retention. Show the explicit session scope and intersected UTC windows. Verify the echoed response selection; reject missing/wrong mode. Existing loading/error/empty states and mode-change cancellation apply. An unresolved retention receipt locks the input/mode and retries the same input/hash without source reads. Inspector diagnostics remain independent and do not establish calendar coverage. + +Likely files/locks: `apps/stock/config/src/contracts/canonical-research.ts`, `apps/stock/web-api/src/services/stored-dataset-preparation.ts`, `apps/stock/web-app/src/features/backtest/services/backtestApiV2.ts`, `.../components/DatasetPreparation.tsx`, focused stored-preparation API/UI tests. Root owns backlog, documentation, integration and browser test file. One implementation owner; disjoint from RP04. + +Acceptance/tests: unchanged default query/output; two sessions with an intervening invalid close marker succeed only in explicit session mode; selected null/OHLC/identity/duplicate errors and missing sessions fail; per-window out-of-range adapter results fail; DST, early close and clipped bounds use declared instants; partial bars fail; metadata/earlier-row mutation cannot affect captured results; abort prevents later reads; repeated same capture has the same v2 hash; wrong response mode and late replies fail; retention retry never rereads. Extend the real browser preparation workflow. Validate a read-only actual stored multi-session preview against exact selected source rows; no new research execution is required. + +Gates: focused regressions, types/strict lint, full repository check, relevant disposable PostgreSQL retention tests and Chromium workbench. Independent backend/frontend acceptance before completion. Risk: hiding source defects outside incorrectly declared sessions or implying gap-free data; declarations remain explicit and unverified by the UI. diff --git a/docs/development/backlog/tasks/RP04.md b/docs/development/backlog/tasks/RP04.md new file mode 100644 index 00000000..4c0f1e89 --- /dev/null +++ b/docs/development/backlog/tasks/RP04.md @@ -0,0 +1,11 @@ +# RP04 — Explain the evaluation horizon and CAGR in canonical results + +Parent: E12. Priority P1 / High (research interpretation). Complexity S. Dependency: RP02. Owner continuation authorizes this presentation correction. ADR-006; no financial or analytics semantic change. + +Evidence: `libs/research/src/results.ts` computes CAGR using actual elapsed calendar time divided by 365 days. `CanonicalResults.tsx` shows CAGR without its evaluation duration and labels a separate policy generically as "Annualization: periods/year". RP02's five-and-a-half-hour total return of approximately -0.054575% produces -58.08% CAGR. The saved finding excludes that extrapolation, but the result UI should explain it itself. + +Scope: in `apps/stock/web-app/src/features/backtest/components/CanonicalResults.tsx`, show retained financial reporting start/end in UTC and elapsed calendar duration. Explain alongside CAGR that it extrapolates this interval to a 365-day year, includes nontrading elapsed time, and is not an observed annual return or forecast. Clarify that `periodsPerYear` governs periodic statistics. Preserve existing metric values, null/reason rendering, units, result contracts, rankings, engine behavior and old saved results. No arbitrary sample cutoff, hiding/recalculation of CAGR, new warning framework or financial calculations in the frontend. + +Acceptance/tests: realistic partial-session result displays exact UTC interval/duration and CAGR explanation with stored CAGR unchanged; multi-day/overnight duration is calendar elapsed time; null CAGR reason and existing fill-only view remain correct; periodic annualization label is unambiguous. Add focused production-component regression assertions in the existing result/UI suite; root may add browser assertions to its owned workbench scenario. Loading/error/empty behavior stays in the existing parent run view; no new backend/data dependency or request. + +Locks: CanonicalResults and its focused result tests only. Parallel with RP03; do not modify shared workbench E2E or manifest. Gates: focused UI tests, authored test/app types, strict lint and production build, root combined check/browser gate, independent review. Regression risk low; the primary risk is misstating the existing computation's time basis.