test: 固定项目红线集成检查 (#317)
This commit is contained in:
@@ -17,7 +17,10 @@ from src.admin_gateway import (
|
||||
SpecResolutionMatch,
|
||||
SpecResolutionReceipt,
|
||||
)
|
||||
from src.http_admin_gateway import HttpAdminGateway
|
||||
from src.http_admin_gateway import (
|
||||
PURCHASE_SPEC_RESOLUTION_TIMEOUT_SECONDS,
|
||||
HttpAdminGateway,
|
||||
)
|
||||
from src.mock_admin_gateway import MockAdminGateway
|
||||
from src.task_models import TaskType
|
||||
|
||||
@@ -281,7 +284,10 @@ class PurchaseSpecResolutionContractVectorTest(unittest.TestCase):
|
||||
for name, value in opener.request.header_items()
|
||||
}
|
||||
self.assertEqual(headers["idempotency-key"], key)
|
||||
self.assertEqual(opener.timeout, 60.0)
|
||||
self.assertEqual(
|
||||
opener.timeout,
|
||||
PURCHASE_SPEC_RESOLUTION_TIMEOUT_SECONDS,
|
||||
)
|
||||
|
||||
def test_error_vectors_are_identical_for_http_and_mock(self):
|
||||
defaults = self.fixture["defaults"]
|
||||
|
||||
@@ -368,6 +368,26 @@ def check_agent_efficiency_rules(errors: list[str], root: Path = ROOT) -> None:
|
||||
errors.append(f"AGENTS.md 缺少:{section}")
|
||||
|
||||
|
||||
def check_project_redlines(errors: list[str], root: Path = ROOT) -> None:
|
||||
"""固定检查 cmautobuy 五条产品红线和跨端契约入口。"""
|
||||
|
||||
path = root / "AGENTS.md"
|
||||
if not path.is_file():
|
||||
return
|
||||
content = path.read_text(encoding="utf-8")
|
||||
required = (
|
||||
"Qt 绑定固定 PyQt5",
|
||||
"Admin 新建采购任务固定为真实下单(不支付)",
|
||||
"不自动注册登录,不自动付款",
|
||||
"公开引导默认密码固定为 `chengma`",
|
||||
"只准核对订单,绝不重新下单",
|
||||
"Client 侧文档",
|
||||
"唯一事实来源",
|
||||
)
|
||||
for section in missing_sections(content, required):
|
||||
errors.append(f"AGENTS.md 缺少项目红线:{section}")
|
||||
|
||||
|
||||
def check_repository_readme(errors: list[str], root: Path = ROOT) -> None:
|
||||
"""检查快速开始包含线上 Wiki 初始化顺序和产品编码门禁。"""
|
||||
|
||||
@@ -596,6 +616,7 @@ def run_check(args: argparse.Namespace) -> int:
|
||||
check_core_documents(errors)
|
||||
check_task_template(errors)
|
||||
check_agent_efficiency_rules(errors)
|
||||
check_project_redlines(errors)
|
||||
check_repository_readme(errors)
|
||||
check_claude_code_entry(errors)
|
||||
check_archives(errors)
|
||||
|
||||
@@ -20,6 +20,7 @@ from harness import ( # noqa: E402
|
||||
check_required_files,
|
||||
check_core_documents,
|
||||
check_agent_efficiency_rules,
|
||||
check_project_redlines,
|
||||
check_repository_readme,
|
||||
check_task_template,
|
||||
core_mapping_errors,
|
||||
@@ -253,6 +254,11 @@ class TaskTemplateTests(unittest.TestCase):
|
||||
|
||||
|
||||
class AgentRuleTests(unittest.TestCase):
|
||||
def test_cmautobuy_product_redlines_are_present(self) -> None:
|
||||
errors: list[str] = []
|
||||
check_project_redlines(errors)
|
||||
self.assertEqual(errors, [])
|
||||
|
||||
def test_required_agent_rules_are_present(self) -> None:
|
||||
errors: list[str] = []
|
||||
check_agent_efficiency_rules(errors)
|
||||
|
||||
Reference in New Issue
Block a user