4.6 KiB
D01 — Introduce availability-aware dataset v2
Parent epic: E3. Priority/severity: P0 / Critical. Relative complexity: M. Recommended specialization: TypeScript trading infrastructure.
Scheduling source of truth: manifest entry D01. 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-01 — Verified: Dataset v1 has one bar timestamp and interval in the manifest, without explicit bar-end/availability semantics. Session dates cannot safely be treated as observation times. libs/core/types/src/historical-data.ts:90; apps/stock/orchestrator/src/services/StorageService.ts:177.
- DAT-03 — Verified: Missing VWAP is replaced with typical price; reported volume and provider-adjusted prices are not a complete corporate-action execution model. apps/stock/orchestrator/src/data/historical-dataset.ts:230; libs/core/types/src/historical-data.ts:98.
- KEEP-02 — Verified: Preserve frozen/hash-verified historical snapshots and fenced durable runner attempts; extend them instead of creating a second job engine. apps/stock/orchestrator/src/data/historical-dataset.ts:98; apps/stock/orchestrator/src/backtest/BacktestRunner.ts:190.
Intended behavior and implementation scope
Add interval start/end, availableAt, venue/calendar revision and source sequence to frozen events; preserve missing VWAP as missing. Keep v1 snapshots immutable. Convert daily session labels only with an explicit versioned calendar; fail closed for unknown venue/time semantics. Include per-series identity/timeframe so a run can select exactly one execution feed per instrument and separate feature-only series.
Measurable benefit: Defines point-in-time truth before new replay logic.
Absorb D03 in the same manifest version: record universe/as-of and corporate-action coverage, distinguish signal-adjusted from raw execution prices and retain limitations. Do not build an action feed or a correctness-gate evidence subsystem. Known unsupported action ranges reject executable policy; unknown coverage stays explicitly exploratory, never silently verified.
Exclusions
No unrelated refactor, new service or broker activation.
Likely files and ownership
- libs/core/types/src/historical-data.ts
- apps/stock/orchestrator/src/data/historical-dataset.ts
- apps/stock/orchestrator/src/services/StorageService.ts
Write locks: dataset-contract. One agent owns this change. Lock names do not override actual overlapping files.
Dependencies and blockers
No code prerequisite. Global execution approval and write-lock acquisition still required.
Architecture decisions: ADR-003. Agents may not independently amend their policies.
Parallel eligibility: only with disjoint actual files and reserved write locks; read FIRST-WAVE.md for the initial exact ownership boundaries.
Acceptance criteria
- A new manifest/hash is produced for every conversion; v1 hashes still verify.
- US daily bars become available at actual session end, including DST and half days; invalid/duplicate conflicts reject.
- Warmup and trade ranges are separate, with no invented VWAP or interpolation.
Mandatory tests
- dataset_v1_compatibility, dataset_v2_hash, DST_half_day, missing_vwap, conflicting_duplicate.
- Future-suffix mutation does not change prior observable prefixes.
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.