@wildo-ai/dev-companion 1.1.14 → 1.1.16

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 (191) hide show
  1. package/dist/esm/.tsbuildinfo +1 -1
  2. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts +233 -6
  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 +316 -13
  5. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js.map +1 -1
  6. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.d.ts +48 -2
  7. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.d.ts.map +1 -1
  8. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.js +41 -3
  9. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.js.map +1 -1
  10. package/dist/esm/claude-cli/models/isolated-recheck-interference.models.d.ts +68 -0
  11. package/dist/esm/claude-cli/models/isolated-recheck-interference.models.d.ts.map +1 -0
  12. package/dist/esm/claude-cli/models/isolated-recheck-interference.models.js +198 -0
  13. package/dist/esm/claude-cli/models/isolated-recheck-interference.models.js.map +1 -0
  14. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.d.ts +6 -0
  15. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.d.ts.map +1 -1
  16. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.js.map +1 -1
  17. package/dist/esm/claude-cli/models/verification-tool-availability.models.d.ts +19 -5
  18. package/dist/esm/claude-cli/models/verification-tool-availability.models.d.ts.map +1 -1
  19. package/dist/esm/claude-cli/models/verification-tool-availability.models.js +17 -5
  20. package/dist/esm/claude-cli/models/verification-tool-availability.models.js.map +1 -1
  21. package/dist/esm/claude-cli/models/workspace-path-claims.models.d.ts +138 -0
  22. package/dist/esm/claude-cli/models/workspace-path-claims.models.d.ts.map +1 -0
  23. package/dist/esm/claude-cli/models/workspace-path-claims.models.js +204 -0
  24. package/dist/esm/claude-cli/models/workspace-path-claims.models.js.map +1 -0
  25. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts +36 -1
  26. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts.map +1 -1
  27. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js +71 -16
  28. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js.map +1 -1
  29. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts +234 -9
  30. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts.map +1 -1
  31. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js +1073 -182
  32. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
  33. package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts +14 -0
  34. package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts.map +1 -1
  35. package/dist/esm/claude-cli/services/research-evidence-store.companion.js +35 -0
  36. package/dist/esm/claude-cli/services/research-evidence-store.companion.js.map +1 -1
  37. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.d.ts +36 -0
  38. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.d.ts.map +1 -0
  39. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.js +134 -0
  40. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.js.map +1 -0
  41. package/dist/esm/companion-api/controllers/companion.controller.d.ts.map +1 -1
  42. package/dist/esm/companion-api/controllers/companion.controller.js +7 -1
  43. package/dist/esm/companion-api/controllers/companion.controller.js.map +1 -1
  44. package/dist/esm/core/introspection/resources/creation-home-projection.companion.js +1 -1
  45. package/dist/esm/core/introspection/resources/creation-home-projection.companion.js.map +1 -1
  46. package/dist/esm/core/introspection/services/translation-placement.companion.service.d.ts +3 -2
  47. package/dist/esm/core/introspection/services/translation-placement.companion.service.d.ts.map +1 -1
  48. package/dist/esm/core/introspection/services/translation-placement.companion.service.js.map +1 -1
  49. package/dist/esm/core/introspection/subprocess/app-shell-placement-content.behavior.d.ts +13 -0
  50. package/dist/esm/core/introspection/subprocess/app-shell-placement-content.behavior.d.ts.map +1 -1
  51. package/dist/esm/core/introspection/subprocess/app-shell-placement-content.behavior.js +98 -16
  52. package/dist/esm/core/introspection/subprocess/app-shell-placement-content.behavior.js.map +1 -1
  53. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.d.ts.map +1 -1
  54. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js +24 -14
  55. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js.map +1 -1
  56. package/dist/esm/core/introspection/workspace-element-index.companion.d.ts +42 -0
  57. package/dist/esm/core/introspection/workspace-element-index.companion.d.ts.map +1 -1
  58. package/dist/esm/core/introspection/workspace-element-index.companion.js +42 -0
  59. package/dist/esm/core/introspection/workspace-element-index.companion.js.map +1 -1
  60. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts +53 -0
  61. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts.map +1 -1
  62. package/dist/esm/core/runtime/dev-compile-quiet.companion.js +119 -2
  63. package/dist/esm/core/runtime/dev-compile-quiet.companion.js.map +1 -1
  64. package/dist/esm/core/runtime/services/start-companion-application.service.d.ts.map +1 -1
  65. package/dist/esm/core/runtime/services/start-companion-application.service.js +13 -1
  66. package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
  67. package/dist/esm/core/runtime/utils/companion-platform-config.companion.d.ts +2 -2
  68. package/dist/esm/core/runtime/utils/companion-platform-config.companion.d.ts.map +1 -1
  69. package/dist/esm/core/runtime/utils/companion-platform-config.companion.js +6 -6
  70. package/dist/esm/core/runtime/utils/companion-platform-config.companion.js.map +1 -1
  71. package/dist/esm/email/services/email-template.companion.service.d.ts +5 -0
  72. package/dist/esm/email/services/email-template.companion.service.d.ts.map +1 -1
  73. package/dist/esm/email/services/email-template.companion.service.js +44 -11
  74. package/dist/esm/email/services/email-template.companion.service.js.map +1 -1
  75. package/dist/esm/email/utils/email-template-fs-discovery.utils.d.ts +26 -2
  76. package/dist/esm/email/utils/email-template-fs-discovery.utils.d.ts.map +1 -1
  77. package/dist/esm/email/utils/email-template-fs-discovery.utils.js +41 -2
  78. package/dist/esm/email/utils/email-template-fs-discovery.utils.js.map +1 -1
  79. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.d.ts +19 -0
  80. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.d.ts.map +1 -0
  81. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.js +171 -0
  82. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.js.map +1 -0
  83. package/dist/esm/email/utils/module-email-root.companion.utils.d.ts +75 -0
  84. package/dist/esm/email/utils/module-email-root.companion.utils.d.ts.map +1 -0
  85. package/dist/esm/email/utils/module-email-root.companion.utils.js +162 -0
  86. package/dist/esm/email/utils/module-email-root.companion.utils.js.map +1 -0
  87. package/dist/esm/expert-personas/services/expert-persona.companion.service.d.ts +21 -1
  88. package/dist/esm/expert-personas/services/expert-persona.companion.service.d.ts.map +1 -1
  89. package/dist/esm/expert-personas/services/expert-persona.companion.service.js +35 -3
  90. package/dist/esm/expert-personas/services/expert-persona.companion.service.js.map +1 -1
  91. package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.d.ts +62 -0
  92. package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.d.ts.map +1 -0
  93. package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.js +62 -0
  94. package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.en.js.map +1 -0
  95. package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.d.ts +62 -0
  96. package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.d.ts.map +1 -0
  97. package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.js +62 -0
  98. package/dist/esm/i18n/components/APP_LAYOUTS_AGENT_ACTIVITY_SETTINGS.fr.js.map +1 -0
  99. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.d.ts +1 -0
  100. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.d.ts.map +1 -1
  101. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.js +1 -0
  102. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.js.map +1 -1
  103. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.d.ts +1 -0
  104. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.d.ts.map +1 -1
  105. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.js +1 -0
  106. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.js.map +1 -1
  107. package/dist/esm/i18n/resources/workbenchAspects.en.d.ts.map +1 -1
  108. package/dist/esm/i18n/resources/workbenchAspects.en.js +4 -0
  109. package/dist/esm/i18n/resources/workbenchAspects.en.js.map +1 -1
  110. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +35 -0
  111. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -1
  112. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +12 -0
  113. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -1
  114. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts +536 -531
  115. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts.map +1 -1
  116. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js +536 -531
  117. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js.map +1 -1
  118. package/dist/esm/i18n/system_enums/workbench-build.en.d.ts +3 -3
  119. package/dist/esm/i18n/system_enums/workbench-build.en.js +3 -3
  120. package/dist/esm/i18n/system_enums/workbench-build.en.js.map +1 -1
  121. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.d.ts.map +1 -1
  122. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.js +7 -3
  123. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.js.map +1 -1
  124. package/dist/esm/meta-workflows/models/carried-verification-failure.models.d.ts +23 -0
  125. package/dist/esm/meta-workflows/models/carried-verification-failure.models.d.ts.map +1 -1
  126. package/dist/esm/meta-workflows/models/carried-verification-failure.models.js +14 -0
  127. package/dist/esm/meta-workflows/models/carried-verification-failure.models.js.map +1 -1
  128. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.d.ts +21 -1
  129. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.d.ts.map +1 -1
  130. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.js +117 -3
  131. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.js.map +1 -1
  132. package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.d.ts +5 -0
  133. package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.d.ts.map +1 -1
  134. package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.js +22 -1
  135. package/dist/esm/meta-workflows/services/application-assembly-checks.companion.utils.js.map +1 -1
  136. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +98 -24
  137. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
  138. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +439 -93
  139. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
  140. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts +21 -8
  141. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts.map +1 -1
  142. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js +74 -12
  143. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js.map +1 -1
  144. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts +47 -1
  145. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts.map +1 -1
  146. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js +98 -9
  147. package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js.map +1 -1
  148. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts +39 -3
  149. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts.map +1 -1
  150. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js +224 -48
  151. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js.map +1 -1
  152. package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.d.ts +45 -0
  153. package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.d.ts.map +1 -1
  154. package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.js +74 -0
  155. package/dist/esm/meta-workflows/services/application-build-website-context.companion.service.js.map +1 -1
  156. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.d.ts +12 -0
  157. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.d.ts.map +1 -1
  158. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.js +30 -1
  159. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.js.map +1 -1
  160. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.d.ts.map +1 -1
  161. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js +21 -2
  162. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js.map +1 -1
  163. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +71 -5
  164. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts.map +1 -1
  165. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js +219 -17
  166. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
  167. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.d.ts +55 -1
  168. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.d.ts.map +1 -1
  169. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.js +157 -10
  170. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.js.map +1 -1
  171. package/dist/esm/meta-workflows/services/website-demo-facts.models.d.ts +19 -1
  172. package/dist/esm/meta-workflows/services/website-demo-facts.models.d.ts.map +1 -1
  173. package/dist/esm/meta-workflows/services/website-demo-facts.models.js +7 -5
  174. package/dist/esm/meta-workflows/services/website-demo-facts.models.js.map +1 -1
  175. package/dist/esm/module-layout/module-layout-convention.companion.d.ts +158 -0
  176. package/dist/esm/module-layout/module-layout-convention.companion.d.ts.map +1 -0
  177. package/dist/esm/module-layout/module-layout-convention.companion.js +272 -0
  178. package/dist/esm/module-layout/module-layout-convention.companion.js.map +1 -0
  179. package/dist/esm/module-layout/module-layout-inspection.companion.d.ts +42 -0
  180. package/dist/esm/module-layout/module-layout-inspection.companion.d.ts.map +1 -0
  181. package/dist/esm/module-layout/module-layout-inspection.companion.js +290 -0
  182. package/dist/esm/module-layout/module-layout-inspection.companion.js.map +1 -0
  183. package/dist/esm/module-layout/module-source-files.companion.d.ts +3 -0
  184. package/dist/esm/module-layout/module-source-files.companion.d.ts.map +1 -0
  185. package/dist/esm/module-layout/module-source-files.companion.js +45 -0
  186. package/dist/esm/module-layout/module-source-files.companion.js.map +1 -0
  187. package/dist/esm/technical-doc/services/technical-documentation-pilot.companion.service.d.ts +2 -0
  188. package/dist/esm/technical-doc/services/technical-documentation-pilot.companion.service.d.ts.map +1 -1
  189. package/dist/esm/technical-doc/services/technical-documentation-pilot.companion.service.js +3 -1
  190. package/dist/esm/technical-doc/services/technical-documentation-pilot.companion.service.js.map +1 -1
  191. package/package.json +17 -17
@@ -181,4 +181,46 @@ export interface WorkspaceRelatedResult {
181
181
  export declare function relatedWorkspaceResources(index: WorkspaceElementIndex, resourceType: string, options?: {
182
182
  readonly hops?: number;
183
183
  }): WorkspaceRelatedResult;
184
+ /**
185
+ * A neighbour whose relationships exceed this many is a HUB (#3891). Measured (#3891 review): in Wonder Todos the hubs are
186
+ * `organizations` 83, `applications` 72 and `users` 64, and the largest application resource is `todos` at 9; in Wonder
187
+ * Procurement 80 / 71 / 53 against `organizationUnits` 9. The threshold sits in that gap, so an application's own central
188
+ * resource (`todos`, which a task on its children uses) stays whole while the engine anchors become stubs.
189
+ */
190
+ export declare const NEIGHBOURHOOD_HUB_RELATIONSHIP_DEGREE = 32;
191
+ /**
192
+ * A hub neighbour as the brief carries it: what it is, its fields (a task showing or filtering by an assignee reads them,
193
+ * and they are small: `users` 2.3 KB), and how to ask for the rest. Its relationships and operations, the part that grows
194
+ * with its degree, are left to the `askFor` command, so the stub's size does not depend on how connected the hub is.
195
+ */
196
+ export interface NeighbourhoodHubStub {
197
+ readonly ref: string;
198
+ readonly resourceType: string;
199
+ readonly moduleId: string | null;
200
+ readonly purpose: string | null;
201
+ readonly fields: WorkspaceResourceView['fields'];
202
+ readonly hub: {
203
+ readonly relationshipCount: number;
204
+ readonly operationCount: number;
205
+ readonly askFor: string;
206
+ };
207
+ }
208
+ /**
209
+ * The one-hop neighbourhood as a CODING BRIEF carries it (#3891), from {@link relatedWorkspaceResources}' full answer.
210
+ *
211
+ * Measured on reference run 43691253927: the neighbourhood source cost $30.66 over 119 coding runs, and 85.7% of its size
212
+ * was `organizations` and `users`, 58.6% their own full relationship lists. So a HUB neighbour (more than
213
+ * {@link NEIGHBOURHOOD_HUB_RELATIONSHIP_DEGREE} relationships) keeps its fields and loses its relationships and operations;
214
+ * every other resource stays whole, its own edges included (a junction's edge to a third resource is what a task wiring it
215
+ * needs). Measured on Wonder Todos' held derivation: `todoLists` 93.2 KB → 36.2 KB, `todos` 104.4 → 47.5, the
216
+ * `todosRelationships` junction 62.7 → 27.1.
217
+ *
218
+ * The CLI's `wildo context workspace related` keeps the full answer: a person asking for it asked for everything.
219
+ */
220
+ export declare function neighbourhoodForCodingBrief(related: WorkspaceRelatedResult): {
221
+ readonly edges: readonly WorkspaceRelationshipView[];
222
+ readonly resources: readonly (WorkspaceResourceView | NeighbourhoodHubStub)[];
223
+ };
224
+ /** What the brief tells the agent about the neighbourhood's shape, stating the rule rather than naming resources (#3891 F4). */
225
+ export declare const TARGET_NEIGHBOURHOOD_NOTE: string;
184
226
  //# sourceMappingURL=workspace-element-index.companion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-element-index.companion.d.ts","sourceRoot":"","sources":["../../../../src/core/introspection/workspace-element-index.companion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,gDAAgD,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,mFAAmF;AACnF,oBAAY,yBAAyB;IACnC,mGAAmG;IACnG,GAAG,QAAQ;IACX,8EAA8E;IAC9E,GAAG,QAAQ;IACX,oEAAoE;IACpE,OAAO,YAAY;CACpB;AAED,6CAA6C;AAC7C,oBAAY,oBAAoB;IAC9B,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,YAAY,iBAAiB;CAC9B;AAED,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mFAAmF;IACnF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,6DAA6D;AAC7D,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM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UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,qBAAqB,EAC5B,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACvC,sBAAsB,CAsCxB"}
1
+ {"version":3,"file":"workspace-element-index.companion.d.ts","sourceRoot":"","sources":["../../../../src/core/introspection/workspace-element-index.companion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,gDAAgD,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,mFAAmF;AACnF,oBAAY,yBAAyB;IACnC,mGAAmG;IACnG,GAAG,QAAQ;IACX,8EAA8E;IAC9E,GAAG,QAAQ;IACX,oEAAoE;IACpE,OAAO,YAAY;CACpB;AAED,6CAA6C;AAC7C,oBAAY,oBAAoB;IAC9B,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,YAAY,iBAAiB;CAC9B;AAED,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mFAAmF;IACnF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,6DAA6D;AAC7D,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAA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C5B,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACvC,sBAAsB,CAsCxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,qCAAqC,KAAK,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACjD,QAAQ,CAAC,GAAG,EAAE;QAAE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAChH;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,sBAAsB,GAAG;IAC5E,QAAQ,CAAC,KAAK,EAAE,SAAS,yBAAyB,EAAE,CAAC;IACrD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,qBAAqB,GAAG,oBAAoB,CAAC,EAAE,CAAC;CAC/E,CAeA;AAED,gIAAgI;AAChI,eAAO,MAAM,yBAAyB,QAIoC,CAAC"}
@@ -308,4 +308,46 @@ export function relatedWorkspaceResources(index, resourceType, options = {}) {
308
308
  .filter((view) => view !== undefined);
309
309
  return { from: resourceType, edges: [...edges.values()], resources, unresolved: [...unresolved] };
310
310
  }
311
+ /**
312
+ * A neighbour whose relationships exceed this many is a HUB (#3891). Measured (#3891 review): in Wonder Todos the hubs are
313
+ * `organizations` 83, `applications` 72 and `users` 64, and the largest application resource is `todos` at 9; in Wonder
314
+ * Procurement 80 / 71 / 53 against `organizationUnits` 9. The threshold sits in that gap, so an application's own central
315
+ * resource (`todos`, which a task on its children uses) stays whole while the engine anchors become stubs.
316
+ */
317
+ export const NEIGHBOURHOOD_HUB_RELATIONSHIP_DEGREE = 32;
318
+ /**
319
+ * The one-hop neighbourhood as a CODING BRIEF carries it (#3891), from {@link relatedWorkspaceResources}' full answer.
320
+ *
321
+ * Measured on reference run 43691253927: the neighbourhood source cost $30.66 over 119 coding runs, and 85.7% of its size
322
+ * was `organizations` and `users`, 58.6% their own full relationship lists. So a HUB neighbour (more than
323
+ * {@link NEIGHBOURHOOD_HUB_RELATIONSHIP_DEGREE} relationships) keeps its fields and loses its relationships and operations;
324
+ * every other resource stays whole, its own edges included (a junction's edge to a third resource is what a task wiring it
325
+ * needs). Measured on Wonder Todos' held derivation: `todoLists` 93.2 KB → 36.2 KB, `todos` 104.4 → 47.5, the
326
+ * `todosRelationships` junction 62.7 → 27.1.
327
+ *
328
+ * The CLI's `wildo context workspace related` keeps the full answer: a person asking for it asked for everything.
329
+ */
330
+ export function neighbourhoodForCodingBrief(related) {
331
+ return {
332
+ edges: related.edges,
333
+ resources: related.resources.map((view) => {
334
+ if (view.resourceType === related.from || view.relationships.length <= NEIGHBOURHOOD_HUB_RELATIONSHIP_DEGREE)
335
+ return view;
336
+ return {
337
+ ref: view.ref,
338
+ resourceType: view.resourceType,
339
+ moduleId: view.moduleId,
340
+ purpose: view.purpose,
341
+ fields: view.fields,
342
+ hub: { relationshipCount: view.relationships.length, operationCount: view.operations.length, askFor: `wildo context workspace get ${view.resourceType}` },
343
+ };
344
+ }),
345
+ };
346
+ }
347
+ /** What the brief tells the agent about the neighbourhood's shape, stating the rule rather than naming resources (#3891 F4). */
348
+ export const TARGET_NEIGHBOURHOOD_NOTE = 'The target resource as it EXISTS today, with its fields, operations and relationships, plus the '
349
+ + `resources one hop away. A neighbour with more than ${NEIGHBOURHOOD_HUB_RELATIONSHIP_DEGREE} relationships is a \`hub\` (in practice the `
350
+ + 'engine anchors: users, organizations, applications): its fields are listed, its relationships and operations are not. Direction '
351
+ + 'matters: `foreignKeyHolderResourceType` says which side carries the key. Ask for more with `wildo context workspace get '
352
+ + '<resourceType>` or `wildo context workspace related <resourceType>`.';
311
353
  //# sourceMappingURL=workspace-element-index.companion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-element-index.companion.js","sourceRoot":"","sources":["../../../../src/core/introspection/workspace-element-index.companion.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,mFAAmF;AACnF,MAAM,CAAN,IAAY,yBAOX;AAPD,WAAY,yBAAyB;IACnC,mGAAmG;IACnG,wCAAW,CAAA;IACX,8EAA8E;IAC9E,wCAAW,CAAA;IACX,oEAAoE;IACpE,gDAAmB,CAAA;AACrB,CAAC,EAPW,yBAAyB,KAAzB,yBAAyB,QAOpC;AAED,6CAA6C;AAC7C,MAAM,CAAN,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,6CAAqB,CAAA;IACrB,uCAAe,CAAA;IACf,+CAAuB,CAAA;IACvB,qDAA6B,CAAA;AAC/B,CAAC,EALW,oBAAoB,KAApB,oBAAoB,QAK/B;AAoCD;;;;;;;;GAQG;AACH,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC,sBAAsB;AACtB,MAAM,UAAU,iBAAiB,CAAC,YAAoB,EAAE,SAAiB;IACvE,OAAO,GAAG,YAAY,GAAG,eAAe,GAAG,SAAS,EAAE,CAAC;AACzD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,YAAoB,EACpB,SAA8F;IAE9F,MAAM,OAAO,GAAG,SAAS,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,WAAW,EAAE,CAAC;IAClF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CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;gBACzE,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC;gBACnH,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;oBAAE,SAAS;gBACrC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;oBACpC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;oBAC1B,SAAS;gBACX,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBACvB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QACD,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM;IACnC,CAAC;IAED,MAAM,SAAS,GAAG,CAAC,GAAG,OAAO,CAAC;SAC3B,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;SACtD,MAAM,CAAC,CAAC,IAAI,EAAiC,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACvE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC;AACpG,CAAC","sourcesContent":["import type {\n DomainModelFieldRow,\n DomainModelOperationRow,\n DomainModelProjection,\n DomainModelRelationshipRow,\n DomainModelResourceRow,\n} from './subprocess/application-domain-model.behavior';\n\n/**\n * MAP / GET / RELATED over the application's OWN CODE TRUTH (#1437).\n *\n * The third knowledge slice of epic #1415, beside decided families (what the creation run decided,\n * #1416) and framework knowledge (the reusable how). Workspace truth is what the application's code\n * CURRENTLY IS — its resources, fields, relationships and operations — and every build task depends\n * on it.\n *\n * ## Why an index and not a filter on the derivation\n *\n * It could only be read whole. Of the pull door's behaviors, `resources-registry` answers 43 KB and\n * `resource-specifications` **227 KB** on the dogfood application, and no filter on the door reaches\n * a module, a resource, a field, a relationship or an operation. The one existing slice is\n * hand-coded — `buildContextSources` cuts one module's field names out of the registry, 8% of it,\n * with no relationships, operations or specifications, and `resourceRef` does not narrow it further.\n *\n * The narrowing is deliberately NOT a behavior input. `application-domain-model` costs ~35 s (it\n * materializes every factory and the specification overlay), and the introspection cache keys on\n * the behavior's INPUT — so a per-resource filter pushed into the derivation would make every\n * distinct question a fresh 35-second subprocess. One derivation, cached, sliced many times is the\n * only shape that is both cheap and consistent: two slices of one projection cannot disagree about\n * an application that is being edited underneath them.\n *\n * ## Pure, and that is what makes it testable\n *\n * Nothing here reads a file, spawns a child or knows what a companion is. It takes the projection\n * and answers three questions about it — the same separation `decided-aspect-index` has on the\n * decided side, and for the same reason: the interesting failures are in the slicing, not in the\n * plumbing that fetches the input.\n */\n\n/** What a caller asks for. One verb per question, named as the caller names it. */\nexport enum WorkspaceElementOperation {\n /** Every element of a kind, as `ref — one line`. The cheapest answer, and the one that orients. */\n MAP = 'map',\n /** One resource in full: its fields, its relationships and its operations. */\n GET = 'get',\n /** What a resource is CONNECTED to, following its relationships. */\n RELATED = 'related',\n}\n\n/** The element kinds a MAP can enumerate. */\nexport enum WorkspaceElementKind {\n RESOURCE = 'resource',\n FIELD = 'field',\n OPERATION = 'operation',\n RELATIONSHIP = 'relationship',\n}\n\n/** One MAP line: how to address the element, and one line saying what it is. */\nexport interface WorkspaceElementMapLine {\n readonly kind: WorkspaceElementKind;\n readonly ref: string;\n readonly label: string;\n /** The resource this element belongs to. Its own `resourceType` for a resource. */\n readonly resourceType: string;\n}\n\n/** What a relationship looks like once it is addressable. */\nexport interface WorkspaceRelationshipView {\n readonly ref: string;\n readonly from: string;\n readonly to: string;\n readonly nature: string;\n readonly cardinality: string;\n readonly foreignKeyField: string | null;\n /** Which side's rows CARRY the key — the direction an arrow points. */\n readonly foreignKeyHolderResourceType: string;\n readonly jointResourceType: string | null;\n readonly isDisabled: boolean;\n}\n\n/** One resource, in full. */\nexport interface WorkspaceResourceView {\n readonly ref: string;\n readonly resourceType: string;\n readonly moduleId: string | null;\n readonly purpose: string | null;\n readonly fields: readonly { readonly ref: string; readonly fieldName: string; readonly meaning: string | null }[];\n readonly operations: readonly { readonly ref: string; readonly operationIdentifier: string; readonly variantType: string | null; readonly variantKey: string | null; readonly purpose: string | null }[];\n readonly relationships: readonly WorkspaceRelationshipView[];\n}\n\n/**\n * The separator between a resource and what it owns.\n *\n * Three distinct ones rather than one, because a ref should say WHAT IT ADDRESSES without a kind\n * beside it: `todos.dueDate` is a field, `todos#read` is an operation, `todos~users~assignedToUserId`\n * is an edge. A single separator would make `todos.read` ambiguous between a field and an operation\n * on a resource that has both, and a reader resolving that ambiguity by trying one and then the\n * other is a reader the ref failed.\n */\nconst FIELD_SEPARATOR = '.';\nconst OPERATION_SEPARATOR = '#';\nconst RELATIONSHIP_SEPARATOR = '~';\n\n/** `todos.dueDate` */\nexport function workspaceFieldRef(resourceType: string, fieldName: string): string {\n return `${resourceType}${FIELD_SEPARATOR}${fieldName}`;\n}\n\n/**\n * `todos#read`, `todos#read@api_call`, `todos#read@api_call/admin`.\n *\n * The variant halves are appended only when they exist, so the common case — a resource's one\n * `read` — is addressed by the name a person would use. They matter: measured across the engine's\n * core map, 133 of 794 operations collide on `identifier × variantType` and are separated only by\n * `variantKey`, so a ref built from the pair alone would address several operations at once.\n */\nexport function workspaceOperationRef(\n resourceType: string,\n operation: Pick<DomainModelOperationRow, 'operationIdentifier' | 'variantType' | 'variantKey'>,\n): string {\n const variant = operation.variantType === null ? '' : `@${operation.variantType}`;\n const key = operation.variantKey === null ? '' : `/${operation.variantKey}`;\n return `${resourceType}${OPERATION_SEPARATOR}${operation.operationIdentifier}${variant}${key}`;\n}\n\n/**\n * A SHORT, readable ref for one relationship — the thing #1437 says relationships do not have.\n *\n * The projection's own `relationshipId` is total and deliberately unreadable: it joins twelve fields\n * with `|` and its docstring says it \"never becomes a URL path parameter\". That is right for an\n * identity a graph de-duplicates on, and useless as something an agent types.\n *\n * So this composes the pair with whatever DISCRIMINATES the edge — the foreign-key field, else the\n * junction resource of a many-to-many, else the nature. Those cover every edge in the dogfood\n * applications. Where two edges still collide, the caller appends an ordinal (see\n * {@link indexWorkspaceElements}), which keeps the ref total without making the common case\n * unreadable.\n *\n * The pair is NOT sorted: `resourceType1`/`resourceType2` carry the declaration's own direction, and\n * `foreignKeyHolderResourceType` beside it says which side holds the key. Sorting the pair would\n * make two edges that differ only in direction produce the same ref.\n */\nexport function workspaceRelationshipRefBase(relationship: DomainModelRelationshipRow): string {\n const discriminator = relationship.foreignKeyField ?? relationship.jointResourceType ?? relationship.nature;\n return [relationship.resourceType1, relationship.resourceType2, discriminator].join(RELATIONSHIP_SEPARATOR);\n}\n\n/** The whole index: every element addressable, and the rows behind each ref. */\nexport interface WorkspaceElementIndex {\n readonly resources: ReadonlyMap<string, DomainModelResourceRow>;\n /** Short relationship ref → the row, and the row's own `relationshipId` for the graph that needs it. */\n readonly relationships: ReadonlyMap<string, DomainModelRelationshipRow>;\n}\n\n/**\n * Index one projection so every element has a ref.\n *\n * Relationship refs are de-collided here rather than at each call site: the same edge rides on BOTH\n * resources it joins, so a ref computed per resource would give one edge two names. The projection's\n * `relationshipId` is what identifies it across those two appearances.\n */\nexport function indexWorkspaceElements(projection: DomainModelProjection): WorkspaceElementIndex {\n const resources = new Map<string, DomainModelResourceRow>();\n for (const resource of projection.domainResources) resources.set(resource.resourceType, resource);\n\n // Deduplicate by the projection's own identity: one edge appears on both endpoints' rows.\n const rowsByIdentity = new Map<string, DomainModelRelationshipRow>();\n for (const resource of projection.domainResources) {\n for (const relationship of resource.relationships) {\n if (!rowsByIdentity.has(relationship.relationshipId)) rowsByIdentity.set(relationship.relationshipId, relationship);\n }\n }\n\n /*\n * Sorted by the full identity before ordinals are assigned, so a colliding pair's suffixes are a\n * function of the edges themselves rather than of the order the projection happened to emit them.\n * Two reads of an unchanged application therefore produce the same refs.\n */\n const relationships = new Map<string, DomainModelRelationshipRow>();\n const seenBase = new Map<string, number>();\n for (const relationship of [...rowsByIdentity.values()].sort((left, right) => left.relationshipId.localeCompare(right.relationshipId))) {\n const base = workspaceRelationshipRefBase(relationship);\n const seen = seenBase.get(base) ?? 0;\n seenBase.set(base, seen + 1);\n relationships.set(seen === 0 ? base : `${base}${RELATIONSHIP_SEPARATOR}${seen + 1}`, relationship);\n }\n return { resources, relationships };\n}\n\n/** The authored `meaning` of a field, when its specification carries one. */\nfunction fieldMeaning(field: DomainModelFieldRow): string | null {\n const meaning = field.params?.['meaning'];\n return typeof meaning === 'string' && meaning.length > 0 ? meaning : null;\n}\n\n/** The authored `purpose` of an operation, when its specification carries one. */\nfunction operationPurpose(operation: DomainModelOperationRow): string | null {\n const purpose = operation.specification?.['purpose'];\n return typeof purpose === 'string' && purpose.length > 0 ? purpose : null;\n}\n\nfunction relationshipView(ref: string, relationship: DomainModelRelationshipRow): WorkspaceRelationshipView {\n return {\n ref,\n from: relationship.resourceType1,\n to: relationship.resourceType2,\n nature: relationship.nature,\n cardinality: `${relationship.cardinality1}-to-${relationship.cardinality2}`,\n foreignKeyField: relationship.foreignKeyField,\n foreignKeyHolderResourceType: relationship.foreignKeyHolderResourceType,\n jointResourceType: relationship.jointResourceType,\n isDisabled: relationship.isDisabled,\n };\n}\n\n/**\n * MAP — every element of the requested kinds as `ref — label`.\n *\n * The label is the AUTHORED prose where there is any: a resource's `purpose`, a field's `meaning`,\n * an operation's `purpose`. Where a specification says nothing, the label states the structural\n * fact instead and says nothing more — an invented sentence would read exactly like an authored one,\n * and the gap is what a reader should see.\n *\n * `resourceTypes` narrows the map to named resources; omitted means every resource, which is what a\n * caller orienting itself asks for and is still two orders of magnitude smaller than the projection.\n */\nexport function mapWorkspaceElements(\n index: WorkspaceElementIndex,\n request: { readonly kinds?: readonly WorkspaceElementKind[]; readonly resourceTypes?: readonly string[] } = {},\n): readonly WorkspaceElementMapLine[] {\n const kinds = new Set(request.kinds ?? [WorkspaceElementKind.RESOURCE]);\n const wanted = request.resourceTypes === undefined ? null : new Set(request.resourceTypes);\n const lines: WorkspaceElementMapLine[] = [];\n\n for (const resource of index.resources.values()) {\n if (wanted !== null && !wanted.has(resource.resourceType)) continue;\n if (kinds.has(WorkspaceElementKind.RESOURCE)) {\n lines.push({\n kind: WorkspaceElementKind.RESOURCE,\n ref: resource.resourceType,\n resourceType: resource.resourceType,\n label: resource.specification?.purpose\n ?? `${resource.fields.length} field(s), ${resource.operations.length} operation(s)${resource.moduleId === null ? ' — engine resource' : `, module \\`${resource.moduleId}\\``}`,\n });\n }\n if (kinds.has(WorkspaceElementKind.FIELD)) {\n for (const field of resource.fields) {\n lines.push({\n kind: WorkspaceElementKind.FIELD,\n ref: workspaceFieldRef(resource.resourceType, field.fieldName),\n resourceType: resource.resourceType,\n label: fieldMeaning(field) ?? String(field.derived?.['kind'] ?? 'field'),\n });\n }\n }\n if (kinds.has(WorkspaceElementKind.OPERATION)) {\n for (const operation of resource.operations) {\n lines.push({\n kind: WorkspaceElementKind.OPERATION,\n ref: workspaceOperationRef(resource.resourceType, operation),\n resourceType: resource.resourceType,\n label: operationPurpose(operation) ?? `${operation.operationIdentifier}${operation.isUnimplemented ? ' (declared, not implemented)' : ''}`,\n });\n }\n }\n }\n\n if (kinds.has(WorkspaceElementKind.RELATIONSHIP)) {\n for (const [ref, relationship] of index.relationships) {\n // An edge belongs to BOTH its endpoints, so a resource narrowing keeps it when either side matches.\n if (wanted !== null && !wanted.has(relationship.resourceType1) && !wanted.has(relationship.resourceType2)) continue;\n lines.push({\n kind: WorkspaceElementKind.RELATIONSHIP,\n ref,\n resourceType: relationship.resourceType1,\n label: `${relationship.resourceType1} ${relationship.cardinality1}-to-${relationship.cardinality2} ${relationship.resourceType2}`\n + ` (${relationship.nature}${relationship.foreignKeyField ? `, fk \\`${relationship.foreignKeyField}\\` on ${relationship.foreignKeyHolderResourceType}` : ''})`\n + (relationship.isDisabled ? ' — DISABLED' : ''),\n });\n }\n }\n return lines;\n}\n\n/**\n * GET — one resource in full, by ref.\n *\n * An unknown ref answers `undefined` rather than throwing: a caller that named a resource the\n * application does not have needs to be told that, and a refusal one layer up can say so with the\n * map beside it. Inventing an empty resource would be the worse answer — it reads as \"exists and\n * holds nothing\".\n */\nexport function getWorkspaceResource(index: WorkspaceElementIndex, resourceType: string): WorkspaceResourceView | undefined {\n const resource = index.resources.get(resourceType);\n if (resource === undefined) return undefined;\n const refByIdentity = new Map([...index.relationships].map(([ref, relationship]) => [relationship.relationshipId, ref]));\n return {\n ref: resource.resourceType,\n resourceType: resource.resourceType,\n moduleId: resource.moduleId,\n purpose: resource.specification?.purpose ?? null,\n fields: resource.fields.map((field) => ({\n ref: workspaceFieldRef(resource.resourceType, field.fieldName),\n fieldName: field.fieldName,\n meaning: fieldMeaning(field),\n })),\n operations: resource.operations.map((operation) => ({\n ref: workspaceOperationRef(resource.resourceType, operation),\n operationIdentifier: operation.operationIdentifier,\n variantType: operation.variantType,\n variantKey: operation.variantKey,\n purpose: operationPurpose(operation),\n })),\n relationships: resource.relationships.map((relationship) => relationshipView(\n refByIdentity.get(relationship.relationshipId) ?? workspaceRelationshipRefBase(relationship),\n relationship,\n )),\n };\n}\n\n/** What RELATED answers: the edges walked, and the resources they reached. */\nexport interface WorkspaceRelatedResult {\n readonly from: string;\n readonly edges: readonly WorkspaceRelationshipView[];\n readonly resources: readonly WorkspaceResourceView[];\n /** Named but not on record — an edge pointing at a resource the projection does not carry. */\n readonly unresolved: readonly string[];\n}\n\n/**\n * RELATED — what a resource is connected to, following its declared relationships.\n *\n * This is what replaces the coding floor's hand-cut module slice. A build task targets ONE resource,\n * and what it needs is that resource plus the ones its edges reach — which is neither \"the whole\n * registry\" nor \"everything in its module\": a module slice over-supplies the siblings a task never\n * touches and UNDER-supplies the engine resources its own foreign keys point at (`users`,\n * `organizations` — the scope anchors, and the most load-bearing edges a resource has).\n *\n * `hops` defaults to 1. Bounded rather than transitive-by-default because the relationship graph of\n * a real application is nearly connected through the scope anchors: two hops from any resource\n * reaches most of the application, which is the whole-registry answer with extra steps.\n *\n * A DISABLED edge is walked and reported as disabled rather than skipped. It is declared, a reader\n * asking what a resource is connected to should see it, and the view says `isDisabled` so nothing\n * mistakes it for a live one.\n */\nexport function relatedWorkspaceResources(\n index: WorkspaceElementIndex,\n resourceType: string,\n options: { readonly hops?: number } = {},\n): WorkspaceRelatedResult {\n const hops = Math.max(1, Math.trunc(options.hops ?? 1));\n const refByIdentity = new Map([...index.relationships].map(([ref, relationship]) => [relationship.relationshipId, ref]));\n const visited = new Set<string>([resourceType]);\n const edges = new Map<string, WorkspaceRelationshipView>();\n const unresolved = new Set<string>();\n\n let frontier: string[] = [resourceType];\n for (let hop = 0; hop < hops; hop += 1) {\n const next: string[] = [];\n for (const current of frontier) {\n const resource = index.resources.get(current);\n if (resource === undefined) {\n // Only reachable for the SEED: a neighbour is only ever added after its row is found.\n unresolved.add(current);\n continue;\n }\n for (const relationship of resource.relationships) {\n const ref = refByIdentity.get(relationship.relationshipId) ?? workspaceRelationshipRefBase(relationship);\n if (!edges.has(ref)) edges.set(ref, relationshipView(ref, relationship));\n const neighbour = relationship.resourceType1 === current ? relationship.resourceType2 : relationship.resourceType1;\n if (visited.has(neighbour)) continue;\n if (!index.resources.has(neighbour)) {\n unresolved.add(neighbour);\n continue;\n }\n visited.add(neighbour);\n next.push(neighbour);\n }\n }\n frontier = next;\n if (frontier.length === 0) break;\n }\n\n const resources = [...visited]\n .map((reached) => getWorkspaceResource(index, reached))\n .filter((view): view is WorkspaceResourceView => view !== undefined);\n return { from: resourceType, edges: [...edges.values()], resources, unresolved: [...unresolved] };\n}\n"]}
1
+ {"version":3,"file":"workspace-element-index.companion.js","sourceRoot":"","sources":["../../../../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/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,GAAG,EAAE,EAAE,iBAAiB,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,+BAA+B,IAAI,CAAC,YAAY,EAAE,EAAE;aAC1J,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC;AAED,gIAAgI;AAChI,MAAM,CAAC,MAAM,yBAAyB,GAAG,kGAAkG;MACvI,sDAAsD,qCAAqC,+CAA+C;MAC1I,kIAAkI;MAClI,0HAA0H;MAC1H,sEAAsE,CAAC","sourcesContent":["import type {\n DomainModelFieldRow,\n DomainModelOperationRow,\n DomainModelProjection,\n DomainModelRelationshipRow,\n DomainModelResourceRow,\n} from './subprocess/application-domain-model.behavior';\n\n/**\n * MAP / GET / RELATED over the application's OWN CODE TRUTH (#1437).\n *\n * The third knowledge slice of epic #1415, beside decided families (what the creation run decided,\n * #1416) and framework knowledge (the reusable how). Workspace truth is what the application's code\n * CURRENTLY IS — its resources, fields, relationships and operations — and every build task depends\n * on it.\n *\n * ## Why an index and not a filter on the derivation\n *\n * It could only be read whole. Of the pull door's behaviors, `resources-registry` answers 43 KB and\n * `resource-specifications` **227 KB** on the dogfood application, and no filter on the door reaches\n * a module, a resource, a field, a relationship or an operation. The one existing slice is\n * hand-coded — `buildContextSources` cuts one module's field names out of the registry, 8% of it,\n * with no relationships, operations or specifications, and `resourceRef` does not narrow it further.\n *\n * The narrowing is deliberately NOT a behavior input. `application-domain-model` costs ~35 s (it\n * materializes every factory and the specification overlay), and the introspection cache keys on\n * the behavior's INPUT — so a per-resource filter pushed into the derivation would make every\n * distinct question a fresh 35-second subprocess. One derivation, cached, sliced many times is the\n * only shape that is both cheap and consistent: two slices of one projection cannot disagree about\n * an application that is being edited underneath them.\n *\n * ## Pure, and that is what makes it testable\n *\n * Nothing here reads a file, spawns a child or knows what a companion is. It takes the projection\n * and answers three questions about it — the same separation `decided-aspect-index` has on the\n * decided side, and for the same reason: the interesting failures are in the slicing, not in the\n * plumbing that fetches the input.\n */\n\n/** What a caller asks for. One verb per question, named as the caller names it. */\nexport enum WorkspaceElementOperation {\n /** Every element of a kind, as `ref — one line`. The cheapest answer, and the one that orients. */\n MAP = 'map',\n /** One resource in full: its fields, its relationships and its operations. */\n GET = 'get',\n /** What a resource is CONNECTED to, following its relationships. */\n RELATED = 'related',\n}\n\n/** The element kinds a MAP can enumerate. */\nexport enum WorkspaceElementKind {\n RESOURCE = 'resource',\n FIELD = 'field',\n OPERATION = 'operation',\n RELATIONSHIP = 'relationship',\n}\n\n/** One MAP line: how to address the element, and one line saying what it is. */\nexport interface WorkspaceElementMapLine {\n readonly kind: WorkspaceElementKind;\n readonly ref: string;\n readonly label: string;\n /** The resource this element belongs to. Its own `resourceType` for a resource. */\n readonly resourceType: string;\n}\n\n/** What a relationship looks like once it is addressable. */\nexport interface WorkspaceRelationshipView {\n readonly ref: string;\n readonly from: string;\n readonly to: string;\n readonly nature: string;\n readonly cardinality: string;\n readonly foreignKeyField: string | null;\n /** Which side's rows CARRY the key — the direction an arrow points. */\n readonly foreignKeyHolderResourceType: string;\n readonly jointResourceType: string | null;\n readonly isDisabled: boolean;\n}\n\n/** One resource, in full. */\nexport interface WorkspaceResourceView {\n readonly ref: string;\n readonly resourceType: string;\n readonly moduleId: string | null;\n readonly purpose: string | null;\n readonly fields: readonly { readonly ref: string; readonly fieldName: string; readonly meaning: string | null }[];\n readonly operations: readonly { readonly ref: string; readonly operationIdentifier: string; readonly variantType: string | null; readonly variantKey: string | null; readonly purpose: string | null }[];\n readonly relationships: readonly WorkspaceRelationshipView[];\n}\n\n/**\n * The separator between a resource and what it owns.\n *\n * Three distinct ones rather than one, because a ref should say WHAT IT ADDRESSES without a kind\n * beside it: `todos.dueDate` is a field, `todos#read` is an operation, `todos~users~assignedToUserId`\n * is an edge. A single separator would make `todos.read` ambiguous between a field and an operation\n * on a resource that has both, and a reader resolving that ambiguity by trying one and then the\n * other is a reader the ref failed.\n */\nconst FIELD_SEPARATOR = '.';\nconst OPERATION_SEPARATOR = '#';\nconst RELATIONSHIP_SEPARATOR = '~';\n\n/** `todos.dueDate` */\nexport function workspaceFieldRef(resourceType: string, fieldName: string): string {\n return `${resourceType}${FIELD_SEPARATOR}${fieldName}`;\n}\n\n/**\n * `todos#read`, `todos#read@api_call`, `todos#read@api_call/admin`.\n *\n * The variant halves are appended only when they exist, so the common case — a resource's one\n * `read` — is addressed by the name a person would use. They matter: measured across the engine's\n * core map, 133 of 794 operations collide on `identifier × variantType` and are separated only by\n * `variantKey`, so a ref built from the pair alone would address several operations at once.\n */\nexport function workspaceOperationRef(\n resourceType: string,\n operation: Pick<DomainModelOperationRow, 'operationIdentifier' | 'variantType' | 'variantKey'>,\n): string {\n const variant = operation.variantType === null ? '' : `@${operation.variantType}`;\n const key = operation.variantKey === null ? '' : `/${operation.variantKey}`;\n return `${resourceType}${OPERATION_SEPARATOR}${operation.operationIdentifier}${variant}${key}`;\n}\n\n/**\n * A SHORT, readable ref for one relationship — the thing #1437 says relationships do not have.\n *\n * The projection's own `relationshipId` is total and deliberately unreadable: it joins twelve fields\n * with `|` and its docstring says it \"never becomes a URL path parameter\". That is right for an\n * identity a graph de-duplicates on, and useless as something an agent types.\n *\n * So this composes the pair with whatever DISCRIMINATES the edge — the foreign-key field, else the\n * junction resource of a many-to-many, else the nature. Those cover every edge in the dogfood\n * applications. Where two edges still collide, the caller appends an ordinal (see\n * {@link indexWorkspaceElements}), which keeps the ref total without making the common case\n * unreadable.\n *\n * The pair is NOT sorted: `resourceType1`/`resourceType2` carry the declaration's own direction, and\n * `foreignKeyHolderResourceType` beside it says which side holds the key. Sorting the pair would\n * make two edges that differ only in direction produce the same ref.\n */\nexport function workspaceRelationshipRefBase(relationship: DomainModelRelationshipRow): string {\n const discriminator = relationship.foreignKeyField ?? relationship.jointResourceType ?? relationship.nature;\n return [relationship.resourceType1, relationship.resourceType2, discriminator].join(RELATIONSHIP_SEPARATOR);\n}\n\n/** The whole index: every element addressable, and the rows behind each ref. */\nexport interface WorkspaceElementIndex {\n readonly resources: ReadonlyMap<string, DomainModelResourceRow>;\n /** Short relationship ref → the row, and the row's own `relationshipId` for the graph that needs it. */\n readonly relationships: ReadonlyMap<string, DomainModelRelationshipRow>;\n}\n\n/**\n * Index one projection so every element has a ref.\n *\n * Relationship refs are de-collided here rather than at each call site: the same edge rides on BOTH\n * resources it joins, so a ref computed per resource would give one edge two names. The projection's\n * `relationshipId` is what identifies it across those two appearances.\n */\nexport function indexWorkspaceElements(projection: DomainModelProjection): WorkspaceElementIndex {\n const resources = new Map<string, DomainModelResourceRow>();\n for (const resource of projection.domainResources) resources.set(resource.resourceType, resource);\n\n // Deduplicate by the projection's own identity: one edge appears on both endpoints' rows.\n const rowsByIdentity = new Map<string, DomainModelRelationshipRow>();\n for (const resource of projection.domainResources) {\n for (const relationship of resource.relationships) {\n if (!rowsByIdentity.has(relationship.relationshipId)) rowsByIdentity.set(relationship.relationshipId, relationship);\n }\n }\n\n /*\n * Sorted by the full identity before ordinals are assigned, so a colliding pair's suffixes are a\n * function of the edges themselves rather than of the order the projection happened to emit them.\n * Two reads of an unchanged application therefore produce the same refs.\n */\n const relationships = new Map<string, DomainModelRelationshipRow>();\n const seenBase = new Map<string, number>();\n for (const relationship of [...rowsByIdentity.values()].sort((left, right) => left.relationshipId.localeCompare(right.relationshipId))) {\n const base = workspaceRelationshipRefBase(relationship);\n const seen = seenBase.get(base) ?? 0;\n seenBase.set(base, seen + 1);\n relationships.set(seen === 0 ? base : `${base}${RELATIONSHIP_SEPARATOR}${seen + 1}`, relationship);\n }\n return { resources, relationships };\n}\n\n/** The authored `meaning` of a field, when its specification carries one. */\nfunction fieldMeaning(field: DomainModelFieldRow): string | null {\n const meaning = field.params?.['meaning'];\n return typeof meaning === 'string' && meaning.length > 0 ? meaning : null;\n}\n\n/** The authored `purpose` of an operation, when its specification carries one. */\nfunction operationPurpose(operation: DomainModelOperationRow): string | null {\n const purpose = operation.specification?.['purpose'];\n return typeof purpose === 'string' && purpose.length > 0 ? purpose : null;\n}\n\nfunction relationshipView(ref: string, relationship: DomainModelRelationshipRow): WorkspaceRelationshipView {\n return {\n ref,\n from: relationship.resourceType1,\n to: relationship.resourceType2,\n nature: relationship.nature,\n cardinality: `${relationship.cardinality1}-to-${relationship.cardinality2}`,\n foreignKeyField: relationship.foreignKeyField,\n foreignKeyHolderResourceType: relationship.foreignKeyHolderResourceType,\n jointResourceType: relationship.jointResourceType,\n isDisabled: relationship.isDisabled,\n };\n}\n\n/**\n * MAP — every element of the requested kinds as `ref — label`.\n *\n * The label is the AUTHORED prose where there is any: a resource's `purpose`, a field's `meaning`,\n * an operation's `purpose`. Where a specification says nothing, the label states the structural\n * fact instead and says nothing more — an invented sentence would read exactly like an authored one,\n * and the gap is what a reader should see.\n *\n * `resourceTypes` narrows the map to named resources; omitted means every resource, which is what a\n * caller orienting itself asks for and is still two orders of magnitude smaller than the projection.\n */\nexport function mapWorkspaceElements(\n index: WorkspaceElementIndex,\n request: { readonly kinds?: readonly WorkspaceElementKind[]; readonly resourceTypes?: readonly string[] } = {},\n): readonly WorkspaceElementMapLine[] {\n const kinds = new Set(request.kinds ?? [WorkspaceElementKind.RESOURCE]);\n const wanted = request.resourceTypes === undefined ? null : new Set(request.resourceTypes);\n const lines: WorkspaceElementMapLine[] = [];\n\n for (const resource of index.resources.values()) {\n if (wanted !== null && !wanted.has(resource.resourceType)) continue;\n if (kinds.has(WorkspaceElementKind.RESOURCE)) {\n lines.push({\n kind: WorkspaceElementKind.RESOURCE,\n ref: resource.resourceType,\n resourceType: resource.resourceType,\n label: resource.specification?.purpose\n ?? `${resource.fields.length} field(s), ${resource.operations.length} operation(s)${resource.moduleId === null ? ' — engine resource' : `, module \\`${resource.moduleId}\\``}`,\n });\n }\n if (kinds.has(WorkspaceElementKind.FIELD)) {\n for (const field of resource.fields) {\n lines.push({\n kind: WorkspaceElementKind.FIELD,\n ref: workspaceFieldRef(resource.resourceType, field.fieldName),\n resourceType: resource.resourceType,\n label: fieldMeaning(field) ?? String(field.derived?.['kind'] ?? 'field'),\n });\n }\n }\n if (kinds.has(WorkspaceElementKind.OPERATION)) {\n for (const operation of resource.operations) {\n lines.push({\n kind: WorkspaceElementKind.OPERATION,\n ref: workspaceOperationRef(resource.resourceType, operation),\n resourceType: resource.resourceType,\n label: operationPurpose(operation) ?? `${operation.operationIdentifier}${operation.isUnimplemented ? ' (declared, not implemented)' : ''}`,\n });\n }\n }\n }\n\n if (kinds.has(WorkspaceElementKind.RELATIONSHIP)) {\n for (const [ref, relationship] of index.relationships) {\n // An edge belongs to BOTH its endpoints, so a resource narrowing keeps it when either side matches.\n if (wanted !== null && !wanted.has(relationship.resourceType1) && !wanted.has(relationship.resourceType2)) continue;\n lines.push({\n kind: WorkspaceElementKind.RELATIONSHIP,\n ref,\n resourceType: relationship.resourceType1,\n label: `${relationship.resourceType1} ${relationship.cardinality1}-to-${relationship.cardinality2} ${relationship.resourceType2}`\n + ` (${relationship.nature}${relationship.foreignKeyField ? `, fk \\`${relationship.foreignKeyField}\\` on ${relationship.foreignKeyHolderResourceType}` : ''})`\n + (relationship.isDisabled ? ' — DISABLED' : ''),\n });\n }\n }\n return lines;\n}\n\n/**\n * GET — one resource in full, by ref.\n *\n * An unknown ref answers `undefined` rather than throwing: a caller that named a resource the\n * application does not have needs to be told that, and a refusal one layer up can say so with the\n * map beside it. Inventing an empty resource would be the worse answer — it reads as \"exists and\n * holds nothing\".\n */\nexport function getWorkspaceResource(index: WorkspaceElementIndex, resourceType: string): WorkspaceResourceView | undefined {\n const resource = index.resources.get(resourceType);\n if (resource === undefined) return undefined;\n const refByIdentity = new Map([...index.relationships].map(([ref, relationship]) => [relationship.relationshipId, ref]));\n return {\n ref: resource.resourceType,\n resourceType: resource.resourceType,\n moduleId: resource.moduleId,\n purpose: resource.specification?.purpose ?? null,\n fields: resource.fields.map((field) => ({\n ref: workspaceFieldRef(resource.resourceType, field.fieldName),\n fieldName: field.fieldName,\n meaning: fieldMeaning(field),\n })),\n operations: resource.operations.map((operation) => ({\n ref: workspaceOperationRef(resource.resourceType, operation),\n operationIdentifier: operation.operationIdentifier,\n variantType: operation.variantType,\n variantKey: operation.variantKey,\n purpose: operationPurpose(operation),\n })),\n relationships: resource.relationships.map((relationship) => relationshipView(\n refByIdentity.get(relationship.relationshipId) ?? workspaceRelationshipRefBase(relationship),\n relationship,\n )),\n };\n}\n\n/** What RELATED answers: the edges walked, and the resources they reached. */\nexport interface WorkspaceRelatedResult {\n readonly from: string;\n readonly edges: readonly WorkspaceRelationshipView[];\n readonly resources: readonly WorkspaceResourceView[];\n /** Named but not on record — an edge pointing at a resource the projection does not carry. */\n readonly unresolved: readonly string[];\n}\n\n/**\n * RELATED — what a resource is connected to, following its declared relationships.\n *\n * This is what replaces the coding floor's hand-cut module slice. A build task targets ONE resource,\n * and what it needs is that resource plus the ones its edges reach — which is neither \"the whole\n * registry\" nor \"everything in its module\": a module slice over-supplies the siblings a task never\n * touches and UNDER-supplies the engine resources its own foreign keys point at (`users`,\n * `organizations` — the scope anchors, and the most load-bearing edges a resource has).\n *\n * `hops` defaults to 1. Bounded rather than transitive-by-default because the relationship graph of\n * a real application is nearly connected through the scope anchors: two hops from any resource\n * reaches most of the application, which is the whole-registry answer with extra steps.\n *\n * A DISABLED edge is walked and reported as disabled rather than skipped. It is declared, a reader\n * asking what a resource is connected to should see it, and the view says `isDisabled` so nothing\n * mistakes it for a live one.\n */\nexport function relatedWorkspaceResources(\n index: WorkspaceElementIndex,\n resourceType: string,\n options: { readonly hops?: number } = {},\n): WorkspaceRelatedResult {\n const hops = Math.max(1, Math.trunc(options.hops ?? 1));\n const refByIdentity = new Map([...index.relationships].map(([ref, relationship]) => [relationship.relationshipId, ref]));\n const visited = new Set<string>([resourceType]);\n const edges = new Map<string, WorkspaceRelationshipView>();\n const unresolved = new Set<string>();\n\n let frontier: string[] = [resourceType];\n for (let hop = 0; hop < hops; hop += 1) {\n const next: string[] = [];\n for (const current of frontier) {\n const resource = index.resources.get(current);\n if (resource === undefined) {\n // Only reachable for the SEED: a neighbour is only ever added after its row is found.\n unresolved.add(current);\n continue;\n }\n for (const relationship of resource.relationships) {\n const ref = refByIdentity.get(relationship.relationshipId) ?? workspaceRelationshipRefBase(relationship);\n if (!edges.has(ref)) edges.set(ref, relationshipView(ref, relationship));\n const neighbour = relationship.resourceType1 === current ? relationship.resourceType2 : relationship.resourceType1;\n if (visited.has(neighbour)) continue;\n if (!index.resources.has(neighbour)) {\n unresolved.add(neighbour);\n continue;\n }\n visited.add(neighbour);\n next.push(neighbour);\n }\n }\n frontier = next;\n if (frontier.length === 0) break;\n }\n\n const resources = [...visited]\n .map((reached) => getWorkspaceResource(index, reached))\n .filter((view): view is WorkspaceResourceView => view !== undefined);\n return { from: resourceType, edges: [...edges.values()], resources, unresolved: [...unresolved] };\n}\n\n/**\n * A neighbour whose relationships exceed this many is a HUB (#3891). Measured (#3891 review): in Wonder Todos the hubs are\n * `organizations` 83, `applications` 72 and `users` 64, and the largest application resource is `todos` at 9; in Wonder\n * Procurement 80 / 71 / 53 against `organizationUnits` 9. The threshold sits in that gap, so an application's own central\n * resource (`todos`, which a task on its children uses) stays whole while the engine anchors become stubs.\n */\nexport const NEIGHBOURHOOD_HUB_RELATIONSHIP_DEGREE = 32;\n\n/**\n * A hub neighbour as the brief carries it: what it is, its fields (a task showing or filtering by an assignee reads them,\n * and they are small: `users` 2.3 KB), and how to ask for the rest. Its relationships and operations, the part that grows\n * with its degree, are left to the `askFor` command, so the stub's size does not depend on how connected the hub is.\n */\nexport interface NeighbourhoodHubStub {\n readonly ref: string;\n readonly resourceType: string;\n readonly moduleId: string | null;\n readonly purpose: string | null;\n readonly fields: WorkspaceResourceView['fields'];\n readonly hub: { readonly relationshipCount: number; readonly operationCount: number; readonly askFor: string };\n}\n\n/**\n * The one-hop neighbourhood as a CODING BRIEF carries it (#3891), from {@link relatedWorkspaceResources}' full answer.\n *\n * Measured on reference run 43691253927: the neighbourhood source cost $30.66 over 119 coding runs, and 85.7% of its size\n * was `organizations` and `users`, 58.6% their own full relationship lists. So a HUB neighbour (more than\n * {@link NEIGHBOURHOOD_HUB_RELATIONSHIP_DEGREE} relationships) keeps its fields and loses its relationships and operations;\n * every other resource stays whole, its own edges included (a junction's edge to a third resource is what a task wiring it\n * needs). Measured on Wonder Todos' held derivation: `todoLists` 93.2 KB → 36.2 KB, `todos` 104.4 → 47.5, the\n * `todosRelationships` junction 62.7 → 27.1.\n *\n * The CLI's `wildo context workspace related` keeps the full answer: a person asking for it asked for everything.\n */\nexport function neighbourhoodForCodingBrief(related: WorkspaceRelatedResult): {\n readonly edges: readonly WorkspaceRelationshipView[];\n readonly resources: readonly (WorkspaceResourceView | NeighbourhoodHubStub)[];\n} {\n return {\n edges: related.edges,\n resources: related.resources.map((view) => {\n if (view.resourceType === related.from || view.relationships.length <= NEIGHBOURHOOD_HUB_RELATIONSHIP_DEGREE) return view;\n return {\n ref: view.ref,\n resourceType: view.resourceType,\n moduleId: view.moduleId,\n purpose: view.purpose,\n fields: view.fields,\n hub: { relationshipCount: view.relationships.length, operationCount: view.operations.length, askFor: `wildo context workspace get ${view.resourceType}` },\n };\n }),\n };\n}\n\n/** What the brief tells the agent about the neighbourhood's shape, stating the rule rather than naming resources (#3891 F4). */\nexport const TARGET_NEIGHBOURHOOD_NOTE = 'The target resource as it EXISTS today, with its fields, operations and relationships, plus the '\n + `resources one hop away. A neighbour with more than ${NEIGHBOURHOOD_HUB_RELATIONSHIP_DEGREE} relationships is a \\`hub\\` (in practice the `\n + 'engine anchors: users, organizations, applications): its fields are listed, its relationships and operations are not. Direction '\n + 'matters: `foreignKeyHolderResourceType` says which side carries the key. Ask for more with `wildo context workspace get '\n + '<resourceType>` or `wildo context workspace related <resourceType>`.';\n"]}
@@ -96,6 +96,59 @@ export declare function waitForApplicationPackagesPublished(input: {
96
96
  readonly published: boolean;
97
97
  readonly unpublished: readonly UnpublishedApplicationPackage[];
98
98
  }>;
99
+ /**
100
+ * Whether one application package's COMPILED output is current with its sources (run 43961156770). The verifier asks it
101
+ * after a check could not be asked because that package's compiled model is behind ({@link waitForApplicationPackageCompileCurrent}),
102
+ * and the hold such a check opens, and the task it withholds, ask it as their free probe.
103
+ *
104
+ * The SAME rule `wildo config check-resources` and `wildo db diff` refuse by (`assessCompiledModelCurrency` in the CLI's
105
+ * `db-schema-plan.utils.ts`, which the companion cannot import), so the companion never waits for, or releases on, a
106
+ * currency the CLI would still refuse: the newest `.ts`/`.tsx` under `<package>/src` (any directory named `dist` or
107
+ * `__tests__`, dotted or `node_modules` skipped; co-located test files COUNT, as the CLI counts them) against the newest
108
+ * `.js`/`.d.ts` under `<package>/dist`; when `dist` is older, the compiler's record (`.wildo-saas/runtime-signals/compilers/`,
109
+ * matched on `packageRoot`, read with the observer's own reader) is current when its last success covers that source and
110
+ * no failure came after it. No compiled output at all is behind whatever the record says. The walk's parameters are pinned
111
+ * to the CLI's source by a parity test; the CLI stays the judge, since a check is only ever asked again, never assumed.
112
+ */
113
+ export declare enum ApplicationPackageCompileCurrency {
114
+ /** The compiled output, or the compiler's last success, covers the newest source, and nothing failed since. */
115
+ CURRENT = "current",
116
+ /** A source is newer than the compiled output and the last successful compile, or a compile failed after it. */
117
+ BEHIND = "behind",
118
+ /**
119
+ * Behind, and its live compiler already started on the newest source and FAILED: no wait clears it, only an edit does
120
+ * (the CLI says the same: "waiting will not clear this one").
121
+ */
122
+ FAILED_ON_CURRENT_SOURCES = "failed-on-current-sources",
123
+ /** Behind, and no compiler record names this package: nothing publishes its build, so there is nothing to wait for. */
124
+ UNOBSERVED = "unobserved"
125
+ }
126
+ /** One reading of {@link ApplicationPackageCompileCurrency}, with the compiler's last success the probes compare against. */
127
+ export interface ApplicationPackageCompileReading {
128
+ readonly currency: ApplicationPackageCompileCurrency;
129
+ /** The compiler record's last successful compile, or `null` when it records none or no record names the package. */
130
+ readonly lastSuccessfulCompileMs: number | null;
131
+ }
132
+ /** See {@link ApplicationPackageCompileCurrency}. `packageDirectory` is relative to the application root (`shared-lib`). */
133
+ export declare function readApplicationPackageCompileCurrency(saasRoot: string, packageDirectory: string, nowMs?: number): ApplicationPackageCompileReading;
134
+ /**
135
+ * Wait (bounded) until one application package's compiled output is current with its sources (run 43961156770). Returns
136
+ * at once when the package is current, when no compiler record names it (nothing will publish it), or when its compiler
137
+ * already failed on the current sources (no wait clears that). Otherwise polls until it is current or the bound passes.
138
+ *
139
+ * A record whose producer is gone is still waited on: a compile watcher that died is respawned (ff6192443), and the
140
+ * respawned compiler writes the same record. `onWait` is called once, when a wait actually begins.
141
+ */
142
+ export declare function waitForApplicationPackageCompileCurrent(input: {
143
+ readonly saasRoot: string;
144
+ readonly packageDirectory: string;
145
+ readonly maximumWaitMs: number;
146
+ readonly pollIntervalMs: number;
147
+ readonly onWait?: (currency: ApplicationPackageCompileCurrency) => void;
148
+ }): Promise<{
149
+ readonly waitedMs: number;
150
+ readonly currency: ApplicationPackageCompileCurrency;
151
+ }>;
99
152
  /**
100
153
  * Did a read of the application's specifications fail on a package that was not COMPILED yet (#3212)?
101
154
  *
@@ -1 +1 @@
1
- {"version":3,"file":"dev-compile-quiet.companion.d.ts","sourceRoot":"","sources":["../../../../src/core/runtime/dev-compile-quiet.companion.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,2BAA2B,EAEjC,MAAM,uBAAuB,CAAC;AAM/B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,mFAAmF;IACnF,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAID,wBAAgB,mBAAmB,CAAC,uBAAuB,EAAE,MAAM,GAAG,IAAI,GAA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AE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAIzH;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACpD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;QAAE,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;YAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CACzG,GAAG,OAAO,CAKV"}
@@ -4,8 +4,8 @@ import { LocalDevCompileState } from '@wildo-ai/platform-core-shared';
4
4
  import { redactModelVendorText } from '@wildo-ai/saas-backend-lib';
5
5
  import { classifyModelProviderAccountRefusal, classifyModelProviderAccountRefusalText, parseModelProviderAccountRefusalDescription, } from '@wildo-ai/saas-models';
6
6
  import { compileObservationsDirectory, findNewestProgramSource, isLiveCompileObservation, readCompileObservation } from '@wildo-ai/platform-core-shared/dev-runtime';
7
- import { existsSync, readdirSync, readFileSync } from 'node:fs';
8
- import { join } from 'node:path';
7
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
8
+ import { join, resolve } from 'node:path';
9
9
  import { classifyNetworkEnvironmentFailure } from './network-environment-failure.companion.js';
10
10
  const DEV_COMPILE_STATUS_RELATIVE_PATH = '.wildo-runtime-signals/dev-compile-status.json';
11
11
  export function readDevCompileChurn(frameworkRepositoryRoot) {
@@ -136,6 +136,123 @@ export async function waitForApplicationPackagesPublished(input) {
136
136
  }
137
137
  return { waitedMs: Date.now() - startedAt, published: false, unpublished };
138
138
  }
139
+ /**
140
+ * Whether one application package's COMPILED output is current with its sources (run 43961156770). The verifier asks it
141
+ * after a check could not be asked because that package's compiled model is behind ({@link waitForApplicationPackageCompileCurrent}),
142
+ * and the hold such a check opens, and the task it withholds, ask it as their free probe.
143
+ *
144
+ * The SAME rule `wildo config check-resources` and `wildo db diff` refuse by (`assessCompiledModelCurrency` in the CLI's
145
+ * `db-schema-plan.utils.ts`, which the companion cannot import), so the companion never waits for, or releases on, a
146
+ * currency the CLI would still refuse: the newest `.ts`/`.tsx` under `<package>/src` (any directory named `dist` or
147
+ * `__tests__`, dotted or `node_modules` skipped; co-located test files COUNT, as the CLI counts them) against the newest
148
+ * `.js`/`.d.ts` under `<package>/dist`; when `dist` is older, the compiler's record (`.wildo-saas/runtime-signals/compilers/`,
149
+ * matched on `packageRoot`, read with the observer's own reader) is current when its last success covers that source and
150
+ * no failure came after it. No compiled output at all is behind whatever the record says. The walk's parameters are pinned
151
+ * to the CLI's source by a parity test; the CLI stays the judge, since a check is only ever asked again, never assumed.
152
+ */
153
+ export var ApplicationPackageCompileCurrency;
154
+ (function (ApplicationPackageCompileCurrency) {
155
+ /** The compiled output, or the compiler's last success, covers the newest source, and nothing failed since. */
156
+ ApplicationPackageCompileCurrency["CURRENT"] = "current";
157
+ /** A source is newer than the compiled output and the last successful compile, or a compile failed after it. */
158
+ ApplicationPackageCompileCurrency["BEHIND"] = "behind";
159
+ /**
160
+ * Behind, and its live compiler already started on the newest source and FAILED: no wait clears it, only an edit does
161
+ * (the CLI says the same: "waiting will not clear this one").
162
+ */
163
+ ApplicationPackageCompileCurrency["FAILED_ON_CURRENT_SOURCES"] = "failed-on-current-sources";
164
+ /** Behind, and no compiler record names this package: nothing publishes its build, so there is nothing to wait for. */
165
+ ApplicationPackageCompileCurrency["UNOBSERVED"] = "unobserved";
166
+ })(ApplicationPackageCompileCurrency || (ApplicationPackageCompileCurrency = {}));
167
+ /** Newest mtime of a file with one of `extensions` under `directory`, skipping what the CLI's walk skips; 0 when none. */
168
+ function newestCompiledModelMtimeMs(directory, extensions, skip) {
169
+ let newest = 0;
170
+ const walk = (current) => {
171
+ let entries;
172
+ try {
173
+ entries = readdirSync(current, { withFileTypes: true });
174
+ }
175
+ catch {
176
+ return;
177
+ }
178
+ for (const entry of entries) {
179
+ if (entry.name === 'node_modules' || entry.name.startsWith('.') || skip.includes(entry.name))
180
+ continue;
181
+ const path = join(current, entry.name);
182
+ if (entry.isDirectory()) {
183
+ walk(path);
184
+ continue;
185
+ }
186
+ if (!extensions.some((extension) => entry.name.endsWith(extension)))
187
+ continue;
188
+ try {
189
+ const { mtimeMs } = statSync(path);
190
+ if (mtimeMs > newest)
191
+ newest = mtimeMs;
192
+ }
193
+ catch {
194
+ // Removed mid-walk.
195
+ }
196
+ }
197
+ };
198
+ walk(directory);
199
+ return newest;
200
+ }
201
+ /** See {@link ApplicationPackageCompileCurrency}. `packageDirectory` is relative to the application root (`shared-lib`). */
202
+ export function readApplicationPackageCompileCurrency(saasRoot, packageDirectory, nowMs = Date.now()) {
203
+ const packageRoot = resolve(saasRoot, packageDirectory);
204
+ const directory = compileObservationsDirectory(saasRoot);
205
+ let entries = [];
206
+ try {
207
+ entries = readdirSync(directory).filter((name) => name.endsWith('.json'));
208
+ }
209
+ catch {
210
+ // No observer: the mtimes alone answer.
211
+ }
212
+ const record = entries.map((entry) => readCompileObservation(join(directory, entry)))
213
+ .find((candidate) => candidate !== undefined && resolve(candidate.packageRoot) === packageRoot);
214
+ const successMs = record?.lastSuccessfulCompileAt ? Date.parse(record.lastSuccessfulCompileAt) : null;
215
+ const reading = (currency) => ({ currency, lastSuccessfulCompileMs: successMs });
216
+ const newestSourceMs = newestCompiledModelMtimeMs(join(packageRoot, 'src'), ['.ts', '.tsx'], ['dist', '__tests__']);
217
+ if (newestSourceMs === 0)
218
+ return reading(ApplicationPackageCompileCurrency.CURRENT);
219
+ const newestCompiledMs = newestCompiledModelMtimeMs(join(packageRoot, 'dist'), ['.js', '.d.ts'], []);
220
+ if (newestCompiledMs >= newestSourceMs)
221
+ return reading(ApplicationPackageCompileCurrency.CURRENT);
222
+ if (record === undefined)
223
+ return reading(ApplicationPackageCompileCurrency.UNOBSERVED);
224
+ const failureMs = record.lastFailureAt ? Date.parse(record.lastFailureAt) : null;
225
+ const failedSinceSuccess = successMs !== null && failureMs !== null && failureMs > successMs;
226
+ if (newestCompiledMs > 0 && successMs !== null && successMs >= newestSourceMs && !failedSinceSuccess)
227
+ return reading(ApplicationPackageCompileCurrency.CURRENT);
228
+ const startedMs = record.lastCompilationStartedAt ? Date.parse(record.lastCompilationStartedAt) : null;
229
+ if (record.state === LocalDevCompileState.FAILED && isLiveCompileObservation(record, nowMs) && startedMs !== null && startedMs >= newestSourceMs) {
230
+ return reading(ApplicationPackageCompileCurrency.FAILED_ON_CURRENT_SOURCES);
231
+ }
232
+ return reading(ApplicationPackageCompileCurrency.BEHIND);
233
+ }
234
+ /**
235
+ * Wait (bounded) until one application package's compiled output is current with its sources (run 43961156770). Returns
236
+ * at once when the package is current, when no compiler record names it (nothing will publish it), or when its compiler
237
+ * already failed on the current sources (no wait clears that). Otherwise polls until it is current or the bound passes.
238
+ *
239
+ * A record whose producer is gone is still waited on: a compile watcher that died is respawned (ff6192443), and the
240
+ * respawned compiler writes the same record. `onWait` is called once, when a wait actually begins.
241
+ */
242
+ export async function waitForApplicationPackageCompileCurrent(input) {
243
+ const startedAt = Date.now();
244
+ let currency = readApplicationPackageCompileCurrency(input.saasRoot, input.packageDirectory).currency;
245
+ if (currency !== ApplicationPackageCompileCurrency.BEHIND)
246
+ return { waitedMs: 0, currency };
247
+ input.onWait?.(currency);
248
+ while (Date.now() - startedAt < input.maximumWaitMs) {
249
+ await new Promise((resolveWait) => setTimeout(resolveWait, input.pollIntervalMs));
250
+ currency = readApplicationPackageCompileCurrency(input.saasRoot, input.packageDirectory).currency;
251
+ if (currency !== ApplicationPackageCompileCurrency.BEHIND)
252
+ break;
253
+ }
254
+ return { waitedMs: Date.now() - startedAt, currency };
255
+ }
139
256
  /**
140
257
  * Did a read of the application's specifications fail on a package that was not COMPILED yet (#3212)?
141
258
  *