# Telemetry Session Reconstruction

Phase 72.5.1.6 adds `@v2/telemetry-session-reconstruction`, the player session
timeline builder that reads governed `TelemetryWarehouseRow` records from
`warehouse.v2_telemetry.events` and writes reconstructed documents to
`warehouse.v2_telemetry.player_sessions`.

## Inputs

The service consumes rows produced by `@v2/telemetry-data-pipeline`. It does not
read raw client payloads or bypass ingestion validation. The input row already
contains the canonical topic, schema version, `sessionId`, sequence,
`eventUnixSeconds`, stable sanitized `payloadJson`, and `payloadSha256`.

`MemoryTelemetrySessionReconstructionSource` is available for tests and local
development. Production deployments bind the same
`TelemetrySessionReconstructionSource` interface to ClickHouse, BigQuery, or
Redshift queries over `warehouse.v2_telemetry.events`.

## Timeline Rules

`reconstructPlayerSessionsFromRows` groups rows by `sessionId` and calls
`reconstructPlayerSession` for each group. Timeline entries are ordered by
`sequence`, then `eventUnixSeconds`, then `eventId` so replay and analyst views
are deterministic even when warehouse reads return shuffled rows.

Session start and end are bracketed by `v2.player.session.started` and
`v2.player.session.ended`. The reconstructed session stores inferred first and
last event times, explicit start/end times when present, `durationSeconds`,
topic counts, source event IDs, `platforms`, `buildIds`, and the complete
timeline of actions in the session.

## Anomalies

Reconstruction records anomalies instead of silently dropping suspicious data:
missing session start/end, duplicate starts/ends, sequence gaps, duplicate
sequence numbers, clock regressions, `payload_parse_failed` for malformed
payload JSON, payload `session_id` mismatches, and changing `account_id_hash`
values. Malformed payloads still keep their timeline event with an empty payload
so source event IDs remain auditable.

Targeted verification:

```bash
pnpm --filter @v2/telemetry-session-reconstruction run typecheck
pnpm --filter @v2/telemetry-session-reconstruction run test
python V2/ue/Tools/check-v2-telemetry-session-reconstruction.py
```
