🐛 fix(main_loop): enforce plan lifecycle ordering

Claim the first executable plan in plan-file order after resuming any in-progress plan, preserve skipped as its own workflow phase, and document the required post-done commit gate in the agent rules.
This commit is contained in:
csh
2026-05-27 14:07:09 +08:00
parent 61afff9d48
commit 1a3ea1f425
6 changed files with 221 additions and 48 deletions
+21 -8
View File
@@ -76,6 +76,7 @@ class SyncTemplatesPlaceholdersTests(unittest.TestCase):
ROOT / "templates" / "prompts" / "coding" / "close-task.template.md"
).read_text(encoding="utf-8")
self.assertIn("main_loop.py finish", close_task_template)
self.assertIn("如本轮来自 `main_loop.py claim`", close_task_template)
self.assertIn("workflow-state.phase", close_task_template)
self.assertIn("## Completed", close_task_template)
self.assertIn("## Not Completed", close_task_template)
@@ -86,6 +87,7 @@ class SyncTemplatesPlaceholdersTests(unittest.TestCase):
verify_change_template = (
ROOT / "templates" / "prompts" / "coding" / "verify-change.template.md"
).read_text(encoding="utf-8")
self.assertIn("如本轮来自 `main_loop.py claim`", verify_change_template)
self.assertIn("workflow-state.phase", verify_change_template)
self.assertIn("plan-status", verify_change_template)
self.assertIn("## Validated", verify_change_template)
@@ -108,9 +110,9 @@ class SyncTemplatesPlaceholdersTests(unittest.TestCase):
self.assertIn("## Open Questions", code_review_template)
self.assertIn("## Residual Risk", code_review_template)
prompts_readme = (
ROOT / "templates" / "prompts" / "README.md"
).read_text(encoding="utf-8")
prompts_readme = (ROOT / "templates" / "prompts" / "README.md").read_text(
encoding="utf-8"
)
self.assertIn("AGENT_RULES.md", prompts_readme)
self.assertIn("docs/superpowers/", prompts_readme)
self.assertIn("不是流程权威", prompts_readme)
@@ -132,16 +134,27 @@ class SyncTemplatesPlaceholdersTests(unittest.TestCase):
self.assertNotIn("main_loop.py claim", agent_behavior_template)
self.assertNotIn("playbook.py -record-spec", agent_behavior_template)
self.assertNotIn("playbook.py -record-plan", agent_behavior_template)
self.assertIn("项目上下文与执行状态写入 `memory-bank/`", agent_behavior_template)
self.assertIn(
"项目上下文与执行状态写入 `memory-bank/`", agent_behavior_template
)
rules_template = (
ROOT / "templates" / "AGENT_RULES.template.md"
).read_text(encoding="utf-8")
rules_template = (ROOT / "templates" / "AGENT_RULES.template.md").read_text(
encoding="utf-8"
)
self.assertIn("唯一流程约束中心", rules_template)
self.assertIn("唯一设计与计划产物中心", rules_template)
self.assertIn("memory-bank/progress.md", rules_template)
self.assertIn("已有 `in-progress` 优先恢复", rules_template)
self.assertIn("按 Plan 文件顺序选择第一个可执行 Plan", rules_template)
self.assertIn("Plan `done` 后必须完成一次 commit", rules_template)
self.assertIn(
"不得由 `main_loop.py finish` 自动执行 `git commit`", rules_template
)
self.assertIn("工作区保持干净后再领取下一个 Plan", rules_template)
def test_sync_templates_replaces_playbook_scripts_without_main_language_support(self):
def test_sync_templates_replaces_playbook_scripts_without_main_language_support(
self,
):
with tempfile.TemporaryDirectory() as tmp_dir:
config_body = f"""
[playbook]