feat: 实现受控真实下单安全边界 (#99)

This commit is contained in:
chengma
2026-08-10 16:35:38 +08:00
parent 7106f6b024
commit e960cab1fb
30 changed files with 1562 additions and 66 deletions
+13
View File
@@ -361,6 +361,7 @@ class HttpAdminGateway(AdminGateway):
raw_type = task.get("type")
version = task.get("version")
priority = task.get("priority")
execution_mode = task.get("execution_mode", "dry_run")
task_payload = task.get("payload")
created_at = task.get("created_at")
updated_at = task.get("updated_at")
@@ -373,6 +374,7 @@ class HttpAdminGateway(AdminGateway):
and version > 0
and isinstance(priority, int)
and not isinstance(priority, bool)
and isinstance(execution_mode, str)
and isinstance(task_payload, Mapping)
and isinstance(created_at, str)
and isinstance(updated_at, str)
@@ -395,6 +397,16 @@ class HttpAdminGateway(AdminGateway):
request_id,
) from exc
if execution_mode not in {"dry_run", "live"} or (
task_type is not TaskType.PURCHASE and execution_mode != "dry_run"
):
raise AdminGatewayError(
"ADMIN_INVALID_RESPONSE",
"Admin 返回了不支持的任务执行模式",
False,
request_id,
)
cls._validate_claim_payload(task_type, task_payload, request_id)
return AdminTask(
@@ -402,6 +414,7 @@ class HttpAdminGateway(AdminGateway):
task_type=task_type,
version=version,
priority=priority,
execution_mode=execution_mode,
payload=dict(task_payload),
created_at=created_at,
updated_at=updated_at,