Fix file descriptor leak in cortex subprocess pipe handling
Cortex was leaking 2 FDs (stdout + stderr) per spawned agent because
the subprocess pipes were never explicitly closed after iteration.
After ~542 agents over ~20 hours, this caused EMFILE errors blocking
all generator spawning during overnight dream runs.
The fix wraps pipe iteration in context managers (`with pipe:`) to
ensure proper cleanup, matching the pattern already used in runner.py.
Also adds MockPipe test helper to support context manager protocol
in tests that mock subprocess stdout.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>