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,14 @@
1
+ class DotfilesC4Anchor {
2
+ id string
3
+ title string
4
+ source_path string
5
+ }
6
+
7
+ class DotfilesC4Document {
8
+ title string
9
+ mermaid_context_source string
10
+ mermaid_container_source string
11
+ mermaid_component_source string
12
+ anchors DotfilesC4Anchor[]
13
+ description string
14
+ }
@@ -0,0 +1,50 @@
1
+ // DotfilesPlanType enum literals: phase, detailed
2
+ // type enum literals: phase, detailed
3
+
4
+ class DotfilesPlanMetadataItem {
5
+ key string
6
+ value string
7
+ }
8
+
9
+ class DotfilesPlanMetadata {
10
+ entries DotfilesPlanMetadataItem[]
11
+ }
12
+
13
+ class DotfilesPlanRef {
14
+ slug string
15
+ file string
16
+ type string
17
+ digest string?
18
+ status string
19
+ }
20
+
21
+ class DotfilesPlanLifecycleEvent {
22
+ transition string
23
+ by string
24
+ at string
25
+ metadata DotfilesPlanMetadata
26
+ }
27
+
28
+ class DotfilesPlanEntry {
29
+ slug string
30
+ file string
31
+ type string
32
+ status string
33
+ created_at string
34
+ updated_at string
35
+ owner_skill string
36
+ handoff_ref string?
37
+ reflection_ref string?
38
+ task_summary string?
39
+ acceptance_criteria_count int?
40
+ roadmap_ref DotfilesPlanRef?
41
+ phase_alias string?
42
+ if_gates_produced string[]
43
+ lanes string[]
44
+ lifecycle DotfilesPlanLifecycleEvent[]
45
+ }
46
+
47
+ class DotfilesPlanManifest {
48
+ schema_version int
49
+ plans DotfilesPlanEntry[]
50
+ }
@@ -0,0 +1,16 @@
1
+ class DotfilesRuntimeProjection {
2
+ runtime_version string
3
+ protocol_version string
4
+ harness string
5
+ source_bundle_digest string
6
+ closeout_status string
7
+ handoff_status string
8
+ current_phase_boundary string
9
+ last_event_iso string
10
+ plans_in_flight int
11
+ plans_executing string[]
12
+ last_plan_event_iso string
13
+ install_status string
14
+ gitignore_init_status string
15
+ operating_mode string
16
+ }
@@ -0,0 +1,20 @@
1
+ class DotfilesTask {
2
+ id string
3
+ title string
4
+ audience string
5
+ owner string
6
+ dependencies string[]
7
+ status string
8
+ }
9
+
10
+ class DotfilesTaskReference {
11
+ title string
12
+ source_path string
13
+ anchor string
14
+ }
15
+
16
+ class DotfilesTaskCatalog {
17
+ tasks DotfilesTask[]
18
+ audiences string[]
19
+ references DotfilesTaskReference[]
20
+ }
@@ -0,0 +1,86 @@
1
+ client<llm> PhaseLoopCloseoutClient {
2
+ provider "openai-generic"
3
+ options {
4
+ base_url "https://example.invalid/v1"
5
+ model "phase-loop-closeout"
6
+ default_role "user"
7
+ }
8
+ }
9
+
10
+ // terminal_status enum literals:
11
+ // unplanned, planned, executing, executed, awaiting_phase_closeout, complete, blocked, unknown
12
+ // verification_status enum literals:
13
+ // not_run, passed, failed, blocked
14
+ // blocker_class enum literals:
15
+ // missing_secret, account_or_billing_setup, admin_approval, destructive_operation,
16
+ // ambiguous_roadmap_selection, product_decision_missing, dirty_worktree_conflict,
17
+ // branch_sync_conflict, stalled_child_observation, repeated_verification_failure,
18
+ // sandbox_command_restriction, upstream_phase_unmet, contract_bug,
19
+ // gold_record_amendment, closeout_evidence_drift, closeout_scope_violation,
20
+ // unretryable_external_outage, stuck_loop, merge_conflict,
21
+ // operator_override_missing_reason, concurrent_dispatch,
22
+ // verification_evidence_missing, none
23
+
24
+ class PhaseLoopCloseoutV1 {
25
+ terminal_status string
26
+ verification_status string
27
+ dirty_paths string[]
28
+ produced_if_gates string[]
29
+ next_action string?
30
+ blocker_class string?
31
+ blocker_summary string?
32
+ human_required bool?
33
+ required_human_inputs string[]
34
+ }
35
+
36
+ function EmitPhaseCloseout(
37
+ phase_alias: string,
38
+ plan_produces: string[],
39
+ plan_owned_files: string[],
40
+ closeout_commit_sha: string?
41
+ ) -> PhaseLoopCloseoutV1 {
42
+ client PhaseLoopCloseoutClient
43
+ prompt #"
44
+ Emit the phase-loop closeout for phase {{ phase_alias }} as one JSON object.
45
+
46
+ Required contract:
47
+ - Field-anchored enum list for terminal_status: {{ allowed_terminal_statuses | join(', ') }}.
48
+ - Field-anchored enum list for verification_status: {{ allowed_verification_statuses | join(', ') }}.
49
+ - terminal_status must never use dry_run. dry_run is an event-level execution mode, not a phase closeout status.
50
+ - dirty_paths must list repo-relative dirty paths left after execution.
51
+ - produced_if_gates must list the interface-freeze gates actually produced by this closeout.
52
+ - Completed closeouts must include every IF gate produced by the active plan and must not leave produced_if_gates empty.
53
+ - blocker_class must be null or one frozen blocker class: {{ allowed_blocker_classes | join(', ') }}. Use none only when a non-null no-blocker marker is required.
54
+ - blocker_summary must be non-secret and null when there is no blocker.
55
+ - human_required must be true only for a true human decision or access blocker, false for repairable automation blockers, and null when not blocked.
56
+ - required_human_inputs must contain only non-secret inputs needed from a human.
57
+
58
+ Terminal-status decision tree:
59
+ - Use complete only when the phase work met acceptance, required verification passed, and every active-plan IF gate is listed in produced_if_gates.
60
+ - Use blocked when work cannot complete in this turn because verification, ownership, access, policy, or contract checks failed.
61
+ - Use executed when implementation ran but final acceptance, artifact tracking, or verification remains unresolved.
62
+ - Use awaiting_phase_closeout when verified phase-owned dirty output still needs the runner closeout mode to commit, isolate, or preserve it.
63
+ - Use planned or unplanned only for planning-state closeouts where execution did not run.
64
+ - Use executing only for an in-progress closeout and unknown only when the executor cannot determine the phase state.
65
+
66
+ Field-pair invariants:
67
+ - terminal_status=complete requires verification_status=passed.
68
+ - terminal_status=planned or terminal_status=unplanned requires verification_status=not_run.
69
+ - terminal_status=blocked requires verification_status=failed or verification_status=blocked.
70
+ - terminal_status=executed, terminal_status=executing, terminal_status=awaiting_phase_closeout, or terminal_status=unknown must use the most accurate verification_status from the work performed.
71
+
72
+ Active plan IF gates:
73
+ {% for gate in plan_produces %}
74
+ - {{ gate }}
75
+ {% endfor %}
76
+
77
+ Active plan owned files:
78
+ {% for owned_file in plan_owned_files %}
79
+ - {{ owned_file }}
80
+ {% endfor %}
81
+
82
+ Closeout commit SHA: {{ closeout_commit_sha | default("none") }}
83
+
84
+ {{ ctx.output_format }}
85
+ "#
86
+ }
@@ -0,0 +1,36 @@
1
+ client<llm> EvidenceAuditClient {
2
+ provider "openai-generic"
3
+ options {
4
+ base_url "https://example.invalid/v1"
5
+ model "phase-loop-evidence-audit"
6
+ default_role "user"
7
+ }
8
+ }
9
+
10
+ class EvidenceJudgment {
11
+ verdict string
12
+ confidence float
13
+ reasoning string
14
+ specific_concerns string[]
15
+ }
16
+
17
+ function EvaluateSuspectedFakeEvidence(
18
+ tier2_signal_summary: string,
19
+ sample_artifact_content: string,
20
+ expected_artifact_characteristics: string
21
+ ) -> EvidenceJudgment {
22
+ client EvidenceAuditClient
23
+ prompt #"
24
+ Evaluate whether a suspected evidence artifact looks fabricated.
25
+
26
+ Inputs are intentionally bounded:
27
+ - Tier 2 signal summary: {{ tier2_signal_summary }}
28
+ - Sample artifact content: {{ sample_artifact_content }}
29
+ - Expected artifact characteristics: {{ expected_artifact_characteristics }}
30
+
31
+ Return only an EvidenceJudgment object. Use verdict "real", "fake", or
32
+ "uncertain". Keep reasoning concise and list concrete concerns, if any.
33
+
34
+ {{ ctx.output_format }}
35
+ "#
36
+ }
@@ -0,0 +1,40 @@
1
+ class VerificationCommandEvidence {
2
+ argv string[]
3
+ cwd string
4
+ exit_code int
5
+ duration_s float
6
+ log_offset int
7
+ }
8
+
9
+ class VerificationEnvRefreshEvidence {
10
+ triggered bool
11
+ manifests string[]
12
+ install_argv string[]
13
+ exit_code int
14
+ }
15
+
16
+ class VerificationSuiteEvidence {
17
+ argv string[]
18
+ exit_code int
19
+ duration_s float
20
+ }
21
+
22
+ class VerificationValidationFinding {
23
+ code string
24
+ message string
25
+ command_index int
26
+ argument_index int?
27
+ value string?
28
+ }
29
+
30
+ class VerificationEvidence {
31
+ schema_version int
32
+ run_id string
33
+ phase_alias string
34
+ commands VerificationCommandEvidence[]
35
+ env_refresh VerificationEnvRefreshEvidence?
36
+ suite VerificationSuiteEvidence?
37
+ started_at string
38
+ finished_at string
39
+ log_sha256 string
40
+ }
@@ -0,0 +1,181 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ from .capability_registry import resolve_dispatch_decision
6
+ from .discovery import dispatch_hints_for_action, parse_dispatch_hints, parse_plan_ownership
7
+ from .models import DelegationDecision, DelegationRequest, DispatchHints
8
+
9
+
10
+ DEFAULT_MAX_DELEGATION_DEPTH = 2
11
+ DEFAULT_MAX_DELEGATION_FANOUT = 2
12
+ DELEGATION_CHILD_ACTIONS = ("execute", "repair", "review")
13
+ DELEGATION_CHILD_EXECUTORS = ("codex", "claude")
14
+
15
+
16
+ def validate_delegation_request(
17
+ repo: Path,
18
+ roadmap: Path,
19
+ plan: Path | None,
20
+ request: DelegationRequest,
21
+ *,
22
+ active_loop_mode: str,
23
+ current_depth: int = 0,
24
+ current_fanout: int = 0,
25
+ max_depth: int = DEFAULT_MAX_DELEGATION_DEPTH,
26
+ max_fanout: int = DEFAULT_MAX_DELEGATION_FANOUT,
27
+ dry_run: bool = False,
28
+ ) -> DelegationDecision:
29
+ if active_loop_mode != "product":
30
+ return _deny(
31
+ request,
32
+ "active_loop_mode_denied",
33
+ f"Delegation requires product loop mode; current mode is {active_loop_mode}.",
34
+ observed_depth=current_depth,
35
+ observed_fanout=current_fanout,
36
+ )
37
+
38
+ if request.product_action not in DELEGATION_CHILD_ACTIONS:
39
+ return _deny(
40
+ request,
41
+ "unsupported_product_action",
42
+ "Delegation requests may only externalize execute, repair, or review child work.",
43
+ observed_depth=current_depth,
44
+ observed_fanout=current_fanout,
45
+ )
46
+
47
+ if request.target_executor not in DELEGATION_CHILD_EXECUTORS:
48
+ return _deny(
49
+ request,
50
+ "unsupported_target_executor",
51
+ "Delegation requests may target only codex or claude child executors.",
52
+ observed_depth=current_depth,
53
+ observed_fanout=current_fanout,
54
+ )
55
+
56
+ ownership = parse_plan_ownership(repo, roadmap, plan)
57
+ if not ownership.valid:
58
+ return _deny(
59
+ request,
60
+ "ownership_contract_invalid",
61
+ "Delegation denied because the active phase plan ownership contract is invalid or incomplete.",
62
+ observed_depth=current_depth,
63
+ observed_fanout=current_fanout,
64
+ )
65
+
66
+ if not request.owned_files:
67
+ return _deny(
68
+ request,
69
+ "missing_owned_files_claim",
70
+ "Delegation requests must claim at least one owned file path or glob.",
71
+ observed_depth=current_depth,
72
+ observed_fanout=current_fanout,
73
+ )
74
+
75
+ invalid_paths = tuple(path for path in request.owned_files if not ownership.matches(path))
76
+ if invalid_paths:
77
+ return _deny(
78
+ request,
79
+ "owned_files_out_of_bounds",
80
+ f"Delegation denied because owned-file claims escape the active phase contract: {', '.join(invalid_paths)}.",
81
+ observed_depth=current_depth,
82
+ observed_fanout=current_fanout,
83
+ )
84
+
85
+ next_depth = current_depth + 1
86
+ if next_depth > max_depth:
87
+ return _deny(
88
+ request,
89
+ "depth_limit_exceeded",
90
+ f"Delegation depth {next_depth} exceeds the configured limit {max_depth}.",
91
+ observed_depth=next_depth,
92
+ observed_fanout=current_fanout,
93
+ )
94
+
95
+ next_fanout = current_fanout + 1
96
+ if next_fanout > max_fanout:
97
+ return _deny(
98
+ request,
99
+ "fanout_limit_exceeded",
100
+ f"Delegation fanout {next_fanout} exceeds the configured limit {max_fanout}.",
101
+ observed_depth=next_depth,
102
+ observed_fanout=next_fanout,
103
+ )
104
+
105
+ if request.budget is None or not request.budget.is_defined():
106
+ return _deny(
107
+ request,
108
+ "missing_budget_metadata",
109
+ "Delegation requests must include metadata-only budget guidance before the runner can approve them.",
110
+ observed_depth=next_depth,
111
+ observed_fanout=next_fanout,
112
+ )
113
+
114
+ plan_hints = dispatch_hints_for_action(parse_dispatch_hints(plan, kind="plan"), request.product_action) if plan else None
115
+ roadmap_hints = dispatch_hints_for_action(parse_dispatch_hints(roadmap, kind="roadmap"), request.product_action)
116
+ operator_hints = DispatchHints(
117
+ preferred_executors=(request.target_executor,),
118
+ allowed_executors=(request.target_executor,),
119
+ source="delegation",
120
+ action=request.product_action,
121
+ )
122
+ dispatch_decision = resolve_dispatch_decision(
123
+ action=request.product_action,
124
+ dry_run=dry_run,
125
+ operator=operator_hints,
126
+ plan=plan_hints,
127
+ roadmap=roadmap_hints,
128
+ )
129
+ if dispatch_decision.blocked:
130
+ return _deny(
131
+ request,
132
+ "dispatch_policy_denied",
133
+ dispatch_decision.blocked_summary or "Delegation denied by dispatch policy.",
134
+ dispatch_decision=dispatch_decision.to_json(),
135
+ observed_depth=next_depth,
136
+ observed_fanout=next_fanout,
137
+ )
138
+ if dispatch_decision.selected_executor != request.target_executor:
139
+ return _deny(
140
+ request,
141
+ "dispatch_executor_mismatch",
142
+ (
143
+ f"Delegation requested {request.target_executor} but dispatch resolved "
144
+ f"{dispatch_decision.selected_executor or 'none'}."
145
+ ),
146
+ dispatch_decision=dispatch_decision.to_json(),
147
+ observed_depth=next_depth,
148
+ observed_fanout=next_fanout,
149
+ )
150
+ return DelegationDecision(
151
+ request_id=request.request_id,
152
+ status="approved",
153
+ reason_code="approved",
154
+ summary=f"Delegation approved for {request.product_action} on {request.target_executor}.",
155
+ selected_executor=request.target_executor,
156
+ dispatch_decision=dispatch_decision.to_json(),
157
+ observed_depth=next_depth,
158
+ observed_fanout=next_fanout,
159
+ )
160
+
161
+
162
+ def _deny(
163
+ request: DelegationRequest,
164
+ reason_code: str,
165
+ summary: str,
166
+ *,
167
+ dispatch_decision: dict | None = None,
168
+ observed_depth: int | None = None,
169
+ observed_fanout: int | None = None,
170
+ ) -> DelegationDecision:
171
+ return DelegationDecision(
172
+ request_id=request.request_id,
173
+ status="denied",
174
+ reason_code=reason_code,
175
+ summary=summary,
176
+ dispatch_decision=dispatch_decision,
177
+ human_required=False,
178
+ blocker_class="repeated_verification_failure",
179
+ observed_depth=observed_depth,
180
+ observed_fanout=observed_fanout,
181
+ )