@wildo-ai/dev-companion 1.1.1 → 1.1.3

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 (212) 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 +408 -38
  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 +70 -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 +110 -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 +62 -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 +295 -19
  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 +243 -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 +370 -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 +40 -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 +126 -0
  82. package/dist/esm/core/introspection/subprocess/family-aspects.behavior.js.map +1 -0
  83. package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.d.ts +51 -0
  84. package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.d.ts.map +1 -0
  85. package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.js +391 -0
  86. package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.js.map +1 -0
  87. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts +103 -0
  88. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts.map +1 -0
  89. package/dist/esm/core/runtime/dev-compile-quiet.companion.js +124 -0
  90. package/dist/esm/core/runtime/dev-compile-quiet.companion.js.map +1 -0
  91. package/dist/esm/core/runtime/services/start-companion-application.service.d.ts +39 -2
  92. package/dist/esm/core/runtime/services/start-companion-application.service.d.ts.map +1 -1
  93. package/dist/esm/core/runtime/services/start-companion-application.service.js +122 -11
  94. package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
  95. package/dist/esm/core/specifications/non-composite-view-specification-context.shared.d.ts +6 -0
  96. package/dist/esm/core/specifications/non-composite-view-specification-context.shared.d.ts.map +1 -1
  97. package/dist/esm/core/specifications/non-composite-view-specification-context.shared.js.map +1 -1
  98. package/dist/esm/core/specifications/specification-context-factory.shared.d.ts +23 -0
  99. package/dist/esm/core/specifications/specification-context-factory.shared.d.ts.map +1 -1
  100. package/dist/esm/core/specifications/specification-context-factory.shared.js +26 -4
  101. package/dist/esm/core/specifications/specification-context-factory.shared.js.map +1 -1
  102. package/dist/esm/executions/services/companion-executions.companion.service.d.ts.map +1 -1
  103. package/dist/esm/executions/services/companion-executions.companion.service.js +13 -8
  104. package/dist/esm/executions/services/companion-executions.companion.service.js.map +1 -1
  105. package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.d.ts +12 -0
  106. package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.d.ts.map +1 -0
  107. package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.js +12 -0
  108. package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.js.map +1 -0
  109. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.d.ts +1 -1
  110. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.js +1 -1
  111. package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.js.map +1 -1
  112. package/dist/esm/i18n/composite_views/app.creation-board.en.d.ts +13 -0
  113. package/dist/esm/i18n/composite_views/app.creation-board.en.d.ts.map +1 -0
  114. package/dist/esm/i18n/composite_views/app.creation-board.en.js +91 -0
  115. package/dist/esm/i18n/composite_views/app.creation-board.en.js.map +1 -0
  116. package/dist/esm/i18n/composite_views/app.domain-model.en.d.ts +38 -0
  117. package/dist/esm/i18n/composite_views/app.domain-model.en.d.ts.map +1 -0
  118. package/dist/esm/i18n/composite_views/app.domain-model.en.js +41 -0
  119. package/dist/esm/i18n/composite_views/app.domain-model.en.js.map +1 -0
  120. package/dist/esm/i18n/index.d.ts +3 -3
  121. package/dist/esm/i18n/index.js +3 -3
  122. package/dist/esm/i18n/index.js.map +1 -1
  123. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.d.ts +24 -0
  124. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.d.ts.map +1 -0
  125. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.js +20 -0
  126. package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.js.map +1 -0
  127. package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.d.ts +31 -0
  128. package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.d.ts.map +1 -0
  129. package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.js +27 -0
  130. package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.js.map +1 -0
  131. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.d.ts +24 -0
  132. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.d.ts.map +1 -0
  133. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.js +20 -0
  134. package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.js.map +1 -0
  135. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.d.ts +28 -0
  136. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.d.ts.map +1 -0
  137. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.js +24 -0
  138. package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.js.map +1 -0
  139. package/dist/esm/i18n/resources/workbenchDomainResources.en.d.ts +138 -0
  140. package/dist/esm/i18n/resources/workbenchDomainResources.en.d.ts.map +1 -0
  141. package/dist/esm/i18n/resources/workbenchDomainResources.en.js +100 -0
  142. package/dist/esm/i18n/resources/workbenchDomainResources.en.js.map +1 -0
  143. package/dist/esm/i18n/resources/workbenchPlaybooks.en.d.ts +29 -0
  144. package/dist/esm/i18n/resources/workbenchPlaybooks.en.d.ts.map +1 -0
  145. package/dist/esm/i18n/resources/workbenchPlaybooks.en.js +25 -0
  146. package/dist/esm/i18n/resources/workbenchPlaybooks.en.js.map +1 -0
  147. package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.d.ts +27 -0
  148. package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.d.ts.map +1 -0
  149. package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.js +23 -0
  150. package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.js.map +1 -0
  151. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +806 -0
  152. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -0
  153. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +326 -0
  154. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -0
  155. package/dist/esm/i18n/resources/workbenchTraceSessions.en.d.ts +26 -0
  156. package/dist/esm/i18n/resources/workbenchTraceSessions.en.d.ts.map +1 -0
  157. package/dist/esm/i18n/resources/workbenchTraceSessions.en.js +22 -0
  158. package/dist/esm/i18n/resources/workbenchTraceSessions.en.js.map +1 -0
  159. package/dist/esm/i18n/system_enums/market.en.d.ts +202 -0
  160. package/dist/esm/i18n/system_enums/market.en.d.ts.map +1 -0
  161. package/dist/esm/i18n/system_enums/market.en.js +209 -0
  162. package/dist/esm/i18n/system_enums/market.en.js.map +1 -0
  163. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts +31 -0
  164. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts.map +1 -1
  165. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js +91 -8
  166. package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js.map +1 -1
  167. package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.d.ts +4 -2
  168. package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.d.ts.map +1 -1
  169. package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.js +10 -7
  170. package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.js.map +1 -1
  171. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +80 -7
  172. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
  173. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +261 -24
  174. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
  175. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts +46 -3
  176. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts.map +1 -1
  177. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js +95 -2
  178. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js.map +1 -1
  179. package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.d.ts +9 -0
  180. package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.d.ts.map +1 -1
  181. package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.js +13 -0
  182. package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.js.map +1 -1
  183. package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.d.ts +12 -0
  184. package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.d.ts.map +1 -1
  185. package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js +23 -0
  186. package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js.map +1 -1
  187. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +113 -1
  188. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts.map +1 -1
  189. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js +517 -54
  190. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
  191. package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.d.ts +40 -0
  192. package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.d.ts.map +1 -1
  193. package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.js +63 -1
  194. package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.js.map +1 -1
  195. package/dist/esm/technical-doc/services/technical-doc.companion.service.d.ts +21 -0
  196. package/dist/esm/technical-doc/services/technical-doc.companion.service.d.ts.map +1 -1
  197. package/dist/esm/technical-doc/services/technical-doc.companion.service.js +84 -2
  198. package/dist/esm/technical-doc/services/technical-doc.companion.service.js.map +1 -1
  199. package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.d.ts +10 -1
  200. package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.d.ts.map +1 -1
  201. package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.js +10 -1
  202. package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.js.map +1 -1
  203. package/package.json +17 -17
  204. package/dist/esm/.builder.pid +0 -9
  205. package/dist/esm/i18n/resources/workbenchApplicationModules.en.d.ts +0 -36
  206. package/dist/esm/i18n/resources/workbenchApplicationModules.en.d.ts.map +0 -1
  207. package/dist/esm/i18n/resources/workbenchApplicationModules.en.js +0 -32
  208. package/dist/esm/i18n/resources/workbenchApplicationModules.en.js.map +0 -1
  209. package/dist/esm/i18n/resources/workbenchResourceRelationships.en.d.ts +0 -29
  210. package/dist/esm/i18n/resources/workbenchResourceRelationships.en.d.ts.map +0 -1
  211. package/dist/esm/i18n/resources/workbenchResourceRelationships.en.js +0 -25
  212. package/dist/esm/i18n/resources/workbenchResourceRelationships.en.js.map +0 -1
@@ -0,0 +1,243 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { inject, injectable } from 'inversify';
14
+ import { WORKBENCH_CREATION_PLANE_BEHAVIOR_IDS, WorkbenchCreationPlaneBehavior, sanitizeWorkbenchCreationPlaneIdentity, } from '@wildo-ai/platform-core-shared';
15
+ import { COMPANION_SERVICE_TYPES } from '../../inject/models/service-types.js';
16
+ /**
17
+ * The IN-PROCESS half of the companion's introspection source — the CREATION PLANE
18
+ * (`workbench-creation-board-resources.md` Phase 2; the mechanism that decided issue #166).
19
+ *
20
+ * The four behaviors here project the companion's OWN runtime services: no subprocess, no app-dist
21
+ * import, milliseconds per read — except the eligibility board, whose ~10-second recompute is
22
+ * exactly why the CACHE below exists. The behavior-id vocabulary is owned by
23
+ * `@wildo-ai/platform-core-shared` (`WorkbenchCreationPlaneBehavior`), the same package that writes
24
+ * the ids into the resource bindings, so the two ends cannot drift.
25
+ *
26
+ * ## The eligibility cache (requirement R3 of the plan)
27
+ *
28
+ * Resource surfaces multiply the consumers of a LIST (RMM, embedded lists, label resolution), so
29
+ * serving the raw recompute would make the board WORSE than the bespoke route it replaces. The
30
+ * cache is `{rows, computedAt}` with a TTL, invalidated through the write register's mutation seam
31
+ * (see the constructor) and by the explicit refresh route; Phase 3 adds operation-success
32
+ * invalidation when dispatches become custom operations. `computedAt` is projected onto every row
33
+ * so the board can render "as of".
34
+ *
35
+ * Rule-5 posture (`one-source-of-truth.md`): this is a per-run projection cache. Deleting it costs
36
+ * one recompute, never truth, and nothing anywhere reads it as an acceptance.
37
+ *
38
+ * ## Identity sanitization, and why it is here
39
+ *
40
+ * The binding's `identityFields` composition refuses any value outside `[a-zA-Z0-9_-]`, and this
41
+ * plane's business keys legitimately violate it: playbook refs carry dots (`top_down.phase-gate`),
42
+ * trace session ids are `dev-<ISO-ish>` directory names. So each projection emits its identity
43
+ * field itself — `.` becomes `__`, any other invalid character becomes `-` — and REFUSES on a
44
+ * post-sanitization duplicate rather than serving two rows under one id (the same trade the
45
+ * source's composed-identity stamping makes, for the same reason: READ returning an arbitrary row
46
+ * is worse than a refusal).
47
+ */
48
+ const ELIGIBILITY_CACHE_TTL_MS = 60_000;
49
+ /** The trace index is bounded by the shared workbench page ceiling, not by the read route's default 50. */
50
+ const TRACE_SESSION_LIMIT = 1000;
51
+ /**
52
+ * Re-exported from the SHARED vocabulary (`@wildo-ai/platform-core-shared`), where the identity
53
+ * rule moved once the frontend needed it too — an interrupted run's re-dispatch derives the row
54
+ * address from its `playbookRef`. One named source; this alias keeps companion-side call sites
55
+ * and pins stable.
56
+ */
57
+ export const sanitizeCreationPlaneIdentity = sanitizeWorkbenchCreationPlaneIdentity;
58
+ let CreationPlaneProjectionCompanionService = class CreationPlaneProjectionCompanionService {
59
+ playbookRunService;
60
+ buildDispatchService;
61
+ runWriteRegister;
62
+ executionTraceReadService;
63
+ eligibilityCache = null;
64
+ eligibilityCachedAtMs = 0;
65
+ /**
66
+ * Bumped by every {@link invalidateEligibility}. A recompute captures it BEFORE deriving and
67
+ * refuses to populate the cache when it moved — without this, an invalidation that fires while
68
+ * a recompute is in flight (a poll-started derivation straddling a dispatch's post-operation
69
+ * invalidation) is silently cancelled out: the in-flight closure would repopulate the cache
70
+ * with the PRE-mutation board for up to the TTL, which is the exact "as of before your
71
+ * dispatch" answer this cache's contract forbids.
72
+ */
73
+ eligibilityEpoch = 0;
74
+ /** Concurrent LISTs during a cold recompute share ONE derivation instead of stacking ~10s reads. */
75
+ eligibilityInFlight = null;
76
+ constructor(playbookRunService, buildDispatchService, runWriteRegister, executionTraceReadService) {
77
+ this.playbookRunService = playbookRunService;
78
+ this.buildDispatchService = buildDispatchService;
79
+ this.runWriteRegister = runWriteRegister;
80
+ this.executionTraceReadService = executionTraceReadService;
81
+ /*
82
+ * A run landing files is exactly the event that changes playbook eligibility, and every run's
83
+ * landing reports to the write register — so the register's mutation seam is the ONE hook that
84
+ * covers playbook runs AND reverts without this service being wired into each dispatch handler
85
+ * (the N-call-sites shape that drifts). What it does NOT cover — a coding-agent landing the
86
+ * HUMAN commits in git — no hook can see, and the TTL is what bounds that staleness.
87
+ */
88
+ this.runWriteRegister.registerMutationListener(() => this.invalidateEligibility());
89
+ }
90
+ supports(behaviorId) {
91
+ return WORKBENCH_CREATION_PLANE_BEHAVIOR_IDS.includes(behaviorId);
92
+ }
93
+ /**
94
+ * Drop the eligibility cache. Called after every creation-plane mutation — the board must not
95
+ * answer "as of before your dispatch" to the person who just dispatched.
96
+ */
97
+ invalidateEligibility() {
98
+ this.eligibilityEpoch += 1;
99
+ this.eligibilityCache = null;
100
+ this.eligibilityCachedAtMs = 0;
101
+ /*
102
+ * Also drop the in-flight handle: a reader arriving AFTER the invalidation must start a fresh
103
+ * derivation rather than join one computing the pre-mutation board. The orphaned computation
104
+ * still completes for its own callers, and the epoch guard keeps it out of the cache.
105
+ */
106
+ this.eligibilityInFlight = null;
107
+ }
108
+ async deriveRows(behaviorId) {
109
+ switch (behaviorId) {
110
+ case WorkbenchCreationPlaneBehavior.PLAYBOOK_ELIGIBILITY:
111
+ return this.derivePlaybookEligibilityRows();
112
+ case WorkbenchCreationPlaneBehavior.BUILD_PLAN_TASKS:
113
+ return this.deriveBuildPlanTaskRows();
114
+ case WorkbenchCreationPlaneBehavior.RUN_WRITE_RECORDS:
115
+ return this.deriveRunWriteRecordRows();
116
+ case WorkbenchCreationPlaneBehavior.TRACE_SESSIONS:
117
+ return this.deriveTraceSessionRows();
118
+ default:
119
+ throw new Error(`'${behaviorId}' is not a creation-plane behavior. The supported set is: `
120
+ + `${WORKBENCH_CREATION_PLANE_BEHAVIOR_IDS.join(', ')}.`);
121
+ }
122
+ }
123
+ async derivePlaybookEligibilityRows() {
124
+ const now = Date.now();
125
+ if (this.eligibilityCache && now - this.eligibilityCachedAtMs < ELIGIBILITY_CACHE_TTL_MS) {
126
+ return this.eligibilityCache.rows;
127
+ }
128
+ if (this.eligibilityInFlight)
129
+ return this.eligibilityInFlight;
130
+ const epochAtStart = this.eligibilityEpoch;
131
+ const flight = (async () => {
132
+ const board = await this.playbookRunService.listPlaybookEligibility();
133
+ const computedAt = new Date().toISOString();
134
+ const rows = this.stampIdentities(board.playbooks.map((playbook) => ({
135
+ playbookRef: playbook.playbookRef,
136
+ playbookVersion: playbook.playbookVersion,
137
+ phase: String(board.phase),
138
+ intent: playbook.intent,
139
+ eligible: playbook.eligible,
140
+ unmet: playbook.unmet,
141
+ blockedOnlyBySequencing: playbook.blockedOnlyBySequencing,
142
+ requiresElicitation: playbook.requiresElicitation,
143
+ wouldReplace: playbook.wouldReplace,
144
+ unlandableFamilies: playbook.unlandableFamilies,
145
+ staleOutputs: playbook.staleOutputs,
146
+ computedAt,
147
+ })), 'workbenchPlaybookId', (row) => String(row.playbookRef), WorkbenchCreationPlaneBehavior.PLAYBOOK_ELIGIBILITY);
148
+ if (this.eligibilityEpoch === epochAtStart) {
149
+ this.eligibilityCache = { rows, computedAt };
150
+ this.eligibilityCachedAtMs = Date.now();
151
+ }
152
+ // An epoch that moved means something mutated mid-derivation: serve the computed rows to
153
+ // THIS caller (they are at worst one mutation old, same as any read that finished a moment
154
+ // earlier) but do not cache them — the next read recomputes against the post-mutation world.
155
+ return rows;
156
+ })();
157
+ this.eligibilityInFlight = flight;
158
+ try {
159
+ return await flight;
160
+ }
161
+ finally {
162
+ // Only clear OUR handle — an invalidation may have nulled it and a newer flight taken the slot.
163
+ if (this.eligibilityInFlight === flight)
164
+ this.eligibilityInFlight = null;
165
+ }
166
+ }
167
+ async deriveBuildPlanTaskRows() {
168
+ const tasks = await this.buildDispatchService.describeBuildPlanBoard();
169
+ return this.stampIdentities(tasks.map((task) => ({ ...task })), 'workbenchBuildPlanTaskId', (row) => String(row.taskRef), WorkbenchCreationPlaneBehavior.BUILD_PLAN_TASKS);
170
+ }
171
+ async deriveRunWriteRecordRows() {
172
+ const records = await this.runWriteRegister.list();
173
+ /*
174
+ * The trace JOIN (Phase 4, R5): a runId is `<sessionId>-<playbookRef>-<ts>`, so the session is
175
+ * resolved by longest-prefix match against the live session index. Listed ONCE per derivation
176
+ * — a per-record listing would re-read the directory N times for one answer. NULL when nothing
177
+ * matches: the register legitimately outlives its trace directory, and a dangling reference
178
+ * would render as a broken link.
179
+ *
180
+ * Resolved against the UNBOUNDED id listing, not the display-limited summaries: the join is a
181
+ * correctness question and must not lose links for records older than the newest
182
+ * TRACE_SESSION_LIMIT sessions (completion-review finding 11a). The bound stays on the
183
+ * trace-sessions ROWS below, where it is a display decision.
184
+ */
185
+ const sessionIdsLongestFirst = [...await this.executionTraceReadService.listSessionIds()]
186
+ .sort((a, b) => b.length - a.length);
187
+ return this.stampIdentities(records.map((record) => {
188
+ const sessionId = sessionIdsLongestFirst.find((candidate) => record.runId.startsWith(`${candidate}-`));
189
+ return {
190
+ runId: record.runId,
191
+ playbookRef: record.playbookRef,
192
+ /*
193
+ * The join keys, SANITIZED so values match the target rows' addressable ids — the same
194
+ * identity rule every creation-plane row is addressed by.
195
+ */
196
+ workbenchPlaybookId: sanitizeWorkbenchCreationPlaneIdentity(record.playbookRef),
197
+ workbenchTraceSessionId: sessionId ? sanitizeWorkbenchCreationPlaneIdentity(sessionId) : null,
198
+ at: record.at,
199
+ /*
200
+ * Pre-image BYTES stay behind: `previousContent` belongs to the revert mechanism, and a
201
+ * LIST carrying every pre-image would ship the working tree's history on every render.
202
+ */
203
+ files: record.files.map((file) => ({ path: file.path, existedBefore: file.existedBefore })),
204
+ fileCount: record.files.length,
205
+ };
206
+ }), 'workbenchRunWriteRecordId', (row) => String(row.runId), WorkbenchCreationPlaneBehavior.RUN_WRITE_RECORDS);
207
+ }
208
+ async deriveTraceSessionRows() {
209
+ const sessions = await this.executionTraceReadService.listSessions(TRACE_SESSION_LIMIT);
210
+ return this.stampIdentities(sessions.map((session) => ({
211
+ sessionId: session.sessionId,
212
+ startedAt: session.startedAt,
213
+ label: session.label,
214
+ eventCount: session.eventCount,
215
+ stepCount: session.stepCount,
216
+ })), 'workbenchTraceSessionId', (row) => String(row.sessionId), WorkbenchCreationPlaneBehavior.TRACE_SESSIONS);
217
+ }
218
+ stampIdentities(rows, fieldIdentifier, businessKey, behavior) {
219
+ const seen = new Map();
220
+ return rows.map((row) => {
221
+ const raw = businessKey(row);
222
+ const identity = sanitizeCreationPlaneIdentity(raw);
223
+ const previous = seen.get(identity);
224
+ if (previous !== undefined && previous !== raw) {
225
+ throw new Error(`Creation-plane behavior '${behavior}' sanitized two distinct keys ('${previous}', '${raw}') to one `
226
+ + `identity '${identity}'. Served, READ would return an arbitrary one of them; refused instead. `
227
+ + 'Rename one of the colliding keys.');
228
+ }
229
+ seen.set(identity, raw);
230
+ return { ...row, [fieldIdentifier]: identity };
231
+ });
232
+ }
233
+ };
234
+ CreationPlaneProjectionCompanionService = __decorate([
235
+ injectable(),
236
+ __param(0, inject(COMPANION_SERVICE_TYPES.PlaybookRunService)),
237
+ __param(1, inject(COMPANION_SERVICE_TYPES.ApplicationBuildDispatchService)),
238
+ __param(2, inject(COMPANION_SERVICE_TYPES.PlaybookRunWriteRegisterService)),
239
+ __param(3, inject(COMPANION_SERVICE_TYPES.ExecutionTraceReadService)),
240
+ __metadata("design:paramtypes", [Function, Function, Function, Function])
241
+ ], CreationPlaneProjectionCompanionService);
242
+ export { CreationPlaneProjectionCompanionService };
243
+ //# sourceMappingURL=creation-plane-projection.companion.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"creation-plane-projection.companion.service.js","sourceRoot":"","sources":["../../../../../../src/core/introspection/resources/creation-plane-projection.companion.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EACL,qCAAqC,EACrC,8BAA8B,EAC9B,sCAAsC,GACvC,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAM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C,MAAM,IAAI,KAAK,CACb,4BAA4B,QAAQ,mCAAmC,QAAQ,OAAO,GAAG,YAAY;sBACnG,aAAa,QAAQ,0EAA0E;sBAC/F,mCAAmC,CACtC,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YACxB,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AApNY,uCAAuC;IADnD,UAAU,EAAE;IAiBR,WAAA,MAAM,CAAC,uBAAuB,CAAC,kBAAkB,CAAC,CAAA;IAElD,WAAA,MAAM,CAAC,uBAAuB,CAAC,+BAA+B,CAAC,CAAA;IAE/D,WAAA,MAAM,CAAC,uBAAuB,CAAC,+BAA+B,CAAC,CAAA;IAE/D,WAAA,MAAM,CAAC,uBAAuB,CAAC,yBAAyB,CAAC,CAAA;;GAtBjD,uCAAuC,CAoNnD","sourcesContent":["import { inject, injectable } from 'inversify';\nimport {\n WORKBENCH_CREATION_PLANE_BEHAVIOR_IDS,\n WorkbenchCreationPlaneBehavior,\n sanitizeWorkbenchCreationPlaneIdentity,\n} from '@wildo-ai/platform-core-shared';\n\nimport { COMPANION_SERVICE_TYPES } from '../../inject/models/service-types';\nimport type { PlaybookRunCompanionService } from '../../../meta-workflows/services/playbook-run.companion.service';\nimport type { ApplicationBuildDispatchCompanionService } from '../../../meta-workflows/services/application-build-dispatch.companion.service';\nimport type { PlaybookRunWriteRegisterCompanionService } from '../../../meta-workflows/services/playbook-run-write-register.companion.service';\nimport type { ExecutionTraceReadCompanionService } from '../../../meta-workflows/services/execution-trace-read.companion.service';\n\n/**\n * The IN-PROCESS half of the companion's introspection source — the CREATION PLANE\n * (`workbench-creation-board-resources.md` Phase 2; the mechanism that decided issue #166).\n *\n * The four behaviors here project the companion's OWN runtime services: no subprocess, no app-dist\n * import, milliseconds per read — except the eligibility board, whose ~10-second recompute is\n * exactly why the CACHE below exists. The behavior-id vocabulary is owned by\n * `@wildo-ai/platform-core-shared` (`WorkbenchCreationPlaneBehavior`), the same package that writes\n * the ids into the resource bindings, so the two ends cannot drift.\n *\n * ## The eligibility cache (requirement R3 of the plan)\n *\n * Resource surfaces multiply the consumers of a LIST (RMM, embedded lists, label resolution), so\n * serving the raw recompute would make the board WORSE than the bespoke route it replaces. The\n * cache is `{rows, computedAt}` with a TTL, invalidated through the write register's mutation seam\n * (see the constructor) and by the explicit refresh route; Phase 3 adds operation-success\n * invalidation when dispatches become custom operations. `computedAt` is projected onto every row\n * so the board can render \"as of\".\n *\n * Rule-5 posture (`one-source-of-truth.md`): this is a per-run projection cache. Deleting it costs\n * one recompute, never truth, and nothing anywhere reads it as an acceptance.\n *\n * ## Identity sanitization, and why it is here\n *\n * The binding's `identityFields` composition refuses any value outside `[a-zA-Z0-9_-]`, and this\n * plane's business keys legitimately violate it: playbook refs carry dots (`top_down.phase-gate`),\n * trace session ids are `dev-<ISO-ish>` directory names. So each projection emits its identity\n * field itself — `.` becomes `__`, any other invalid character becomes `-` — and REFUSES on a\n * post-sanitization duplicate rather than serving two rows under one id (the same trade the\n * source's composed-identity stamping makes, for the same reason: READ returning an arbitrary row\n * is worse than a refusal).\n */\n\nconst ELIGIBILITY_CACHE_TTL_MS = 60_000;\n\n/** The trace index is bounded by the shared workbench page ceiling, not by the read route's default 50. */\nconst TRACE_SESSION_LIMIT = 1000;\n\n/**\n * Re-exported from the SHARED vocabulary (`@wildo-ai/platform-core-shared`), where the identity\n * rule moved once the frontend needed it too — an interrupted run's re-dispatch derives the row\n * address from its `playbookRef`. One named source; this alias keeps companion-side call sites\n * and pins stable.\n */\nexport const sanitizeCreationPlaneIdentity = sanitizeWorkbenchCreationPlaneIdentity;\n\n@injectable()\nexport class CreationPlaneProjectionCompanionService {\n private eligibilityCache: { rows: readonly Record<string, unknown>[]; computedAt: string } | null = null;\n private eligibilityCachedAtMs = 0;\n /**\n * Bumped by every {@link invalidateEligibility}. A recompute captures it BEFORE deriving and\n * refuses to populate the cache when it moved — without this, an invalidation that fires while\n * a recompute is in flight (a poll-started derivation straddling a dispatch's post-operation\n * invalidation) is silently cancelled out: the in-flight closure would repopulate the cache\n * with the PRE-mutation board for up to the TTL, which is the exact \"as of before your\n * dispatch\" answer this cache's contract forbids.\n */\n private eligibilityEpoch = 0;\n /** Concurrent LISTs during a cold recompute share ONE derivation instead of stacking ~10s reads. */\n private eligibilityInFlight: Promise<readonly Record<string, unknown>[]> | null = null;\n\n constructor(\n @inject(COMPANION_SERVICE_TYPES.PlaybookRunService)\n private readonly playbookRunService: PlaybookRunCompanionService,\n @inject(COMPANION_SERVICE_TYPES.ApplicationBuildDispatchService)\n private readonly buildDispatchService: ApplicationBuildDispatchCompanionService,\n @inject(COMPANION_SERVICE_TYPES.PlaybookRunWriteRegisterService)\n private readonly runWriteRegister: PlaybookRunWriteRegisterCompanionService,\n @inject(COMPANION_SERVICE_TYPES.ExecutionTraceReadService)\n private readonly executionTraceReadService: ExecutionTraceReadCompanionService,\n ) {\n /*\n * A run landing files is exactly the event that changes playbook eligibility, and every run's\n * landing reports to the write register — so the register's mutation seam is the ONE hook that\n * covers playbook runs AND reverts without this service being wired into each dispatch handler\n * (the N-call-sites shape that drifts). What it does NOT cover — a coding-agent landing the\n * HUMAN commits in git — no hook can see, and the TTL is what bounds that staleness.\n */\n this.runWriteRegister.registerMutationListener(() => this.invalidateEligibility());\n }\n\n public supports(behaviorId: string): boolean {\n return WORKBENCH_CREATION_PLANE_BEHAVIOR_IDS.includes(behaviorId);\n }\n\n /**\n * Drop the eligibility cache. Called after every creation-plane mutation — the board must not\n * answer \"as of before your dispatch\" to the person who just dispatched.\n */\n public invalidateEligibility(): void {\n this.eligibilityEpoch += 1;\n this.eligibilityCache = null;\n this.eligibilityCachedAtMs = 0;\n /*\n * Also drop the in-flight handle: a reader arriving AFTER the invalidation must start a fresh\n * derivation rather than join one computing the pre-mutation board. The orphaned computation\n * still completes for its own callers, and the epoch guard keeps it out of the cache.\n */\n this.eligibilityInFlight = null;\n }\n\n public async deriveRows(behaviorId: string): Promise<readonly Record<string, unknown>[]> {\n switch (behaviorId as WorkbenchCreationPlaneBehavior) {\n case WorkbenchCreationPlaneBehavior.PLAYBOOK_ELIGIBILITY:\n return this.derivePlaybookEligibilityRows();\n case WorkbenchCreationPlaneBehavior.BUILD_PLAN_TASKS:\n return this.deriveBuildPlanTaskRows();\n case WorkbenchCreationPlaneBehavior.RUN_WRITE_RECORDS:\n return this.deriveRunWriteRecordRows();\n case WorkbenchCreationPlaneBehavior.TRACE_SESSIONS:\n return this.deriveTraceSessionRows();\n default:\n throw new Error(\n `'${behaviorId}' is not a creation-plane behavior. The supported set is: `\n + `${WORKBENCH_CREATION_PLANE_BEHAVIOR_IDS.join(', ')}.`,\n );\n }\n }\n\n private async derivePlaybookEligibilityRows(): Promise<readonly Record<string, unknown>[]> {\n const now = Date.now();\n if (this.eligibilityCache && now - this.eligibilityCachedAtMs < ELIGIBILITY_CACHE_TTL_MS) {\n return this.eligibilityCache.rows;\n }\n if (this.eligibilityInFlight) return this.eligibilityInFlight;\n\n const epochAtStart = this.eligibilityEpoch;\n const flight = (async () => {\n const board = await this.playbookRunService.listPlaybookEligibility();\n const computedAt = new Date().toISOString();\n const rows = this.stampIdentities(\n board.playbooks.map((playbook) => ({\n playbookRef: playbook.playbookRef,\n playbookVersion: playbook.playbookVersion,\n phase: String(board.phase),\n intent: playbook.intent,\n eligible: playbook.eligible,\n unmet: playbook.unmet,\n blockedOnlyBySequencing: playbook.blockedOnlyBySequencing,\n requiresElicitation: playbook.requiresElicitation,\n wouldReplace: playbook.wouldReplace,\n unlandableFamilies: playbook.unlandableFamilies,\n staleOutputs: playbook.staleOutputs,\n computedAt,\n })),\n 'workbenchPlaybookId',\n (row) => String(row.playbookRef),\n WorkbenchCreationPlaneBehavior.PLAYBOOK_ELIGIBILITY,\n );\n if (this.eligibilityEpoch === epochAtStart) {\n this.eligibilityCache = { rows, computedAt };\n this.eligibilityCachedAtMs = Date.now();\n }\n // An epoch that moved means something mutated mid-derivation: serve the computed rows to\n // THIS caller (they are at worst one mutation old, same as any read that finished a moment\n // earlier) but do not cache them — the next read recomputes against the post-mutation world.\n return rows;\n })();\n this.eligibilityInFlight = flight;\n try {\n return await flight;\n } finally {\n // Only clear OUR handle — an invalidation may have nulled it and a newer flight taken the slot.\n if (this.eligibilityInFlight === flight) this.eligibilityInFlight = null;\n }\n }\n\n private async deriveBuildPlanTaskRows(): Promise<readonly Record<string, unknown>[]> {\n const tasks = await this.buildDispatchService.describeBuildPlanBoard();\n return this.stampIdentities(\n tasks.map((task) => ({ ...task })),\n 'workbenchBuildPlanTaskId',\n (row) => String(row.taskRef),\n WorkbenchCreationPlaneBehavior.BUILD_PLAN_TASKS,\n );\n }\n\n private async deriveRunWriteRecordRows(): Promise<readonly Record<string, unknown>[]> {\n const records = await this.runWriteRegister.list();\n /*\n * The trace JOIN (Phase 4, R5): a runId is `<sessionId>-<playbookRef>-<ts>`, so the session is\n * resolved by longest-prefix match against the live session index. Listed ONCE per derivation\n * — a per-record listing would re-read the directory N times for one answer. NULL when nothing\n * matches: the register legitimately outlives its trace directory, and a dangling reference\n * would render as a broken link.\n *\n * Resolved against the UNBOUNDED id listing, not the display-limited summaries: the join is a\n * correctness question and must not lose links for records older than the newest\n * TRACE_SESSION_LIMIT sessions (completion-review finding 11a). The bound stays on the\n * trace-sessions ROWS below, where it is a display decision.\n */\n const sessionIdsLongestFirst = [...await this.executionTraceReadService.listSessionIds()]\n .sort((a, b) => b.length - a.length);\n return this.stampIdentities(\n records.map((record) => {\n const sessionId = sessionIdsLongestFirst.find((candidate) => record.runId.startsWith(`${candidate}-`));\n return {\n runId: record.runId,\n playbookRef: record.playbookRef,\n /*\n * The join keys, SANITIZED so values match the target rows' addressable ids — the same\n * identity rule every creation-plane row is addressed by.\n */\n workbenchPlaybookId: sanitizeWorkbenchCreationPlaneIdentity(record.playbookRef),\n workbenchTraceSessionId: sessionId ? sanitizeWorkbenchCreationPlaneIdentity(sessionId) : null,\n at: record.at,\n /*\n * Pre-image BYTES stay behind: `previousContent` belongs to the revert mechanism, and a\n * LIST carrying every pre-image would ship the working tree's history on every render.\n */\n files: record.files.map((file) => ({ path: file.path, existedBefore: file.existedBefore })),\n fileCount: record.files.length,\n };\n }),\n 'workbenchRunWriteRecordId',\n (row) => String(row.runId),\n WorkbenchCreationPlaneBehavior.RUN_WRITE_RECORDS,\n );\n }\n\n private async deriveTraceSessionRows(): Promise<readonly Record<string, unknown>[]> {\n const sessions = await this.executionTraceReadService.listSessions(TRACE_SESSION_LIMIT);\n return this.stampIdentities(\n sessions.map((session) => ({\n sessionId: session.sessionId,\n startedAt: session.startedAt,\n label: session.label,\n eventCount: session.eventCount,\n stepCount: session.stepCount,\n })),\n 'workbenchTraceSessionId',\n (row) => String(row.sessionId),\n WorkbenchCreationPlaneBehavior.TRACE_SESSIONS,\n );\n }\n\n private stampIdentities(\n rows: readonly Record<string, unknown>[],\n fieldIdentifier: string,\n businessKey: (row: Record<string, unknown>) => string,\n behavior: WorkbenchCreationPlaneBehavior,\n ): readonly Record<string, unknown>[] {\n const seen = new Map<string, string>();\n return rows.map((row) => {\n const raw = businessKey(row);\n const identity = sanitizeCreationPlaneIdentity(raw);\n const previous = seen.get(identity);\n if (previous !== undefined && previous !== raw) {\n throw new Error(\n `Creation-plane behavior '${behavior}' sanitized two distinct keys ('${previous}', '${raw}') to one `\n + `identity '${identity}'. Served, READ would return an arbitrary one of them; refused instead. `\n + 'Rename one of the colliding keys.',\n );\n }\n seen.set(identity, raw);\n return { ...row, [fieldIdentifier]: identity };\n });\n }\n}\n"]}
@@ -0,0 +1,123 @@
1
+ import type { AppConfigurationService, LoggerService, WebSocketService } from '@wildo-ai/saas-backend-lib';
2
+ import type { IntrospectionSourceWatcherCompanionService } from '../services/introspection-source-watcher.companion.service';
3
+ import type { IntrospectionResourceSourceCompanionService } from './introspection-resource-source.companion.service';
4
+ /**
5
+ * What one recompilation did to one resource's rows.
6
+ *
7
+ * Deliberately the same three verbs the engine's `ResourceAction` already publishes, because the
8
+ * consumer is `RMMWebSocketBridge` and it already knows how to apply exactly these.
9
+ */
10
+ interface ProjectedRowDiff {
11
+ readonly created: readonly Record<string, unknown>[];
12
+ readonly updated: readonly Record<string, unknown>[];
13
+ readonly deletedIds: readonly string[];
14
+ }
15
+ /**
16
+ * Publishes an introspection recompilation to the frontends watching it.
17
+ *
18
+ * ## What this joins, rather than builds
19
+ *
20
+ * Every part of the delivery already existed and none of it was reachable from here:
21
+ *
22
+ * - the companion MOUNTS the engine WebSocket server (`skipWebSocket: false`), and before this
23
+ * change held no reference to `WebSocketService` at all — it served a frontend and emitted nothing;
24
+ * - `sendResourceData` builds a sync-grade payload and validates the row against the resource's own
25
+ * canonical READ DTO before it leaves the process;
26
+ * - `RMMWebSocketBridge` receives that payload, re-validates it, diffs it FIELD BY FIELD against
27
+ * what the client holds, and applies the result with no refetch.
28
+ *
29
+ * So a changed row travels from a `tsc` emit to a repainted field without anybody asking for it, and
30
+ * the only new code is the diff below.
31
+ *
32
+ * ## Why the diff is computed here rather than pushed wholesale
33
+ *
34
+ * A recompilation of a 93-row derivation in which one row moved must not repaint 93 rows. The rows
35
+ * are keyed by the identity the binding already composes — the same value a READ addresses — so the
36
+ * three sets fall out of a map comparison, and a derivation that recompiled to a byte-identical
37
+ * payload never reaches this service at all (the state service reports it as unchanged).
38
+ *
39
+ * ## The `version` is the derivation's generation, and that is load-bearing
40
+ *
41
+ * `sendResourceData` refuses a non-DELETED sync payload with no version, and
42
+ * `ResourceMutationManager` DROPS any update whose version is not strictly greater than the one it
43
+ * holds. Introspection rows carry no `_version`, so the generation is supplied explicitly — and it
44
+ * is wall-clock-derived precisely so that a companion restart cannot hand an open browser tab a
45
+ * lower number than it already has, which would silently freeze that tab forever.
46
+ */
47
+ export declare class IntrospectionResourceNotifierCompanionService {
48
+ private readonly logger;
49
+ private readonly websocketService;
50
+ private readonly watcher;
51
+ private readonly resourceSource;
52
+ private readonly appConfigService;
53
+ private readonly logDebug;
54
+ private unsubscribe;
55
+ constructor(logger: LoggerService, websocketService: WebSocketService, watcher: IntrospectionSourceWatcherCompanionService, resourceSource: IntrospectionResourceSourceCompanionService, appConfigService: AppConfigurationService);
56
+ /** Begin publishing recompilations. Idempotent. */
57
+ start(): void;
58
+ stop(): void;
59
+ /** Publish every resource that projects the behavior this outcome recompiled. */
60
+ private publishOutcome;
61
+ /**
62
+ * Emit one sync-grade event per changed row, then one collection-level event.
63
+ *
64
+ * Both are needed and they serve different consumers. The per-row events reach a live
65
+ * `ResourceMutationManager` and repaint fields in place. The collection event reaches
66
+ * `WebSocketEventBridge`, which fans it out to `RESOURCE_REFRESH` and is what a LIST surface
67
+ * listens to — lists are served in `SUMMARY` mode and therefore cannot consume the RAW canonical
68
+ * replay a per-row sync carries.
69
+ */
70
+ private publishDiff;
71
+ /**
72
+ * Tell every subscriber of this resource's COLLECTION that its rows moved.
73
+ *
74
+ * ## Why the per-row lane is not enough, measured rather than assumed
75
+ *
76
+ * `sendResourceData` emits into the PER-ROW room, and a client is only in that room while a live
77
+ * `ResourceMutationManager` holds it — `RMMWebSocketBridge` claims row rooms from live RMM
78
+ * instances and destroys one 100 ms after unmount. The application-creation workbench instantiates
79
+ * NONE: its surfaces are read-only lists and a graph. So on 2026-09-03 a source edit produced a
80
+ * correct, versioned, single-row publication that a browser sitting on the affected surface
81
+ * received **zero** frames of (issue #283). The producer was right and the room was empty.
82
+ *
83
+ * The collection lane has a subscriber that already exists and is already confirmed. The same
84
+ * browser sends `resource:subscribe` for these resource types and the server answers
85
+ * `{"success": true}` — those are SCOPE rooms, which is a different family from the row room the
86
+ * push went to. Emitting here is what makes the two meet.
87
+ *
88
+ * ## Why the APPLICATION room, and only that one
89
+ *
90
+ * Every resource this notifier serves is APPLICATION-scoped by declaration — the workbench's
91
+ * introspection resources anchor `isPrimaryScope: true` on `CoreResourceType.APPLICATION`, and
92
+ * their configuration says so in prose: "APPLICATION rather than ORGANIZATIONS on purpose: these
93
+ * rows describe the application's own structure". They carry no tenant dimension, so there is no
94
+ * organization or user room they could honestly be addressed by — and this notifier, which runs
95
+ * off a filesystem watcher rather than a request, has no principal whose org or user it could
96
+ * borrow. `app` is the only room that is true of the data.
97
+ *
98
+ * That room is joinable and authorized because issue #247 made it so; before that a client could
99
+ * not subscribe to it at all.
100
+ *
101
+ * ## Notification-grade on purpose
102
+ *
103
+ * No `resourceData`. A collection-room payload cannot settle a list's membership, ordering or
104
+ * pagination for a client whose query it does not know, so it says only "this collection moved"
105
+ * and lets the surface re-read. The per-row sync emit above is unchanged and stays authoritative
106
+ * for a client that IS holding the row.
107
+ */
108
+ private emitCollectionRefresh;
109
+ private emitRow;
110
+ }
111
+ /**
112
+ * Compare two projections of one resource by the identity the binding composes.
113
+ *
114
+ * Exported for its own test: this is the whole of what decides whether a frontend repaints one row
115
+ * or ninety-three, and it is the only part of the notification path this repository owns.
116
+ *
117
+ * An `updated` row is one whose serialized content differs. Serializing is honest here for the same
118
+ * reason it is in the state service's payload comparison — a row is produced by one code path from
119
+ * one imported module graph, so key order is stable between two runs of the same bytes.
120
+ */
121
+ export declare function diffProjectedRows(before: readonly Record<string, unknown>[], after: readonly Record<string, unknown>[], identityField: string): ProjectedRowDiff;
122
+ export {};
123
+ //# sourceMappingURL=introspection-resource-notifier.companion.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspection-resource-notifier.companion.service.d.ts","sourceRoot":"","sources":["../../../../../../src/core/introspection/resources/introspection-resource-notifier.companion.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAY3G,OAAO,KAAK,EAAE,0CAA0C,EAAE,MAAM,4DAA4D,CAAC;AAC7H,OAAO,KAAK,EAAE,2CAA2C,EAAE,MAAM,mDAAmD,CAAC;AAErH;;;;;GAKG;AACH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