Skip to content

Clean adopted children after Pipecat recorder groups exit - #1011

Merged
zlareb1 merged 2 commits into
mainfrom
fix/pipecat-adopted-child-cleanup
Nov 20, 2026
Merged

zlareb1 merged 2 commits into
mainfrom
fix/pipecat-adopted-child-cleanup

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Related: #1010

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry

Not required.

Why

The optional Pipecat recorder reports remaining direct children after its owned process groups finish cleanup. A child can leave its launcher's process group while remaining a descendant of the recorder. Group cleanup alone cannot reap that adopted child.

After all four existing cleanup calls succeed, clean direct children adopted by the recorder's active subreaper. Pin each child with a PID file descriptor and verify its parent, birth and UID before signaling or reaping. A changed identity or unavailable ownership check refuses cleanup. There is no numeric-PID signaling fallback.

Scope and risk

Each additional TERM and KILL stage has a shared three-second deadline across all adopted children. These stages add at most six seconds of cleanup waiting; procfs checks are bounded observations, not forcibly interrupted system calls. The current list is limited to 4,096 bytes and 128 children, with at most 128 distinct child identities across both stages. Newly adopted children in the KILL stage receive KILL. Zombies use nonblocking reaping. Every pinned handle is closed, including when another close fails. The existing final census remains separate evidence.

Capture diagnostics gain fixed I/O categories and a bounded numeric errno. They unwrap only an exception-valued URL error reason. An owned launcher snapshot records running, exited, signalled or unavailable with a bounded numeric code, using nonblocking WNOWAIT before cleanup. Raw exceptions, browser logs, arguments, URLs, paths and environment values are not exported.

Browser environment, sandbox, request deadlines, native assertions, fixture hashes, media limits and workflow caps retain their existing behavior. The browser-session I/O cause remains unknown. This change repairs the owned-child cleanup gap and adds evidence for that separate setup failure.

Compatibility, rollout and rollback

  • Wire schema and operator settings: none.
  • The optional status extends capture_failure with io and driver_exit diagnostics.
  • After merge, a separate recording selects the exact merged main commit. Reverting removes the adopted-child sweep and diagnostics.

Tests

The adopted-child regression failed against the original recorder: its final census remained nonempty. The related mocked module passed all 67 cases in 0.94 seconds. Added cases cover TERM-to-KILL escalation, adoption during KILL, changing process groups, zombies, changed parent/birth/UID, PID reuse, the cumulative child bound, unsupported PID descriptors, closing all handles after one close fails, filtered I/O diagnostics and the launcher's unreaped exit snapshot. Ordinary main tests mock the adopted-child sweep; controlled sweep cases enable it only after mocking every process syscall. A fixture-isolation regression failed before the correction because an ordinary main test opened a child descriptor. It passes after the correction and asserts no descriptor open, signal or reap reaches another test's helper. These tests start no browser, product service, database or provider.

Scoped Ruff formatting, lint and the diff whitespace check passed. A local attempt refused admission before workload; a later attempt exposed a test mock that counted a temporary-directory handle as the pinned child handle. Both results remain recorded. The corrected mock passes through ordinary closes and checks the exact pinned handle.

All three actual recording attempts passed the native text memory case and removed their owned database fixture. None produced a qualified video. The latest failed at browser-session setup and reported remaining children after group cleanup; their liveness and exact identity were not exported. Required hosted CI and a fresh independent review of this pushed head passed. A later qualified recording remains outstanding.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated: Codex wrote the change. Source inspection covers process ownership, descriptor lifetime, fixed cleanup deadlines, diagnostic exports and unchanged browser and media controls. Validation is listed above.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Required hosted CI passes.
  • No wire schema, migration, generated SDK, plugin or frontend change.
  • No sandbox, ownership, request timeout or native assertion is weakened.
  • The pushed head and entire final body receive an independent review.
  • Commits are signed off.

Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 merged commit 6766169 into main Nov 20, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant