@wildo-ai/dev-companion 1.1.1 → 1.1.2

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 (224) hide show
  1. package/dist/esm/.tsbuildinfo +1 -1
  2. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts +12 -1
  3. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts.map +1 -1
  4. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js +11 -0
  5. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js.map +1 -1
  6. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts +153 -1
  7. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts.map +1 -1
  8. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js +419 -41
  9. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
  10. package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.d.ts +25 -10
  11. package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.d.ts.map +1 -1
  12. package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.js +65 -24
  13. package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.js.map +1 -1
  14. package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts +86 -0
  15. package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts.map +1 -0
  16. package/dist/esm/claude-cli/services/research-evidence-store.companion.js +127 -0
  17. package/dist/esm/claude-cli/services/research-evidence-store.companion.js.map +1 -0
  18. package/dist/esm/companion-api/companion-api.schemas.d.ts +59 -2
  19. package/dist/esm/companion-api/companion-api.schemas.d.ts.map +1 -1
  20. package/dist/esm/companion-api/companion-api.schemas.js +60 -0
  21. package/dist/esm/companion-api/companion-api.schemas.js.map +1 -1
  22. package/dist/esm/companion-api/controllers/companion.controller.d.ts +63 -1
  23. package/dist/esm/companion-api/controllers/companion.controller.d.ts.map +1 -1
  24. package/dist/esm/companion-api/controllers/companion.controller.js +322 -21
  25. package/dist/esm/companion-api/controllers/companion.controller.js.map +1 -1
  26. package/dist/esm/core/inject/models/container.d.ts.map +1 -1
  27. package/dist/esm/core/inject/models/container.js +11 -0
  28. package/dist/esm/core/inject/models/container.js.map +1 -1
  29. package/dist/esm/core/inject/models/service-types.d.ts +5 -0
  30. package/dist/esm/core/inject/models/service-types.d.ts.map +1 -1
  31. package/dist/esm/core/inject/models/service-types.js +5 -0
  32. package/dist/esm/core/inject/models/service-types.js.map +1 -1
  33. package/dist/esm/core/introspection/behaviors/companion-introspection-behavior-definitions.d.ts.map +1 -1
  34. package/dist/esm/core/introspection/behaviors/companion-introspection-behavior-definitions.js +81 -0
  35. package/dist/esm/core/introspection/behaviors/companion-introspection-behavior-definitions.js.map +1 -1
  36. package/dist/esm/core/introspection/models/companion-introspection.models.d.ts +11 -1
  37. package/dist/esm/core/introspection/models/companion-introspection.models.d.ts.map +1 -1
  38. package/dist/esm/core/introspection/models/companion-introspection.models.js +39 -0
  39. package/dist/esm/core/introspection/models/companion-introspection.models.js.map +1 -1
  40. package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.d.ts +8 -0
  41. package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.d.ts.map +1 -0
  42. package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.js +317 -0
  43. package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.js.map +1 -0
  44. package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.d.ts +45 -0
  45. package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.d.ts.map +1 -0
  46. package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js +250 -0
  47. package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js.map +1 -0
  48. package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.d.ts +123 -0
  49. package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.d.ts.map +1 -0
  50. package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.js +298 -0
  51. package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.js.map +1 -0
  52. package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.d.ts +78 -1
  53. package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.d.ts.map +1 -1
  54. package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.js +155 -6
  55. package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.js.map +1 -1
  56. package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts +131 -2
  57. package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts.map +1 -1
  58. package/dist/esm/core/introspection/services/companion-introspection.companion.service.js +259 -9
  59. package/dist/esm/core/introspection/services/companion-introspection.companion.service.js.map +1 -1
  60. package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.d.ts +243 -0
  61. package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.d.ts.map +1 -0
  62. package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.js +417 -0
  63. package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.js.map +1 -0
  64. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts +186 -0
  65. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts.map +1 -0
  66. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js +368 -0
  67. package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js.map +1 -0
  68. package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.d.ts +101 -0
  69. package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.d.ts.map +1 -0
  70. package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.js +278 -0
  71. package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.js.map +1 -0
  72. package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.d.ts +365 -0
  73. package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.d.ts.map +1 -0
  74. package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.js +167 -0
  75. package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.js.map +1 -0
  76. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.d.ts.map +1 -1
  77. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js +332 -3
  78. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js.map +1 -1
  79. package/dist/esm/core/introspection/subprocess/family-aspects.behavior.d.ts +19 -0
  80. package/dist/esm/core/introspection/subprocess/family-aspects.behavior.d.ts.map +1 -0
  81. package/dist/esm/core/introspection/subprocess/family-aspects.behavior.js +164 -0
  82. package/dist/esm/core/introspection/subprocess/family-aspects.behavior.js.map +1 -0
  83. package/dist/esm/core/introspection/subprocess/openapi-generation-input.behavior.d.ts +3 -1
  84. package/dist/esm/core/introspection/subprocess/openapi-generation-input.behavior.d.ts.map +1 -1
  85. package/dist/esm/core/introspection/subprocess/openapi-generation-input.behavior.js +36 -23
  86. package/dist/esm/core/introspection/subprocess/openapi-generation-input.behavior.js.map +1 -1
  87. package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.d.ts +51 -0
  88. package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.d.ts.map +1 -0
  89. package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.js +391 -0
  90. package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.js.map +1 -0
  91. package/dist/esm/core/runtime/companion-startup-assembly.d.ts.map +1 -1
  92. package/dist/esm/core/runtime/companion-startup-assembly.js +5 -0
  93. package/dist/esm/core/runtime/companion-startup-assembly.js.map +1 -1
  94. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts +103 -0
  95. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts.map +1 -0
  96. package/dist/esm/core/runtime/dev-compile-quiet.companion.js +124 -0
  97. package/dist/esm/core/runtime/dev-compile-quiet.companion.js.map +1 -0
  98. package/dist/esm/core/runtime/services/start-companion-application.service.d.ts +39 -2
  99. package/dist/esm/core/runtime/services/start-companion-application.service.d.ts.map +1 -1
  100. package/dist/esm/core/runtime/services/start-companion-application.service.js +122 -11
  101. package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
  102. package/dist/esm/core/specifications/non-composite-view-specification-context.shared.d.ts +6 -0
  103. package/dist/esm/core/specifications/non-composite-view-specification-context.shared.d.ts.map +1 -1
  104. package/dist/esm/core/specifications/non-composite-view-specification-context.shared.js.map +1 -1
  105. package/dist/esm/core/specifications/specification-context-factory.shared.d.ts +23 -0
  106. package/dist/esm/core/specifications/specification-context-factory.shared.d.ts.map +1 -1
  107. package/dist/esm/core/specifications/specification-context-factory.shared.js +26 -4
  108. package/dist/esm/core/specifications/specification-context-factory.shared.js.map +1 -1
  109. package/dist/esm/executions/services/companion-executions.companion.service.d.ts +82 -3
  110. package/dist/esm/executions/services/companion-executions.companion.service.d.ts.map +1 -1
  111. package/dist/esm/executions/services/companion-executions.companion.service.js +126 -12
  112. package/dist/esm/executions/services/companion-executions.companion.service.js.map +1 -1
  113. package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.d.ts +12 -0
  114. package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.d.ts.map +1 -0
  115. package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.js +12 -0
  116. package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.js.map +1 -0
  117. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.d.ts +1 -1
  118. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.js +1 -1
  119. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.js.map +1 -1
  120. package/dist/esm/i18n/composite_views/app.creation-board.en.d.ts +13 -0
  121. package/dist/esm/i18n/composite_views/app.creation-board.en.d.ts.map +1 -0
  122. package/dist/esm/i18n/composite_views/app.creation-board.en.js +91 -0
  123. package/dist/esm/i18n/composite_views/app.creation-board.en.js.map +1 -0
  124. package/dist/esm/i18n/composite_views/app.domain-model.en.d.ts +38 -0
  125. package/dist/esm/i18n/composite_views/app.domain-model.en.d.ts.map +1 -0
  126. package/dist/esm/i18n/composite_views/app.domain-model.en.js +41 -0
  127. package/dist/esm/i18n/composite_views/app.domain-model.en.js.map +1 -0
  128. package/dist/esm/i18n/index.d.ts +3 -3
  129. package/dist/esm/i18n/index.js +3 -3
  130. package/dist/esm/i18n/index.js.map +1 -1
  131. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.d.ts +24 -0
  132. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.d.ts.map +1 -0
  133. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.js +20 -0
  134. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.js.map +1 -0
  135. package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.d.ts +31 -0
  136. package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.d.ts.map +1 -0
  137. package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.js +27 -0
  138. package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.js.map +1 -0
  139. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.d.ts +24 -0
  140. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.d.ts.map +1 -0
  141. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.js +20 -0
  142. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.js.map +1 -0
  143. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.d.ts +28 -0
  144. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.d.ts.map +1 -0
  145. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.js +24 -0
  146. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.js.map +1 -0
  147. package/dist/esm/i18n/resources/workbenchDomainResources.en.d.ts +138 -0
  148. package/dist/esm/i18n/resources/workbenchDomainResources.en.d.ts.map +1 -0
  149. package/dist/esm/i18n/resources/workbenchDomainResources.en.js +100 -0
  150. package/dist/esm/i18n/resources/workbenchDomainResources.en.js.map +1 -0
  151. package/dist/esm/i18n/resources/workbenchPlaybooks.en.d.ts +29 -0
  152. package/dist/esm/i18n/resources/workbenchPlaybooks.en.d.ts.map +1 -0
  153. package/dist/esm/i18n/resources/workbenchPlaybooks.en.js +25 -0
  154. package/dist/esm/i18n/resources/workbenchPlaybooks.en.js.map +1 -0
  155. package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.d.ts +27 -0
  156. package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.d.ts.map +1 -0
  157. package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.js +23 -0
  158. package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.js.map +1 -0
  159. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +806 -0
  160. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -0
  161. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +326 -0
  162. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -0
  163. package/dist/esm/i18n/resources/workbenchTraceSessions.en.d.ts +26 -0
  164. package/dist/esm/i18n/resources/workbenchTraceSessions.en.d.ts.map +1 -0
  165. package/dist/esm/i18n/resources/workbenchTraceSessions.en.js +22 -0
  166. package/dist/esm/i18n/resources/workbenchTraceSessions.en.js.map +1 -0
  167. package/dist/esm/i18n/system_enums/market.en.d.ts +202 -0
  168. package/dist/esm/i18n/system_enums/market.en.d.ts.map +1 -0
  169. package/dist/esm/i18n/system_enums/market.en.js +209 -0
  170. package/dist/esm/i18n/system_enums/market.en.js.map +1 -0
  171. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts +112 -2
  172. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts.map +1 -1
  173. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js +201 -34
  174. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js.map +1 -1
  175. package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.d.ts +31 -3
  176. package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.d.ts.map +1 -1
  177. package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.js +48 -12
  178. package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.js.map +1 -1
  179. package/dist/esm/meta-workflows/models/brief-adequacy.actors-system.definitions.d.ts +36 -0
  180. package/dist/esm/meta-workflows/models/brief-adequacy.actors-system.definitions.d.ts.map +1 -0
  181. package/dist/esm/meta-workflows/models/brief-adequacy.actors-system.definitions.js +75 -0
  182. package/dist/esm/meta-workflows/models/brief-adequacy.actors-system.definitions.js.map +1 -0
  183. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +105 -7
  184. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
  185. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +298 -24
  186. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
  187. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts +46 -3
  188. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts.map +1 -1
  189. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js +95 -2
  190. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js.map +1 -1
  191. package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.d.ts +9 -0
  192. package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.d.ts.map +1 -1
  193. package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.js +13 -0
  194. package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.js.map +1 -1
  195. package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.d.ts +12 -0
  196. package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.d.ts.map +1 -1
  197. package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js +23 -0
  198. package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js.map +1 -1
  199. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +120 -3
  200. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts.map +1 -1
  201. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js +636 -81
  202. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
  203. package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.d.ts +40 -0
  204. package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.d.ts.map +1 -1
  205. package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.js +63 -1
  206. package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.js.map +1 -1
  207. package/dist/esm/technical-doc/services/technical-doc.companion.service.d.ts +21 -0
  208. package/dist/esm/technical-doc/services/technical-doc.companion.service.d.ts.map +1 -1
  209. package/dist/esm/technical-doc/services/technical-doc.companion.service.js +86 -2
  210. package/dist/esm/technical-doc/services/technical-doc.companion.service.js.map +1 -1
  211. package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.d.ts +12 -1
  212. package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.d.ts.map +1 -1
  213. package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.js +47 -1
  214. package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.js.map +1 -1
  215. package/package.json +17 -17
  216. package/dist/esm/.builder.pid +0 -9
  217. package/dist/esm/i18n/resources/workbenchApplicationModules.en.d.ts +0 -36
  218. package/dist/esm/i18n/resources/workbenchApplicationModules.en.d.ts.map +0 -1
  219. package/dist/esm/i18n/resources/workbenchApplicationModules.en.js +0 -32
  220. package/dist/esm/i18n/resources/workbenchApplicationModules.en.js.map +0 -1
  221. package/dist/esm/i18n/resources/workbenchResourceRelationships.en.d.ts +0 -29
  222. package/dist/esm/i18n/resources/workbenchResourceRelationships.en.d.ts.map +0 -1
  223. package/dist/esm/i18n/resources/workbenchResourceRelationships.en.js +0 -25
  224. package/dist/esm/i18n/resources/workbenchResourceRelationships.en.js.map +0 -1
@@ -15,15 +15,15 @@ import { z } from 'zod';
15
15
  import { ResearchAgentDispatchCompanionService } from '../../claude-cli/services/research-agent-dispatch.companion.service.js';
16
16
  import * as ApplicationCreationSpecs from '@wildo-ai/saas-specifications/application-creation';
17
17
  import { inject, injectable } from 'inversify';
18
- import { AI_ENGINE_CAPABILITIES, ENGINE_CLIENT_STORAGE_ENTRIES, DataRetentionClass, ErasureRetentionMode, undeclaredAiUseCapabilities, undeclaredRetentionClasses, uninventoriedClientStorageSurfaces, DataProcessingConsent, ProviderDeploymentModel, } from '@wildo-ai/saas-models';
19
- import { ApplicationDocumentFactSpecificationSchema, ApplicationProcessorRegisterSchema, processorRefsNotConfigured, ProcessorRegisterEntryKind, processorProcessingRegions, registerEstablishesNoProcessorRecipients, undeclaredProcessorRefs, MetaWorkflow_ContextSource, MetaWorkflow_Executor, collectComplianceDocumentFactAvailability, } from '@wildo-ai/saas-specifications/application-creation';
18
+ import { AI_ENGINE_CAPABILITIES, ENGINE_CLIENT_STORAGE_ENTRIES, DataRetentionClass, ErasureRetentionMode, undeclaredAiUseCapabilities, undeclaredRetentionClasses, uninventoriedClientStorageSurfaces, BillingConfigurationSchema, outstandingOperatorComplianceIdentityParts, DataProcessingConsent, ProviderDeploymentModel, } from '@wildo-ai/saas-models';
19
+ import { ApplicationAuthoredDocumentFactSpecificationSchema, ApplicationDocumentFactSpecificationSchema, ApplicationProcessorRegisterSchema, processorRefsNotConfigured, ProcessorRegisterEntryKind, processorProcessingRegions, registerEstablishesNoProcessorRecipients, undeclaredProcessorRefs, MetaWorkflow_ContextSource, MetaWorkflow_Executor, collectComplianceDocumentFactAvailability, } from '@wildo-ai/saas-specifications/application-creation';
20
20
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
21
21
  import * as path from 'node:path';
22
22
  import { join } from 'node:path';
23
23
  import { loadPackageCompanionExport } from '@wildo-ai/platform-config-lib';
24
24
  import { getFrameworkKnowledgePlaybook, listFrameworkKnowledgePlaybooks, listFrameworkKnowledgeSkillSummaries } from '@wildo-ai/framework-knowledge';
25
25
  import { MetaWorkflow_EvaluationTreatmentDefinitionSchema } from '@wildo-ai/saas-models/meta-workflows';
26
- import { APPLICATION_SPECIFICATION_SEMANTIC_SCHEMA_BINDINGS, composeElicitationSection, BUILD_DECOMPOSE_INPUT_FAMILIES, STANDARD_APPLICATION_SPECIFICATION_SEMANTIC_AUTHORITY, evaluatePlaybookCatalogEligibility, buildApplicationCoherenceReport, composeAssuranceDocumentBlueprintBrief, composeAssuranceDocumentFactObligationsBrief, deriveOneFamilyFreshness, resolveStepOutputSchema, runPlaybookChoreography, buildPlaybookReviewGuide, evaluatePlaybookEligibility, getFamilyPackageRelativePath, getLandableArtifactFamilies, isPlaybookGenerationSuspension, renderApplicationCoherenceReport, renderInputFamilyContext, renderPlaybookReviewGuide, runPlaybookGeneration, DEFAULT_MAXIMUM_CLARIFICATION_ROUNDS, PlaybookClarificationAction, accumulateClarificationRequests, composeClarificationAnswersSection, runPlaybookJudge, runPlaybookLoop, } from '@wildo-ai/application-creation-runtime';
26
+ import { APPLICATION_SPECIFICATION_SEMANTIC_SCHEMA_BINDINGS, composeElicitationSection, BUILD_DECOMPOSE_INPUT_FAMILIES, STANDARD_APPLICATION_SPECIFICATION_SEMANTIC_AUTHORITY, evaluatePlaybookCatalogEligibility, buildApplicationCoherenceReport, composeAssuranceDocumentBlueprintBrief, composeAssuranceDocumentFactObligationsBrief, composeAssuranceProgramAuthorityBrief, deriveOneFamilyFreshness, resolveStepOutputSchema, runPlaybookChoreography, buildPlaybookReviewGuide, evaluatePlaybookEligibility, getFamilyPackageRelativePath, getLandableArtifactFamilies, isPlaybookGenerationSuspension, renderApplicationCoherenceReport, renderInputFamilyContext, renderPlaybookReviewGuide, runPlaybookGeneration, DEFAULT_MAXIMUM_CLARIFICATION_ROUNDS, PlaybookClarificationAction, accumulateClarificationRequests, composeClarificationAnswersSection, runPlaybookJudge, runPlaybookLoop, composeBillingCommercialModelBrief, composeOperatingJurisdictionCoverageBrief, } from '@wildo-ai/application-creation-runtime';
27
27
  import { SAAS_SERVICE_TYPES } from '@wildo-ai/saas-backend-lib';
28
28
  import { JourneyArtifactValidationState, MetaWorkflowPlaybookSchema } from '@wildo-ai/saas-specifications/application-creation';
29
29
  import { StructuredDeliberationCompanionService } from '../../deliberations/services/structured-deliberation.companion.service.js';
@@ -34,12 +34,15 @@ import { ApplicationBuildDispatchCompanionService } from './application-build-di
34
34
  import { GitChangeSetCompanionService } from '../../claude-cli/services/git-change-set.companion.service.js';
35
35
  import { CompanionIntrospectionService } from '../../core/introspection/services/companion-introspection.companion.service.js';
36
36
  import { FoundationExecutorCompanionService } from './foundation-executor.companion.service.js';
37
+ import { CodingAgentDispatchCompanionService } from '../../claude-cli/services/coding-agent-dispatch.companion.service.js';
37
38
  import { PlaybookChoreographyCheckpointCompanionService } from './playbook-choreography-checkpoint.companion.service.js';
38
39
  import { PlaybookSuspendedRunCompanionService } from './playbook-suspended-run.companion.service.js';
39
40
  import { CompanionTraceabilityService } from '../../core/traceability/companion-traceability.service.js';
40
41
  import { createPlaybookExecutionTrace } from './playbook-execution-trace.companion.service.js';
41
- import { loadSpecificationsCompanionExports } from '../../core/context/companion-package-loaders.companion.js';
42
+ import { loadBackendCompanionExports, loadSpecificationsCompanionExports } from '../../core/context/companion-package-loaders.companion.js';
43
+ import { choreographyEndedByEnvironment, isInfrastructureShapedAgentFailure, waitForDevCompileQuiet, } from '../../core/runtime/dev-compile-quiet.companion.js';
42
44
  import { META_WORKFLOWS_STRUCTURED_ARTIFACT_GENERATOR_AGENT_REF, META_WORKFLOW_TRACE_STEP_KIND } from '../models/meta-workflows-lane.models.js';
45
+ import { BRIEF_ADEQUACY_JUDGE_AGENT_REF, BriefAdequacyVerdictOutputSchema } from '../models/brief-adequacy.actors-system.definitions.js';
43
46
  /**
44
47
  * Run one compiled playbook: brief the model against the family's own schema, then land the answer as
45
48
  * specification FILES in the application's specifications package.
@@ -86,6 +89,34 @@ const FILE_ONLY_ARTIFACT_FAMILIES = Object.freeze(['domain-plan', 'build-plan'])
86
89
  function playbookDeclaresContextSource(playbook, source) {
87
90
  return (playbook?.method?.contextSources ?? []).includes(source);
88
91
  }
92
+ /**
93
+ * The application-wide verification a `DETERMINISTIC_CLI` playbook runs, per playbook ref.
94
+ *
95
+ * The HOST owns the mapping, not the playbook, and that is the same rule
96
+ * `APPLICATION_CODING_TASK_VERIFICATION_CATALOG` already states for coding tasks: *"a task contract
97
+ * names semantic check references, not commands. Translating a new ref into executable process
98
+ * arguments is application-host work that must be reviewed here."* A playbook naming its own
99
+ * commands would be an authored surface that can spawn a process, which is a much larger admission
100
+ * than this tier needs.
101
+ *
102
+ * An unmapped ref is REFUSED rather than defaulted. A default check set would make a new
103
+ * `DETERMINISTIC_CLI` playbook silently verify something nobody chose — which is the exact shape of
104
+ * the defect #119 closed, where an unhonoured tier fell through and produced a result the
105
+ * declaration never asked for.
106
+ *
107
+ * Why these four checks: topic 7 asks whether the built application ASSEMBLES, so the unit is the
108
+ * application's four workspace packages, not the one package a coding task happened to touch. The
109
+ * dispatch lane already typechecks the mutated package per task; this is the whole-app question that
110
+ * no per-task check can answer, which is why it is not a duplicate of a live check.
111
+ */
112
+ const DETERMINISTIC_CLI_VERIFICATION_CHECKS = {
113
+ 'bottom_up.assemble-verify': [
114
+ 'check:specifications-typecheck',
115
+ 'check:shared-lib-typecheck',
116
+ 'check:backend-api-typecheck',
117
+ 'check:app-typecheck',
118
+ ],
119
+ };
89
120
  /** The zero-output playbook the composite foundation executor owns (J-2 item 2). */
90
121
  const FOUNDATION_PLAYBOOK_REF = 'bottom_up.foundation';
91
122
  /** Marker for "the file is there, its value is not readable from here". Never confused with real content. */
@@ -102,6 +133,29 @@ const DRAFTABLE_DOCUMENT_DEFINITION_REFS = Object.freeze([
102
133
  'document-definition:public.privacy-notice',
103
134
  'document-definition:public.service-terms',
104
135
  ]);
136
+ /**
137
+ * The documents whose FACTS the producer is briefed on — a wider set than the ones the lane may draft.
138
+ *
139
+ * Declaring a fact and drafting a document are different acts with different costs. The drafting brief ships a document's sections, clauses and inclusion kinds; adding
140
+ * the four governance documents there would be ~42KB of obligations for documents this lane does not produce, and a prompt section that gets skimmed is
141
+ * indistinguishable from an absent one. The FACT brief ships names and authority kinds, which is a few lines each.
142
+ *
143
+ * TWO of the four governance documents are included, and only those two: `scope-system-description` and `program-handbook` are the ones carrying
144
+ * `APPLICATION_SPECIFICATION` facts — `governance-system-boundaries`, `governance-entities-products-environments`, `governance-dependencies-responsibilities` and
145
+ * `governance-scope-boundaries`. `roles-responsibilities` and `document-record-control` carry none: every one of their ten facts needs a creator decision or a
146
+ * qualified review, so briefing them would add ten "do not declare" lines about documents with nothing to declare.
147
+ *
148
+ * Withholding the two meant the only facts a governance document could ever have were the sixteen a human must write, so it could not be partially answered at all
149
+ * (#186).
150
+ *
151
+ * The other sixteen are rendered in the same brief as facts the producer must NOT declare, with the authority each needs. That is the whole reason it is safe to widen
152
+ * this list: the brief now distinguishes the two halves rather than asking for everything (#217).
153
+ */
154
+ const FACT_OBLIGATION_DOCUMENT_DEFINITION_REFS = Object.freeze([
155
+ ...DRAFTABLE_DOCUMENT_DEFINITION_REFS,
156
+ 'document-definition:governance.scope-system-description',
157
+ 'document-definition:governance.program-handbook',
158
+ ]);
105
159
  const FILE_PRESENT_WITHOUT_VALUE = Object.freeze({ __artifactPresentWithoutValue: true });
106
160
  /**
107
161
  * The map the coherence report reads: accepted families PLUS landed drafts.
@@ -194,9 +248,29 @@ function renderRetentionSchedule(schedule) {
194
248
  * register but no longer configured is reported too — a stale entry keeps a recipient in the notice
195
249
  * that receives nothing, which is the quieter of the two errors.
196
250
  */
197
- function renderProcessorRegister(configuredProviderRefs, register) {
198
- const undeclared = undeclaredProcessorRefs(configuredProviderRefs, register);
199
- const stale = processorRefsNotConfigured(configuredProviderRefs, register);
251
+ function renderProcessorRegister(configuredProviderRefs, register, choices) {
252
+ /*
253
+ * A provider the operator declared SELF_HOSTED is not a recipient, so it cannot be an outstanding
254
+ * DISCLOSURE either — and until this filter existed it was reported as one.
255
+ *
256
+ * `renderProviderComplianceChoices` above already draws exactly this line ("the deployment model is
257
+ * the axis that decides whether a bound provider is a RECIPIENT at all"), and
258
+ * `vendorHostedProviderRefs` exists so a caller need not remember it. The two renderers sat in ONE
259
+ * section disagreeing: one said a self-hosted provider is operator-run, the other listed it as an
260
+ * identity nobody had established. Measured on wonder-crm's `email-preview`, which renders mail to a
261
+ * log and calls no API — the notice reported an outstanding disclosure about a provider that
262
+ * discloses nothing (wildo-ai/wildo-ai#208).
263
+ *
264
+ * A provider with NO choice STAYS in scope, deliberately. Absence means nobody has answered, which is
265
+ * exactly the gap this section exists to report; assuming self-hosted would silence it, and assuming
266
+ * vendor-hosted would publish a third party nobody declared. Only an explicit SELF_HOSTED excludes.
267
+ */
268
+ const operatorRunRefs = new Set(Object.entries(choices ?? {})
269
+ .filter(([, choice]) => choice.deploymentModel === ProviderDeploymentModel.SELF_HOSTED)
270
+ .map(([providerRef]) => providerRef));
271
+ const recipientCandidateRefs = configuredProviderRefs.filter((providerRef) => !operatorRunRefs.has(providerRef));
272
+ const undeclared = undeclaredProcessorRefs(recipientCandidateRefs, register);
273
+ const stale = processorRefsNotConfigured(recipientCandidateRefs, register);
200
274
  const declared = register?.processors ?? [];
201
275
  return [
202
276
  '## Who else processes personal data',
@@ -448,20 +522,66 @@ function renderOperatorComplianceIdentity(identity) {
448
522
  'an address or a contact — those are what a subject uses to exercise a right against a real company.',
449
523
  ];
450
524
  }
525
+ /*
526
+ * Every part is now independently declarable (#228), so this renders PART BY PART rather than
527
+ * assuming a complete identity. An outstanding part is named, with the configuration key that closes
528
+ * it — a drafter that cannot see what is missing has no way to mark the gap, and marking it is the
529
+ * behaviour the whole lane depends on.
530
+ */
531
+ const outstanding = outstandingOperatorComplianceIdentityParts(identity);
451
532
  return [
452
533
  '',
453
- `Operator: ${identity.legalEntityName}, registered at ${identity.registeredAddress}.`,
454
- `Privacy contact: ${identity.privacyContact}.`,
534
+ identity.legalEntityName === undefined
535
+ ? 'Operator legal entity: OUTSTANDING — not declared in `operatorComplianceIdentity.legalEntityName`. Do NOT invent one.'
536
+ : `Operator: ${identity.legalEntityName}.`,
537
+ identity.registeredAddress === undefined
538
+ ? 'Registered address: OUTSTANDING — `operatorComplianceIdentity.registeredAddress`. Do NOT invent one; it is what a subject uses to serve a request on a real company.'
539
+ : `Registered at ${identity.registeredAddress}.`,
540
+ identity.privacyContact === undefined
541
+ ? 'Privacy contact route: OUTSTANDING — `operatorComplianceIdentity.privacyContact`. Do NOT invent one; a route that does not exist is worse than a stated gap.'
542
+ : `Privacy contact: ${identity.privacyContact}.`,
455
543
  ...(identity.representative === undefined
456
- ? ['No Art. 27 representative is declared, which means one is not required — not that the question was skipped.']
544
+ /*
545
+ * The "absent means not required" reading holds only on a COMPLETE identity. On a partial one it
546
+ * cannot be told apart from a part nobody reached yet, and asserting the stronger sentence there
547
+ * would put an unsupported claim about Art. 27 into the drafter's context.
548
+ */
549
+ ? outstanding.length === 0
550
+ ? ['No Art. 27 representative is declared, which means one is not required — not that the question was skipped.']
551
+ : ['No Art. 27 representative is declared. On a partially declared identity that cannot be read as "not required" — it is simply unanswered.']
457
552
  : [`Art. 27 representative: ${identity.representative.name}, ${identity.representative.address}.`]),
458
553
  '',
459
- 'Role, per population of data — there may be SEVERAL, and a notice must not collapse them into one:',
460
- ...identity.roleAllocations.map((allocation) => ` - ${allocation.role} for ${allocation.dataScope}`),
554
+ ...(identity.roleAllocations === undefined
555
+ ? [
556
+ 'Role per population of data: OUTSTANDING — `operatorComplianceIdentity.roleAllocations`. Do NOT assign the',
557
+ 'operator a single role by default: controller and processor carry different obligations, and a product is',
558
+ 'commonly both at once over different populations.',
559
+ ]
560
+ : [
561
+ 'Role, per population of data — there may be SEVERAL, and a notice must not collapse them into one:',
562
+ ...identity.roleAllocations.map((allocation) => ` - ${allocation.role} for ${allocation.dataScope}`),
563
+ ]),
461
564
  '',
462
- 'Lawful basis, per purpose:',
463
- ...identity.lawfulBases.map((entry) => ` - ${entry.basis} for ${entry.purpose}`
464
- + (entry.assessmentNote === undefined ? '' : ` — assessment: ${entry.assessmentNote}`)),
565
+ ...(identity.lawfulBases === undefined
566
+ ? [
567
+ 'Lawful basis per purpose: OUTSTANDING — `operatorComplianceIdentity.lawfulBases`. This is a legal',
568
+ 'determination, not a drafting choice. State it as unestablished; do NOT select a basis because one',
569
+ 'sounds plausible, and in particular do not write CONSENT, which would tell a person their data is',
570
+ 'processed on an agreement they could withdraw.',
571
+ ]
572
+ : [
573
+ 'Lawful basis, per purpose:',
574
+ ...identity.lawfulBases.map((entry) => ` - ${entry.basis} for ${entry.purpose}`
575
+ + (entry.assessmentNote === undefined ? '' : ` — assessment: ${entry.assessmentNote}`)),
576
+ ]),
577
+ ...(outstanding.length === 0
578
+ ? []
579
+ : [
580
+ '',
581
+ `${outstanding.length} of 5 identity part(s) outstanding: ${outstanding.join(', ')}. The identity is PARTIALLY`,
582
+ 'declared — state each outstanding part as an open gap in the document rather than omitting it. A document',
583
+ 'that silently leaves them out reads as though the operator answered.',
584
+ ]),
465
585
  ];
466
586
  }
467
587
  function renderClientStorage(frontendSurfaceKeys, inventory) {
@@ -500,6 +620,7 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
500
620
  traceability;
501
621
  writeRegister;
502
622
  buildDispatch;
623
+ codingAgentDispatch;
503
624
  git;
504
625
  introspection;
505
626
  foundationExecutor;
@@ -507,7 +628,7 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
507
628
  choreographyCheckpoints;
508
629
  structuredDeliberation;
509
630
  logDebug;
510
- constructor(logger, companionContext, researchDispatch, agents, traceability, writeRegister, buildDispatch, git, introspection, foundationExecutor, suspendedRuns, choreographyCheckpoints, structuredDeliberation) {
631
+ constructor(logger, companionContext, researchDispatch, agents, traceability, writeRegister, buildDispatch, codingAgentDispatch, git, introspection, foundationExecutor, suspendedRuns, choreographyCheckpoints, structuredDeliberation) {
511
632
  this.logger = logger;
512
633
  this.companionContext = companionContext;
513
634
  this.researchDispatch = researchDispatch;
@@ -515,6 +636,7 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
515
636
  this.traceability = traceability;
516
637
  this.writeRegister = writeRegister;
517
638
  this.buildDispatch = buildDispatch;
639
+ this.codingAgentDispatch = codingAgentDispatch;
518
640
  this.git = git;
519
641
  this.introspection = introspection;
520
642
  this.foundationExecutor = foundationExecutor;
@@ -599,8 +721,24 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
599
721
  * withheld on a phase gate its parent had already been admitted past.
600
722
  */
601
723
  proceedPastSequencing: true,
602
- runChild: (playbookRef, objective, stepResults) => this.runChoreographyChild({ playbookRef, objective, stepResults, ...(input.session ? { session: input.session } : {}) }),
603
- select: { select: (request) => this.selectChoreographyChildren({ ...request, composite: input.playbook }) },
724
+ runChild: (playbookRef, objective, stepResults) => this.runChoreographyChild({
725
+ playbookRef,
726
+ objective,
727
+ stepResults,
728
+ ...(input.parentElicitationSection ? { parentElicitationSection: input.parentElicitationSection } : {}),
729
+ // The COMPOSITE names the investigation: every research child of every run of this
730
+ // composite consolidates into one evidence-store directory, which is what makes a
731
+ // relaunch start from what earlier runs already established.
732
+ evidenceScope: input.playbook.ref,
733
+ ...(input.session ? { session: input.session } : {}),
734
+ }),
735
+ select: {
736
+ select: (request) => this.selectChoreographyChildren({
737
+ ...request,
738
+ composite: input.playbook,
739
+ ...(input.parentElicitationSection ? { parentElicitationSection: input.parentElicitationSection } : {}),
740
+ }),
741
+ },
604
742
  ...(input.session ? { trace: this.buildTrace(input.session, 'playbook-choreography') } : {}),
605
743
  });
606
744
  /*
@@ -608,11 +746,30 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
608
746
  * and must go. Keeping it would make the next run of this composite resume a finished one, which
609
747
  * is the failure mode a resume cache has instead of the one it replaced.
610
748
  *
611
- * Deliberately unconditional on the stop reason: a run that stopped at its iteration ceiling, or
612
- * because every child failed, has still CONCLUDED. What the checkpoint exists for is the case
613
- * where no conclusion was reached at all, because the process was taken away mid-iteration.
749
+ * ONE exception, and it is measured rather than hypothetical: a conclusion the ENVIRONMENT
750
+ * forced. When ALL_CHILDREN_FAILED and every fatal child was taken by infrastructure or quota
751
+ * (a companion pause, a 529 storm outliving the retry, "You've hit your session limit"), the
752
+ * children never met the work — that is the process-taken-away case the checkpoint exists for,
753
+ * arriving as child failures instead of a SIGTERM. On 2026-09-03 the unconditional consume here
754
+ * discarded a 56-minute compliance run's 10 iterations of accumulated evidence because its 11th
755
+ * iteration hit the provider's 5-hour session limit. The checkpoint survives that shape now, and
756
+ * re-running the composite resumes it — the same gesture as after a companion restart.
757
+ *
758
+ * Still unconditional for every SEMANTIC conclusion: an iteration ceiling, a chosen stop, or a
759
+ * fatal iteration containing even one real (non-environmental) failure, because there the next
760
+ * selection would see genuine information and must not inherit a finished run's state.
614
761
  */
615
- await this.choreographyCheckpoints.consume(input.playbook.ref);
762
+ const endedByEnvironment = choreographyEndedByEnvironment(result);
763
+ if (endedByEnvironment) {
764
+ this.logDebug('Choreography ended by environment; preserving its checkpoint for relaunch', {
765
+ playbookRef: input.playbook.ref,
766
+ completedIterations: result.iterations.length,
767
+ fatalFailures: result.iterations[result.iterations.length - 1]?.children.map((child) => child.failure?.slice(0, 160)),
768
+ });
769
+ }
770
+ else {
771
+ await this.choreographyCheckpoints.consume(input.playbook.ref);
772
+ }
616
773
  return {
617
774
  playbookRef: input.playbook.ref,
618
775
  choreographed: true,
@@ -629,6 +786,11 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
629
786
  ...(resumeFrom
630
787
  ? { resumedFrom: { completedIterations: resumeFrom.completedIterations, checkpointedAt: resumeFrom.checkpointedAt } }
631
788
  : {}),
789
+ /*
790
+ * Reported so the caller can SAY "re-run this ref to resume" instead of reading a failed run
791
+ * as a dead end — the whole point of preserving the checkpoint is that somebody relaunches.
792
+ */
793
+ ...(endedByEnvironment ? { resumableFromCheckpoint: true } : {}),
632
794
  // No acceptance, exactly as an ordinary run reports none: files landed as working edits and a
633
795
  // human commit is the only acceptance there has ever been.
634
796
  accepted: false,
@@ -660,18 +822,53 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
660
822
  if (!stepOutput) {
661
823
  throw new Error(`Research child "${child.ref}" declares no stepOutput; its evidence would have nowhere to go.`);
662
824
  }
663
- const research = await this.researchDispatch.runResearchTask({
664
- objective: [
665
- child.method?.guidance ?? '',
666
- '',
667
- '# Your objective for THIS round',
668
- input.objective,
669
- '',
670
- '# What to return',
671
- stepOutput.condensation,
672
- ].join('\n'),
673
- });
674
- return { stepResults: new Map([[stepOutput.ref, research.evidence]]) };
825
+ const researchObjective = [
826
+ child.method?.guidance ?? '',
827
+ '',
828
+ '# Your objective for THIS round',
829
+ input.objective,
830
+ // The creator's facts, verbatim: research that knows the real jurisdictions, data classes
831
+ // and commitments verifies triggers against THIS product instead of surveying the field.
832
+ ...(input.parentElicitationSection ? ['', input.parentElicitationSection] : []),
833
+ '',
834
+ '# What to return',
835
+ stepOutput.condensation,
836
+ ].join('\n');
837
+ /*
838
+ * The churn gate + one classified retry (#265, smallest shape). A research turn is READ-ONLY
839
+ * and its result is regenerable, which is what makes ONE retry safe here and why the coding
840
+ * lane gets the gate but never the retry. Two measured failure families qualify — the exit-0
841
+ * mid-turn kill under a companion pause, and the provider's transient overload — and nothing
842
+ * else does: an agent's own outcome retried is spend, not resilience.
843
+ */
844
+ const frameworkRoot = this.companionContext.resolvedHomes.framework.repositoryRoot;
845
+ const logGate = (message, context) => this.logDebug(message, { playbookRef: child.ref, ...context });
846
+ await waitForDevCompileQuiet({ frameworkRepositoryRoot: frameworkRoot, log: logGate });
847
+ try {
848
+ const research = await this.researchDispatch.runResearchTask({
849
+ objective: researchObjective,
850
+ ...(input.evidenceScope ? { evidenceScope: input.evidenceScope } : {}),
851
+ playbookRef: child.ref,
852
+ });
853
+ return { stepResults: new Map([[stepOutput.ref, research.evidence]]) };
854
+ }
855
+ catch (error) {
856
+ const message = error instanceof Error ? error.message : String(error);
857
+ if (!isInfrastructureShapedAgentFailure(message))
858
+ throw error;
859
+ this.logger.warn('Research turn lost to infrastructure; retrying once', { playbookRef: child.ref, failure: message.slice(0, 200) });
860
+ // Overload answers deserve real backoff; a churn kill only needs the tree quiet again.
861
+ if (/529|429|Overloaded|overloaded_error|rate.?limit/i.test(message)) {
862
+ await new Promise((resolve) => setTimeout(resolve, 60_000));
863
+ }
864
+ await waitForDevCompileQuiet({ frameworkRepositoryRoot: frameworkRoot, log: logGate });
865
+ const research = await this.researchDispatch.runResearchTask({
866
+ objective: researchObjective,
867
+ ...(input.evidenceScope ? { evidenceScope: input.evidenceScope } : {}),
868
+ playbookRef: child.ref,
869
+ });
870
+ return { stepResults: new Map([[stepOutput.ref, research.evidence]]) };
871
+ }
675
872
  }
676
873
  /*
677
874
  * A CODING_AGENT child cannot ALSO produce a step value, and saying so beats routing it silently.
@@ -692,13 +889,20 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
692
889
  }
693
890
  if ((child.stepOutputs?.length ?? 0) > 0) {
694
891
  const stepOutput = child.stepOutputs[0];
695
- const value = await this.generateChoreographyStepValue({ child, stepOutput, objective: input.objective, stepResults: input.stepResults });
892
+ const value = await this.generateChoreographyStepValue({
893
+ child,
894
+ stepOutput,
895
+ objective: input.objective,
896
+ stepResults: input.stepResults,
897
+ ...(input.parentElicitationSection ? { parentElicitationSection: input.parentElicitationSection } : {}),
898
+ });
696
899
  return { stepResults: new Map([[stepOutput.ref, value]]) };
697
900
  }
698
901
  const run = await this.runPlaybook({
699
902
  playbookRef: input.playbookRef,
700
903
  creatorBrief: input.objective,
701
904
  stepResults: input.stepResults,
905
+ ...(input.parentElicitationSection ? { parentElicitationSection: input.parentElicitationSection } : {}),
702
906
  ...(input.session ? { session: input.session } : {}),
703
907
  });
704
908
  /*
@@ -735,6 +939,9 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
735
939
  '',
736
940
  '# Your objective for THIS round',
737
941
  input.objective,
942
+ // The creator's facts, for the judge that needs them: adequacy against evidence WITHOUT the
943
+ // product facts converges on honest-INSUFFICIENT forever (#284's deadlock, measured run 4).
944
+ ...(input.parentElicitationSection ? ['', input.parentElicitationSection] : []),
738
945
  '',
739
946
  '# What you are judging',
740
947
  /*
@@ -805,6 +1012,10 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
805
1012
  '# Decide what this composite does next',
806
1013
  `Goal: ${request.goal}`,
807
1014
  ...(inputTruth ? ['', inputTruth] : []),
1015
+ // The creator's answers rank WITH the declared inputs: round-1 research aimed at the real
1016
+ // jurisdictions and telemetry beats a general survey the facts then invalidate (run 4's whole
1017
+ // first round was that survey).
1018
+ ...(request.parentElicitationSection ? ['', request.parentElicitationSection] : []),
808
1019
  '',
809
1020
  '# What you may choose from',
810
1021
  'These are the ONLY options, computed from what has already happened rather than proposed by you.',
@@ -872,11 +1083,24 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
872
1083
  const treatment = input.hydrated.evaluationTreatment
873
1084
  ? MetaWorkflow_EvaluationTreatmentDefinitionSchema.safeParse(input.hydrated.evaluationTreatment.value)
874
1085
  : undefined;
1086
+ /*
1087
+ * The DECLARED derived sections, delivered to the path that actually runs this playbook.
1088
+ *
1089
+ * `composeCoherenceSection` gates on the playbook's `contextSources` declaration and was only ever
1090
+ * called from `composeBrief` — the GENERATION path. An assessing playbook (`outputs: []`) never
1091
+ * takes that path, so `top_down.phase-gate` — the sole declarer of `coherence_report`, the playbook
1092
+ * the section EXISTS for — judged six families with the arithmetic it declared composed one branch
1093
+ * over and delivered to nobody (the promise-vs-delivery class, #259; found by its own sweep,
1094
+ * 2026-09-02). Best-effort like the section itself: an unbuildable report must not cost the gate
1095
+ * its run.
1096
+ */
1097
+ const coherenceSection = this.composeCoherenceSection(input.playbook, input.artifactState);
875
1098
  if (treatment?.success) {
876
1099
  judge = await runPlaybookJudge({
877
1100
  playbookRef: input.playbookRef,
878
1101
  treatment: treatment.data,
879
1102
  landed: subjects,
1103
+ ...(coherenceSection !== '' ? { derivedContext: [coherenceSection] } : {}),
880
1104
  model: this.buildGenerationPort(),
881
1105
  ...(input.session ? { trace: this.buildTrace(input.session, `playbook-assess-${input.playbookRef}`) } : {}),
882
1106
  });
@@ -1057,14 +1281,32 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
1057
1281
  }
1058
1282
  return parsed.data;
1059
1283
  }
1284
+ /**
1285
+ * BOTH fact families (#192).
1286
+ *
1287
+ * A document asserts the FACT, not one family's declaration of it, so reading only the derived half
1288
+ * would refuse every clause resting on a fact a human established. Each half is optional and parsed
1289
+ * independently: one unreadable file must not erase the other's facts, because that would turn a
1290
+ * wiring failure into a content verdict
1291
+ * (`.claude/rules/negative-results-require-a-positive-probe.md`).
1292
+ *
1293
+ * Returns nothing when NEITHER is readable — an empty availability map means "check against nothing"
1294
+ * and refuses every citation, which is the wrong answer for an application that has simply not run
1295
+ * `refinement.document-facts`.
1296
+ */
1060
1297
  resolveDeclaredDocumentFacts(artifactState) {
1061
- const value = artifactState.artifactsByFamily.get('document-facts');
1062
- if (value === undefined || value === FILE_PRESENT_WITHOUT_VALUE)
1063
- return {};
1064
- const parsed = ApplicationDocumentFactSpecificationSchema.safeParse(value);
1065
- if (!parsed.success)
1298
+ const readFamily = (family, schema) => {
1299
+ const value = artifactState.artifactsByFamily.get(family);
1300
+ if (value === undefined || value === FILE_PRESENT_WITHOUT_VALUE)
1301
+ return undefined;
1302
+ const parsed = schema.safeParse(value);
1303
+ return parsed.success ? parsed.data : undefined;
1304
+ };
1305
+ const derived = readFamily('document-facts', ApplicationDocumentFactSpecificationSchema);
1306
+ const authored = readFamily('document-facts-authored', ApplicationAuthoredDocumentFactSpecificationSchema);
1307
+ if (derived === undefined && authored === undefined)
1066
1308
  return {};
1067
- return { declaredDocumentFacts: collectComplianceDocumentFactAvailability(parsed.data) };
1309
+ return { declaredDocumentFacts: collectComplianceDocumentFactAvailability(derived, authored) };
1068
1310
  }
1069
1311
  /**
1070
1312
  * Refresh `src/COHERENCE.md` from the tree this run produced.
@@ -1168,7 +1410,23 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
1168
1410
  // — measured, because the bare and `/index` forms both fail to resolve.
1169
1411
  const subpath = `./${path.basename(path.dirname(packageRelativePath))}`;
1170
1412
  try {
1171
- const moduleExports = await loadPackageCompanionExport(specificationsPackageRoot, subpath);
1413
+ /*
1414
+ * `freshModuleCache` is REQUIRED here, and its absence was issue #170.
1415
+ *
1416
+ * jiti's module cache is process-global, so in the long-lived companion a draft family
1417
+ * imported once stays frozen at that evaluation for the process lifetime. The accepted
1418
+ * families beside it are read through `loadSpecificationsCompanionExports`, which does pass
1419
+ * it — so a run that lands a draft produced a report comparing a STALE draft against FRESH
1420
+ * declarations. Measured on wonder-crm: 17 phantom
1421
+ * `compliance-document-cites-undeclared-fact` findings against a document that was actually
1422
+ * coherent, on an endpoint whose own heading claims to describe "the CURRENT working tree".
1423
+ *
1424
+ * Worst exactly when it matters most — immediately after a run lands files, which is when
1425
+ * someone asks for a coherence report.
1426
+ */
1427
+ const moduleExports = await loadPackageCompanionExport(specificationsPackageRoot, subpath, {
1428
+ freshModuleCache: true,
1429
+ });
1172
1430
  // A landed family module exports exactly one constant, named by the landing profile's
1173
1431
  // `constantSuffix`. Taking the sole export keeps this from restating that naming rule.
1174
1432
  const values = Object.values(moduleExports ?? {}).filter((value) => value !== undefined && value !== null);
@@ -1319,7 +1577,10 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
1319
1577
  // reason than theirs: not "nothing happened", but "what happened is not a family landing",
1320
1578
  // and the loop's eligibility gate reads families. Its progress is visible through
1321
1579
  // `resolveBuildExecutionProgress`, which counts landed TASKS.
1322
- if ('scenarios' in result || 'status' in result || 'assessed' in result || 'dispatched' in result)
1580
+ // `verified` joins them for the same reason: a DETERMINISTIC_CLI run answers a question about
1581
+ // the built application and lands no family, so an empty landed set is truthful.
1582
+ if ('scenarios' in result || 'status' in result || 'assessed' in result || 'dispatched' in result
1583
+ || 'verified' in result)
1323
1584
  return { landed: [] };
1324
1585
  return { landed: result.landed.map((entry) => entry.packageRelativePath) };
1325
1586
  },
@@ -1503,7 +1764,19 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
1503
1764
  * is not a choreography at all; branching on it would make two unrelated things one code path.
1504
1765
  */
1505
1766
  if (playbook.method?.choreography) {
1506
- return this.runChoreography({ playbook, ...(input.session ? { session: input.session } : {}) });
1767
+ /*
1768
+ * The umbrella's rendered elicitation travels into the run (#284 shape (a)): the questions are
1769
+ * declared on the COMPOSITE (validated just above, so an unanswered launch was already refused),
1770
+ * and the answers are the product facts every child derives from. Rendered ONCE here — children
1771
+ * must not re-validate parent answers against their own (empty) vocabularies, so what travels is
1772
+ * the section, not the raw answers. Channel-agnostic on purpose: this is "the run's elicitation
1773
+ * state", so answers arriving through a future mid-run workbench resume ride the same path.
1774
+ */
1775
+ return this.runChoreography({
1776
+ playbook,
1777
+ ...(elicitationSection ? { parentElicitationSection: elicitationSection } : {}),
1778
+ ...(input.session ? { session: input.session } : {}),
1779
+ });
1507
1780
  }
1508
1781
  /*
1509
1782
  * The CODING_AGENT tier (issue #119).
@@ -1573,7 +1846,66 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
1573
1846
  * none of those. `DETERMINISTIC_CLI` needs a registry of runnable commands, which does not
1574
1847
  * exist. Both are decisions for whoever authors the first playbook that needs one.
1575
1848
  */
1576
- if (playbook.executor === MetaWorkflow_Executor.HUMAN || playbook.executor === MetaWorkflow_Executor.DETERMINISTIC_CLI) {
1849
+ /*
1850
+ * The DETERMINISTIC_CLI tier (issues #147, #119).
1851
+ *
1852
+ * Topic 7 — "does the built application assemble and pass its own checks?" — had no producer:
1853
+ * `bottom_up.assemble-verify` was deleted on 2026-08-25 with the digest demolition, and the
1854
+ * question it asked went with it even though the answer needs no digests. Verification also
1855
+ * cannot be a build-plan task: `BuildPlanTaskTargetKind` has no member for it, so the decomposer
1856
+ * is structurally right to emit none. It has to be a playbook that RUNS COMMANDS.
1857
+ *
1858
+ * Keyed on the EXECUTOR, like CODING_AGENT above: any playbook declaring this tier is asking for
1859
+ * the same mechanism. The CHECK SET is host-owned and per-ref (see the constant), because
1860
+ * translating a semantic check ref into argv is reviewed host work.
1861
+ *
1862
+ * A DRY RUN resolves the checks and runs NOTHING. Not because verification mutates the
1863
+ * application — it does not — but because `tsc` writes `.tsbuildinfo`, so a dry run that executed
1864
+ * it would write, and `dryRun` is documented to the operator as "the full pipe ran and NOTHING
1865
+ * was written". Reporting the resolved set keeps the flag honest and cheap.
1866
+ */
1867
+ if (playbook.executor === MetaWorkflow_Executor.DETERMINISTIC_CLI) {
1868
+ const checkRefs = DETERMINISTIC_CLI_VERIFICATION_CHECKS[input.playbookRef];
1869
+ if (!checkRefs) {
1870
+ throw new PlaybookNotReadyError(`"${input.playbookRef}" declares executor ${MetaWorkflow_Executor.DETERMINISTIC_CLI} but no verification `
1871
+ + 'check set is registered for it. Translating a check ref into a runnable command is reviewed host '
1872
+ + 'work — add the ref to DETERMINISTIC_CLI_VERIFICATION_CHECKS rather than letting it verify a '
1873
+ + 'default nobody chose.');
1874
+ }
1875
+ if (input.dryRun === true) {
1876
+ return {
1877
+ playbookRef: input.playbookRef,
1878
+ verified: true,
1879
+ dryRun: true,
1880
+ checkRefs: [...checkRefs],
1881
+ checks: [],
1882
+ passed: null,
1883
+ accepted: false,
1884
+ };
1885
+ }
1886
+ const { verification, infrastructureError } = await this.codingAgentDispatch
1887
+ .runApplicationVerificationChecks(checkRefs);
1888
+ /*
1889
+ * An infrastructure error is reported, never swallowed and never conflated with a failing
1890
+ * check: "the application does not typecheck" and "we could not run the typecheck" send an
1891
+ * operator to entirely different places, and only one of them is the application's fault.
1892
+ */
1893
+ return {
1894
+ playbookRef: input.playbookRef,
1895
+ verified: true,
1896
+ checkRefs: [...checkRefs],
1897
+ checks: verification.map(({ checkRef, outcome }) => ({
1898
+ checkRef,
1899
+ success: outcome.success,
1900
+ message: outcome.message,
1901
+ })),
1902
+ passed: verification.every(({ outcome }) => outcome.success),
1903
+ ...(infrastructureError ? { infrastructureError: String(infrastructureError) } : {}),
1904
+ // No acceptance, as everywhere in this lane: a human commit is the only acceptance.
1905
+ accepted: false,
1906
+ };
1907
+ }
1908
+ if (playbook.executor === MetaWorkflow_Executor.HUMAN) {
1577
1909
  throw new PlaybookNotReadyError(`"${input.playbookRef}" declares executor ${playbook.executor}, which this runtime does not honour. `
1578
1910
  + 'It is a declared design with no implementation: HUMAN needs a decided contract for what a '
1579
1911
  + 'human-performed step returns and how a resume supplies it, and DETERMINISTIC_CLI needs a '
@@ -1600,34 +1932,79 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
1600
1932
  ...(input.dryRun === true ? { dryRun: true } : {}),
1601
1933
  });
1602
1934
  }
1603
- const workspaceTruthSection = await this.composeWorkspaceTruthSection(playbook);
1604
- const compliancePrimaryFactsSection = await this.composeCompliancePrimaryFactsSection(playbook);
1605
- const documentBlueprintSection = this.composeDocumentBlueprintSection(playbook);
1606
- const documentFactObligationsSection = this.composeDocumentFactObligationsSection(playbook);
1607
- const outputs = (playbook.outputs ?? []).map((output) => ({
1608
- family: output.family,
1609
- // A playbook output without a `schemaRef` has no family contract, so nothing could validate what the
1610
- // model returned. Passing the empty string makes the runtime refuse it by name rather than here.
1611
- schemaRef: output.schemaRef ?? '',
1612
- brief: this.composeBrief({
1613
- playbookRef: input.playbookRef,
1614
- guidance: playbook.method?.guidance ?? '',
1935
+ /*
1936
+ * Section composition as a function of an EFFECTIVE playbook, so the brief-adequacy repair arm
1937
+ * below can recompose ONCE with a widened `contextSources` declaration and nothing else. Every
1938
+ * composer already keys off `playbookDeclaresContextSource(effective, MEMBER)`, so widening the
1939
+ * declaration is the entire mechanism — no composer changes, and monotonicity is structural:
1940
+ * a union can only ADD sections, never remove or soften one (#254, design 2).
1941
+ */
1942
+ const composeGenerationOutputs = async (effective) => {
1943
+ const workspaceTruthSection = await this.composeWorkspaceTruthSection(effective);
1944
+ const compliancePrimaryFactsSection = await this.composeCompliancePrimaryFactsSection(effective);
1945
+ const documentBlueprintSection = this.composeDocumentBlueprintSection(effective);
1946
+ const documentFactObligationsSection = this.composeDocumentFactObligationsSection(effective);
1947
+ const assuranceProgramAuthoritySection = this.composeAssuranceProgramAuthoritySection(effective);
1948
+ return (playbook.outputs ?? []).map((output) => ({
1615
1949
  family: output.family,
1616
- creatorBrief: input.creatorBrief,
1617
- elicitationSection,
1618
- inputTruthSection: this.composeInputTruthSection(playbook, artifactState),
1619
- workspaceTruthSection,
1620
- compliancePrimaryFactsSection,
1621
- documentBlueprintSection,
1622
- documentFactObligationsSection,
1623
- skillCatalogSection: this.composeSkillCatalogSection(playbook),
1624
- coherenceSection: this.composeCoherenceSection(playbook, artifactState),
1625
- stepEvidenceSection: this.composeStepEvidenceSection(input.stepResults),
1626
- clarificationAnswersSection: input.clarification
1627
- ? composeClarificationAnswersSection(input.clarification.requests, input.clarification.answers, input.clarification.action)
1628
- : '',
1629
- }),
1630
- }));
1950
+ // A playbook output without a `schemaRef` has no family contract, so nothing could validate what the
1951
+ // model returned. Passing the empty string makes the runtime refuse it by name rather than here.
1952
+ schemaRef: output.schemaRef ?? '',
1953
+ brief: this.composeBrief({
1954
+ playbookRef: input.playbookRef,
1955
+ guidance: playbook.method?.guidance ?? '',
1956
+ family: output.family,
1957
+ creatorBrief: input.creatorBrief,
1958
+ elicitationSection,
1959
+ inputTruthSection: this.composeInputTruthSection(effective, artifactState),
1960
+ workspaceTruthSection,
1961
+ compliancePrimaryFactsSection,
1962
+ documentBlueprintSection,
1963
+ documentFactObligationsSection,
1964
+ assuranceProgramAuthoritySection,
1965
+ skillCatalogSection: this.composeSkillCatalogSection(effective),
1966
+ coherenceSection: this.composeCoherenceSection(effective, artifactState),
1967
+ stepEvidenceSection: this.composeStepEvidenceSection(input.stepResults),
1968
+ parentElicitationSection: input.parentElicitationSection ?? '',
1969
+ clarificationAnswersSection: input.clarification
1970
+ ? composeClarificationAnswersSection(input.clarification.requests, input.clarification.answers, input.clarification.action)
1971
+ : '',
1972
+ }),
1973
+ }));
1974
+ };
1975
+ let outputs = await composeGenerationOutputs(playbook);
1976
+ let briefAdequacy;
1977
+ if (playbook.method?.briefAdequacyGate === true && outputs.length > 0) {
1978
+ const judged = await this.judgeBriefAdequacy(playbook, outputs[0].brief);
1979
+ if (judged) {
1980
+ const declared = new Set(playbook.method?.contextSources ?? []);
1981
+ const excludedSources = new Set(playbook.method?.briefAdequacyExcludedSources ?? []);
1982
+ const addedSources = judged.missingSources.filter((source) => !declared.has(source) && !excludedSources.has(source));
1983
+ if (judged.verdict === 'insufficient' && addedSources.length > 0) {
1984
+ const widened = {
1985
+ ...playbook,
1986
+ method: { ...playbook.method, contextSources: [...declared, ...addedSources] },
1987
+ };
1988
+ outputs = await composeGenerationOutputs(widened);
1989
+ briefAdequacy = { verdict: 'insufficient', addedSources };
1990
+ this.logDebug('Brief-adequacy gate repaired the brief', { playbookRef: input.playbookRef, addedSources });
1991
+ }
1992
+ else {
1993
+ briefAdequacy = { verdict: judged.verdict, addedSources: [] };
1994
+ }
1995
+ }
1996
+ /*
1997
+ * ALWAYS logged, whatever the verdict — the first pilot run produced a state where "ran and
1998
+ * judged sufficient" and "never ran at all" were byte-identical to every observer (no log, no
1999
+ * trace, no result field), which is the silent-gate defect class this gate exists to remove.
2000
+ * A gate must SAY it gated.
2001
+ */
2002
+ this.logger.info('Brief-adequacy gate verdict', {
2003
+ playbookRef: input.playbookRef,
2004
+ verdict: briefAdequacy?.verdict ?? 'unavailable',
2005
+ addedSources: briefAdequacy?.addedSources ?? [],
2006
+ });
2007
+ }
1631
2008
  /*
1632
2009
  * THE ASSESSMENT PATH — a playbook whose deliverable is a VERDICT, not a file.
1633
2010
  *
@@ -1666,6 +2043,13 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
1666
2043
  // citation". Collapsing them would refuse every draft in every application that has not yet
1667
2044
  // run `refinement.document-facts`.
1668
2045
  ...this.resolveDeclaredDocumentFacts(artifactState),
2046
+ /*
2047
+ * The landed values, so the generation loop and the landing can refuse a citation of something
2048
+ * that does not exist — the coherence report's dangling class, moved from post-hoc page into
2049
+ * the findings-fed retry (2026-09-02). The same map eligibility and the input sections already
2050
+ * read; file-only sentinels ride along and are reported unreadable by the report, never thrown on.
2051
+ */
2052
+ landedFamilyValues: artifactState.artifactsByFamily,
1669
2053
  // WHICH documents this application needs, so a draft naming one it does not need is refused at
1670
2054
  // the landing and retried in the generation loop. Same absent-vs-empty contract as the facts
1671
2055
  // above: an omitted key skips the check rather than refusing everything.
@@ -1954,6 +2338,55 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
1954
2338
  ...[...stepResults.entries()].map(([ref, value]) => `## ${ref}\n${typeof value === 'string' ? value : JSON.stringify(value, null, 1)}`),
1955
2339
  ].join('\n');
1956
2340
  }
2341
+ /**
2342
+ * Judge ONE composed brief through the dedicated structured gate agent. FAIL-OPEN by returning
2343
+ * null on any fault — an auxiliary judgment must never withhold a generation (the turn
2344
+ * classifier's contract, for the same reason). The judge sees the closed list of UNDECLARED
2345
+ * sources only, so the repair arm can never be talked into removing anything.
2346
+ */
2347
+ async judgeBriefAdequacy(playbook, brief) {
2348
+ try {
2349
+ const declared = new Set(playbook.method?.contextSources ?? []);
2350
+ const excluded = new Set(playbook.method?.briefAdequacyExcludedSources ?? []);
2351
+ const undeclared = Object.values(MetaWorkflow_ContextSource).filter((source) => !declared.has(source) && !excluded.has(source));
2352
+ if (undeclared.length === 0)
2353
+ return null;
2354
+ const prompt = [
2355
+ 'Judge whether the generation brief below is SUFFICIENT to produce its declared artifact.',
2356
+ 'If it is not, name which of these UNDECLARED context sources would repair it (these are the only',
2357
+ `admissible proposals): ${undeclared.join(', ')}`,
2358
+ '',
2359
+ '# The brief',
2360
+ brief,
2361
+ ].join('\n');
2362
+ const invocation = {
2363
+ agentRef: BRIEF_ADEQUACY_JUDGE_AGENT_REF,
2364
+ initiator: {},
2365
+ invocationContext: [],
2366
+ input: { prompt, schema: BriefAdequacyVerdictOutputSchema },
2367
+ output: { object: {} },
2368
+ executionContext: {},
2369
+ artifactBindings: [],
2370
+ };
2371
+ const response = await this.agents.invokeAgent(invocation);
2372
+ const parsed = BriefAdequacyVerdictOutputSchema.safeParse(response.output?.object);
2373
+ if (!parsed.success)
2374
+ return null;
2375
+ return { verdict: parsed.data.verdict, missingSources: parsed.data.missingSources };
2376
+ }
2377
+ catch (error) {
2378
+ this.logger.warn('Brief-adequacy gate failed; generating from the static brief (fail-open)', {
2379
+ playbookRef: playbook.ref,
2380
+ error: error instanceof Error ? error.message : (() => { try {
2381
+ return JSON.stringify(error)?.slice(0, 400) ?? String(error);
2382
+ }
2383
+ catch {
2384
+ return String(error);
2385
+ } })(),
2386
+ });
2387
+ return null;
2388
+ }
2389
+ }
1957
2390
  composeBrief(input) {
1958
2391
  return [
1959
2392
  `# Playbook: ${input.playbookRef}`,
@@ -2013,12 +2446,17 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
2013
2446
  // writes about what is missing, which is the document this lane owes.
2014
2447
  ...(input.documentBlueprintSection ? ['', input.documentBlueprintSection] : []),
2015
2448
  ...(input.documentFactObligationsSection ? ['', input.documentFactObligationsSection] : []),
2449
+ ...(input.assuranceProgramAuthoritySection ? ['', input.assuranceProgramAuthoritySection] : []),
2016
2450
  ...(input.compliancePrimaryFactsSection ? ['', input.compliancePrimaryFactsSection] : []),
2017
2451
  ...(input.skillCatalogSection ? ['', input.skillCatalogSection] : []),
2018
2452
  ...(input.coherenceSection ? ['', input.coherenceSection] : []),
2019
2453
  // LAST, after every other truth: an answer the creator gave DURING this run settles whatever
2020
2454
  // the sections above left ambiguous, and the closing word should be theirs.
2021
2455
  ...(input.clarificationAnswersSection ? ['', input.clarificationAnswersSection] : []),
2456
+ // The PARENT's creator answers, on a choreography child — the same last-word ranking as the
2457
+ // child's own elicitation, and BEFORE it, so a child that also interviews closes on its own
2458
+ // exchange while still seeing the composite's.
2459
+ ...(input.parentElicitationSection ? ['', input.parentElicitationSection] : []),
2022
2460
  ...(input.elicitationSection ? ['', input.elicitationSection] : []),
2023
2461
  ].join('\n');
2024
2462
  }
@@ -2097,10 +2535,55 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
2097
2535
  * shape of the same one: a fact producer authors no sections and needs the closed name set, and
2098
2536
  * burying eight lines under section obligations is how a prompt section gets skimmed.
2099
2537
  */
2538
+ /** The closed objective/source sets a compliance programme may draw on. See {@link composeAssuranceProgramAuthorityBrief}. */
2539
+ composeAssuranceProgramAuthoritySection(playbook) {
2540
+ if (!playbookDeclaresContextSource(playbook, MetaWorkflow_ContextSource.ASSURANCE_PROGRAM_AUTHORITY))
2541
+ return '';
2542
+ return composeAssuranceProgramAuthorityBrief();
2543
+ }
2100
2544
  composeDocumentFactObligationsSection(playbook) {
2101
2545
  if (!playbookDeclaresContextSource(playbook, MetaWorkflow_ContextSource.DOCUMENT_FACT_OBLIGATIONS))
2102
2546
  return '';
2103
- return composeAssuranceDocumentFactObligationsBrief(DRAFTABLE_DOCUMENT_DEFINITION_REFS);
2547
+ return composeAssuranceDocumentFactObligationsBrief(FACT_OBLIGATION_DOCUMENT_DEFINITION_REFS);
2548
+ }
2549
+ /**
2550
+ * The application's BILLING configuration, as the terms lane needs it (#227).
2551
+ *
2552
+ * Read from the backend companion exports rather than from `wildo.saas.config.ts`, because that is
2553
+ * where it lives: `billing` is declared in the application's `saas-config.backend.ts` and reaches the
2554
+ * runtime `AppConfiguration`, not the root config the companion already holds.
2555
+ *
2556
+ * THREE outcomes, never two. "The configuration could not be read" and "the application declares no
2557
+ * billing" are different facts with different consequences — the first means the question was not
2558
+ * asked, the second is a positive statement that nothing is sold through the framework — and a
2559
+ * drafter told the wrong one writes a confident clause about a product it never saw. Collapsing them
2560
+ * into `undefined` is the conflation this whole lane exists to refuse.
2561
+ *
2562
+ * Best-effort by design: this brief must not be the reason a run fails. An unreadable configuration
2563
+ * is rendered as unreadable and the drafter marks the gap.
2564
+ */
2565
+ async resolveBillingDeclaration() {
2566
+ try {
2567
+ const { backendConfig } = await loadBackendCompanionExports(this.companionContext);
2568
+ const authored = backendConfig.billing;
2569
+ if (authored === undefined || authored === null)
2570
+ return { kind: 'ABSENT' };
2571
+ const parsed = BillingConfigurationSchema.safeParse(authored);
2572
+ if (!parsed.success) {
2573
+ return { kind: 'UNREADABLE', reason: 'the declared billing configuration does not satisfy its own schema' };
2574
+ }
2575
+ return {
2576
+ kind: 'DECLARED',
2577
+ billing: parsed.data,
2578
+ // The AUTHORED object, before defaults — which is what separates "the operator chose this" from
2579
+ // "the framework filled it in". The parsed value cannot answer that: every key is present there.
2580
+ authoredKeys: Object.keys(authored),
2581
+ };
2582
+ }
2583
+ catch (error) {
2584
+ this.logDebug('Billing configuration read failed (brief will report it as unreadable)', { error: String(error) });
2585
+ return { kind: 'UNREADABLE', reason: 'the backend configuration could not be loaded' };
2586
+ }
2104
2587
  }
2105
2588
  async composeCompliancePrimaryFactsSection(playbook) {
2106
2589
  if (!playbookDeclaresContextSource(playbook, MetaWorkflow_ContextSource.COMPLIANCE_PRIMARY_FACTS))
@@ -2277,10 +2760,12 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
2277
2760
  ...renderRetentionSchedule(saasConfig.dataRetention),
2278
2761
  '',
2279
2762
  // Joined to the RUNTIME-SCOPED set: a profile with no runtime binding is not a recipient.
2280
- ...renderProcessorRegister(runtimeScopedProviderRefs, await this.resolveProcessorRegister()),
2763
+ ...renderProcessorRegister(runtimeScopedProviderRefs, await this.resolveProcessorRegister(), saasConfig.providerComplianceChoices),
2281
2764
  '',
2282
2765
  ...renderAiUsePosture(new Set(declaredCapabilities), saasConfig.aiUsePosture),
2283
2766
  '',
2767
+ ...composeBillingCommercialModelBrief(await this.resolveBillingDeclaration()),
2768
+ ...composeOperatingJurisdictionCoverageBrief(saasConfig.operatingJurisdictions),
2284
2769
  ...renderOperatorComplianceIdentity(saasConfig.operatorComplianceIdentity),
2285
2770
  ...renderServiceConsentRequirement(saasConfig.operatorComplianceIdentity?.serviceConsentRequirement),
2286
2771
  ...renderClientStorage(Object.entries(this.companionContext.servicesByKey)
@@ -2481,7 +2966,75 @@ let PlaybookRunCompanionService = class PlaybookRunCompanionService {
2481
2966
  activeChoreography = null;
2482
2967
  /** What is running in this process, and what died leaving a resumable checkpoint. */
2483
2968
  async readRunsInFlight() {
2484
- return { running: this.activeChoreography, interrupted: await this.choreographyCheckpoints.list() };
2969
+ return {
2970
+ running: this.activeChoreography,
2971
+ interrupted: await this.choreographyCheckpoints.list(),
2972
+ lastCompleted: [...this.lastCompletedDetachedRuns.values()],
2973
+ };
2974
+ }
2975
+ /**
2976
+ * The most recent DETACHED run outcome per playbook ref — the read side of async submission (#265).
2977
+ *
2978
+ * In memory deliberately (one-source-of-truth Rule 5: a per-run cache; a restart costs the summary
2979
+ * and no fact — the artifacts are in the tree and the details in the traces). Bounded to one entry
2980
+ * per ref, because the question this answers is "what happened to the run I submitted", not a
2981
+ * history — the traces are the history.
2982
+ */
2983
+ lastCompletedDetachedRuns = new Map();
2984
+ /**
2985
+ * Submit a run and return IMMEDIATELY — the async half of #265's envelope fix.
2986
+ *
2987
+ * The synchronous route holds one HTTP request open for the run's whole life, and the server's
2988
+ * 30-minute request ceiling is SHORTER than a choreography's own duration bound — measured twice:
2989
+ * the connection dies at exactly 1800s, the run continues and even completes server-side, and the
2990
+ * caller gets HTTP 000 instead of a result. This path returns at submission; the caller polls
2991
+ * `readRunsInFlight`, whose `lastCompleted` carries the outcome (including a failure — an async
2992
+ * submission must never turn an error into silence).
2993
+ */
2994
+ submitPlaybookRunDetached(input) {
2995
+ const startedAt = new Date().toISOString();
2996
+ void this.runPlaybook(input)
2997
+ .then((result) => {
2998
+ this.lastCompletedDetachedRuns.set(input.playbookRef, {
2999
+ playbookRef: input.playbookRef,
3000
+ startedAt,
3001
+ finishedAt: new Date().toISOString(),
3002
+ ok: true,
3003
+ result,
3004
+ });
3005
+ })
3006
+ .catch((error) => {
3007
+ this.lastCompletedDetachedRuns.set(input.playbookRef, {
3008
+ playbookRef: input.playbookRef,
3009
+ startedAt,
3010
+ finishedAt: new Date().toISOString(),
3011
+ ok: false,
3012
+ error: error instanceof Error ? error.message : JSON.stringify(error)?.slice(0, 500) ?? 'unknown',
3013
+ });
3014
+ });
3015
+ return {
3016
+ accepted: false,
3017
+ async: true,
3018
+ playbookRef: input.playbookRef,
3019
+ note: 'Submitted. Poll GET /playbooks/runs — `running` while in flight, then your outcome in `lastCompleted`. '
3020
+ + 'Validation failures (an unanswered elicitation, an ineligible playbook) surface there too, not as an HTTP error.',
3021
+ };
3022
+ }
3023
+ /**
3024
+ * Every run waiting for its creator to answer — a THIRD state, and neither of the two above.
3025
+ *
3026
+ * `readRunsInFlight` answers `{ running, interrupted }`: the in-process marker for a choreography
3027
+ * executing right now, and the checkpoints of one that stopped mid-way. A SUSPENDED run is neither.
3028
+ * It is healthy, it has written nothing — the clarification check runs before the artifact call —
3029
+ * and it is waiting on a decision only a person can make. It appeared in neither read, so nothing
3030
+ * could name it once its creator's client was gone.
3031
+ *
3032
+ * Kept as its own method rather than folded into `readRunsInFlight` for that reason: merging the
3033
+ * three would say a suspended run is a kind of in-flight one, and the difference is exactly what a
3034
+ * reader needs — one of the three is waiting for THEM.
3035
+ */
3036
+ async readSuspendedRuns() {
3037
+ return this.suspendedRuns.list();
2485
3038
  }
2486
3039
  modelCallBreaker = { hour: '', calls: 0, providerBudgetNoted: false };
2487
3040
  assertPlaybookModelCallBreaker() {
@@ -2664,15 +3217,17 @@ PlaybookRunCompanionService = PlaybookRunCompanionService_1 = __decorate([
2664
3217
  __param(4, inject(COMPANION_SERVICE_TYPES.TraceabilityService)),
2665
3218
  __param(5, inject(COMPANION_SERVICE_TYPES.PlaybookRunWriteRegisterService)),
2666
3219
  __param(6, inject(COMPANION_SERVICE_TYPES.ApplicationBuildDispatchService)),
2667
- __param(7, inject(COMPANION_SERVICE_TYPES.GitChangeSetService)),
2668
- __param(8, inject(COMPANION_SERVICE_TYPES.IntrospectionService)),
2669
- __param(9, inject(COMPANION_SERVICE_TYPES.FoundationExecutorService)),
2670
- __param(10, inject(COMPANION_SERVICE_TYPES.PlaybookSuspendedRunService)),
2671
- __param(11, inject(COMPANION_SERVICE_TYPES.PlaybookChoreographyCheckpointService)),
2672
- __param(12, inject(COMPANION_SERVICE_TYPES.StructuredDeliberationService)),
3220
+ __param(7, inject(COMPANION_SERVICE_TYPES.CodingAgentDispatchService)),
3221
+ __param(8, inject(COMPANION_SERVICE_TYPES.GitChangeSetService)),
3222
+ __param(9, inject(COMPANION_SERVICE_TYPES.IntrospectionService)),
3223
+ __param(10, inject(COMPANION_SERVICE_TYPES.FoundationExecutorService)),
3224
+ __param(11, inject(COMPANION_SERVICE_TYPES.PlaybookSuspendedRunService)),
3225
+ __param(12, inject(COMPANION_SERVICE_TYPES.PlaybookChoreographyCheckpointService)),
3226
+ __param(13, inject(COMPANION_SERVICE_TYPES.StructuredDeliberationService)),
2673
3227
  __metadata("design:paramtypes", [Function, Object, ResearchAgentDispatchCompanionService, Function, CompanionTraceabilityService,
2674
3228
  PlaybookRunWriteRegisterCompanionService,
2675
3229
  ApplicationBuildDispatchCompanionService,
3230
+ CodingAgentDispatchCompanionService,
2676
3231
  GitChangeSetCompanionService,
2677
3232
  CompanionIntrospectionService,
2678
3233
  FoundationExecutorCompanionService,