fix: restore stage-based Alpha check classification

This commit is contained in:
yuxuanhui
2026-09-12 22:34:14 +08:00
parent 45eb4c3a17
commit c18960946b
13 changed files with 253 additions and 25 deletions
+11 -9
View File
@@ -7,7 +7,7 @@ from datetime import datetime
from sqlalchemy import or_, select, update
from .models import Alpha, Research, ResearchTag, SelfCorrelation, now
from .platform_checks import split_checks, submission_limits
from .platform_checks import check_result, split_checks, submission_limits
from .research.provenance import source_alpha_ids
METRIC_FIELDS = (
@@ -20,16 +20,17 @@ def failed_checks(checks):
"""Return failed Alpha check names, excluding submission limits and local correlation."""
return [
check.get("name") if isinstance(check.get("name"), str) else "未命名检查"
for check in split_checks(checks)[0] if isinstance(check, dict) and check.get("result") == "FAIL"
for check in split_checks(checks)[0] if isinstance(check, dict) and check_result(check) == "FAIL"
] if isinstance(checks, list) else []
def snapshot_columns(settings, metrics, checks):
def snapshot_columns(settings, metrics, checks, *, checked=False):
"""Derive list fields from a platform snapshot, preserving missing metrics as null.
Submission limits are excluded. Only explicit Alpha FAIL results count.
Empty, malformed and unfinished Alpha checks are
pending; all known checks passing without PROD_CORRELATION is only a pre-check.
Sync snapshots with no failures are PRE_CHECK; a completed explicit /check
with no failures is PASS. WARNING/PENDING do not count as failures, matching
the legacy workflow. Empty, malformed or unknown results remain PENDING.
No submission eligibility or activity eligibility is inferred here.
"""
settings = settings if isinstance(settings, dict) else {}
@@ -40,10 +41,10 @@ def snapshot_columns(settings, metrics, checks):
by_name = {check["name"]: check for check in valid if isinstance(check.get("name"), str)}
if failures:
check_type = "FAIL_1" if failures == 1 else "FAIL_2"
elif not checks or len(valid) != len(checks) or any(check.get("result") != "PASS" for check in valid):
elif not checks or len(valid) != len(checks) or any(check_result(check) not in ("PASS", "WARNING", "PENDING") for check in valid):
check_type = "PENDING"
else:
check_type = "PASS" if "PROD_CORRELATION" in by_name else "PRE_CHECK"
check_type = "PASS" if checked else "PRE_CHECK"
# /check values are freshest; submitted snapshots also expose a scalar in IS.
prod_correlation = number(by_name.get("PROD_CORRELATION", {}).get("value"))
if prod_correlation is None:
@@ -66,12 +67,13 @@ def snapshot_columns(settings, metrics, checks):
}
def check_summary(checks):
def check_summary(checks, *, check_type):
"""Separate cached Alpha findings from submission limits; infer no live eligibility."""
return {
"check_type": snapshot_columns({}, {}, checks)["check_type"],
"check_type": check_type,
"failed_checks": failed_checks(checks),
"submission_limits": submission_limits(checks),
"meaning": "PRE_CHECK 为同步无失败项;PASS 为主动检查完成且无失败项。PENDING/WARNING 不算失败,不代表全部检查项 PASS 或当前可提交",
}