test(task): strengthen validation status semantics
This commit is contained in:
@ -8,6 +8,7 @@ from typing import Any, Literal
|
||||
|
||||
ValidationStatus = Literal["accepted", "rejected", "insufficient_evidence", "validator_error"]
|
||||
|
||||
VALIDATION_STATUSES = {"accepted", "rejected", "insufficient_evidence", "validator_error"}
|
||||
TASK_OPEN_STATUSES = {"open", "running", "validating", "awaiting_feedback", "needs_review", "needs_revision"}
|
||||
|
||||
|
||||
@ -33,6 +34,8 @@ class ValidationResult:
|
||||
recommended_revision_prompt: str = "",
|
||||
validator: str = "heuristic",
|
||||
) -> None:
|
||||
if status is not None and status not in VALIDATION_STATUSES:
|
||||
raise ValueError(f"unknown validation status: {status}")
|
||||
self.status = status or ("accepted" if passed and score >= 0.75 else "rejected")
|
||||
self.score = max(0.0, min(1.0, float(score or 0.0)))
|
||||
self.issues = list(issues or [])
|
||||
@ -67,11 +70,7 @@ class ValidationResult:
|
||||
if not isinstance(payload, dict):
|
||||
return None
|
||||
raw_status = payload.get("status")
|
||||
status: ValidationStatus | None = (
|
||||
raw_status
|
||||
if raw_status in {"accepted", "rejected", "insufficient_evidence", "validator_error"}
|
||||
else None
|
||||
)
|
||||
status: ValidationStatus | None = raw_status if raw_status in VALIDATION_STATUSES else None
|
||||
return cls(
|
||||
status=status,
|
||||
passed=bool(payload.get("passed")) if status is None else None,
|
||||
|
||||
Reference in New Issue
Block a user