Add kqueue parent-death watcher for Python sidecars#301
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubYour 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". |
Summary
Verification
Notes
BRAINLAYER_DISABLE_PARENT_DEATH_WATCH=1disables the watcher for emergency/debug runs.Note
Medium Risk
Medium risk because it changes lifecycle/termination behavior for multiple persistent processes and uses a background
kqueuethread withos._exit, which could surface platform-specific edge cases.Overview
Adds a new
brainlayer.parent_death.install_parent_death_watcher()implementation using BSD/macOSkqueueNOTE_EXITto terminate Python sidecar processes when their parent exits (with an env var escape hatch and no-op behavior on unsupported platforms).Installs the watcher at startup across several long-running entry points (daemon, MCP stdio server, drain loop, enrichment pipeline runner, hybrid helper, CLI
enrich/watch, and BrainBar’sbrainbar_stdio_adapter).Introduces
tests/test_parent_death.py, including a subprocess-based integration test that verifies the child process exits shortly after its parent terminates, plus a unit test for the no-kqueuefallback and a check that entrypoints include the watcher.Reviewed by Cursor Bugbot for commit edf76d1. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add kqueue parent-death watcher to Python sidecar processes
install_parent_death_watcher(), which useskqueue/EVFILT_PROCto monitor the parent PID and callsos._exit(0)in a daemon thread when the parent exits.enrichandwatchcommands, hybrid helper, enrichment pipeline, and the stdio adapter.BRAINLAYER_DISABLE_PARENT_DEATH_WATCH; no-ops silently on platforms withoutselect.kqueue(i.e. non-BSD/macOS).install_parent_death_watcher.Macroscope summarized edf76d1.