Codex direct paging misses child rollouts spawned beyond the bounded discovery window
Problem
Current dev correctly uses bounded byte-offset paging for Codex Direct Session transcripts. Child rollout discovery, however, scans only the first 1 MiB / 512 JSONL entries of each known stream. If a long parent session spawns a SubAgent after that bounded discovery window:
- the current page can project the synthetic SubAgent tool row when it reaches the late spawn event,
- but the corresponding child rollout is not part of the stream vector,
- so the child transcript never appears in Direct Session paging.
A real 239 MiB / 100,750-line Codex rollout has spawn events well beyond the first MiB, so this is reachable in practice.
Expected
When backward paging encounters a previously unknown subagent-spawn event, it should add the matching child rollout to the same bounded paging operation and keep it available across subsequent opaque cursors.
The cursor must not trust a caller-provided thread identity: restored late-child streams should be tied to a verified parent rollout line/byte offset that actually declares that child.
Proposed fix
- Dynamically add child rollout files discovered in the current backward page.
- Persist late-child stream identity and discovery provenance in a new backward cursor version; keep v3 decode compatibility.
- On a later page, validate the exact parent JSONL line before resolving the child rollout.
- Support nested late-discovered children regardless of cursor entry sort order.
Tests
The draft patch covers:
- late spawn beyond 1 MiB / 512 entries includes child transcript,
- child stream remains available across older pages,
- forged child identity in an opaque cursor is ignored,
- nested late child/grandchild restoration is independent of cursor sort order.
AI assistance disclosure
Investigated and implemented with OpenAI Codex assistance. I reproduced the failure, ran the focused Vitest suites and CLI typecheck, and benchmarked current dev against a real 239 MiB rollout.