Repository navigation
Conversation
Orphan reclaim in Stop compares the executable the kernel mapped for the port's PID against our managed binary, but procImage read only Linux's /proc, so on macOS the image was always empty and the fail-closed check declined even a clearly managed orphan: TestUninstall_TerminatesRunningInstance failed there and the lifecycle_stop reclaim/decline tests skipped. Give procImage and procRunsScript per-platform homes. Linux keeps the /proc reads verbatim; darwin asks lsof for the process's txt mappings (-Fn, one path per line), whose first entry is the exec'd binary - that is kernel vnode info, unlike ps, which echoes spoofable argv. A venv script engine (vLLM) keeps declining on macOS, as before: no trustworthy command line is readable there. isOurEngineImage gains a canonicalised retry so macOS's canonical /private/var/... image spelling matches a managed path written through the /var symlink; anything unresolvable still fails closed. Signed-off-by: Steven Beverly <thestevbev@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On macOS,
procImagecould never resolve a process's executable: it read only Linux's/proc, yet sat in the//go:build !windowsfile. The orphan-reclaim identity check indoStoptherefore always saw an empty image and failed closed — soengine:stopand uninstall refused a PAIR-managed orphan left on PAIR's own managed port, with a decline error that couldn't even name the image (... under external management (pid 92530, )). It also leftTestUninstall_TerminatesRunningInstancered on macOS and thelifecycle_stop_test.goreclaim/decline tests permanently skipping.The fix gives the darwin build a trustworthy image lookup:
lsof -a -p <pid> -d txt -Fnreturns the executables the kernel actually mapped, whose first entry is the binary that was exec'd — vnode info, not the argv a process can rewrite (pswas evaluated and rejected as spoofable). Since macOS reports the image canonically (/private/var/...) while managed paths can be spelled through the/varsymlink,isOurEngineImagegains a canonicalised retry. User-visible outcome: stopping or uninstalling an engine reclaims its own orphans on macOS again, and declines of foreign listeners name the real executable.Closes #17.
Release intent
Changelog title
Engine orphan reclaim works on macOS
Changelog body
The stop and uninstall ownership check can now identify the executable a
process is actually running on macOS, from the kernel's mapped-executable
record rather than only Linux's
/proc. A PAIR-managed engine process lefton PAIR's own managed port by an earlier run is reclaimed by stop and
uninstall again, and a decline of a foreign listener now names the real
executable path. Script-run engines (a venv invoked through its interpreter)
still decline on macOS, as before; an unresolvable image still fails closed.
Bumps
Scope
Included:
procImage/procRunsScriptsplit out ofproc_unix.gointoproc_linux.go(verbatim/proclogic) andproc_darwin.go(lsof lookup, bounded by the existingportLookupTimeout;-Fnso spaces in paths need no column parsing).isOurEngineImage:EvalSymlinkson both sides, with a directory-resolve fallback for replaced-but-still-running binaries, mirroring Linux's" (deleted)"match. Platform-neutral; a no-op on every path Linux already matched.lsof -Fncaptures (plain binary, path with spaces, Python framework bundle, empty/header-only).lifecycle_stop_test.goskip-guard comment no longer claim macOS cannot resolve an image.Excluded:
proc_pidpath()via libproc: the more direct API, but cgo, and these binaries are builtCGO_ENABLED=0and cross-compiled.procRunsScriptstays false and vLLM-venv orphans keep declining — same as today, just with an honest error.Validation
Environment: macOS 26.7.3 (25G342), Apple Silicon, Go 1.27.4.
7a8c524(the branchwas later rebased onto
dfac16awith no conflicts and re-validated):go test -count=1 -v -run 'TestUninstall_TerminatesRunningInstance|TestStop_ReclaimsOurOrphanOnManagedPort|TestStop_DoesNotReclaimSameExternalImage|TestStop_RejectsForeignListenerWithActionableError' .→ the uninstall test FAILs with(pid 92530, )(empty image), the three reclaim/decline tests SKIP.go test -count=1 -v -run 'TestProcImage|TestParseLsofExecName' .→ PASS.go test -count=1 ./...(189 s) → passes, 0 skips (pre-fix baseline on this machine: 16 skips; PR test: make the macOS Go test suite pass, including cross-process tests beside a running installation #230, now in the base, separately fixed theTestHFToolPathdarwin failure).go vet ./...plusGOOS=linux go vet ./...andGOOS=windows go vet ./...→ only the pre-existinglostcancelwarning ininstall_artifacts_test.go, unchanged on clean develop.gofmt -lclean on all touched files;node scripts/spdx-headers.mjs→ 0 missing.Not run: the Linux module suite (no Linux host here). The Linux code path is a verbatim move under
//go:build linuxplus a retry branch that only runs after the exact string compare fails; CI covers Linux.Risk
ps-style argv views were rejected because they are spoofable. A byte-identical copy of the engine elsewhere is still declined (tested), and reclaim additionally still requiresisManagedInstallPath.lsofis already invoked bypidOnPorton this exact code path, under the same timeout budget. No wire, payload, or contract changes, so noservice-contractsimpact and no desktop-side change.Checklist
git commit -s), certifying the Developer Certificate of Origin.services/versions.jsonis written by automation — do not edit it by hand.