mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-24 05:47:10 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The paperclip-runner package has a live test that starts the native
runner through a Python wrapper, `test/support/private-host-control.py`
> - The wrapper has a daemon thread that reads frames from stdin. This
thread stays blocked in `readline` after the native child exits
> - At interpreter shutdown, Python must close stdin. The blocked thread
holds the stdin buffer lock, so Python aborts with "could not acquire
lock ... at interpreter shutdown, possibly due to daemon threads"
(SIGABRT)
> - On macOS, each abort opens a "Python quit unexpectedly" dialog. Long
unattended agent sessions run this test many times and leave tens of
dialogs (59 crash reports on one machine)
> - This pull request makes the wrapper exit with `os._exit` after it
flushes its receipts
> - The benefit is a clean wrapper exit and no crash dialogs on
developer machines
## Linked Issues or Issue Description
**What happened?**
Each run of `src/live/runnerd-codex-transport-release-resume.test.ts`
aborts its Python wrapper with SIGABRT at exit. On macOS each abort
opens a crash dialog. The crash reports show `_enter_buffered_busy` in
`_io__Buffered_close` during `_Py_Finalize`, with a `forward` thread
blocked in `_buffered_readline`.
**Expected behavior**
The wrapper exits with code 0 and no crash report after it emits the
`exited` receipt.
**Steps to reproduce**
1. On macOS or Linux, start `python3
test/support/private-host-control.py /bin/sh -c "sleep 0.3"` in a new
process group with stdin as an open pipe.
2. Keep stdin open after the child exits.
3. The wrapper ends with SIGABRT.
**Paperclip version or commit**
master at cb4129a918
## What Changed
- `private-host-control.py`: exit with `os._exit(status)` after `main()`
or `cleanup()`. This skips interpreter finalization. `emit()` already
flushes every receipt, so no output is lost.
- `src/live/private-host-control-wrapper.test.ts`: new regression test.
It starts the wrapper with stdin open and expects exit code 0 and no
signal.
## Verification
- Red: with the old wrapper, the new test fails with `{ code: null,
signal: 'SIGABRT' }`.
- Green: with the fix, `npx vitest run
src/live/private-host-control-wrapper.test.ts` passes 3 of 3 runs.
- A manual reproduction script gave exit -6 before the fix and exit 0 (3
of 3) after it.
## Risks
Low risk. The change affects only a test-support wrapper. `os._exit`
skips `atexit` handlers and buffer flushes. The wrapper registers no
`atexit` handlers, and it flushes stdout after each write.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
code execution.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>