From 43ea2cc9b69610066a78ef5395a77ecae21cb7b0 Mon Sep 17 00:00:00 2001 From: Boki Date: Tue, 27 Oct 2026 09:55:09 -0400 Subject: [PATCH] docs(research): plan validated retained dataset export --- docs/development/backlog/README.md | 4 ++- docs/development/backlog/dependencies.mmd | 3 +++ docs/development/backlog/manifest.json | 30 +++++++++++++++++++++-- docs/development/backlog/tasks/RP07.md | 17 +++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 docs/development/backlog/tasks/RP07.md diff --git a/docs/development/backlog/README.md b/docs/development/backlog/README.md index ffdd37d2..db82ef2b 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: 82 retained IDs.** RP01–RP06 add the authorized real-data workflow and its dataset reuse/custody follow-ups. 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: 83 retained IDs.** RP01–RP06 add the authorized real-data workflow and its dataset reuse/custody follow-ups. 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. @@ -167,3 +167,5 @@ Owner authorized planning and per-task implementation commits. [Execution plan a - [RP05: Retained dataset reuse](tasks/RP05.md) — done, `6d549542`; load older catalog pages or select and verify a known hash. - [RP06: Settings and preparation custody](tasks/RP06.md) — done, `c838e3d0`; preserve the current backtest draft and captured retry across tabs/run URLs. + +- [RP07: Retained dataset download](tasks/RP07.md) — in progress; export validated original inputs for local research. diff --git a/docs/development/backlog/dependencies.mmd b/docs/development/backlog/dependencies.mmd index a44ab416..88b46727 100644 --- a/docs/development/backlog/dependencies.mmd +++ b/docs/development/backlog/dependencies.mmd @@ -289,3 +289,6 @@ flowchart TD RP03 --> RP05 R11 --> RP05 RP03 --> RP06 + + RP05 --> RP07 + R05 --> RP07 diff --git a/docs/development/backlog/manifest.json b/docs/development/backlog/manifest.json index f91699a4..1c6b0cf1 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.92", + "plan_revision": "2026-10-27.93", "repository_base": "b7aeca4", - "plan_status": "dataset_reuse_and_settings_custody_complete", + "plan_status": "retained_dataset_export_in_progress", "execution_authorized": true, "execution_scope": { "authorized_by": "Owner: commit and continue with the rest of the tasks till 100%", @@ -3250,6 +3250,32 @@ "review_status": "accepted", "reviewer": "/root/review_cleanup_backend", "review_notes": "Independent review accepted. Combined full repository check passed; all 21 browser scenarios covered by 20 successful full-suite scenarios and the corrected RP05 focused rerun. No application code changed after full browser run." + }, + { + "id": "RP07", + "title": "Download a validated retained dataset for local research", + "epic": "E12", + "priority": "P1", + "severity": "High", + "status": "in_progress", + "dependencies": [ + "RP05", + "R05" + ], + "decision_dependencies": [], + "task_file": "backlog/tasks/RP07.md", + "complexity": "M", + "assignment": "/root", + "write_locks": [ + "retained-dataset-export-route", + "retained-dataset-download-ui" + ], + "completed_commit": null, + "blocker": null, + "integration_state": "implementing", + "integration_base": "d465e270", + "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/RP07.md b/docs/development/backlog/tasks/RP07.md new file mode 100644 index 00000000..b611a013 --- /dev/null +++ b/docs/development/backlog/tasks/RP07.md @@ -0,0 +1,17 @@ +# RP07 — Download a validated retained dataset for local research + +Parent E12. Priority P1 / High workflow gap. Complexity M. Dependencies RP05 and R05. Owner's "commit and continue" authorizes this next useful research slice. Conditional performance, monitoring and paper/live work remain deferred. + +Evidence: existing canonical dataset GET endpoints return descriptors without bars. `readCanonicalDataset` already loads and validates an eligible retained v2 snapshot, while `scripts/import-research-dataset.ts` accepts the full `{manifest,bars}` representation. A user currently needs direct database access to inspect the frozen observations behind a saved run in VS Code, notebooks or local AI tools. + +Frozen contract: `GET /api/v2/datasets/canonical/:hash/export` returns the existing full `HistoricalDatasetV2` object, with no wrapper or new format. Reuse `readCanonicalDataset` once; preserve its supported-single-asset eligibility gate, values, manifest hash and converted parent identity. Add a minimal `CanonicalDatasetReadError extends HistoricalDataRequestError` for read rejection statuses while preserving current messages and base-class catches: 400 invalid hash, 404 missing, 409 corrupt content or identity mismatch, 422 unsupported. Unexpected failures return sanitized 500. Check cancellation before/after reading; cancelled route work returns499. Route-handled responses are no-store/nosniff; only validated success gets `Content-Disposition: attachment; filename="dataset-.json"` and JSON content type. No source queries, writes, slicing, renormalization, financial changes, cache, streaming framework or migration. Exact means identical validated values/hash, not original JSONB formatting or file byte hash. + +Authorization: preserve existing read/operator/service and browser-session access. Research credentials still cannot use dataset routes; test the actual ResearchAgentsService resolver instead of a permissive fake. This does not give autonomous agents new data or trading capabilities. Users may supply downloaded files to local tools. + +Frontend: a small shared `DatasetDownload` action in verified CanonicalSetup selection and full CanonicalResults provenance, using that saved result's immutable request.datasetHash. Loading, failure/retry and duplicate-click guards; selection change/unmount fences late bodies and download effects. Use the existing cookie-aware apiFetch path. Require status200, JSON type and response manifest shape/hash plus bar-array count before creating a Blob from the received text; the server remains the full content/hash validator. No frontend financial calculations or Node hashing. Use the known hash for the filename; no cross-origin custom-header dependency, raw link fallback or automatic downloads. Release Blob URLs. Never save settings or start a run. Keep the fills-only view unchanged. + +Ownership: backend agent owns `canonical-research.service.ts`, `datasets.routes.ts` and focused API/read tests. Frontend agent owns `DatasetDownload.tsx`, `backtestApiV2.ts`, the two insertion components and focused download UI tests. No shared implementation files. Root owns PostgreSQL/browser tests, integration, docs and commits. Independent reviewer checks both halves against this contract. + +Acceptance/tests: full downloaded JSON validates with identical manifest and every bar; converted parent, delayed availableAt, source ordinals and null VWAP survive. Invalid hashes avoid storage; missing/corrupt/mismatched/unsupported data never attach; internal errors are sanitized; cancellation fences delivery. Existing role access and research-token denial hold. Actual PostgreSQL export followed by the existing CLI import is idempotent, with unchanged unrelated tables. Real browser downloads from a selected dataset and an original run whose editable template now points elsewhere; file identity must match each source. Malformed/HTML/mismatched responses and delayed selection changes cannot create a download. No run/template/source writes from export. + +Gates: focused API/UI/read tests, app/authored-test types, strict lint and production build; root full repository check, relevant disposable PostgreSQL tests and Chromium workbench. Document JSON inspection and existing CLI reimport; the file is a retained v2 snapshot, distinct from the source-input preparation uploader. Risk: exporting a mutable template's new dataset instead of original run input, or presenting a transport error as a data file. No broad research framework is needed.