feat(ack): support project agent routing overrides

This commit is contained in:
2026-09-19 17:52:14 +08:00
parent 44cee4be91
commit f469c8f5f5
25 changed files with 746 additions and 83 deletions
+35 -3
View File
@@ -32,6 +32,7 @@ from yaml_subset import (
load_yaml_subset,
make_unique_pyyaml_loader,
)
from worker_profiles import validate_orchestration
from worker_profiles import validate_routing_document
STATUS_ENUM = {
@@ -894,7 +895,11 @@ def validate_with_schema(data: dict, schema_path: Path) -> list[str]:
return errors
def validate_builtin(data: dict) -> list[str]:
def validate_builtin(
data: dict,
*,
orchestration_override: dict | None = None,
) -> list[str]:
errors: list[str] = []
project_intake_workflow = "read-only-v1"
@@ -1044,6 +1049,8 @@ def validate_builtin(data: dict) -> list[str]:
if "ackVersion" in data and version_match is None:
errors.append("ackVersion 必须是合法 SemVer(例如 0.10.0)")
routing_required = (
orchestration_override is not None
or
(isinstance(project, dict) and "orchestration" in project)
or "workerReceipts" in data
or (
@@ -1053,7 +1060,12 @@ def validate_builtin(data: dict) -> list[str]:
)
)
if routing_required:
errors.extend(validate_routing_document(data))
errors.extend(
validate_routing_document(
data,
orchestration_override=orchestration_override,
)
)
if "summary" in data:
summary = data["summary"]
@@ -1415,7 +1427,27 @@ def main(argv: list[str] | None = None) -> int:
sys.stderr.write(f"找不到指定的 schema 文件: {schema_path}\n")
return 2
errors = validate_builtin(data)
agents_path = tasks_path.with_name("agents.yaml")
agents = None
if agents_path.is_symlink():
errors = ["agents.yaml 不能是 symlink"]
agents = None
elif agents_path.is_file():
agents = load_document(agents_path)
if not isinstance(agents, dict):
errors = ["agents.yaml 顶层必须是对象(mapping)"]
agents = None
else:
errors = validate_orchestration(agents, where="agents.yaml")
else:
errors = []
errors.extend(validate_builtin(data, orchestration_override=agents))
if agents is not None:
project = data.get("project")
board_orchestration = project.get("orchestration") if isinstance(project, dict) else None
if board_orchestration is not None:
errors.extend(validate_orchestration(board_orchestration))
mode = "内置语义规则"
try:
import jsonschema # type: ignore # noqa: F401