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

3.5 KiB

RP28 — Read hash-verified frozen market data through research credentials

Parent E12. Priority P2 / Medium research capability gap. Complexity S. Dependencies A03, RP07, RP27. Owner continuation authorizes implementation and commits. All seven conditional tasks remain deferred.

Verified baseline: the web app already downloads GET /api/v2/datasets/canonical/:hash/export through the strict retained-data reader. Research credentials cannot access that path, and the typed client has no dataset method. AI clients can inspect full run results after RP27 but still need a separate operator transport to inspect their source bars.

Selected scope: allow only the existing exact GET/HEAD canonical export path with a lowercase 64-character hash in the research read allowlist. This makes known retained snapshots readable under the existing shared research-catalog read model; it does not add per-dataset grants or an export endpoint. Dataset listing, provider inspection/preparation/retention, other dataset paths and all data writes retain their current permissions. Job budgets, strategy OS isolation and paper/live boundaries remain unchanged. Analysis clients can read historical data; candidate callbacks still receive only published prefixes and no credentials/network.

Add ResearchClient.canonicalDataset(hash, signal?), using the existing validateDatasetV2 content/hash validator and matching the requested hash. Return detached, frozen retained bars/metadata without interpolation or provider queries. Callers select the exact hash from the saved run request or predeclared experiment input, including phase-specific hashes. No new storage, financial calculations, caches, input truncation or automatic research execution.

Affected files: research credential service/allowlist; research client and tests; authenticated AI workflow fixture/tests; existing security/export integration tests; README usage and the operator page's permission description. The dataset export/validator implementation remains authoritative and is reused unchanged. The web change is descriptive copy only.

Acceptance/tests:

  • Exact known-hash GET/HEAD export authenticates a real research credential; source/data-write/catalog/admin/trading routes remain denied as before. Malformed/extra dataset paths fail closed. Revoked credentials cannot export.
  • Typed reads preserve original bars, calendar/session/availability metadata, lineage/hash and limitations. Invalid hash inputs fail before transport; tampered content, derived-policy mismatches and a different valid dataset fail as read errors without retries.
  • Actual API tests compare exports to retained PostgreSQL payloads, demonstrate existing saved-template edits do not change a prior hash, and verify no runs/experiments/datasets are created by reads. Unknown/corrupt snapshots produce the existing 404/409 read errors. Abort/deadline behavior uses the existing client transport.
  • Run client/cycle and focused credential/security suites, complete tooling/integration, actual PostgreSQL AI/agent tests, application/authored types, contracts, strict lint/formatting and secrets. Build the web app to verify the permission description; no engine rebuild or browser-flow change is necessary.

Definition of done: reproduce the missing typed/read permission capability, add the narrow existing endpoint access and typed read, review shared research-read versus privileged data-write scope, pass gates, document usage/holdout discipline, update task state and commit. This fits ADR-007 research/data isolation; no new architecture approval is required.