-
Notifications
You must be signed in to change notification settings - Fork 1
feat(anomaly): model preview roc curve #97
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
0xAlcibiades
wants to merge
6
commits into
master
Choose a base branch
from
alcibiades/eng-4077-featanomaly-platform-ux-and-integration
base: master
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 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fd4707b
feat(anomaly): model preview roc curve
0xAlcibiades dae17a8
fix(anomaly): remove score bps
0xAlcibiades 0ff5731
fix(anomaly): address feedback
0xAlcibiades 91a2073
feat(anomaly): add an ungated assertion that blocks every firing
0xAlcibiades ecc1958
fix(anomaly): vacuous test of vacuous assertion
0xAlcibiades 1023b9d
fix(anomaly): remove trailing boolean
0xAlcibiades 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
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,54 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.13; | ||
|
|
||
| /// @title Sensitivity | ||
| /// @notice How aggressively an anomaly trigger fires, as a level rather than a threshold. | ||
| /// @dev Each level is a point on the detector's recall-versus-false-positive curve, fixed to a | ||
| /// false-positive budget that is the same on every contract: | ||
| /// | ||
| /// | Level | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | | ||
| /// | ----- | ----- | ----- | ----- | ---- | ---- | ---- | -- | -- | -- | --- | | ||
| /// | Fires on | 0.01% | 0.02% | 0.05% | 0.1% | 0.2% | 0.5% | 1% | 2% | 5% | 10% | | ||
| /// | ||
| /// Higher is more sensitive: it catches more, and fires on more benign traffic. The | ||
| /// *threshold* behind a level is resolved per contract, from that contract's own history, | ||
| /// where the trigger is evaluated. One level therefore means one budget everywhere, and a | ||
| /// retrain moves the threshold without touching this code. | ||
| /// | ||
| /// An assertion never names a basis-point score for that reason. A threshold belongs to one | ||
| /// contract and one model version; copy it to a second contract, or keep it across a retrain, | ||
| /// and the trigger mis-configures in the direction that hurts. It stops firing while still | ||
| /// looking healthy. | ||
| /// | ||
| /// Firing is not blocking. A trigger that fires runs the assertion, and the assertion decides. | ||
| /// Pair an anomaly trigger with a damage check and only what is both unusual *and* doing | ||
| /// damage gets blocked. See `src/protection/anomaly`. | ||
| library Sensitivity { | ||
| /// @notice Fires on 0.01% of this contract's transactions. Catches the least. | ||
| uint8 internal constant LEVEL_1 = 1; | ||
| uint8 internal constant LEVEL_2 = 2; | ||
| uint8 internal constant LEVEL_3 = 3; | ||
| uint8 internal constant LEVEL_4 = 4; | ||
| uint8 internal constant LEVEL_5 = 5; | ||
| uint8 internal constant LEVEL_6 = 6; | ||
| /// @notice Fires on 1% of this contract's transactions. The recommended operating point. | ||
| uint8 internal constant LEVEL_7 = 7; | ||
| uint8 internal constant LEVEL_8 = 8; | ||
| uint8 internal constant LEVEL_9 = 9; | ||
| /// @notice Fires on 10% of this contract's transactions. Catches the most. | ||
| uint8 internal constant LEVEL_10 = 10; | ||
|
|
||
| /// @notice The recommended level for a protocol without a reason to choose otherwise. | ||
| uint8 internal constant RECOMMENDED = LEVEL_7; | ||
|
|
||
| /// @notice The strictest level, and the loosest — the bounds a valid level lies within. | ||
| uint8 internal constant MIN = LEVEL_1; | ||
| uint8 internal constant MAX = LEVEL_10; | ||
|
|
||
| /// @notice Whether `level` names a rung of the ladder. | ||
| /// @dev `0` is not a level: it is the "cleared nothing" sentinel an unscored target reads | ||
| /// back in `PhEvm.AnomalyContext.firesAt`. | ||
| function isValid(uint8 level) internal pure returns (bool) { | ||
| return level >= MIN && level <= MAX; | ||
| } | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.