Files
fengqun/tests/test_model_io_report_audit.py
T
gongzhiyongandOmX cd2431ece2 Add minimal quality-gated convergence
Promote the S07 external FastAPI chain from score-only acceptance to a minimal quality-gated flow with refusal detection, retry/fallback recovery, handoff quality checks, and a multi-round consensus gate before final convergence.

Constraint: The user asked to fix the documented shortcomings around score-only convergence, weak refusal scoring, and unqualified handoff evidence while continuing the minimal version.

Rejected: Replacing the whole coordinator with a production consensus runtime | the minimal fix keeps the existing task pool/convergence shape and adds scenario-level quality gates plus consensus evidence.

Confidence: high

Scope-risk: moderate

Directive: Future S07 runs must keep all_outputs_pass_quality_gate and multi_round_quality_consensus_accepts_chain as required checks before claiming PASS.

Tested: .venv/bin/python -B -m unittest tests.test_standard_scenarios; .venv/bin/python -u -B examples/run_continuous_reasoning_acceptance.py; .venv/bin/python -B examples/export_model_agnet_io_report.py; .venv/bin/python -B -m unittest discover -s tests; .venv/bin/python -B -m py_compile swarm_minimal/*.py examples/*.py tests/*.py; .venv/bin/python -u -B examples/run_academic_standard_evaluation.py; .venv/bin/python -B -m unittest tests.test_model_io_report_audit; git diff --check; docs secret pattern scan.

Not-tested: The combined run_standard_scenario_acceptance wrapper was not rerun after report export to avoid creating a newer live run that would make the exported latest-run report stale.

Co-authored-by: OmX <omx@oh-my-codex.dev>
2026-05-16 16:35:00 +08:00

64 lines
2.3 KiB
Python

from pathlib import Path
import re
import unittest
ROOT = Path(__file__).resolve().parents[1]
REPORT = ROOT / "docs" / "MODEL_AGNET_IO_REPORT.zh-CN.md"
class ModelIoReportAuditTests(unittest.TestCase):
def test_report_exposes_scenarios_inputs_outputs_and_handoff(self) -> None:
text = REPORT.read_text(encoding="utf-8")
for required in [
"## 场景说明:FastAPI 是什么项目",
"## 本轮实际做了什么代码 / 测试工作",
"## 不同 Agnet 的工作怎么实现",
"## 收敛过程如何发生",
"## 本轮测试场景补充",
"| S01 | syntax_import_sanity |",
"| S02 | unit_regression |",
"| S03-S06 | deterministic_standard_scenarios |",
"| S07 | live_external_github_code_reasoning |",
"| S08 | model_io_report_audit |",
"fastapi/fastapi",
"ecace740f3eaccb1aba152cf1de79477095c56f4",
"fastapi/routing.py",
"#### 本次任务输入 task.input",
"#### Agnet / 模型实际输出 task.output(审计摘要)",
"#### 接手 / 交接机制",
"原始来源:PostgreSQL `swarm_tasks.output`",
"质量补救",
"共识质量门",
"quality_attempt=1",
"chain_edge=",
]:
self.assertIn(required, text)
for forbidden in [
"为 swarm-minimal 设计可恢复的大规模代码任务推理链",
"swarm_minimal/core.py",
"swarm_minimal/newapi_agnet.py",
"swarm_minimal/azure_store.py",
"I appreciate the detailed context",
"What I can actually do",
"What I cannot do",
"输出质量风险",
]:
self.assertNotIn(forbidden, text)
def test_report_does_not_contain_obvious_secret_values(self) -> None:
text = REPORT.read_text(encoding="utf-8")
forbidden_patterns = [
r"sk-[A-Za-z0-9]{20,}",
r"AccountKey=[^<\s`]+",
r"password=[^<\s`]+",
r"BEGIN [A-Z ]*PRIVATE KEY",
]
for pattern in forbidden_patterns:
self.assertIsNone(re.search(pattern, text, flags=re.IGNORECASE))
if __name__ == "__main__":
unittest.main()