Skip to content

Fleet Orphan Reaper Identity Check Relies on /proc — No macOS Fallback #2256

Closed

Description

@Trecek

Problem

The fleet orphan reaper in src/autoskillit/cli/fleet/_fleet_lifecycle.py:113-114 uses read_starttime_ticks(pid) from core/runtime/_linux_proc.py to verify PID identity before killing an orphan process. On macOS, /proc does not exist, so read_starttime_ticks() returns None.

The identity guard:

current_ticks = read_starttime_ticks(pid)
if current_ticks is not None and current_ticks == dispatch.dispatched_starttime_ticks:
    # KILL path — only reached on Linux
else:
    # "reaped_pid_recycled" path — NO KILL issued

When current_ticks is None (macOS), the guard evaluates False, the reaper takes the else branch, marks the dispatch as reaped_pid_recycled, and never sends a signal to the orphan process. This is a silent behavioral gap, not an intentional design choice.

Failure Chain

  1. Test writes dispatched_starttime_ticks=0 (because read_starttime_ticks returns None on macOS, collapsed via or 0)
  2. Reaper reads current_ticks = read_starttime_ticks(pid) → None
  3. Guard current_ticks is not None → False → kill branch skipped
  4. Orphan sleep 999 process stays alive
  5. test_orphan_l3_reaping assertion not psutil.pid_exists(orphan_pid) or _is_zombie(orphan_pid) fails

Related Functions

  • read_starttime_ticks() — src/autoskillit/core/runtime/_linux_proc.py — reads /proc/{pid}/stat
  • read_boot_id() — same module — reads /proc/sys/kernel/random/boot_id
  • _reap_stale_dispatches() — src/autoskillit/cli/fleet/_fleet_lifecycle.py:86-134
  • kill_process_tree() — src/autoskillit/execution/process/_process_kill.py:48-58

Potential Approach

When current_ticks is None (non-Linux), fall back to psutil.Process(pid).create_time() for cross-platform PID-reuse detection. Both dispatched_starttime_ticks and the current check would use the same cross-platform API. This is already available via psutil on all platforms.

Alternatively, on non-Linux where /proc identity is unavailable, treat the process as the original orphan (assume no PID recycling) and proceed with the kill — PID-reuse protection is already degraded without /proc.

Context

  • Discovered via PR test #945 macOS-15 CI failure
  • Investigation report: .autoskillit/temp/investigate/investigation_macos_ci_failures_pr945_2026-05-08_160000.md
  • Note: Fleet is currently a develop-only experimental feature. See companion issue for test gating.

Activity

  1. added
    in-progressIssue is being actively worked on
    stagedImplementation staged and waiting for promotion to main
    and removed
    in-progressIssue is being actively worked on
    on May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stagedImplementation staged and waiting for promotion to main

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions