feat(scenes): add deterministic romantic cinema template

This commit is contained in:
Miayui
2026-09-21 12:07:49 +08:00
parent b3bd90f748
commit ad0c1f4ed1
8 changed files with 453 additions and 23 deletions
@@ -48,7 +48,10 @@ from cognitive_agent.application.scene_composer import (
scene_required_peripheral_refs,
scene_semantic_guidance,
)
from cognitive_agent.application.scene_templates import normalize_scene_template_name
from cognitive_agent.application.scene_templates import (
PRESERVE_BASE_EXTERNAL_LIGHT_TEMPLATE_IDS,
normalize_scene_template_name,
)
from cognitive_agent.application.schedule_intent import is_schedule_stop, needs_mode_schedule
LOGGER = logging.getLogger(__name__)
@@ -1034,15 +1037,53 @@ class CodexAssistantService:
if mode_parts
else None
)
scene_template_plan = (
candidate_scene_template_plan = (
_catalog_exact_scene_template_plan(catalog, mode_parts[0])
if mode_parts and not mode_parts[1] and exact_mode_matches == 0
if mode_parts and not mode_parts[1]
else None
)
candidate_scene_template_metadata = (
candidate_scene_template_plan.get("metadata")
if isinstance(candidate_scene_template_plan, Mapping)
else None
)
candidate_scene_template_id = (
str(candidate_scene_template_metadata.get("template_id") or "")
if isinstance(candidate_scene_template_metadata, Mapping)
else ""
)
scene_template_plan = (
candidate_scene_template_plan
if exact_mode_matches == 0
or candidate_scene_template_id
in PRESERVE_BASE_EXTERNAL_LIGHT_TEMPLATE_IDS
else None
)
scene_template_metadata = (
scene_template_plan.get("metadata")
if isinstance(scene_template_plan, Mapping)
else None
)
preserve_base_external_lights = bool(
isinstance(scene_template_metadata, Mapping)
and str(scene_template_metadata.get("template_id") or "")
in PRESERVE_BASE_EXTERNAL_LIGHT_TEMPLATE_IDS
)
if preserve_base_external_lights:
# The template already owns every native cinema action. Do not let
# generic romantic-scene defaults replace or append native actions;
# only the deterministic, NFC-authorized light refs may be added.
scene_semantics = scene_context.get("scene_semantics")
if isinstance(scene_semantics, dict):
scene_semantics["required_native_domains"] = []
scene_semantics["required_native_controls"] = []
scene_semantics["native_fallback_requests"] = []
scene_semantics["default_control_bundle_applied"] = False
dynamic_scene_request = bool(mode_parts and needs_mode_schedule(message))
scene_peripheral_actions = scene_context.get("peripheral_actions", [])
template_augmentation_preview = bool(
scene_template_plan is not None
and not preserve_base_external_lights
and not dynamic_scene_request
and isinstance(scene_peripheral_actions, list)
and scene_peripheral_actions