# E152 incident: file-descriptor leak in MCPGate invalidated part of development (2026-11-23)

**What happened.** `cain/mcp_proxy.py` probed the trust store with `with sqlite3.connect(...) as _c:`. In Python, sqlite3's context manager commits or rolls back but never closes the connection, so every MCPGate authorization leaked one open file (the live gateway database, read-only). E152's long-lived worker processes reached about 1,300 open files. Above 1,024, Python's `select()` refuses the descriptor, and the E152 sandbox recorded the run as `CRASHED` after about 0.05 s with 0 API calls.

**Effect.** Known-good researchers (the frozen parents G0 and LF1) "crashed" in most runs from the middle of generation 4. Affected development decisions: **LV generations 4 and 5, N generation 4 (and 5, not finished), LF generation 5.** None of them had been accepted. Earlier generations had 0 instant crashes. E151 (development, confirmation, replication) had 0 instant crashes, so its published result is unaffected.

**Action.**
1. Fixed `cain/mcp_proxy.py` with `contextlib.closing` (verified: 60 authorizations now open 6 files once instead of 60 that stay open). The file is not frozen in any preregistration.
2. Stopped E152 development by PID (its runner wrote no failure line, so nothing downstream started).
3. Moved the 540 result rows and 72 candidate records of the affected arm-generations to `artifacts/e152/development/INVALIDATED_fd_leak_2026-11-23.jsonl` (kept, not deleted), with a summary in `INVALIDATED_summary.json`. LV's strategy-lineage entries for generations 4-5 were removed (no change had been adopted).
4. Re-ran exactly those arm-generations with the same development and selection salts (the same problems), in fresh processes.

**Disclosed limits.** The append-only self-improvement memory keeps its entries from the invalid generations (it cannot be rewritten). The re-run proposals therefore saw those entries, which say that candidates "crashed". The model calls of the invalid generations (about $0.30) were real spend and stay in the API ledger. This is a protocol incident, not a change to the analysis plan; the sealed confirmation is unaffected (fresh process, fixed code, fresh salts).

## CORRECTIONS AND ADDED DISCLOSURES (2026-11-23, about 13:45 UTC)

* Model spend of the invalid generations was **$0.4509** by the ledger; "about $0.30" above was an unchecked figure.
* The re-run was decided after seeing that all four invalid arm-generations were rejected, so it gives each a second, fresh set of model proposals. It is a deviation from the preregistered run and must be reported as one with the E152 result. The re-run of LV generation 4 was also rejected (p = 0.206) but adopted a strategy change the invalid run had not, so LV's later path differs. The re-run of N generation 4 was rejected (p = 0.148).
* The MCPGate code (`cain/mcp_proxy.py`) differs between the generations before the fix and the re-run. 95 MCPGate/JIT tests pass on the fixed code. The live gateway has not been restarted.
* Commit 4f5b3ce6c put `artifacts/e152/development/state.json`, with the E152 development and selection salts, into private git history (off-site replicas are private servers of the same team; both public sites return 404 for the path). Candidate sandboxes have no repository access. The sealed confirmation uses new salts drawn later.
* The E154 forecasts (sealed 11:45 UTC) were made from evidence that included the invalid E152 generations. F1 will resolve on the re-run; its score must carry this note.
* Re-run health check at 13:36 UTC: 592 runs, 0 CRASHED, 0 at the wall limit (max 67 s).
