Skip to content

fix(bin): read session-lock owner identity without the ps binary - #7609

Merged
kunchenguid merged 30 commits into
kunchenguid:mainfrom
kesslerio:fix/5238-session-lock-ps-denial
Nov 4, 2026
Merged

kunchenguid merged 30 commits into
kunchenguid:mainfrom
kesslerio:fix/5238-session-lock-ps-denial

Conversation

@kesslerio

@kesslerio kesslerio commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #5238

What Changed

  • Added bin/fm-procinfo.py and a ps-free identity fallback in bin/fm-session-lock-lib.sh: when the ps binary cannot execute at all (126/127), owner identity is read through /proc (Linux, honoring FM_PROC_ROOT_OVERRIDE) or macOS kernel syscalls, with fail-closed parsing, exact-field verification, and once-per-shell diagnostics.
  • Introduced the shared fm_session_lock_pid_blocks_reclaim verdict (liveness first, then identity) and routed bin/fm-lock.sh, bin/fm-claude-stop-autoarm.sh, bin/fm-turnend-guard.sh, and bin/fm-turnend-guard-cursor.sh through it instead of re-deriving liveness; fm_session_lock_inspect now uses the same single verdict for numeric and tagged Windows pids.
  • Added tests/fm-session-lock-ps-denied.test.sh and extended tests/fm-session-lock-ancestry.test.sh, registered the new suite in bin/fm-test-run.sh, and updated the session-lock, watcher-continuity, turnend-guard, and scripts documentation.

Risk Assessment

✅ Low: The fallback is bounded to confirmed ps execution denial, and source inspection found no new material defect in identity classification, ownership protection, or recovery.

Testing

Ran the four focused suites first (ps-denied suite all pass; windows-consumers and inbox pass; ancestry shows only the already-reported pre-existing pid-1 reparent assertion). Then drove the real bin/fm-lock.sh inside a disposable fm-lab home against a genuine process tree with ps denied (a ps shim that exits 126 for every invocation, including ps -V, while everything else runs for real). All 17 live checks passed: a primary acquires the lock on the denied-ps host, a second primary is refused with a lock unchanged (no takeover), a dead owner's lock is still reclaimed, fm-lock.sh status reports held/stale correctly through the ps-free route, and a live Cursor owner behind a non-ASCII (José) alias path keeps byte-identical comm/args across the ps and /proc routes and blocks reclaim. The Darwin sysctl provider (bin/fm-procinfo.py) is untested because this host is Linux and only a Darwin host can exercise KERN_PROCARGS2, so that scenario stays honestly untested; the shared verdict logic it feeds was exercised live. Labs were removed and no background work remains.

  • Live validation: ✅ go - 5 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A primary acquires the session lock on a ps-denied host (real bin/fm-lock.sh, real process tree, /proc identity route) ✅ pass live live-drive-transcript.log S1: lock acquired: harness pid 961880, cli-rc=0, lock-line1=961880
A second primary on a ps-denied host cannot take a live owner's lock (foreign-owner refusal, no takeover) ✅ pass live live-drive-transcript.log S2: error: another live firstmate session holds the lock (pid 962021), contender-rc=1, lock still 962021
A dead owner's lock remains reclaimable on a ps-denied host (no permanent read-only wedge) ✅ pass live live-drive-transcript.log S3: after stopping the owner, lock acquired: harness pid 962388, cli-rc=0, lock-line1=962388
bin/fm-lock.sh status agrees with the lock verdict on a ps-denied host (held while alive, stale after exit) ✅ pass live live-drive-transcript.log S4: lock: held by live harness pid 962021 then lock: stale (pid 962021 dead or not a harness)
A live Cursor owner behind a non-ASCII alias path (…/José/.local/bin/agent) keeps its lock on a ps-denied host: comm/args identical across ps and /proc routes and the contender is refused ✅ pass live live-drive-transcript.log S5: ps and /proc routes both report comm=[agent] args=[/tmp/…~/.local/bin/agent …], harness verdict with ps denied: [alive], contender refused, lock unchanged a…
The macOS sysctl identity provider (bin/fm-procinfo.py) resolves identity and preserves UTF-8 on a genuinely ps-denied Darwin host ⏸️ untested no This host is Linux 7.3.1; bin/fm-procinfo.py reads identity only through Darwin's sysctl(KERN_PROCARGS2/KERN_PROC_PID), which no Linux kernel provides, so the only routes available here (real Darwin s…
Evidence: Live drive transcript (17/17 PASS, driver rc=0)

Source: Live drive transcript (17/17 PASS, driver rc=0)

=== host: Linux 7.3.1; lab: /tmp/fm-lab.m3OoHG
=== denied ps probe:
    ps -o comm= -> rc=126
    ps -V -> rc=126

=== S1: a primary acquires the session lock while ps is denied
harness-pid=961880
lock acquired: harness pid 961880
cli-rc=0
lock-line1=961880
PASS S1 the CLI reported acquisition
PASS S1 the CLI exited 0
PASS S1 state/.lock records the live harness pid 961880
PASS S1 no ancestry failure on the denied-ps host

=== S2/S3/S4: live foreign owner refused, dead owner reclaimable, status agrees
    owner harness pid=962021 : lock acquired: harness pid 962021 acquire-rc=0 
    S4 live status (denied ps): lock: held by live harness pid 962021
PASS S4 a live harness holder reads held
error: another live firstmate session holds the lock (pid 962021); operate read-only until resolved
contender-rc=1
lock-line1=962021
PASS S2 the contender was refused, naming the live owner
PASS S2 the contender exited 1
PASS S2 the takeover attempt left the owner pid 962021 in state/.lock
Terminated                 env -u CLAUDE_CODE_SESSION_ID -u CLAUDE_PID -u CLAUDE_CONFIG_DIR -u NO_MISTAKES_GATE -u FM_GATE_REFUSE_BYPASS -u FM_ROOT_OVERRIDE -u FM_STATE_OVERRIDE -u FM_DATA_OVERRIDE -u FM_CONFIG_OVERRIDE -u FM_PROJECTS_OVERRIDE FM_HOME="$LAB" FM_LAB="$LAB" FM_WT="$WT" FM_TAG="$2" PATH="$DENIED_PATH" "$1" --norc --noprofile -c "$3"
    owner 962021 stopped
    S4 dead status (denied ps): lock: stale (pid 962021 dead or not a harness)
PASS S4 a dead holder reads stale (no permanent read-only wedge)
harness-pid=962388
lock acquired: harness pid 962388
cli-rc=0
lock-line1=962388
PASS S3 the stale lock was reclaimed by the new primary
PASS S3 the reclaiming CLI exited 0
PASS S3 state/.lock was rewritten to the new harness pid 962388

=== S5: a live Cursor owner behind a non-ASCII alias path still blocks reclaim
    cursor alias harness pid=962676 : lock acquired: harness pid 962676 acquire-rc=0 
    alias path: /tmp/fm-lab.m3OoHG/Users/José/.local/bin/agent
    kernel comm: agent
    ps route   : comm=[agent] args=[/tmp/fm-lab.m3OoHG/Users/José/.local/bin/agent --norc --noprofile -c  printf "%s" $$ > "$FM_LAB/$FM_TAG.pid" cd "$FM_WT" || exit 9 bin/fm-lock.sh > "$FM_LAB/$FM_TAG.acquire" 2>&1 printf "acquire-rc=%s\n" "$?" >> "$FM_LAB/$FM_TAG.acquire" : > "$FM_LAB/$FM_TAG.ready" sleep 300 : ]
    /proc route: comm=[agent] args=[/tmp/fm-lab.m3OoHG/Users/José/.local/bin/agent --norc --noprofile -c  printf "%s" $$ > "$FM_LAB/$FM_TAG.pid" cd "$FM_WT" || exit 9 bin/fm-lock.sh > "$FM_LAB/$FM_TAG.acquire" 2>&1 printf "acquire-rc=%s\n" "$?" >> "$FM_LAB/$FM_TAG.acquire" : > "$FM_LAB/$FM_TAG.ready" sleep 300 : ]
PASS S5 comm is identical across the ps and /proc routes
PASS S5 args are identical across the ps and /proc routes
PASS S5 the /proc route preserved the UTF-8 bytes of the alias path
    harness verdict with ps available: [alive]
    harness verdict with ps denied   : [alive]
error: another live firstmate session holds the lock (pid 962676); operate read-only until resolved
contender-rc=1
lock-line1=962676
PASS S5 the contender was refused, naming the live Cursor owner
PASS S5 state/.lock still records the Cursor owner pid 962676
Terminated                 env -u CLAUDE_CODE_SESSION_ID -u CLAUDE_PID -u CLAUDE_CONFIG_DIR -u NO_MISTAKES_GATE -u FM_GATE_REFUSE_BYPASS -u FM_ROOT_OVERRIDE -u FM_STATE_OVERRIDE -u FM_DATA_OVERRIDE -u FM_CONFIG_OVERRIDE -u FM_PROJECTS_OVERRIDE FM_HOME="$LAB" FM_LAB="$LAB" FM_WT="$WT" FM_TAG="$2" PATH="$DENIED_PATH" "$1" --norc --noprofile -c "$3"

=== RESULT rc=0
Evidence: Live drive script (denied-ps lab fixture, harness tree, Cursor alias scenario)

Source: Live drive script (denied-ps lab fixture, harness tree, Cursor alias scenario)

#!/usr/bin/env bash
# Live drive of bin/fm-lock.sh on a ps-denied host, in a disposable lab home.
#
# ps denial is simulated the way an EDR policy presents itself: a `ps` on PATH
# that prints "Operation not permitted" and exits 126 for EVERY call (including
# `ps -V`), which is exactly the shape bin/fm-session-lock-lib.sh requires
# before it routes identity off ps. Everything else is real: a real process
# tree, the real /proc provider, the real CLI.
set -u
WT=$1
LAB=$2
rc=0
say() { printf '%s\n' "$*"; }
pass() { say "PASS $*"; }
fail() { say "FAIL $*"; rc=1; }
check() {  # <label> <expected-substring> <actual>
  [ -n "$2" ] || { fail "$1 (driver bug: empty expectation)"; return; }
  case "$3" in
    *"$2"*) pass "$1" ;;
    *) fail "$1 (wanted '$2', got: $3)" ;;
  esac
}

# The harness: a copy of bash, so the launched process's kernel comm is the
# harness name and a real ancestry walk from the CLI reaches it.
mkdir -p "$LAB/bin" "$LAB/fakebin"
cp "$(command -v bash)" "$LAB/bin/claude"

# A denied ps: every invocation of the binary is refused.
printf '#!/usr/bin/env bash\necho "ps: Operation not permitted" >&2\nexit 126\n' > "$LAB/fakebin/ps"
chmod +x "$LAB/fakebin/ps"

STATE=$LAB/state
DENIED_PATH="$LAB/fakebin:$PATH"

# Run one command inside a live harness-named process, with ps denied.
harness() {  # <bin> <tag> <body>
  env -u CLAUDE_CODE_SESSION_ID -u CLAUDE_PID -u CLAUDE_CONFIG_DIR \
      -u NO_MISTAKES_GATE -u FM_GATE_REFUSE_BYPASS -u FM_ROOT_OVERRIDE \
      -u FM_STATE_OVERRIDE -u FM_DATA_OVERRIDE -u FM_CONFIG_OVERRIDE \
      -u FM_PROJECTS_OVERRIDE \
      FM_HOME="$LAB" FM_LAB="$LAB" FM_WT="$WT" FM_TAG="$2" PATH="$DENIED_PATH" \
      "$1" --norc --noprofile -c "$3"
}

# A long-lived harness that acquires the lock, publishes its pid, stays alive.
OWN_PID=
own_lock_bg() {  # <bin> <tag>
  local bin=$1 tag=$2
  rm -f "$LAB/$tag.pid" "$LAB/$tag.ready" "$LAB/$tag.acquire"
  harness "$bin" "$tag" '
printf "%s" $$ > "$FM_LAB/$FM_TAG.pid"
cd "$FM_WT" || exit 9
bin/fm-lock.sh > "$FM_LAB/$FM_TAG.acquire" 2>&1
printf "acquire-rc=%s\n" "$?" >> "$FM_LAB/$FM_TAG.acquire"
: > "$FM_LAB/$FM_TAG.ready"
sleep 300
: ' &
  local i=0
  while [ ! -e "$LAB/$tag.ready" ] && [ "$i" -lt 300 ]; do sleep 0.1; i=$((i + 1)); done
  OWN_PID=$(cat "$LAB/$tag.pid" 2>/dev/null)
  return 0
}

stop_pid() {  # <pid>
  [ -n "${1:-}" ] || return 0
  kill -TERM "$1" 2>/dev/null
  local i=0
  while kill -0 "$1" 2>/dev/null && [ "$i" -lt 100 ]; do sleep 0.1; i=$((i + 1)); done
  kill -KILL "$1" 2>/dev/null
  wait "$1" 2>/dev/null
  return 0
}

# Ask the library directly, in a plain shell, with ps denied.
lib_denied() {  # <pid> <expression>
  env -u CLAUDE_PID -u CLAUDE_CODE_SESSION_ID FM_HOME="$LAB" PATH="$DENIED_PATH" TARGET="$1" \
    bash -c '. "$1/bin/fm-session-lock-lib.sh"; eval "$2"' _ "$WT" "$2"
}
lib_allowed() {  # <pid> <expression>
  env -u CLAUDE_PID -u CLAUDE_CODE_SESSION_ID FM_HOME="$LAB" TARGET="$1" \
    bash -c '. "$1/bin/fm-session-lock-lib.sh"; eval "$2"' _ "$WT" "$2"
}

say "=== host: $(uname -s) $(uname -r); lab: $LAB"
say "=== denied ps probe:"
env PATH="$DENIED_PATH" ps -o comm= -p $$ >/dev/null 2>&1
say "    ps -o comm= -> rc=$?"
env PATH="$DENIED_PATH" ps -V >/dev/null 2>&1
say "    ps -V -> rc=$?"

# ---------------------------------------------------------------- scenario 1
say ""
say "=== S1: a primary acquires the session lock while ps is denied"
rm -f "$STATE/.lock" "$STATE/.lock-session" "$STATE/.lock.acquire"
s1=$(harness "$LAB/bin/claude" s1 '
printf "harness-pid=%s\n" $$
cd "$FM_WT" || exit 9
bin/fm-lock.sh; printf "cli-rc=%s\n" "$?"
printf "lock-line1=%s\n" "$(cat "$FM_HOME/state/.lock" 2>/dev/null)"
' 2>&1)
say "$s1"
p1=$(printf '%s\n' "$s1" | sed -n 's/^harness-pid=//p')
l1=$(printf '%s\n' "$s1" | sed -n 's/^lock-line1=//p')
check "S1 the CLI reported acquisition" "lock acquired: harness pid $p1" "$s1"
check "S1 the CLI exited 0" "cli-rc=0" "$s1"
[ -n "$p1" ] && [ "$l1" = "$p1" ] && pass "S1 state/.lock records the live harness pid $p1" \
  || fail "S1 state/.lock holds '$l1', expected $p1"
case "$s1" in
  *"cannot locate harness process"*) fail "S1 the walk still failed on the denied-ps host" ;;
  *) pass "S1 no ancestry failure on the denied-ps host" ;;
esac

# ------------------------------------------------------------- scenarios 2-4
say ""
say "=== S2/S3/S4: live foreign owner refused, dead owner reclaimable, status agrees"
rm -f "$STATE/.lock" "$STATE/.lock-session" "$STATE/.lock.acquire"
own_lock_bg "$LAB/bin/claude" owner
owner=$OWN_PID
say "    owner harness pid=$owner : $(tr '\n' ' ' < "$LAB/owner.acquire")"
s4live=$(harness "$LAB/bin/claude" status4 'cd "$FM_WT" && bin/fm-lock.sh status')
say "    S4 live status (denied ps): $s4live"
check "S4 a live harness holder reads held" "lock: held by live harness pid $owner" "$s4live"

s2=$(harness "$LAB/bin/claude" s2 '
cd "$FM_WT" || exit 9
bin/fm-lock.sh; printf "contender-rc=%s\n" "$?"
printf "lock-line1=%s\n" "$(cat "$FM_HOME/state/.lock" 2>/dev/null)"
' 2>&1)
say "$s2"
check "S2 the contender was refused, naming the live owner" "another live firstmate session holds the lock (pid $owner)" "$s2"
check "S2 the contender exited 1" "contender-rc=1" "$s2"
l2=$(printf '%s\n' "$s2" | sed -n 's/^lock-line1=//p')
[ "$l2" = "$owner" ] && pass "S2 the takeover attempt left the owner pid $owner in state/.lock" \
  || fail "S2 the lock changed to '$l2' while owner $owner was alive"

stop_pid "$owner"
say "    owner $owner stopped"
s4dead=$(harness "$LAB/bin/claude" status4b 'cd "$FM_WT" && bin/fm-lock.sh status')
say "    S4 dead status (denied ps): $s4dead"
check "S4 a dead holder reads stale (no permanent read-only wedge)" "lock: stale (pid $owner dead or not a harness)" "$s4dead"

s3=$(harness "$LAB/bin/claude" s3 '
printf "harness-pid=%s\n" $$
cd "$FM_WT" || exit 9
bin/fm-lock.sh; printf "cli-rc=%s\n" "$?"
printf "lock-line1=%s\n" "$(cat "$FM_HOME/state/.lock" 2>/dev/null)"
' 2>&1)
say "$s3"
p3=$(printf '%s\n' "$s3" | sed -n 's/^harness-pid=//p')
l3=$(printf '%s\n' "$s3" | sed -n 's/^lock-line1=//p')
check "S3 the stale lock was reclaimed by the new primary" "lock acquired: harness pid $p3" "$s3"
check "S3 the reclaiming CLI exited 0" "cli-rc=0" "$s3"
[ -n "$p3" ] && [ "$l3" = "$p3" ] && pass "S3 state/.lock was rewritten to the new harness pid $p3" \
  || fail "S3 state/.lock holds '$l3', expected $p3"

# ---------------------------------------------------------------- scenario 5
say ""
say "=== S5: a live Cursor owner behind a non-ASCII alias path still blocks reclaim"
CUR_DIR="$LAB/Users/José/.local/share/cursor-agent/versions/test"
CUR_ALIAS="$LAB/Users/José/.local/bin/agent"
mkdir -p "$CUR_DIR" "${CUR_ALIAS%/*}"
cp "$(command -v bash)" "$CUR_DIR/agent"
ln -sfn "$CUR_DIR/agent" "$CUR_ALIAS"
rm -f "$STATE/.lock" "$STATE/.lock-session" "$STATE/.lock.acquire"
own_lock_bg "$CUR_ALIAS" cursor
cur=$OWN_PID
say "    cursor alias harness pid=$cur : $(tr '\n' ' ' < "$LAB/cursor.acquire")"
say "    alias path: $CUR_ALIAS"
say "    kernel comm: $(cat "/proc/$cur/comm" 2>/dev/null)"

ps_comm=$(ps -o comm= -p "$cur")
ps_args=$(ps -o args= -p "$cur")
prov=$(lib_denied "$cur" 'fm_os_proc_triple "$TARGET"')
prov_comm=${prov#*$'\t'}; prov_comm=${prov_comm%%$'\t'*}
prov_rest=${prov#*$'\t'}; prov_args=${prov_rest#*$'\t'}
say "    ps route   : comm=[$ps_comm] args=[$ps_args]"
say "    /proc route: comm=[$prov_comm] args=[$prov_args]"
[ -n "$prov_comm" ] && [ "$prov_comm" = "$ps_comm" ] && pass "S5 comm is identical across the ps and /proc routes" \
  || fail "S5 comm differs: ps=[$ps_comm] proc=[$prov_comm]"
[ -n "$prov_args" ] && [ "$prov_args" = "$ps_args" ] && pass "S5 args are identical across the ps and /proc routes" \
  || fail "S5 args differ: ps=[$ps_args] proc=[$prov_args]"
case "$prov_args" in
  *"José"*) pass "S5 the /proc route preserved the UTF-8 bytes of the alias path" ;;
  *) fail "S5 the /proc route lost the UTF-8 bytes: [$prov_args]" ;;
esac

v_ps=$(lib_allowed "$cur" 'fm_harness_pid_alive "$TARGET" && echo alive')
v_denied=$(lib_denied "$cur" 'fm_harness_pid_alive "$TARGET" && echo alive')
say "    harness verdict with ps available: [${v_ps:-not-a-harness}]"
say "    harness verdict with ps denied   : [${v_denied:-not-a-harness}]"

s5=$(harness "$LAB/bin/claude" s5 '
cd "$FM_WT" || exit 9
bin/fm-lock.sh; printf "contender-rc=%s\n" "$?"
printf "lock-line1=%s\n" "$(cat "$FM_HOME/state/.lock" 2>/dev/null)"
' 2>&1)
say "$s5"
check "S5 the contender was refused, naming the live Cursor owner" "another live firstmate session holds the lock (pid $cur)" "$s5"
l5=$(printf '%s\n' "$s5" | sed -n 's/^lock-line1=//p')
[ "$l5" = "$cur" ] && pass "S5 state/.lock still records the Cursor owner pid $cur" \
  || fail "S5 the lock changed to '$l5' while the Cursor owner $cur was alive"

stop_pid "$cur"
say ""
say "=== RESULT rc=$rc"
exit "$rc"
Evidence: Focused suite: tests/fm-session-lock-ps-denied.test.sh (ALL PASS)

Source: Focused suite: tests/fm-session-lock-ps-denied.test.sh (ALL PASS)

ok - live owner with unreadable identity returns a successful verdict
ok - partial identity reads block reclaim; successfully empty args remain readable
ok - empty, whitespace and non-numeric lock records allow acquisition
ok - acquisition refuses a live owner with unreadable identity
ok - 126-route parse assigns each field and refuses a blank ppid
ok - provider records off the defined shape are refused, not parsed
ok - a provider record with an empty comm field reports a present pid
ok - ps 1 stays a stop with the provider untouched; ps 127 routes to it
ok - refused -p with a live ps -V stays a stop; the denial check is cached once
ok - the denied-ps diagnostic prints once per shell, whatever reads follow
ok - ps returning no name stays a present pid, never a reclaimable stale one
ok - denied ps: own lock is owned, foreign live harness is refused and named
ok - linux route parses a fixture /proc tree through the repo's override hook
ok - Unicode identity survives denied ps; controls flatten and live Cursor blocks reclaim
ok - ps denied: ancestry and liveness still resolve through the OS provider
ok - ps denied with no provider data: the walk refuses, it never guesses
ok - ps denied: a chain containing no harness is still no harness
ok - ps works: the fallback provider is never consulted
ok - e2e blocked ps: the real platform provider identified a real harness tree, identity included
ok - fm-procinfo.py: macOS-only, skipped
ok - fm-procinfo.py fail-closed: macOS-only, skipped
ok - route equivalence: macOS-only, skipped
ok - control bytes preserve identical identity fields across routes
ok - trailing empty argv elements are dropped; interior empties and argument spaces survive
ALL PASS
Evidence: Focused suite: tests/fm-session-lock-ancestry.test.sh (21 ok, 1 pre-existing pid-1 reparent failure)

Source: Focused suite: tests/fm-session-lock-ancestry.test.sh (21 ok, 1 pre-existing pid-1 reparent failure)

ok - session-lock: a version-named Claude Code session is identified from its install path and argv[0]
ok - session-lock: a harness that is pid 1 of its own namespace is examined, not skipped
ok - session-lock: ordinary script paths under a harness directory are not harness processes
ok - session-lock: ownership stops at the first non-harness gap above the contiguous run
ok - session-lock: a live version-named session holding the lock is not mistaken for a stale owner
ok - session-lock: a trusted same-session id keeps owning a recycled background chain, and nothing weaker does
ok - session-lock: a trusted id anchors the lock on the model-loop process, anything else on the outermost pid
ok - session-lock: a Windows session is identified from its published pid across the severed parent link
ok - session-lock: a published Windows pid is confirmed against the process table before it is trusted
ok - session-lock: a tagged Windows pid is never resolved against the Cygwin process table
ok - session-lock: a published identity is accepted by every gate that reads the lock
ok - session-lock: a live tagged lock holder is a live foreign owner to a second Windows session
ok - session-lock: fm-lock.sh protects valid tagged owners and reclaims dead or malformed records
ok - session-lock: a published Windows Claude pid is accepted only with its session id
ok - session-lock: a Windows /clear keeps the lock and re-keys its session id
ok - session-lock: a Windows-tagged lock stays inert off Windows
ok - session-lock: a task lease follows a live tagged lock holder and goes stale when it exits
ok - session-lock: a harness in the local process table resolves untagged when ps has no -o option
ok - session-lock e2e: a version-named session claims the home and arms supervision
ok - session-lock e2e: a session parented by a harness-named daemon claims the home and arms supervision
ok - session-lock e2e: a version-named session under a harness-named daemon keeps its own lock
not ok - the pty-host was not reparented to init after the daemon ended
Evidence: Focused suite: tests/fm-inbox.test.sh

Source: Focused suite: tests/fm-inbox.test.sh

ok - plain note, list, and wake stay on the historical human path
ok - plain note keeps exit 1 for a saved-but-unannounced failure
ok - the same request id returns the original note as a distinguishable replay
ok - a crash between recording the request id and publishing the note reuses the original id
ok - saved-but-unannounced notes are repairable without creating a second note
ok - repair and replay do not wake firstmate for an already-acknowledged note
ok - receipts JSON is bounded by fixed bounds and discloses what it omitted
ok - notes that predate the announcement marker are unknown, not re-announced
ok - the reply channel is durable and its cursor is a strict order
ok - the reply cursor never goes backwards when the sequence counter is lost
ok - a reply without a valid sequence is reported as malformed
ok - a non-UTF-8 note does not break the receipts view
ok - readiness says unknown (or not-receivable) instead of inferring liveness from a lock
ok - empty bodies and unsafe request ids are refused
ok - a note body that opens with a double dash is queued as text
ok - drain --ack still moves the note to handled
Evidence: Focused suite: tests/fm-session-lock-windows-consumers.test.sh

Source: Focused suite: tests/fm-session-lock-windows-consumers.test.sh

ok - untagged lock values: the session-pid helpers answer exactly as fm_pid_identity and fm_pid_alive do
ok - supervision host: a win:<pid> session lock yields the main-session key only while that Windows process lives
ok - auto-arm: a claim pins a win:<pid> lock holder and reads open only while that holder lives
ok - auto-arm: mid-turn health accepts a rewake bound to a live win:<pid> holder and drops it when that holder exits
Evidence: Live validation summary

Source: Live validation summary

# Live validation: ps-denied session-lock identity (fix/5238-session-lock-ps-denial @ 6060cdf0)

Host: Linux (zeppola) 7.3.1. Everything below ran in a disposable lab home minted with
`bin/fm-lab-home.sh create` and removed in the same turn; no operator fleet state touched.

## How the product was driven

`ps` denial is produced exactly as an EDR policy presents it: a `ps` on PATH that prints
"Operation not permitted" and exits 126 for every call, including `ps -V` (the shape
`bin/fm-session-lock-lib.sh` requires before it routes identity off ps). The process tree,
the `/proc` provider, and the CLI are real:

- harness = a copy of bash at `<lab>/bin/claude` (kernel comm `claude`)
- Cursor harness = copy of bash at `<lab>~/.local/share/cursor-agent/versions/test/agent`,
  launched through the legacy alias symlink `<lab>~/.local/bin/agent` (comm `agent`,
  argv0 carries the non-ASCII path)
- CLI = `bin/fm-lock.sh` from this worktree, `FM_HOME=<lab>`

Driver: `live-drive.sh` (this directory). Transcript: `live-drive-transcript.log`.

## Scenarios and results

| # | Scenario | Result |
|---|----------|--------|
| S1 | A primary acquires the lock while ps is denied | PASS — `lock acquired: harness pid N`, exit 0, `state/.lock` = N |
| S2 | A second primary cannot take a live owner's lock while ps is denied | PASS — refused with `another live firstmate session holds the lock (pid OWNER)`, exit 1, lock unchanged |
| S3 | A dead owner's lock is still reclaimable while ps is denied | PASS — reclaim succeeded, exit 0, `state/.lock` rewritten to the new pid |
| S4 | `fm-lock.sh status` agrees with the lock verdict while ps is denied | PASS — `held by live harness pid N` while alive, `stale` after the owner exits |
| S5 | A live Cursor owner behind a non-ASCII (`José`) alias path keeps its lock | PASS — ps and /proc routes report byte-identical comm/args, `José` preserved, harness verdict `alive` on both routes, contender refused, lock unchanged |

## What could not be driven here

`bin/fm-procinfo.py` is the Darwin-only identity provider (sysctl KERN_PROCARGS2 /
KERN_PROC_PID). This host is Linux, so only the `/proc` provider could be exercised live; the
suite's own `fm-procinfo.py` cases report "macOS-only, skipped" here as well. Re-running
`tests/fm-session-lock-ps-denied.test.sh` (its e2e blocked-ps case) on a macOS host exercises
the sysctl route.

## Focused suites

- `tests/fm-session-lock-ps-denied.test.sh` — ALL PASS (`suite-ps-denied.log`)
- `tests/fm-session-lock-windows-consumers.test.sh` — pass (`suite-windows-consumers.log`)
- `tests/fm-inbox.test.sh` — pass (`suite-inbox.log`)
- `tests/fm-session-lock-ancestry.test.sh` — 21 ok, 1 pre-existing failure
  `the pty-host was not reparented to init after the daemon ended` (pid-1 reparent assertion,
  already reported in earlier rounds; unrelated to this change) (`suite-ancestry.log`)
Evidence: Key live evidence lines
=== S1: a primary acquires the session lock while ps is denied
lock acquired: harness pid 961880
cli-rc=0
lock-line1=961880
PASS S1 the CLI exited 0
=== S2: live foreign owner refused
S4 live status (denied ps): lock: held by live harness pid 962021
error: another live firstmate session holds the lock (pid 962021); operate read-only until resolved
contender-rc=1
lock-line1=962021
PASS S2 the takeover attempt left the owner pid 962021 in state/.lock
=== S3/S4: dead owner
S4 dead status (denied ps): lock: stale (pid 962021 dead or not a harness)
lock acquired: harness pid 962388
cli-rc=0
lock-line1=962388
=== S5: Cursor alias under a UTF-8 path
kernel comm: agent
ps route : comm=[agent] args=[/tmp/fm-lab.m3OoHG/Users/José/.local/bin/agent ...]
/proc route: comm=[agent] args=[/tmp/fm-lab.m3OoHG/Users/José/.local/bin/agent ...]
harness verdict with ps available: [alive]
harness verdict with ps denied : [alive]
error: another live firstmate session holds the lock (pid 962676); operate read-only until resolved
=== RESULT rc=0

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A primary acquires the session lock on a ps-denied host (real bin/fm-lock.sh, real process tree, /proc identity route) ✅ pass live live-drive-transcript.log S1: lock acquired: harness pid 961880, cli-rc=0, lock-line1=961880
A second primary on a ps-denied host cannot take a live owner's lock (foreign-owner refusal, no takeover) ✅ pass live live-drive-transcript.log S2: error: another live firstmate session holds the lock (pid 962021), contender-rc=1, lock still 962021
A dead owner's lock remains reclaimable on a ps-denied host (no permanent read-only wedge) ✅ pass live live-drive-transcript.log S3: after stopping the owner, lock acquired: harness pid 962388, cli-rc=0, lock-line1=962388
bin/fm-lock.sh status agrees with the lock verdict on a ps-denied host (held while alive, stale after exit) ✅ pass live live-drive-transcript.log S4: lock: held by live harness pid 962021 then lock: stale (pid 962021 dead or not a harness)
A live Cursor owner behind a non-ASCII alias path (…/José/.local/bin/agent) keeps its lock on a ps-denied host: comm/args identical across ps and /proc routes and the contender is refused ✅ pass live live-drive-transcript.log S5: ps and /proc routes both report comm=[agent] args=[/tmp/…~/.local/bin/agent …], harness verdict with ps denied: [alive], contender refused, lock unchanged a…
The macOS sysctl identity provider (bin/fm-procinfo.py) resolves identity and preserves UTF-8 on a genuinely ps-denied Darwin host ⏸️ untested no This host is Linux 7.3.1; bin/fm-procinfo.py reads identity only through Darwin's sysctl(KERN_PROCARGS2/KERN_PROC_PID), which no Linux kernel provides, so the only routes available here (real Darwin s…
  • bash tests/fm-session-lock-ps-denied.test.sh -> ALL PASS
  • bash tests/fm-session-lock-windows-consumers.test.sh -> pass
  • bash tests/fm-inbox.test.sh -> pass
  • bash tests/fm-session-lock-ancestry.test.sh -> 21 ok, 1 pre-existing failure (the pty-host was not reparented to init after the daemon ended)
  • live: bin/fm-lab-home.sh create $LAB then bash live-drive.sh &lt;worktree&gt; $LAB — real bin/fm-lock.sh under a ps shim that exits 126 for every call (including ps -V), real process tree with a bash-copy harness (claude), real /proc provider
  • live S1: primary acquires the lock with ps denied (lock acquired: harness pid N, exit 0, state/.lock = N)
  • live S2: second primary refused with another live firstmate session holds the lock (pid OWNER), exit 1, state/.lock unchanged
  • live S3: after the owner was stopped, the stale lock was reclaimed and state/.lock rewritten to the new pid
  • live S4: bin/fm-lock.sh status -> lock: held by live harness pid N while alive, lock: stale (...) after exit
  • live S5: Cursor harness launched via &lt;lab&gt;~/.local/bin/agent; ps route and /proc route report byte-identical comm/args with José preserved, fm_harness_pid_alive = alive on both routes, contender refused and lock unchanged
  • teardown: rm -rf $LAB for every lab; worktree left clean (git status --porcelain empty)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kesslerio
kesslerio force-pushed the fix/5238-session-lock-ps-denial branch from 44b1fb2 to 0ffc012 Compare October 21, 2026 16:03
@kesslerio kesslerio changed the title fix(session): preserve lock safety when ps execution is denied fix(session-lock): recover locks when ps execution is denied Oct 21, 2026
@kesslerio kesslerio changed the title fix(session-lock): recover locks when ps execution is denied fix(bin): preserve session locks when ps execution is denied Oct 21, 2026
@kesslerio kesslerio changed the title fix(bin): preserve session locks when ps execution is denied fix: recover session locks when ps execution is denied Oct 21, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio. This is careful work on a nasty failure mode. A home that's permanently lock-refused, or a live owner that gets taken over, is exactly the kind of thing that should never happen quietly. I read head 01b6a3c1 against main 3847411b (0 behind).

What I checked:

  • All identity reads now go through fm_proc_info. ps is still used as-is wherever it executes. Only a ps that can't execute at all (exit 126 or 127) falls back, to /proc on Linux or the new bin/fm-procinfo.py on macOS. That helper reads only the ppid and the argv region through sysctl, stops before env, and has no network or file writes. With no python3, it fails closed with a one-time diagnostic.
  • fm-lock.sh, fm-claude-stop-autoarm.sh and fm-turnend-guard-cursor.sh now use fm_session_lock_pid_blocks_reclaim in place of fm_harness_pid_alive. A live owner whose identity can't be read now blocks reclaim instead of being taken over. A lock file that holds no pid stays reclaimable.
  • No .github changes and no credential paths. I have no security concerns.
  • The body closes A denied ps binary exec makes session identity unprovable: every session is lock-refused read-only, and a live lock owner can be taken over #5238 (ready-for-pr), and the change does address it.
  • The no-mistakes attestation matches this head. CI is green except Behavior portable serial 2, which is still running.

Contract-class (mine): restore. The session lock is an existing default path, and its promise is to refuse a live owner and reclaim a dead one. On a host where ps is denied, that path was broken in both directions. On hosts where ps runs, the read route is unchanged, and your 200-process divergence run backs that up. The only verdict change is fail-closed, inside the lock's own refusal.

VISION.md, rule by rule

  • One captain, one interface: aligns (no new captain-facing surface).
  • Authority is explicit and never inferred: aligns (a live owner is never taken over).
  • Scripts own the mechanics, agents own the judgment: aligns (exact reads, fail-closed).
  • A restart is a non-event: aligns (a home can take its lock again instead of staying read-only).
  • Delegation with a spine: cannot tell yet. See below.
  • The fleet outlives any vendor: aligns (OS-native providers, ps stays primary).
  • Scope: aligns.

One warm ask, no rush (waiting on you): #5238 was reported on a hardened macOS host, and the macOS provider is the one part nothing has exercised yet. Your body says so, and the pipeline's live verdict is 1 of 4. When you get the chance, could you run this head on a macOS host where ps exec is denied (the original one, if you still have it)? It would help to see three things: a fresh session taking the lock, a second session refused while the first is alive, and fm-procinfo.py agreeing with Apple's ps on a host where ps runs. Please post the transcript here, or re-raise through git push no-mistakes with it. We won't run our own live test. With that evidence and green CI, this is on track to merge as a restore.

@cr101

cr101 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

A note for the rebase over #6300 (merged 2026-10-23): main's session lock can now hold a Windows-tagged owner, win:<pid>, and fm_harness_pid_alive answers that from ps -W.

At head 01b6a3c1, fm_session_lock_pid_blocks_reclaim returns 1 for any non-numeric value (''|*[!0-9]*|0) return 1 ;;). Once it replaces fm_harness_pid_alive at the call sites in fm-lock.sh, fm-claude-stop-autoarm.sh and fm-turnend-guard-cursor.sh, a live Windows session's lock would read as reclaimable, and a second session could take it over. That regresses what #6300 added.

A tagged value probably needs its own branch: validity from fm_session_pid_valid, and liveness from fm_win_command. Its exit 2, meaning the Windows process table could not be read, would map to unreadable and block reclaim, the Windows counterpart of the denied-ps case this PR fixes.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: a quick update on where this stands, @kesslerio.

Two things changed on main's side since my 10-21 note:

  • It now conflicts with main. GitHub reports 01b6a3c1 as CONFLICTING against d46a6431, so it needs a rebase.
  • @cr101's note above is right, and it blocks the merge. fix: identify Windows/Git Bash harness sessions for the session lock #6300 (merged 2026-10-23) lets the session lock record a Windows-tagged owner, win:<pid>, and main's fm_harness_pid_alive answers it through fm_win_untag_pid / fm_win_command. At this head, fm_session_lock_pid_blocks_reclaim returns "reclaimable" for any non-numeric value (''|*[!0-9]*|0) return 1 ;;). Once it replaces fm_harness_pid_alive in fm-lock.sh, fm-claude-stop-autoarm.sh and fm-turnend-guard-cursor.sh, a live Windows session's lock would read as free and a second session could take it. That's the same "live owner taken over" failure this PR fixes for denied ps. A win: branch that maps an unreadable Windows process table to unreadable (blocks reclaim) would keep both promises. A test with a live tagged owner would pin it.

Still open from 10-21: the macOS ps-denied live trace (a fresh session takes the lock, a second session is refused while the first is alive, and fm-procinfo.py agrees with Apple's ps where ps runs). If you no longer have that host, just say so in the PR body.

Please rebase, cover the tagged owner, and re-raise with git push no-mistakes so the attestation binds the new head. Contract-class (mine): restore, unchanged. It's on the auto-merge path once those are in and CI is green. VISION.md: unchanged from 10-21. "Authority is explicit" now depends on the Windows case: a live owner must never be taken over on any platform.

Status: waiting on you.

@kesslerio
kesslerio force-pushed the fix/5238-session-lock-ps-denial branch from 01b6a3c to a447924 Compare October 27, 2026 06:08
@kesslerio kesslerio changed the title fix: recover session locks when ps execution is denied fix(session-lock): resolve harness identity when ps is denied Oct 27, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio, this round covers both things from my 10-24 note.

What I checked at a4479244:

  • The Windows tagged owner is fixed. fm_session_lock_pid_blocks_reclaim now starts with fm_session_pid_valid, so a win:<pid> owner gets to the fm_win_untag_pid / fm_win_command verdict. An unreadable Windows table reads as unreadable and blocks reclaim. Empty, whitespace, malformed and all-zero records stay reclaimable. That's what @cr101 described.
  • The macOS trace: the body now says plainly that no macOS host was available, which is what I asked for. Live validation reads go (4 of 5), and the macOS route is the one disclosed gap.
  • The no-mistakes attestation matches this head. I found no .github changes, no network calls and no credential paths, so no security concerns.

The conflict is ours to fix, and you don't need to rebase. Main moved to 7da4c362 with #7746, which also touched tagged Windows lock holders. The only conflict is one hunk in docs/watcher-continuity.md, the session-lock bullet. I merged main into this branch locally and kept your wording, since it describes the new reclaim rule. bin/fm-session-lock-lib.sh merges cleanly with #7746's fm_session_pid_alive / fm_session_pid_identity. On that merge, tests/fm-session-lock-ps-denied.test.sh and #7746's tests/fm-session-lock-windows-consumers.test.sh both pass. I can't push it from here, because the merge carries main's workflow-file changes onto your fork. So we'll land the merge another way on our side. Because of the conflict, CI hasn't run on this head yet.

Contract-class (mine): restore, unchanged. The session lock's existing promise is to refuse a live owner and reclaim a dead one, and on a ps-denied host that promise was broken. VISION.md: it aligns on every rule, the same as 10-21. Authority is explicit: no platform now lets a live owner be taken over.

Status: on our side, not waiting on you. Once the conflict is resolved, CI needs to go green on the merged head. Then it's on the auto-merge path.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio for sticking with this. I tried to land it through a port of your change, resolved against main after #7746 (#7845), and CI turned up a few things that come from the current head here (a4479244), not from the conflict:

  • tests/fm-grok-harness.test.sh and tests/fm-kimi-harness.test.sh: "fm-lock did not recognize grok/kimi as a live holder". I can reproduce this locally on a4479244. Main and your earlier head 01b6a3c1 both pass, so it seems to have come in with the last fix round.
  • tests/fm-inbox.test.sh: "a live claude-named holder is a held lock (expected 'held', got 'unknown')".
  • ShellCheck SC2034 in bin/fm-session-lock-lib.sh (win_rc, FM_LOCK_INSPECT_STATE, FM_LOCK_INSPECT_LIVE_HARNESS unused).

Could you take a look at those when you have a moment? Two other failures on the port are on our side and not yours: the test coverage guard's shard budget (fixed by a pending shard change), and a serial job hitting the time cap. The merge conflict with main is also ours to resolve; you don't need to rebase. Once the three items above pass, we'll take it from there. I'm closing the port #7845 so there's one place to work: this PR.

@kesslerio

kesslerio commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Fixed in db73c9d8. Root cause of the three CI failures at a4479244.

fm_session_lock_inspect in bin/fm-session-lock-lib.sh decides a holder from FM_SESSION_LOCK_PID_VERDICT, but its readable branch had stopped asking whether the process is a verified harness. Every live holder therefore fell through to the function's initial unknown, so nothing could ever read held:

  • tests/fm-grok-harness.test.sh and tests/fm-kimi-harness.test.sh: "fm-lock did not recognize grok/kimi as a live holder", reported as lock: stale instead of lock: held by live harness pid.
  • tests/fm-inbox.test.sh: "a live claude-named holder is a held lock (expected 'held', got 'unknown')".

The same commit added a Windows-tagged pre-block that decided held a second time through fm_harness_pid_alive, which is also what left winpid and win_rc unused for SC2034.

The fix decides the verdict once. The readable branch calls fm_harness_process_matches on the FM_PROC_COMM/FM_PROC_ARGS that fm_session_lock_pid_verdict already loaded, so a classified harness reads held and a readable non-harness stays unknown. The tagged-pid pre-block is gone because fm_session_lock_pid_verdict already resolves a tagged pid through the Windows table and leaves the same fields for that same match; keeping both let one holder be classified twice and diverge. That removes the unused bindings with it.

Evidence:

  • tests/fm-grok-harness.test.sh, tests/fm-kimi-harness.test.sh, tests/fm-inbox.test.sh: fail at a4479244 with the messages above, pass at db73c9d8.
  • Windows-tagged inspect verdicts are unchanged and still covered by tests/fm-session-lock-ancestry.test.sh, which asserts held win:7204 true, stale false for a pid absent from the table, unknown false for a live non-harness, and unknown unknown behind an unreadable table.
  • bin/fm-lint.sh: pass, ShellCheck 0.11.0 at the pinned version, no SC2034 left in the file.
  • Also green on db73c9d8: fm-session-lock-ps-denied, fm-cursor-primary, fm-guard-stale-banner, fm-pi-watch-extension, fm-pi-branch-extension, fm-startup-network, fm-turnend-guard, fm-herdr-session-cleanup, fm-secondmate-safety.

The merge conflict and the rebase are untouched, since those are owned here.

Failures that predate this diff, reproduced both at a4479244 with the fix stashed and on upstream main in this checkout, so not caused by it: the pty-host reparent assertion in fm-session-lock-ancestry, the dead-steal-owner reclaim in fm-watcher-lock, harness resolution in fm-secondmate-harness, and fm-backlog-read-bound, fm-claude-stop-autoarm, fm-omp-harness, fm-session-start. Each fails because of this host's process and environment shape, not the session-lock change.

The exact patch, for a port that does not take the branch:

diff --git a/bin/fm-session-lock-lib.sh b/bin/fm-session-lock-lib.sh
index de057dd4..b3eb8e51 100644
--- a/bin/fm-session-lock-lib.sh
+++ b/bin/fm-session-lock-lib.sh
@@ -840,7 +840,7 @@ FM_LOCK_INSPECT_STATE=unknown
 FM_LOCK_INSPECT_PID=
 FM_LOCK_INSPECT_LIVE_HARNESS=unknown
 fm_session_lock_inspect() {  # <state>
-  local state=$1 lock pid winpid win_rc
+  local state=$1 lock pid
   # shellcheck disable=SC2034 # Output globals, read by lock status and inbox ready.
   FM_LOCK_INSPECT_STATE=unknown
   # shellcheck disable=SC2034 # Output globals, read by lock status and inbox ready.
@@ -865,14 +865,10 @@ fm_session_lock_inspect() {  # <state>
   # shellcheck disable=SC2034 # Output global, read by lock status and inbox ready.
   FM_LOCK_INSPECT_PID=$pid
   fm_session_pid_valid "$pid" || return 0
-  if winpid=$(fm_win_untag_pid "$pid"); then
-    # The same verdicts as a local pid below, read from the Windows table.
-    if fm_harness_pid_alive "$pid"; then
-      FM_LOCK_INSPECT_STATE=held
-      FM_LOCK_INSPECT_LIVE_HARNESS=true
-      return 0
-    fi
-  fi
+  # One verdict for every identity form. A tagged Windows pid is resolved by
+  # this same call through the Windows table, so the match below is the single
+  # place "live verified harness" is decided; deciding it a second time ahead
+  # of this one is what let a holder read as held there and unknown here.
   fm_session_lock_pid_verdict "$pid"
   case "$FM_SESSION_LOCK_PID_VERDICT" in
     dead)
@@ -882,8 +878,15 @@ fm_session_lock_inspect() {  # <state>
       FM_LOCK_INSPECT_LIVE_HARNESS=false
       ;;
     readable)
-      FM_LOCK_INSPECT_STATE=unknown
-      FM_LOCK_INSPECT_LIVE_HARNESS=false
+      if fm_harness_process_matches "$FM_PROC_COMM" "$FM_PROC_ARGS"; then
+        # shellcheck disable=SC2034 # Output globals, read by lock status and inbox ready.
+        FM_LOCK_INSPECT_STATE=held
+        # shellcheck disable=SC2034 # Output globals, read by lock status and inbox ready.
+        FM_LOCK_INSPECT_LIVE_HARNESS=true
+      else
+        # shellcheck disable=SC2034 # Output global, read by lock status and inbox ready.
+        FM_LOCK_INSPECT_LIVE_HARNESS=false
+      fi
       ;;
   esac
 }

@kesslerio

Copy link
Copy Markdown
Contributor Author

Rebased onto main 095db3bc so the fix can be re-validated against the current tree.

  • Conflicts: docs/watcher-continuity.md (prose) plus one earlier commit's hunk in bin/fm-session-lock-lib.sh. Both resolved by keeping main's newer content and this branch's documented behavior. The doc keeps main's tagged win:<pid> / fm_harness_pid_alive wording together with this branch's precision about when a lock is reclaimable (confirmed dead, or a readable identity that is not a verified harness; a live owner whose identity cannot be read stays inert). The library keeps main's fm_session_pid_alive / fm_session_pid_identity beside this branch's fm_session_lock_pid_blocks_reclaim.
  • Rebased tip: bb17a785. The patch from my previous comment is unchanged: fm_session_lock_inspect decides held on the readable verdict again.
  • Local evidence at the rebased tip: tests/fm-session-lock-ps-denied.test.sh ALL PASS (including the ps-denied e2e), tests/fm-session-lock-windows-consumers.test.sh pass, bin/fm-lint.sh clean (ShellCheck 0.11.0, actionlint 1.7.12), tests/fm-pi-primary-types.test.sh pass.

One environmental caveat: tests/fm-session-lock-ancestry.test.sh fails its the pty-host was not reparented to init after the daemon ended case here. That assertion is byte-identical on main, and it cannot pass on a host whose systemd --user manager (a subreaper) reaps the orphan instead of pid 1, so it is not from this branch.

@kesslerio
kesslerio force-pushed the fix/5238-session-lock-ps-denial branch from a447924 to cafa115 Compare October 31, 2026 07:30
@kesslerio kesslerio changed the title fix(session-lock): resolve harness identity when ps is denied fix(bin): read session-lock owner identity without ps and stop reclaiming unreadable live owners Oct 31, 2026
@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link