Repository navigation
fix: stabilize Herdr pane process identity checks - #45
Merged
Merged
Conversation
ps lstart is derived from boot time plus starttime/HZ and drifts by one second between reads, so a live pane's recorded ps identity compared unequal and the pane read foreign and missing, duplicating secondmates. Record proc:<pid>:<boot-id>:<ticks> where /proc exists, keep ps:<pid>:<lstart> as the portable fallback, and treat a ps record with an equal pid and an lstart within one second as the same process. Relaunch re-records the identity through spawn.
This was referenced Oct 7, 2026
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
Fix a regression from PR 41 (commit e2b9778): the herdr pane process identity check is flaky, so live panes read as missing and get duplicated.
fm_backend_herdr_pane_process_identityinbin/backends/herdr.shrecordsps:<shell_pid>:<ps -o lstart>.ps lstartis derived from boot time plus starttime/HZ and drifts by plus or minus one second across calls.Observed example: a pane shell pid 1408408 recorded
Wed Oct 7 02:03:32 2026, while the same live process later read02:03:31;/proc/1408408/statfield 22 stayed stable at 43800329.fm_backend_herdr_endpoint_foreignthen treats the live owning pane as foreign,fm_backend_agent_statereportsmissing, and the secondmate liveness sweep relaunched several second mates into new panes beside their still-running, lock-holding agents (duplicates; one hit the relaunch bound).Existing worker and secondmate metas in every home still carry the flaky
ps:<pid>:<lstart>identity line.Requested fix:
/proc/<pid>/statstarttime ticks, or pid plus boot id plus starttime ticks).ps:<pid>:<lstart>records (accept a plus-or-minus one second lstart match, or re-derive).fm-controlrelaunch andfm-secondmate-restartrefresh the recorded identity when the pane process changes.What Changed
/procstart ticks and boot ID, retaining the portablepsfallback when start ticks are unavailable.ps:records so live panes are not incorrectly reported as missing and relaunched.Risk Assessment
✅ Low: The change is narrowly scoped, preserves legacy identity compatibility and ownership controls, and refreshes identities through the existing shared launch boundary without introducing substantiated material defects.
Testing
Five focused regressions and all live scenarios passed after resolving fixture setup issues; the old adapter reproduced the drift failure, while current ownership checks and recovery commands behaved correctly. Product logs and persisted metadata were retained, and disposable labs were removed. The secondmate persistence acknowledgment was supplied manually; this was runtime identity validation, not an autonomous LLM evaluation or a UI change.
Evidence: Validation report with persisted identity comparisons and test limitations
Source: Validation report with persisted identity comparisons and test limitations
Evidence: Live drift reproduction, fallback compatibility, and ownership refusals
Source: Live drift reproduction, fallback compatibility, and ownership refusals
Evidence: Public worker recovery and secondmate restart identity refresh
Source: Public worker recovery and secondmate restart identity refresh
Evidence: Supplemental targeted regression results
Source: Supplemental targeted regression results
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
tests/fm-backend-herdr.test.sh:5676- The legacy-record setup uses GNU-stylesed -i, which fails with stock macOS/BSD sed because it requires a backup-suffix argument. That failure is unchecked, leaving the originalproc:record intact; the assertion at tests/fm-backend-herdr.test.sh:5679 can then pass without exercising legacy-identity refresh. Use a portable, checked rewrite and verify that the persisted identity is the intendedps:value before relaunching.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
TMPDIR="$PWD/.identity-validation/tmp" bash tests/.identity-targeted.tmp.sh: executed the five targeted identity, drift, refresh, and unavailable-identity regression functions without running the full suite.bash .identity-validation/live-identity.sh: exercised real Herdr/Pi process ownership, legacy timestamp offsets, real-ps fallback, unreadable identities, and refused foreign input.Loaded the base-commit Herdr adapter against the same running pane and legacy +1-second record; reproduced its incorrectmissingverdict.bash .identity-validation/live-recovery.sh: exercised public recovery commands against disposable homes and an unchanged archived product checkout.$CODE/bin/fm-control.sh identity-worker relaunch --note 'Disposable fixture; no open work. Remain idle; do not invoke any pipeline.'Stopped and reprovisioned the named lab usingbin/fm-herdr-lab.sh, then repeated worker relaunch and verified a new endpoint and current process identity.$CODE/bin/fm-secondmate-restart.sh identity-mate, invoked through a real sanitized Pi primary; supplied the empty fixture's persistence acknowledgment throughfm-secondmate-report.sh.Verified published worker and secondmate metadata against fresh real-pane process identities.Tore down every lab, removed transient worktree fixtures, and confirmed only the default Herdr session remained.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.