feat: make mode creation preview-only and cache-safe
This commit is contained in:
@@ -15,7 +15,13 @@ from cognitive_agent.application.codex_assistant import (
|
||||
_catalog_exact_scene_template_plan,
|
||||
)
|
||||
from cognitive_agent.application.mode_profile import ModeProfileRegistry
|
||||
from cognitive_agent.application.scene_composer import normalize_scene_output
|
||||
from cognitive_agent.application.scene_composer import (
|
||||
normalize_scene_output,
|
||||
scene_context_for_mode_creation,
|
||||
scene_required_native_fallbacks,
|
||||
scene_required_peripheral_refs,
|
||||
scene_semantic_guidance,
|
||||
)
|
||||
from cognitive_agent.application.seat_service import REPOSITORY_ROOT, SeatDemoService
|
||||
from cognitive_agent.application.self_extension import (
|
||||
ExtensionIntegrationError,
|
||||
@@ -212,6 +218,33 @@ def test_scene_composer_mixed_can_ir_preview_save_and_revalidate(
|
||||
*template_external["requests"],
|
||||
],
|
||||
}
|
||||
template_context = scene_context_for_mode_creation(
|
||||
context,
|
||||
"创建一个浪漫模式",
|
||||
)
|
||||
template_semantics = scene_semantic_guidance("浪漫模式")
|
||||
template_native_fallbacks = scene_required_native_fallbacks(
|
||||
"浪漫模式",
|
||||
template_context,
|
||||
include_default_bundle=True,
|
||||
)
|
||||
template_semantics["required_native_domains"] = [
|
||||
str(item["domain"])
|
||||
for item in template_native_fallbacks
|
||||
]
|
||||
template_semantics["native_fallback_requests"] = template_native_fallbacks
|
||||
template_semantics["peripheral_policy"] = {
|
||||
"required_refs": scene_required_peripheral_refs(
|
||||
"浪漫模式",
|
||||
template_context,
|
||||
include_default_bundle=True,
|
||||
),
|
||||
}
|
||||
template_context["scene_semantics"] = template_semantics
|
||||
augmented_template = CodexAssistantService._with_required_scene_peripherals(
|
||||
augmented_template,
|
||||
template_context,
|
||||
)
|
||||
template_preview = handler._preview_mode_with_scene_peripherals(
|
||||
"/api/requests/preview",
|
||||
{
|
||||
@@ -224,11 +257,30 @@ def test_scene_composer_mixed_can_ir_preview_save_and_revalidate(
|
||||
on_commands_validated=None,
|
||||
)
|
||||
assert template_preview["status"] == "succeeded"
|
||||
assert template_preview["mode_profile_draft"]["source_template_id"] == "romantic"
|
||||
assert template_preview["mode_profile_draft"]["operation_count"] == (
|
||||
len(template_preview["intent_ir"]["spec"]["actions"])
|
||||
assert template_preview["mode_profile_draft"]["generation_source"] == (
|
||||
"codex_scene_composition"
|
||||
)
|
||||
assert template_preview["mode_profile_draft"]["domains"][-1] == "self_extension"
|
||||
template_actions = template_preview["intent_ir"]["spec"]["actions"]
|
||||
assert template_preview["mode_profile_draft"]["operation_count"] == (
|
||||
len(template_actions)
|
||||
)
|
||||
assert {
|
||||
"climate",
|
||||
"ambient_light",
|
||||
"roof",
|
||||
"self_extension",
|
||||
}.issubset(template_preview["mode_profile_draft"]["domains"])
|
||||
template_capabilities = {
|
||||
action["capability"]
|
||||
for action in template_actions
|
||||
}
|
||||
assert any(
|
||||
capability.startswith("climate.")
|
||||
for capability in template_capabilities
|
||||
)
|
||||
assert "ambient_light.set_power" in template_capabilities
|
||||
assert "roof.set_shade_position" in template_capabilities
|
||||
assert "infrared.emit" in template_capabilities
|
||||
|
||||
explicit = handler._execute_request_with_peripherals(
|
||||
"/api/requests/preview",
|
||||
|
||||
Reference in New Issue
Block a user