Files
fengqun/tests/test_acceptance_scoring.py
T
gongzhiyongandOmX a4d771ede5 Define numeric swarm acceptance gates
Add a concrete 0-100 swarmness/compliance score, local large-scale stress, and 3000 TPM budget acceptance so the repo can say when it is a swarm by measured criteria instead of prose alone.

Constraint: user required Chinese docs, explicit scenarios, parameters, formulas, pass/fail lines, and git upload.

Rejected: prose-only PASS reports | they did not answer whether the system is a swarm with a concrete score.

Confidence: high

Scope-risk: moderate

Directive: keep production runtime claims separate from local minimal swarm acceptance scores.

Tested: py_compile swarm_minimal examples tests; unittest discover -s tests 45 tests; run_swarm_compliance_score.py; run_tpm_budget_acceptance.py; run_academic_standard_evaluation.py; git diff --check; docs/script secret-pattern scan.

Not-tested: live S07 and production Kubernetes/NewAPI provider-rate-limit stress were not rerun in this upload step.

Co-authored-by: OmX <omx@oh-my-codex.dev>
2026-05-17 18:19:24 +08:00

42 lines
1.4 KiB
Python

import unittest
from swarm_minimal.acceptance_scoring import ScoreItem, current_minimal_swarm_score, score_items
class AcceptanceScoringTest(unittest.TestCase):
def test_current_minimal_swarm_score_is_numeric_and_highly_compliant(self) -> None:
report = current_minimal_swarm_score()
self.assertEqual(report.status, "PASS")
self.assertEqual(report.swarmness_score, 100.0)
self.assertEqual(report.minimal_compliance_score, 100.0)
self.assertEqual(report.tier, "极强本地最小蜂群合规")
self.assertEqual(report.hard_caps, ())
def test_core_swarm_failure_caps_score_below_acceptance(self) -> None:
items = tuple(
ScoreItem(
id=f"F{index}",
name=f"feature-{index}",
weight=10,
passed=index != 3,
actual="test",
threshold="test",
group="core_swarm",
)
for index in range(1, 7)
) + (
ScoreItem("S07", "support", 40, True, "ok", "ok", "support"),
)
report = score_items(items)
self.assertEqual(report.status, "FAIL")
self.assertLessEqual(report.minimal_compliance_score, 59)
self.assertIn("core swarm feature failed", report.hard_caps[0])
self.assertEqual(report.tier, "不满足蜂群")
if __name__ == "__main__":
unittest.main()