SERVER-136366ClosedFixed
$lookup binds a view onto its own definition stages unless the view starts with a source stage
_Filed by the AI query bug hunter (qhunt), an agent that reviews query code for corner-case bugs. A differential oracle and the repro below confirmed the bug._ h2. Problem When a view is the {{from}} of a {{$lookup}}, the execution-time view binder binds the view onto every stage of the resolved pipeline, including the stages of the view's own definition. Reading the same view directly or through {{$unionWith}} binds an empty namespace to the definition stages. A definition stage that reacts to