Summary:
- The PR refactors session-lock inspection to reclaim untracked current-process locks with matching starttime during acquisition and startup cleanup, adds regression tests, and adds a changelog entry.
- Reproducibility: yes. A high-confidence code-level reproduction is to create a fresh `.jsonl.lock` with `pid ... eLock or cleanStaleLockFiles on current main and observe that acquisition waits or cleanup leaves the lock.
ClawSweeper fixups:
- Included follow-up commit: docs: add session lock changelog entry
- Included follow-up commit: refactor(agents): distill session lock reclaim policy
Validation:
- ClawSweeper review passed for head 2eae2c93b1.
- Required merge gates passed before the squash merge.
Prepared head SHA: 2eae2c93b1
Review: https://github.com/openclaw/openclaw/pull/75822#issuecomment-4361741599
Co-authored-by: Cedric <86914379+cdznho@users.noreply.github.com>
Co-authored-by: Ayaan Zaidi <hi@obviy.us>
* fix: detect PID recycling in session write lock staleness check
The session lock uses isPidAlive() to determine if a lock holder is
still running. In containers, PID recycling can cause a different
process to inherit the same PID, making the lock appear valid when
the original holder is dead.
Record the process start time (field 22 of /proc/pid/stat) in the
lock file and compare it during staleness checks. If the PID is alive
but its start time differs from the recorded value, the lock is
treated as stale and reclaimed immediately.
Backward compatible: lock files without starttime are handled with
the existing PID-alive + age-based logic. Non-Linux platforms skip
the starttime check entirely (getProcessStartTime returns null).
* shared: harden pid starttime parsing
* sessions: validate lock pid/starttime payloads
* changelog: note recycled PID lock recovery fix
* changelog: credit hiroki and vincent on lock recovery fix
---------
Co-authored-by: HirokiKobayashi-R <hiroki@rhems-japan.co.jp>