فهرست منبع

test(阶段策略): 锁定 Host 注入协议与 Prompt 边界

验证公共 Planner Prompt 不包含 Phase2 边界,Phase1 RunConfig 带受保护 phase,Phase2 策略包含写作用域、Structure 引用、adoption 完整分区和单 Compose Portfolio 规则。
SamLee 23 ساعت پیش
والد
کامیت
c4cee58314
1فایلهای تغییر یافته به همراه23 افزوده شده و 0 حذف شده
  1. 23 0
      script_build_host/tests/test_mission_factory.py

+ 23 - 0
script_build_host/tests/test_mission_factory.py

@@ -1,6 +1,7 @@
 import json
 from datetime import UTC, datetime
 
+from script_build_host.agents.prompts import PARAGRAPH_WORKER_PROMPT, PLANNER_PROMPT
 from script_build_host.application.mission_factory import ScriptMissionFactory
 from script_build_host.domain.input_snapshot import ScriptBuildInputSnapshotV1
 from script_build_host.domain.records import MissionBinding
@@ -64,11 +65,33 @@ def test_factory_reads_nested_real_topic_and_does_not_double_prefix_digest() ->
     assert "workflow" not in str(spec).lower()
     message = json.loads(factory.build_planner_message(_binding(), _snapshot()))
     assert message["input_sha256"] == "sha256:" + "b" * 64
+    assert "Retrieval children under that Direction" in message["instruction"]
+    assert "exact reason PHASE_ONE_CAPABILITY_BOUNDARY" in message["instruction"]
     config = factory.build_run_config(_binding(), _snapshot())
     assert config.agent_type == "script_planner"
     assert config.model == "planner-model"
     assert config.temperature == 0.1
     assert config.max_iterations == 42
     assert config.new_trace_id == "root"
+    assert config.context["phase"] == 1
     assert config.enable_memory is False
     assert config.enable_research_flow is False
+
+
+def test_common_planner_prompt_does_not_leak_phase_two_boundary() -> None:
+    factory = ScriptMissionFactory()
+    assert "PHASE_TWO_CANDIDATE_PORTFOLIO_READY" not in PLANNER_PROMPT
+    assert "using the returned Direction Task ID as `parent_task_id`" in PLANNER_PROMPT
+    assert "`PHASE_ONE_CAPABILITY_BOUNDARY` with no additional text" in PLANNER_PROMPT
+    phase_two = factory.build_phase_two_policy(_snapshot())
+    assert "PHASE_TWO_CANDIDATE_PORTFOLIO_READY" in phase_two
+    assert "CandidatePortfolio and Compose must use the exact parent" in phase_two
+    assert "script-build://writes/paragraphs/<stable-selector>" in phase_two
+    assert "script-build://writes/elements/<stable-selector>" in phase_two
+    assert "Never copy scope_ref into write_scope" in phase_two
+    assert "whole Structure accepted_decision_ref" in phase_two
+    assert "whole artifact_ref unchanged into base_artifact_ref" in phase_two
+    assert "must also include and adopt its covering" in phase_two
+    assert "must partition that complete candidate list" in phase_two
+    assert "candidate_decision_ids, adopted_decision_ids, and compose_order" in phase_two
+    assert "derive a strategy reference" in PARAGRAPH_WORKER_PROMPT