feat(n7web): sync N7 scene cards and optimize runtime
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from cognitive_agent.application.mode_profile import ModeProfileRegistry
|
||||
from cognitive_agent.application.seat_service import REPOSITORY_ROOT, SeatDemoService
|
||||
|
||||
|
||||
def test_all_repository_mode_cards_preserve_every_operation_in_dry_run(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
"""Every visible preset must reach a validated executable configuration."""
|
||||
|
||||
service = SeatDemoService(REPOSITORY_ROOT)
|
||||
service.mode_profiles = ModeProfileRegistry(
|
||||
REPOSITORY_ROOT / "config" / "modes",
|
||||
user_root=tmp_path / "user-modes",
|
||||
)
|
||||
service.artifact_root = tmp_path / "runs"
|
||||
vehicle_id = "denza_n7"
|
||||
failures: list[dict[str, object]] = []
|
||||
|
||||
for card in service.mode_profiles.public_modes(vehicle_id):
|
||||
profile = service.mode_profiles.get_profile(str(card["id"]), vehicle_id)
|
||||
result = service.process(
|
||||
profile.instruction or f"进入{profile.name}",
|
||||
provider="local",
|
||||
conversation_id=f"conv-mode-integrity-{profile.id.replace('_', '-')}",
|
||||
execution_mode="dry_run",
|
||||
vehicle_id=vehicle_id,
|
||||
control_transport="wireless_mqtt",
|
||||
)
|
||||
compiled_operations = [
|
||||
operation
|
||||
for config in result.get("function_configs", {}).values()
|
||||
for operation in config.get("spec", {}).get("operations", [])
|
||||
]
|
||||
validation_errors = [
|
||||
issue
|
||||
for issue in result.get("validation", [])
|
||||
if issue.get("severity") == "error"
|
||||
]
|
||||
if (
|
||||
result.get("status") != "succeeded"
|
||||
or validation_errors
|
||||
or result.get("deferred_requests")
|
||||
or len(compiled_operations) != len(profile.operations)
|
||||
):
|
||||
failures.append(
|
||||
{
|
||||
"id": profile.id,
|
||||
"expected_operations": len(profile.operations),
|
||||
"compiled_operations": len(compiled_operations),
|
||||
"status": result.get("status"),
|
||||
"deferred_requests": result.get("deferred_requests"),
|
||||
"validation_errors": validation_errors,
|
||||
}
|
||||
)
|
||||
|
||||
assert not failures, json.dumps(failures, ensure_ascii=False, indent=2)
|
||||
Reference in New Issue
Block a user