suraj-01 commited on
Commit
7ee6ca2
·
1 Parent(s): bc1af75

fixed grader

Browse files
Files changed (2) hide show
  1. tasks/hard.py +10 -6
  2. 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 1.0 when no chains exist (nothing to detect).
415
  """
416
  if not self._chains:
417
- return 1.0
418
  stopped = sum(
419
  1 for c in self._chains.values()
420
  if c.completed and not c.hit_failure
421
  )
422
- return stopped / len(self._chains)
 
 
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
- return score
575
- return _STABILITY_FLOOR
 
 
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 1.0 when no costly actions were taken (no waste, but also no work).
240
  """
241
  costly = [h for h in self._action_history
242
  if h["action"] in ("INVESTIGATE", "ESCALATE")]
243
  if not costly:
244
- return 1.0
245
  productive = sum(1 for h in costly if h["true_severity"] >= _MEDIUM_LOWER)
246
- return productive / len(costly)
 
 
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