fix(history): make Phase 4 finalization interrupt-safe (#137)#139
Merged
Conversation
discoverClub's onInterrupt guard covered only Phases 2-3; Phase 4 (HistoryRun.complete + logSummary) ran outside it. An interrupt landing in that window ran neither finalizer — the wave block's onInterrupt had already deregistered — leaving history_run stranded in its non-terminal Phase-1 state. Widen the guard to span Phases 2-4 and gate the onInterrupt finalizer on a finalizedRef. The success-path finalize (complete + logSummary + flag) commits atomically (uninterruptible) and flips the flag, so a late interrupt skips the partial-stats finalize; an interrupt anywhere earlier finds the flag false and completes the run with partial stats. Exactly one finalize on every exit, and the run always reaches a terminal state. Closes #137 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
HistoryApp.discoverClub'sonInterruptguard covered only Phases 2–3; Phase 4 (HistoryRun.complete+logSummary) ran outside it. ZIO's.onInterruptderegisters once the wave block completes, so an interrupt landing in the Phase-4 window ran neither finalizer, leavinghistory_runstranded in its non-terminal Phase-1 state.Fix
onInterruptfinalizer on a newfinalizedRef.complete+logSummary+finalizedRef.set(true)) commit atomically (.uninterruptible).Result — exactly one finalize on every exit, run always terminal:
finalizeInterrupted.Fixes
Closes #137 (surfaced during review of #138).
Testing
sbt testgreen via pre-push (960 passed).testOnlyhistory +TestJobRunner+ stats + membership (143) — green, incl.TestHistoryAppNetworkOutageabort path.🤖 Generated with Claude Code