4 KiB
RP26 — Download the displayed saved research revision
Parent E12. Priority P2 / Medium product gap. Complexity S. Dependencies R04, RP08, RP25. Owner continuation authorizes implementation and commits. All seven conditional tasks remain deferred.
Verified baseline: the web app exports retained datasets and complete run results, and the typed AI client now reopens artifact history. ResearchEntry displays saved hypotheses, notes/findings and exact historical revisions but provides no local download. Its loaded revision already contains authorship, source and server-resolved citations; no additional endpoint is necessary.
Scope: add Download saved revision to the loaded research entry. Export inert JSON { kind: 'research-revision-export/v1', projectId, entry, revision }. entry contains its ID and kind (hypothesis, note, finding), plus the exact linked hypothesis-revision ID for artifacts. revision is the complete saved revision displayed, preserving IDs/ordinal, narrative, authorship, source, evidence values, units, availability, dataset hashes and limitations. Filename: research-<entryId>-<revisionId>.json. Unsaved edits are excluded and the UI says so while editing.
Reuse the existing pure JSON download helper by moving it from the backtest feature into src/utils/, updating its two consumers. No new download framework, financial calculation, endpoint, schema migration, automatic research job, archive bundle or import format. Run results/datasets remain separate downloads. Moving this helper must preserve object-URL cleanup and error behavior.
Affected modules: ResearchEntry.tsx; the shared download helper and its existing canonical-result/dataset consumers; workspace UI and browser tests; existing walkthrough documentation. Backend and financial engine are excluded.
Acceptance and tests:
- Latest and explicitly selected historical revisions export exactly the displayed saved object; an older revision never acquires the latest narrative/source. Hypotheses, notes, findings and archived entries work. Null metrics, raw precision, authorship and evidence metadata are unchanged.
- Download issues no API call, write, run or revision. Editing a draft exports the saved version and keeps the draft untouched. Pending save disables download. Loading, missing revision and load failure expose no download action.
- Browser URL/click failures show a local retry; retry exports the same revision. Temporary anchors/URLs are cleaned up, and changing the selected revision resets the local error. Existing result/dataset downloads remain green.
- Add an actual Chromium download/readback in the existing research workflow, covering the old finding revision after a newer edit and an exact hypothesis revision. Verify file bytes against API-retained revisions and no added API requests or research rows from download.
- Run workspace/finding/source and existing canonical-download UI tests, application/authored types, contracts, scoped lint/formatting, web build and the browser workbench. Record actual gates and limitations; preserve all existing financial semantics.
Definition of done: demonstrate the missing action, implement this local export with the shared helper, review selected-revision/draft custody, pass checks, document the analysis-file scope, update task state and commit. No new architecture decision is needed.
Accepted after root review: plan 6ce3b68b, implementation 54349502. Baseline capability checks had six failures and one existing no-action pass. Final workspace/finding/source/canonical UI checks passed 137 tests / 921 assertions; complete built Chromium workbench passed 23 / 862. Browser files matched exact API-retained old finding and hypothesis revisions, with unchanged API requests and row counts. Application/authored types, contracts, strict scoped lint, formatting, secrets and diff passed. The helper move is byte-identical and old imports are gone. Disposable stores were stopped. Execution evidence.