Implement reviewed F02/D02: exact owner accounting, atomic funding checks, idempotent receipts and ledger checkpoints; connect existing EOD intraday storage through validated research admission without active financial-engine cutover.
5.3 KiB
D02 — Connect supported intraday storage to research datasets
Parent epic: E3. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: TypeScript trading infrastructure.
Scheduling source of truth: manifest entry D02. No task is authorized until the plan is approved. Dependencies and decision references below describe the design; the manifest controls current readiness.
Evidence and root cause
- DAT-04 — Verified: Historical storage selects QuestDB or daily MongoDB; the Mongo path explicitly rejects intraday requests. Ingestion-to-research routing requires an executable provider/interval capability check. apps/stock/orchestrator/src/services/StorageService.ts:287; apps/stock/orchestrator/src/services/StorageService.ts:299.
Intended behavior and implementation scope
Trace the actual intraday collection/schema, add the smallest provider adapter or correct routing, and expose an explicit provider/interval coverage capability. Keep a single normalized dataset admission path; do not migrate all storage systems.
Measurable benefit: Makes supported intraday requests usable and honest.
Verified ingestion evidence and seventh-wave boundary
Before implementation, inspected apps/stock/data-ingestion/src/handlers/eod/actions/intraday.ts: fetchIntraday looks up the listing, uses eodExchange || Exchange, copies provider Unix-second timestamp, datetime, gmtoffset and OHLCV, then upserts eodIntraday1M, eodIntraday5M or eodIntraday1H keyed by timestamp + eodSearchCode (lines 486–585 at base b4af840). The research reader currently chooses QuestDB first, otherwise only daily eodPrices.
Retain the common getHistoricalBars admission path. Add the existing EOD intraday mapping, explicit provider selection/capabilities and typed unavailable/unsupported errors. Capabilities describe connected stores and supported intervals, not proven range coverage. Preserve default QuestDB priority and never switch provider on an empty range/error. Explicit provider requests never fall back to daily or synthetic data. Validate whole Unix seconds and listing identity; Unix timestamps are already UTC and must not be shifted by gmtoffset. QM's adjusted/unpinned interval records remain unsupported.
Tests invoke the actual EOD writer with replaced HTTP/Mongo transport, then the real storage reader and v1/v2 dataset normalizers with explicit retained calendar/action metadata. This proves adapter composition, not database-server conformance or F06 replay. No optional v2 loader, active-runtime cutover or storage migration is required here.
Provider check (2026-10-22): EODHD's intraday documentation identifies the timestamp as UTC bar start and prices as unadjusted for subsequent corporate actions. It also describes delayed finalization after market close and possible historical corrections. Retrieval therefore does not establish point-in-time publication availability. Interval-end availability remains an explicit simulation assumption, never provider evidence; frozen content hashes retain the actual retrieved revision. Provider choice is initially a storage API parameter, not a new web/run-configuration control.
Exclusions
No unrelated refactor, new service or broker activation.
Likely files and ownership
- apps/stock/orchestrator/src/services/StorageService.ts
- apps/stock/data-ingestion/src/
- test/integration/ingestion-backtest.test.ts
Write locks: storage-adapters. One agent owns this change. Lock names do not override actual overlapping files.
Dependencies and blockers
Implementation requires D01 integrated.
No additional economic-policy approval is needed for this narrowly scoped task.
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
Acceptance criteria
- A disposable ingested 5m fixture is retrieved through the research path with unchanged timestamps/OHLC/count.
- Unavailable ranges/providers return typed errors, never daily data or synthetic fallbacks.
- Record the verified ingestion collection/adapter in the task evidence before changing code.
Mandatory tests
- ingest_5m_freeze_replay, unsupported_interval, missing_range, provider_priority.
- Hash the ingested normalized fixture and compare retrieval.
Apply the relevant quality gates; submit exact commands, outcomes and skipped checks. Named cases above are required regression scenarios, not claims that those tests already exist.
Regression risks and rollback
Compatibility or lifecycle regression; preserve frozen inputs, old results and existing failure tests. Keep migrations additive and previous results readable. Do not add a switch that restores a correctness defect. Versioned cutover/migration is required only when persisted contracts or active engines change; never silently fall back to old economics.
Handoff
Report scope changes (if any), fixture expectations, API/schema changes, measurements, remaining limitations and commit/PR references once authorized. Request independent review; only the integration/planning owner may mark the manifest done.