mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 17:45:53 +01:00
The startup exposure-drift sweep classified any row without exposure state as dormant, including rows recorded RUNNING. A running pre-exposure service carries a plain port column with exposure null, so when that port sits inside the dedicated exposure app range (42000-42999) the sweep probed it, found the service's own live listener, could not attribute it (the in-memory runtime registry is empty at startup), and reported drift "recorded stopped/removed" for a row that was recorded running. Reconciliation then quarantined the row instead of adopting the surviving process. This is how the shell-command adoption test added in #11744 flaked on CI: it reserved its service port with listen(0), and on Linux the kernel's ephemeral span (32768-60999) contains the dedicated range, so roughly one run in thirty landed in-range and reconciliation returned adopted: 0. The same failure hit several unrelated PRs per day. It never reproduced on macOS, whose ephemeral range starts at 49152. Extract the dormancy decision into isDormantExposureRow and use it in both findExposureReservationDrift and the candidate-port filter of detectPersistedExposureReservationDrift: stopped/failed rows and rows whose exposure was explicitly torn down keep exactly today's behavior; a running row with no exposure state is a live lane pending adoption, not a stale reservation to police. Provisioning/starting rows keep their current dormant treatment. The adoption test now reserves an in-range port on purpose (falling back to ephemeral only when the whole range is busy), turning the once-probabilistic collision into the case the test always exercises. Two unit tests pin the classification: a running pre-exposure row's own in-range listener is not drift; a stopped pre-exposure row's pair is still swept. Verification: reproduced the CI failure deterministically on macOS by forcing the in-range port pre-fix (identical adopted: 0 assertion and drift warning as CI); post-fix the test passes 5/5 repeat runs. port-reservation.test.ts 36/36, PAP-17419 reservation suite 7/7, workspace-runtime.test.ts and workspace-runtime-exposure.test.ts show no delta against a clean-master baseline on the same host. Server typecheck passes.