Skip to content

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

Merged
code-yeongyu merged 2 commits into
code-yeongyu:mainfrom
surlymochan:fix/3067-dst-fallback-holder
Nov 16, 2026
Merged

code-yeongyu merged 2 commits into
code-yeongyu:mainfrom
surlymochan:fix/3067-dst-fallback-holder

Conversation

@surlymochan

@surlymochan surlymochan commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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.

Written for commit 910ae77. Summary will update on new commits.

View guided diff

@code-yeongyu

Copy link
Copy Markdown
Owner

Thanks, @surlymochan. Reading process start times in UTC so the repeated hour at a DST fall-back doesn't make a live holder look dead is a subtle one to catch (#3067 L1). Queued for review; I'll post the result here.

@code-yeongyu

Copy link
Copy Markdown
Owner

Thanks, @surlymochan. The review at 910ae77b6f is CLEAR (no critical/high/medium findings). Three small notes, none blocking:

  • changes/unreleased/6118.md:12 claims "every live-process start-time probe reads in UTC by construction", which is only true for readProcessStartTime callers. Two probes still read local lstart (no TZ=UTC): packages/coding-agent/src/modes/rpc/session-held.ts:68 (ps -axo pid=,lstart=) and packages/coding-agent/src/core/extensions/builtin/terminal/process-start-probe.ts:40 (darwinProcessStartMs). They
  • The test named "a UTC-recorded child stays a holder under a simulated DST zone" (packages/coding-agent/test/suite/regressions/3067-dst-fallback-holder.test.ts:48-81) never starts a holder inside the fall-back hour, so its holderPids assertion (:72) also passes on base. Only the UTC-suffix checks (:59, :80) fail on base. The first test (:35-46) only restates how Date.parse resolves the repeated hour
  • packages/coding-agent/test/suite/regressions/3054-utc-child-identity-holder.test.ts:28-30 still names the probe local, but it now reads UTC. The check is close to comparing the probe with itself, and the scenario that test was written for (UTC-tagged record vs local probe) is no longer exercised. Rename the variable, or leave the mixed-format coverage to the legacy-identity tests. Route to the next stack PR.

The first is worth a one-line wording fix in the changelog fragment if you're touching the branch again; the others can be follow-ups. This will be merged through the normal gate once its CI and receipt are in.

@code-yeongyu

Copy link
Copy Markdown
Owner

Correction to my note above, @surlymochan: two of those "small notes" should land before merge, since they decide whether the fix is complete and proven:

  1. Finish the class. session-held.ts:68 (ps -axo pid=,lstart=) and terminal/process-start-probe.ts:40 (darwinProcessStartMs) still read local lstart without TZ=UTC, so the same DST fall-back misread remains there. Please route them through the same UTC read (or readProcessStartTime), so the changelog's "every live-process start-time probe reads in UTC" is true.
  2. Make the holder test fail on base. In 3067-dst-fallback-holder.test.ts:48-81 the holder never starts inside the repeated hour, so the holderPids assertion (:72) passes on base too. Start the simulated holder inside the fall-back hour so that assertion goes red without the fix.

The third note (the 3054 test) can stay a follow-up. Sorry for the mixed signal.

code-yeongyu pushed a commit that referenced this pull request Nov 7, 2026
…enpi#3067 L5)

L5 of #3067 only; L1 is #6118, L2/L3/L4 are untouched, so this does not close #3067.
code-yeongyu pushed a commit that referenced this pull request Nov 7, 2026
…hrows (senpi#3067 L4)

L4 of #3067 only; L1 is #6118, L2/L3/L5 are untouched, so this does not close #3067.
@code-yeongyu
code-yeongyu merged commit 5559f11 into code-yeongyu:main Nov 16, 2026
11 checks passed
@code-yeongyu

Copy link
Copy Markdown
Owner

Landed on main through the merge train #6840 (merge commit c87f32d5ffeb8de6cf239f2a2229c95bfa291ec1) at this PR's head 910ae77b6f, merged unchanged with git merge --no-ff. Verified at the train top 648c980a9d: the Linux job set of .github/workflows/ci.yml ran green (24/24 jobs), bun run check and npm run knip:check exit 0, and a source build passed the CLI, RPC and mock-loop smokes.

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.

rpc host child identity: DST fall-back and wall-clock steps can misread a live child (review follow-ups from #3057)

2 participants