v2 rehearsal: FLAG-3 order note-before-notice on first-turn co-pending (fix effective order, pin with test)

This commit is contained in:
host committed 2026-11-05 02:45:09 +00:00
1 parent 6a70775ad9
commit adc2a02f6c
2 files changed
+40 -9

No files matched your search

+27
View File
@@ -504,6 +504,33 @@ class HostLoopTestCase(unittest.TestCase):
self.assertIn("new goal", prompts[0])
self.assertIn("旧目标", prompts[0])
def test_first_turn_both_pending_note_before_notice(self):
# FLAG-3 定序(v2 演练决定):首轮断点备注与改 goal 通知
# 同 pending 时,模型可见顺序为备注在前、通知在后。
# 注意代码里两次 prepend 的执行顺序与可见顺序相反
# (先贴通知、再贴备注),本测试钉住的是可见顺序,
# 而非执行顺序。
task = self._task()
self._write_signal(1, "new goal")
prompts = []
script = [("completed", "目标已达成", None)]
fake = _fake_turn_script(prompts, script)
note = ("[审计推回包(第 1 轮)]\n"
"- [execution_failed] 证据:boom detail")
with mock.patch.object(host_mod, "run_task_turn", fake):
result = host_mod.run_goal_loop(
SimpleNamespace(), self.state, self.state_path, task,
"old goal", None, 0, None, None, None, cfg=None,
resume_note=note)
self.assertTrue(result["ok"])
self.assertEqual(result["rounds_done"], 1)
self.assertEqual(len(prompts), 1)
first = prompts[0]
self.assertTrue(first.startswith(note))
self.assertLess(first.index(note), first.index("目标已更新"))
self.assertIn("new goal", first)
self.assertIn("作废", first)
if __name__ == "__main__":
unittest.main()