feat: integrate production cockpit AI assistant

This commit is contained in:
vee
2026-09-08 17:46:07 +08:00
parent 5e228e12ae
commit 93103c2579
66 changed files with 11046 additions and 374 deletions
+70
View File
@@ -121,6 +121,76 @@ def test_scene_composition_relaxes_only_text_evidence_for_an_atomic_dry_run(
assert scene.rejected_requests == ()
def test_scene_template_metadata_is_preserved_only_on_the_scene_path(
service: SeatDemoService,
) -> None:
plan = {
**_plan(
_request(
"climate",
"climate.set_temperature",
"vehicle",
{"temperature_c": 24},
)
),
"metadata": {
"source": "scene_template",
"template_id": "cinema",
"template_revision": "0123456789abcdef",
},
}
guarded = _guard(
service,
"进入观影模式",
plan,
allow_scene_composition=True,
)
assert guarded.plan["metadata"] == plan["metadata"]
with pytest.raises(ValueError, match="only valid for scene composition"):
_guard(service, "进入观影模式", plan)
@pytest.mark.parametrize(
"metadata",
(
{"source": "model", "template_id": "cinema", "template_revision": "0123456789abcdef"},
{"source": "scene_template", "template_id": "../cinema", "template_revision": "0123456789abcdef"},
{"source": "scene_template", "template_id": "cinema", "template_revision": "stale"},
{
"source": "scene_template",
"template_id": "cinema",
"template_revision": "0123456789abcdef",
"extra": "untrusted",
},
),
)
def test_scene_template_metadata_rejects_spoofed_or_malformed_values(
service: SeatDemoService,
metadata: dict[str, object],
) -> None:
plan = {
**_plan(
_request(
"climate",
"climate.set_temperature",
"vehicle",
{"temperature_c": 24},
)
),
"metadata": metadata,
}
with pytest.raises(ValueError, match="metadata is invalid"):
_guard(
service,
"进入观影模式",
plan,
allow_scene_composition=True,
)
@pytest.mark.parametrize(
"plan",
(