Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Jun 26, 2026
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.
Related GitHub Issue
Closes: #366 (part of #357 — Epic 2: Task Lifecycle Fixes)
Description
Implements Story 2.3: a status transition guard and startup reconciliation loop to prevent and recover from
HistoryItemstatus corruption.Transition guard (
assertValidTransition)Adds an
assertValidTransition(from, to)function that enforces the valid state machine:active → delegated | completeddelegated → activecompleted → [](terminal)Called at all five
updateTaskHistorysites inClineProviderthat changestatus(removeClineFromStack,cancelTask,delegateParentAndOpenChild,reopenParentFromDelegation×2). Throws on invalid transitions so corrupt writes are surfaced immediately rather than silently persisted.Startup reconciliation (
reconcileDelegationState)Called from
TaskHistoryStore.initialize()afterreconcile(). Repairs three crash-induced inconsistencies:delegatedwith noawaitingChildId→activedelegated, child not found (orphaned) →activedelegated, child alreadycompleted(interrupted handoff) →active, copying the child'scompletionResultSummaryImplementation details:
withLockvia a newupsertCoreprivate helper (avoids re-entrant deadlock)do { } while (repairsInThisPass > 0)) so chained delegations (A→B→C) are resolved in one startupMapawaitingChildIdanddelegatedToIdTest Procedure
All 64 tests across the four affected suites pass. New
TaskHistoryStore.reconciliation.spec.tsadds 18 tests covering the transition guard (valid/invalid transitions including self-loops) and all reconciliation scenarios (orphaned delegation, interrupted handoff, fallback summary, active-child left alone, multiple parents, chained delegation, idempotency, logging).Pre-Submission Checklist