fix(coding-agent): read process start times in UTC so DST fall-back hours keep live holders (senpi#3067 L1)

Merged
SU
7d ago
+140-6

Summary

Fixes L1 of #3067 only (DST fall-back hour in the session-path holder lookup). L2–L5 are untouched, so this PR does not close #3067.

Root cause

holderPids in host-reservations.ts probes the live process with the local-time form (readProcessStartTime), while host-child.pid records a UTC-tagged start time (#3054). During a DST fall-back the local time 01:30 happens twice and Date.parse takes the earlier offset, so a child started in the repeated hour reads 1 hour off and stops counting as a holder of its sessions. The same mixed-format comparison existed in every other readProcessStartTime consumer (pidfile matching via processMatchesPidFile, published session-path claims, rpc-public-key records): all direct readProcessIdentity call sites already pass "UTC", only readProcessStartTime still probed local.

What changed

  • packages/coding-agent/src/utils/process-identity.ts: readProcessStartTime gains an optional timeZone: "UTC" = "UTC" parameter and passes it through to readProcessIdentity, so every live-process start-time probe reads in UTC by construction. Legacy local-format records are still parsed as local time by processStartTimeMs; outside the ambiguous hour the parsed instants are identical, inside it they are exact instead of 1h off.
  • packages/coding-agent/src/modes/rpc/host-reservations.ts: updated the now-stale comment that said the probe reads the local form.
  • packages/coding-agent/test/suite/regressions/3054-utc-child-identity-holder.test.ts: the old expect(utc.identity).not.toBe(local) asserted the two forms differ; the probe now returns the UTC form too, so it asserts the two parse to the same instant instead.

RED → GREEN

New regression packages/coding-agent/test/suite/regressions/3067-dst-fallback-holder.test.ts (senpi#3067 L1):

  • Parsing trap (passes pre/post fix, documents why): under TZ=America/New_York, processStartTimeMs("Sun Nov 1 01:30:00 2026") is 2026-11-01T05:30:00Z while the UTC form of the second-occurrence instant is 06:30:00Z — exactly 3,600,000 ms apart, sameProcessStartMs is false. No live process can be started in a past hour, so the repeated-hour instant itself is covered here by parsing; the holder test covers the wiring under a simulated DST zone.
  • Holder test (failed pre-fix at expect(probe.endsWith(" UTC")).toBe(true), passes post-fix): under simulated TZ=America/New_York, the probe of a live holder returns a UTC-tagged identity parsing to the same instant as readProcessIdentity(..., "UTC"), a UTC-recorded child is found by holderPids, and a claim published by createSessionPathReservations carries a UTC-tagged processStartTime.

Tests

  • New + directly affected: 3067-dst-fallback-holder.test.ts (2), 3054-utc-child-identity-holder.test.ts (1), test/suite/process-identity.test.ts (4) — 7 passed.
  • Targeted host suite (29 files covering every readProcessStartTime consumer, 225 tests): 162 passed, 62 failed — all 62 failures are environmental, reproduced identically on unmodified baseline via git stash对照:
    • 3054-supervisor-child-exit.test.ts: 11/11 ENOSPC: System limit for number of file watchers reached on baseline too.
    • rpc-host-daemon-dir.test.ts: same 1 test (HostDaemonStateError expectation) fails on baseline too.
    • Remaining failures share the same signatures: ENOSPC file-watcher exhaustion, unsafe_key_record (supervisor refuses group-writable tmp dirs under this VM's umask 0007), and stdin lifetime reopen unavailable on spawned supervisors. Two full targeted runs reproduce identical counts (13 files / 62 tests), i.e. deterministic environment failure, not a code regression.
  • bun run check (oxlint, fmt, tsc, locks): exit 0.

Out of scope

L2 (wall-clock steps / /proc ticks), L3 (once-per-generation logging), L4 (recovery error chaining), L5 (shutdown-recovery test gaps) — left for follow-ups.


Summary by cubic

Fixes DST fall-back hours dropping live session holders in the coding agent (L1 of #3067 only; L2–L5 untouched). readProcessStartTime now probes live processes in UTC by default, matching the UTC-tagged records written by host-child.pid, so a child started in the ambiguous fall-back hour no longer reads one hour off and stops counting as a holder. A changelog fragment documents the fix.

  • Legacy local-format records still parse as local time, so behavior outside the repeated hour is unchanged.
  • Updated the 3054 regression test to assert the probe and record parse to the same instant rather than different forms.
  • Added a regression test under TZ=America/New_York covering the parsing trap, holder lookup through holderPids, and UTC-tagged published claims.