The P14 staircase's last step: lag_gap_detect found the silences, session_running_flag minted the ids, and this atom cashes them — the derived id is a first-class grouping key, and every P04 skill applies at the new grain. Two edges: single-event sessions have duration 0 (real, and it feeds the denominator question); and session-level rollups per entity stack a second GROUP BY — avg_of_avgs waiting at the door.
SELECT sid, COUNT(*) AS mins FROM pings GROUP BY sid ORDER BY sid;
SELECT sid, MAX(ts) - MIN(ts) AS mins FROM pings GROUP BY sid ORDER BY sid;
Session duration read as the event count (2, 2) instead of the elapsed span — once an id is minted, sessions are a grain, and duration is MAX(ts) - MIN(ts) per session (10 and 5), not the number of pings.
Metrics at session grain first; entity rollups as a deliberate second aggregation with stated weighting.