Fix bug 94: Add TTL to claims so interrupted runs don't leave stale claims - #95
Open
joewalker wants to merge 1 commit into
Open
Fix bug 94: Add TTL to claims so interrupted runs don't leave stale claims#95joewalker wants to merge 1 commit into
joewalker wants to merge 1 commit into
Conversation
…laims This fixes the issue where an interrupted loop() run leaves a non-expiring claim, causing the prompt to be silently skipped forever on resume. Changes: - Add CLAIM_TTL_MS constant (1 hour) for claim expiration - Set expiresAt when creating new claims - Check for expired claims in claim() method and clean them up - Handle legacy claims without expiresAt that are owned by different runId This ensures that stale claims from interrupted runs will eventually expire and allow the prompt to be reprocessed on subsequent runs. Closes #94
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
This fixes bug #94 where an interrupted
loop()run leaves a non-expiring claim, causing the prompt to be silently skipped forever on resume.Root Cause
When
loop()is terminated ungracefully (Ctrl+C/SIGINT/SIGKILL) while a prompt is claimed but not yet completed:runIdfinallyblock doesn't execute, sorelease()never runsrunIdclaim()sees a claim with a differentrunIdand returnsfalse, causing the prompt to be skipped with "Skip (claimed elsewhere)"expiresAtfield existed but was never set or checked, so the stale claim persists indefinitelySolution
CLAIM_TTL_MSconstant (1 hour) for claim expiration - safely longer than any prompt's maximum runtimeexpiresAtwhen creating new claimsclaim()method and clean them up before checking ownershipexpiresAtthat are owned by a differentrunIdby treating them as staleChanges
src/loop-states/file.ts: Modified theclaim()method to check for expired claims and handle legacy claimsTesting
The fix ensures that:
claim()is calledexpiresAtthat are owned by a different run are treated as stale and removedCloses #94