Files
orca/tests/e2e
Brennan Benson baa42c88bc feat(native-chat): release a structured session when its chat closes
A codex app-server outlived the chat that owned it for the whole app session.
The host tracked live sessions in a map with no delete, and tore them down at
three unrelated call sites — app quit, handoff to a TUI, and error cleanup —
none of which is "the user closed the chat". Resident children tracked sessions
ever opened rather than sessions open now, and each one kept a lease renewer
probing process identity every 10 seconds.

Teardown is now a named, ordered step list rather than a method body. Adding a
resource to release is a list entry, not an edit to control flow, which is the
actual fault here: liveness was recorded in one place and cleanup in another, so
a new way for a session to end silently skipped cleanup. Steps are named so a
half-finished eviction reports which one failed, and a failing step no longer
skips the rest — a child that will not stop must not also leave the session
wired to a dead sink.

Order is the correctness property and is asserted directly: drain what the
session already produced before stopping its child, and stop the child before
forgetting it. Draining afterwards discards rows the provider already sent;
forgetting first strands the process.

Closing does NOT end the conversation. The record and journal stay on disk, so
the same session can be attached again.

Also splits the host, which was at exactly 300 of its 300-line cap. The attach
orchestration moves to its own module behind an explicit context type, so the
host reads as a coordinator — serialize per session, track in-flight work —
rather than an implementation. The host is now 277 lines with real headroom; no
cap was raised and no rule disabled.

Verified: 1963 tests across native-chat, runtime RPC and the cross-version wire
harness. agentSession.close is exercised in all three version skews. Mutations:
dropping the child-stop step turns 4 tests red; reordering drain after the stop
turns 2 red — an ordering fault the previous imperative shape could not detect.
2026-08-18 18:57:00 -07:00
..
2026-06-10 17:23:12 -07:00