feat: Add overdue milestone escalation with 14-day grace period#11
feat: Add overdue milestone escalation with 14-day grace period#110xdevcollins merged 2 commits intomainfrom
Conversation
flag_overdue_milestone() only emitted an event with no on-chain consequence. Now it records flagged_at timestamp on the milestone, and a new permissionless escalate_overdue_milestone() rejects the milestone and cancels the campaign for refunds if the creator doesn't submit within 14 days of being flagged. Closes #4 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Disabled knowledge base sources:
📝 WalkthroughWalkthroughThis PR adds enforcement for overdue milestones: milestones gain a Changes
Sequence DiagramsequenceDiagram
participant Creator
participant Campaign as "Campaign Contract"
participant Storage as "Milestone Storage"
participant System as "Escalation Caller"
participant Refund as "Refund Mechanism"
Creator->>Campaign: set_milestones()
Campaign->>Storage: initialize milestone(flagged_at = 0)
Note over Campaign,Storage: milestone deadline passed
Creator->>Campaign: flag_overdue_milestone()
Campaign->>Storage: set flagged_at = now
Campaign->>Campaign: emit MilestoneOverdue
Note over Campaign,Storage: 14-day grace period
alt Creator resubmits within grace
Creator->>Campaign: submit_milestone()
Campaign->>Storage: update milestone status (not Pending)
else Grace period expires
System->>Campaign: escalate_overdue_milestone(campaign_id, milestone_index)
Campaign->>Storage: ensure flagged_at != 0 and now >= flagged_at + 14d
Campaign->>Storage: set milestone.status = Rejected
Campaign->>Campaign: set campaign.status = Cancelled, refund_progress = 0
Campaign->>Campaign: persist changes
Campaign->>Campaign: emit MilestoneEscalated
Campaign->>Refund: trigger refunds
Refund->>Storage: process donor refunds
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
…d registry contract
Summary
flag_overdue_milestone()now recordsflagged_attimestamp on the milestone (previously only emitted an event with no state change)escalate_overdue_milestone()— if 14 days pass after flagging with no submission, rejects the milestone and cancels the campaign for refundsflagged_at: u64field toMilestonestruct (0 = not flagged)MilestoneEscalatedevent for indexer integrationMilestoneNotFlagged(828) andGracePeriodNotExpired(829) error variantsCloses #4
Test plan
test_overdue_flag_and_escalate— full flow: flag → grace period too early (fails) → grace period expires → escalate → milestone rejected, campaign cancelled, refunds worktest_overdue_escalate_not_flagged_fails— escalating without flagging first returnsMilestoneNotFlaggedtest_overdue_creator_submits_during_grace_period— creator submits milestone during grace period → escalation fails (milestone no longer Pending), campaign stays active🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Events
Tests