# F08 — Publish canonical metrics and versioned result projections Parent epic: E2. Priority/severity: P1 / High. Relative complexity: M. Recommended specialization: Quant analytics/Rust integration. Scheduling source of truth: [manifest entry F08](../manifest.json). 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 - **FIN-07 — Verified:** Daily return grouping, Sharpe/Sortino conventions and placeholder exposure/VaR produce incomparable or misleading native metrics. [apps/stock/engine/src/backtest/simple_results.rs:374](../../../../apps/stock/engine/src/backtest/simple_results.rs#L374); [apps/stock/engine/src/backtest/simple_results.rs:542](../../../../apps/stock/engine/src/backtest/simple_results.rs#L542). - **WEB-04 — Verified:** Existing results snapshot configuration and datasets but do not capture an immutable strategy artifact/engine build/model/seed bundle. Legacy projection can fall back to mutable definition fields. [libs/core/types/src/backtest-run.ts:4](../../../../libs/core/types/src/backtest-run.ts#L4); [apps/stock/web-api/src/services/backtest-result.ts:107](../../../../apps/stock/web-api/src/services/backtest-result.ts#L107). - **Verified reusable analytics:** [reviewed return statistics](../../../../libs/calculations/src/analytics/return-statistics.ts#L24) already separate statistical reporting from financial execution. ## Intended behavior and implementation scope Use canonical Rust ledger postings, owned fills, occupied intervals and session-ending marks as the sole financial inputs. Reuse reviewed TypeScript statistical functions in `libs/calculations/src/analytics/` for return ratios and reports; do not port them to Rust merely for language uniformity. Add a small adapter for the engine-declared session calendar rather than blindly regrouping every venue by UTC date. Version economics and metrics independently. Define sampling, annualization, benchmark and risk-free conventions in the result policy. Missing benchmark/risk-free inputs must not silently become invented measurements. Undefined or unsupported metrics are null with reasons. Adapt existing result DTOs without rewriting old rows. Measurable benefit: comparable, independently checked rankings without a second ledger or a needless analytics rewrite. ## Exclusions No accounting/fill recomputation in TypeScript, statistical library rewrite, forced native port, new service, or silent reinterpretation of historical results. Native analytics remain an option only if measured as a bottleneck. ## Likely files and ownership - apps/stock/engine/src/backtest/simple_results.rs (authoritative projections, not new statistical formulas) - apps/stock/orchestrator/src/backtest/native-result.ts - apps/stock/orchestrator/src/backtest/BacktestReport.ts - libs/calculations/src/analytics/return-statistics.ts - libs/calculations/src/analytics/equity.ts (review existing UTC grouping; use explicit session marks) - libs/core/types/src/backtest-run.ts Write locks: result-contract. One agent owns this change. Lock names do not override actual overlapping files. ## Dependencies and blockers Implementation requires [F06](F06.md) integrated. Architecture decisions: ADR-002, 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 - Fees/P&L/equity/trades reconcile to Rust outputs; session returns include the final session and use the declared risk-session/calendar policy. - Sharpe uses periodic excess-return mean/std; Sortino uses downside deviation relative to the declared target; zero-variance/undefined cases are null with reasons. - Exposure uses the union of occupied intervals; open positions count; attribution distinguishes fills and round trips. - Reviewed calculation functions are reused where their conventions match. Any deliberate difference has a versioned policy and independent arithmetic fixture, not an unexplained second formula. ## Mandatory tests - two_session_marks, constant_negative_returns, zero_variance, overlapping_positions, open_position_exposure. - Existing result mapping and frontend metric unit fixtures; documented independent arithmetic cross-check. Apply the relevant [quality gates](../../QUALITY-GATES.md); 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 Financial or compatibility regression; preserve existing fixtures and version changed semantics. 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.