code-to10 v6 A12: scorecard example renamed to 2026-10-31 snapshot with timeliness fields
(cherry picked from commit 633cdbc94e7a7b0c5d3b0b135189faf3de6673f4) Reconcile-port: handler_admin.py hunks redirected into cloud/server.py _audit_scorecard (target keeps 6-mixin split; scorecard module itself applied cleanly).
This commit is contained in:
1 parent
e131e8658d
commit
e32391fd85
4 files changed
+39
-19
No files matched your search
@@ -467,13 +467,16 @@ def build_scorecard(evidence, thresholds=None):
|
||||
}
|
||||
|
||||
|
||||
def example_scorecard_current_state():
|
||||
"""用当前真实状态证据跑出来的系统评分卡(不是上一轮判断分)。
|
||||
def example_scorecard_as_of_2026_10_31():
|
||||
"""2026-10-31 快照示例卡(历史示例,不是当前系统得分)。
|
||||
|
||||
证据口径:生产仍跑 v0.2、main 仍 aebc623、CI 账单模式、
|
||||
#238/#240/#244/#241/#247/#249/#253/#255/#256/#258/#259/#260/#261
|
||||
全部只到 PR OPEN。凡是只到 PR、未合并部署、未真实验证的,
|
||||
在这里都记为未知或已知未强制,不估算、不写成判断分。
|
||||
证据是本函数 2026-10-31 落笔时记录的快照值(生产 v0.2、
|
||||
main aebc623、覆盖率 0.7787 等),此后未重新实测;调用方
|
||||
绝不能把它读成当前系统得分。要当前分数,须显式把新证据
|
||||
传给 build_scorecard()。凡是只到 PR、未合并部署、未真实
|
||||
验证的,在这里都记为未知或已知未强制,不估算、不写成
|
||||
判断分。阈值仍为测试默认值
|
||||
(source="test_default_unapproved"),未拍板。
|
||||
总体结论必然是不达标。
|
||||
"""
|
||||
evidence = {
|
||||
@@ -513,4 +516,8 @@ def example_scorecard_current_state():
|
||||
"parallel_scale_proven": 18,
|
||||
},
|
||||
}
|
||||
return build_scorecard(evidence)
|
||||
report = build_scorecard(evidence)
|
||||
report["evidence_as_of"] = "2026-10-31"
|
||||
report["evidence_kind"] = "historical_example_snapshot"
|
||||
report["not_current_system_score"] = True
|
||||
return report
|
||||
+13
-7
@@ -8583,17 +8583,20 @@ pid 须为整数、address 须为字符串,否则 400(注册表里的
|
||||
|
||||
权限:与 /metrics 同款,任意项目成员即可读(不要求 owner),
|
||||
但本端点不统计任何项目数据、不写库、不写账本、不改链头、
|
||||
不触发推回或重审——它只是把评分卡模块的当前状态报出来。
|
||||
主基底(main)上没有存放结构化评分证据的表(metrics-report、
|
||||
台账、账本、门禁模块都在未合并的 PR 分支上),所以本端点
|
||||
在主基底上返回的只能是“全部未知/已知未强制”的诚实状态,
|
||||
总体必然是不达标;调用方要拿到真实分数,必须显式把结构化
|
||||
不触发推回或重审——它只返回评分卡模块的一张历史示例卡。
|
||||
该示例卡的证据是 2026-10-31 的快照(见
|
||||
``example_scorecard_as_of_2026_10_31``),此后未重新
|
||||
实测,响应里以 ``evidence_as_of`` /
|
||||
``not_current_system_score`` 明示;调用方绝不能把它读
|
||||
成当前系统得分。调用方要拿到真实分数,必须显式把结构化
|
||||
证据传给 cloud/audit_scorecard.py 的 build_scorecard(),
|
||||
端点本身绝不从测试文件、摘要文档、PR 描述里拼凑分数。
|
||||
阈值仍为测试默认值(``test_default_unapproved``),未拍板。
|
||||
"""
|
||||
try:
|
||||
from cloud.audit_scorecard import example_scorecard_current_state
|
||||
report = example_scorecard_current_state()
|
||||
from cloud.audit_scorecard import (
|
||||
example_scorecard_as_of_2026_10_31)
|
||||
report = example_scorecard_as_of_2026_10_31()
|
||||
except ImportError: # pragma: no cover - 导入失败时仍要诚实返回
|
||||
report = {
|
||||
"dimensions": [], "average_score": None,
|
||||
@@ -8602,6 +8605,9 @@ pid 须为整数、address 须为字符串,否则 400(注册表里的
|
||||
"missing_items": ["audit_scorecard_module_unavailable"],
|
||||
"untested_items": [],
|
||||
"thresholds_source": "test_default_unapproved",
|
||||
"evidence_as_of": "2026-10-31",
|
||||
"evidence_kind": "historical_example_snapshot",
|
||||
"not_current_system_score": True,
|
||||
}
|
||||
self._send_json(200, report)
|
||||
|
||||
|
||||
@@ -22,13 +22,13 @@ from pathlib import Path
|
||||
|
||||
try:
|
||||
from cloud.audit_scorecard import (
|
||||
DEFAULT_THRESHOLDS, build_scorecard, example_scorecard_current_state)
|
||||
DEFAULT_THRESHOLDS, build_scorecard, example_scorecard_as_of_2026_10_31)
|
||||
from cloud.auth import AuthStore
|
||||
from cloud.server import create_server
|
||||
except ImportError:
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2]))
|
||||
from cloud.audit_scorecard import (
|
||||
DEFAULT_THRESHOLDS, build_scorecard, example_scorecard_current_state)
|
||||
DEFAULT_THRESHOLDS, build_scorecard, example_scorecard_as_of_2026_10_31)
|
||||
from cloud.auth import AuthStore
|
||||
from cloud.server import create_server
|
||||
|
||||
@@ -161,9 +161,16 @@ class ScorecardTestCase(unittest.TestCase):
|
||||
|
||||
def test_example_current_state_is_not_pass_and_not_estimated(self):
|
||||
# 示例是系统用当前真实状态证据算出来的,不是上一轮判断分。
|
||||
report = example_scorecard_current_state()
|
||||
report = example_scorecard_as_of_2026_10_31()
|
||||
self.assertEqual(report["overall"], "not_pass")
|
||||
self.assertFalse(report["overall_pass"])
|
||||
# 时效标注:示例卡是 2026-10-31 快照,不是当前系统得分。
|
||||
self.assertEqual(report["evidence_as_of"], "2026-10-31")
|
||||
self.assertEqual(report["evidence_kind"],
|
||||
"historical_example_snapshot")
|
||||
self.assertTrue(report["not_current_system_score"])
|
||||
self.assertEqual(report["thresholds_source"],
|
||||
"test_default_unapproved")
|
||||
# 至少有一维是未知(None),且总体不达标不靠平均分。
|
||||
self.assertTrue(any(d["score"] is None
|
||||
for d in report["dimensions"]))
|
||||
|
||||
@@ -14,7 +14,7 @@ import unittest
|
||||
from cloud.audit_scorecard import (
|
||||
DEFAULT_THRESHOLDS,
|
||||
build_scorecard,
|
||||
example_scorecard_current_state,
|
||||
example_scorecard_as_of_2026_10_31,
|
||||
_result,
|
||||
_round1,
|
||||
_score_higher,
|
||||
@@ -398,7 +398,7 @@ class OverallTestCase(unittest.TestCase):
|
||||
self.assertEqual(card["thresholds_source"], "user_approved")
|
||||
|
||||
def test_example_current_state_is_not_pass(self):
|
||||
card = example_scorecard_current_state()
|
||||
card = example_scorecard_as_of_2026_10_31()
|
||||
self.assertEqual(card["overall"], "not_pass")
|
||||
self.assertTrue(card["missing_items"] or card["untested_items"])
|
||||
|
||||
|
||||
Reference in new issue
Block a user