feat: warn delegators when an orchestrator's reward cut is rising sharply#682
feat: warn delegators when an orchestrator's reward cut is rising sharply#682rickstaa wants to merge 3 commits into
Conversation
…rply Render the existing delegation widget banner as a yellow warning when an orchestrator's reward cut had any >=50 percentage point upward swing within any rolling 7-day window in the last 180 days. Surfaces sharp reward cut increases at the point of delegation so delegators can review the history before committing stake. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds a delegator-facing warning when an orchestrator’s reward cut has recently increased sharply (≥50 percentage points within any rolling 7-day window over the last 180 days), surfacing this risk directly in the delegation flow.
Changes:
- Introduces
useOrchestratorRewardCutSpikeplus a pure helper (findRecentRewardCutSpike) to detect recent reward-cut spikes fromTranscoderUpdateEventhistory. - Updates the Delegation widget notice to render a yellow warning with relative timing and from/to cut percentages when a spike is detected (neutral info banner otherwise).
- Aligns cut-history calculations to use
PERCENTAGE_PRECISION_MILLIONand expands ignores for local tooling dirs (.playwright-mcp,.vscode) in eslint/prettier/git.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| hooks/useOrchestratorRewardCutSpike.tsx | Adds spike-detection heuristic and hook backed by useTranscoderUpdateEventsQuery. |
| hooks/useOrchestratorCutHistory.tsx | Refactors input typing and replaces hardcoded 1_000_000 with PERCENTAGE_PRECISION_MILLION. |
| components/DelegatingWidget/Delegate.tsx | Replaces the static cut notice with a spike-aware warning banner. |
| eslint.config.mjs | Ignores .playwright-mcp/** and .vscode/** in ESLint. |
| .prettierignore | Ignores .playwright-mcp. |
| .gitignore | Ignores .playwright-mcp/. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📝 WalkthroughWalkthroughThis PR adds spike detection for orchestrator reward-cut changes. When a reward cut rises ≥50 percentage points within a rolling 7-day window in the last 180 days, a yellow warning replaces the neutral delegation banner. The implementation refactors the cut history hook for flexibility, introduces spike detection logic, and integrates it into the UI. Development tooling ignores are also added. ChangesReward Cut Spike Warning
Development Tooling Configuration
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@hooks/useOrchestratorRewardCutSpike.tsx`:
- Around line 88-94: The query in useTranscoderUpdateEventsQuery is fetching the
oldest 1000 updates because it sets first: 1000 and orderDirection:
OrderDirection.Asc, which can omit the last 180 days; change the pagination to
fetch newest-first by setting orderDirection to OrderDirection.Desc (keep
orderBy: TranscoderUpdateEvent_OrderBy.Timestamp and first as needed) and/or add
a server-side time filter to the variables.where (e.g., include a timestamp
cutoff condition) so findRecentRewardCutSpike always receives events from the
most recent 180-day window.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3f5f448b-6ddc-4ee5-b16f-fba6721d4cec
📒 Files selected for processing (6)
.gitignore.prettierignorecomponents/DelegatingWidget/Delegate.tsxeslint.config.mjshooks/useOrchestratorCutHistory.tsxhooks/useOrchestratorRewardCutSpike.tsx
For orchestrators with >1000 lifetime update events, Asc + first:1000 dropped the recent 180-day window entirely. Flip both queries to Desc so the recent slice is always present; chart hook sorts ascending in its mapping step to preserve display order. Co-Authored-By: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Covers threshold, window cutoff, up-only direction, and most-recent-spike selection. Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
useOrchestratorRewardCutSpike— pure heuristic plus React hook that flags an orchestrator when their reward cut had any ≥50pp upward swing within any rolling 7-day window in the last 180 days.cutChangeNoticein the delegation widget so it renders as a yellow warning with dynamic copy (X ago, A% → B%) when the heuristic fires. Falls back to the existing neutral info banner otherwise.useTranscoderUpdateEventsQueryApollo cache withuseOrchestratorCutHistory, so the warning detection adds zero extra network requests.Closes #681.
Visual
Test plan
pnpm typecheckpasses.showApproveFlowand final-delegate branches both render the notice in the same position.Manual verification (14 orchestrators)
Verified on the preview deployment for this PR.
Correctly flagged (9):
Correctly not flagged (3):
Edge cases (1):