Skip to content

fix(coding-agent): stabilize daemon process identity across timezone changes - #1971

Merged
snimu merged 1 commit into
PrimeIntellect-ai:mainfrom
sethkarten:fix/timezone-stable-process-identity
Sep 2, 2026
Merged

snimu merged 1 commit into
PrimeIntellect-ai:mainfrom
sethkarten:fix/timezone-stable-process-identity

Conversation

@sethkarten

@sethkarten sethkarten commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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 rendered Sat Aug 29 13:55:18 2026 in America/Los_Angeles and Sat Aug 29 16:55:18 2026 after switching to America/New_York. The durable owner comparison then reported supervisor_generation_stale, and new session creation timed out after 30 seconds.

This revives the still-unmerged timezone fix from #908 against current main and includes the locale pinning discussed in #1234 and #1607.

Changes

  • Run only the portable ps -o lstart= fallback with TZ=UTC and a fixed C locale while preserving the rest of the caller environment.
  • Keep the Linux /proc and Windows UTC-tick identity paths unchanged.
  • Add a deterministic regression that changes the caller timezone from America/Los_Angeles to America/New_York and verifies both probes receive the same UTC identity.
  • Add the coding-agent changelog fragment.

This is backward-compatible at the daemon protocol level: no command, event, capability, or response shape changes, and processStartId remains an optional opaque string. Pre-fix ps: 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).
  • Source probe with process.env.TZ changed from America/Los_Angeles to America/New_York — both returned ps: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 different ps: processStartId values and durable ownership checks treated the supervisor as stale.

getPsProcessStartId now runs that query with TZ=UTC and a fixed C locale (LC_ALL, LC_TIME, LANG), via an optional env on runProcessQuery. Linux /proc and Windows tick identities are unchanged.

Adds a regression test (mocked ps plus Darwin supervisor ownership across a TZ switch) and a changelog fragment. Pre-fix ps: 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 getProcessStartId to pin UTC/C environment in ps fallback

  • Adds getPsProcessStartId in session-lease.ts, which forces LC_ALL, LC_TIME, LANG to C and TZ to UTC in the ps subprocess so the lstart field is stable across caller timezone or locale changes.
  • Extends ProcessQuery and runProcessQuery to accept an optional env parameter so callers can pin subprocess environment variables.
  • Reworks the POSIX fallback in getProcessStartId to delegate to getPsProcessStartId instead of issuing an inline ps command.
  • Adds a regression test in 879-timezone-stable-process-identity.test.ts verifying identical identifiers across timezone changes on macOS.
  • Behavioral Change: non-win32 platforms without /proc now derive the process start ID from a ps subprocess with a pinned UTC/C environment rather than inheriting the caller's locale and timezone.

Macroscope summarized 99611ab.

Linear

@snimu
snimu merged commit 0ba0423 into PrimeIntellect-ai:main Sep 2, 2026
18 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing macOS timezone invalidates the running daemon

2 participants