Fix frozen clock so dirty-worktree auto-recovery triggers (#367)#368
Merged
nicobistolfi merged 1 commit intomainfrom Apr 1, 2026
Conversation
App.New() assigned clock: time.Now().UTC which captures a bound method value from a single startup timestamp. Every call to a.clock() returned that frozen time, preventing blockedSessionExceededInactivityTimeout from ever aging blocked sessions past the auto-recovery window. Replace the frozen method value with a live closure that calls time.Now().UTC() on each invocation so timeout comparisons use wall clock time. Add regression tests: - TestNewAppClockReturnsLiveTime verifies successive clock calls advance - TestBlockedDirtyWorktreeSessionSkipsAutoRecoveryBeforeTimeout covers the negative case where a recently blocked session stays below timeout
6 tasks
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.
Summary
App.New()assigningclock: time.Now().UTC(a bound method value capturing a frozen startup timestamp) instead of a live closure — every call toa.clock()returned the same time, preventingblockedSessionExceededInactivityTimeoutfrom aging blocked sessions past the auto-recovery windowfunc() time.Time { return time.Now().UTC() }so timeout comparisons use wall clock timeTestNewAppClockReturnsLiveTime(successive calls advance) andTestBlockedDirtyWorktreeSessionSkipsAutoRecoveryBeforeTimeout(recently blocked session stays below timeout)Test plan
TestNewAppClockReturnsLiveTime— verifiesNew()clock returns advancing UTC timeTestBlockedDirtyWorktreeSessionSkipsAutoRecoveryBeforeTimeout— negative case: recently blocked session not prematurely recoveredTestScanOnceAutoRecoversStaleBlockedMaintenanceSession— existing e2e recovery path still passesTestShouldAutoRecoverBlockedSession— existing blocked-session eligibility logic unchangedTestBlockedSessionExceededInactivityTimeout*— all 3 existing inactivity activity-signal tests passgo test ./...)Closes #367