fix(coding-agent): stabilize daemon process identity across timezone changes - #1971
Merged
snimu merged 1 commit intoSep 2, 2026
Conversation
snimu
approved these changes
Sep 2, 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.
Context
Fixes #879.
Prime Agent 0.9.1 still stores the raw output of
ps -o lstart=as the macOS/BSD process identity. For the same live supervisor, macOS renderedSat Aug 29 13:55:18 2026inAmerica/Los_AngelesandSat Aug 29 16:55:18 2026after switching toAmerica/New_York. The durable owner comparison then reportedsupervisor_generation_stale, and new session creation timed out after 30 seconds.This revives the still-unmerged timezone fix from #908 against current
mainand includes the locale pinning discussed in #1234 and #1607.Changes
ps -o lstart=fallback withTZ=UTCand a fixed C locale while preserving the rest of the caller environment./procand Windows UTC-tick identity paths unchanged.America/Los_AngelestoAmerica/New_Yorkand verifies both probes receive the same UTC identity.This is backward-compatible at the daemon protocol level: no command, event, capability, or response shape changes, and
processStartIdremains an optional opaque string. Pre-fixps:owner records created outside UTC cannot be safely normalized because they contain no offset; a daemon that predates this change may need one session-preserving restart to refresh its durable record.Validation
npx tsx ../../node_modules/vitest/dist/cli.js --run test/suite/regressions/879-timezone-stable-process-identity.test.ts— 2 passed, including a real Darwin supervisor ownership check across the timezone change. The deterministic identity assertion failed before the implementation (expected "ps:Sat Aug 29 20:55:18 2026", received undefined).process.env.TZchanged fromAmerica/Los_AngelestoAmerica/New_York— both returnedps:Tue Sep 1 22:23:57 2026(stable: true).npm run check— passed with no warnings or errors.Note
Low Risk
Narrow change to macOS/BSD process identity probing for daemon leases; no protocol or API shape changes, with minor risk that old non-UTC
ps:owner records mismatch until restart.Overview
Fixes daemon session creation failing after macOS timezone changes (#879). The portable
ps -o lstart=fallback for process identity was using the host timezone, so the same supervisor PID could get differentps:processStartIdvalues and durable ownership checks treated the supervisor as stale.getPsProcessStartIdnow runs that query withTZ=UTCand a fixed C locale (LC_ALL,LC_TIME,LANG), via an optionalenvonrunProcessQuery. Linux/procand Windows tick identities are unchanged.Adds a regression test (mocked
psplus Darwin supervisor ownership across a TZ switch) and a changelog fragment. Pre-fixps:records without UTC normalization may need one restart to refresh stored identity.Reviewed by Cursor Bugbot for commit 99611ab. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
getProcessStartIdto pin UTC/C environment inpsfallbackgetPsProcessStartIdin session-lease.ts, which forcesLC_ALL,LC_TIME,LANGtoCandTZtoUTCin thepssubprocess so thelstartfield is stable across caller timezone or locale changes.ProcessQueryandrunProcessQueryto accept an optionalenvparameter so callers can pin subprocess environment variables.getProcessStartIdto delegate togetPsProcessStartIdinstead of issuing an inlinepscommand./procnow derive the process start ID from apssubprocess with a pinned UTC/C environment rather than inheriting the caller's locale and timezone.Macroscope summarized 99611ab.
Linear