Skip to content

feat: warn delegators when an orchestrator's reward cut is rising sharply#682

Open
rickstaa wants to merge 3 commits into
mainfrom
feat/bait-and-switch-warning
Open

feat: warn delegators when an orchestrator's reward cut is rising sharply#682
rickstaa wants to merge 3 commits into
mainfrom
feat/bait-and-switch-warning

Conversation

@rickstaa
Copy link
Copy Markdown
Member

@rickstaa rickstaa commented May 27, 2026

Summary

  • Adds 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.
  • Augments the existing cutChangeNotice in 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.
  • Shares the useTranscoderUpdateEventsQuery Apollo cache with useOrchestratorCutHistory, so the warning detection adds zero extra network requests.

Closes #681.

Visual

image

Test plan

  • pnpm typecheck passes.
  • Self-delegation: no banner.
  • showApproveFlow and 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):

  • 0xb5164d6b780786338c52f4787abba0e4a371af4d — appears to be a deliberate reward-cut increase rather than bait-and-switch. Filtering it out would require significantly more logic; accepting as a known false positive within the heuristic's coarse-grained design.

…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>
Copilot AI review requested due to automatic review settings May 27, 2026 17:33
@rickstaa rickstaa requested a review from ECWireless as a code owner May 27, 2026 17:33
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer-arbitrum-one Ready Ready Preview, Comment May 27, 2026 6:34pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 useOrchestratorRewardCutSpike plus a pure helper (findRecentRewardCutSpike) to detect recent reward-cut spikes from TranscoderUpdateEvent history.
  • 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_MILLION and 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.

Comment thread hooks/useOrchestratorRewardCutSpike.tsx
Comment thread hooks/useOrchestratorRewardCutSpike.tsx
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

📝 Walkthrough

Walkthrough

This 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.

Changes

Reward Cut Spike Warning

Layer / File(s) Summary
Spike detection algorithm and hook
hooks/useOrchestratorRewardCutSpike.tsx
Defines REWARD_CUT_SPIKE_PP (50pp), ROLLING_WINDOW_DAYS (7), WARNING_WINDOW_DAYS (180) constants and types CutEvent and RewardCutSpike. The findRecentRewardCutSpike function scans events newest-to-oldest to find the most recent up-only spike by comparing each candidate's reward cut against the rolling-window minimum. The hook useOrchestratorRewardCutSpike queries orchestrator update events and memoizes spike detection.
Cut history hook flexibility
hooks/useOrchestratorCutHistory.tsx
Input parameter type changes from Transcoder to OrchestratorRef to accept partial delegator fragments. New export type UseOrchestratorCutHistoryReturn documents the return shape. Percentage normalization updated to use shared PERCENTAGE_PRECISION_MILLION constant for subgraph events and activation anchors.
Delegation warning UI integration
components/DelegatingWidget/Delegate.tsx
New CutChangeNotice component replaces the static inlined banner, conditionally rendering a yellow warning with spike details (relative date, before/after percentages, icons) or a neutral info banner. The component is integrated into Delegate for non-transcoders.

Development Tooling Configuration

Layer / File(s) Summary
Playwright MCP tool ignores
.gitignore, .prettierignore, eslint.config.mjs
Adds .playwright-mcp/ directory to Git and Prettier ignore rules, and .playwright-mcp/** to ESLint global ignores to prevent tooling interference with development artifacts.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the primary change: a new warning feature for delegators when an orchestrator's reward cut increases sharply.
Linked Issues check ✅ Passed The PR successfully implements all core objectives from #681: reward-cut spike detection heuristic (≥50pp within 7-day rolling window over 180 days), yellow warning banner with dynamic copy, Apollo cache reuse, and no self-delegation warnings.
Out of Scope Changes check ✅ Passed All code changes are scoped to the linked objective: hook implementations, component refactoring, configuration updates (.gitignore, .prettierignore, eslint.config), and hook refactoring for flexibility. No unrelated changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request description is comprehensive and follows the template structure. It includes a clear summary of changes, visual evidence, a detailed test plan with manual verification on 14 orchestrators, and acknowledges known limitations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/bait-and-switch-warning

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9959381 and 787ba64.

📒 Files selected for processing (6)
  • .gitignore
  • .prettierignore
  • components/DelegatingWidget/Delegate.tsx
  • eslint.config.mjs
  • hooks/useOrchestratorCutHistory.tsx
  • hooks/useOrchestratorRewardCutSpike.tsx

Comment thread hooks/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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: warn delegators when an orchestrator's reward cut is rising sharply

2 participants