create-agdf 0.30.0 → 0.31.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 (341) hide show
  1. package/generated/.agdf/control/README.md +5 -0
  2. package/generated/.agdf/control/templates/BRAND.md +28 -0
  3. package/generated/.agdf/control/templates/artefacts/PRD.md +11 -0
  4. package/generated/.agdf/control/templates/artefacts/SD.md +4 -0
  5. package/generated/.agdf/control/templates/artefacts/UX_INTENT_DEFINITION.md +1 -1
  6. package/generated/.opencode/agdf-interaction-locales.json +292 -2
  7. package/generated/.opencode/contracts/gate-artifact-preparation.md +9 -3
  8. package/generated/.opencode/contracts/interaction.md +10 -4
  9. package/generated/.opencode/contracts/modes.md +5 -0
  10. package/generated/.opencode/contracts/prd-definition.md +40 -1
  11. package/generated/.opencode/contracts/quality.md +35 -0
  12. package/generated/.opencode/contracts/request-activation.md +6 -3
  13. package/generated/.opencode/contracts/sd-definition.md +46 -0
  14. package/generated/.opencode/contracts/tp-definition.md +8 -0
  15. package/generated/.opencode/contracts/ur-definition.md +9 -5
  16. package/generated/.opencode/skills/agdf-ux-intent-definition/SKILL.md +31 -2
  17. package/generated/plugins/agdf/.claude-plugin/plugin.json +1 -1
  18. package/generated/plugins/agdf/.codex-plugin/plugin.json +1 -1
  19. package/generated/plugins/agdf/companion/events.mjs +117 -0
  20. package/generated/plugins/agdf/companion/figure.mjs +6 -6
  21. package/generated/plugins/agdf/companion/gate-bar.mjs +10 -28
  22. package/generated/plugins/agdf/companion/localization.mjs +10 -32
  23. package/generated/plugins/agdf/companion/notice.mjs +10 -8
  24. package/generated/plugins/agdf/companion/register.mjs +229 -43
  25. package/generated/plugins/agdf/companion/run-state.mjs +77 -90
  26. package/generated/plugins/agdf/companion/state.mjs +6 -32
  27. package/generated/plugins/agdf/companion/view.mjs +57 -12
  28. package/generated/plugins/agdf/control/README.md +5 -0
  29. package/generated/plugins/agdf/control/templates/BRAND.md +28 -0
  30. package/generated/plugins/agdf/control/templates/artefacts/PRD.md +11 -0
  31. package/generated/plugins/agdf/control/templates/artefacts/SD.md +4 -0
  32. package/generated/plugins/agdf/control/templates/artefacts/UX_INTENT_DEFINITION.md +1 -1
  33. package/generated/plugins/agdf/mcp/server/README.md +26 -2
  34. package/generated/plugins/agdf/mcp/server/package.json +3 -3
  35. package/generated/plugins/agdf/mcp/server/src/generation-runtime.js +11 -2
  36. package/generated/plugins/agdf/mcp/server/src/main.js +1 -0
  37. package/generated/plugins/agdf/mcp/server/src/next-action.js +227 -0
  38. package/generated/plugins/agdf/mcp/server/src/prepared-call-transport.js +306 -0
  39. package/generated/plugins/agdf/mcp/server/src/safe-read-continuation.js +62 -0
  40. package/generated/plugins/agdf/mcp/server/src/server.js +139 -35
  41. package/generated/plugins/agdf/mcp/server/ui/cockpit.html +2 -2
  42. package/generated/plugins/agdf/mcp/server/ui/decision-manifest.json +3 -3
  43. package/generated/plugins/agdf/mcp/server/ui/decision.html +2 -2
  44. package/generated/plugins/agdf/mcp/server/ui/manifest.json +3 -3
  45. package/generated/plugins/agdf/meta/agdf-interaction-locales.json +292 -2
  46. package/generated/plugins/agdf/meta/agdf-mcp-capability.json +1 -1
  47. package/generated/plugins/agdf/meta/agdf-plugin.definition.json +1 -1
  48. package/generated/plugins/agdf/meta/contracts/gate-artifact-preparation.md +9 -3
  49. package/generated/plugins/agdf/meta/contracts/interaction.md +10 -4
  50. package/generated/plugins/agdf/meta/contracts/modes.md +5 -0
  51. package/generated/plugins/agdf/meta/contracts/prd-definition.md +40 -1
  52. package/generated/plugins/agdf/meta/contracts/quality.md +35 -0
  53. package/generated/plugins/agdf/meta/contracts/request-activation.md +6 -3
  54. package/generated/plugins/agdf/meta/contracts/sd-definition.md +46 -0
  55. package/generated/plugins/agdf/meta/contracts/tp-definition.md +8 -0
  56. package/generated/plugins/agdf/meta/contracts/ur-definition.md +9 -5
  57. package/generated/plugins/agdf/meta/copilot-payload-baseline.json +3 -3
  58. package/generated/plugins/agdf/meta/distribution-profile-history.json +7 -0
  59. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-interaction-locales.json +292 -2
  60. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-plugin.definition.json +1 -1
  61. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/gate-artifact-preparation.md +9 -3
  62. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/interaction.md +10 -4
  63. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/modes.md +5 -0
  64. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/prd-definition.md +40 -1
  65. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/quality.md +35 -0
  66. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/request-activation.md +6 -3
  67. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/sd-definition.md +46 -0
  68. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/tp-definition.md +8 -0
  69. package/generated/plugins/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/ur-definition.md +9 -5
  70. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/command-registry.js +2 -1
  71. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/parse-args.js +7 -4
  72. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/project-read-command.js +29 -0
  73. package/generated/plugins/agdf/runtime/create-agdf/lib/cli/validation-handlers.js +2 -1
  74. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-dispatch-runtime.js +32 -6
  75. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/package.js +7 -0
  76. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/plugin-runtime.js +34 -6
  77. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-lifecycle/prepared-call-journal.js +269 -0
  78. package/generated/plugins/agdf/runtime/create-agdf/lib/mcp-worker-runtime.js +86 -83
  79. package/generated/plugins/agdf/runtime/create-agdf/lib/runtime/validator-application.js +2 -2
  80. package/generated/plugins/agdf/runtime/create-agdf/package.json +1 -1
  81. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/companion/events.js +154 -0
  82. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/companion/figure-state.js +36 -0
  83. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/companion/journal.js +180 -0
  84. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/companion/run-view.js +184 -0
  85. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/acceptance-criteria.js +2 -0
  86. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/closeout-readiness.js +24 -6
  87. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-check.js +44 -6
  88. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-policy-inputs.js +2 -0
  89. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-policy-pure.js +7 -3
  90. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/prd-readiness.js +7 -2
  91. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/report-decision.js +9 -0
  92. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/traceability-readiness.js +57 -8
  93. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/ur-readiness.js +15 -2
  94. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/artifact-readiness.js +5 -3
  95. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/authoring-inputs.js +107 -22
  96. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/cockpit.js +4 -20
  97. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/contract.js +64 -24
  98. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/material-recording-calls.js +54 -0
  99. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/project-state.js +2 -1
  100. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/run-classification.js +31 -0
  101. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/selection.js +6 -0
  102. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/service.js +32 -5
  103. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/authoring-text-handoff.js +3 -0
  104. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/input-resolution.js +7 -5
  105. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/material-limits.js +4 -0
  106. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/prepared-control-calls.js +137 -0
  107. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/presentation-delivery.js +4 -1
  108. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-contract.js +10 -4
  109. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-schema.js +9 -3
  110. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-service.js +35 -11
  111. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-identity.js +2 -0
  112. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-inventory-reader.js +5 -3
  113. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-material.js +25 -7
  114. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-presentation-render.js +84 -28
  115. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-revision.js +38 -20
  116. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-source-revisions.js +37 -17
  117. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-reader.js +10 -3
  118. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-steps.js +8 -5
  119. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/index.js +3 -1
  120. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/interaction-catalog-validation.js +6 -1
  121. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/interaction-catalog.js +8 -0
  122. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/interaction-presentation.js +26 -1
  123. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/mcp-input-hints.js +30 -1
  124. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/mcp-tool-errors.js +5 -3
  125. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/resources/canonical-init-plan.js +1 -1
  126. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/runtime/plugin-provenance.js +9 -2
  127. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/contract.js +6 -4
  128. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/delivery-intake.js +3 -1
  129. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/mcp-continuation.js +25 -2
  130. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/prd-definition.js +3 -2
  131. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/readiness-findings.js +7 -0
  132. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/sd-definition.js +4 -2
  133. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/service.js +17 -4
  134. package/generated/plugins/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/tp-definition.js +4 -2
  135. package/generated/plugins/agdf/runtime/runtime-manifest.json +2 -2
  136. package/generated/plugins/agdf/scripts/check-runtime-integrity.mjs +4 -3
  137. package/generated/plugins/agdf/skills/ux-intent-definition/SKILL.md +31 -2
  138. package/generated/plugins/agdf/skills/ux-intent-definition/help.md +8 -1
  139. package/generated/plugins/agdf/submission/openai/availability.md +1 -1
  140. package/generated/plugins/agdf/submission/openai/capability-matrix.json +1 -1
  141. package/generated/plugins/agdf/submission/openai/release-notes.md +8 -8
  142. package/generated/plugins/agdf/submission/openai/reviewer-cases.json +1 -1
  143. package/generated/plugins/agdf-planning/.codex-plugin/plugin.json +1 -1
  144. package/generated/plugins/agdf-planning/plugin.json +1 -1
  145. package/generated/plugins/copilot/agdf/.agdf-payload-inventory.json +332 -195
  146. package/generated/plugins/copilot/agdf/control/README.md +5 -0
  147. package/generated/plugins/copilot/agdf/control/templates/BRAND.md +28 -0
  148. package/generated/plugins/copilot/agdf/control/templates/artefacts/PRD.md +11 -0
  149. package/generated/plugins/copilot/agdf/control/templates/artefacts/SD.md +4 -0
  150. package/generated/plugins/copilot/agdf/control/templates/artefacts/UX_INTENT_DEFINITION.md +1 -1
  151. package/generated/plugins/copilot/agdf/mcp/server/README.md +26 -2
  152. package/generated/plugins/copilot/agdf/mcp/server/package.json +3 -3
  153. package/generated/plugins/copilot/agdf/mcp/server/src/generation-runtime.js +11 -2
  154. package/generated/plugins/copilot/agdf/mcp/server/src/main.js +1 -0
  155. package/generated/plugins/copilot/agdf/mcp/server/src/next-action.js +227 -0
  156. package/generated/plugins/copilot/agdf/mcp/server/src/prepared-call-transport.js +306 -0
  157. package/generated/plugins/copilot/agdf/mcp/server/src/safe-read-continuation.js +62 -0
  158. package/generated/plugins/copilot/agdf/mcp/server/src/server.js +139 -35
  159. package/generated/plugins/copilot/agdf/meta/agdf-plugin.definition.json +1 -1
  160. package/generated/plugins/copilot/agdf/meta/distribution-profile-history.json +7 -0
  161. package/generated/plugins/copilot/agdf/plugin.json +1 -1
  162. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-interaction-locales.json +292 -2
  163. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/agdf-plugin.definition.json +1 -1
  164. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/gate-artifact-preparation.md +9 -3
  165. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/interaction.md +10 -4
  166. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/modes.md +5 -0
  167. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/prd-definition.md +40 -1
  168. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/quality.md +35 -0
  169. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/request-activation.md +6 -3
  170. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/sd-definition.md +46 -0
  171. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/tp-definition.md +8 -0
  172. package/generated/plugins/copilot/agdf/runtime/create-agdf/generated/plugins/agdf/meta/contracts/ur-definition.md +9 -5
  173. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/command-registry.js +2 -1
  174. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/parse-args.js +7 -4
  175. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/project-read-command.js +29 -0
  176. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/cli/validation-handlers.js +2 -1
  177. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-dispatch-runtime.js +32 -6
  178. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/package.js +7 -0
  179. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/plugin-runtime.js +34 -6
  180. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-lifecycle/prepared-call-journal.js +269 -0
  181. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/mcp-worker-runtime.js +81 -78
  182. package/generated/plugins/copilot/agdf/runtime/create-agdf/lib/runtime/validator-application.js +2 -2
  183. package/generated/plugins/copilot/agdf/runtime/create-agdf/package.json +1 -1
  184. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/companion/events.js +154 -0
  185. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/companion/figure-state.js +36 -0
  186. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/companion/journal.js +180 -0
  187. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/companion/run-view.js +184 -0
  188. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/acceptance-criteria.js +2 -0
  189. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/closeout-readiness.js +24 -6
  190. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-check.js +44 -6
  191. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-policy-inputs.js +2 -0
  192. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/gate-policy-pure.js +7 -3
  193. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/prd-readiness.js +7 -2
  194. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/report-decision.js +9 -0
  195. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/traceability-readiness.js +57 -8
  196. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-evaluation/ur-readiness.js +15 -2
  197. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/artifact-readiness.js +5 -3
  198. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/authoring-inputs.js +107 -22
  199. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/contract.js +64 -24
  200. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/material-recording-calls.js +54 -0
  201. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/project-state.js +2 -1
  202. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/run-classification.js +31 -0
  203. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/selection.js +6 -0
  204. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-inspect/service.js +32 -5
  205. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/authoring-text-handoff.js +3 -0
  206. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/input-resolution.js +7 -5
  207. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/material-limits.js +4 -0
  208. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/prepared-control-calls.js +137 -0
  209. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/presentation-delivery.js +4 -1
  210. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-contract.js +10 -4
  211. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-schema.js +9 -3
  212. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-command-service.js +35 -11
  213. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-identity.js +2 -0
  214. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-inventory-reader.js +5 -3
  215. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-material.js +25 -7
  216. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-presentation-render.js +84 -28
  217. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-revision.js +38 -20
  218. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-source-revisions.js +37 -17
  219. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-state-reader.js +10 -3
  220. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/control-state/run-steps.js +8 -5
  221. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/index.js +3 -1
  222. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/interaction-catalog-validation.js +6 -1
  223. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/interaction-catalog.js +8 -0
  224. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/interaction-presentation.js +26 -1
  225. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/mcp-input-hints.js +30 -1
  226. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/mcp-tool-errors.js +5 -3
  227. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/resources/canonical-init-plan.js +1 -1
  228. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/runtime/plugin-provenance.js +9 -2
  229. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/contract.js +6 -4
  230. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/delivery-intake.js +3 -1
  231. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/mcp-continuation.js +25 -2
  232. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/prd-definition.js +3 -2
  233. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/readiness-findings.js +7 -0
  234. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/sd-definition.js +4 -2
  235. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/service.js +17 -4
  236. package/generated/plugins/copilot/agdf/runtime/create-agdf/runtime/core/lib/skill-dispatch/tp-definition.js +4 -2
  237. package/generated/plugins/copilot/agdf/runtime/runtime-manifest.json +2 -2
  238. package/generated/plugins/copilot/agdf/skills/agdf-interaction-locales.json +1 -1
  239. package/generated/plugins/copilot/agdf/skills/agdf-ux-intent-definition/SKILL.md +31 -2
  240. package/generated/plugins/copilot/agdf/skills/contracts/gate-artifact-preparation.md +9 -3
  241. package/generated/plugins/copilot/agdf/skills/contracts/interaction.md +10 -4
  242. package/generated/plugins/copilot/agdf/skills/contracts/modes.md +5 -0
  243. package/generated/plugins/copilot/agdf/skills/contracts/prd-definition.md +40 -1
  244. package/generated/plugins/copilot/agdf/skills/contracts/quality.md +35 -0
  245. package/generated/plugins/copilot/agdf/skills/contracts/request-activation.md +6 -3
  246. package/generated/plugins/copilot/agdf/skills/contracts/sd-definition.md +46 -0
  247. package/generated/plugins/copilot/agdf/skills/contracts/tp-definition.md +8 -0
  248. package/generated/plugins/copilot/agdf/skills/contracts/ur-definition.md +9 -5
  249. package/generated/submissions/openai/agdf/.codex-plugin/plugin.json +1 -1
  250. package/generated/submissions/openai/agdf/meta/agdf-interaction-locales.json +292 -2
  251. package/generated/submissions/openai/agdf/meta/agdf-plugin.definition.json +1 -1
  252. package/generated/submissions/openai/agdf/meta/contracts/gate-artifact-preparation.md +9 -3
  253. package/generated/submissions/openai/agdf/meta/contracts/interaction.md +10 -4
  254. package/generated/submissions/openai/agdf/meta/contracts/modes.md +5 -0
  255. package/generated/submissions/openai/agdf/meta/contracts/prd-definition.md +40 -1
  256. package/generated/submissions/openai/agdf/meta/contracts/quality.md +35 -0
  257. package/generated/submissions/openai/agdf/meta/contracts/request-activation.md +6 -3
  258. package/generated/submissions/openai/agdf/meta/contracts/sd-definition.md +46 -0
  259. package/generated/submissions/openai/agdf/meta/contracts/tp-definition.md +8 -0
  260. package/generated/submissions/openai/agdf/meta/contracts/ur-definition.md +9 -5
  261. package/generated/submissions/openai/agdf/meta/copilot-payload-baseline.json +3 -3
  262. package/generated/submissions/openai/agdf/meta/distribution-profile-history.json +7 -0
  263. package/generated/submissions/openai/agdf/plugin.json +1 -1
  264. package/generated/submissions/openai/agdf/skills/ux-intent-definition/SKILL.md +31 -2
  265. package/generated/submissions/openai/agdf/skills/ux-intent-definition/help.md +8 -1
  266. package/generated/submissions/openai/agdf/submission/openai/availability.md +1 -1
  267. package/generated/submissions/openai/agdf/submission/openai/capability-matrix.json +1 -1
  268. package/generated/submissions/openai/agdf/submission/openai/inventory.json +24 -24
  269. package/generated/submissions/openai/agdf/submission/openai/listing.json +1 -1
  270. package/generated/submissions/openai/agdf/submission/openai/readiness.json +2 -2
  271. package/generated/submissions/openai/agdf/submission/openai/readiness.md +2 -2
  272. package/generated/submissions/openai/agdf/submission/openai/release-notes.md +8 -8
  273. package/generated/submissions/openai/agdf/submission/openai/reviewer-cases.json +1 -1
  274. package/lib/cli/command-registry.js +2 -1
  275. package/lib/cli/parse-args.js +7 -4
  276. package/lib/cli/project-read-command.js +29 -0
  277. package/lib/cli/validation-handlers.js +2 -1
  278. package/lib/mcp-dispatch-runtime.js +32 -6
  279. package/lib/mcp-lifecycle/package.js +7 -0
  280. package/lib/mcp-lifecycle/plugin-runtime.js +34 -6
  281. package/lib/mcp-lifecycle/prepared-call-journal.js +269 -0
  282. package/lib/mcp-worker-runtime.js +86 -83
  283. package/lib/runtime/validator-application.js +2 -2
  284. package/lib/scaffold/plan.js +2 -0
  285. package/package.json +1 -1
  286. package/runtime/core/lib/companion/events.js +154 -0
  287. package/runtime/core/lib/companion/figure-state.js +36 -0
  288. package/runtime/core/lib/companion/journal.js +180 -0
  289. package/runtime/core/lib/companion/run-view.js +184 -0
  290. package/runtime/core/lib/control-evaluation/acceptance-criteria.js +2 -0
  291. package/runtime/core/lib/control-evaluation/closeout-readiness.js +24 -6
  292. package/runtime/core/lib/control-evaluation/gate-check.js +44 -6
  293. package/runtime/core/lib/control-evaluation/gate-policy-inputs.js +2 -0
  294. package/runtime/core/lib/control-evaluation/gate-policy-pure.js +7 -3
  295. package/runtime/core/lib/control-evaluation/prd-readiness.js +7 -2
  296. package/runtime/core/lib/control-evaluation/report-decision.js +9 -0
  297. package/runtime/core/lib/control-evaluation/traceability-readiness.js +57 -8
  298. package/runtime/core/lib/control-evaluation/ur-readiness.js +15 -2
  299. package/runtime/core/lib/control-inspect/artifact-readiness.js +5 -3
  300. package/runtime/core/lib/control-inspect/authoring-inputs.js +107 -22
  301. package/runtime/core/lib/control-inspect/cockpit.js +4 -20
  302. package/runtime/core/lib/control-inspect/contract.js +64 -24
  303. package/runtime/core/lib/control-inspect/material-recording-calls.js +54 -0
  304. package/runtime/core/lib/control-inspect/project-state.js +2 -1
  305. package/runtime/core/lib/control-inspect/run-classification.js +31 -0
  306. package/runtime/core/lib/control-inspect/selection.js +6 -0
  307. package/runtime/core/lib/control-inspect/service.js +32 -5
  308. package/runtime/core/lib/control-state/authoring-text-handoff.js +3 -0
  309. package/runtime/core/lib/control-state/input-resolution.js +7 -5
  310. package/runtime/core/lib/control-state/material-limits.js +4 -0
  311. package/runtime/core/lib/control-state/prepared-control-calls.js +137 -0
  312. package/runtime/core/lib/control-state/presentation-delivery.js +4 -1
  313. package/runtime/core/lib/control-state/run-command-contract.js +10 -4
  314. package/runtime/core/lib/control-state/run-command-schema.js +9 -3
  315. package/runtime/core/lib/control-state/run-command-service.js +35 -11
  316. package/runtime/core/lib/control-state/run-identity.js +2 -0
  317. package/runtime/core/lib/control-state/run-inventory-reader.js +5 -3
  318. package/runtime/core/lib/control-state/run-material.js +25 -7
  319. package/runtime/core/lib/control-state/run-presentation-render.js +84 -28
  320. package/runtime/core/lib/control-state/run-revision.js +38 -20
  321. package/runtime/core/lib/control-state/run-source-revisions.js +37 -17
  322. package/runtime/core/lib/control-state/run-state-reader.js +10 -3
  323. package/runtime/core/lib/control-state/run-steps.js +8 -5
  324. package/runtime/core/lib/index.js +3 -1
  325. package/runtime/core/lib/interaction-catalog-validation.js +6 -1
  326. package/runtime/core/lib/interaction-catalog.js +8 -0
  327. package/runtime/core/lib/interaction-presentation.js +26 -1
  328. package/runtime/core/lib/mcp-input-hints.js +30 -1
  329. package/runtime/core/lib/mcp-tool-errors.js +5 -3
  330. package/runtime/core/lib/resources/canonical-init-plan.js +1 -1
  331. package/runtime/core/lib/runtime/plugin-provenance.js +9 -2
  332. package/runtime/core/lib/skill-dispatch/contract.js +6 -4
  333. package/runtime/core/lib/skill-dispatch/delivery-intake.js +3 -1
  334. package/runtime/core/lib/skill-dispatch/mcp-continuation.js +25 -2
  335. package/runtime/core/lib/skill-dispatch/prd-definition.js +3 -2
  336. package/runtime/core/lib/skill-dispatch/readiness-findings.js +7 -0
  337. package/runtime/core/lib/skill-dispatch/sd-definition.js +4 -2
  338. package/runtime/core/lib/skill-dispatch/service.js +17 -4
  339. package/runtime/core/lib/skill-dispatch/tp-definition.js +4 -2
  340. package/generated/plugins/agdf/companion/core.mjs +0 -16
  341. package/generated/plugins/agdf/companion/locales.json +0 -200
@@ -1,4 +1,9 @@
1
+ import { MATERIAL_LIMITS } from '../control-state/material-limits.js';
2
+ import { AUTHORING_TEXT_HANDOFF } from '../control-state/authoring-text-handoff.js';
3
+ import { approvalSummaryAuthoringFormat } from '../control-state/run-presentation-render.js';
4
+ import { resolveArtifactPresentationLanguages } from '../resources/context.js';
1
5
  import { runDocumentPath } from '../control-state/run-identity.js';
6
+ import { preparedCommandCall } from '../control-state/prepared-control-calls.js';
2
7
  import { inspectArtefactRecordingMode } from '../control-state/run-artefact-recording.js';
3
8
  import { readFileSync, statSync } from '../control-read/fs.js';
4
9
  import { captureControlScope } from '../control-read/snapshot.js';
@@ -14,6 +19,7 @@ import { evaluateGateCheck } from '../control-evaluation/gate-check.js';
14
19
  import { inspectPlannedEntry, inspectPlannedSelection } from '../control-state/planned-entry.js';
15
20
  import { assertPlannedNotTransferred } from '../control-state/planned-origin-reader.js';
16
21
  import { parseControlState } from '../control-state/run-state-parser.js';
22
+ import { CLOSEOUT_AUTHORING_SCOPE, isCompletedStructuredCloseout } from './selection.js';
17
23
 
18
24
  const templateId = gate => ({ UR: 'UR', PRD: 'PRD', SD: 'SD', TP: 'TP', QA: 'QA_REPORT', OR: 'OR',
19
25
  'Brownfield Review': 'BROWNFIELD_REVIEW', 'Brownfield Analysis': 'BROWNFIELD_REVIEW', 'Mode/Slice Decision': 'BROWNFIELD_REVIEW',
@@ -24,29 +30,37 @@ const templateId = gate => ({ UR: 'UR', PRD: 'PRD', SD: 'SD', TP: 'TP', QA: 'QA_
24
30
  export function inspectAuthoringInputs(root, input, { gitObservation } = {}) {
25
31
  const unavailable = reason => ({ available: false, reason, authorizes: false });
26
32
  try {
27
- const observeGit = () => !input.planning && gitObservation ? { head: gitObservation.gitValue(root, ['rev-parse', 'HEAD']),
33
+ const scopedCloseout = input.authoring_scope === CLOSEOUT_AUTHORING_SCOPE;
34
+ const observeGit = () => ({ head: gitObservation.gitValue(root, ['rev-parse', 'HEAD']),
28
35
  tracked: gitObservation.gitPathList(root, ['diff', 'HEAD', '--name-only']),
29
- untracked: gitObservation.gitPathList(root, ['ls-files', '--others', '--exclude-standard']) } : null;
30
- const git = observeGit(), observedGit = git ? { gitValue: () => git.head,
31
- gitPathList: (_root, args) => args[0] === 'diff' ? git.tracked : git.untracked } : undefined;
36
+ untracked: gitObservation.gitPathList(root, ['ls-files', '--others', '--exclude-standard']) });
37
+ let git;
38
+ const currentGit = () => git ??= observeGit();
39
+ const observedGit = !input.planning && gitObservation ? { gitValue: () => currentGit().head,
40
+ gitPathList: (_root, args) => args[0] === 'diff' ? currentGit().tracked : currentGit().untracked } : undefined;
32
41
  const captured = captureControlScope(root, () => {
42
+ const languages = resolveArtifactPresentationLanguages(root, input.presentation_language);
33
43
  if (input.planning) {
34
44
  inspectPlannedSelection(root, input.planning, { presentationLanguage: input.presentation_language });
35
45
  const creating = input.planning.expected_digest === null;
36
46
  const entry = creating ? null : inspectPlannedEntry(root, input.planning.plan_id, { presentationLanguage: input.presentation_language });
37
47
  if (!creating) assertPlannedNotTransferred(root, input.planning.plan_id);
38
48
  const kind = creating ? 'planned_ur.create' : 'planned_ur.replace';
39
- return { gate: null, authoring_owner: 'UR', mode: 'planning', recording: { mode: creating ? 'create_planned' : 'replace_planned', kind },
49
+ return { languages, gate: null, authoring_owner: 'UR', mode: 'planning', recording: { mode: creating ? 'create_planned' : 'replace_planned', kind },
40
50
  next_operation: { type: 'author_planned_ur', skill_id: 'ur-definition', kind }, status: 'draft', blocking_reason: null,
41
51
  sources: entry ? [{ type: 'UR', path: entry.path, status: 'draft', digest: entry.digest, content: entry.content }] : [] };
42
52
  }
43
53
  const state = readRunState(root, { runId: input.run_id, ignoreRunIdEnv: true });
44
54
  if (state.resolution_error || state.meta?.revision_id !== input.expected_revision_id || runSealState(root, state.content).status !== 'valid') throw Error('authoring_binding_stale_or_invalid');
45
55
  const evaluated = evaluateGateCheck(root, { runId: input.run_id, ignoreRunIdEnv: true, presentationLanguage: input.presentation_language }, observedGit);
56
+ const mode = state.mode_slice_decision?.decision;
57
+ if (scopedCloseout && !isCompletedStructuredCloseout(evaluated, mode)) throw Error('authoring_closeout_unavailable');
46
58
  const protectedSources = parseControlState(state.content, { closeoutArtefacts: ['Planned UR Snapshot', 'Planned UR Origin'] }).artefacts;
47
59
  const rows = [...new Map([...state.artefacts, ...protectedSources])].filter(([, r]) => r.path).map(([type, row]) => ({ type, ...row }));
48
60
  if (rows.length > 32) throw Error('authoring_source_limit');
49
- const sources = rows.map(row => {
61
+ const selected = scopedCloseout ? rows.filter(row => row.type === 'OR' || row.type === 'QA') : rows;
62
+ if (scopedCloseout && selected.length !== 2) throw Error('authoring_closeout_unavailable');
63
+ const sources = selected.map(row => {
50
64
  const path = row.path.replace(/^`|`$/gu, '');
51
65
  if (!path.startsWith(`${runDocumentPath(input.run_id, '')}/`) || hasSymlinkComponent(root, path)) throw Error('authoring_source_unavailable');
52
66
  const file = containedRegularFile(root, path);
@@ -54,17 +68,19 @@ export function inspectAuthoringInputs(root, input, { gitObservation } = {}) {
54
68
  const content = new TextDecoder('utf-8', { fatal: true }).decode(readFileSync(file.path));
55
69
  return { type: row.type, path, status: row.status, digest: artefactFileDigest(root, path), content };
56
70
  });
71
+ if (scopedCloseout) return { languages, gate: evaluated.current_gate, mode, status: evaluated.status,
72
+ blocking_reason: evaluated.blocking_reason, next_operation: evaluated.next_operation, sources };
57
73
  // Match dispatch's initial UX prerequisite route as well as source reassessment.
58
74
  // Reuse its eligibility and contained-source facts; inspection grants no repair permission.
59
75
  const prdEligible = prdDefinitionEligible(evaluated, { ...input, skill_id: 'prd-definition' });
60
76
  const uxRequired = prdEligible && inspectDefinitionSources(root, state, input.run_id, 'PRD', ['UR', 'Brownfield Review']).issue?.repairable;
61
77
  const nextOperation = uxRequired ? { type: 'reassess_source_analysis', skill_id: 'ux-intent-definition', analysis: 'UX Intent Definition' } : evaluated.next_operation;
62
- return { gate: evaluated.current_gate, authoring_owner: nextOperation?.type === 'record_closeout' ? 'OR'
63
- : nextOperation?.analysis ?? nextOperation?.gate ?? evaluated.current_gate,
64
- recording: inspectArtefactRecordingMode(state, evaluated.current_gate), mode: state.mode_slice_decision?.decision, next_operation: nextOperation, status: evaluated.status,
78
+ return { languages, gate: evaluated.current_gate, authoring_owner: nextOperation?.type === 'record_closeout' ? 'OR'
79
+ : nextOperation?.analysis ?? nextOperation?.internal_step ?? nextOperation?.gate ?? evaluated.current_gate,
80
+ recording: inspectArtefactRecordingMode(state, evaluated.current_gate), mode, next_operation: nextOperation, status: evaluated.status,
65
81
  blocking_reason: evaluated.blocking_reason, sources };
66
82
  });
67
- const data = captured.data, ids = [data.gate === 'OR' && data.mode === 'verified_change' ? 'VERIFIED_CHANGE' : templateId(data.authoring_owner),
83
+ const data = captured.data, ids = scopedCloseout ? [] : [data.gate === 'OR' && data.mode === 'verified_change' ? 'VERIFIED_CHANGE' : templateId(data.authoring_owner),
68
84
  ...(['Brownfield Review', 'Mode/Slice Decision'].includes(data.gate) ? ['VERIFIED_CHANGE'] : [])].filter(Boolean);
69
85
  const templates = ids.map(id => {
70
86
  const path = resolveArtefactTemplatePath(id);
@@ -72,39 +88,108 @@ export function inspectAuthoringInputs(root, input, { gitObservation } = {}) {
72
88
  const content = new TextDecoder('utf-8', { fatal: true }).decode(readFileSync(path));
73
89
  return { role: 'template', type: id, digest: digest(canonicalRunText(content)), content, source: 'version_matched_plugin' };
74
90
  });
75
- const documents = [...templates, ...data.sources.map(s => ({ role: 'source', ...s }))];
91
+ const sources = data.sources.map(s => ({ role: 'source', ...s }));
92
+ const currentDraft = sources.find(source => source.type === data.authoring_owner);
93
+ // The source being corrected must not move behind unrelated, growing sources.
94
+ // Keep the legacy template-first view; bundles put the current source first.
95
+ const documents = input.bundle && currentDraft
96
+ ? [currentDraft, ...templates, ...sources.filter(source => source !== currentDraft)]
97
+ : [...templates, ...sources];
76
98
  if (documents.length > 32) throw Error('authoring_source_limit');
77
99
  const manifest = digest(JSON.stringify({ target_id: resolveControlCommandTarget(root).target_id, run_id: input.run_id,
78
100
  ...(input.planning ? { planning: input.planning } : {}),
79
- revision_id: input.expected_revision_id, gate: data.gate, authoring_owner: data.authoring_owner, recording: data.recording, documents: documents.map(({ content, ...r }) => r) })).slice(7);
101
+ ...(scopedCloseout ? { authoring_scope: input.authoring_scope } : {}),
102
+ revision_id: input.expected_revision_id, languages: data.languages, ...(input.bundle ? { bundle: 2 } : {}), gate: data.gate, authoring_owner: data.authoring_owner, recording: data.recording, documents: documents.map(({ content, ...r }) => r) })).slice(7);
80
103
  const chunks = [];
81
104
  for (const document of documents) {
82
105
  const { content, ...metadata } = document, bytes = Buffer.from(content);
106
+ if (input.bundle && !bytes.length) chunks.push({ ...metadata, content: '', byte_start: 0, byte_end: 0, total_bytes: 0 });
83
107
  for (let start = 0; start < bytes.length;) {
84
108
  let end = Math.min(start + 16384, bytes.length);
85
109
  while (end < bytes.length && (bytes[end] & 0xc0) === 0x80) end--;
86
- chunks.push({ ...metadata, content: bytes.subarray(start, end).toString('utf8'), byte_start: start, byte_end: end, total_bytes: bytes.length });
110
+ let chunk;
111
+ for (;;) {
112
+ chunk = { ...metadata, content: bytes.subarray(start, end).toString('utf8'), byte_start: start, byte_end: end, total_bytes: bytes.length };
113
+ if (!input.bundle || Buffer.byteLength(JSON.stringify([chunk])) <= 48128) break;
114
+ end = start + Math.floor((end - start) / 2);
115
+ while (end > start && (bytes[end] & 0xc0) === 0x80) end--;
116
+ if (end <= start) throw Error('authoring_metadata_limit');
117
+ }
118
+ chunks.push(chunk);
87
119
  start = end;
88
120
  }
89
121
  }
122
+ const pages = [];
123
+ if (input.bundle) {
124
+ for (const chunk of chunks) {
125
+ const last = pages.at(-1);
126
+ if (!last || Buffer.byteLength(JSON.stringify([...last, chunk])) > 48128) pages.push([chunk]);
127
+ else last.push(chunk);
128
+ }
129
+ }
130
+ const selection = input.bundle ? pages : chunks;
90
131
  const prefix = `${manifest}:`;
91
132
  if (input.cursor !== undefined && (!input.cursor.startsWith(prefix) || !/^(0|[1-9][0-9]*)$/u.test(input.cursor.slice(prefix.length)))) throw Error('authoring_cursor_stale_or_invalid');
92
133
  const index = input.cursor === undefined ? 0 : Number(input.cursor.slice(prefix.length));
93
- if (!Number.isSafeInteger(index) || index < 0 || index >= Math.max(chunks.length, 1)) throw Error('authoring_cursor_stale_or_invalid');
134
+ if (!Number.isSafeInteger(index) || index < 0 || index >= Math.max(selection.length, 1)) throw Error('authoring_cursor_stale_or_invalid');
135
+ if (git && JSON.stringify(observeGit()) !== JSON.stringify(git)) throw Error('authoring_binding_stale_or_invalid');
94
136
  captured.view.revalidate();
95
- if (JSON.stringify(observeGit()) !== JSON.stringify(git)) throw Error('authoring_binding_stale_or_invalid');
96
- const formats = input.planning ? operationContract('agdf_record', data.recording.kind) : data.authoring_owner === 'OR' ? operationContract('agdf_closeout', 'closeout.record')
137
+ const grouped = new Map();
138
+ for (const part of pages[index] ?? []) {
139
+ const key = JSON.stringify([part.role, part.type, part.path, part.digest]);
140
+ const prior = grouped.get(key);
141
+ if (prior) {
142
+ if (prior.byte_end !== part.byte_start) throw Error('authoring_fragment_order_invalid');
143
+ prior.content += part.content; prior.byte_end = part.byte_end;
144
+ } else grouped.set(key, { ...part });
145
+ }
146
+ const documentRows = [...grouped.values()].map(row => ({ ...row, complete: row.byte_start === 0 && row.byte_end === row.total_bytes }));
147
+ const documentPage = { documents: documentRows.filter(row => row.complete), fragments: documentRows.filter(row => !row.complete) };
148
+ if (input.bundle && Buffer.byteLength(JSON.stringify(documentPage)) > 49152) throw Error('authoring_page_limit');
149
+ const pageCall = page => ({ tool: 'agdf_inspect', arguments: { operation: 'authoring-inputs',
150
+ ...Object.fromEntries(['presentation_language', 'working_directory', 'primary_target', 'target_source', 'target_id',
151
+ 'run_id', 'expected_revision_id', 'planning', 'bundle', 'authoring_scope'].filter(key => input[key] !== undefined).map(key => [key, input[key]])),
152
+ cursor: `${prefix}${page}` } });
153
+ const nextPage = index + 1 < selection.length ? pageCall(index + 1) : null;
154
+ if (scopedCloseout) return { available: true, ...data.languages, run_id: input.run_id, revision_id: input.expected_revision_id,
155
+ gate: data.gate, mode: data.mode, status: data.status, blocking_reason: data.blocking_reason, next_operation: data.next_operation,
156
+ authoring_scope: input.authoring_scope, manifest_digest: `sha256:${manifest}`,
157
+ document_manifest: documents.map(({ content, ...metadata }) => metadata), format: 'document_bundle_v2',
158
+ ...documentPage, page_bytes_limit: 49152, page_index: index, page_count: Math.max(selection.length, 1),
159
+ complete: !nextPage, next_cursor: nextPage?.arguments.cursor ?? null, next_calls: nextPage ? [nextPage] : [], authorizes: false };
160
+ const draftRow = currentDraft && documentRows.find(row => row.role === 'source' && row.type === currentDraft.type && row.path === currentDraft.path && row.digest === currentDraft.digest);
161
+ const draftPage = input.bundle && currentDraft ? pages.findIndex(page => page.some(row => row.role === 'source'
162
+ && row.type === currentDraft.type && row.path === currentDraft.path && row.digest === currentDraft.digest && row.byte_start === 0)) : -1;
163
+ const registeredUr = data.authoring_owner === 'UR' && data.sources.some(source => source.type === 'UR' && source.path);
164
+ const formats = input.planning ? operationContract('agdf_record', data.recording.kind)
165
+ : registeredUr ? operationContract('agdf_revise', 'ur_draft.replace', { gate: 'UR' }) : data.authoring_owner === 'OR' ? operationContract('agdf_closeout', 'closeout.record')
97
166
  : operationContract('agdf_record', ['PRD', 'SD', 'TP', 'QA'].includes(data.authoring_owner) ? 'artefact.record' : 'step.record', { gate: data.authoring_owner });
98
- return { available: true, run_id: input.run_id, revision_id: input.expected_revision_id, gate: data.gate, mode: data.mode,
167
+ const summaryFormat = approvalSummaryAuthoringFormat(data.authoring_owner, currentDraft?.content ?? '', data.languages);
168
+ return { available: true, ...data.languages, run_id: input.run_id, revision_id: input.expected_revision_id, gate: data.gate, mode: data.mode,
99
169
  ...(input.planning ? { planning: input.planning, canonical_skill: 'ur-definition' } : {}),
100
170
  authoring_owner: data.authoring_owner, recording: data.recording,
171
+ ...(summaryFormat ? { approval_summary_format: summaryFormat } : {}),
172
+ ...(!input.planning && index === 0 ? { material_call: preparedCommandCall('agdf_record', 'material.stage',
173
+ { ...input, target_id: resolveControlCommandTarget(root).target_id }, { gate: data.authoring_owner }) } : {}),
101
174
  status: data.status, blocking_reason: data.blocking_reason, next_operation: data.next_operation,
102
- manifest_digest: `sha256:${manifest}`, documents: documents.map(({ content, ...r }) => r),
103
- chunk: chunks[index] ?? null, complete: index + 1 >= chunks.length, next_cursor: index + 1 < chunks.length ? `${prefix}${index + 1}` : null,
175
+ manifest_digest: `sha256:${manifest}`, ...(input.bundle ? { document_manifest: documents.map(({ content, ...r }) => r) } : { documents: documents.map(({ content, ...r }) => r) }),
176
+ ...(input.bundle ? { format: 'document_bundle_v2', ...documentPage, page_bytes_limit: 49152,
177
+ page_index: index, page_count: Math.max(selection.length, 1),
178
+ first_page_call: pageCall(0),
179
+ current_draft: currentDraft ? { type: currentDraft.type, path: currentDraft.path, status: currentDraft.status, digest: currentDraft.digest,
180
+ content_state: draftRow?.complete ? 'complete' : draftRow ? 'fragment' : 'not_on_page',
181
+ ...(draftPage >= 0 && (!draftRow || draftRow.byte_start > 0) ? { read_call: pageCall(draftPage) } : {}),
182
+ instruction: 'Metadata only, never document text or edit permission. Use the matching complete report.documents row. For a fragment, join matching report.fragments by byte offsets across next_calls before editing. If not_on_page or earlier fragment bytes were not retained, copy read_call.arguments unchanged to read its first page.' } : null }
183
+ : { chunk: chunks[index] ?? null }), complete: index + 1 >= selection.length,
184
+ next_cursor: index + 1 < selection.length ? `${prefix}${index + 1}` : null,
185
+ next_calls: nextPage ? [{ ...nextPage, instruction: 'Copy arguments unchanged to read the next page of this manifest. Retain earlier bytes; repeat until complete before editing a fragmented source. No JavaScript cloning or source/path discovery is needed.' }] : [],
104
186
  // The writer contract is identical on every page of one manifest; later pages only name it.
105
- formats: index === 0 ? formats : { schema_version: formats.schema_version, available: formats.available, group: formats.group, kind: formats.kind,
187
+ formats: index === 0 ? input.bundle ? (({ schema, result_schema, ...authoring }) => authoring)(formats) : formats : { schema_version: formats.schema_version, available: formats.available, group: formats.group, kind: formats.kind,
106
188
  omitted: 'identical to the first page of this manifest' },
107
- material_transport: { tool: 'agdf_record', kind: input.planning ? 'planned_material.stage' : 'material.stage', limits: { request_bytes: 65536, part_bytes: 16384, source_bytes: 131072 },
108
- instructions: 'Read all chunks. Stage exact permitted material; seal to obtain identity. Record via the eligible typed writer with explicit cooperative review. No file/path discovery or shell hashing.' }, authorizes: false };
189
+ material_transport: { tool: 'agdf_record', kind: input.planning ? 'planned_material.stage' : 'material.stage', limits: { request_bytes: 65536, inline_file_bytes: MATERIAL_LIMITS.inline, part_bytes: MATERIAL_LIMITS.part, source_bytes: MATERIAL_LIMITS.file },
190
+ instructions: (input.bundle
191
+ ? 'MCP access: response.structuredContent.report (or JSON.parse(response.content[0].text).report). Read complete report.documents[].content; report.document_manifest and current_draft are metadata only. The registered current draft is prioritized; inspect current_draft.content_state before looking for its complete document. Join report.fragments by identity and byte offsets across all next_calls pages before editing. Absent content is an error, never the string undefined. Copy call.arguments unchanged and supply only authored content in the named fields; no JavaScript helper is required. Preserve bundle:true. '
192
+ : 'MCP access: response.structuredContent.report (or JSON.parse(response.content[0].text).report). This legacy view puts text in report.chunk.content; report.documents is metadata only. Follow every next_cursor with this exact binding, or request bundle:true for fewer round trips. ')
193
+ + 'The included formats and bound forms replace a second operation-contract read. Retain unchanged sources for this manifest. Prefer material_call: put takes exact UTF-8 <=48 KiB per file within the 64 KiB JSON request bound and seals once. Use returned recording_calls, adding only required author/review inputs. Larger files use multipart; each action has its own UUID. Follow next_calls exactly. No file/path discovery or shell hashing. ' + AUTHORING_TEXT_HANDOFF }, authorizes: false };
109
194
  } catch (e) { return unavailable(e.code ?? e.message); }
110
195
  }
@@ -22,7 +22,10 @@ import { runSealState } from '../control-state/run-seal.js';
22
22
  import { ARTIFACT_READINESS_GATES, projectArtifactReadiness, describeArtifactReadiness } from './artifact-readiness.js';
23
23
  import { artefactFileDigest } from '../control-state/run-seal-compute.js';
24
24
  import { inspectApprovedArtefact } from '../control-state/artefact-binding-proof.js';
25
- import { runClosure, ENDED_LIFECYCLES } from '../control-state/run-operations.js';
25
+ import { runClosure } from '../control-state/run-operations.js';
26
+ // Shared with the companion run view, in a module every runtime profile carries.
27
+ import { boundedCode, projectCockpitAssessment } from './run-classification.js';
28
+ export { boundedCode, projectCockpitAssessment };
26
29
 
27
30
  const CONTROL = '.agdf/control/';
28
31
  const SUPPORTED = new Map([['md', 'markdown'], ['json', 'json'], ['txt', 'text'], ['log', 'text']]);
@@ -31,13 +34,6 @@ const DOCUMENT_GATES = new Set(['UR', 'PRD', 'SD', 'TP', 'QA', 'UAT']);
31
34
  const DESCRIPTION_LIMIT = 256 * 1024;
32
35
  const rawDigest = bytes => createHash('sha256').update(bytes).digest('hex');
33
36
  const assertDescriptionBound = value => { if (Buffer.byteLength(JSON.stringify(value)) > DESCRIPTION_LIMIT) fail('resource_limit'); };
34
- function boundedCode(error) {
35
- const code = error.code ?? error.message;
36
- if (code === 'AGDF_CONTROL_LAYOUT_UNSUPPORTED') return 'control_layout_unsupported';
37
- if (code === 'AGDF_RUN_VERSION_UNSUPPORTED') return 'run_version_unsupported';
38
- if (code === 'AGDF_CONTROL_LAYOUT_INVALID') return 'control_invalid';
39
- return ['resource_denied', 'source_changed', 'timeout', 'resource_limit', 'read_failed'].includes(error.code) ? error.code : 'read_failed';
40
- }
41
37
  const objective = content => content?.match(/(?:^|\n)## Objective\s*\n([\s\S]*?)(?=\n## |$)/)?.[1]?.trim() ?? null;
42
38
  // History of an ended Run, read only from its sealed closure receipt; null for every other Run.
43
39
  export function projectRunClosure(content) {
@@ -46,18 +42,6 @@ export function projectRunClosure(content) {
46
42
  closed_at: closure.closed_at, operation_id: closure.operation_id, receipt: closure.receipt, authorizes: false };
47
43
  }
48
44
 
49
- // Read-only projection of the evaluated decision, never a second gate evaluator.
50
- // Doctor warnings are already considered by evaluateGateCheck; they are not a UI veto.
51
- export function projectCockpitAssessment(report, lifecycle) {
52
- const state = ENDED_LIFECYCLES.includes(lifecycle) ? 'ended'
53
- : lifecycle === 'completed' ? report.completion?.fulfilled === true ? 'completed' : 'unconfirmed'
54
- : lifecycle !== 'active' ? 'unconfirmed'
55
- : report.status === 'blocked' || (report.blocking_reason && report.blocking_reason !== 'none')
56
- || (report.missing_approval && report.missing_approval !== 'none') ? 'blocked'
57
- : report.status === 'open' && report.blocking_reason === 'none' && report.missing_approval === 'none' ? 'open'
58
- : 'unconfirmed';
59
- return { state, authorizes: false };
60
- }
61
45
 
62
46
  export function createCockpitReader(root, options = {}) {
63
47
  let view = null, details = new Map(), documents = new Map();
@@ -11,6 +11,7 @@ import {
11
11
  import { normalizeTaskTargetSource, TASK_TARGET_SOURCES } from "../task-target-resolution.js";
12
12
  import { SKILL_DISPATCH_MAX_OUTPUT_BYTES, SkillDispatchInputError, emptySkillDispatchTiming } from "../skill-dispatch/contract.js";
13
13
  import { ARTIFACT_READINESS_GATES, ALL_ACTIVE_OPERATIONS, VARIANT_OPERATION, MODULE_OPERATION, CONTROL_INSPECT_OPERATIONS, GATE_CHECK_VARIANTS, ReadSelectionError, validateReadSelection } from "./selection.js";
14
+ import { CLOSEOUT_AUTHORING_SCOPE } from './selection.js';
14
15
 
15
16
  export const CONTROL_INSPECT_SCHEMA_VERSION = "1";
16
17
  export const CONTROL_INSPECT_CONTRACT_VERSION = 1;
@@ -29,6 +30,7 @@ function deepFreeze(value) {
29
30
  export const PRESENTATION_OPERATIONS = Object.freeze(['presentation-document', 'presentation-preview']);
30
31
  export const BOUND_INSPECT_OPERATIONS = Object.freeze(['artifact-readiness', 'authoring-inputs', 'operation-contract', 'operation-status', 'native-qualification', ...PRESENTATION_OPERATIONS, 'runtime-generations']);
31
32
  export const PRESENTATION_CATALOG_MODULE = 'agdf_prepare/presentation.prepare';
33
+ const CLI_MODULE_HINTS = Object.freeze({ 'agdf_approve/run-approve': 'agdf_approve/approval.record' });
32
34
  const uuidSchema = { type: 'string', pattern: REVISION_ID_PATTERN.source };
33
35
  const cursorSchema = { type: 'string', maxLength: 80, pattern: '^[0-9a-f]{64}:(?:0|[1-9][0-9]{0,6})$' };
34
36
  const fieldModel = {
@@ -43,36 +45,46 @@ const fieldModel = {
43
45
  expected_revision_id: { help: 'Bound inspections use current gate-check revision. Document/preview reads preserve the original selected catalog or conversation revision.', schema: { $ref: '#/$defs/i' }, description: 'gate-check revision; original for reads.', operations: BOUND_INSPECT_OPERATIONS },
44
46
  presentation_id: { help: 'Exact prepared ID from validated catalog or conversation. Never guess, select by timestamp, or prepare a replacement to read.', schema: { $ref: '#/$defs/i' }, description: 'ID from catalog/conversation.', operations: PRESENTATION_OPERATIONS },
45
47
  target_id: { help: 'Optional confirmed target hash on target-bound reads; when supplied it must match. Required for presentation reads; never grants authority.', schema: { type: 'string', pattern: '^sha256:[0-9a-f]{64}$' }, description: 'Optional verified target hash.' },
48
+ bundle: { help: 'authoring-inputs only: bounded multi-document pages with exact source bytes.', schema: { type: 'boolean' }, operations: ['authoring-inputs'] },
49
+ authoring_scope: { help: 'Bundled authoring-inputs for a completed structured Run: read only its current OR and QA.', schema: { type: 'string', const: CLOSEOUT_AUTHORING_SCOPE }, operations: ['authoring-inputs'] },
46
50
  cursor: { help: 'Omit initially; copy next_cursor. doctor requires all_active; catalog requires its declared module. Never exchange cursor types.', schema: cursorSchema, description: 'Copy next_cursor.', operations: [...PRESENTATION_OPERATIONS, 'operation-contract', 'authoring-inputs', 'doctor'] },
47
51
  variant: { help: 'gate-check view only; never records approval.', schema: { enum: [...GATE_CHECK_VARIANTS] }, description: 'gate-check view.', operations: [VARIANT_OPERATION] },
48
52
  module: { help: 'contract: advertised module; operation-contract: group/kind; operation-status: original operation UUID from saved receipt, never a new UUID. Setup uses project.initialize/ORIGINAL_UUID without Run/revision; Run operations require Run/revision.', schema: { type: 'string', minLength: 1, maxLength: 64 }, description: 'Contract, group/kind or receipt UUID.', operations: [MODULE_OPERATION, 'operation-contract', 'operation-status'] },
49
53
  all_active: { help: 'true: doctor/delivery-map only; false: selected Run.', schema: { type: 'boolean' }, description: 'doctor/delivery-map only.' },
50
54
  };
51
- const selectorKeys = { gate: 'gate', expected_revision_id: 'expectedRevisionId', presentation_id: 'presentationId', target_id: 'targetId', cursor: 'cursor', variant: 'variant', module: 'contractModule', planning: 'planning' };
55
+ const selectorKeys = { gate: 'gate', expected_revision_id: 'expectedRevisionId', presentation_id: 'presentationId', target_id: 'targetId', cursor: 'cursor', variant: 'variant', module: 'contractModule', planning: 'planning', bundle: 'bundle', authoring_scope: 'authoringScope' };
52
56
  const moduleOperations = [MODULE_OPERATION, 'operation-contract', 'operation-status'];
53
57
  const inputSchema = {
54
58
  type: 'object', additionalProperties: false,
55
59
  required: ['operation', 'presentation_language', 'working_directory'],
56
- $defs: { i: uuidSchema, b: { not: { enum: CONTROL_INSPECT_OPERATIONS.filter(op => !BOUND_INSPECT_OPERATIONS.includes(op)) } }, d: { enum: PRESENTATION_OPERATIONS }, m: { enum: ['operation-contract', 'operation-status'] } },
60
+ $defs: {
61
+ i: uuidSchema,
62
+ b: { not: { enum: CONTROL_INSPECT_OPERATIONS.filter(op => !BOUND_INSPECT_OPERATIONS.includes(op)) } },
63
+ d: { enum: PRESENTATION_OPERATIONS },
64
+ m: { enum: ['operation-contract', 'operation-status'] },
65
+ u: { not: { anyOf: [{ required: ['run_id'] }, { required: ['expected_revision_id'] }] } },
66
+ },
57
67
  properties: Object.fromEntries(Object.entries(fieldModel).map(([name, field]) => [name, { ...field.schema, description: field.description }])),
58
68
  dependentRequired: { target_source: ['primary_target'], primary_target: ['target_source'], target_id: ['primary_target', 'target_source'] },
59
69
  dependentSchemas: Object.fromEntries(Object.entries(fieldModel).filter(([, f]) => f.operations).map(([name, field]) => [name,
60
- name === 'cursor' ? { anyOf: [ { properties: { operation: { enum: [...PRESENTATION_OPERATIONS, 'authoring-inputs'] } } },
70
+ // Bundle selects authoring-inputs, whose Run binding requires an expected revision.
71
+ name === 'authoring_scope' ? { properties: { bundle: { const: true } }, required: ['bundle', 'run_id'] }
72
+ : name === 'cursor' ? { anyOf: [ { properties: { operation: { enum: [...PRESENTATION_OPERATIONS, 'authoring-inputs'] } } },
61
73
  { properties: { operation: { const: 'doctor' }, all_active: { const: true } }, required: ['all_active'] },
62
74
  { properties: { operation: { const: 'operation-contract' }, module: { const: PRESENTATION_CATALOG_MODULE } } } ] }
63
75
  : { properties: { operation: field.operations === BOUND_INSPECT_OPERATIONS ? { $ref: '#/$defs/b' }
64
76
  : field.operations === PRESENTATION_OPERATIONS ? { $ref: '#/$defs/d' } : name === 'module' ? { enum: moduleOperations } : { enum: field.operations } } },
65
77
  ])),
66
78
  allOf: [
67
- { if: { properties: { operation: { enum: ['project-state', 'planned-inventory', 'planned-entry'] } } }, then: { required: ['target_source', 'primary_target'], not: { anyOf: [{ required: ['run_id'] }, { required: ['expected_revision_id'] }] } } },
79
+ { if: { properties: { operation: { enum: ['project-state', 'planned-inventory', 'planned-entry'] } } }, then: { required: ['target_source', 'primary_target'], $ref: '#/$defs/u' } },
68
80
  { if: { properties: { operation: { const: 'planned-entry' } } }, then: { required: ['planning'] } },
69
- { if: { required: ['planning'] }, then: { required: ['target_source', 'primary_target'], not: { anyOf: [{ required: ['run_id'] }, { required: ['expected_revision_id'] }] } } },
81
+ { if: { required: ['planning'] }, then: { required: ['target_source', 'primary_target'], $ref: '#/$defs/u' } },
70
82
  { not: { properties: { all_active: { const: true } }, required: ['all_active', 'run_id'] } },
71
83
  { anyOf: [{ properties: { all_active: { const: false } } }, { properties: { operation: { enum: [...ALL_ACTIVE_OPERATIONS] } } }] },
72
84
  { if: { properties: { operation: { $ref: '#/$defs/m' } } }, then: { required: ['module'] } },
73
85
  { if: { properties: { operation: { $ref: '#/$defs/b' } } }, then: { required: ['target_source'], anyOf: [
74
86
  { required: ['run_id', 'expected_revision_id'] },
75
- { not: { anyOf: [{ required: ['run_id'] }, { required: ['expected_revision_id'] }] }, oneOf: [
87
+ { $ref: '#/$defs/u', oneOf: [
76
88
  { properties: { operation: { const: 'operation-status' } } },
77
89
  { properties: { operation: { const: 'operation-contract' }, module: { anyOf: [{ enum: ['agdf_run/run.create', 'agdf_project/project.initialize'] }, { pattern: '/(?:planned_|run\\.create_from_planned)' }] } }, required: ['module'] },
78
90
  { properties: { operation: { const: 'authoring-inputs' } }, required: ['planning'] },
@@ -85,21 +97,17 @@ const inputSchema = {
85
97
 
86
98
  inputSchema.dependentSchemas.operation = { allOf: inputSchema.allOf };
87
99
  delete inputSchema.allOf;
88
- const conciseHelp = { target_source: 'Pair primary_target; explicit=named; continued=confirmed; current=unambiguous repo.', primary_target: 'Confirmed root; pair target_source.',
89
- module: 'contract:index; operation-contract:group/kind; status:UUID.',
90
- run_id: 'Not for inventory/project/planned.',
91
- expected_revision_id: 'Bound reads only; not gate-check.',
92
- planning: 'Planning reads only.',
93
- target_id: 'Required for docs; gate-check.',
94
- gate: 'Not for gate-check.' };
95
- for (const [key, field] of Object.entries(inputSchema.properties)) {
96
- delete field.description;
97
- if (conciseHelp[key]) field.description = conciseHelp[key];
98
- }
100
+ // Full selector help is available on demand; discovery keeps the exact guards.
101
+ for (const field of Object.values(inputSchema.properties)) delete field.description;
102
+ Object.assign(inputSchema.properties.target_source, { description: 'Pair primary_target.' });
103
+ Object.assign(inputSchema.properties.primary_target, { description: 'Confirmed target.' });
104
+ Object.assign(inputSchema.properties.module, { description: 'Contract, group/kind or receipt UUID.' });
105
+ Object.assign(inputSchema.properties.gate, { description: 'Not for gate-check.' });
106
+ Object.assign(inputSchema.properties.target_id, { description: 'Required for docs; gate-check.' });
99
107
 
100
108
  const inspectContract = {
101
109
  name: "agdf_inspect",
102
- description: 'Read-only. Ex:{"operation":"operation-contract","module":"agdf_run/run.create","working_directory":"/r","target_source":"explicit_target","primary_target":"/r"}. navigation.next_calls sequentially; read all pages; never dispatch. Setup status: project.initialize/UUID, no Run/revision. Run status: original UUID+run_id+expected_revision_id.',
110
+ description: 'Read only. Use next_action.call. Raw bound reads need working_directory,presentation_language,primary_target,target_source. Run status needs run_id+expected_revision_id. Setup omits both.',
103
111
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
104
112
  inputSchema: projectMcpInputSchema(inputSchema),
105
113
  outputSchema: {
@@ -175,14 +183,42 @@ export function inspectContractHelp() {
175
183
  });
176
184
  }
177
185
 
186
+ function correctedOperationModule(module) {
187
+ if (typeof module !== 'string' || module.length > 64 || OPERATION_CONTRACT_MODULES.includes(module)) return null;
188
+ const exact = CLI_MODULE_HINTS[module];
189
+ if (exact && OPERATION_CONTRACT_MODULES.includes(exact)) return exact;
190
+ const kind = module.split('/').at(-1);
191
+ const matches = OPERATION_CONTRACT_MODULES.filter(value => value.split('/').at(-1) === kind);
192
+ return matches.length === 1 ? matches[0] : null;
193
+ }
194
+
195
+ // A new read-only schema lookup for one unambiguous registered owner. This
196
+ // preserves explicit bindings; it never executes or repairs the invalid request.
197
+ export function inspectModuleRecoveryCall(input) {
198
+ if (!input || input.operation !== 'operation-contract') return null;
199
+ const module = correctedOperationModule(input.module);
200
+ const allowed = new Set(['operation', 'module', 'working_directory', 'primary_target', 'target_source',
201
+ 'presentation_language', 'run_id', 'expected_revision_id', 'gate', 'target_id']);
202
+ if (!module || Object.keys(input).some(key => !allowed.has(key))) return null;
203
+ for (const key of ['working_directory', 'primary_target', 'target_source', 'run_id'])
204
+ if (!Object.hasOwn(input, key) || schemaDiagnostics(input[key], fieldModel[key].schema).length) return null;
205
+ if (!isAbsolute(input.working_directory) || !isAbsolute(input.primary_target)
206
+ || typeof input.expected_revision_id !== 'string' || !REVISION_ID_PATTERN.test(input.expected_revision_id)
207
+ || input.presentation_language !== undefined && schemaDiagnostics(input.presentation_language, fieldModel.presentation_language.schema).length
208
+ || input.gate !== undefined && !APPROVAL_GATES.includes(input.gate)
209
+ || input.target_id !== undefined && (typeof input.target_id !== 'string' || !/^sha256:[0-9a-f]{64}$/u.test(input.target_id))) return null;
210
+ return { tool: 'agdf_inspect', arguments: { ...input, module } };
211
+ }
212
+
178
213
  export function inspectInputValidationHint(input) {
179
214
  if (!input || typeof input !== 'object' || !CONTROL_INSPECT_OPERATIONS.includes(input.operation)) return '';
180
215
  const operation = input.operation, messages = [];
216
+ let diagnosedModule = input.module;
181
217
  if (operation === 'operation-contract' && typeof input.module === 'string' && input.module.length <= 64
182
218
  && !OPERATION_CONTRACT_MODULES.includes(input.module)) {
183
- const kind = input.module.split('/').at(-1);
184
- const matches = OPERATION_CONTRACT_MODULES.filter(module => module.split('/').at(-1) === kind);
185
- messages.push(matches.length === 1 ? `Use module ${matches[0]}; this is the registered owner of ${kind}.`
219
+ const correction = correctedOperationModule(input.module);
220
+ if (correction) diagnosedModule = correction; // Help only; the original invalid request remains rejected.
221
+ messages.push(correction ? `Use module ${correction}; the original module is invalid and was not executed.`
186
222
  : 'Read contract without module for the registered operation_modules; do not guess a group/kind.');
187
223
  }
188
224
  for (const [name, field] of Object.entries(fieldModel)) {
@@ -194,8 +230,8 @@ export function inspectInputValidationHint(input) {
194
230
  // Diagnose the selected operation, rather than making the model interpret
195
231
  // errors from every alternative of the discovery schema's oneOf branches.
196
232
  const unboundContract = operation === 'operation-contract' &&
197
- (['agdf_run/run.create', 'agdf_project/project.initialize'].includes(input.module)
198
- || OPERATION_CONTRACT_MODULES.includes(input.module) && /\/(?:planned_|run\.create_from_planned)/u.test(input.module));
233
+ (['agdf_run/run.create', 'agdf_project/project.initialize'].includes(diagnosedModule)
234
+ || OPERATION_CONTRACT_MODULES.includes(diagnosedModule) && /\/(?:planned_|run\.create_from_planned)/u.test(diagnosedModule));
199
235
  const bound = BOUND_INSPECT_OPERATIONS.includes(operation) && !unboundContract
200
236
  && !(operation === 'operation-status' && !input.run_id && !input.expected_revision_id)
201
237
  && !(operation === 'authoring-inputs' && input.planning);
@@ -254,6 +290,7 @@ export function parseControlInspectFunctionArguments(argumentsValue, trustedCont
254
290
 
255
291
  // Shared language, target and read-selection rules; errors carry the invalid field.
256
292
  export function normalizeControlInspectInput(input) {
293
+ if (input.bundle !== undefined && typeof input.bundle !== 'boolean') throw new SkillDispatchInputError('bundle', 'bundle must be boolean');
257
294
  const operation = requireText(input.operation, "operation", 64);
258
295
  if (!CONTROL_INSPECT_OPERATIONS.includes(operation)) throw new SkillDispatchInputError("operation", `Unsupported inspect operation: ${operation}`);
259
296
  let requestedPresentationLanguage;
@@ -276,6 +313,9 @@ export function normalizeControlInspectInput(input) {
276
313
  throw new SkillDispatchInputError('target_id', 'A valid target hash requires a confirmed target');
277
314
  const runId = input.runId || null;
278
315
  const planning = input.planning;
316
+ if (input.authoringScope !== undefined && (input.authoringScope !== CLOSEOUT_AUTHORING_SCOPE
317
+ || input.bundle !== true || !runId || planning !== undefined))
318
+ throw new SkillDispatchInputError('authoring_scope', 'Closeout scope requires a bundled Run read');
279
319
  if (planning !== undefined && (schemaDiagnostics(planning, PLANNING_SCOPE_SCHEMA).length || runId || input.expectedRevisionId !== undefined || input.gate !== undefined
280
320
  || !primaryTarget || !fieldModel.planning.operations.includes(operation))) throw new SkillDispatchInputError('planning', 'Planning requires one exact pre-Run source scope and confirmed target; no Run/revision/gate');
281
321
  if (operation === 'operation-status' && Boolean(planning) !== /^(?:planned_ur\.|run\.create_from_planned\/)/u.test(input.contractModule ?? ''))
@@ -336,7 +376,7 @@ export function normalizeControlInspectInput(input) {
336
376
  target_source: targetSource,
337
377
  primary_target: primaryTarget,
338
378
  run_id: runId,
339
- planning,
379
+ planning, bundle: input.bundle, authoring_scope: input.authoringScope,
340
380
  gate: input.gate,
341
381
  expected_revision_id: input.expectedRevisionId,
342
382
  presentation_id: input.presentationId, target_id: input.targetId, cursor: input.cursor,
@@ -0,0 +1,54 @@
1
+ import { resolveTaskTarget } from '../task-target-resolution.js';
2
+ import { preparedCommandCall } from '../control-state/prepared-control-calls.js';
3
+ import { inspectUxIntentDecision, UX_DECISION_FORMAT } from '../control-evaluation/definition-sources.js';
4
+ import { validateRunCommand } from '../control-state/run-command-schema.js';
5
+ import { inspectAuthoringInputs } from './authoring-inputs.js';
6
+
7
+ // Mirrors an explicit author declaration; never chooses a judgement or review.
8
+ export function withUxSourceDecision(form, content) {
9
+ const observed = inspectUxIntentDecision(content);
10
+ const source_validation = { ...observed, format: UX_DECISION_FORMAT, authorizes: false };
11
+ if (!observed.well_formed || !observed.supported || observed.decision === 'not_applicable') return {
12
+ source_validation: { ...source_validation, recordable: false,
13
+ reason: !observed.well_formed ? 'ux_decision_malformed' : 'ux_decision_not_supported_for_required_analysis',
14
+ instruction: 'Correct the explicit - decision: field in the authored report, then stage the corrected bytes with the new material_call. No canonical record was attempted; choose ready or blocked from actual analysis, never from this diagnostic.' } };
15
+ const filled = structuredClone(form);
16
+ filled.call.arguments.command.payload.decision = observed.decision;
17
+ filled.required_inputs = filled.required_inputs.filter(p => p !== '/command/payload/decision');
18
+ filled.state = validateRunCommand(filled.call.tool, filled.call.arguments).length ? 'requires_author_input' : 'ready';
19
+ return { form: filled, source_validation: { ...source_validation, recordable: true,
20
+ decision_origin: 'exact explicit author declaration in staged source; not generated judgement' } };
21
+ }
22
+
23
+ // Reuse the canonical author/source selection, including analytical prerequisites
24
+ // at an outer gate. Transport itself cannot choose a future/protected writer.
25
+ export function withMaterialRecordingCalls(input, result) {
26
+ if (result.outcome !== 'accepted' || input.planning || !['put', 'seal'].includes(input.command.payload.action)) return result;
27
+ try {
28
+ const target = resolveTaskTarget({ workingDirectory: input.working_directory, primaryTarget: input.primary_target, targetSource: input.target_source });
29
+ if (target.resolution_state !== 'resolved') return result;
30
+ const authoring = inspectAuthoringInputs(target.governance_target, input);
31
+ if (!authoring.available || authoring.revision_id !== input.expected_revision_id) return result;
32
+ const slot = authoring.material_call?.call.arguments.command.payload.files[0].slot;
33
+ const files = (result.family_result.files ?? []).filter(file => file.reference && file.slot === slot);
34
+ if (files.length !== 1 || !authoring.formats?.available) return result;
35
+ const { group, kind } = authoring.formats;
36
+ if (kind === 'closeout.record') {
37
+ if (!['structured_delivery', 'structured_slice'].includes(authoring.mode)
38
+ || authoring.next_operation?.type !== 'record_closeout' || authoring.authoring_owner !== 'OR' || slot !== 'OR') return result;
39
+ } else if (!['step.record', 'artefact.record', 'ur_draft.replace'].includes(kind)) return result;
40
+ const form = preparedCommandCall(group, kind, input,
41
+ { gate: authoring.authoring_owner, material: files[0].reference, recording: authoring.recording });
42
+ if (kind === 'closeout.record' && form?.state !== 'ready') return result;
43
+ if (form && authoring.authoring_owner === 'UX Intent Definition' && input.command.payload.action === 'put') {
44
+ const text = input.command.payload.files.find(file => file.slot === slot)?.content;
45
+ if (typeof text === 'string') {
46
+ const checked = withUxSourceDecision(form, text);
47
+ return { ...result, source_validation: checked.source_validation,
48
+ ...(checked.form ? { recording_calls: [{ slot, ...checked.form }] }
49
+ : { recording_calls: [], material_call: authoring.material_call }) };
50
+ }
51
+ }
52
+ return form && !form.required_inputs.includes('/command/payload') ? { ...result, recording_calls: [{ slot, ...form }] } : result;
53
+ } catch { return result; } // Guidance cannot conceal an accepted private transfer.
54
+ }
@@ -37,7 +37,8 @@ export function inspectProjectState(root, input, gitObservation) {
37
37
  ? projectOperationStatusCall({ ...input, operation_id: original }) : null;
38
38
  const report = { available: true, target_id, repository, plan: inspectCanonicalInitializationPlan(), ...state,
39
39
  setup: { tool: 'agdf_project', kind: 'project.initialize', binding: { schema_version: '1', assurance: 'cooperative_local', ...common, target_id },
40
- required_agent_fields: ['operation_id'], requires_explicit_intent: true }, next_calls: [...(next ? [next] : []), ...(statusCall ? [statusCall] : [])],
40
+ required_agent_fields: ['operation_id'], requires_explicit_intent: true }, next_calls: next ? [next] : [],
41
+ ...(statusCall ? { recovery_only: { status_call: statusCall, authorizes: false } } : {}),
41
42
  ...(input.operation === 'operation-status' ? { operation_id: input.operation_id, status: state.operation_status, current_setup: state.status } : {}),
42
43
  ...(state.status === 'pending' ? { recovery: { action: 'replay_original', operation_id: state.operation.operation_id,
43
44
  request_digest: state.operation.request_digest, instruction: 'Replay only the saved original project.initialize UUID/payload. Owned stage, target, plan and producer are revalidated before any effect.', authorizes: false } } : {}),
@@ -0,0 +1,31 @@
1
+ // Read-only run classification shared by the Codex cockpit and the companion run view (companion core
2
+ // SDD-001, SDD-003). It lives apart from the cockpit so every runtime profile carries it, Copilot
3
+ // included, whose projection leaves the private cockpit out. Nothing here evaluates a gate rule.
4
+ import { ENDED_LIFECYCLES } from '../control-state/run-operations.js';
5
+
6
+ // The read-failure codes passed through unchanged, and every code `boundedCode` can return.
7
+ const READ_FAILURE_CODES = Object.freeze(['resource_denied', 'source_changed', 'timeout', 'resource_limit', 'read_failed']);
8
+ export const BOUNDED_READ_CODES = Object.freeze(['control_layout_unsupported', 'run_version_unsupported', 'control_invalid', ...READ_FAILURE_CODES]);
9
+
10
+ // Bounded reason code of a read failure.
11
+ export function boundedCode(error) {
12
+ const code = error.code ?? error.message;
13
+ if (code === 'AGDF_CONTROL_LAYOUT_UNSUPPORTED' || code === 'control_layout_unsupported') return 'control_layout_unsupported';
14
+ if (code === 'AGDF_RUN_VERSION_UNSUPPORTED') return 'run_version_unsupported';
15
+ // The configuration owner's codes (resources/configuration.js configurationError).
16
+ if (code === 'AGDF_CONTROL_LAYOUT_INVALID' || code === 'configuration_invalid') return 'control_invalid';
17
+ return READ_FAILURE_CODES.includes(error.code) ? error.code : 'read_failed';
18
+ }
19
+
20
+ // Read-only projection of the evaluated decision, never a second gate evaluator.
21
+ // Doctor warnings are already considered by evaluateGateCheck; they are not a UI veto.
22
+ export function projectCockpitAssessment(report, lifecycle) {
23
+ const state = ENDED_LIFECYCLES.includes(lifecycle) ? 'ended'
24
+ : lifecycle === 'completed' ? report.completion?.fulfilled === true ? 'completed' : 'unconfirmed'
25
+ : lifecycle !== 'active' ? 'unconfirmed'
26
+ : report.status === 'blocked' || (report.blocking_reason && report.blocking_reason !== 'none')
27
+ || (report.missing_approval && report.missing_approval !== 'none') ? 'blocked'
28
+ : report.status === 'open' && report.blocking_reason === 'none' && report.missing_approval === 'none' ? 'open'
29
+ : 'unconfirmed';
30
+ return { state, authorizes: false };
31
+ }
@@ -2,6 +2,12 @@
2
2
 
3
3
  export const ARTIFACT_READINESS_GATES = Object.freeze(['UR', 'PRD', 'SD', 'TP']);
4
4
  export const CONTROL_INSPECT_OPERATIONS = Object.freeze(["doctor", "gate-check", "delivery-map", "contract", "artifact-readiness", "authoring-inputs", "operation-contract", "operation-status", "native-qualification", "presentation-document", "presentation-preview", "runtime-generations", "project-state", "inventory", "planned-inventory", "planned-entry"]);
5
+ export const CLOSEOUT_AUTHORING_SCOPE = 'delivery-closeout';
6
+
7
+ export function isCompletedStructuredCloseout(control, mode) {
8
+ return control.current_gate === 'OR' && control.completion?.fulfilled === true
9
+ && ['structured_delivery', 'structured_slice'].includes(mode);
10
+ }
5
11
  export const ALL_ACTIVE_OPERATIONS = Object.freeze(["doctor", "delivery-map"]);
6
12
  export const VARIANT_OPERATION = "gate-check";
7
13
  export const MODULE_OPERATION = "contract";