create-agdf 0.20.2 → 0.30.0

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 (836) hide show
  1. package/README.md +148 -191
  2. package/generated/.agdf/control/README.md +31 -110
  3. package/generated/.agdf/control/planned-urs.md +95 -0
  4. package/generated/.agdf/control/templates/RUN_STATE.md +15 -64
  5. package/generated/.agdf/control/templates/artefacts/UR.md +1 -1
  6. package/generated/.agents/plugins/marketplace.json +12 -0
  7. package/generated/.opencode/agdf-agent-router.md +3 -3
  8. package/generated/.opencode/agdf-interaction-locales.json +2668 -2682
  9. package/generated/.opencode/contracts/closeout.md +1 -1
  10. package/generated/.opencode/contracts/control-scaffold.md +63 -46
  11. package/generated/.opencode/contracts/gate-artifact-preparation.md +58 -48
  12. package/generated/.opencode/contracts/gate-transition.md +5 -6
  13. package/generated/.opencode/contracts/interaction.md +43 -126
  14. package/generated/.opencode/contracts/modes.md +4 -3
  15. package/generated/.opencode/contracts/prd-definition.md +6 -6
  16. package/generated/.opencode/contracts/quality.md +10 -2
  17. package/generated/.opencode/contracts/request-activation.md +9 -8
  18. package/generated/.opencode/contracts/sd-definition.md +3 -3
  19. package/generated/.opencode/contracts/task-target-resolution.md +24 -0
  20. package/generated/.opencode/contracts/tp-definition.md +1 -1
  21. package/generated/.opencode/contracts/ur-definition.md +41 -7
  22. package/generated/.opencode/skills/agdf-brownfield-analysis/SKILL.md +8 -5
  23. package/generated/.opencode/skills/agdf-clean-implementation-review/SKILL.md +3 -2
  24. package/generated/.opencode/skills/agdf-code-review/SKILL.md +5 -3
  25. package/generated/.opencode/skills/agdf-delivery-closeout/SKILL.md +3 -2
  26. package/generated/.opencode/skills/agdf-delivery-path-search/SKILL.md +3 -2
  27. package/generated/.opencode/skills/agdf-gate-check/SKILL.md +35 -31
  28. package/generated/.opencode/skills/agdf-prd-definition/SKILL.md +3 -2
  29. package/generated/.opencode/skills/agdf-qa-gate/SKILL.md +3 -2
  30. package/generated/.opencode/skills/agdf-release-or/SKILL.md +8 -5
  31. package/generated/.opencode/skills/agdf-sd-definition/SKILL.md +3 -2
  32. package/generated/.opencode/skills/agdf-task-plan-review/SKILL.md +3 -2
  33. package/generated/.opencode/skills/agdf-tp-definition/SKILL.md +3 -2
  34. package/generated/.opencode/skills/agdf-ur-definition/SKILL.md +12 -4
  35. package/generated/.opencode/skills/agdf-ux-intent-definition/SKILL.md +5 -4
  36. package/generated/plugins/agdf/.claude-plugin/plugin.json +3 -2
  37. package/generated/plugins/agdf/.codex-plugin/plugin.json +1 -1
  38. package/generated/plugins/agdf/companion/assignment.mjs +65 -0
  39. package/generated/plugins/agdf/companion/companion.json +4 -0
  40. package/generated/plugins/agdf/companion/core.mjs +16 -0
  41. package/generated/plugins/agdf/companion/figure.mjs +137 -0
  42. package/generated/plugins/agdf/companion/gate-bar.mjs +54 -0
  43. package/generated/plugins/agdf/companion/hooks.json +3 -0
  44. package/generated/plugins/agdf/companion/locales.json +200 -0
  45. package/generated/plugins/agdf/companion/localization.mjs +89 -0
  46. package/generated/plugins/agdf/companion/notice.mjs +90 -0
  47. package/generated/plugins/agdf/companion/persistence.mjs +36 -0
  48. package/generated/plugins/agdf/companion/register.mjs +444 -0
  49. package/generated/plugins/agdf/companion/run-state.mjs +110 -0
  50. package/generated/plugins/agdf/companion/state.mjs +48 -0
  51. package/generated/plugins/agdf/companion/view.mjs +84 -0
  52. package/generated/plugins/agdf/control/README.md +31 -110
  53. package/generated/plugins/agdf/control/planned-urs.md +95 -0
  54. package/generated/plugins/agdf/control/templates/RUN_STATE.md +15 -64
  55. package/generated/plugins/agdf/control/templates/artefacts/UR.md +1 -1
  56. package/generated/plugins/agdf/mcp/server/README.md +119 -7
  57. package/generated/plugins/agdf/mcp/server/package.json +12 -7
  58. package/generated/plugins/agdf/mcp/server/src/generation-entry.js +3 -85
  59. package/generated/plugins/agdf/mcp/server/src/generation-protocol.js +2 -44
  60. package/generated/plugins/agdf/mcp/server/src/generation-runtime.js +94 -0
  61. package/generated/plugins/agdf/mcp/server/src/generation-thread-entry.js +8 -0
  62. package/generated/plugins/agdf/mcp/server/src/generation.js +64 -20
  63. package/generated/plugins/agdf/mcp/server/src/main.js +42 -10
  64. package/generated/plugins/agdf/mcp/server/src/server.js +24 -15
  65. package/generated/plugins/agdf/mcp/server/src/stdio-output.js +42 -0
  66. package/generated/plugins/agdf/mcp/server/src/worker-entry.js +2 -2
  67. package/generated/plugins/agdf/mcp/server/src/worker.js +53 -7
  68. package/generated/plugins/agdf/mcp/server/ui/cockpit.html +31 -31
  69. package/generated/plugins/agdf/mcp/server/ui/decision-manifest.json +3 -3
  70. package/generated/plugins/agdf/mcp/server/ui/decision.html +36 -36
  71. package/generated/plugins/agdf/mcp/server/ui/manifest.json +4 -4
  72. package/generated/plugins/agdf/meta/agdf-agent-router.md +3 -3
  73. package/generated/plugins/agdf/meta/agdf-defaults.json +9 -0
  74. package/generated/plugins/agdf/meta/agdf-defaults.schema.json +20 -0
  75. package/generated/plugins/agdf/meta/agdf-interaction-locales.json +2668 -2682
  76. package/generated/plugins/agdf/meta/agdf-mcp-capability.json +1 -1
  77. package/generated/plugins/agdf/meta/agdf-plugin.definition.json +8 -3
  78. package/generated/plugins/agdf/meta/contracts/closeout.md +1 -1
  79. package/generated/plugins/agdf/meta/contracts/control-scaffold.md +63 -46
  80. package/generated/plugins/agdf/meta/contracts/gate-artifact-preparation.md +58 -48
  81. package/generated/plugins/agdf/meta/contracts/gate-transition.md +5 -6
  82. package/generated/plugins/agdf/meta/contracts/interaction.md +43 -126
  83. package/generated/plugins/agdf/meta/contracts/modes.md +4 -3
  84. package/generated/plugins/agdf/meta/contracts/prd-definition.md +6 -6
  85. package/generated/plugins/agdf/meta/contracts/quality.md +10 -2
  86. package/generated/plugins/agdf/meta/contracts/request-activation.md +9 -8
  87. package/generated/plugins/agdf/meta/contracts/sd-definition.md +3 -3
  88. package/generated/plugins/agdf/meta/contracts/task-target-resolution.md +24 -0
  89. package/generated/plugins/agdf/meta/contracts/tp-definition.md +1 -1
  90. package/generated/plugins/agdf/meta/contracts/ur-definition.md +41 -7
  91. package/generated/plugins/agdf/meta/copilot-payload-baseline.json +3 -3
  92. package/generated/plugins/agdf/meta/distribution-profile-history.json +7 -0
  93. package/generated/plugins/agdf/runtime/agdf-session-check.js +25 -21
  94. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-defaults.json +9 -0
  95. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-defaults.schema.json +20 -0
  96. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-interaction-locales.json +2668 -2682
  97. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-plugin.definition.json +8 -3
  98. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/closeout.md +1 -1
  99. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/control-scaffold.md +63 -46
  100. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/gate-artifact-preparation.md +58 -48
  101. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/gate-transition.md +5 -6
  102. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/interaction.md +43 -126
  103. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/modes.md +4 -3
  104. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/prd-definition.md +6 -6
  105. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/quality.md +10 -2
  106. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/request-activation.md +9 -8
  107. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/sd-definition.md +3 -3
  108. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/task-target-resolution.md +24 -0
  109. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/tp-definition.md +1 -1
  110. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/ur-definition.md +41 -7
  111. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/codex-document-command.js +195 -0
  112. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/command-registry.js +82 -148
  113. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/control-maintenance-command.js +8 -37
  114. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/parse-args.js +98 -16
  115. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/planned-command.js +55 -0
  116. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/project-read-command.js +35 -0
  117. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/run-command-aliases.js +116 -0
  118. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/runtime-context.js +1 -59
  119. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/validation-handlers.js +33 -103
  120. package/generated/plugins/agdf/runtime/create-agdf/lib/control-evaluation/git-observation.js +7 -5
  121. package/generated/plugins/agdf/runtime/create-agdf/lib/control-maintenance/startup.js +2 -2
  122. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-decision-protocol.js +40 -0
  123. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-dispatch-runtime.js +71 -306
  124. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/facade-entry.js +3 -24
  125. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/facade-owner-entry.js +31 -15
  126. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/facade-runtime.js +29 -0
  127. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/facade-thread-entry.js +11 -0
  128. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/owner-client.js +79 -0
  129. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/package.js +14 -80
  130. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/plugin-runtime.js +29 -9
  131. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/thread-owner.js +164 -0
  132. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-owner-protocol.js +1 -0
  133. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-protocol-runtime.js +308 -0
  134. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-worker-runtime.js +152 -0
  135. package/generated/plugins/agdf/runtime/create-agdf/lib/runtime/control-command-service.js +22 -7
  136. package/generated/plugins/agdf/runtime/create-agdf/lib/runtime/control-context.js +8 -1
  137. package/generated/plugins/agdf/runtime/create-agdf/lib/runtime/validator-application.js +2 -2
  138. package/generated/plugins/agdf/runtime/create-agdf/package.json +5 -1
  139. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/closeout-readiness.js +10 -2
  140. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/decision-content-placeholder.js +9 -0
  141. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/decision-content-readiness.js +2 -7
  142. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/definition-sources.js +3 -2
  143. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/delivery-map.js +2 -12
  144. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/doctor.js +162 -172
  145. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-check.js +10 -9
  146. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-policy-inputs.js +11 -0
  147. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-policy-pure.js +446 -0
  148. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-policy.js +3 -434
  149. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/next-action.js +2 -0
  150. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/parent-reconciliation.js +2 -1
  151. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/qa-follow-up.js +2 -1
  152. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/required-files.js +9 -7
  153. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/run-state-policy.js +1 -1
  154. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/run-state.js +15 -9
  155. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/run-step-policy.js +2 -1
  156. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/run-work-summary.js +6 -4
  157. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/shared-value.js +7 -0
  158. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/shared.js +5 -254
  159. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/tp-planning.js +3 -2
  160. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/ur-readiness.js +7 -2
  161. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/verified-change.js +11 -9
  162. package/{runtime/core/lib/control-evaluation/backlog-vocabulary.js → generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/work-vocabulary.js} +2 -2
  163. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/artifact-readiness.js +5 -3
  164. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/authoring-inputs.js +110 -0
  165. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit-archive.js +53 -0
  166. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit-context.js +2 -1
  167. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit-contract.js +11 -4
  168. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit-list.d.ts +10 -6
  169. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit-list.js +32 -41
  170. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit-session.js +8 -8
  171. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit-work.js +33 -0
  172. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit.js +75 -44
  173. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/contract.js +124 -32
  174. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/decision-session.js +53 -11
  175. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/doctor-observation.js +91 -0
  176. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/project-operation-call.js +5 -0
  177. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/project-state.js +48 -0
  178. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/result.js +61 -0
  179. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/selection.js +9 -3
  180. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/service.js +119 -67
  181. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/compatibility.js +42 -132
  182. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/contract.js +5 -5
  183. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/presentation.js +27 -119
  184. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/service.js +9 -37
  185. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-read/cockpit-pool.js +25 -9
  186. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-read/cockpit-worker.js +4 -3
  187. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-read/doctor-reader.js +92 -0
  188. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-read/doctor-worker.js +11 -0
  189. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-read/fs.js +18 -0
  190. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-read/snapshot.js +68 -17
  191. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/aggregate.js +3 -1
  192. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/approval-command.js +13 -10
  193. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/approval-operations.js +10 -7
  194. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/artefact-binding-proof.js +12 -20
  195. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/artefact-bindings.js +10 -7
  196. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/canonical-initialization.js +761 -0
  197. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/control-layout.js +183 -0
  198. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/decision-action-contract.js +10 -1
  199. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/decision-action-service.js +24 -3
  200. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/decision-material-contract.js +2 -1
  201. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/evidence-bindings.js +7 -7
  202. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/git-identity.js +86 -0
  203. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/index.js +0 -1
  204. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/input-resolution.js +99 -0
  205. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/planned-entry.js +273 -0
  206. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/planned-handoff.js +174 -0
  207. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/planned-inventory.js +90 -0
  208. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/planned-origin-reader.js +48 -0
  209. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/planned-origin.js +40 -0
  210. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/presentation-decision.js +12 -7
  211. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/presentation-delivery.js +90 -0
  212. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/preview-render.js +5 -2
  213. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/preview-review.js +3 -2
  214. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/preview-snapshot.js +9 -6
  215. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/recording-formats.js +12 -16
  216. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-artefact-recording.js +54 -66
  217. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-closure.js +343 -0
  218. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-contract.js +33 -250
  219. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-schema.js +508 -0
  220. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-service.js +198 -34
  221. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-create-command.js +60 -0
  222. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-identity.d.ts +14 -0
  223. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-identity.js +40 -0
  224. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-input-resolution.js +72 -0
  225. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-inventory-reader.js +31 -0
  226. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-inventory.js +179 -0
  227. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-material.js +211 -0
  228. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-mutation.js +51 -0
  229. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-operation-identity.js +2 -1
  230. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-operation-proof.js +7 -4
  231. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-operation-status.js +20 -4
  232. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-operations.js +70 -13
  233. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-owned-outputs.js +21 -9
  234. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-presentation-envelope.js +25 -33
  235. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-presentation-render.js +8 -7
  236. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-presentation.js +45 -21
  237. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-recording.js +10 -179
  238. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-revision-boundary.js +7 -21
  239. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-revision-history.js +23 -16
  240. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-revision.js +84 -161
  241. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-seal-compute.js +19 -44
  242. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-seal.js +6 -1
  243. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-source-revisions.js +19 -18
  244. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-document.js +110 -42
  245. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-edits.js +13 -5
  246. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-parser.js +14 -6
  247. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-reader.js +27 -18
  248. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-repository.js +112 -48
  249. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-resolver.js +12 -15
  250. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-writer.js +21 -377
  251. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-step-pending.js +2 -1
  252. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-step-transaction.js +125 -114
  253. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-steps.js +136 -248
  254. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-store-inspection.js +14 -2
  255. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-verified-change.js +81 -0
  256. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-work-summary-shape.d.ts +1 -0
  257. package/{runtime/core/lib/control-state/backlog-summary-shape.js → generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-work-summary-shape.js} +7 -19
  258. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/delivery-continuation/service.js +5 -66
  259. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/delivery-path-search/persistence.js +26 -8
  260. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/delivery-path-search/state-adapter.js +1 -1
  261. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/index.js +14 -6
  262. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/interaction-catalog.js +3 -3
  263. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/interaction-presentation.js +29 -11
  264. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/mcp-input-hints.js +46 -0
  265. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/mcp-input-resolution.js +98 -0
  266. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/mcp-input-schema.js +15 -0
  267. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/mcp-resource-contract.js +1 -1
  268. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/mcp-tool-errors.js +31 -15
  269. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/owned-file-lock.js +266 -0
  270. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/owner-placement.js +50 -0
  271. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/resources/canonical-init-plan.js +34 -0
  272. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/resources/configuration.js +92 -0
  273. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/resources/context.js +7 -11
  274. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/resources/language-preference.js +59 -0
  275. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/runtime/mcp-owner-protocol.js +102 -0
  276. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/runtime/plugin-provenance.js +173 -18
  277. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/compact-continuation.js +3 -3
  278. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/contract.js +28 -9
  279. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/delivery-intake.js +11 -5
  280. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/delivery-run-assignment.js +6 -10
  281. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/mcp-continuation.js +64 -0
  282. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/prd-definition.js +14 -5
  283. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/sd-definition.js +2 -1
  284. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/service.js +49 -14
  285. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/tp-definition.js +2 -1
  286. package/generated/plugins/agdf/runtime/runtime-manifest.json +2 -2
  287. package/generated/plugins/agdf/scripts/check-runtime-integrity.mjs +60 -42
  288. package/generated/plugins/agdf/scripts/instruction-footprint.mjs +5 -5
  289. package/generated/plugins/agdf/skills/brownfield-analysis/SKILL.md +8 -5
  290. package/generated/plugins/agdf/skills/clean-implementation-review/SKILL.md +3 -2
  291. package/generated/plugins/agdf/skills/code-review/SKILL.md +5 -3
  292. package/generated/plugins/agdf/skills/delivery-closeout/SKILL.md +3 -2
  293. package/generated/plugins/agdf/skills/delivery-path-search/SKILL.md +3 -2
  294. package/generated/plugins/agdf/skills/gate-check/SKILL.md +35 -31
  295. package/generated/plugins/agdf/skills/prd-definition/SKILL.md +3 -2
  296. package/generated/plugins/agdf/skills/qa-gate/SKILL.md +3 -2
  297. package/generated/plugins/agdf/skills/release-or/SKILL.md +8 -5
  298. package/generated/plugins/agdf/skills/sd-definition/SKILL.md +3 -2
  299. package/generated/plugins/agdf/skills/task-plan-review/SKILL.md +3 -2
  300. package/generated/plugins/agdf/skills/tp-definition/SKILL.md +3 -2
  301. package/generated/plugins/agdf/skills/ur-definition/SKILL.md +12 -4
  302. package/generated/plugins/agdf/skills/ux-intent-definition/SKILL.md +5 -4
  303. package/generated/plugins/agdf/submission/openai/availability.md +1 -1
  304. package/generated/plugins/agdf/submission/openai/capability-matrix.json +1 -1
  305. package/generated/plugins/agdf/submission/openai/release-notes.md +9 -1
  306. package/generated/plugins/agdf/submission/openai/reviewer-cases.json +1 -1
  307. package/generated/plugins/agdf-planning/.codex-plugin/plugin.json +40 -0
  308. package/generated/plugins/agdf-planning/README.md +21 -0
  309. package/generated/plugins/agdf-planning/assets/agdf-icon.svg +16 -0
  310. package/generated/plugins/agdf-planning/assets/agdf-logo.svg +16 -0
  311. package/generated/plugins/agdf-planning/meta/agdf-planning.definition.json +9 -0
  312. package/generated/plugins/agdf-planning/plugin.json +45 -0
  313. package/generated/plugins/agdf-planning/skills/planning/SKILL.md +56 -0
  314. package/generated/plugins/copilot/agdf/.agdf-payload-inventory.json +878 -475
  315. package/generated/plugins/copilot/agdf/control/README.md +31 -110
  316. package/generated/plugins/copilot/agdf/control/planned-urs.md +95 -0
  317. package/generated/plugins/copilot/agdf/control/templates/RUN_STATE.md +15 -64
  318. package/generated/plugins/copilot/agdf/control/templates/artefacts/UR.md +1 -1
  319. package/generated/plugins/copilot/agdf/mcp/server/README.md +119 -7
  320. package/generated/plugins/copilot/agdf/mcp/server/package.json +12 -7
  321. package/generated/plugins/copilot/agdf/mcp/server/src/generation-entry.js +3 -85
  322. package/generated/plugins/copilot/agdf/mcp/server/src/generation-protocol.js +2 -44
  323. package/generated/plugins/copilot/agdf/mcp/server/src/generation-runtime.js +94 -0
  324. package/generated/plugins/copilot/agdf/mcp/server/src/generation-thread-entry.js +8 -0
  325. package/generated/plugins/copilot/agdf/mcp/server/src/generation.js +64 -20
  326. package/generated/plugins/copilot/agdf/mcp/server/src/main.js +42 -10
  327. package/generated/plugins/copilot/agdf/mcp/server/src/server.js +24 -15
  328. package/generated/plugins/copilot/agdf/mcp/server/src/stdio-output.js +42 -0
  329. package/generated/plugins/copilot/agdf/mcp/server/src/worker-entry.js +2 -2
  330. package/generated/plugins/copilot/agdf/mcp/server/src/worker.js +53 -7
  331. package/generated/plugins/copilot/agdf/meta/agdf-agent-router.md +3 -3
  332. package/generated/plugins/copilot/agdf/meta/agdf-plugin.definition.json +8 -3
  333. package/generated/plugins/copilot/agdf/meta/distribution-profile-history.json +7 -0
  334. package/generated/plugins/copilot/agdf/plugin.json +1 -1
  335. package/generated/plugins/copilot/agdf/runtime/agdf-session-check.js +25 -21
  336. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-defaults.json +9 -0
  337. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-defaults.schema.json +20 -0
  338. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-interaction-locales.json +2668 -2682
  339. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-plugin.definition.json +8 -3
  340. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/closeout.md +1 -1
  341. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/control-scaffold.md +63 -46
  342. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/gate-artifact-preparation.md +58 -48
  343. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/gate-transition.md +5 -6
  344. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/interaction.md +43 -126
  345. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/modes.md +4 -3
  346. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/prd-definition.md +6 -6
  347. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/quality.md +10 -2
  348. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/request-activation.md +9 -8
  349. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/sd-definition.md +3 -3
  350. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/task-target-resolution.md +24 -0
  351. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/tp-definition.md +1 -1
  352. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/ur-definition.md +41 -7
  353. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/codex-document-command.js +195 -0
  354. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/command-registry.js +82 -148
  355. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/control-maintenance-command.js +8 -37
  356. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/parse-args.js +98 -16
  357. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/planned-command.js +55 -0
  358. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/project-read-command.js +35 -0
  359. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/run-command-aliases.js +116 -0
  360. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/runtime-context.js +1 -59
  361. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/validation-handlers.js +33 -103
  362. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/control-evaluation/git-observation.js +7 -5
  363. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/control-maintenance/startup.js +2 -2
  364. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-decision-protocol.js +40 -0
  365. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-dispatch-runtime.js +71 -306
  366. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/facade-entry.js +3 -24
  367. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/facade-owner-entry.js +31 -15
  368. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/facade-runtime.js +29 -0
  369. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/facade-thread-entry.js +11 -0
  370. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/owner-client.js +79 -0
  371. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/package.js +14 -80
  372. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/plugin-runtime.js +29 -9
  373. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/thread-owner.js +164 -0
  374. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-owner-protocol.js +1 -0
  375. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-protocol-runtime.js +308 -0
  376. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-worker-runtime.js +152 -0
  377. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/runtime/control-command-service.js +22 -7
  378. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/runtime/control-context.js +8 -1
  379. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/runtime/validator-application.js +2 -2
  380. package/generated/plugins/copilot/agdf/runtime/create-agdf/package.json +5 -1
  381. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/closeout-readiness.js +10 -2
  382. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/decision-content-placeholder.js +9 -0
  383. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/decision-content-readiness.js +2 -7
  384. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/definition-sources.js +3 -2
  385. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/delivery-map.js +2 -12
  386. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/doctor.js +162 -172
  387. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-check.js +10 -9
  388. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-policy-inputs.js +11 -0
  389. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-policy-pure.js +446 -0
  390. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-policy.js +3 -434
  391. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/next-action.js +2 -0
  392. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/parent-reconciliation.js +2 -1
  393. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/qa-follow-up.js +2 -1
  394. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/required-files.js +9 -7
  395. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/run-state-policy.js +1 -1
  396. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/run-state.js +15 -9
  397. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/run-step-policy.js +2 -1
  398. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/run-work-summary.js +6 -4
  399. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/shared-value.js +7 -0
  400. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/shared.js +5 -254
  401. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/tp-planning.js +3 -2
  402. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/ur-readiness.js +7 -2
  403. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/verified-change.js +11 -9
  404. package/generated/plugins/{agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/backlog-vocabulary.js → copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/work-vocabulary.js} +2 -2
  405. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/artifact-readiness.js +5 -3
  406. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/authoring-inputs.js +110 -0
  407. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit-archive.js +53 -0
  408. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/contract.js +124 -32
  409. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/doctor-observation.js +91 -0
  410. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/project-operation-call.js +5 -0
  411. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/project-state.js +48 -0
  412. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/result.js +61 -0
  413. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/selection.js +9 -3
  414. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/service.js +119 -67
  415. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/compatibility.js +42 -132
  416. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/contract.js +5 -5
  417. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/presentation.js +27 -119
  418. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/service.js +9 -37
  419. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-read/cockpit-pool.js +121 -0
  420. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-read/doctor-reader.js +92 -0
  421. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-read/doctor-worker.js +11 -0
  422. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-read/fs.js +18 -0
  423. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-read/snapshot.js +68 -17
  424. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/aggregate.js +3 -1
  425. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/approval-command.js +13 -10
  426. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/approval-operations.js +10 -7
  427. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/artefact-binding-proof.js +12 -20
  428. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/artefact-bindings.js +10 -7
  429. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/canonical-initialization.js +761 -0
  430. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/control-layout.js +183 -0
  431. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/decision-material-contract.js +2 -1
  432. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/evidence-bindings.js +7 -7
  433. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/git-identity.js +86 -0
  434. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/index.js +0 -1
  435. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/input-resolution.js +99 -0
  436. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/planned-entry.js +273 -0
  437. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/planned-handoff.js +174 -0
  438. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/planned-inventory.js +90 -0
  439. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/planned-origin-reader.js +48 -0
  440. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/planned-origin.js +40 -0
  441. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/presentation-decision.js +12 -7
  442. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/presentation-delivery.js +90 -0
  443. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/preview-render.js +5 -2
  444. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/preview-review.js +3 -2
  445. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/preview-snapshot.js +9 -6
  446. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/recording-formats.js +12 -16
  447. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-artefact-recording.js +54 -66
  448. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-closure.js +343 -0
  449. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-contract.js +33 -250
  450. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-schema.js +508 -0
  451. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-service.js +198 -34
  452. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-create-command.js +60 -0
  453. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-identity.d.ts +14 -0
  454. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-identity.js +40 -0
  455. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-input-resolution.js +72 -0
  456. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-inventory-reader.js +31 -0
  457. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-inventory.js +179 -0
  458. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-material.js +211 -0
  459. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-mutation.js +51 -0
  460. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-operation-identity.js +2 -1
  461. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-operation-proof.js +7 -4
  462. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-operation-status.js +20 -4
  463. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-operations.js +70 -13
  464. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-owned-outputs.js +21 -9
  465. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-presentation-envelope.js +25 -33
  466. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-presentation-render.js +8 -7
  467. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-presentation.js +45 -21
  468. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-recording.js +10 -179
  469. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-revision-boundary.js +7 -21
  470. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-revision-history.js +23 -16
  471. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-revision.js +84 -161
  472. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-seal-compute.js +19 -44
  473. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-seal.js +6 -1
  474. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-source-revisions.js +19 -18
  475. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-document.js +110 -42
  476. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-edits.js +13 -5
  477. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-parser.js +14 -6
  478. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-reader.js +27 -18
  479. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-repository.js +112 -48
  480. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-resolver.js +12 -15
  481. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-writer.js +21 -377
  482. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-step-pending.js +2 -1
  483. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-step-transaction.js +125 -114
  484. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-steps.js +136 -248
  485. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-store-inspection.js +14 -2
  486. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-verified-change.js +81 -0
  487. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-work-summary-shape.d.ts +1 -0
  488. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/{backlog-summary-shape.js → run-work-summary-shape.js} +7 -19
  489. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/delivery-continuation/service.js +5 -66
  490. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/delivery-path-search/persistence.js +26 -8
  491. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/delivery-path-search/state-adapter.js +1 -1
  492. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/index.js +14 -6
  493. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/interaction-catalog.js +3 -3
  494. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/interaction-presentation.js +29 -11
  495. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/mcp-input-hints.js +46 -0
  496. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/mcp-input-resolution.js +98 -0
  497. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/mcp-input-schema.js +15 -0
  498. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/mcp-resource-contract.js +1 -1
  499. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/mcp-tool-errors.js +31 -15
  500. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/owned-file-lock.js +266 -0
  501. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/owner-placement.js +50 -0
  502. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/resources/canonical-init-plan.js +34 -0
  503. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/resources/configuration.js +92 -0
  504. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/resources/context.js +7 -11
  505. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/resources/language-preference.js +59 -0
  506. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/runtime/mcp-owner-protocol.js +102 -0
  507. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/runtime/plugin-provenance.js +173 -18
  508. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/compact-continuation.js +3 -3
  509. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/contract.js +28 -9
  510. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/delivery-intake.js +11 -5
  511. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/delivery-run-assignment.js +6 -10
  512. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/mcp-continuation.js +64 -0
  513. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/prd-definition.js +14 -5
  514. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/sd-definition.js +2 -1
  515. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/service.js +49 -14
  516. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/tp-definition.js +2 -1
  517. package/generated/plugins/copilot/agdf/runtime/runtime-manifest.json +2 -2
  518. package/generated/plugins/copilot/agdf/skills/agdf-brownfield-analysis/SKILL.md +8 -5
  519. package/generated/plugins/copilot/agdf/skills/agdf-clean-implementation-review/SKILL.md +3 -2
  520. package/generated/plugins/copilot/agdf/skills/agdf-code-review/SKILL.md +5 -3
  521. package/generated/plugins/copilot/agdf/skills/agdf-delivery-closeout/SKILL.md +3 -2
  522. package/generated/plugins/copilot/agdf/skills/agdf-delivery-path-search/SKILL.md +3 -2
  523. package/generated/plugins/copilot/agdf/skills/agdf-gate-check/SKILL.md +35 -31
  524. package/generated/plugins/copilot/agdf/skills/agdf-interaction-locales.json +1 -1
  525. package/generated/plugins/copilot/agdf/skills/agdf-prd-definition/SKILL.md +3 -2
  526. package/generated/plugins/copilot/agdf/skills/agdf-qa-gate/SKILL.md +3 -2
  527. package/generated/plugins/copilot/agdf/skills/agdf-release-or/SKILL.md +8 -5
  528. package/generated/plugins/copilot/agdf/skills/agdf-sd-definition/SKILL.md +3 -2
  529. package/generated/plugins/copilot/agdf/skills/agdf-task-plan-review/SKILL.md +3 -2
  530. package/generated/plugins/copilot/agdf/skills/agdf-tp-definition/SKILL.md +3 -2
  531. package/generated/plugins/copilot/agdf/skills/agdf-ur-definition/SKILL.md +12 -4
  532. package/generated/plugins/copilot/agdf/skills/agdf-ux-intent-definition/SKILL.md +5 -4
  533. package/generated/plugins/copilot/agdf/skills/contracts/closeout.md +1 -1
  534. package/generated/plugins/copilot/agdf/skills/contracts/control-scaffold.md +63 -46
  535. package/generated/plugins/copilot/agdf/skills/contracts/gate-artifact-preparation.md +58 -48
  536. package/generated/plugins/copilot/agdf/skills/contracts/gate-transition.md +5 -6
  537. package/generated/plugins/copilot/agdf/skills/contracts/interaction.md +43 -126
  538. package/generated/plugins/copilot/agdf/skills/contracts/modes.md +4 -3
  539. package/generated/plugins/copilot/agdf/skills/contracts/prd-definition.md +6 -6
  540. package/generated/plugins/copilot/agdf/skills/contracts/quality.md +10 -2
  541. package/generated/plugins/copilot/agdf/skills/contracts/request-activation.md +9 -8
  542. package/generated/plugins/copilot/agdf/skills/contracts/sd-definition.md +3 -3
  543. package/generated/plugins/copilot/agdf/skills/contracts/task-target-resolution.md +24 -0
  544. package/generated/plugins/copilot/agdf/skills/contracts/tp-definition.md +1 -1
  545. package/generated/plugins/copilot/agdf/skills/contracts/ur-definition.md +41 -7
  546. package/generated/submissions/openai/agdf/.codex-plugin/plugin.json +1 -1
  547. package/generated/submissions/openai/agdf/meta/agdf-agent-router.md +3 -3
  548. package/generated/submissions/openai/agdf/meta/agdf-defaults.json +9 -0
  549. package/generated/submissions/openai/agdf/meta/agdf-defaults.schema.json +20 -0
  550. package/generated/submissions/openai/agdf/meta/agdf-interaction-locales.json +2668 -2682
  551. package/generated/submissions/openai/agdf/meta/agdf-plugin.definition.json +8 -3
  552. package/generated/submissions/openai/agdf/meta/contracts/closeout.md +1 -1
  553. package/generated/submissions/openai/agdf/meta/contracts/control-scaffold.md +63 -46
  554. package/generated/submissions/openai/agdf/meta/contracts/gate-artifact-preparation.md +58 -48
  555. package/generated/submissions/openai/agdf/meta/contracts/gate-transition.md +5 -6
  556. package/generated/submissions/openai/agdf/meta/contracts/interaction.md +43 -126
  557. package/generated/submissions/openai/agdf/meta/contracts/modes.md +4 -3
  558. package/generated/submissions/openai/agdf/meta/contracts/prd-definition.md +6 -6
  559. package/generated/submissions/openai/agdf/meta/contracts/quality.md +10 -2
  560. package/generated/submissions/openai/agdf/meta/contracts/request-activation.md +9 -8
  561. package/generated/submissions/openai/agdf/meta/contracts/sd-definition.md +3 -3
  562. package/generated/submissions/openai/agdf/meta/contracts/task-target-resolution.md +24 -0
  563. package/generated/submissions/openai/agdf/meta/contracts/tp-definition.md +1 -1
  564. package/generated/submissions/openai/agdf/meta/contracts/ur-definition.md +41 -7
  565. package/generated/submissions/openai/agdf/meta/copilot-payload-baseline.json +3 -3
  566. package/generated/submissions/openai/agdf/meta/distribution-profile-history.json +7 -0
  567. package/generated/submissions/openai/agdf/plugin.json +1 -1
  568. package/generated/submissions/openai/agdf/skills/brownfield-analysis/SKILL.md +8 -5
  569. package/generated/submissions/openai/agdf/skills/clean-implementation-review/SKILL.md +3 -2
  570. package/generated/submissions/openai/agdf/skills/code-review/SKILL.md +5 -3
  571. package/generated/submissions/openai/agdf/skills/delivery-closeout/SKILL.md +3 -2
  572. package/generated/submissions/openai/agdf/skills/delivery-path-search/SKILL.md +3 -2
  573. package/generated/submissions/openai/agdf/skills/gate-check/SKILL.md +35 -31
  574. package/generated/submissions/openai/agdf/skills/prd-definition/SKILL.md +3 -2
  575. package/generated/submissions/openai/agdf/skills/qa-gate/SKILL.md +3 -2
  576. package/generated/submissions/openai/agdf/skills/release-or/SKILL.md +8 -5
  577. package/generated/submissions/openai/agdf/skills/sd-definition/SKILL.md +3 -2
  578. package/generated/submissions/openai/agdf/skills/task-plan-review/SKILL.md +3 -2
  579. package/generated/submissions/openai/agdf/skills/tp-definition/SKILL.md +3 -2
  580. package/generated/submissions/openai/agdf/skills/ur-definition/SKILL.md +12 -4
  581. package/generated/submissions/openai/agdf/skills/ux-intent-definition/SKILL.md +5 -4
  582. package/generated/submissions/openai/agdf/submission/openai/availability.md +1 -1
  583. package/generated/submissions/openai/agdf/submission/openai/capability-matrix.json +1 -1
  584. package/generated/submissions/openai/agdf/submission/openai/inventory.json +49 -41
  585. package/generated/submissions/openai/agdf/submission/openai/listing.json +1 -1
  586. package/generated/submissions/openai/agdf/submission/openai/readiness.json +2 -2
  587. package/generated/submissions/openai/agdf/submission/openai/readiness.md +2 -2
  588. package/generated/submissions/openai/agdf/submission/openai/release-notes.md +9 -1
  589. package/generated/submissions/openai/agdf/submission/openai/reviewer-cases.json +1 -1
  590. package/lib/cli/application.js +31 -43
  591. package/lib/cli/codex-document-command.js +195 -0
  592. package/lib/cli/command-registry.js +82 -148
  593. package/lib/cli/control-maintenance-command.js +8 -37
  594. package/lib/cli/parse-args.js +98 -16
  595. package/lib/cli/planned-command.js +55 -0
  596. package/lib/cli/project-init-command.js +21 -0
  597. package/lib/cli/project-read-command.js +35 -0
  598. package/lib/cli/run-command-aliases.js +116 -0
  599. package/lib/cli/runtime-context.js +1 -59
  600. package/lib/cli/validation-handlers.js +33 -103
  601. package/lib/control-evaluation/git-observation.js +7 -5
  602. package/lib/control-maintenance/startup.js +2 -2
  603. package/lib/host-adapters/codex/plugin.js +48 -1
  604. package/lib/install-setup/contract.js +4 -4
  605. package/lib/install-setup/{control-migration.js → control-compatibility.js} +1 -2
  606. package/lib/install-setup/interaction.js +0 -1
  607. package/lib/install-setup/presentation.js +3 -4
  608. package/lib/install-setup/service.js +5 -18
  609. package/lib/installers/local-marketplace.js +262 -8
  610. package/lib/lifecycle/codex-startup-status.js +29 -0
  611. package/lib/lifecycle/presentation.js +6 -0
  612. package/lib/mcp-decision-protocol.js +40 -0
  613. package/lib/mcp-dispatch-runtime.js +71 -306
  614. package/lib/mcp-lifecycle/adapters/codex-origin-probe.js +28 -4
  615. package/lib/mcp-lifecycle/evidence.js +2 -1
  616. package/lib/mcp-lifecycle/facade-entry.js +3 -24
  617. package/lib/mcp-lifecycle/facade-owner-entry.js +31 -15
  618. package/lib/mcp-lifecycle/facade-runtime.js +29 -0
  619. package/lib/mcp-lifecycle/facade-thread-entry.js +11 -0
  620. package/lib/mcp-lifecycle/owner-client.js +79 -0
  621. package/lib/mcp-lifecycle/package.js +14 -80
  622. package/lib/mcp-lifecycle/plugin-runtime.js +29 -9
  623. package/lib/mcp-lifecycle/service.js +5 -4
  624. package/lib/mcp-lifecycle/thread-owner.js +164 -0
  625. package/lib/mcp-owner-protocol.js +1 -0
  626. package/lib/mcp-protocol-runtime.js +308 -0
  627. package/lib/mcp-worker-runtime.js +152 -0
  628. package/lib/runtime/control-command-service.js +22 -7
  629. package/lib/runtime/control-context.js +8 -1
  630. package/lib/runtime/validator-application.js +2 -2
  631. package/lib/scaffold/canonical-init.js +2 -691
  632. package/lib/scaffold/plan.js +9 -32
  633. package/lib/scaffold/presentation.js +2 -2
  634. package/lib/scaffold/write.js +6 -1
  635. package/package.json +6 -2
  636. package/runtime/core/lib/control-evaluation/closeout-readiness.js +10 -2
  637. package/runtime/core/lib/control-evaluation/decision-content-placeholder.js +9 -0
  638. package/runtime/core/lib/control-evaluation/decision-content-readiness.js +2 -7
  639. package/runtime/core/lib/control-evaluation/definition-sources.js +3 -2
  640. package/runtime/core/lib/control-evaluation/delivery-map.js +2 -12
  641. package/runtime/core/lib/control-evaluation/doctor.js +162 -172
  642. package/runtime/core/lib/control-evaluation/gate-check.js +10 -9
  643. package/runtime/core/lib/control-evaluation/gate-policy-inputs.js +11 -0
  644. package/runtime/core/lib/control-evaluation/gate-policy-pure.js +446 -0
  645. package/runtime/core/lib/control-evaluation/gate-policy.js +3 -434
  646. package/runtime/core/lib/control-evaluation/next-action.js +2 -0
  647. package/runtime/core/lib/control-evaluation/parent-reconciliation.js +2 -1
  648. package/runtime/core/lib/control-evaluation/qa-follow-up.js +2 -1
  649. package/runtime/core/lib/control-evaluation/required-files.js +9 -7
  650. package/runtime/core/lib/control-evaluation/run-state-policy.js +1 -1
  651. package/runtime/core/lib/control-evaluation/run-state.js +15 -9
  652. package/runtime/core/lib/control-evaluation/run-step-policy.js +2 -1
  653. package/runtime/core/lib/control-evaluation/run-work-summary.js +6 -4
  654. package/runtime/core/lib/control-evaluation/shared-value.js +7 -0
  655. package/runtime/core/lib/control-evaluation/shared.js +5 -254
  656. package/runtime/core/lib/control-evaluation/tp-planning.js +3 -2
  657. package/runtime/core/lib/control-evaluation/ur-readiness.js +7 -2
  658. package/runtime/core/lib/control-evaluation/verified-change.js +11 -9
  659. package/{generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/backlog-vocabulary.js → runtime/core/lib/control-evaluation/work-vocabulary.js} +2 -2
  660. package/runtime/core/lib/control-inspect/artifact-readiness.js +5 -3
  661. package/runtime/core/lib/control-inspect/authoring-inputs.js +110 -0
  662. package/runtime/core/lib/control-inspect/cockpit-archive.js +53 -0
  663. package/runtime/core/lib/control-inspect/cockpit-context.js +2 -1
  664. package/runtime/core/lib/control-inspect/cockpit-contract.js +11 -4
  665. package/runtime/core/lib/control-inspect/cockpit-list.d.ts +10 -6
  666. package/runtime/core/lib/control-inspect/cockpit-list.js +32 -41
  667. package/runtime/core/lib/control-inspect/cockpit-session.js +8 -8
  668. package/runtime/core/lib/control-inspect/cockpit-work.js +33 -0
  669. package/runtime/core/lib/control-inspect/cockpit.js +75 -44
  670. package/runtime/core/lib/control-inspect/contract.js +124 -32
  671. package/runtime/core/lib/control-inspect/decision-session.js +53 -11
  672. package/runtime/core/lib/control-inspect/doctor-observation.js +91 -0
  673. package/runtime/core/lib/control-inspect/project-operation-call.js +5 -0
  674. package/runtime/core/lib/control-inspect/project-state.js +48 -0
  675. package/runtime/core/lib/control-inspect/result.js +61 -0
  676. package/runtime/core/lib/control-inspect/selection.js +9 -3
  677. package/runtime/core/lib/control-inspect/service.js +119 -67
  678. package/runtime/core/lib/control-maintenance/compatibility.js +42 -132
  679. package/runtime/core/lib/control-maintenance/contract.js +5 -5
  680. package/runtime/core/lib/control-maintenance/presentation.js +27 -119
  681. package/runtime/core/lib/control-maintenance/service.js +9 -37
  682. package/runtime/core/lib/control-read/cockpit-pool.js +25 -9
  683. package/runtime/core/lib/control-read/cockpit-worker.js +4 -3
  684. package/runtime/core/lib/control-read/doctor-reader.js +92 -0
  685. package/runtime/core/lib/control-read/doctor-worker.js +11 -0
  686. package/runtime/core/lib/control-read/fs.js +18 -0
  687. package/runtime/core/lib/control-read/snapshot.js +68 -17
  688. package/runtime/core/lib/control-state/aggregate.js +3 -1
  689. package/runtime/core/lib/control-state/approval-command.js +13 -10
  690. package/runtime/core/lib/control-state/approval-operations.js +10 -7
  691. package/runtime/core/lib/control-state/artefact-binding-proof.js +12 -20
  692. package/runtime/core/lib/control-state/artefact-bindings.js +10 -7
  693. package/runtime/core/lib/control-state/canonical-initialization.js +761 -0
  694. package/runtime/core/lib/control-state/control-layout.js +183 -0
  695. package/runtime/core/lib/control-state/decision-action-contract.js +10 -1
  696. package/runtime/core/lib/control-state/decision-action-service.js +24 -3
  697. package/runtime/core/lib/control-state/decision-material-contract.js +2 -1
  698. package/runtime/core/lib/control-state/evidence-bindings.js +7 -7
  699. package/runtime/core/lib/control-state/git-identity.js +86 -0
  700. package/runtime/core/lib/control-state/index.js +0 -1
  701. package/runtime/core/lib/control-state/input-resolution.js +99 -0
  702. package/runtime/core/lib/control-state/planned-entry.js +273 -0
  703. package/runtime/core/lib/control-state/planned-handoff.js +174 -0
  704. package/runtime/core/lib/control-state/planned-inventory.js +90 -0
  705. package/runtime/core/lib/control-state/planned-origin-reader.js +48 -0
  706. package/runtime/core/lib/control-state/planned-origin.js +40 -0
  707. package/runtime/core/lib/control-state/presentation-decision.js +12 -7
  708. package/runtime/core/lib/control-state/presentation-delivery.js +90 -0
  709. package/runtime/core/lib/control-state/preview-render.js +5 -2
  710. package/runtime/core/lib/control-state/preview-review.js +3 -2
  711. package/runtime/core/lib/control-state/preview-snapshot.js +9 -6
  712. package/runtime/core/lib/control-state/recording-formats.js +12 -16
  713. package/runtime/core/lib/control-state/run-artefact-recording.js +54 -66
  714. package/runtime/core/lib/control-state/run-closure.js +343 -0
  715. package/runtime/core/lib/control-state/run-command-contract.js +33 -250
  716. package/runtime/core/lib/control-state/run-command-schema.js +508 -0
  717. package/runtime/core/lib/control-state/run-command-service.js +198 -34
  718. package/runtime/core/lib/control-state/run-create-command.js +60 -0
  719. package/runtime/core/lib/control-state/run-identity.d.ts +14 -0
  720. package/runtime/core/lib/control-state/run-identity.js +40 -0
  721. package/runtime/core/lib/control-state/run-input-resolution.js +72 -0
  722. package/runtime/core/lib/control-state/run-inventory-reader.js +31 -0
  723. package/runtime/core/lib/control-state/run-inventory.js +179 -0
  724. package/runtime/core/lib/control-state/run-material.js +211 -0
  725. package/runtime/core/lib/control-state/run-mutation.js +51 -0
  726. package/runtime/core/lib/control-state/run-operation-identity.js +2 -1
  727. package/runtime/core/lib/control-state/run-operation-proof.js +7 -4
  728. package/runtime/core/lib/control-state/run-operation-status.js +20 -4
  729. package/runtime/core/lib/control-state/run-operations.js +70 -13
  730. package/runtime/core/lib/control-state/run-owned-outputs.js +21 -9
  731. package/runtime/core/lib/control-state/run-presentation-envelope.js +25 -33
  732. package/runtime/core/lib/control-state/run-presentation-render.js +8 -7
  733. package/runtime/core/lib/control-state/run-presentation.js +45 -21
  734. package/runtime/core/lib/control-state/run-recording.js +10 -179
  735. package/runtime/core/lib/control-state/run-revision-boundary.js +7 -21
  736. package/runtime/core/lib/control-state/run-revision-history.js +23 -16
  737. package/runtime/core/lib/control-state/run-revision.js +84 -161
  738. package/runtime/core/lib/control-state/run-seal-compute.js +19 -44
  739. package/runtime/core/lib/control-state/run-seal.js +6 -1
  740. package/runtime/core/lib/control-state/run-source-revisions.js +19 -18
  741. package/runtime/core/lib/control-state/run-state-document.js +110 -42
  742. package/runtime/core/lib/control-state/run-state-edits.js +13 -5
  743. package/runtime/core/lib/control-state/run-state-parser.js +14 -6
  744. package/runtime/core/lib/control-state/run-state-reader.js +27 -18
  745. package/runtime/core/lib/control-state/run-state-repository.js +112 -48
  746. package/runtime/core/lib/control-state/run-state-resolver.js +12 -15
  747. package/runtime/core/lib/control-state/run-state-writer.js +21 -377
  748. package/runtime/core/lib/control-state/run-step-pending.js +2 -1
  749. package/runtime/core/lib/control-state/run-step-transaction.js +125 -114
  750. package/runtime/core/lib/control-state/run-steps.js +136 -248
  751. package/runtime/core/lib/control-state/run-store-inspection.js +14 -2
  752. package/runtime/core/lib/control-state/run-verified-change.js +81 -0
  753. package/runtime/core/lib/control-state/run-work-summary-shape.d.ts +1 -0
  754. package/{generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/backlog-summary-shape.js → runtime/core/lib/control-state/run-work-summary-shape.js} +7 -19
  755. package/runtime/core/lib/delivery-continuation/service.js +5 -66
  756. package/runtime/core/lib/delivery-path-search/persistence.js +26 -8
  757. package/runtime/core/lib/delivery-path-search/state-adapter.js +1 -1
  758. package/runtime/core/lib/index.js +14 -6
  759. package/runtime/core/lib/interaction-catalog.js +3 -3
  760. package/runtime/core/lib/interaction-presentation.js +29 -11
  761. package/runtime/core/lib/mcp-input-hints.js +46 -0
  762. package/runtime/core/lib/mcp-input-resolution.js +98 -0
  763. package/runtime/core/lib/mcp-input-schema.js +15 -0
  764. package/runtime/core/lib/mcp-resource-contract.js +1 -1
  765. package/runtime/core/lib/mcp-tool-errors.js +31 -15
  766. package/runtime/core/lib/owned-file-lock.js +266 -0
  767. package/runtime/core/lib/owner-placement.js +50 -0
  768. package/runtime/core/lib/resources/canonical-init-plan.js +34 -0
  769. package/runtime/core/lib/resources/configuration.js +92 -0
  770. package/runtime/core/lib/resources/context.js +7 -11
  771. package/runtime/core/lib/resources/language-preference.js +59 -0
  772. package/runtime/core/lib/runtime/mcp-owner-protocol.js +102 -0
  773. package/runtime/core/lib/runtime/plugin-provenance.js +173 -18
  774. package/runtime/core/lib/skill-dispatch/compact-continuation.js +3 -3
  775. package/runtime/core/lib/skill-dispatch/contract.js +28 -9
  776. package/runtime/core/lib/skill-dispatch/delivery-intake.js +11 -5
  777. package/runtime/core/lib/skill-dispatch/delivery-run-assignment.js +6 -10
  778. package/runtime/core/lib/skill-dispatch/mcp-continuation.js +64 -0
  779. package/runtime/core/lib/skill-dispatch/prd-definition.js +14 -5
  780. package/runtime/core/lib/skill-dispatch/sd-definition.js +2 -1
  781. package/runtime/core/lib/skill-dispatch/service.js +49 -14
  782. package/runtime/core/lib/skill-dispatch/tp-definition.js +2 -1
  783. package/generated/.agdf/control/templates/AGDF_RUN.md +0 -139
  784. package/generated/.agdf/control/templates/MASTER_BACKLOG.md +0 -39
  785. package/generated/plugins/agdf/control/templates/AGDF_RUN.md +0 -139
  786. package/generated/plugins/agdf/control/templates/MASTER_BACKLOG.md +0 -39
  787. package/generated/plugins/agdf/runtime/create-agdf/lib/control-maintenance/interaction.js +0 -28
  788. package/generated/plugins/agdf/runtime/create-agdf/lib/control-maintenance/repair.js +0 -4
  789. package/generated/plugins/agdf/runtime/create-agdf/lib/control-maintenance/service.js +0 -3
  790. package/generated/plugins/agdf/runtime/create-agdf/lib/control-state/run-recovery.js +0 -5
  791. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit-backlog.js +0 -135
  792. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/interaction.js +0 -57
  793. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/migration.js +0 -85
  794. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/repair.js +0 -226
  795. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/backlog-summary-shape.d.ts +0 -4
  796. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/backlog-summary.js +0 -67
  797. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/legacy-migration.js +0 -69
  798. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/legacy-projection-reader.js +0 -38
  799. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-backlog-writer.js +0 -80
  800. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-backlog.js +0 -90
  801. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-recovery.js +0 -296
  802. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-relationship-correction.js +0 -74
  803. package/generated/plugins/copilot/agdf/control/templates/AGDF_RUN.md +0 -139
  804. package/generated/plugins/copilot/agdf/control/templates/MASTER_BACKLOG.md +0 -39
  805. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/control-maintenance/interaction.js +0 -28
  806. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/control-maintenance/repair.js +0 -4
  807. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/control-maintenance/service.js +0 -3
  808. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/control-state/run-recovery.js +0 -5
  809. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/interaction.js +0 -57
  810. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/migration.js +0 -85
  811. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-maintenance/repair.js +0 -226
  812. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/backlog-summary-shape.d.ts +0 -4
  813. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/backlog-summary.js +0 -67
  814. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/legacy-migration.js +0 -69
  815. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/legacy-projection-reader.js +0 -38
  816. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-backlog-writer.js +0 -80
  817. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-backlog.js +0 -90
  818. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-recovery.js +0 -296
  819. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-relationship-correction.js +0 -74
  820. package/lib/control-maintenance/interaction.js +0 -28
  821. package/lib/control-maintenance/repair.js +0 -4
  822. package/lib/control-maintenance/service.js +0 -3
  823. package/lib/control-state/run-recovery.js +0 -5
  824. package/lib/install-setup/control-repair.js +0 -1
  825. package/runtime/core/lib/control-inspect/cockpit-backlog.js +0 -135
  826. package/runtime/core/lib/control-maintenance/interaction.js +0 -57
  827. package/runtime/core/lib/control-maintenance/migration.js +0 -85
  828. package/runtime/core/lib/control-maintenance/repair.js +0 -226
  829. package/runtime/core/lib/control-state/backlog-summary-shape.d.ts +0 -4
  830. package/runtime/core/lib/control-state/backlog-summary.js +0 -67
  831. package/runtime/core/lib/control-state/legacy-migration.js +0 -69
  832. package/runtime/core/lib/control-state/legacy-projection-reader.js +0 -38
  833. package/runtime/core/lib/control-state/run-backlog-writer.js +0 -80
  834. package/runtime/core/lib/control-state/run-backlog.js +0 -90
  835. package/runtime/core/lib/control-state/run-recovery.js +0 -296
  836. package/runtime/core/lib/control-state/run-relationship-correction.js +0 -74
@@ -0,0 +1,273 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { existsSync, lstatSync, mkdirSync, readdirSync, unlinkSync } from 'node:fs';
3
+ import { join, dirname } from 'node:path';
4
+ import { atomicWrite, fsyncDirectory, withOwnedFileLock } from '../owned-file-lock.js';
5
+ import { renameSyncWithRetry } from '../fs-swap.js';
6
+ import { canonicalRunText } from './run-seal-compute.js';
7
+ import { exactObject, canonicalJson } from './approval-command-contract.js';
8
+ import { RUN_ID_PATTERN, REVISION_ID_PATTERN } from './run-identity.js';
9
+ import { hasSymlinkComponent, containedRegularFile } from './contained-file.js';
10
+ import { CURRENT_LAYOUT, readControlLayout, withControlMutation, withControlRecovery, inspectMutationClaims, markControlMutationEffect } from './control-layout.js';
11
+ import { evaluateUrContentReadiness } from '../control-evaluation/ur-readiness.js';
12
+ import { resolveArtifactPresentationLanguages } from '../resources/context.js';
13
+ import { readContainedControlText, controlPathPresent } from '../control-read/snapshot.js';
14
+ import { assertPlannedNotTransferred } from './planned-origin-reader.js';
15
+ import { bindInputResolution, resolutionRecord } from './input-resolution.js';
16
+ import { existsSync as observedExists } from '../control-read/fs.js';
17
+
18
+ export const PLANNED_SCHEMA = 'planned-ur-v1';
19
+ export const PLANNED_ROOT = '.agdf/control/planned';
20
+ export const PLANNED_INTENT_BYTES = 1048576;
21
+ export const plannedTextDigest = text => 'sha256:' + createHash('sha256').update(canonicalRunText(text)).digest('hex');
22
+ export const plannedRawDigest = text => 'sha256:' + createHash('sha256').update(text).digest('hex');
23
+ const digestPattern = /^sha256:[a-f0-9]{64}$/u;
24
+ const fail = code => { throw Error(code); };
25
+ const priorities = ['high', 'normal', 'low'];
26
+ const json = value => JSON.stringify(value) + '\n';
27
+ export const planningId = operationId => {
28
+ if (!REVISION_ID_PATTERN.test(operationId)) fail('AGDF_PLANNED_OPERATION_INVALID');
29
+ return `plan-${operationId}`;
30
+ };
31
+ export function plannedEntryPath(id) {
32
+ if (typeof id !== 'string' || !RUN_ID_PATTERN.test(id)) fail('AGDF_PLANNED_ID_INVALID');
33
+ return `${PLANNED_ROOT}/${id}`;
34
+ }
35
+
36
+ function safeRead(root, path, limit = 131072) {
37
+ try { return readContainedControlText(root, path, limit); }
38
+ catch (error) { if (error.code === 'resource_denied') fail('AGDF_PLANNED_PATH_INVALID'); throw error; }
39
+ }
40
+ function ensureDirectory(root, relative) {
41
+ if (hasSymlinkComponent(root, relative)) fail('AGDF_PLANNED_PATH_INVALID');
42
+ const path = join(root, relative);
43
+ if (!existsSync(path)) {
44
+ try { mkdirSync(path, { mode: 0o700 }); fsyncDirectory(dirname(path)); }
45
+ catch (error) { if (error.code !== 'EEXIST') throw error; }
46
+ }
47
+ const stat = lstatSync(path);
48
+ if (!stat.isDirectory() || stat.isSymbolicLink()) fail('AGDF_PLANNED_PATH_INVALID');
49
+ }
50
+ function validateContent(content) {
51
+ if (typeof content !== 'string' || !content.isWellFormed() || Buffer.byteLength(content) > 131072
52
+ || /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/u.test(content)) fail('AGDF_PLANNED_CONTENT_INVALID');
53
+ return canonicalRunText(content);
54
+ }
55
+ export function parsePlannedUr(content, expectedId) {
56
+ const text = validateContent(content), metadata = text.split(/^##[ \t]+/mu)[0];
57
+ const field = key => {
58
+ const rows = [...metadata.matchAll(new RegExp(`^${key}:[ \\t]*([^\\n]*)$`, 'gmu'))];
59
+ if (rows.length !== 1) fail('AGDF_PLANNED_METADATA_INVALID');
60
+ return rows[0][1].trim();
61
+ };
62
+ const schema = field('Planning schema'), id = field('Planning id'), priority = field('Planning priority');
63
+ if (schema !== PLANNED_SCHEMA || !RUN_ID_PATTERN.test(id) || expectedId && id !== expectedId || !priorities.includes(priority)) fail('AGDF_PLANNED_METADATA_INVALID');
64
+ const titles = [...text.matchAll(/^# ([^\n]+)$/gmu)];
65
+ if (titles.length !== 1 || !text.startsWith('# ') || !titles[0][1].trim() || titles[0][1].length > 1024) fail('AGDF_PLANNED_TITLE_INVALID');
66
+ const title = titles[0][1].replace(/^UR:[ \t]*/u, '').trim();
67
+ if (!title) fail('AGDF_PLANNED_TITLE_INVALID');
68
+ return { schema, plan_id: id, priority, title, content: text, digest: plannedTextDigest(text) };
69
+ }
70
+
71
+ export function preparePlannedUr(content, id, priority = 'normal') {
72
+ plannedEntryPath(id);
73
+ const text = validateContent(content);
74
+ if (!priorities.includes(priority) || /^Planning (schema|id|priority):/mu.test(text)) fail('AGDF_PLANNED_METADATA_INVALID');
75
+ const end = text.indexOf('\n');
76
+ if (end < 0) fail('AGDF_PLANNED_TITLE_INVALID');
77
+ const candidate = text.slice(0, end + 1) + `\nPlanning schema: ${PLANNED_SCHEMA}\nPlanning id: ${id}\nPlanning priority: ${priority}\n` + text.slice(end + 1);
78
+ return parsePlannedUr(candidate, id).content;
79
+ }
80
+
81
+ export function inspectPlannedEntry(root, id, { presentationLanguage } = {}) {
82
+ const path = `${plannedEntryPath(id)}/UR.md`;
83
+ const raw = safeRead(root, path), entry = parsePlannedUr(raw, id);
84
+ const readiness = evaluateUrContentReadiness(entry.content, { languages: resolveArtifactPresentationLanguages(root, presentationLanguage), path, requireClarification: true });
85
+ return { ...entry, raw_digest: plannedRawDigest(raw), path, readiness, pending: controlPathPresent(root, `${plannedEntryPath(id)}/MUTATION_PENDING.json`), authorizes: false };
86
+ }
87
+
88
+ export function withPlannedEntryLock(root, id, work, { operation_id, recovery = false, resume = false, proveOutcome, checkpoint } = {}) {
89
+ const path = plannedEntryPath(id);
90
+ readControlLayout(root);
91
+ ensureDirectory(root, PLANNED_ROOT);
92
+ if (hasSymlinkComponent(root, path)) fail('AGDF_PLANNED_PATH_INVALID');
93
+ return withOwnedFileLock(join(root, PLANNED_ROOT, `.entry-${id}`), () => {
94
+ const resource = `planned:${id}`;
95
+ const recovering = recovery || resume && inspectMutationClaims(root, { strict: false }).some(row => row.resource === resource && row.operation_id === operation_id);
96
+ return recovering ? withControlRecovery(root, { resource, operation_id, proveOutcome }, work)
97
+ : withControlMutation(root, { resource, operation_id, checkpoint }, work);
98
+ });
99
+ }
100
+
101
+ function validReceipt(receipt, id) {
102
+ receipt = resolutionRecord(receipt);
103
+ if (!receipt) return false;
104
+ return exactObject(receipt, ['schema_version', 'kind', 'operation_id', 'plan_id', 'request_digest', 'previous_digest', 'resulting_digest'])
105
+ && receipt.schema_version === 1 && ['planned_ur.create', 'planned_ur.replace'].includes(receipt.kind)
106
+ && REVISION_ID_PATTERN.test(receipt.operation_id) && receipt.plan_id === id && digestPattern.test(receipt.request_digest)
107
+ && (receipt.previous_digest === null || digestPattern.test(receipt.previous_digest)) && digestPattern.test(receipt.resulting_digest)
108
+ && (receipt.kind === 'planned_ur.create' ? receipt.previous_digest === null : receipt.previous_digest !== null);
109
+ }
110
+ function receiptPath(id, operationId) { return `${plannedEntryPath(id)}/operations/${operationId}.json`; }
111
+ function receiptAt(root, id, operationId) {
112
+ const path = receiptPath(id, operationId);
113
+ if (!existsSync(join(root, path))) return null;
114
+ let receipt; try { receipt = JSON.parse(safeRead(root, path, 16384)); } catch { fail('AGDF_PLANNED_RECOVERY_REQUIRED'); }
115
+ if (!validReceipt(receipt, id) || receipt.operation_id !== operationId) fail('AGDF_PLANNED_RECOVERY_REQUIRED');
116
+ return receipt;
117
+ }
118
+ function publishReceipt(root, receipt) {
119
+ const path = receiptPath(receipt.plan_id, receipt.operation_id);
120
+ ensureDirectory(root, `${plannedEntryPath(receipt.plan_id)}/operations`);
121
+ if (existsSync(join(root, path))) {
122
+ if (safeRead(root, path, 16384) !== json(receipt)) fail('AGDF_PLANNED_RECOVERY_REQUIRED');
123
+ } else atomicWrite(join(root, path), json(receipt));
124
+ }
125
+ function readIntent(root, id) {
126
+ const path = `${plannedEntryPath(id)}/MUTATION_PENDING.json`;
127
+ let intent; try { intent = JSON.parse(safeRead(root, path, PLANNED_INTENT_BYTES)); } catch { fail('AGDF_PLANNED_RECOVERY_REQUIRED'); }
128
+ if (!exactObject(intent, ['schema_version', 'receipt', 'old', 'next']) || intent.schema_version !== 1
129
+ || !validReceipt(intent.receipt, id) || intent.receipt.kind !== 'planned_ur.replace'
130
+ || typeof intent.old !== 'string' || typeof intent.next !== 'string'
131
+ || parsePlannedUr(intent.old, id).digest !== intent.receipt.previous_digest
132
+ || parsePlannedUr(intent.next, id).digest !== intent.receipt.resulting_digest) fail('AGDF_PLANNED_RECOVERY_REQUIRED');
133
+ return { path, intent };
134
+ }
135
+ export function recoverPlannedMutationLocked(root, id, operationId) {
136
+ const path = `${plannedEntryPath(id)}/MUTATION_PENDING.json`;
137
+ if (!existsSync(join(root, path))) return { status: 'none' };
138
+ const { intent } = readIntent(root, id);
139
+ if (intent.receipt.operation_id !== operationId) fail('AGDF_PLANNED_RECOVERY_REQUIRED');
140
+ const current = safeRead(root, `${plannedEntryPath(id)}/UR.md`);
141
+ let status;
142
+ if (current === intent.old) status = 'rolled_back';
143
+ else if (current === intent.next) { publishReceipt(root, intent.receipt); status = 'completed'; }
144
+ else fail('AGDF_PLANNED_RECOVERY_REQUIRED');
145
+ unlinkSync(join(root, path)); fsyncDirectory(join(root, plannedEntryPath(id)));
146
+ return { status, receipt: status === 'completed' ? intent.receipt : null };
147
+ }
148
+
149
+ export function recoverPlannedMutation(root, id, operationId) {
150
+ return withPlannedEntryLock(root, id, () => recoverPlannedMutationLocked(root, id, operationId), {
151
+ recovery: true, operation_id: operationId, proveOutcome: result => ['none', 'completed', 'rolled_back'].includes(result.status),
152
+ });
153
+ }
154
+
155
+ export function inspectPlannedOperation(root, id, operationId) {
156
+ plannedEntryPath(id);
157
+ if (!REVISION_ID_PATTERN.test(operationId ?? '')) fail('AGDF_PLANNED_OPERATION_INVALID');
158
+ const receipt = receiptAt(root, id, operationId);
159
+ const pendingPath = `${plannedEntryPath(id)}/MUTATION_PENDING.json`;
160
+ const pending = observedExists(join(root, pendingPath)) ? readIntent(root, id).intent.receipt : null;
161
+ const stagePath = `${PLANNED_ROOT}/.stage-${id}-${operationId}/OWNER.json`;
162
+ let creation = null;
163
+ if (observedExists(join(root, stagePath))) {
164
+ creation = JSON.parse(safeRead(root, stagePath, 16384));
165
+ if (!validReceipt(creation, id) || creation.operation_id !== operationId) fail('AGDF_PLANNED_RECOVERY_REQUIRED');
166
+ }
167
+ return { status: receipt ? pending?.operation_id === operationId ? 'committed_recovery_required' : 'recorded'
168
+ : pending?.operation_id === operationId || creation ? 'pending' : 'absent', receipt,
169
+ pending: pending?.operation_id === operationId ? pending : creation, authorizes: false };
170
+ }
171
+
172
+ export function inspectPlannedSelection(root, scope, options) {
173
+ plannedEntryPath(scope.plan_id);
174
+ if (readControlLayout(root).layout !== CURRENT_LAYOUT) fail('AGDF_CONTROL_LAYOUT_MIGRATION_REQUIRED');
175
+ if (scope.expected_digest === null) return { available: true, planning: scope, authorizes: false };
176
+ const entry = inspectPlannedEntry(root, scope.plan_id, options);
177
+ if (entry.digest !== scope.expected_digest) {
178
+ if (!entry.pending || readIntent(root, scope.plan_id).intent.receipt.previous_digest !== scope.expected_digest) fail('AGDF_PLANNED_SOURCE_STALE');
179
+ }
180
+ return { available: true, planning: scope, source_digest: entry.digest, authorizes: false };
181
+ }
182
+
183
+ export function replayPlannedUr(root, { plan_id, operation_id, request_digest }) {
184
+ return withPlannedEntryLock(root, plan_id, () => {
185
+ const previous = receiptAt(root, plan_id, operation_id);
186
+ if (!previous || previous.request_digest !== request_digest) fail('AGDF_OPERATION_PAYLOAD_CONFLICT');
187
+ if (existsSync(join(root, plannedEntryPath(plan_id), 'MUTATION_PENDING.json')) && readIntent(root, plan_id).intent.receipt.operation_id === operation_id)
188
+ recoverPlannedMutationLocked(root, plan_id, operation_id);
189
+ return { outcome: 'already_applied', receipt: previous, entry: inspectPlannedEntry(root, plan_id) };
190
+ }, { operation_id, resume: true, proveOutcome: result => result.outcome === 'already_applied' });
191
+ }
192
+
193
+ // Source content is the only editable authority. Receipts retain operation/source
194
+ // history but are never used as a saved title, priority, status or approval.
195
+ export function mutatePlannedUr(root, { kind, operation_id, plan_id = planningId(operation_id), expected_digest, content, priority, request_digest: commandDigest }, { checkpoint = () => {} } = {}) {
196
+ if (!['planned_ur.create', 'planned_ur.replace'].includes(kind) || !REVISION_ID_PATTERN.test(operation_id)
197
+ || kind === 'planned_ur.create' && (expected_digest !== null || plan_id !== planningId(operation_id))
198
+ || kind === 'planned_ur.replace' && (!digestPattern.test(expected_digest) || priority !== undefined)) fail('AGDF_PLANNED_OPERATION_INVALID');
199
+ const text = kind === 'planned_ur.create' ? preparePlannedUr(content, plan_id, priority) : parsePlannedUr(content, plan_id).content;
200
+ if (commandDigest !== undefined && !digestPattern.test(commandDigest)) fail('AGDF_PLANNED_OPERATION_INVALID');
201
+ const request_digest = commandDigest ?? plannedTextDigest(canonicalJson({ kind, plan_id, expected_digest, content: text }));
202
+ let effectStarted = false;
203
+ const execute = () => {
204
+ const base = plannedEntryPath(plan_id), destination = join(root, base);
205
+ const existing = receiptAt(root, plan_id, operation_id);
206
+ if (existing) {
207
+ if (existing.kind !== kind || existing.request_digest !== request_digest) fail('AGDF_OPERATION_PAYLOAD_CONFLICT');
208
+ if (existsSync(join(destination, 'MUTATION_PENDING.json')) && readIntent(root, plan_id).intent.receipt.operation_id === operation_id)
209
+ recoverPlannedMutationLocked(root, plan_id, operation_id);
210
+ return { outcome: 'already_applied', receipt: existing, entry: inspectPlannedEntry(root, plan_id) };
211
+ }
212
+ if (existsSync(join(destination, 'MUTATION_PENDING.json'))) {
213
+ if (readIntent(root, plan_id).intent.receipt.request_digest !== request_digest) fail('AGDF_OPERATION_PAYLOAD_CONFLICT');
214
+ recoverPlannedMutationLocked(root, plan_id, operation_id);
215
+ const recovered = receiptAt(root, plan_id, operation_id);
216
+ if (recovered) {
217
+ if (recovered.request_digest !== request_digest) fail('AGDF_OPERATION_PAYLOAD_CONFLICT');
218
+ return { outcome: 'already_applied', receipt: recovered, entry: inspectPlannedEntry(root, plan_id) };
219
+ }
220
+ }
221
+ for (const name of ['HANDOFF_PENDING.json', 'TRANSFER.json'])
222
+ if (existsSync(join(destination, name))) fail('AGDF_PLANNED_ALREADY_TRANSFERRED');
223
+ assertPlannedNotTransferred(root, plan_id);
224
+ const receipt = bindInputResolution({ schema_version: 1, kind, operation_id, plan_id, request_digest,
225
+ previous_digest: expected_digest, resulting_digest: plannedTextDigest(text) });
226
+ if (kind === 'planned_ur.create') {
227
+ if (existsSync(destination)) fail('AGDF_PLANNED_COLLISION');
228
+ const stage = `${PLANNED_ROOT}/.stage-${plan_id}-${operation_id}`, stagePath = join(root, stage);
229
+ if (hasSymlinkComponent(root, stage)) fail('AGDF_PLANNED_PATH_INVALID');
230
+ if (existsSync(stagePath)) {
231
+ if (!lstatSync(stagePath).isDirectory() || readdirSync(stagePath).some(name => !['OWNER.json', 'UR.md', 'operations'].includes(name))
232
+ || safeRead(root, `${stage}/OWNER.json`, 16384) !== json(receipt)) fail('AGDF_PLANNED_RECOVERY_REQUIRED');
233
+ if (existsSync(join(stagePath, 'UR.md')) && safeRead(root, `${stage}/UR.md`) !== text) fail('AGDF_PLANNED_RECOVERY_REQUIRED');
234
+ if (existsSync(join(stagePath, 'operations'))) {
235
+ ensureDirectory(root, `${stage}/operations`);
236
+ if (readdirSync(join(stagePath, 'operations')).some(name => name !== `${operation_id}.json`)
237
+ || existsSync(join(stagePath, 'operations', `${operation_id}.json`)) && safeRead(root, `${stage}/operations/${operation_id}.json`, 16384) !== json(receipt)) fail('AGDF_PLANNED_RECOVERY_REQUIRED');
238
+ }
239
+ } else {
240
+ effectStarted = true;
241
+ markControlMutationEffect();
242
+ ensureDirectory(root, stage);
243
+ atomicWrite(join(stagePath, 'OWNER.json'), json(receipt)); checkpoint('create_intent');
244
+ }
245
+ effectStarted = true;
246
+ markControlMutationEffect();
247
+ if (!existsSync(join(stagePath, 'UR.md'))) atomicWrite(join(stagePath, 'UR.md'), text);
248
+ checkpoint('create_source');
249
+ ensureDirectory(root, `${stage}/operations`);
250
+ if (!existsSync(join(stagePath, 'operations', `${operation_id}.json`))) atomicWrite(join(stagePath, 'operations', `${operation_id}.json`), json(receipt));
251
+ fsyncDirectory(join(stagePath, 'operations')); fsyncDirectory(stagePath); checkpoint('create_staged');
252
+ renameSyncWithRetry(stagePath, destination); fsyncDirectory(join(root, PLANNED_ROOT)); checkpoint('create_committed');
253
+ } else {
254
+ const old = safeRead(root, `${base}/UR.md`);
255
+ if (parsePlannedUr(old, plan_id).digest !== expected_digest) fail('AGDF_PLANNED_SOURCE_STALE');
256
+ if (old === text) fail('AGDF_PLANNED_SOURCE_UNCHANGED');
257
+ effectStarted = true;
258
+ markControlMutationEffect();
259
+ atomicWrite(join(destination, 'MUTATION_PENDING.json'), json({ schema_version: 1, receipt, old, next: text })); checkpoint('replace_intent');
260
+ atomicWrite(join(destination, 'UR.md'), text); checkpoint('replace_committed');
261
+ publishReceipt(root, receipt); checkpoint('replace_receipt');
262
+ unlinkSync(join(destination, 'MUTATION_PENDING.json')); fsyncDirectory(destination); checkpoint('replace_retired');
263
+ }
264
+ return { outcome: 'accepted', receipt, entry: inspectPlannedEntry(root, plan_id) };
265
+ };
266
+ return withPlannedEntryLock(root, plan_id, () => {
267
+ try { return execute(); }
268
+ catch (error) {
269
+ if (!effectStarted || /RECOVERY_REQUIRED/u.test(error.message)) throw error;
270
+ throw Object.assign(Error('AGDF_PLANNED_RECOVERY_REQUIRED'), { cause: error, operation_id, plan_id });
271
+ }
272
+ }, { operation_id, resume: true, proveOutcome: result => ['accepted', 'already_applied'].includes(result.outcome) });
273
+ }
@@ -0,0 +1,174 @@
1
+ import { RUN_OPERATION_VERSION } from './run-operations.js';
2
+ import { runDocumentPath, runHistoryPath } from './run-identity.js';
3
+ import { existsSync, lstatSync, mkdirSync, unlinkSync, readdirSync, rmdirSync } from 'node:fs';
4
+ import { join, dirname } from 'node:path';
5
+ import { atomicWrite, fsyncDirectory, withOwnedFileLock } from '../owned-file-lock.js';
6
+ import { readContainedControlText, controlPathPresent } from '../control-read/snapshot.js';
7
+ import { inspectPlannedEntry, withPlannedEntryLock, plannedEntryPath, plannedTextDigest, plannedRawDigest, PLANNED_INTENT_BYTES } from './planned-entry.js';
8
+ import { inspectPlannedOrigins } from './planned-origin-reader.js';
9
+ import { validPlannedOrigin } from './planned-origin.js';
10
+ import { exactObject, canonicalJson, digest, COOPERATIVE_ASSURANCE, resolveControlCommandTarget } from './approval-command-contract.js';
11
+ import { REVISION_ID_PATTERN, creationRunId } from './run-identity.js';
12
+ import { hasSymlinkComponent } from './contained-file.js';
13
+ import { markControlMutationEffect, withControlRecovery } from './control-layout.js';
14
+ import { createRun, recoverRunCreationStage } from './run-state-repository.js';
15
+ import { parseRunState } from './run-state-parser.js';
16
+ import { readRunOperations, appendRunOperation } from './run-operations.js';
17
+ import { projectUrObjective, upsertTableRow, appendTableRow, replaceFirstScalar } from './run-state-edits.js';
18
+ import { runSealState, computeRunSeals } from './run-seal.js';
19
+ import { bindInputResolution, resolutionRecord, recordedInputResolution } from './input-resolution.js';
20
+
21
+ const json = value => JSON.stringify(value) + '\n';
22
+ const fail = code => { throw Error(code); };
23
+ function ensureDirectory(root, path) {
24
+ if (hasSymlinkComponent(root, path)) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
25
+ const full = join(root, path);
26
+ if (!existsSync(full)) { mkdirSync(full, { mode: 0o700 }); fsyncDirectory(dirname(full)); }
27
+ if (!lstatSync(full).isDirectory() || lstatSync(full).isSymbolicLink()) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
28
+ }
29
+ function validateIntent(stored, id) {
30
+ const intent = resolutionRecord(stored);
31
+ if (!intent) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
32
+ if (!exactObject(intent, ['schema_version', 'origin', 'outputs']) || intent.schema_version !== 1 || !validPlannedOrigin(intent.origin)
33
+ || intent.origin.plan_id !== id || !Array.isArray(intent.outputs) || intent.outputs.length !== 2) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
34
+ const { origin, outputs } = intent, base = `${runDocumentPath(origin.run_id, '')}/`;
35
+ const expected = [origin.initial_ur.path, origin.snapshot.path];
36
+ if (outputs.some((row, i) => !exactObject(row, ['path', 'content', 'digest']) || row.path !== expected[i]
37
+ || typeof row.content !== 'string' || Buffer.byteLength(row.content) > 131072 || plannedTextDigest(row.content) !== row.digest)
38
+ || outputs[0].content !== outputs[1].content || outputs[0].digest !== origin.planned.digest
39
+ || plannedRawDigest(outputs[1].content) !== origin.raw_digest) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
40
+ const resolution = recordedInputResolution(stored);
41
+ if (resolution && (resolution.operation_id !== intent.origin.operation_id || resolution.kind !== 'run.create_from_planned'
42
+ || resolution.effective_digest !== intent.origin.request_digest)) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
43
+ return stored;
44
+ }
45
+ function transferRecord(origin, originDigest) {
46
+ return { schema_version: 1, plan_id: origin.plan_id, run_id: origin.run_id, operation_id: origin.operation_id,
47
+ request_digest: origin.request_digest, source_digest: origin.planned.digest, origin_digest: originDigest };
48
+ }
49
+ function finishEntry(root, origin, originDigest, checkpoint) {
50
+ const base = plannedEntryPath(origin.plan_id), transfer = `${base}/TRANSFER.json`, pending = `${base}/HANDOFF_PENDING.json`;
51
+ const receipt = transferRecord(origin, originDigest), text = json(receipt);
52
+ if (existsSync(join(root, transfer))) {
53
+ if (readContainedControlText(root, transfer, 4096) !== text) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
54
+ } else { markControlMutationEffect(); atomicWrite(join(root, transfer), text); checkpoint('handoff_entry_receipt'); }
55
+ if (existsSync(join(root, pending))) {
56
+ const intent = validateIntent(JSON.parse(readContainedControlText(root, pending, PLANNED_INTENT_BYTES)), origin.plan_id);
57
+ if (canonicalJson(intent.origin) !== canonicalJson(origin)) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
58
+ unlinkSync(join(root, pending)); fsyncDirectory(join(root, base)); checkpoint('handoff_retired');
59
+ }
60
+ return receipt;
61
+ }
62
+
63
+ export function inspectPlannedHandoffOperation(root, planId, operationId) {
64
+ plannedEntryPath(planId);
65
+ if (!REVISION_ID_PATTERN.test(operationId ?? '')) fail('AGDF_PLANNED_HANDOFF_INPUT_INVALID');
66
+ const observed = inspectPlannedOrigins(root, planId);
67
+ if (!observed.complete) return { status: 'unknown', reason: 'planned_origin_unconfirmed', findings: observed.findings, authorizes: false };
68
+ const known = observed.matches[0], path = `${plannedEntryPath(planId)}/HANDOFF_PENDING.json`;
69
+ if (known) {
70
+ if (known.origin.operation_id !== operationId) return { status: 'already_transferred', run_id: known.run_id, authorizes: false };
71
+ return { status: existsSync(join(root, path)) ? 'committed_recovery_required' : 'recorded', receipt: known.receipt,
72
+ request_digest: known.origin.request_digest, run_id: known.run_id, historical_effect: true, authorizes: false };
73
+ }
74
+ if (controlPathPresent(root, `${plannedEntryPath(planId)}/TRANSFER.json`)) return { status: 'unknown', reason: 'planned_transfer_unconfirmed', authorizes: false };
75
+ if (!existsSync(join(root, path))) return { status: 'absent', reason: 'absence_is_not_proof_of_non_execution', authorizes: false };
76
+ const pending = validateIntent(JSON.parse(readContainedControlText(root, path, PLANNED_INTENT_BYTES)), planId);
77
+ if (pending.origin.operation_id !== operationId) return { status: 'unknown', reason: 'another_pending_handoff', authorizes: false };
78
+ return { status: 'pending', request_digest: pending.origin.request_digest, pending, run_id: pending.origin.run_id, authorizes: false };
79
+ }
80
+
81
+ // Explicit selected-source handoff, never approval. Entry -> deterministic
82
+ // creation -> staged Run publication. No active UR synchronization afterwards.
83
+ export function createRunFromPlanned(root, { plan_id, expected_digest, operation_id, target_id, request_digest, presentation_language = 'en', title },
84
+ { packageVersion = '0.20.2', checkpoint = () => {} } = {}) {
85
+ plannedEntryPath(plan_id);
86
+ if (!REVISION_ID_PATTERN.test(operation_id ?? '') || !/^sha256:[a-f0-9]{64}$/u.test(expected_digest ?? '')
87
+ || !/^sha256:[a-f0-9]{64}$/u.test(request_digest ?? '') || target_id !== resolveControlCommandTarget(root).target_id) fail('AGDF_PLANNED_HANDOFF_INPUT_INVALID');
88
+ let effectStarted = false;
89
+ return withPlannedEntryLock(root, plan_id, () => {
90
+ const execute = () => {
91
+ const origins = inspectPlannedOrigins(root, plan_id);
92
+ if (!origins.complete) fail('AGDF_PLANNED_ORIGIN_UNCONFIRMED');
93
+ if (origins.matches.length) {
94
+ const known = origins.matches[0], originDigest = digest(canonicalJson(known.receipt.effect.record));
95
+ if (known.origin.operation_id === operation_id && (known.origin.request_digest !== request_digest || known.origin.target_id !== target_id)) fail('AGDF_OPERATION_PAYLOAD_CONFLICT');
96
+ effectStarted = true;
97
+ const finish = () => withOwnedFileLock(join(root, '.agdf/control/runs', `.create-${known.origin.operation_id}`),
98
+ () => finishEntry(root, known.origin, originDigest, checkpoint));
99
+ if (known.origin.operation_id === operation_id) finish();
100
+ else withControlRecovery(root, { resource: `planned:${plan_id}`, operation_id: known.origin.operation_id,
101
+ proveOutcome: () => inspectPlannedOrigins(root, plan_id).matches.length === 1 }, finish);
102
+ return { outcome: known.origin.operation_id === operation_id ? 'already_applied' : 'already_transferred', run_id: known.run_id, receipt: known.receipt, historical_effect: true, authorizes: false };
103
+ }
104
+ if (controlPathPresent(root, `${plannedEntryPath(plan_id)}/TRANSFER.json`)) fail('AGDF_PLANNED_ORIGIN_UNCONFIRMED');
105
+ const entry = inspectPlannedEntry(root, plan_id, { presentationLanguage: presentation_language });
106
+ if (entry.pending) fail('AGDF_PLANNED_RECOVERY_REQUIRED');
107
+ if (entry.digest !== expected_digest) fail('AGDF_PLANNED_SOURCE_STALE');
108
+ if (!entry.readiness.ready) throw Object.assign(Error('AGDF_PLANNED_UR_NOT_READY'), { readiness: entry.readiness });
109
+ if (title !== undefined && title !== entry.title) fail('AGDF_PLANNED_TITLE_INVALID');
110
+ const rawSource = readContainedControlText(root, entry.path);
111
+ if (plannedRawDigest(rawSource) !== entry.raw_digest) fail('AGDF_PLANNED_SOURCE_STALE');
112
+ const runId = creationRunId(operation_id), base = plannedEntryPath(plan_id), runBase = `${runDocumentPath(runId, '')}/`;
113
+ const origin = { schema_version: 1, plan_id, operation_id, run_id: runId, target_id, request_digest, raw_digest: entry.raw_digest,
114
+ planned: { path: entry.path, digest: entry.digest }, snapshot: { path: runHistoryPath(runId, 'planning/UR.md'), digest: entry.digest },
115
+ initial_ur: { path: `${runBase}UR.md`, digest: entry.digest } };
116
+ const outputs = [{ path: origin.initial_ur.path, content: rawSource, digest: entry.digest },
117
+ { path: origin.snapshot.path, content: rawSource, digest: entry.digest }];
118
+ const intent = validateIntent(bindInputResolution({ schema_version: 1, origin, outputs }), plan_id), pendingPath = `${base}/HANDOFF_PENDING.json`;
119
+ function matching(content, staged) {
120
+ const parsed = parseRunState(content, runId), receipt = readRunOperations(content).receipts.find(row => row.operation_id === operation_id);
121
+ const seals = staged ? computeRunSeals(root, content, { artefactDigests: staged.artefactDigests }) : null;
122
+ const sealed = staged ? seals.content_seal === parsed.meta.content_seal && seals.approval_seal === parsed.meta.approval_seal : runSealState(root, content).status === 'valid';
123
+ if (!parsed.valid || !sealed || receipt?.kind !== 'run.create_from_planned'
124
+ || receipt.target_id !== target_id || receipt.request_digest !== request_digest
125
+ || canonicalJson(receipt.effect.record.planned) !== canonicalJson({ plan_id, path: entry.path, digest: entry.digest })) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
126
+ return receipt;
127
+ }
128
+ return withOwnedFileLock(join(root, '.agdf/control/runs', `.create-${operation_id}`), () => {
129
+ if (existsSync(join(root, pendingPath))) {
130
+ const previous = validateIntent(JSON.parse(readContainedControlText(root, pendingPath, PLANNED_INTENT_BYTES)), plan_id);
131
+ if (canonicalJson(previous) !== canonicalJson(intent)) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
132
+ // Roll back only the original sealed stage and exact owned bytes.
133
+ // Foreign or partially unprovable state remains recovery-required.
134
+ effectStarted = true; markControlMutationEffect();
135
+ recoverRunCreationStage(root, runId, matching, { discard: true, outputs });
136
+ checkpoint('handoff_rolled_back');
137
+ } else {
138
+ // No pre-existing publication or sibling output may be adopted just
139
+ // because its bytes happen to match the requested content.
140
+ if (existsSync(join(root, `.agdf/control/runs/${runId}`)) || outputs.some(row => existsSync(join(root, row.path)))) fail('AGDF_PLANNED_HANDOFF_COLLISION');
141
+ }
142
+ effectStarted = true; markControlMutationEffect();
143
+ if (existsSync(join(root, pendingPath))) {
144
+ if (readContainedControlText(root, pendingPath, PLANNED_INTENT_BYTES) !== json(intent)) fail('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED');
145
+ } else atomicWrite(join(root, pendingPath), json(intent));
146
+ checkpoint('handoff_intent');
147
+ let receipt = recoverRunCreationStage(root, runId, matching, { outputs });
148
+ if (!receipt) {
149
+ createRun(root, runId, undefined, { outputs, checkpoint, prepare(content) {
150
+ const next = projectUrObjective(content, entry.content);
151
+ const parsed = parseRunState(next, runId);
152
+ receipt = bindInputResolution({ schema_version: RUN_OPERATION_VERSION, kind: 'run.create_from_planned', operation_id, request_digest, target_id,
153
+ run_id: runId, expected_revision_id: null, created_at: new Date().toISOString(), producer: { contract: 'run-command/1', package_version: packageVersion },
154
+ assurance: COOPERATIVE_ASSURANCE, effect: { previous_revision_id: null, resulting_revision_id: parsed.meta.revision_id, revision: 1,
155
+ record: { title: entry.title, planned: { plan_id, path: entry.path, digest: entry.digest },
156
+ snapshot: { ...origin.snapshot, raw_digest: origin.raw_digest } } } });
157
+ return appendRunOperation(next, receipt);
158
+ }, beforePublish: () => {
159
+ checkpoint('handoff_before_run_publish');
160
+ if (readContainedControlText(root, entry.path) !== rawSource) fail('AGDF_PLANNED_SOURCE_STALE');
161
+ } });
162
+ }
163
+ checkpoint('handoff_run_committed');
164
+ finishEntry(root, origin, digest(canonicalJson(receipt.effect.record)), checkpoint);
165
+ return { outcome: 'accepted', run_id: runId, receipt, historical_effect: false, authorizes: false };
166
+ });
167
+ };
168
+ try { return execute(); }
169
+ catch (error) {
170
+ if (!effectStarted || /RECOVERY_REQUIRED/u.test(error.message)) throw error;
171
+ throw Object.assign(Error('AGDF_PLANNED_HANDOFF_RECOVERY_REQUIRED'), { cause: error, operation_id, plan_id });
172
+ }
173
+ }, { operation_id, resume: true, proveOutcome: result => ['accepted', 'already_applied', 'already_transferred'].includes(result.outcome) });
174
+ }
@@ -0,0 +1,90 @@
1
+ import { readControlLayout } from './control-layout.js';
2
+ import { existsSync, readdirSync, lstatSync, currentControlReadView } from '../control-read/fs.js';
3
+ import { captureControlScope, controlPathPresent } from '../control-read/snapshot.js';
4
+ import { join } from 'node:path';
5
+ import { inspectPlannedEntry, inspectPlannedOperation, PLANNED_ROOT } from './planned-entry.js';
6
+ import { inspectPlannedOrigins } from './planned-origin-reader.js';
7
+ import { readRunInventory } from './run-inventory-reader.js';
8
+ import { artefactFileDigest } from './run-seal.js';
9
+ import { RUN_ID_PATTERN } from './run-identity.js';
10
+ import { hasSymlinkComponent } from './contained-file.js';
11
+
12
+ const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
13
+ const titleKey = title => title.normalize('NFKC').replace(/\s+/gu, ' ').trim().toLowerCase();
14
+ const rank = { high: 0, normal: 1, low: 2 };
15
+
16
+ export function projectPlannedInventory(root, { language = 'en' } = {}) {
17
+ readControlLayout(root);
18
+ const entries = [], findings = [];
19
+ if (!existsSync(join(root, PLANNED_ROOT))) throw Error('AGDF_PLANNED_STORE_MISSING');
20
+ if (hasSymlinkComponent(root, PLANNED_ROOT) || !lstatSync(join(root, PLANNED_ROOT)).isDirectory()) throw Error('AGDF_PLANNED_PATH_INVALID');
21
+ const names = readdirSync(join(root, PLANNED_ROOT));
22
+ if (names.length > 20000) throw Error('AGDF_PLANNED_INVENTORY_LIMIT');
23
+ for (const name of names.filter(name => !RUN_ID_PATTERN.test(name))) {
24
+ if (name === '.gitkeep') {
25
+ const marker = lstatSync(join(root, PLANNED_ROOT, name));
26
+ if (marker.isFile() && !marker.isSymbolicLink() && marker.size === 0) continue;
27
+ }
28
+ if (/^\.entry-[a-z0-9][a-z0-9._-]{0,127}\.lock(?:\.reclaim)?$/u.test(name)) continue;
29
+ const staged = name.match(/^\.stage-(plan-[a-f0-9-]{36})-([a-f0-9-]{36})$/u);
30
+ if (staged) {
31
+ try {
32
+ const operation = inspectPlannedOperation(root, staged[1], staged[2]);
33
+ if (operation.status !== 'pending' || !operation.pending) throw Error('planned_stage_unknown');
34
+ findings.push({ plan_id: staged[1], code: 'planned_creation_pending', operation_id: staged[2] });
35
+ entries.push({ kind: 'planned', identity: `planned/${staged[1]}`, plan_id: staged[1], title: staged[1], priority: null,
36
+ source: { path: `${PLANNED_ROOT}/${staged[1]}/UR.md`, digest: null, raw_digest: null }, coverage: 'recovery_required',
37
+ run_id: null, handoff_ready: false, diagnostics: [{ code: 'planned_creation_pending', operation_id: staged[2] }],
38
+ actions: ['inspect_original_operation'], authorizes: false });
39
+ } catch (error) { findings.push({ code: 'planned_stage_unknown', path: `${PLANNED_ROOT}/${name}`, reason: error.code ?? error.message }); }
40
+ } else findings.push({ code: 'planned_name_unsupported', path: `${PLANNED_ROOT}/${name}` });
41
+ }
42
+ for (const id of names.filter(name => RUN_ID_PATTERN.test(name)).sort()) {
43
+ try {
44
+ const entry = inspectPlannedEntry(root, id, { presentationLanguage: language }), origins = inspectPlannedOrigins(root, id);
45
+ const handedOff = origins.matches.length === 1 && origins.complete;
46
+ const handoffPending = controlPathPresent(root, `${PLANNED_ROOT}/${id}/HANDOFF_PENDING.json`);
47
+ const orphanTransfer = !handedOff && controlPathPresent(root, `${PLANNED_ROOT}/${id}/TRANSFER.json`);
48
+ if (orphanTransfer) origins.findings.push({ code: 'planned_transfer_unconfirmed', plan_id: id });
49
+ const coverage = !origins.complete || orphanTransfer ? 'unconfirmed' : handedOff ? 'transferred' : entry.pending || handoffPending ? 'recovery_required'
50
+ : entry.readiness.ready ? 'ready' : 'draft';
51
+ entries.push({ kind: 'planned', identity: `planned/${id}`, plan_id: id, title: entry.title, priority: entry.priority,
52
+ source: { path: entry.path, digest: entry.digest, raw_digest: entry.raw_digest }, coverage,
53
+ run_id: handedOff ? origins.matches[0].run_id : null, handoff_ready: coverage === 'ready',
54
+ diagnostics: origins.findings, actions: handedOff ? ['inspect_source', 'open_run'] : coverage === 'unconfirmed' || coverage === 'recovery_required'
55
+ ? ['inspect_source', 'inspect_original_operation'] : ['inspect_source', 'continue_planning'], authorizes: false });
56
+ findings.push(...origins.findings.map(row => ({ ...row, plan_id: id })));
57
+ } catch (error) {
58
+ findings.push({ plan_id: id, code: error.code ?? error.message });
59
+ entries.push({ kind: 'planned', identity: `planned/${id}`, plan_id: id, title: id, priority: null,
60
+ source: { path: `${PLANNED_ROOT}/${id}/UR.md`, digest: null, raw_digest: null }, coverage: 'unavailable', run_id: null,
61
+ handoff_ready: false, diagnostics: [{ code: error.code ?? error.message }], actions: ['retry_inspection'], authorizes: false });
62
+ }
63
+ }
64
+ entries.sort((a, b) => (rank[a.priority] ?? 3) - (rank[b.priority] ?? 3) || compare(titleKey(a.title), titleKey(b.title)) || compare(a.plan_id, b.plan_id));
65
+ return { schema_version: 'planned-inventory/1', state: findings.length ? 'partial' : 'complete', entries, findings, authorizes: false };
66
+ }
67
+
68
+ export function readPlannedInventory(root, options) {
69
+ try { return currentControlReadView()?.readOptionalFileSync ? projectPlannedInventory(root, options) : captureControlScope(root, () => projectPlannedInventory(root, options)).data; }
70
+ catch (error) { return { schema_version: 'planned-inventory/1', state: 'unavailable', entries: [], findings: [{ code: error.code ?? error.message }], authorizes: false }; }
71
+ }
72
+
73
+ export function readWorkInventory(root, options = {}) {
74
+ try {
75
+ readControlLayout(root);
76
+ const project = () => {
77
+ const planned = projectPlannedInventory(root, options), runs = readRunInventory(root, options);
78
+ const references = planned.entries.filter(row => row.coverage === 'transferred');
79
+ const entries = [...planned.entries.filter(row => row.coverage !== 'transferred'), ...runs.runs.map(row => ({ ...row,
80
+ kind: 'run', identity: `run/${row.run_id}`, source: { path: row.path, digest: row.valid ? artefactFileDigest(root, row.path) : null },
81
+ planning_origins: references.filter(ref => ref.run_id === row.run_id).map(ref => ({ plan_id: ref.plan_id, source: ref.source })),
82
+ coverage: row.valid ? 'available' : 'unavailable', actions: ['open_run'], authorizes: false }))];
83
+ return { schema_version: 'work-inventory/1', state: planned.state === 'partial' || runs.state !== 'complete' ? 'partial' : 'complete',
84
+ entries, planning_references: references, findings: [...planned.findings, ...runs.findings, ...runs.runs.flatMap(row => row.findings)],
85
+ counts: { planned: planned.entries.length - references.length, runs: runs.runs.length, planning_references: references.length }, authorizes: false };
86
+ };
87
+ return currentControlReadView()?.readOptionalFileSync ? project() : captureControlScope(root, project).data;
88
+ } catch (error) { return { schema_version: 'work-inventory/1', state: 'unavailable', entries: [], planning_references: [],
89
+ findings: [{ code: error.code ?? error.message }], counts: null, authorizes: false }; }
90
+ }
@@ -0,0 +1,48 @@
1
+ // Live origin discovery composes current proof and seal validation. The seal's
2
+ // immutable-origin proof stays below this reader to keep the dependency acyclic.
3
+ import { RUN_ID_PATTERN } from './run-identity.js';
4
+ import { existsSync, readdirSync, memoizeControlRead } from '../control-read/fs.js';
5
+ import { join } from 'node:path';
6
+ import { readContainedControlText, controlPathPresent, READ_LIMITS } from '../control-read/snapshot.js';
7
+ import { parseRunState } from './run-state-parser.js';
8
+ import { readRunOperations } from './run-operations.js';
9
+ import { runSealState } from './run-seal.js';
10
+ import { hasSymlinkComponent } from './contained-file.js';
11
+ import { plannedOriginFromReceipt, validPlannedOrigin } from './planned-origin.js';
12
+
13
+ function collectPlannedOrigins(root) {
14
+ const directory = '.agdf/control/runs', matches = [], findings = [];
15
+ if (hasSymlinkComponent(root, directory)) throw Error('AGDF_PLANNED_ORIGIN_UNCONFIRMED');
16
+ if (!existsSync(join(root, directory))) return { matches, findings };
17
+ const names = readdirSync(join(root, directory));
18
+ if (names.length > 20000) throw Error('AGDF_PLANNED_ORIGIN_LIMIT');
19
+ for (const id of names.filter(name => RUN_ID_PATTERN.test(name))) {
20
+ let receipt, origin;
21
+ try {
22
+ const path = `${directory}/${id}/RUN_STATE.md`;
23
+ if (!controlPathPresent(root, path)) continue;
24
+ const content = readContainedControlText(root, path, READ_LIMITS.file), parsed = parseRunState(content, id);
25
+ if (!parsed.valid) throw Error();
26
+ const creations = readRunOperations(content).receipts.filter(row => row.kind === 'run.create_from_planned');
27
+ if (creations.length > 1) throw Error();
28
+ receipt = creations[0]; if (!receipt) continue;
29
+ origin = plannedOriginFromReceipt(receipt);
30
+ if (!validPlannedOrigin(origin) || runSealState(root, content).status !== 'valid') throw Error();
31
+ matches.push({ origin, receipt, run_id: id, current_revision_id: parsed.meta.revision_id });
32
+ } catch { findings.push({ run_id: id, ...(origin ? { plan_id: origin.plan_id } : {}), code: 'planned_origin_unconfirmed' }); }
33
+ }
34
+ return { matches, findings };
35
+ }
36
+ export function inspectPlannedOrigins(root, planId) {
37
+ if (!RUN_ID_PATTERN.test(planId ?? '')) throw Error('AGDF_PLANNED_ID_INVALID');
38
+ const inventory = memoizeControlRead(`plannedOrigins:${root}`, () => collectPlannedOrigins(root));
39
+ const matches = inventory.matches.filter(row => row.origin.plan_id === planId);
40
+ const findings = inventory.findings.filter(row => !row.plan_id || row.plan_id === planId);
41
+ if (matches.length > 1) findings.push({ code: 'planned_origin_ambiguous', plan_id: planId });
42
+ return { matches, findings, complete: findings.length === 0 };
43
+ }
44
+ export function assertPlannedNotTransferred(root, id) {
45
+ const origins = inspectPlannedOrigins(root, id);
46
+ if (!origins.complete) throw Error('AGDF_PLANNED_ORIGIN_UNCONFIRMED');
47
+ if (origins.matches.length) throw Object.assign(Error('AGDF_PLANNED_ALREADY_TRANSFERRED'), { run_id: origins.matches[0].run_id });
48
+ }
@@ -0,0 +1,40 @@
1
+ import { runDocumentPath, runHistoryPath, RUN_ID_PATTERN, REVISION_ID_PATTERN } from './run-identity.js';
2
+ import { readContainedControlText } from '../control-read/snapshot.js';
3
+ import { exactObject, digest, canonicalJson } from './approval-command-contract.js';
4
+ import { readRunOperations } from './run-operations.js';
5
+ import { artefactFileDigest } from './run-seal-compute.js';
6
+
7
+ const hash = value => typeof value === 'string' && /^sha256:[a-f0-9]{64}$/u.test(value);
8
+ const reference = (value, path) => exactObject(value, ['path', 'digest']) && value.path === path && hash(value.digest);
9
+ // The pending handoff retains its exact original effect for recovery. After
10
+ // publication, the creation receipt and immutable snapshot are the authority.
11
+ export function validPlannedOrigin(origin) {
12
+ if (!exactObject(origin, ['schema_version', 'plan_id', 'operation_id', 'run_id', 'target_id', 'request_digest', 'raw_digest', 'planned', 'snapshot', 'initial_ur'])
13
+ || origin.schema_version !== 1 || !RUN_ID_PATTERN.test(origin.plan_id ?? '') || !REVISION_ID_PATTERN.test(origin.operation_id ?? '')
14
+ || origin.run_id !== `run-${origin.operation_id}` || !hash(origin.target_id) || !hash(origin.request_digest) || !hash(origin.raw_digest)) return false;
15
+ return reference(origin.planned, `.agdf/control/planned/${origin.plan_id}/UR.md`)
16
+ && reference(origin.snapshot, runHistoryPath(origin.run_id, 'planning/UR.md'))
17
+ && reference(origin.initial_ur, runDocumentPath(origin.run_id, 'UR.md'))
18
+ && origin.snapshot.digest === origin.planned.digest && origin.initial_ur.digest === origin.planned.digest;
19
+ }
20
+ export function plannedOriginFromReceipt(receipt) {
21
+ const r = receipt.effect.record;
22
+ return { schema_version: 1, plan_id: r.planned.plan_id, operation_id: receipt.operation_id, run_id: receipt.run_id,
23
+ target_id: receipt.target_id, request_digest: receipt.request_digest, raw_digest: r.snapshot.raw_digest,
24
+ planned: { path: r.planned.path, digest: r.planned.digest }, snapshot: { path: r.snapshot.path, digest: r.snapshot.digest },
25
+ initial_ur: { path: runDocumentPath(receipt.run_id, 'UR.md'), digest: r.planned.digest } };
26
+ }
27
+ export function assertPlannedOriginImmutable(root, before, after) {
28
+ const creation = readRunOperations(before).receipts.find(row => row.kind === 'run.create_from_planned');
29
+ if (!creation) return;
30
+ try {
31
+ const next = readRunOperations(after).receipts.find(row => row.operation_id === creation.operation_id);
32
+ const origin = plannedOriginFromReceipt(creation);
33
+ if (canonicalJson(next) !== canonicalJson(creation) || !validPlannedOrigin(origin)
34
+ || artefactFileDigest(root, origin.snapshot.path) !== origin.snapshot.digest
35
+ || digest(readContainedControlText(root, origin.snapshot.path)) !== origin.raw_digest) throw Error();
36
+ } catch { throw Error('AGDF_PLANNED_ORIGIN_IMMUTABLE'); }
37
+ }
38
+ export function validPlannedOriginHistory(root, content) {
39
+ try { assertPlannedOriginImmutable(root, content, content); return true; } catch { return false; }
40
+ }