落地并存测服全端:智能体 Graph/路由、后台切 8180、主账与部署脚本齐备,便于线上重发与验收。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
"""
|
||||
字段合同校验入口壳。
|
||||
|
||||
本文件职责:暴露 validate_required_fields_shell;正式规则读 contracts JSON 后再实现。
|
||||
禁止:在未 require_formal_contract 时假装已激活字段;禁止用正则替代模型语义。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from agent.schema.contracts_loader import load_contract, require_formal_contract
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def validate_required_fields_shell(
|
||||
*,
|
||||
facts: dict[str, Any],
|
||||
business_line: str = "",
|
||||
require_formal: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
字段校验空壳。
|
||||
|
||||
返回结构固定:ok / implemented / missing / errors。
|
||||
implemented=False 表示规则引擎尚未接入(框架阶段预期)。
|
||||
"""
|
||||
stem = "inquiry-required-fields-v1"
|
||||
try:
|
||||
contract = (
|
||||
require_formal_contract(stem) if require_formal else load_contract(stem)
|
||||
)
|
||||
except (FileNotFoundError, RuntimeError) as exc:
|
||||
return {
|
||||
"ok": False,
|
||||
"implemented": False,
|
||||
"missing": [],
|
||||
"errors": [str(exc)],
|
||||
"business_line": business_line,
|
||||
}
|
||||
|
||||
is_ph = bool(contract.get("_meta", {}).get("is_placeholder"))
|
||||
logger.info(
|
||||
"schema.validate_shell line=%s placeholder=%s facts_keys=%s(未跑激活规则)",
|
||||
business_line or "-",
|
||||
is_ph,
|
||||
sorted(facts.keys()),
|
||||
)
|
||||
return {
|
||||
"ok": False,
|
||||
"implemented": False,
|
||||
"missing": [],
|
||||
"errors": ["field_activation_rules_not_implemented"],
|
||||
"business_line": business_line,
|
||||
"contract_placeholder": is_ph,
|
||||
}
|
||||
Reference in New Issue
Block a user