fix(watcher): make Linux PID identity clock-drift stable#900
Open
omnimaycha wants to merge 1 commit into
Open
Conversation
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.
Intent
Prevent a live, healthy Firstmate watcher from being rejected by process-identity checks when WSL2 or another Linux host adjusts its wall-clock or boot-time reference.
Background
On WSL2,
ps lstartchanged for the same live PID after NTP synchronization or suspend.Observed identities shifted from
07:09:22when recorded to07:09:27on a live read, and a later watcher shifted from07:11:22to07:11:33.The drift recurred after watcher restarts, causing the turn-end guard and continuity gate to treat a healthy watcher as mismatched.
What Changed
/proc/<pid>/statfield 22 (starttime, in clock ticks since boot) together with the full/proc/<pid>/cmdlinebytes.statrecord after its final)so process names containing spaces or parentheses parse correctly./procidentity data is unavailable instead of falling back to drift-proneps lstart.ps lstartplus command fallback for non-Linux hosts such as macOS.Compatibility and migration
Existing consumers compare the identity as an opaque string and require no format-specific changes.
A legacy
lstartidentity mismatches once without producing a false healthy result.The supported watcher restart arm replaces that lock with a fresh watcher and writes the stable Linux identity.
Regression coverage
pswhen/procdata is missing.ps lstartoutput shifts by 11 seconds.fm-watch-arm.sh --restart.Validation
bin/fm-test-run.sh --changed --base origin/main: 10 watcher/wake/lock scripts passed with 0 failures.tests/fm-watcher-lock.test.sh: passed on WSL2, including the live lock and legacy migration cases.bin/fm-lint.sh: passed with the repository-pinned ShellCheck 0.11.0 across the canonical script set.Risk assessment
Low.
The behavior change is limited to Linux process-identity collection and strengthens fail-closed handling.
The non-Linux fallback and opaque consumer contract remain intact.