-
Notifications
You must be signed in to change notification settings - Fork 20
feat: warn delegators when an orchestrator's reward cut is rising sharply #682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rickstaa
wants to merge
4
commits into
main
Choose a base branch
from
feat/bait-and-switch-warning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
787ba64
feat: warn delegators when an orchestrator's reward cut is rising sha…
rickstaa 00eb77d
fix: fetch newest events first in transcoder update queries
rickstaa deb58a2
test: add unit tests for findRecentRewardCutSpike
rickstaa 8db9ead
tune: raise reward cut spike threshold to 0.8
rickstaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ next-env.d.ts | |
| .code-workspace | ||
| .claude/ | ||
| .pnpm-store/ | ||
| .playwright-mcp/ | ||
|
|
||
| # debug | ||
| npm-debug.log* | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ node_modules | |
| .pnpm-store | ||
| .github | ||
| .vscode | ||
| .playwright-mcp | ||
| @types | ||
| apollo | ||
| codegen.yml | ||
|
|
||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import { | ||
| type CutEvent, | ||
| findRecentRewardCutSpike, | ||
| } from "./useOrchestratorRewardCutSpike"; | ||
|
|
||
| const NOW_MS = Date.UTC(2026, 0, 1); | ||
| const NOW_SEC = Math.floor(NOW_MS / 1000); | ||
| const SEC_PER_DAY = 86_400; | ||
| const MS_PER_DAY = 86_400_000; | ||
|
|
||
| const event = (daysAgo: number, rewardCutPct: number): CutEvent => ({ | ||
| timestamp: NOW_SEC - daysAgo * SEC_PER_DAY, | ||
| rewardCut: String(Math.round(rewardCutPct * 10_000)), | ||
| }); | ||
|
|
||
| const opts = { now: NOW_MS }; | ||
|
|
||
| describe("findRecentRewardCutSpike", () => { | ||
| it("returns null for empty input", () => { | ||
| expect(findRecentRewardCutSpike([], opts)).toBeNull(); | ||
| }); | ||
|
|
||
| it("returns null for a single event", () => { | ||
| expect(findRecentRewardCutSpike([event(10, 50)], opts)).toBeNull(); | ||
| }); | ||
|
|
||
| it("fires on a single-event 50pp jump", () => { | ||
| const spike = findRecentRewardCutSpike([event(10, 0), event(5, 50)], opts); | ||
| expect(spike?.fromRewardCut).toBe(0); | ||
| expect(spike?.toRewardCut).toBe(0.5); | ||
| }); | ||
|
|
||
| it("fires on a 4x25pp climb spread over 6 days", () => { | ||
| const spike = findRecentRewardCutSpike( | ||
| [event(10, 0), event(9, 25), event(8, 50), event(7, 75), event(5, 100)], | ||
| opts | ||
| ); | ||
| expect(spike?.fromRewardCut).toBe(0); | ||
| expect(spike?.toRewardCut).toBe(1); | ||
| }); | ||
|
|
||
| it("fires on a dip-then-spike within 7 days", () => { | ||
| const spike = findRecentRewardCutSpike( | ||
| [event(30, 100), event(5, 0), event(2, 100)], | ||
| opts | ||
| ); | ||
| expect(spike?.fromRewardCut).toBe(0); | ||
| expect(spike?.toRewardCut).toBe(1); | ||
| }); | ||
|
|
||
| it("fires at exactly the 50pp threshold", () => { | ||
| expect( | ||
| findRecentRewardCutSpike([event(10, 25), event(5, 75)], opts) | ||
| ).not.toBeNull(); | ||
| }); | ||
|
|
||
| it("does not fire below the 50pp threshold", () => { | ||
| expect( | ||
| findRecentRewardCutSpike([event(10, 0), event(5, 49)], opts) | ||
| ).toBeNull(); | ||
| }); | ||
|
|
||
| it("does not fire on downward-only changes", () => { | ||
| expect( | ||
| findRecentRewardCutSpike([event(10, 100), event(5, 50)], opts) | ||
| ).toBeNull(); | ||
| }); | ||
|
|
||
| it("does not fire on spikes outside the 180-day cutoff", () => { | ||
| expect( | ||
| findRecentRewardCutSpike([event(200, 0), event(190, 100)], opts) | ||
| ).toBeNull(); | ||
| }); | ||
|
|
||
| it("returns the most recent qualifying spike", () => { | ||
| const spike = findRecentRewardCutSpike( | ||
| [event(150, 0), event(145, 100), event(50, 0), event(45, 100)], | ||
| opts | ||
| ); | ||
| expect(spike?.endTimestamp).toBe(NOW_MS - 45 * MS_PER_DAY); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Threshold assertions are stale (50pp) and now fail CI against the 80pp rule
REWARD_CUT_SPIKE_PP = 0.8(80pp).REWARD_CUT_SPIKE_PPso future threshold tuning doesn’t break tests again).Proposed patch
import { type CutEvent, findRecentRewardCutSpike, + REWARD_CUT_SPIKE_PP, } from "./useOrchestratorRewardCutSpike"; @@ - it("fires on a single-event 50pp jump", () => { - const spike = findRecentRewardCutSpike([event(10, 0), event(5, 50)], opts); + it("fires on a single-event 80pp jump", () => { + const spike = findRecentRewardCutSpike([event(10, 0), event(5, 80)], opts); expect(spike?.fromRewardCut).toBe(0); - expect(spike?.toRewardCut).toBe(0.5); + expect(spike?.toRewardCut).toBe(0.8); }); @@ - it("fires at exactly the 50pp threshold", () => { + it("fires at exactly the configured threshold", () => { expect( - findRecentRewardCutSpike([event(10, 25), event(5, 75)], opts) + findRecentRewardCutSpike( + [event(10, 0), event(5, REWARD_CUT_SPIKE_PP * 100)], + opts + ) ).not.toBeNull(); }); @@ - it("does not fire below the 50pp threshold", () => { + it("does not fire below the configured threshold", () => { expect( - findRecentRewardCutSpike([event(10, 0), event(5, 49)], opts) + findRecentRewardCutSpike( + [event(10, 0), event(5, REWARD_CUT_SPIKE_PP * 100 - 1)], + opts + ) ).toBeNull(); });🧰 Tools
🪛 GitHub Actions: CI / 0_lint-and-test.txt
[error] 29-29: Jest assertion failed in test 'findRecentRewardCutSpike › fires on a single-event 50pp jump'. Expected spike?.fromRewardCut to be 0, but received undefined.
[error] 54-54: Jest assertion failed in test 'findRecentRewardCutSpike › fires at exactly the 50pp threshold'. Expected result not to be null, but received null.
🪛 GitHub Actions: CI / lint-and-test
[error] 29-29: Jest test failed in 'findRecentRewardCutSpike › fires on a single-event 50pp jump'. Expected spike?.fromRewardCut to be 0, received undefined.
[error] 54-54: Jest test failed in 'findRecentRewardCutSpike › fires at exactly the 50pp threshold'. Expected result not to be null, but received null.
🤖 Prompt for AI Agents