phase-loop-runtime 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. phase_loop_runtime/__init__.py +20 -0
  2. phase_loop_runtime/_contract_docs/phase-loop/extraction-readiness.md +90 -0
  3. phase_loop_runtime/_contract_docs/phase-loop/granular-execution-policy.md +137 -0
  4. phase_loop_runtime/_contract_docs/phase-loop/harness-capability-matrix.md +510 -0
  5. phase_loop_runtime/_contract_docs/phase-loop/harness-skill-matrix.md +125 -0
  6. phase_loop_runtime/_contract_docs/phase-loop/harness-substrate-manifest.md +232 -0
  7. phase_loop_runtime/_contract_docs/phase-loop/pi-loop-control.md +247 -0
  8. phase_loop_runtime/_contract_docs/phase-loop/protocol.md +2759 -0
  9. phase_loop_runtime/_contract_docs/phase-loop/runtime-boundary.md +289 -0
  10. phase_loop_runtime/_contract_docs/phase-loop/spec-discovery-roots.md +47 -0
  11. phase_loop_runtime/_contract_docs/phase-loop/substrate-soak-governed-pipeline.md +42 -0
  12. phase_loop_runtime/_contract_docs/phase-loop/substrate-soak-portal-projection.md +34 -0
  13. phase_loop_runtime/_contract_docs/phase-loop/substrate-soak-regenesis.md +29 -0
  14. phase_loop_runtime/_contract_docs/phase-loop/substrate-soak-report.md +32 -0
  15. phase_loop_runtime/_contract_docs/runtime/verification-evidence-contract.md +52 -0
  16. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-mixed-signals/commands.txt +2 -0
  17. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-mixed-signals/manifest.json +16 -0
  18. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-mixed-signals/mixed.json +5 -0
  19. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-provider-timeout/manifest.json +16 -0
  20. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-provider-timeout/timeout-note.txt +2 -0
  21. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-redacted-summary/manifest.json +16 -0
  22. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-redacted-summary/redacted-summary.json +6 -0
  23. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-small-sample/manifest.json +16 -0
  24. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-small-sample/sample.json +7 -0
  25. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-threshold-edge/edge.txt +2 -0
  26. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/borderline/borderline-threshold-edge/manifest.json +16 -0
  27. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-duplicate-png/manifest.json +16 -0
  28. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-duplicate-png/shot-a.txt +1 -0
  29. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-duplicate-png/shot-b.txt +1 -0
  30. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-duplicate-png/shot-c.txt +1 -0
  31. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-missing-references/claimed-results.json +5 -0
  32. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-missing-references/manifest.json +16 -0
  33. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-subtle-low-variance/manifest.json +16 -0
  34. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-subtle-low-variance/metrics.json +9 -0
  35. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-templated-prose/findings.md +10 -0
  36. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-templated-prose/manifest.json +16 -0
  37. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-uniform-scores/manifest.json +16 -0
  38. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-uniform-scores/scores.json +4 -0
  39. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-fake/fake-uniform-scores/summary.txt +1 -0
  40. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-adoption-bundle/bundle-check.json +8 -0
  41. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-adoption-bundle/manifest.json +16 -0
  42. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-adoption-bundle/operator-note.txt +2 -0
  43. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-handoff-ledger/events-sample.jsonl +3 -0
  44. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-handoff-ledger/manifest.json +16 -0
  45. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-handoff-ledger/receipt.txt +1 -0
  46. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-runner-diff/evidence.json +13 -0
  47. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-runner-diff/manifest.json +16 -0
  48. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-runner-diff/summary.txt +2 -0
  49. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-test-matrix/manifest.json +16 -0
  50. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-test-matrix/matrix.json +9 -0
  51. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-test-matrix/notes.md +4 -0
  52. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-ui-screenshot-standin/console-summary.txt +2 -0
  53. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-ui-screenshot-standin/manifest.json +16 -0
  54. phase_loop_runtime/_test_fixtures/evidence-audit-calibration/known-real/real-ui-screenshot-standin/screenshot-standin.ppm +5 -0
  55. phase_loop_runtime/adoption_bundle.py +273 -0
  56. phase_loop_runtime/advisor_board/CONTRACTS.md +257 -0
  57. phase_loop_runtime/advisor_board/__init__.py +288 -0
  58. phase_loop_runtime/advisor_board/backing.py +137 -0
  59. phase_loop_runtime/advisor_board/backing_omnigent.py +498 -0
  60. phase_loop_runtime/advisor_board/config.py +225 -0
  61. phase_loop_runtime/advisor_board/events.py +115 -0
  62. phase_loop_runtime/advisor_board/fixtures/advisor-boards.example.toml +59 -0
  63. phase_loop_runtime/advisor_board/fixtures.py +91 -0
  64. phase_loop_runtime/advisor_board/harness_mapping.py +125 -0
  65. phase_loop_runtime/advisor_board/matrix.py +146 -0
  66. phase_loop_runtime/advisor_board/observability.py +481 -0
  67. phase_loop_runtime/advisor_board/presets.py +188 -0
  68. phase_loop_runtime/advisor_board/registries.py +309 -0
  69. phase_loop_runtime/advisor_board/resolver.py +253 -0
  70. phase_loop_runtime/advisor_board/schema.py +269 -0
  71. phase_loop_runtime/advisor_board/standin.py +166 -0
  72. phase_loop_runtime/advisor_board/validation.py +159 -0
  73. phase_loop_runtime/agent_runtime_provider.py +676 -0
  74. phase_loop_runtime/baml_modular.py +656 -0
  75. phase_loop_runtime/baml_src/dotfiles_adoption_manifest.baml +37 -0
  76. phase_loop_runtime/baml_src/dotfiles_c4_document.baml +14 -0
  77. phase_loop_runtime/baml_src/dotfiles_plan_manifest.baml +50 -0
  78. phase_loop_runtime/baml_src/dotfiles_runtime_projection.baml +16 -0
  79. phase_loop_runtime/baml_src/dotfiles_task_catalog.baml +20 -0
  80. phase_loop_runtime/baml_src/emit_phase_closeout.baml +86 -0
  81. phase_loop_runtime/baml_src/evaluate_suspected_fake_evidence.baml +36 -0
  82. phase_loop_runtime/baml_src/verification_evidence.baml +40 -0
  83. phase_loop_runtime/broker.py +181 -0
  84. phase_loop_runtime/build_bundle.py +294 -0
  85. phase_loop_runtime/capability_registry.py +835 -0
  86. phase_loop_runtime/classifier.py +87 -0
  87. phase_loop_runtime/claude_agent_view.py +625 -0
  88. phase_loop_runtime/claude_channel_sidecar.py +1086 -0
  89. phase_loop_runtime/cli.py +2599 -0
  90. phase_loop_runtime/closeout.py +865 -0
  91. phase_loop_runtime/closeout_classifier.py +120 -0
  92. phase_loop_runtime/closeout_evidence_audit.py +112 -0
  93. phase_loop_runtime/closeout_validation.py +144 -0
  94. phase_loop_runtime/closeout_validators.py +203 -0
  95. phase_loop_runtime/consiliency_gates.py +374 -0
  96. phase_loop_runtime/consiliency_ingest.py +399 -0
  97. phase_loop_runtime/consiliency_layout.py +176 -0
  98. phase_loop_runtime/consiliency_scaffold.py +305 -0
  99. phase_loop_runtime/cross_repo_channel.py +331 -0
  100. phase_loop_runtime/discovery.py +2368 -0
  101. phase_loop_runtime/dispatch_lock.py +167 -0
  102. phase_loop_runtime/doc_delta_validator.py +98 -0
  103. phase_loop_runtime/docs_audit.py +285 -0
  104. phase_loop_runtime/docs_freshness.py +468 -0
  105. phase_loop_runtime/docs_surfaces.py +150 -0
  106. phase_loop_runtime/dotfiles_profile_plugin.py +96 -0
  107. phase_loop_runtime/events.py +154 -0
  108. phase_loop_runtime/events_migration.py +96 -0
  109. phase_loop_runtime/evidence_audit.py +1082 -0
  110. phase_loop_runtime/evidence_audit_config.py +172 -0
  111. phase_loop_runtime/fleet_map.py +426 -0
  112. phase_loop_runtime/fleet_metrics.py +298 -0
  113. phase_loop_runtime/fleet_metrics_export.py +196 -0
  114. phase_loop_runtime/git_discipline.py +479 -0
  115. phase_loop_runtime/git_ops.py +122 -0
  116. phase_loop_runtime/git_topology.py +252 -0
  117. phase_loop_runtime/governed_bundle.py +137 -0
  118. phase_loop_runtime/governed_premerge.py +219 -0
  119. phase_loop_runtime/governed_review.py +264 -0
  120. phase_loop_runtime/handoff.py +932 -0
  121. phase_loop_runtime/handoff_path.py +14 -0
  122. phase_loop_runtime/injection.py +740 -0
  123. phase_loop_runtime/install_status.py +88 -0
  124. phase_loop_runtime/lane_scheduler.py +317 -0
  125. phase_loop_runtime/launcher.py +2760 -0
  126. phase_loop_runtime/lease_store.py +553 -0
  127. phase_loop_runtime/maintenance.py +401 -0
  128. phase_loop_runtime/migrate_handoffs.py +201 -0
  129. phase_loop_runtime/models.py +2144 -0
  130. phase_loop_runtime/observability.py +1290 -0
  131. phase_loop_runtime/panel_invoker.py +1638 -0
  132. phase_loop_runtime/phase_loop_drift_audit.py +388 -0
  133. phase_loop_runtime/phase_worktree_executor.py +433 -0
  134. phase_loop_runtime/pipeline_adapter/__init__.py +12 -0
  135. phase_loop_runtime/pipeline_adapter/branch_ops.py +274 -0
  136. phase_loop_runtime/pipeline_adapter/flag.py +55 -0
  137. phase_loop_runtime/pipeline_adapter/markers.py +13 -0
  138. phase_loop_runtime/pipeline_adapter/merge_policy.py +72 -0
  139. phase_loop_runtime/pipeline_adapter/ratification.py +100 -0
  140. phase_loop_runtime/pipeline_adapter/sibling_matcher.py +123 -0
  141. phase_loop_runtime/plan_ir.py +523 -0
  142. phase_loop_runtime/plan_manifest.py +415 -0
  143. phase_loop_runtime/planner_validation.py +176 -0
  144. phase_loop_runtime/profiles.py +462 -0
  145. phase_loop_runtime/prompts.py +365 -0
  146. phase_loop_runtime/provenance.py +165 -0
  147. phase_loop_runtime/publishing.py +339 -0
  148. phase_loop_runtime/py.typed +1 -0
  149. phase_loop_runtime/reconcile.py +1550 -0
  150. phase_loop_runtime/redaction.py +184 -0
  151. phase_loop_runtime/reflection_sync.py +293 -0
  152. phase_loop_runtime/release_guard.py +186 -0
  153. phase_loop_runtime/render.py +432 -0
  154. phase_loop_runtime/repo_validation.py +427 -0
  155. phase_loop_runtime/review_summary.py +150 -0
  156. phase_loop_runtime/roadmap_lint.py +425 -0
  157. phase_loop_runtime/route_log.py +59 -0
  158. phase_loop_runtime/route_policy/__init__.py +11 -0
  159. phase_loop_runtime/route_policy/fixtures/route_selection.golden.json +263 -0
  160. phase_loop_runtime/runner.py +8400 -0
  161. phase_loop_runtime/runtime_paths.py +225 -0
  162. phase_loop_runtime/runtime_projection.py +113 -0
  163. phase_loop_runtime/runtime_resources.py +36 -0
  164. phase_loop_runtime/schema_export.py +292 -0
  165. phase_loop_runtime/schemas/phase_loop_closeout.schema.json +366 -0
  166. phase_loop_runtime/skill_install.py +176 -0
  167. phase_loop_runtime/skill_inventory.py +662 -0
  168. phase_loop_runtime/skill_paths.py +42 -0
  169. phase_loop_runtime/skill_sources_plugin.py +37 -0
  170. phase_loop_runtime/skills_bundle/claude-advisor-board/README.md +1 -0
  171. phase_loop_runtime/skills_bundle/claude-advisor-board/SKILL.md +38 -0
  172. phase_loop_runtime/skills_bundle/claude-advisor-panel/README.md +1 -0
  173. phase_loop_runtime/skills_bundle/claude-advisor-panel/SKILL.md +38 -0
  174. phase_loop_runtime/skills_bundle/claude-execute-detailed/README.md +1 -0
  175. phase_loop_runtime/skills_bundle/claude-execute-detailed/SKILL.md +152 -0
  176. phase_loop_runtime/skills_bundle/claude-execute-phase/README.md +1 -0
  177. phase_loop_runtime/skills_bundle/claude-execute-phase/SKILL.md +745 -0
  178. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/allocate_worktree_name.sh +33 -0
  179. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/audit_lane_file_touches.py +197 -0
  180. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/cleanup_lane_worktrees.sh +103 -0
  181. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/parent_tree_leakage_check.sh +125 -0
  182. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/post_merge_import_smoke.sh +62 -0
  183. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/pre_merge_destructiveness_check.sh +127 -0
  184. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/resolve_branch_from_sha.sh +51 -0
  185. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/state.py +274 -0
  186. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/sweep_stale_worktrees.sh +62 -0
  187. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/team_teardown.sh +32 -0
  188. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/validate_plan_doc.py +642 -0
  189. phase_loop_runtime/skills_bundle/claude-execute-phase/scripts/verify_harness.sh +96 -0
  190. phase_loop_runtime/skills_bundle/claude-phase-loop/README.md +1 -0
  191. phase_loop_runtime/skills_bundle/claude-phase-loop/SKILL.md +115 -0
  192. phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/README.md +1 -0
  193. phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/SKILL.md +439 -0
  194. phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/assets/review_prompt.md +19 -0
  195. phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/references/parallelization-heuristics.md +111 -0
  196. phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/references/roadmap-template.md +193 -0
  197. phase_loop_runtime/skills_bundle/claude-phase-roadmap-builder/scripts/validate_roadmap.py +32 -0
  198. phase_loop_runtime/skills_bundle/claude-plan-detailed/README.md +1 -0
  199. phase_loop_runtime/skills_bundle/claude-plan-detailed/SKILL.md +334 -0
  200. phase_loop_runtime/skills_bundle/claude-plan-detailed/assets/review_prompt.md +25 -0
  201. phase_loop_runtime/skills_bundle/claude-plan-phase/README.md +1 -0
  202. phase_loop_runtime/skills_bundle/claude-plan-phase/SKILL.md +776 -0
  203. phase_loop_runtime/skills_bundle/claude-plan-phase/assets/review_prompt.md +17 -0
  204. phase_loop_runtime/skills_bundle/claude-plan-phase/scripts/validate_plan_doc.py +1092 -0
  205. phase_loop_runtime/skills_bundle/claude-run-train/README.md +1 -0
  206. phase_loop_runtime/skills_bundle/claude-run-train/SKILL.md +75 -0
  207. phase_loop_runtime/skills_bundle/claude-skill-editor/README.md +1 -0
  208. phase_loop_runtime/skills_bundle/claude-skill-editor/SKILL.md +243 -0
  209. phase_loop_runtime/skills_bundle/claude-skill-editor/assets/editor_prompt.md +72 -0
  210. phase_loop_runtime/skills_bundle/claude-skill-improvement-planner/README.md +1 -0
  211. phase_loop_runtime/skills_bundle/claude-skill-improvement-planner/SKILL.md +249 -0
  212. phase_loop_runtime/skills_bundle/claude-skill-improvement-planner/assets/aggregator_prompt.md +79 -0
  213. phase_loop_runtime/skills_bundle/claude-task-contextualizer/README.md +1 -0
  214. phase_loop_runtime/skills_bundle/claude-task-contextualizer/SKILL.md +74 -0
  215. phase_loop_runtime/skills_bundle/claude-task-contextualizer/references/task-templates.md +103 -0
  216. phase_loop_runtime/skills_bundle/codex-advisor-board/README.md +1 -0
  217. phase_loop_runtime/skills_bundle/codex-advisor-board/SKILL.md +38 -0
  218. phase_loop_runtime/skills_bundle/codex-advisor-panel/README.md +1 -0
  219. phase_loop_runtime/skills_bundle/codex-advisor-panel/SKILL.md +38 -0
  220. phase_loop_runtime/skills_bundle/codex-execute-detailed/README.md +1 -0
  221. phase_loop_runtime/skills_bundle/codex-execute-detailed/SKILL.md +154 -0
  222. phase_loop_runtime/skills_bundle/codex-execute-phase/README.md +1 -0
  223. phase_loop_runtime/skills_bundle/codex-execute-phase/SKILL.md +231 -0
  224. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/allocate_worktree_name.sh +33 -0
  225. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/audit_lane_file_touches.py +197 -0
  226. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/cleanup_lane_worktrees.sh +103 -0
  227. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/parent_tree_leakage_check.sh +125 -0
  228. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/post_merge_import_smoke.sh +62 -0
  229. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/pre_merge_destructiveness_check.sh +127 -0
  230. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/resolve_branch_from_sha.sh +51 -0
  231. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/state.py +274 -0
  232. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/sweep_stale_worktrees.sh +62 -0
  233. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/team_teardown.sh +32 -0
  234. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/validate_plan_doc.py +642 -0
  235. phase_loop_runtime/skills_bundle/codex-execute-phase/scripts/verify_harness.sh +96 -0
  236. phase_loop_runtime/skills_bundle/codex-phase-loop/README.md +1 -0
  237. phase_loop_runtime/skills_bundle/codex-phase-loop/SKILL.md +248 -0
  238. phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/README.md +1 -0
  239. phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/SKILL.md +150 -0
  240. phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/assets/review_prompt.md +19 -0
  241. phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/references/parallelization-heuristics.md +111 -0
  242. phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/references/roadmap-template.md +193 -0
  243. phase_loop_runtime/skills_bundle/codex-phase-roadmap-builder/scripts/validate_roadmap.py +32 -0
  244. phase_loop_runtime/skills_bundle/codex-plan-detailed/README.md +1 -0
  245. phase_loop_runtime/skills_bundle/codex-plan-detailed/SKILL.md +119 -0
  246. phase_loop_runtime/skills_bundle/codex-plan-detailed/assets/review_prompt.md +25 -0
  247. phase_loop_runtime/skills_bundle/codex-plan-phase/README.md +1 -0
  248. phase_loop_runtime/skills_bundle/codex-plan-phase/SKILL.md +307 -0
  249. phase_loop_runtime/skills_bundle/codex-plan-phase/assets/review_prompt.md +17 -0
  250. phase_loop_runtime/skills_bundle/codex-plan-phase/scripts/validate_plan_doc.py +1092 -0
  251. phase_loop_runtime/skills_bundle/codex-run-train/README.md +1 -0
  252. phase_loop_runtime/skills_bundle/codex-run-train/SKILL.md +75 -0
  253. phase_loop_runtime/skills_bundle/codex-skill-editor/README.md +1 -0
  254. phase_loop_runtime/skills_bundle/codex-skill-editor/SKILL.md +94 -0
  255. phase_loop_runtime/skills_bundle/codex-skill-editor/assets/editor_prompt.md +72 -0
  256. phase_loop_runtime/skills_bundle/codex-skill-improvement-planner/README.md +1 -0
  257. phase_loop_runtime/skills_bundle/codex-skill-improvement-planner/SKILL.md +114 -0
  258. phase_loop_runtime/skills_bundle/codex-skill-improvement-planner/assets/aggregator_prompt.md +79 -0
  259. phase_loop_runtime/skills_bundle/codex-task-contextualizer/README.md +1 -0
  260. phase_loop_runtime/skills_bundle/codex-task-contextualizer/SKILL.md +102 -0
  261. phase_loop_runtime/skills_bundle/codex-task-contextualizer/references/task-templates.md +103 -0
  262. phase_loop_runtime/skills_bundle/gemini-advisor-board/README.md +1 -0
  263. phase_loop_runtime/skills_bundle/gemini-advisor-board/SKILL.md +38 -0
  264. phase_loop_runtime/skills_bundle/gemini-advisor-panel/README.md +1 -0
  265. phase_loop_runtime/skills_bundle/gemini-advisor-panel/SKILL.md +38 -0
  266. phase_loop_runtime/skills_bundle/gemini-execute-detailed/README.md +1 -0
  267. phase_loop_runtime/skills_bundle/gemini-execute-detailed/SKILL.md +144 -0
  268. phase_loop_runtime/skills_bundle/gemini-execute-phase/README.md +1 -0
  269. phase_loop_runtime/skills_bundle/gemini-execute-phase/SKILL.md +198 -0
  270. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/allocate_worktree_name.sh +33 -0
  271. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/audit_lane_file_touches.py +197 -0
  272. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/cleanup_lane_worktrees.sh +103 -0
  273. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/parent_tree_leakage_check.sh +125 -0
  274. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/post_merge_import_smoke.sh +62 -0
  275. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/pre_merge_destructiveness_check.sh +127 -0
  276. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/resolve_branch_from_sha.sh +51 -0
  277. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/state.py +274 -0
  278. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/sweep_stale_worktrees.sh +62 -0
  279. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/team_teardown.sh +32 -0
  280. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/validate_plan_doc.py +642 -0
  281. phase_loop_runtime/skills_bundle/gemini-execute-phase/scripts/verify_harness.sh +96 -0
  282. phase_loop_runtime/skills_bundle/gemini-phase-loop/README.md +1 -0
  283. phase_loop_runtime/skills_bundle/gemini-phase-loop/SKILL.md +111 -0
  284. phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/README.md +1 -0
  285. phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/SKILL.md +147 -0
  286. phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/assets/review_prompt.md +19 -0
  287. phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/references/parallelization-heuristics.md +111 -0
  288. phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/references/roadmap-template.md +193 -0
  289. phase_loop_runtime/skills_bundle/gemini-phase-roadmap-builder/scripts/validate_roadmap.py +32 -0
  290. phase_loop_runtime/skills_bundle/gemini-plan-detailed/README.md +1 -0
  291. phase_loop_runtime/skills_bundle/gemini-plan-detailed/SKILL.md +119 -0
  292. phase_loop_runtime/skills_bundle/gemini-plan-detailed/assets/review_prompt.md +25 -0
  293. phase_loop_runtime/skills_bundle/gemini-plan-phase/README.md +1 -0
  294. phase_loop_runtime/skills_bundle/gemini-plan-phase/SKILL.md +217 -0
  295. phase_loop_runtime/skills_bundle/gemini-plan-phase/assets/review_prompt.md +17 -0
  296. phase_loop_runtime/skills_bundle/gemini-plan-phase/scripts/validate_plan_doc.py +1092 -0
  297. phase_loop_runtime/skills_bundle/gemini-run-train/README.md +1 -0
  298. phase_loop_runtime/skills_bundle/gemini-run-train/SKILL.md +75 -0
  299. phase_loop_runtime/skills_bundle/gemini-skill-editor/README.md +1 -0
  300. phase_loop_runtime/skills_bundle/gemini-skill-editor/SKILL.md +87 -0
  301. phase_loop_runtime/skills_bundle/gemini-skill-editor/assets/editor_prompt.md +72 -0
  302. phase_loop_runtime/skills_bundle/gemini-skill-improvement-planner/README.md +1 -0
  303. phase_loop_runtime/skills_bundle/gemini-skill-improvement-planner/SKILL.md +109 -0
  304. phase_loop_runtime/skills_bundle/gemini-skill-improvement-planner/assets/aggregator_prompt.md +79 -0
  305. phase_loop_runtime/skills_bundle/gemini-task-contextualizer/README.md +1 -0
  306. phase_loop_runtime/skills_bundle/gemini-task-contextualizer/SKILL.md +98 -0
  307. phase_loop_runtime/skills_bundle/gemini-task-contextualizer/references/task-templates.md +103 -0
  308. phase_loop_runtime/skills_bundle/opencode-advisor-board/README.md +1 -0
  309. phase_loop_runtime/skills_bundle/opencode-advisor-board/SKILL.md +38 -0
  310. phase_loop_runtime/skills_bundle/opencode-advisor-panel/README.md +1 -0
  311. phase_loop_runtime/skills_bundle/opencode-advisor-panel/SKILL.md +38 -0
  312. phase_loop_runtime/skills_bundle/opencode-execute-detailed/README.md +1 -0
  313. phase_loop_runtime/skills_bundle/opencode-execute-detailed/SKILL.md +144 -0
  314. phase_loop_runtime/skills_bundle/opencode-execute-phase/README.md +1 -0
  315. phase_loop_runtime/skills_bundle/opencode-execute-phase/SKILL.md +196 -0
  316. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/allocate_worktree_name.sh +33 -0
  317. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/audit_lane_file_touches.py +197 -0
  318. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/cleanup_lane_worktrees.sh +103 -0
  319. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/parent_tree_leakage_check.sh +125 -0
  320. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/post_merge_import_smoke.sh +62 -0
  321. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/pre_merge_destructiveness_check.sh +127 -0
  322. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/resolve_branch_from_sha.sh +51 -0
  323. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/state.py +274 -0
  324. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/sweep_stale_worktrees.sh +62 -0
  325. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/team_teardown.sh +32 -0
  326. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/validate_plan_doc.py +642 -0
  327. phase_loop_runtime/skills_bundle/opencode-execute-phase/scripts/verify_harness.sh +96 -0
  328. phase_loop_runtime/skills_bundle/opencode-phase-loop/README.md +1 -0
  329. phase_loop_runtime/skills_bundle/opencode-phase-loop/SKILL.md +113 -0
  330. phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/README.md +1 -0
  331. phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/SKILL.md +147 -0
  332. phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/assets/review_prompt.md +19 -0
  333. phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/references/parallelization-heuristics.md +111 -0
  334. phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/references/roadmap-template.md +193 -0
  335. phase_loop_runtime/skills_bundle/opencode-phase-roadmap-builder/scripts/validate_roadmap.py +32 -0
  336. phase_loop_runtime/skills_bundle/opencode-plan-detailed/README.md +1 -0
  337. phase_loop_runtime/skills_bundle/opencode-plan-detailed/SKILL.md +119 -0
  338. phase_loop_runtime/skills_bundle/opencode-plan-detailed/assets/review_prompt.md +25 -0
  339. phase_loop_runtime/skills_bundle/opencode-plan-phase/README.md +1 -0
  340. phase_loop_runtime/skills_bundle/opencode-plan-phase/SKILL.md +211 -0
  341. phase_loop_runtime/skills_bundle/opencode-plan-phase/assets/review_prompt.md +17 -0
  342. phase_loop_runtime/skills_bundle/opencode-plan-phase/scripts/validate_plan_doc.py +1092 -0
  343. phase_loop_runtime/skills_bundle/opencode-run-train/README.md +1 -0
  344. phase_loop_runtime/skills_bundle/opencode-run-train/SKILL.md +75 -0
  345. phase_loop_runtime/skills_bundle/opencode-skill-editor/README.md +1 -0
  346. phase_loop_runtime/skills_bundle/opencode-skill-editor/SKILL.md +87 -0
  347. phase_loop_runtime/skills_bundle/opencode-skill-editor/assets/editor_prompt.md +72 -0
  348. phase_loop_runtime/skills_bundle/opencode-skill-improvement-planner/README.md +1 -0
  349. phase_loop_runtime/skills_bundle/opencode-skill-improvement-planner/SKILL.md +109 -0
  350. phase_loop_runtime/skills_bundle/opencode-skill-improvement-planner/assets/aggregator_prompt.md +79 -0
  351. phase_loop_runtime/skills_bundle/opencode-task-contextualizer/README.md +1 -0
  352. phase_loop_runtime/skills_bundle/opencode-task-contextualizer/SKILL.md +98 -0
  353. phase_loop_runtime/skills_bundle/opencode-task-contextualizer/references/task-templates.md +103 -0
  354. phase_loop_runtime/state.py +156 -0
  355. phase_loop_runtime/state_degradation.py +136 -0
  356. phase_loop_runtime/state_ops.py +676 -0
  357. phase_loop_runtime/train_ledger.py +215 -0
  358. phase_loop_runtime/train_roadmap.py +339 -0
  359. phase_loop_runtime/train_runner.py +1197 -0
  360. phase_loop_runtime/verification_evidence.py +650 -0
  361. phase_loop_runtime/verification_evidence_validator.py +75 -0
  362. phase_loop_runtime/visual_evidence_validator.py +36 -0
  363. phase_loop_runtime/worker_pool.py +123 -0
  364. phase_loop_runtime/worktree_index.py +270 -0
  365. phase_loop_runtime-0.2.0.data/data/share/phase-loop-runtime/protocol/protocol.md +2475 -0
  366. phase_loop_runtime-0.2.0.dist-info/METADATA +106 -0
  367. phase_loop_runtime-0.2.0.dist-info/RECORD +370 -0
  368. phase_loop_runtime-0.2.0.dist-info/WHEEL +5 -0
  369. phase_loop_runtime-0.2.0.dist-info/entry_points.txt +9 -0
  370. phase_loop_runtime-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,776 @@
1
+ ---
2
+ name: claude-plan-phase
3
+ description: "Harness Code phase planner for a versioned roadmap phase. Produces an interface-freeze + swim-lane document for parallel execution. Use in plan mode. Supports --consensus for multi-agent architectural consensus across named Plan teammates."
4
+ ---
5
+
6
+ # <harness>-plan-phase
7
+
8
+ ## Runtime State
9
+
10
+ For reflections, handoffs, and latest handoff pointers, follow `<harness>-config/shared/runtime-state.md`. This repo/branch/run-isolated contract supersedes any older flat closeout examples retained for historical context in this skill.
11
+
12
+ `shared/phase-loop/protocol.md` is the canonical shared contract for
13
+ execution-ready plan metadata, including `phase_loop_plan_version: 1`,
14
+ `roadmap_sha256`, optional `Dispatch Hints`, and downstream roadmap-amendment
15
+ rules.
16
+
17
+ When this skill runs through the live phase-loop adapter, the child launch is a
18
+ non-interactive `<harness> -p` session and the final response must still include a
19
+ shared `automation:` closeout with `verification_status`. The repo-injected
20
+ workflow bundle remains authoritative whether the adapter delivers it inline or
21
+ through the run-local context-file fallback.
22
+ That repo-owned bundle includes the full Harness workflow pack
23
+ (`<harness>-phase-roadmap-builder`, `<harness>-plan-phase`,
24
+ `<harness>-execute-phase`, and `<harness>-phase-loop`) and does not depend on
25
+ installed bridge skills under `resolve_skill_bundle_root("claude")/`.
26
+
27
+ ## Phase-Loop Adapter Mode
28
+
29
+ When the prompt or run-local context file starts with a concrete
30
+ `<harness>-plan-phase <roadmap> <phase>` command from `.codex/phase-loop/runs/`,
31
+ this adapter mode overrides the delegation-first interactive workflow below.
32
+
33
+ - Do not read installed handoffs under `resolve_skill_bundle_root("claude")/**`; the run-local
34
+ phase-loop context is the only predecessor context.
35
+ - Do not call `ToolSearch`, `TaskCreate`, `TeamCreate`, `TeamDelete`, `Agent`,
36
+ `SendMessage`, `ExitPlanMode`, `advisor()`, or `AskUserQuestion`.
37
+ - Resolve the roadmap and phase from the first command line, read only the
38
+ repo-local roadmap and relevant files, and write the repo-local
39
+ `plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md` artifact directly.
40
+ - The plan artifact frontmatter is part of the trust contract. `roadmap:` MUST
41
+ be the exact repo-relative path from repo root to the roadmap file, not a
42
+ shortened basename or suffix, and `roadmap_sha256:` MUST be the SHA-256 of
43
+ that exact roadmap file.
44
+ - Do not read or write `~/.claude/**` reflection or handoff files, and do not
45
+ edit `.codex/phase-loop/` runner artifacts. Adapter-mode closeout happens
46
+ only through stdout plus repo-local artifacts.
47
+ - If ambiguity, access, dirty-state, or missing-input handling would normally
48
+ ask a user, stop and emit a shared `automation:` closeout with
49
+ `status: blocked`, `human_required` set accurately, the frozen
50
+ `blocker_class`, concrete `blocker_summary`, and `verification_status:
51
+ blocked`.
52
+ - End stdout with one shared `automation:` closeout. Do not wait for
53
+ interactive approval after the artifact is written.
54
+
55
+ ## Dispatch Hints
56
+
57
+ When non-default executor policy is needed, add an optional `## Dispatch Hints`
58
+ section using the frozen vocabulary from `shared/phase-loop/protocol.md`
59
+ instead of inventing Harness-only plan metadata.
60
+
61
+ When model, effort, work-unit defaults, lane-specific policy, fallback, policy
62
+ source, or override reason must also be frozen, add optional `## Execution
63
+ Policy` using the protocol syntax. Precedence is CLI/operator override,
64
+ phase-plan policy, roadmap policy, `Dispatch Hints`, then registry defaults;
65
+ silent downgrade is forbidden unless explicit fallback or default inheritance
66
+ is recorded.
67
+
68
+ ## Model & Effort Tiering (right-size per lane, don't default to the ceiling)
69
+
70
+ The runtime resolves one heavy model per executor (`codex` → `gpt-5.5`,
71
+ `claude` → `claude-opus-4-8`), so **reasoning effort is the primary cost dial.**
72
+ The normalized effort ladder, cheapest first, is:
73
+
74
+ `minimal` < `low` < `medium` < `high` < `xhigh` < `max`
75
+
76
+ Registry action defaults today are blunt — `plan`/`roadmap`/`review` = `high`,
77
+ `execute`/`repair` = `medium` — applied uniformly regardless of how hard the
78
+ lane actually is. As the planner you have the complexity signal the runtime
79
+ lacks; use it:
80
+
81
+ - **Default each lane to the cheapest effort you believe will succeed**, not the
82
+ action default. A mechanical edit, a config bump, a docs-sweep lane, or a
83
+ rename rarely needs more than `low`/`minimal`.
84
+ - **Escalate only with a stated reason.** Subtle concurrency, cross-module
85
+ refactors, security-sensitive logic, or ambiguous specs justify `high`/`xhigh`;
86
+ record *why* in the rule's `reason=`.
87
+ - Express the choice in an `## Execution Policy` section the runtime parses
88
+ (selector = `default`, an action, or a lane alias):
89
+
90
+ ```
91
+ ## Execution Policy
92
+ - default: effort=low, reason=most lanes are mechanical this phase
93
+ - execute: effort=medium
94
+ - SL-3: effort=high, reason=constant-time comparison is subtly wrong-prone
95
+ - SL-7: effort=minimal, reason=docs sweep only
96
+ ```
97
+
98
+ Two hard syntax rules the parser enforces (a malformed line fails the whole
99
+ section, not just that line):
100
+
101
+ - **Lane selectors are the numeric lane id** (`SL-3`, `P2A` → use `lane <name>:`
102
+ for non-numeric names). `SL-DOCS`-style names are rejected; write `SL-7` or
103
+ `lane SL-DOCS: …`.
104
+ - **No commas inside a `reason=` value** — the comma separates assignments, so
105
+ `reason=docs sweep, no logic` breaks parsing. Keep reasons comma-free.
106
+
107
+ Operator `--model`/`--effort` and CLI overrides still win, so this never blocks
108
+ a human from forcing a tier. The goal is to stop paying `high` for a one-line
109
+ change by default.
110
+
111
+ **Model class (vendor-agnostic role).** Alongside effort, a rule may set a
112
+ `model_class` — `planner` / `implementer` / `worker` — which resolves to a
113
+ concrete model per executor. The shipped `model_policy` already routes planning
114
+ to the planner class at `max` and implementation to the implementer class, so
115
+ you rarely set this by hand; reach for it when a specific lane wants a cheaper
116
+ worker-class model for a bounded, schema-checked subtask. The `worker` class
117
+ must never author a final patch, and an executor that can't run at `max` (e.g.
118
+ gemini) is never the max-effort planner of record.
119
+
120
+ **Run mode is separate.** `model_policy` (what model) is independent of
121
+ `run_mode` (autonomous default vs opt-in governed review). Planning a phase does
122
+ not enable the governed panel; that is an operator opt-in.
123
+
124
+ ## Planner Literal Validation
125
+
126
+ Before writing a plan document to the project path, validate the complete draft
127
+ with `phase_loop_runtime.planner_validation.validate_plan_dispatch_hints`. In
128
+ Plan Mode, run this after the scratch draft is fully emitted and before
129
+ `ExitPlanMode`; in adapter/default flows, run it before writing
130
+ `plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md`. If findings are returned, do not
131
+ write the plan artifact. Stop with a validation_failed closeout:
132
+ `terminal_status=blocked`, `verification_status=blocked`,
133
+ `blocker_class=contract_bug`, `human_required=false`, and a non-secret
134
+ `blocker_summary` listing each finding's `field_path`, `literal`,
135
+ `allowed_values`, and `suggested_fix`.
136
+
137
+ The validator imports its defaults from `phase_loop_runtime.models`:
138
+ `DISPATCH_CAPABILITIES`, `EXECUTORS`, and `PRODUCT_LOOP_ACTIONS`. Keep these
139
+ allowed values inline in the planner prompt so invented literals are visibly
140
+ out of contract:
141
+
142
+ - `dispatch_hints.required_capabilities`: `live_launch`, `dry_run`, `skill_bundle_injection`, `inline_instructions`, `context_file_instructions`, `manual_handoff`, `subagents`, `explicit_approval_controls`, `structured_output`, `browser_automation`
143
+ - `dispatch_hints.executors[]`: `codex`, `claude`, `gemini`, `opencode`, `pi`, `command`, `manual`
144
+ - `## Execution Policy` selectors: `work-unit defaults`, `roadmap`, `plan`, `execute`, `repair`, `review`, `maintain-skills`, and lane selectors such as `SL-2`
145
+ - `terminal_status`: `unplanned`, `planned`, `executing`, `executed`, `awaiting_phase_closeout`, `complete`, `blocked`, `unknown`
146
+ - `verification_status`: `not_run`, `passed`, `failed`, `blocked`
147
+ - `blocker_class`: `missing_secret`, `account_or_billing_setup`, `admin_approval`, `destructive_operation`, `ambiguous_roadmap_selection`, `product_decision_missing`, `dirty_worktree_conflict`, `branch_sync_conflict`, `stalled_child_observation`, `repeated_verification_failure`, `sandbox_command_restriction`, `upstream_phase_unmet`, `contract_bug`, `gold_record_amendment`, `unretryable_external_outage`, `stuck_loop`
148
+
149
+ Architecture-first planner for a single phase of a multi-phase specification. Produces a plan document containing interface freezes, swim lanes with disjoint file ownership, a lane DAG, per-lane task lists (test → impl → verify), and testable acceptance criteria. Designed to be run in **plan mode** and handed off to `<harness>-execute-phase` for parallel execution.
150
+
151
+ ## When to use
152
+
153
+ - The input is a multi-phase spec (e.g., `specs/phase-plans-v1.md`) and the user wants to plan a specific phase.
154
+ - The work touches more than one area of the codebase and would benefit from parallel lane execution.
155
+ - You need interface contracts frozen before lanes diverge.
156
+
157
+ ## When NOT to use
158
+
159
+ - Single-file, single-concern change → use `/<harness>-plan-detailed` instead.
160
+ - Pure research / "how does X work" → use `Agent(subagent_type: "Explore")` directly, no plan doc needed.
161
+ - No phase structure in the spec → use `/<harness>-plan-detailed` or ad-hoc planning.
162
+
163
+ ## Inputs
164
+
165
+ | Arg | Required | Meaning |
166
+ |---|---|---|
167
+ | `<spec-path>` | no | Path to the spec file (relative to repo root). Default: auto-detected `specs/phase-plans-v*.md` at the highest version. |
168
+ | `<phase-name-or-id>` | yes | A phase heading, short alias (`P1`–`P7`), or any fuzzy match. Ambiguous → stop and ask via `AskUserQuestion`. |
169
+ | `--output <path>` | no | Override the default output path. Default: `plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md`. `<PHASE_ALIAS>` MUST be uppercase exactly as declared in the roadmap (e.g., `FOUND`, `DESIGNFOUND`); lowercase or alternate filename variants force an extra plan-iteration roundtrip because the runner uses the uppercase alias to locate the plan artifact. |
170
+ | `--consensus` | no | Enable multi-agent architectural consensus (2–3 Plan teammates with different framings). |
171
+ | `--review-external` | no | After writing the plan doc, run Gemini + Codex CLIs in parallel to review it. Requires `gemini` and `codex` installed and authenticated. Produces a `_reviews.md` sibling file. |
172
+
173
+ Repos may supply a phase alias table (JSON file) via `$PLAN_PHASE_ALIASES` or fall back to the built-in `P1`–`P7` table. If the alias isn't recognized and no custom table is set, stop and ask via `AskUserQuestion` with the actual spec headings.
174
+
175
+ ## Environment variables
176
+
177
+ | Variable | Default | Meaning |
178
+ |---|---|---|
179
+ | `PLAN_SPEC` | Auto-detected highest `specs/phase-plans-v*.md` | Path to the spec file. |
180
+ | `PLAN_VERSION` | Extracted `v\d+` from spec filename | Version string embedded in output filename. |
181
+ | `PLAN_PHASE_ALIASES` | Built-in alias table | Path to a JSON file mapping alias → phase heading. |
182
+
183
+ Example `.env`:
184
+
185
+ ```sh
186
+ PLAN_SPEC=specs/phase-plans-v1.md
187
+ ```
188
+
189
+ Invocation examples:
190
+
191
+ ```
192
+ /<harness>-plan-phase P1
193
+ /<harness>-plan-phase P3 --consensus
194
+ /<harness>-plan-phase P3 --review-external
195
+ /<harness>-plan-phase specs/roadmap.md "Phase 3: Billing" --consensus --review-external
196
+ ```
197
+
198
+ ## Expected helpers
199
+
200
+ The skill references these `_shared/` helpers. Each degrades gracefully if absent:
201
+
202
+ - `_shared/next_reflection_path.py` — legacy helper only; current closeout writes reflections to `resolve_skill_bundle_root("codex")/<harness>-plan-phase/reflections/<repo_hash>/<branch_slug>/<run_id>.md`.
203
+ - `_shared/review_with_cli.py` — required only for `--review-external`. No fallback; if absent, surface an `AskUserQuestion` with `[skip review this run, abort]`.
204
+ - `_shared/scaffold_docs_catalog.py` — used by `SL-docs.1`. If absent, the docs lane records "docs-catalog rescan helper unavailable; manual catalog audit" in its commit message and proceeds.
205
+
206
+ ## Deferred tool preloading
207
+
208
+ Load tools used later in a single query so mid-workflow calls don't pay a round-trip:
209
+
210
+ ```
211
+ ToolSearch(query: "select:TaskCreate,AskUserQuestion,ExitPlanMode")
212
+ ```
213
+
214
+ ## Workflow (delegation-first)
215
+
216
+ The main thread is an orchestrator only: brief specialists, synthesize output, enforce consensus, write the final doc, emit tasks. See `## Teamwork & delegation posture` for the posture rules.
217
+
218
+ ### Step 0 — Read predecessor handoff (if present)
219
+
220
+ Handoffs are keyed on the current repo so each workspace has its own slot. Resolve both candidate paths first:
221
+
222
+ ```bash
223
+ REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
224
+ if [ -z "$REPO_ROOT" ]; then
225
+ REPO_KEY="_no-git-$(pwd | sha1sum | cut -c1-12)"
226
+ else
227
+ REPO_KEY="$(basename "$REPO_ROOT")-$(printf '%s' "$REPO_ROOT" | sha1sum | cut -c1-12)"
228
+ fi
229
+ ROADMAP_HANDOFF="$(python3 - <<'PYH'
230
+ from importlib import util
231
+ from pathlib import Path
232
+ repo = Path.cwd().resolve()
233
+ spec = util.spec_from_file_location("handoff_path", repo / "shared" / "phase-loop" / "handoff_path.py")
234
+ mod = util.module_from_spec(spec)
235
+ spec.loader.exec_module(mod)
236
+ print(mod.resolve_handoff_path(repo, "<harness>-phase-roadmap-builder"))
237
+ PYH
238
+ )"
239
+ EXECUTE_HANDOFF="$(python3 - <<'PYH'
240
+ from importlib import util
241
+ from pathlib import Path
242
+ repo = Path.cwd().resolve()
243
+ spec = util.spec_from_file_location("handoff_path", repo / "shared" / "phase-loop" / "handoff_path.py")
244
+ mod = util.module_from_spec(spec)
245
+ spec.loader.exec_module(mod)
246
+ print(mod.resolve_handoff_path(repo, "<harness>-execute-phase"))
247
+ PYH
248
+ )"
249
+ ```
250
+
251
+ The predecessor skill may be either:
252
+
253
+ - `<harness>-phase-roadmap-builder` (first time planning a phase against a new roadmap) → `$ROADMAP_HANDOFF`
254
+ - `<harness>-execute-phase` (planning the next phase after a prior one finished executing) → `$EXECUTE_HANDOFF`
255
+
256
+ Check both paths. If both exist, pick the one with the newer `timestamp:` in its metadata header. If only one exists, use it. If neither, proceed standalone.
257
+
258
+ Defense-in-depth checks (the repo-key scheme prevents the common cross-project case, but these still catch symlink-shared workspaces, manual file copies, and stale handoffs):
259
+
260
+ - `from:` must match the expected predecessor.
261
+ - Timestamp must be recent (<7 days).
262
+ - Every `artifact:` path must resolve under `$(git rev-parse --show-toplevel)`.
263
+
264
+ On any failure, flag via `AskUserQuestion` with `[use anyway, ignore, abort]`.
265
+
266
+ Fold the handoff's "Open items" and "Repo-specific gotchas" into the brief given to Step 2's Explore teammates so they know what to watch for.
267
+
268
+ ### Step 1 — Resolve spec path, phase, and PHASE_ID
269
+
270
+ **Spec path resolution (in order):**
271
+ 1. `$PLAN_SPEC` env var → use verbatim.
272
+ 2. `<spec-path>` arg → use verbatim.
273
+ 3. Glob `specs/phase-plans-v*.md`; pick the highest version.
274
+ 4. Else any `specs/*.md` if exactly one exists → use it and note the assumption.
275
+ 5. Else stop and ask via `AskUserQuestion`.
276
+
277
+ **Version string** (for output filename): `$PLAN_VERSION` → pattern `v\d+` in filename → `v1` default.
278
+
279
+ **Phase alias table**: `$PLAN_PHASE_ALIASES` (JSON file) → built-in table.
280
+
281
+ **Phase name**: short alias → fuzzy match → 0 matches: stop + ask → multiple matches: stop + disambiguate.
282
+
283
+ **PHASE_ALIAS**: the resolved short alias in lowercase (e.g., `p1`). If none exists, use `phase-<N>`.
284
+
285
+ **Output path**: `--output` override, else `plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md`.
286
+
287
+ ### Step 2 — Parallel reconnaissance via Explore teammates
288
+
289
+ Preflight: call `TeamDelete` defensively to flush any inherited team context from a predecessor skill run, then `TeamCreate` a fresh team named for this run before dispatching any `Agent` calls. Recognize these error signatures as benign on the `TeamDelete`: `Team X does not exist` or `already leading team X`.
290
+
291
+ Launch up to 3 `Agent(subagent_type: "Explore")` calls in a single message. One per major area the phase touches. Each Agent call MUST set `name:` so it can be re-addressed later via `SendMessage`.
292
+
293
+ Teammate-naming template: `explore-<area>` (e.g., `explore-schema`, `explore-workers`).
294
+
295
+ Each brief must include:
296
+
297
+ - The phase's Objective + Exit criteria copied verbatim from the spec.
298
+ - A scoped question: "Map existing code in `<paths>` relevant to this phase. Surface: (a) existing utilities/patterns to reuse, (b) current type/schema/interface shapes that constrain the design, (c) places that will need to change, (d) hidden coupling that would break worktree isolation."
299
+ - A 1–2 sentence architecture context: how these paths fit the larger system.
300
+ - Related files the teammate should know about but not rewrite (type defs, tests, shared config).
301
+ - A preload instruction: "Load `SendMessage` via `ToolSearch(query: \"select:SendMessage\")` as your first action so you can reply without a round-trip."
302
+ - An explicit deliverable statement: "Your deliverable is a `SendMessage` to team-lead with your findings; do not rely on text output or idle without reporting."
303
+ - A length guideline: "Be as short as possible while citing every load-bearing file:line. No fixed word cap."
304
+
305
+ Apply the `/<harness>-task-contextualizer` checklist to every brief.
306
+
307
+ Block until all return. Their findings populate `## Context`.
308
+
309
+ ### Step 2.5 — Explore teammate recovery
310
+
311
+ If a teammate idles without a substantive reply, send one targeted `SendMessage` nudge naming the missing deliverable. On a second non-response, proceed with main-thread read-only reconnaissance rather than respawning the teammate.
312
+
313
+ ### Step 3 — Architectural decisions
314
+
315
+ **With `--consensus`**: Launch 2–3 `Agent(subagent_type: "Plan")` calls in a single message, each with a distinct framing:
316
+
317
+ | Name | Framing |
318
+ |---|---|
319
+ | `arch-minimal` | Minimal change. Preserve current module boundaries. Add, don't refactor. |
320
+ | `arch-clean` | Clean architecture. Willing to refactor to make the design right. |
321
+ | `arch-parallel` | Maximize parallelism. Prefer more, smaller lanes over fewer, fatter lanes, even if it adds interface surface. |
322
+
323
+ Each teammate's brief includes: the spec phase section, all Explore teammate findings, and its framing. Apply the `/<harness>-task-contextualizer` checklist — architecture context and related-files list carry over from the Explore briefs. Each must return: (1) proposed interface freezes, (2) proposed lane decomposition with file ownership, (3) rationale, (4) known risks.
324
+
325
+ Synthesize per the Consensus mechanism below. If round 1 doesn't converge, re-address the same named teammates via `SendMessage` (not new `Agent` calls) with the specific disagreement surfaced. Max 2 rounds.
326
+
327
+ **Without `--consensus`**: Launch 1 `Agent(subagent_type: "Plan", name: "arch-baseline")` for baseline architecture decisions.
328
+
329
+ ## Preamble lane archetype
330
+
331
+ The "preamble lane" concentrates single-writer files AND freezes interface shapes on Day 1, letting all downstream lanes run in parallel without contending for the same index/config/init file.
332
+
333
+ **When to use**: ≥2 parallel lanes would otherwise need to touch the same index/config/init file, OR ≥2 lanes consume the same frozen type.
334
+
335
+ Template sketch:
336
+
337
+ ```markdown
338
+ ### SL-0 — Preamble (interface + single-writer setup)
339
+ - **Scope**: Freeze shared types and stub the single-writer files every downstream lane will import from.
340
+ - **Owned files**: `src/index.ts`, `src/config.ts`, `src/__init__.py` (list every shared index/config/init file)
341
+ - **Interfaces provided**: `FooContract`, `BarRegistry`, `WorkerRouter` (frozen type names)
342
+ - **Interfaces consumed**: (none)
343
+ - **Parallel-safe**: no (terminal in preamble position — no downstream lane modifies SL-0's files)
344
+ - **Tasks**: one test task pinning the frozen type shapes; one impl task adding the stubs; one verify task
345
+ ```
346
+
347
+ Downstream lanes depend on `SL-0` and consume its frozen interfaces; they must not list any SL-0 owned file in their own `Owned files`.
348
+
349
+ ### Step 4 — Lane decomposition (main thread)
350
+
351
+ Synthesize Explore + Plan output into swim lanes. For each lane, determine:
352
+
353
+ - **Scope** — one sentence.
354
+ - **Owned files** — glob list. Must be disjoint from every other lane's globs. Before emitting the plan, scan every lane's owned files for overlap with every other lane in the same wave. If overlap is found, either (a) move the shared file into a preamble lane that all dependents consume, or (b) collapse the overlapping lanes into a single lane. Overlap surviving into the final plan triggers `overlapping_write_ownership` lane-IR diagnostic at runtime and refuses execution (Pattern B from 2026-05-25 runner failure analysis). Owned files MUST enumerate the COMPLETE set the executor will touch — not just headline source files. For every primary file added or modified, include matching test file(s), snapshot file(s), generated artifact(s), `.env.example` / `.env.local.example` if env shape changes, `package.json` + `pnpm-lock.yaml` (or equivalent) if dependencies change, and migration files matching the timestamp pattern. Under-enumeration causes the closeout's `phase_owned_dirty` check to fail closed (Pattern A from 2026-05-25 — hit ~70% of phases in that drive).
355
+ - **Interfaces provided** — symbols, types, endpoints, migrations this lane publishes.
356
+ - **Interfaces consumed** — symbols this lane depends on from other lanes.
357
+ - **Parallel-safe** — `yes` / `no` / `mixed` (with explanation if not `yes`).
358
+
359
+ Run the Lane validation checklist (below) before proceeding. If it fails, return to Step 3 with the failure noted.
360
+
361
+ ### Step 5 — Task authoring (main thread)
362
+
363
+ For each lane, author an ordered task list:
364
+
365
+ - One **test** task (write failing tests for the lane's contracts).
366
+ - One or more **impl** tasks (each depends on the preceding test task).
367
+ - One **verify** task (runs the full test suite for the lane, plus any integration checks).
368
+
369
+ Tasks are identified `<SL-ID>.<N>`.
370
+
371
+ **Every phase must include a terminal `SL-docs` lane** after the impl/verify lanes. See `## Docs-sweep lane template` below. No opt-out — force a conscious doc decision every phase, even if the lane ends up recording "no cross-cutting changes needed."
372
+
373
+ ### Step 6 — Emit per-lane tasks via TaskCreate
374
+
375
+ Plan-mode note: `TaskCreate` writes outside the scratch file and is blocked in plan mode. Author the task bodies in-thread during Step 5 so they are ready, but defer the actual `TaskCreate` invocations until AFTER `ExitPlanMode` approval (Step 8).
376
+
377
+ For each lane, emit one `TaskCreate`:
378
+
379
+ - **Title**: `<SL-ID> — <lane name>`
380
+ - **Body**: `Depends on: <upstream SL-IDs>`, `Blocks: <downstream SL-IDs>`, `Parallel-safe: <flag>`, and the ordered child task list (`test / impl / verify`).
381
+
382
+ This makes the lane DAG visible in the user's task pane and becomes the hand-off surface for `<harness>-execute-phase`.
383
+
384
+ ### Step 7 — Write plan doc
385
+
386
+ Draft the plan in the plan-mode scratch file only. The scratch-file path is given in the plan-mode system reminder — do not guess it. Do NOT write to `plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md` yet; plan mode forbids writes outside the scratch file. The project-path copy + staging happens in the Close-out "Stage artifact" section after `ExitPlanMode` approval.
387
+
388
+ Then validate the scratch draft with
389
+ `validate_plan_dispatch_hints`. If it returns findings, stop without writing
390
+ the project-path artifact and emit the validation_failed closeout described in
391
+ `## Planner Literal Validation`. If `scripts/validate_plan_doc.py` exists
392
+ (shell test `[ -f scripts/validate_plan_doc.py ]`), run it against the scratch
393
+ file and fix any errors before `ExitPlanMode`:
394
+
395
+ ```
396
+ python scripts/validate_plan_doc.py <scratch-file-path>
397
+ ```
398
+
399
+ Otherwise walk the Lane validation checklist by hand and note manual verification in the post-approval closeout or Execution Notes. The validator checks required headings, disjoint file ownership, DAG acyclicity, grep-assertion-paired-with-tests, and eager-reexport risks.
400
+
401
+ ### Step 7.75 — Advisor review
402
+
403
+ After the plan doc is drafted in the scratch file and before `ExitPlanMode`, call `advisor()`. Expect 1–4 contract-tightening suggestions per run, typically covering: under-specified freezes, asserted-but-unverified file paths, test-outline mechanism gaps, and spec-vs-contract conflicts. Apply the findings to the scratch draft before calling `ExitPlanMode`.
404
+
405
+ ### Step 7.5 — External CLI review (only if `--review-external`)
406
+
407
+ Run the shared review script:
408
+
409
+ ```bash
410
+ python3 "$(git rev-parse --show-toplevel)/.claude/skills/_shared/review_with_cli.py" \
411
+ --artifact plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md \
412
+ --prompt-file "$(git rev-parse --show-toplevel)/.claude/skills/<harness>-plan-phase/assets/review_prompt.md" \
413
+ --out plans/phase-plan-<VERSION>-<PHASE_ALIAS>_reviews.md
414
+ ```
415
+
416
+ If the script reports the frontier-model cache is empty, it prints a discovery prompt to stderr. Surface to the user via `AskUserQuestion` with options `[run discovery now, skip review this run, abort]`.
417
+
418
+ Tell the user: "Review written to `plans/phase-plan-<VERSION>-<PHASE_ALIAS>_reviews.md`. When Gemini and Codex flag the same concern, treat it as real; divergent comments are context, not verdicts."
419
+
420
+ ### Step 8 — ExitPlanMode
421
+
422
+ Call `ExitPlanMode`. The plan doc is the approval surface. After approval, execute the deferred actions in this order: Close-out "Stage artifact" (writes the project-path `plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md` and stages it unless forbidden), then Step 6 `TaskCreate` invocations, then Close-out "Reflection + Handoff".
423
+
424
+ ## Plan document template
425
+
426
+ Use this frontmatter and these headings verbatim — the phase-loop runner trusts
427
+ the frontmatter before it trusts the plan body:
428
+
429
+ ```markdown
430
+ ---
431
+ phase_loop_plan_version: 1
432
+ phase: <PHASE_ALIAS>
433
+ roadmap: <repo-relative roadmap path, e.g. specs/phase-plans-v1.md>
434
+ roadmap_sha256: <sha256 of that roadmap file>
435
+ ---
436
+
437
+ # <PHASE_ID>: <Phase Name>
438
+
439
+ ## Context
440
+ <Synthesized from Explore teammates. What exists, what constrains the design, what will change.>
441
+
442
+ ## Interface Freeze Gates
443
+ - [ ] IF-0-<PHASE>-<N> — <one-line description of the frozen interface>
444
+ - [ ] IF-0-<PHASE>-<N+1> — …
445
+
446
+ ## Cross-Repo Gates
447
+ <Omit entirely if the phase only touches this repo.>
448
+ - [ ] IF-XR-<N> — <interface that must be frozen across repo boundaries>
449
+
450
+ ## Lane Index & Dependencies
451
+
452
+ SL-1 — <lane name>
453
+ Depends on: (none)
454
+ Blocks: SL-3, SL-4
455
+ Parallel-safe: yes
456
+
457
+ SL-2 — <lane name>
458
+ Depends on: (none)
459
+ Blocks: SL-4
460
+ Parallel-safe: yes
461
+
462
+ ## Lanes
463
+
464
+ ### SL-1 — <lane name>
465
+ - **Scope**: <one sentence>
466
+ - **Owned files**: `path/one/**`, `path/two/*.ts` (MUST be a single-line inline bullet, comma-separated backticked globs; do NOT use nested sub-bullets — the downstream file-touch auditor expects inline form)
467
+ - **Interfaces provided**: `FooContract`, `POST /api/bar`
468
+ - **Interfaces consumed**: (none)
469
+ - **Tasks**:
470
+
471
+ | Task ID | Type | Depends on | Files in scope | Tests owned | Test command |
472
+ |---|---|---|---|---|---|
473
+ | SL-1.1 | test | — | `path/one/__tests__/foo.test.ts` | `FooContract` shape | `pnpm test path/one/__tests__/foo.test.ts` |
474
+ | SL-1.2 | impl | SL-1.1 | `path/one/foo.ts` | — | — |
475
+ | SL-1.3 | verify | SL-1.2 | `path/one/**` | all SL-1 tests | `pnpm test path/one` |
476
+
477
+ ### SL-2 — <lane name>
478
+
479
+
480
+ ### SL-docs — Documentation & spec reconciliation
481
+
482
+ (See `## Docs-sweep lane template` earlier in this skill for the full lane spec. Copy it verbatim and set `Depends on:` to list every other SL-N in this phase.)
483
+
484
+ ## Execution Notes
485
+ - <Parallelism caveats, sequencing gotchas, lanes that can't be worktree-isolated (shared migrations, shared generated files), etc.>
486
+ - **Single-writer files**: <files multiple lanes might want to touch but only one is allowed to modify — e.g., barrel index files, generated types, nav config, worker router. List the owner lane for each. If a single-writer file is also touched by a later phase, name this phase's owner lane and have them author-at-plan-time any additions the later phase's consumer lanes will need. Re-opening the file from the later phase's lane adds a cross-phase serialization edge that shouldn't exist.>
487
+ - **Known destructive changes**: <any deletions a lane legitimately performs, named by file path. If empty, write "none — every lane is purely additive." This is the whitelist <harness>-execute-phase's pre-merge check uses to distinguish legitimate deletions from stale-base accidents.>
488
+ - **Expected add/add conflicts**: <if SL-0 preamble stubs a file that a later lane replaces the body of, list the file path here. The orchestrator pre-authorizes `git checkout --theirs <path>` resolution at merge time.>
489
+ - **SL-0 re-exports**: <if the preamble adds symbols to an `__init__.py`, specify the `__getattr__` lazy pattern (not top-level imports). Eager re-exports break package load when a later lane drops or renames the symbol.>
490
+ - **Worktree naming**: <harness>-execute-phase allocates unique worktree names via `scripts/allocate_worktree_name.sh`. Plan doc does not need to spell out lane worktree paths.
491
+ - **Stale-base guidance** (copy verbatim): Lane teammates working in isolated worktrees do not see sibling-lane merges automatically. If a lane finds its worktree base is pre-<first upstream dependency's merge>, it MUST stop and report rather than committing — the orchestrator will re-spawn or rebase. Silent `git reset --hard` or `git checkout HEAD~N -- …` in a stale worktree produces commits that destroy peer-lane work on `--no-ff` merge.
492
+ - (If `--consensus` was used) **Architectural choices**: <consensus summary, or unresolved disagreement with dissent recorded>
493
+
494
+ ## Acceptance Criteria
495
+ - [ ] <Testable assertion 1 drawn from the spec phase's Exit criteria>
496
+ - [ ] <Testable assertion 2>
497
+
498
+ ## Verification
499
+ <Concrete end-to-end commands to run after all lanes merge. pnpm, supabase, curl, playwright, etc.>
500
+ ```
501
+
502
+ ## ID conventions
503
+
504
+ | ID | Format | Example |
505
+ |---|---|---|
506
+ | `PHASE_ID` | Spec identifier, else `PHASE-<kebab>` | `PHASE-1-shared-semantics` |
507
+ | Lane ID | `SL-<N>` | `SL-3` |
508
+ | Task ID | `<LANE_ID>.<N>` | `SL-3.2` |
509
+ | Interface freeze | `IF-0-<PHASE>-<N>` | `IF-0-P1-1` |
510
+ | Cross-repo freeze | `IF-XR-<N>` | `IF-XR-2` |
511
+
512
+ Defaults only — if the spec already uses its own identifiers (e.g., `P1-SL-AUTH-01`), adopt those verbatim.
513
+
514
+ Any non-numeric lane alias (e.g., `SL-docs`) must still appear in the machine-readable `## Lane Index & Dependencies` block as `SL-<N>` for compatibility with downstream audit/validator tooling that expects `SL-\d+`. Its `Depends on:` line must be on its own line (not inlined with prose that could regex-match as a dependency). The alias (e.g., `SL-docs`) remains valid as the author-facing lane heading in `## Lanes`.
515
+
516
+ ## Task types & dependency rules
517
+
518
+ | Type | Purpose | Rules |
519
+ |---|---|---|
520
+ | `test` | Write failing tests that pin down the lane's contracts. | Must precede any `impl` task in the same lane. |
521
+ | `impl` | Write the code that makes the preceding tests pass. | Must depend on exactly one `test` task in the same lane. |
522
+ | `verify` | Run the full lane test suite + any integration checks. | Last task in the lane. Depends on the last `impl` task. |
523
+ | `docs` | Update cross-cutting documentation and the docs catalog. | Lives in the terminal `SL-docs` lane. Depends on every other lane's final `verify` task. |
524
+
525
+ ## Docs-sweep lane template
526
+
527
+ Every phase plan must include this as the final lane. Copy verbatim into the `## Lanes` section, adjust `Depends on:` to list every other `SL-N` in the phase, and edit the `Scope notes` if the phase has atypical docs impact.
528
+
529
+ ```markdown
530
+ ### SL-docs — Documentation & spec reconciliation
531
+
532
+ - **Scope**: Refresh the docs catalog, update cross-cutting documentation touched or invalidated by this phase's impl lanes, and append any post-execution amendments to phase specs whose interface freezes turned out wrong.
533
+ - **Owned files** (read `.claude/docs-catalog.json` for the authoritative list; a minimum set is below, but the catalog is canonical):
534
+ - Root: `README.md`, `CHANGELOG.md`, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, `SECURITY.md`, `MIGRATION.md`, `ARCHITECTURE.md`, `DESIGN.md`, `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`
535
+ - Agent indexes: `llm.txt`, `llms.txt`, `llms-full.txt`
536
+ - Service manifests: `services.json`, `openapi.yaml`/`.yml`/`.json`
537
+ - `docs/**`, `rfcs/**`, `adrs/**`
538
+ - `.claude/docs-catalog.json` (this lane maintains it)
539
+ - The current phase's section of `specs/phase-plans-v<N>.md` (append-only amendments)
540
+ - Any prior `plans/phase-plan-v<N>-<alias>.md` or prior spec phase sections whose contracts this phase invalidated (prior-phase amendments allowed)
541
+ - **Interfaces provided**: (none)
542
+ - **Interfaces consumed**: (none)
543
+ - **Parallel-safe**: no (terminal)
544
+ - **Depends on**: every other `SL-N` in this phase
545
+
546
+ **Tasks**:
547
+
548
+ | Task ID | Type | Depends on | Files in scope | Action |
549
+ |---|---|---|---|---|
550
+ | SL-docs.1 | docs | — | `.claude/docs-catalog.json` | Rescan: `python3 "$(git rev-parse --show-toplevel)/.claude/skills/_shared/scaffold_docs_catalog.py" --rescan`. Picks up any new doc files created by impl lanes; preserves `touched_by_phases` history. |
551
+ | SL-docs.2 | docs | SL-docs.1 | per catalog | For each file in the catalog, decide: does this phase's work change it? If yes, update the file and append the current phase alias to its `touched_by_phases`. If no, leave it. Record in commit message any files intentionally skipped. |
552
+ | SL-docs.3 | docs | SL-docs.2 | `specs/phase-plans-v<N>.md`, prior plans | Append `### Post-execution amendments` subsections to any phase section (current or prior) whose interface freeze was empirically wrong this run. Named freeze IDs + dated correction. |
553
+ | SL-docs.4 | verify | SL-docs.3 | — | Run any repo doc linters (`markdownlint`, `vale`, `prettier --check`, Mermaid/PlantUML render check). If none configured, no-op. |
554
+ ```
555
+
556
+ No opt-out. A phase with nothing to change still runs `SL-docs` and records that explicitly in its commit message — the audit trail.
557
+
558
+ ## Consensus mechanism (synthesis rule)
559
+
560
+ Applied by the main thread after `--consensus` Step 3a:
561
+
562
+ 1. **Unanimous** across all teammates → accept directly.
563
+ 2. **Majority (2 of 3)** → accept the majority view; record the dissenting view under `## Execution Notes > Architectural choices > Dissent`.
564
+ 3. **No majority** → re-address the same named teammates via `SendMessage` with the specific conflict surfaced. Max 1 additional round.
565
+ 4. **Still no convergence** → main thread picks (biased toward `arch-parallel` for this skill's purpose) and records the full disagreement under `## Execution Notes > Unresolved architectural disagreements`.
566
+
567
+ ## Lane validation checklist
568
+
569
+ Before writing the plan doc, verify:
570
+
571
+ - [ ] **Disjoint file ownership** — no two lanes' `Owned files` globs intersect. For generated files, call out shared-generated status in Execution Notes.
572
+ - [ ] **Owned files is inline, one line** — no nested bullets; comma-separated backticked concrete paths/globs only. Do not use prose entries such as "callsite wiring", "new migration file", "or equivalent", or "additions to"; resolve those to actual files before writing the plan.
573
+ - [ ] **DAG has no cycles** — a topological sort of `Depends on:` succeeds.
574
+ - [ ] **Every `impl` task has a preceding `test` task** in the same lane.
575
+ - [ ] **Every acceptance criterion is a testable assertion**, not prose. "Users can log in" is not testable; "`POST /api/auth` returns 200 with a valid session cookie for a registered user" is. `validate_plan_doc.py` WARNs (check K) on a criterion that names no command/path/assertion.
576
+ - [ ] **Each acceptance criterion names the command that proves it.** The definition of done (canonical term: `acceptance_criteria`) and the `## Verification` commands are one contract, not two parallel lists — cite the proving command (or test file) in or beside each `- [ ]` item so done is mechanically checkable.
577
+ - [ ] **Grep assertions are paired with tests.** Any acceptance criterion using `rg` or `grep` as its sole check must also cite a test file — grep alone is defeated by renaming a symbol to pass the regex.
578
+ - [ ] **UI changes get a visual check.** When any lane owns UI/visual files (`*.tsx`/`*.jsx`/`*.vue`/`*.svelte`, `*.css`/`*.scss`, `components/**`), `## Verification` must include a browser/screenshot step (Playwright-via-PMCP or claude-in-chrome) and at least one acceptance criterion phrased as a visually observable outcome. `validate_plan_doc.py` WARNs (check L) when UI files change but Verification names no browser step.
579
+ - [ ] **Interface freeze gates are concrete** — name the symbol/endpoint/migration, not a vibe.
580
+ - [ ] **Stale-base resilience** — for each lane that isn't a DAG root, list every upstream symbol, migration number, or file path it reads under `Interfaces consumed`. This gives `<harness>-execute-phase` evidence to verify the base wasn't stale and narrows the blast radius of a mis-based commit. Execution Notes must call out "if lane teammate finds its worktree base is pre-<upstream-SL>, stop and report — do not rebase silently."
581
+ - [ ] **Synthesis lanes are explicit reducers** — any lane that writes a docs summary, truth table, readiness matrix, release summary, or other synthesized artifact lists every producer lane under `Depends on` and every consumed finding under `Interfaces consumed`. Mark these lanes `Parallel-safe: no`.
582
+ - [ ] **No completion-order assumptions** — the plan never relies on lane numbering, prose ordering, or "last lane" wording to sequence final artifact writes; the DAG is the only sequencing mechanism.
583
+ - [ ] **Cross-lane file deletions called out** — if any lane legitimately deletes a file that another lane produces (rare but real: a lane replacing a stub), record it under Execution Notes' "Known destructive changes" block.
584
+ - [ ] **Expected add/add conflicts declared** — if SL-0 preamble stubs a file that a lane replaces, add it under Execution Notes' "Expected add/add conflicts" block.
585
+ - [ ] **SL-0 re-exports use `__getattr__` lazy form** — declared under Execution Notes' "SL-0 re-exports" block.
586
+ - [ ] **Plan doc passes `validate_plan_doc.py`** — run the validator and confirm zero errors before calling `ExitPlanMode`. The validator catches structural issues (missing headings, duplicate lane IDs, malformed task tables) that manual review misses.
587
+ - [ ] **Terminal `SL-docs` lane present** — every phase plan must include the docs-sweep lane from `## Docs-sweep lane template`. `Depends on:` lists every other lane in the phase. No opt-out; a phase with no doc changes still runs the lane and records that.
588
+
589
+ ## Teamwork & delegation posture
590
+
591
+ - **Main thread = orchestrator only.** Brief, synthesize, write, emit. Do not `Grep`/`Read` the codebase directly during Steps 2–5. If you find yourself doing so, the teammate's brief was incomplete — re-brief via `SendMessage`.
592
+ - **Parallel-by-default.** Step 2 (Explore) and Step 3a (consensus Plan) MUST be issued as a single message with multiple `Agent` tool calls.
593
+ - **Name every teammate.** Set `name:` on every `Agent` call so you can re-address via `SendMessage` without losing context or paying to restart.
594
+ - **Task list as source of truth for the lane DAG.** Step 6's per-lane `TaskCreate` is how the plan becomes actionable; each lane task is addressable by ID for `<harness>-execute-phase`.
595
+ - **Hand-off to `<harness>-execute-phase`.** After `ExitPlanMode` approval, invoke `/<harness>-execute-phase <plan-doc-path>`. See that skill for the full execution contract (team creation, worktree isolation, merge policy). Do NOT pass `isolation: "worktree"` alongside `team_name` — the harness drops `isolation` in that combination.
596
+ - **Manual hand-off (when `<harness>-execute-phase` is unavailable).** Run `python scripts/validate_plan_doc.py <plan-doc-path>` first. Then execute each lane in one of two ways:
597
+ - (a) **Standalone** — `Agent(isolation: "worktree", name: "<SL-ID>", subagent_type: "general-purpose")` without `team_name`. The `isolation` kwarg is honored in this form; loses team coordination.
598
+ - (b) **Teamed** — `TeamCreate` + `Agent(team_name=…, name="<SL-ID>", subagent_type="general-purpose")`, and the teammate's first tool call is `EnterWorktree` (load via `ToolSearch(query="select:EnterWorktree")`). Worktree via tool, team coordination preserved.
599
+
600
+ ## Output contract
601
+
602
+ After `ExitPlanMode` approval, three artifacts exist:
603
+
604
+ 1. `plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md` — committable, valid markdown, all headings present.
605
+ 2. The plan-mode scratch file — identical contents.
606
+ 3. One `TaskCreate`'d top-level task per lane, each with `test / impl / verify` children, containing `Depends on:` / `Blocks:` / `Parallel-safe:` metadata in the body.
607
+
608
+ Those three are the full hand-off surface — everything downstream (manual lane execution or `<harness>-execute-phase`) reads from them.
609
+
610
+ ## Close-out — Stage artifact (preservation guarantee)
611
+
612
+ After `ExitPlanMode` is approved, before exiting:
613
+
614
+ 1. Verify frontmatter before staging:
615
+ - `phase_loop_plan_version: 1`
616
+ - `phase: <PHASE_ALIAS>`
617
+ - `roadmap: <repo-relative roadmap path from repo root>`
618
+ - `roadmap_sha256: <sha256 of that roadmap file>`
619
+ 2. Run `validate_plan_dispatch_hints` before copying or staging the project-path
620
+ artifact; stop with the validation_failed closeout if it returns findings.
621
+ 3. Run `python scripts/validate_plan_doc.py plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md` when the script is present; fix any frontmatter/path/hash failures before continuing.
622
+ 4. Run `git status --short -- plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md` and include the `_reviews.md` sibling if `--review-external` produced one.
623
+ 5. If the plan or review artifact is untracked or modified and the user did not explicitly forbid staging, run `git add plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md` plus the review sibling if present.
624
+ 6. Rerun `git status --short -- plans/phase-plan-<VERSION>-<PHASE_ALIAS>.md` and report `Artifact state: staged|tracked|modified|unstaged|blocked`.
625
+ 7. Do not commit unless the user explicitly asked for a commit.
626
+
627
+ When the generated plan is ready to execute, set `Next phase: <PHASE_ALIAS> - execution ready` and `Next command: /<harness>-execute-phase <PHASE_ALIAS>`. If execution should not start yet, set `Next phase: <PHASE_ALIAS> - blocked: <reason>` and `Next command: none - <reason>`.
628
+
629
+ ## Close-out — Reflection + Handoff
630
+
631
+ After artifacts are staged or confirmed tracked, resolve paths. Treat `_shared/next_reflection_path.py` as optional-if-present: check existence, use it when available, otherwise fall back to an inline date-based filename.
632
+
633
+ ```bash
634
+ REFLECTION_PATH=resolve_skill_bundle_root("codex")/<harness>-plan-phase/reflections/<repo_hash>/<branch_slug>/<run_id>.md
635
+ REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
636
+ REPO_LOCAL_HANDOFF=$(python3 - <<'PYH'
637
+ from importlib import util
638
+ from pathlib import Path
639
+ repo = Path.cwd().resolve()
640
+ spec = util.spec_from_file_location("handoff_path", repo / "shared" / "phase-loop" / "handoff_path.py")
641
+ mod = util.module_from_spec(spec)
642
+ spec.loader.exec_module(mod)
643
+ print(mod.resolve_handoff_path(repo, "<harness>-plan-phase"))
644
+ PYH
645
+ )
646
+ mkdir -p "$(dirname "$REPO_LOCAL_HANDOFF")"
647
+ SKILL_MD=resolve_skill_bundle_root("codex")/<harness>-plan-phase/SKILL.md
648
+ ```
649
+
650
+ Primary path: the orchestrator writes BOTH files directly with the Write tool. Before writing either file, ensure the plan doc has been staged in the preceding Close-out "Stage artifact" section unless the user explicitly forbade staging.
651
+
652
+ FILE 1 — REPO-AGNOSTIC reflection → `<REFLECTION_PATH>`:
653
+
654
+ ```markdown
655
+ # <harness>-plan-phase reflection — <ISO timestamp>
656
+
657
+ ## Run context
658
+ - Skill: <harness>-plan-phase
659
+ - Timestamp: <ISO timestamp>
660
+ - Repo: <repo>
661
+ - Branch: <branch>
662
+ - Commit: <commit>
663
+ - Artifact: <artifact path if any, or none>
664
+
665
+ ## What worked
666
+ - <bullet, about the SKILL's instructions>
667
+
668
+ ## What didn't
669
+ - <bullet, about friction or gaps in the SKILL's instructions>
670
+
671
+ ## Improvements to SKILL.md
672
+ - <specific, actionable change to the instructions>
673
+ ```
674
+
675
+ Do NOT reference this project, codebase, filenames, or domain in FILE 1. Feedback is about how the skill's instructions performed, for a future meta-skill that digests reflections across runs.
676
+
677
+ FILE 2 — REPO-SPECIFIC handoff → `<REPO_LOCAL_HANDOFF>` (per-repo slot; overwrites any prior handoff from this skill in the same repo):
678
+
679
+ ```markdown
680
+ <!--
681
+ Consumer validation — before acting on this handoff:
682
+ 1. Verify `from:` matches the expected predecessor skill.
683
+ 2. Verify `timestamp:` is within the last 7 days.
684
+ 3. Verify every `artifact:` path resolves under your current
685
+ `$(git rev-parse --show-toplevel)`. If any path points to a
686
+ different repo, stop and surface it to the user — the handoff
687
+ was written against a different workspace.
688
+ -->
689
+ ---
690
+ from: <harness>-plan-phase
691
+ timestamp: <ISO>
692
+ artifact: <absolute path to plan doc + reviews if any>
693
+ artifact_state: <staged|tracked|modified|unstaged|blocked>
694
+ next_skill: <<harness>-execute-phase|none>
695
+ next_command: </<harness>-execute-phase PHASE_ALIAS|none - reason>
696
+ next_phase: <PHASE_ALIAS - execution ready|PHASE_ALIAS - blocked: reason>
697
+ ---
698
+
699
+ # Handoff for <harness>-execute-phase
700
+
701
+ ## Summary
702
+ <2-3 sentences: phase planned, lanes count, plan doc path.>
703
+
704
+ ## Key decisions made this run
705
+ - <numbered, one line each — lane boundaries, IF-freeze signatures, consensus outcomes if --consensus was used>
706
+
707
+ ## Open items for <harness>-execute-phase
708
+ - <concrete — e.g., "SL-2 depends on SL-1's StoreRegistry.get signature; ensure lane ordering in dispatch">
709
+
710
+ ## Repo-specific gotchas surfaced
711
+ - <quirks of THIS codebase discovered during planning>
712
+
713
+ ## Planning artifacts staged this run
714
+ - <path> @ <artifact_state>
715
+
716
+ ## Execute-phase's likely scope
717
+ - <file globs from Owned files across lanes>
718
+ ```
719
+
720
+ Optional alternative: when fresh-context independent review is desired, the orchestrator MAY instead spawn ONE close-out agent using the `frontier` tier with the prompt below. Use this only when the orchestrator wants a clean-context review of the transcript before writing.
721
+
722
+ ```
723
+ Agent(
724
+ subagent_type: "general-purpose",
725
+ model: "<frontier-model-id>",
726
+ name: "<harness>-plan-phase-closeout",
727
+ prompt: """
728
+ Review the skill at <SKILL_MD> and the current execution transcript.
729
+ Produce the two files above (same schemas) via the Write tool to
730
+ <REFLECTION_PATH> and <REPO_LOCAL_HANDOFF>.
731
+ """
732
+ )
733
+ ```
734
+
735
+ After the files are written, print to the user:
736
+
737
+ > Plan written to `<plan-doc-path>`.
738
+ > Reflection saved to `<REFLECTION_PATH>`.
739
+ > Handoff written to `<REPO_LOCAL_HANDOFF>`.
740
+ >
741
+ > Recommended next step: run `/clear` to reset your context window, then invoke `/<harness>-execute-phase <alias>`. The next skill reads the handoff automatically.
742
+
743
+
744
+ Use `phase_loop_runtime.skill_paths` resolver helpers for harness skill roots, handoff roots, helper roots, and reflection roots.
745
+
746
+
747
+
748
+ ## Spec Closeout Plan
749
+
750
+ Generated phase plans must include a machine-readable section:
751
+
752
+ ```markdown
753
+ ## Spec Closeout Plan
754
+ - schema: `spec_delta_closeout.v1`
755
+ - decision: `<one of no_spec_delta, roadmap_amendment, canonical_spec_update, governed_pipeline_refresh, mirror_cutover_required, dotfiles_skill_source_update, human_source_judgment_required>`
756
+ - target surfaces: `<repo-relative paths or globs>`
757
+ - evidence paths: `<repo-relative metadata-only artifacts>`
758
+ - redaction posture: `metadata_only`
759
+ - downstream handling: `<none, roadmap amendment, Governed Pipeline refresh, mirror cutover, or human source judgment>`
760
+ ```
761
+
762
+ Validate that the decision literal is in vocabulary, `target surfaces` and `evidence paths` are present, and `redaction posture` is `metadata_only`. Missing, malformed, or out-of-vocabulary spec-closeout sections are repairable `contract_bug` blockers unless the plan explicitly requires `human_source_judgment_required`. This section must preserve the allowed `## Execution Policy` selector vocabulary and must not invent new Dispatch Hints selectors. Reducer and verification lanes keep the existing `work-unit=phase_reducer` and `work-unit=phase_verify` policy literals.
763
+
764
+ ## Verification Contract
765
+
766
+ Generated plans must contain machine-checkable verification commands and an effective `automation.suite_command`; phase plans must validate those commands through IF-0-VC-2 before they are handoff-ready. If an acceptance item depends on operational evidence that cannot be machine-checked directly, the plan must name the operational evidence artifact and the runner-stamped amendment mechanism that records it. proxy evidence requires a roadmap amendment before downstream plans rely on it.
767
+
768
+ ## Closeout
769
+
770
+ ### Manifest write
771
+
772
+ After the plan artifact and repo-local handoff path are known, perform a best-effort `plan-manifest append` through `phase_loop_runtime.plan_manifest.append_entry`. Append a `type=phase` entry with `status=committed`, `slug`, `file`, `created_at`, `owner_skill=<harness>-plan-phase`, `handoff_ref`, `roadmap_ref`, `phase_alias`, `if_gates_produced`, and `lanes`. Resolve paths with `phase_loop_runtime.skill_paths` helpers and keep the manifest write best-effort during the dual-mode window: failures are non-fatal, emit a ledger warning, and are mentioned in the mandatory reflection without changing the existing plan closeout result. A legacy `plans/manifest.json` using the `schema`/`entries` layout raises `unsupported manifest schema_version: 0`; treat that exact error as the expected non-fatal case (warn, do not block or migrate in place). `phase_loop_runtime` may resolve from the installed dotfiles runtime on `PYTHONPATH` even when the target repo neither vendors nor installs it — use the importable package; a missing repo-local checkout is not a blocker.
773
+
774
+ Closeout payload shape is defined by `EmitPhaseCloseout` in `phase_loop_runtime/baml_src/emit_phase_closeout.baml` (if that path is absent in the checkout, use the operator/prompt-supplied field contract or the installed `phase_loop_runtime` package — the missing vendored BAML source is not a blocker); keep skill text focused on value selection and handoff routing, not duplicated field ceremony.
775
+
776
+ Before final response, write a reflection for every non-trivial run. Write it to `resolve_skill_bundle_root("codex")/<harness>-plan-phase/reflections/<repo_hash>/<branch_slug>/<run_id>.md`. The reflection must include `## Run context` with skill name, ISO timestamp, repo, branch, commit, and artifact path if any, followed by `## What worked`, `## What didn't`, and `## Improvements to SKILL.md`. skip only when no artifact was produced AND no decision was made AND the run was pure inspection.