fix(external): preserve child events across engine spawn races #62
<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"5e81b44e8d11472bd4a7dbdf44f7f1405f2c7214","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->
<details>
<summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-30T13:58:28.082891Z">2026-11-30T13:58:28.082891Z</relative-time> | 5e81b44 | New commits |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
</details>
</details>
<sub><sub>!P2 Badge</sub></sub> Preserve terminal events when the pending buffer fills
If a child emits more than 32 image-bearing events while the spawn window remains open, this check also drops its later turn/end. Replaying the buffer then creates a progress row without settling it, so the row remains running until the child is disposed; reserve space for lifecycle events or evict image events instead.
Useful? React with 👍 / 👎.
<!-- codex-code-review-finding:v1 -->
<!-- codex-review-receipt:v1 -->
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aba006871c
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
chatgpt-codex-connector[bot]
free6589
What this fixes
The foreign-child bridge previously discarded every event from an unknown child while its parent had an engine spawn in flight. It did this to avoid racing the engine's own child claim.
That avoided duplicate rows, but created a correctness hole: a genuinely foreign child whose entire
turn/start→ image/tool result →turn/endlifecycle happened inside that window disappeared completely from the parent progress view.The bridge now buffers only essential lifecycle/image events for unknown children while the window is open. When the final pending engine spawn closes:
The buffer is bounded per child and by child count, so it is not a transcript cache.
Tests
Adds a regression test for a foreign child whose entire lifecycle, including an image-bearing event, occurs inside the spawn race window.