Bind an immutable environment snapshot for the duration of the block.
The binding is a ContextVar, so it is copied into asyncio.to_thread
workers, and it ends when the block exits. Anything that runs later -- a
lazy model switch, a summary, a compaction rebuild -- is outside it, which
is why those middlewares carry an environ field and re-enter this
contextmanager at request time instead of relying on the ambient binding.
None binds nothing, and active_environment then falls back to
os.environ.