Repository navigation
fix(bin): pin pid-identity time zone so engines in another TZ keep the host's grant - #7265
Conversation
fm_pid_identity's ps fallback (macOS, or any host without /proc) renders lstart in local time. A supervision engine launched through a wrapper that exports a different TZ than the host's hook environment read the host's branch-grant owner identity as a different process, so its drain discarded the grant as stale and refused. The engine reported but could never acknowledge its granted rows, and the host handed nearly every wake to main. Pin TZ=UTC0 alongside the existing LC_ALL and COLUMNS pins, and pin the same zone in fm-extension.mjs's pidIdentity, which compares identities the bash helper writes. Add a host regression test that runs the engine in another time zone than the host on the process-table path.
|
Speaking as Kun's firstmate: thank you @leo1oel. This is a really clean find. A real-engine negative control that reproduces the What I checked: the full diff at Fork CI: approved for this head (CI Contract-class (my own verdict): restore. The supervision engine was already specified to drain, report, and acknowledge its granted rows. A time-zone mismatch was breaking that path. After the fix the default run does what it already promised, with no new surface. I accept the bounded upgrade-window residual on /proc-less non-UTC hosts as documented. VISION: aligns on every rule (fewer duplicate main turns, deterministic script fix, harness-agnostic, guard for report-without-ack kept). Live validation: 4 of 6 live, including the real-Claude before/after. I accept that. Optional, your call: the no-mistakes review note about Next step: once CI is green this can merge on its own, so it's waiting on CI, not on you. |
# Conflicts: # tests/fm-supervision-host.test.sh
|
Speaking as Kun's firstmate: thanks for bringing this up to date, @leo1oel, and for documenting the residual in I re-checked new head Contract-class (mine): restore, unchanged. The engine was already specified to drain, report and acknowledge its granted rows, and a time-zone mismatch broke that. VISION: aligns on every rule. Your earlier live evidence still covers this. A heads-up, nothing to do now: #7706 is splitting Next step: nothing is waiting on you. We're waiting on CI, and once it's green this can merge. |
|
Speaking as Kun's firstmate: this is merged. Thank you @leo1oel — really appreciate you taking the time on this. |
Port #7265's engine time-zone grant test into the split host suites and keep the combined host test file deleted. Co-authored-by: Kun Chen <[email protected]>
…e host's grant (kunchenguid#7265) * fix(wake): pin TZ in the process-table pid identity fm_pid_identity's ps fallback (macOS, or any host without /proc) renders lstart in local time. A supervision engine launched through a wrapper that exports a different TZ than the host's hook environment read the host's branch-grant owner identity as a different process, so its drain discarded the grant as stale and refused. The engine reported but could never acknowledge its granted rows, and the host handed nearly every wake to main. Pin TZ=UTC0 alongside the existing LC_ALL and COLUMNS pins, and pin the same zone in fm-extension.mjs's pidIdentity, which compares identities the bash helper writes. Add a host regression test that runs the engine in another time zone than the host on the process-table path. * no-mistakes(review): Document TZ-pin identity upgrade-window residual * no-mistakes(document): Note TZ pid-identity upgrade residual in turnend-guard doc (cherry picked from commit 43cd3b7)
Intent
The captain approved (2026-10-14: "好的, 你来提交就行") submitting the real firstmate bugs found by a retro to firstmate's upstream. This task fixes retro candidate #4: the supervision-host engine almost never completes a wake. state/.supervision-host.log over 2026-10-13T05:45Z to 2026-10-14T02:53Z shows 134 start, 109 failed, 110 to-main and 1 handled; each failed line has rc=0 reports=1 unacked=: the engine recorded an outcome but left its granted wake rows queued, so bin/fm-supervision-host.sh labels the turn failed and hands every wake to the main session (two model turns per wake). The engine prompt (bin/fm-supervision-instructions.sh) appears to have no wake-ack step for a Claude engine; that is the leading hypothesis, not yet proven.
What Changed
fm_pid_identityinbin/fm-wake-lib.shnow runsps -o lstart=withTZ=UTC0. Before this, a supervision engine launched with a differentTZthan the host's hooks would read the host's grant owner as dead. It then discarded the branch grant, refused its drain, and left every granted wake row queued for main.capturedProcessOutputinbin/fm-extension.mjs(whichpidIdentityuses) now pins the sameTZ: "UTC0".docs/turnend-guard.mdrecord one accepted upgrade-window residual. On a host without /proc and outside UTC, an identity recorded before this change can read as reused until the restart that follows the update.test_engine_in_another_time_zone_handles_its_granted_rowstotests/fm-supervision-host.test.sh. It runs the engine stub in another TZ through a newstub-tzfixture and hides /proc so Linux takes the process-table path. It then checks that the turn ends handled without a failed line, that the drain keeps the grant, and that the wake is acknowledged and never reaches main.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is small and well-bounded. It pins TZ=UTC0 on the lstart fallback in fm_pid_identity and on the matching ps call in fm-extension.mjs's pidIdentity, which consumes those identities. The grant-owner check in fm-supervision-engine-lib.sh (lines 196 and 259) goes through fm_pid_identity, so the engine-side drain now reads the same identity as the host. Other callers of capturedProcessOutput (pgid and command) do not depend on TZ. The upgrade-window residual is documented, as the user decided.
Testing
I first ran the new regression test on its own. It passes with the fix and fails with the fix reverted, reproducing the retro's
failed rc=0 reports=1 unacked→to-mainpattern. I then drove the real supervision host with a real Claude engine launched through the machine's cac wrapper, which exports a different TZ from the host's. With the fix the turn endedhandled reports=1, the wake queue was empty and nothing went to main. With the fix reverted the real engine produced the exact retro failure and hand-back to main, and its own summary says the drain refused for lack of a branch-eligible snapshot. A cross-TZ check showsfm_pid_identityand the extension's ps spawn now render the same identity in every zone; before the change the extension's spawn rendered a different one. One setup problem came up: the first real-engine attempt had nobin/in the fixture home and recorded no report. I symlinkedbinand re-ran. Temporary test copies and wrapper dirs were removed and the worktree is clean. The change has no UI, so there are no screenshots.handled ... rc=0 reports=1, wake queue empty, host still parked (no host.rc / no to-main)failed rc=0 reports=1 unacked=1 2,to-main ... left its granted wake rows 1 2 unacknowledged; engine says the dra…piis not on PATH. Only the extension's /bin/ps i…Evidence: Live real Claude engine, host TZ=UTC0 vs cac engine TZ=America/New_York, with fix: turn handled, queue empty, no hand-back to main
Source: Live real Claude engine, host TZ=UTC0 vs cac engine TZ=America/New_York, with fix: turn handled, queue empty, no hand-back to main
Evidence: Live real Claude engine, same setup with the TZ pin reverted: failed rc=0 reports=1 unacked=1 2, then to-main (retro signature)
Source: Live real Claude engine, same setup with the TZ pin reverted: failed rc=0 reports=1 unacked=1 2, then to-main (retro signature)
Evidence: Real engine JSON result with fix (filed report and ran ack)
Source: Real engine JSON result with fix (filed report and ran ack)
Evidence: Real engine JSON result with fix reverted (drain refused: no branch-eligible row snapshot)
Source: Real engine JSON result with fix reverted (drain refused: no branch-eligible row snapshot)
Evidence: Live driver script used for the real-engine runs
Source: Live driver script used for the real-engine runs
Evidence: Regression test output with fix
Source: Regression test output with fix
Evidence: Regression test output with fix reverted (fails as the retro did)
Source: Regression test output with fix reverted (fails as the retro did)
Evidence: pid identity rendered identically across TZs (shell and extension-style spawn)
Source: pid identity rendered identically across TZs (shell and extension-style spawn)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
handled ... rc=0 reports=1, wake queue empty, host still parked (no host.rc / no to-main)failed rc=0 reports=1 unacked=1 2,to-main ... left its granted wake rows 1 2 unacknowledged; engine says the dra…piis not on PATH. Only the extension's /bin/ps i…bash tests/zz-tz-only.test.sh(a temporary copy of tests/fm-supervision-host.test.sh, since removed, that runs onlytest_engine_in_another_time_zone_handles_its_granted_rowsplustest_attended_routine_wake_is_handled_on_the_engine_and_stays_off_main) with the fix: both okThe same focused test with theTZ=UTC0pin reverted in bin/fm-wake-lib.sh: the new test fails with the retro signaturefailed rc=0 reports=1 unacked=1 2/to-main, and the drain saysno branch-eligible row snapshot; the pin was restored afterwards withgit checkoutLive run: the real bin/fm-supervision-host.sh, watcher, grant, drain and report scripts in a disposable fixture home, host started with TZ=UTC0. The engine was the real Claude CLI through the machine's cac wrapper~/.cac/bin/claude(exports TZ=America/New_York), behind a tee wrapper that captures its JSON result. A real status append triggered the wakeThe same live real-engine run with the fix revertedCross-TZ check:fm_pid_identityunder TZ=UTC0, America/New_York, ENG-9 and Asia/Tokyo, compared with a node spawn of /bin/ps using the extension's new env and its pre-change env✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.