SERVER-138000ClosedFixed
$setWindowFields with sortBy after a join-optimized $lookup+$unwind hits tassert
$setWindowFields desugars to \{$sort: {..., $_internalOutputSortKeyMetadata: true}} plus $_internalSetWindowFields. The sort-key metadata dependency reaches the base collection CanonicalQuery, the planner puts a SORT_KEY_GENERATOR on top of the access plan, and CBR has no estimate for that node in single_table_access.cpp. A plain \{$sort: {_id: 1}} suffix does not trigger it.