Spaces:
Sleeping
Sleeping
Daksh Verma commited on
Keep public task scores inside strict validator bounds
Browse files
unified_incident_env/server/grader.py
CHANGED
|
@@ -6,6 +6,9 @@ from typing import Any
|
|
| 6 |
|
| 7 |
from ..models import GraderCheck, GraderReport, PostmortemPayload
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def _contains_all(text: str, phrases: list[str]) -> bool:
|
| 11 |
lowered = text.lower()
|
|
@@ -17,6 +20,10 @@ def _contains_any(text: str, phrases: list[str]) -> bool:
|
|
| 17 |
return any(phrase.lower() in lowered for phrase in phrases)
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
class DeterministicPostmortemScorer:
|
| 21 |
"""Deterministic postmortem scorer with the final rubric."""
|
| 22 |
|
|
@@ -110,6 +117,7 @@ class UnifiedIncidentGrader:
|
|
| 110 |
)
|
| 111 |
if state.get("security_subquest_status") != "completed":
|
| 112 |
final_score = min(final_score, 0.5)
|
|
|
|
| 113 |
|
| 114 |
return {
|
| 115 |
"infrastructure_score": round(infrastructure_score, 4),
|
|
|
|
| 6 |
|
| 7 |
from ..models import GraderCheck, GraderReport, PostmortemPayload
|
| 8 |
|
| 9 |
+
MIN_PUBLIC_SCORE = 0.01
|
| 10 |
+
MAX_PUBLIC_SCORE = 0.99
|
| 11 |
+
|
| 12 |
|
| 13 |
def _contains_all(text: str, phrases: list[str]) -> bool:
|
| 14 |
lowered = text.lower()
|
|
|
|
| 20 |
return any(phrase.lower() in lowered for phrase in phrases)
|
| 21 |
|
| 22 |
|
| 23 |
+
def _strict_public_score(score: float) -> float:
|
| 24 |
+
return round(min(MAX_PUBLIC_SCORE, max(MIN_PUBLIC_SCORE, score)), 4)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
class DeterministicPostmortemScorer:
|
| 28 |
"""Deterministic postmortem scorer with the final rubric."""
|
| 29 |
|
|
|
|
| 117 |
)
|
| 118 |
if state.get("security_subquest_status") != "completed":
|
| 119 |
final_score = min(final_score, 0.5)
|
| 120 |
+
final_score = _strict_public_score(final_score)
|
| 121 |
|
| 122 |
return {
|
| 123 |
"infrastructure_score": round(infrastructure_score, 4),
|