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

Affected Versions
Versions known to exhibit this issue

No affected versions recorded.

Fixed Versions
Versions that include the fix
9.1.0-rc09.1.0-rc10259.0.9
Components
Server components related to this issue

No components specified.

Labels
Tags and classification
found-by-ai-hunter