Spaces:
Sleeping
Sleeping
fixed grader
Browse files- tasks/hard.py +10 -6
- tasks/medium.py +5 -3
tasks/hard.py
CHANGED
|
@@ -411,15 +411,17 @@ class HardTaskGrader:
|
|
| 411 |
"""
|
| 412 |
Fraction of chains that were successfully stopped (any position).
|
| 413 |
|
| 414 |
-
Returns
|
| 415 |
"""
|
| 416 |
if not self._chains:
|
| 417 |
-
return
|
| 418 |
stopped = sum(
|
| 419 |
1 for c in self._chains.values()
|
| 420 |
if c.completed and not c.hit_failure
|
| 421 |
)
|
| 422 |
-
|
|
|
|
|
|
|
| 423 |
|
| 424 |
def calculate_stability_score(self) -> float:
|
| 425 |
"""Return the stability multiplier for the current failure count."""
|
|
@@ -568,11 +570,13 @@ class HardTaskGrader:
|
|
| 568 |
|
| 569 |
@staticmethod
|
| 570 |
def _stability_score(failures: int) -> float:
|
| 571 |
-
"""Step-function stability multiplier."""
|
| 572 |
for threshold, score in _STABILITY_BY_FAILURES:
|
| 573 |
if failures <= threshold:
|
| 574 |
-
|
| 575 |
-
|
|
|
|
|
|
|
| 576 |
|
| 577 |
|
| 578 |
# ---------------------------------------------------------------------------
|
|
|
|
| 411 |
"""
|
| 412 |
Fraction of chains that were successfully stopped (any position).
|
| 413 |
|
| 414 |
+
Returns 0.99 when no chains exist (nothing to detect).
|
| 415 |
"""
|
| 416 |
if not self._chains:
|
| 417 |
+
return 0.99
|
| 418 |
stopped = sum(
|
| 419 |
1 for c in self._chains.values()
|
| 420 |
if c.completed and not c.hit_failure
|
| 421 |
)
|
| 422 |
+
raw = stopped / len(self._chains)
|
| 423 |
+
# Clamp to (0, 1)
|
| 424 |
+
return max(0.01, min(raw, 0.99))
|
| 425 |
|
| 426 |
def calculate_stability_score(self) -> float:
|
| 427 |
"""Return the stability multiplier for the current failure count."""
|
|
|
|
| 570 |
|
| 571 |
@staticmethod
|
| 572 |
def _stability_score(failures: int) -> float:
|
| 573 |
+
"""Step-function stability multiplier clamped to (0, 1)."""
|
| 574 |
for threshold, score in _STABILITY_BY_FAILURES:
|
| 575 |
if failures <= threshold:
|
| 576 |
+
# Clamp stability scores to strict (0, 1)
|
| 577 |
+
return max(0.01, min(score, 0.99))
|
| 578 |
+
# Return floor clamped to (0, 1)
|
| 579 |
+
return max(0.01, min(_STABILITY_FLOOR, 0.99))
|
| 580 |
|
| 581 |
|
| 582 |
# ---------------------------------------------------------------------------
|
tasks/medium.py
CHANGED
|
@@ -236,14 +236,16 @@ class MediumTaskGrader:
|
|
| 236 |
Fraction of INVESTIGATE + ESCALATE actions that were productive.
|
| 237 |
|
| 238 |
Productive = action on an alert with true_severity ≥ 0.50.
|
| 239 |
-
Returns
|
| 240 |
"""
|
| 241 |
costly = [h for h in self._action_history
|
| 242 |
if h["action"] in ("INVESTIGATE", "ESCALATE")]
|
| 243 |
if not costly:
|
| 244 |
-
return
|
| 245 |
productive = sum(1 for h in costly if h["true_severity"] >= _MEDIUM_LOWER)
|
| 246 |
-
|
|
|
|
|
|
|
| 247 |
|
| 248 |
# ------------------------------------------------------------------
|
| 249 |
# Metrics
|
|
|
|
| 236 |
Fraction of INVESTIGATE + ESCALATE actions that were productive.
|
| 237 |
|
| 238 |
Productive = action on an alert with true_severity ≥ 0.50.
|
| 239 |
+
Returns 0.99 when no costly actions were taken (or 0.99 for perfect efficiency).
|
| 240 |
"""
|
| 241 |
costly = [h for h in self._action_history
|
| 242 |
if h["action"] in ("INVESTIGATE", "ESCALATE")]
|
| 243 |
if not costly:
|
| 244 |
+
return 0.99
|
| 245 |
productive = sum(1 for h in costly if h["true_severity"] >= _MEDIUM_LOWER)
|
| 246 |
+
raw = productive / len(costly)
|
| 247 |
+
# Clamp to (0, 1)
|
| 248 |
+
return max(0.01, min(raw, 0.99))
|
| 249 |
|
| 250 |
# ------------------------------------------------------------------
|
| 251 |
# Metrics
|