Skip to content

Fix frozen clock so dirty-worktree auto-recovery triggers (#367)#368

Merged
nicobistolfi merged 1 commit intomainfrom
vigilante/issue-367-fix-dirty-worktree-blocked-sessions-so-maintenance-auto-recovery-actually-triggers
Apr 1, 2026
Merged

Fix frozen clock so dirty-worktree auto-recovery triggers (#367)#368
nicobistolfi merged 1 commit intomainfrom
vigilante/issue-367-fix-dirty-worktree-blocked-sessions-so-maintenance-auto-recovery-actually-triggers

Conversation

@nicobistolfi
Copy link
Copy Markdown
Collaborator

Summary

  • Fix App.New() assigning clock: time.Now().UTC (a bound method value capturing a frozen startup timestamp) instead of a live closure — every call to a.clock() returned the same time, preventing blockedSessionExceededInactivityTimeout from aging blocked sessions past the auto-recovery window
  • Replace with func() time.Time { return time.Now().UTC() } so timeout comparisons use wall clock time
  • Add regression tests: TestNewAppClockReturnsLiveTime (successive calls advance) and TestBlockedDirtyWorktreeSessionSkipsAutoRecoveryBeforeTimeout (recently blocked session stays below timeout)

Test plan

  • TestNewAppClockReturnsLiveTime — verifies New() clock returns advancing UTC time
  • TestBlockedDirtyWorktreeSessionSkipsAutoRecoveryBeforeTimeout — negative case: recently blocked session not prematurely recovered
  • TestScanOnceAutoRecoversStaleBlockedMaintenanceSession — existing e2e recovery path still passes
  • TestShouldAutoRecoverBlockedSession — existing blocked-session eligibility logic unchanged
  • TestBlockedSessionExceededInactivityTimeout* — all 3 existing inactivity activity-signal tests pass
  • Full test suite passes (go test ./...)

Closes #367

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
@nicobistolfi nicobistolfi merged commit 93d975a into main Apr 1, 2026
1 check passed
@nicobistolfi nicobistolfi deleted the vigilante/issue-367-fix-dirty-worktree-blocked-sessions-so-maintenance-auto-recovery-actually-triggers branch April 1, 2026 21:44
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.

Fix dirty-worktree blocked sessions so maintenance auto-recovery actually triggers

1 participant