@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
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Where a business module's email templates live, read from the module's own source (#3904).
3
+ *
4
+ * The convention is `backend-api/src/modules/<module>/emails/`, registered by `emails/module-email-template-definitions.ts`
5
+ * scanning `system/` and `resources/` (`MODULE_EMAIL_DIRECTORY` in `module-layout-convention.companion.ts`, the one source
6
+ * the build lane's `check:module-layout` also reads). On reference run 43691253927 the `enquiries` module's templates were
7
+ * registered from `email/email-template-definitions.ts` instead; the companion wrote its generated template into
8
+ * `emails/`, where nothing registered it, and the preview's import failed with `ERR_MODULE_NOT_FOUND`.
9
+ *
10
+ * Since Paul's decision of 2026-11-17 the build PREVENTS that placement (`check:module-layout` fails the run that made it,
11
+ * with the move that corrects it). This file stays the READ path, and it is honest about what it could read:
12
+ *
13
+ * - the email root is the directory of the file that CALLS `scanEmailTemplateDirectory`, read from its syntax tree, so a
14
+ * call inside a comment does not count and an aliased or namespace import does (#3904 review F6). Several such files
15
+ * (unusual): the one under `emails/` wins, then the shallowest. None: the convention, reported `discovered: false`;
16
+ * - which directory each family of refs is registered from is read from each call's `subdir` and `keyFromPath` when they
17
+ * are literals (review F5): `{ 'email.': 'resources', 'system.': 'system' }` for the conventional file. A call whose
18
+ * arguments are not literals is counted as undetermined, never assumed to be the standard layout;
19
+ * - {@link moduleEmailTemplatePlacement} turns both into what the generation step may write (review F2): a module that
20
+ * registers templates and has no readable scanner is UNDETERMINED, and the generation step writes nothing for it
21
+ * rather than writing where nothing registers.
22
+ *
23
+ * Read from source, never from `dist`, so a module whose definitions moved is read where it is now.
24
+ */
25
+ import { existsSync, readFileSync } from 'node:fs';
26
+ import { dirname, join, relative, sep } from 'node:path';
27
+ import { MODULE_EMAIL_DEFINITIONS_FILE, MODULE_EMAIL_DIRECTORY } from '../../module-layout/module-layout-convention.companion.js';
28
+ import { listModuleSourceFiles } from '../../module-layout/module-source-files.companion.js';
29
+ import { mayCallEmailTemplateScanner, readEmailTemplateScannerCalls } from './email-template-scanner-calls.companion.utils.js';
30
+ /** The conventional email root, under a module's source directory. */
31
+ export const CONVENTIONAL_MODULE_EMAIL_ROOT = MODULE_EMAIL_DIRECTORY;
32
+ /** The conventional definitions file, under the email root. */
33
+ export const CONVENTIONAL_MODULE_EMAIL_DEFINITIONS_FILE = MODULE_EMAIL_DEFINITIONS_FILE;
34
+ /**
35
+ * The email root of the module whose source directory is `moduleSourceDirectory` (`backend-api/src/modules/<module>`).
36
+ * Pure but for the reads; never throws: an unreadable directory answers the convention, undiscovered.
37
+ */
38
+ export function resolveModuleEmailRoot(moduleSourceDirectory) {
39
+ const conventional = {
40
+ rootDirectory: CONVENTIONAL_MODULE_EMAIL_ROOT,
41
+ definitionsFile: `${CONVENTIONAL_MODULE_EMAIL_ROOT}/${CONVENTIONAL_MODULE_EMAIL_DEFINITIONS_FILE}`,
42
+ discovered: false,
43
+ directoriesByRefPrefix: {},
44
+ undeterminedScannerCalls: 0,
45
+ };
46
+ if (!existsSync(moduleSourceDirectory))
47
+ return conventional;
48
+ const scanners = [];
49
+ for (const file of listModuleSourceFiles(moduleSourceDirectory)) {
50
+ let text;
51
+ try {
52
+ text = readFileSync(join(moduleSourceDirectory, file), 'utf8');
53
+ }
54
+ catch {
55
+ continue; // Unreadable: not a scanner we can see.
56
+ }
57
+ if (!mayCallEmailTemplateScanner(text))
58
+ continue;
59
+ const calls = readEmailTemplateScannerCalls(text, file);
60
+ if (calls.length > 0)
61
+ scanners.push({ file, calls });
62
+ }
63
+ const inConvention = (file) => (file.startsWith(`${CONVENTIONAL_MODULE_EMAIL_ROOT}/`) ? 0 : 1);
64
+ const chosen = [...scanners].sort((left, right) => inConvention(left.file) - inConvention(right.file)
65
+ || left.file.split('/').length - right.file.split('/').length
66
+ || left.file.localeCompare(right.file))[0];
67
+ if (chosen === undefined)
68
+ return conventional;
69
+ const slash = chosen.file.lastIndexOf('/');
70
+ const directoriesByRefPrefix = {};
71
+ let undeterminedScannerCalls = 0;
72
+ for (const call of chosen.calls) {
73
+ if (call.subdir === null || call.refPrefix === null) {
74
+ undeterminedScannerCalls += 1;
75
+ continue;
76
+ }
77
+ directoriesByRefPrefix[call.refPrefix] = call.subdir;
78
+ }
79
+ return {
80
+ rootDirectory: slash < 0 ? '.' : chosen.file.slice(0, slash),
81
+ definitionsFile: chosen.file,
82
+ discovered: true,
83
+ directoriesByRefPrefix,
84
+ undeterminedScannerCalls,
85
+ };
86
+ }
87
+ /** The compiled form of a definitions file (`emails/x.ts` → `emails/x.js`), as the preview imports it from `dist`. */
88
+ export function compiledDefinitionsFile(definitionsFile) {
89
+ return definitionsFile.replace(/\.tsx?$/u, '.js');
90
+ }
91
+ /**
92
+ * The template map a module's definitions file exports, chosen by its CONTENT (#3904 review F1): the exported object whose
93
+ * keys include one of the module's own registered template refs. A definitions file may export the map under any name
94
+ * (`clientDocumentsEmailTemplateDefinitions`), so a fixed name finds nothing for most of them. The conventional names are
95
+ * tried first, then every other export, then the default export's members. `{}` when nothing matches: the module's
96
+ * templates are then not refreshed, never replaced by another export's.
97
+ */
98
+ export function selectModuleEmailTemplateDefinitions(moduleExports, ownTemplateRefs) {
99
+ const isMap = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
100
+ const matches = (value) => isMap(value) && ownTemplateRefs.some((ref) => Object.hasOwn(value, ref));
101
+ const preferred = ['emailTemplateDefinitions', 'moduleEmailTemplateDefinitions'];
102
+ const defaultExport = isMap(moduleExports.default) ? moduleExports.default : {};
103
+ const candidates = [
104
+ ...preferred.map((name) => moduleExports[name]),
105
+ ...Object.entries(moduleExports).filter(([name]) => !preferred.includes(name) && name !== 'default').map(([, value]) => value),
106
+ ...preferred.map((name) => defaultExport[name]),
107
+ ...Object.values(defaultExport),
108
+ ];
109
+ return candidates.find(matches) ?? {};
110
+ }
111
+ /**
112
+ * A business module's email placement, as the `email-template-placement-info` introspection reports it (#3904): the
113
+ * APPLICATION-relative root, `<the backend service's path>/src/modules/<module>/<root>` (the service's path read from where
114
+ * the service is, review F4, not assumed to be `backend-api`), and the layout the generation step may write under it.
115
+ */
116
+ export function moduleEmailTemplatePlacement(input) {
117
+ const root = resolveModuleEmailRoot(join(input.backendPackageRoot, 'src', 'modules', input.moduleId));
118
+ const servicePath = relative(input.applicationRoot, input.backendPackageRoot).split(sep).join('/') || '.';
119
+ const moduleDirectory = `${servicePath}/src/modules/${input.moduleId}`;
120
+ const backend = root.rootDirectory === '.' ? moduleDirectory : `${moduleDirectory}/${root.rootDirectory}`;
121
+ if (!root.discovered) {
122
+ return {
123
+ backend,
124
+ layout: {
125
+ determined: false,
126
+ reason: `no file under ${moduleDirectory} calls scanEmailTemplateDirectory (imported from @wildo-ai/saas-backend-lib), so where the `
127
+ + 'module registers its templates cannot be read and nothing is written for it. Register them from '
128
+ + `${moduleDirectory}/${CONVENTIONAL_MODULE_EMAIL_ROOT}/${CONVENTIONAL_MODULE_EMAIL_DEFINITIONS_FILE}, scanning \`resources\` and \`system\``,
129
+ },
130
+ };
131
+ }
132
+ if (Object.keys(root.directoriesByRefPrefix).length === 0) {
133
+ return {
134
+ backend,
135
+ layout: {
136
+ determined: false,
137
+ reason: `${moduleDirectory}/${root.definitionsFile} calls scanEmailTemplateDirectory with a \`subdir\` or \`keyFromPath\` that is not a `
138
+ + 'literal, so which folder registers which refs cannot be read and nothing is written for it. Write `subdir` as a string and '
139
+ + '`keyFromPath` as a function returning `email.${…}` or `system.${…}`',
140
+ },
141
+ };
142
+ }
143
+ return {
144
+ backend,
145
+ layout: {
146
+ determined: true,
147
+ definitionsFile: `${moduleDirectory}/${root.definitionsFile}`,
148
+ directoriesByRefPrefix: root.directoriesByRefPrefix,
149
+ undeterminedScannerCalls: root.undeterminedScannerCalls,
150
+ },
151
+ };
152
+ }
153
+ /** A business module's email root, APPLICATION-relative: {@link moduleEmailTemplatePlacement}'s `backend`. */
154
+ export function moduleEmailRootApplicationPath(input) {
155
+ return moduleEmailTemplatePlacement(input).backend;
156
+ }
157
+ /** The compiled definitions file the preview imports for a business module (#3904): `dist` mirrors `src` (`rootDir: src`). */
158
+ export function moduleEmailDefinitionsEntryPath(backendDistRoot, moduleId) {
159
+ const moduleSource = join(dirname(backendDistRoot), 'src', 'modules', moduleId);
160
+ return join(backendDistRoot, 'modules', moduleId, compiledDefinitionsFile(resolveModuleEmailRoot(moduleSource).definitionsFile));
161
+ }
162
+ //# sourceMappingURL=module-email-root.companion.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-email-root.companion.utils.js","sourceRoot":"","sources":["../../../../src/email/utils/module-email-root.companion.utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AAC/H,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,2BAA2B,EAAE,6BAA6B,EAAiC,MAAM,gDAAgD,CAAC;AAE3J,sEAAsE;AACtE,MAAM,CAAC,MAAM,8BAA8B,GAAG,sBAAsB,CAAC;AACrE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,0CAA0C,GAAG,6BAA6B,CAAC;AAmBxF;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,qBAA6B;IAClE,MAAM,YAAY,GAAoB;QACpC,aAAa,EAAE,8BAA8B;QAC7C,eAAe,EAAE,GAAG,8BAA8B,IAAI,0CAA0C,EAAE;QAClG,UAAU,EAAE,KAAK;QACjB,sBAAsB,EAAE,EAAE;QAC1B,wBAAwB,EAAE,CAAC;KAC5B,CAAC;IACF,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC;QAAE,OAAO,YAAY,CAAC;IAC5D,MAAM,QAAQ,GAA0F,EAAE,CAAC;IAC3G,KAAK,MAAM,IAAI,IAAI,qBAAqB,CA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,EAAE,uBAAuB,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;AACnI,CAAC","sourcesContent":["/**\n * Where a business module's email templates live, read from the module's own source (#3904).\n *\n * The convention is `backend-api/src/modules/<module>/emails/`, registered by `emails/module-email-template-definitions.ts`\n * scanning `system/` and `resources/` (`MODULE_EMAIL_DIRECTORY` in `module-layout-convention.companion.ts`, the one source\n * the build lane's `check:module-layout` also reads). On reference run 43691253927 the `enquiries` module's templates were\n * registered from `email/email-template-definitions.ts` instead; the companion wrote its generated template into\n * `emails/`, where nothing registered it, and the preview's import failed with `ERR_MODULE_NOT_FOUND`.\n *\n * Since Paul's decision of 2026-11-17 the build PREVENTS that placement (`check:module-layout` fails the run that made it,\n * with the move that corrects it). This file stays the READ path, and it is honest about what it could read:\n *\n * - the email root is the directory of the file that CALLS `scanEmailTemplateDirectory`, read from its syntax tree, so a\n * call inside a comment does not count and an aliased or namespace import does (#3904 review F6). Several such files\n * (unusual): the one under `emails/` wins, then the shallowest. None: the convention, reported `discovered: false`;\n * - which directory each family of refs is registered from is read from each call's `subdir` and `keyFromPath` when they\n * are literals (review F5): `{ 'email.': 'resources', 'system.': 'system' }` for the conventional file. A call whose\n * arguments are not literals is counted as undetermined, never assumed to be the standard layout;\n * - {@link moduleEmailTemplatePlacement} turns both into what the generation step may write (review F2): a module that\n * registers templates and has no readable scanner is UNDETERMINED, and the generation step writes nothing for it\n * rather than writing where nothing registers.\n *\n * Read from source, never from `dist`, so a module whose definitions moved is read where it is now.\n */\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, relative, sep } from 'node:path';\n\nimport { MODULE_EMAIL_DEFINITIONS_FILE, MODULE_EMAIL_DIRECTORY } from '../../module-layout/module-layout-convention.companion';\nimport { listModuleSourceFiles } from '../../module-layout/module-source-files.companion';\nimport { mayCallEmailTemplateScanner, readEmailTemplateScannerCalls, type EmailTemplateScannerCall } from './email-template-scanner-calls.companion.utils';\n\n/** The conventional email root, under a module's source directory. */\nexport const CONVENTIONAL_MODULE_EMAIL_ROOT = MODULE_EMAIL_DIRECTORY;\n/** The conventional definitions file, under the email root. */\nexport const CONVENTIONAL_MODULE_EMAIL_DEFINITIONS_FILE = MODULE_EMAIL_DEFINITIONS_FILE;\n\n/** Where one module's emails live, relative to the module's source directory (POSIX separators). */\nexport interface ModuleEmailRoot {\n /** The directory templates are written under and scanned from (`emails`, `email`, …). */\n readonly rootDirectory: string;\n /** The definitions file, relative to the module's directory (`emails/module-email-template-definitions.ts`). */\n readonly definitionsFile: string;\n /** Whether it was read from the module's source (true) or is the convention, nothing scanning yet (false). */\n readonly discovered: boolean;\n /**\n * The directory, relative to the email root, each family of refs is registered from, keyed by the refs' prefix\n * (`email.` → `resources`), read from the definitions file's literal scanner calls. Empty when not discovered.\n */\n readonly directoriesByRefPrefix: Readonly<Record<string, string>>;\n /** How many of the definitions file's scanner calls had a `subdir` or `keyFromPath` that is not a literal. */\n readonly undeterminedScannerCalls: number;\n}\n\n/**\n * The email root of the module whose source directory is `moduleSourceDirectory` (`backend-api/src/modules/<module>`).\n * Pure but for the reads; never throws: an unreadable directory answers the convention, undiscovered.\n */\nexport function resolveModuleEmailRoot(moduleSourceDirectory: string): ModuleEmailRoot {\n const conventional: ModuleEmailRoot = {\n rootDirectory: CONVENTIONAL_MODULE_EMAIL_ROOT,\n definitionsFile: `${CONVENTIONAL_MODULE_EMAIL_ROOT}/${CONVENTIONAL_MODULE_EMAIL_DEFINITIONS_FILE}`,\n discovered: false,\n directoriesByRefPrefix: {},\n undeterminedScannerCalls: 0,\n };\n if (!existsSync(moduleSourceDirectory)) return conventional;\n const scanners: Array<{ readonly file: string; readonly calls: readonly EmailTemplateScannerCall[] }> = [];\n for (const file of listModuleSourceFiles(moduleSourceDirectory)) {\n let text: string;\n try {\n text = readFileSync(join(moduleSourceDirectory, file), 'utf8');\n } catch {\n continue; // Unreadable: not a scanner we can see.\n }\n if (!mayCallEmailTemplateScanner(text)) continue;\n const calls = readEmailTemplateScannerCalls(text, file);\n if (calls.length > 0) scanners.push({ file, calls });\n }\n const inConvention = (file: string) => (file.startsWith(`${CONVENTIONAL_MODULE_EMAIL_ROOT}/`) ? 0 : 1);\n const chosen = [...scanners].sort((left, right) => inConvention(left.file) - inConvention(right.file)\n || left.file.split('/').length - right.file.split('/').length\n || left.file.localeCompare(right.file))[0];\n if (chosen === undefined) return conventional;\n const slash = chosen.file.lastIndexOf('/');\n const directoriesByRefPrefix: Record<string, string> = {};\n let undeterminedScannerCalls = 0;\n for (const call of chosen.calls) {\n if (call.subdir === null || call.refPrefix === null) {\n undeterminedScannerCalls += 1;\n continue;\n }\n directoriesByRefPrefix[call.refPrefix] = call.subdir;\n }\n return {\n rootDirectory: slash < 0 ? '.' : chosen.file.slice(0, slash),\n definitionsFile: chosen.file,\n discovered: true,\n directoriesByRefPrefix,\n undeterminedScannerCalls,\n };\n}\n\n/** The compiled form of a definitions file (`emails/x.ts` → `emails/x.js`), as the preview imports it from `dist`. */\nexport function compiledDefinitionsFile(definitionsFile: string): string {\n return definitionsFile.replace(/\\.tsx?$/u, '.js');\n}\n\n/**\n * The template map a module's definitions file exports, chosen by its CONTENT (#3904 review F1): the exported object whose\n * keys include one of the module's own registered template refs. A definitions file may export the map under any name\n * (`clientDocumentsEmailTemplateDefinitions`), so a fixed name finds nothing for most of them. The conventional names are\n * tried first, then every other export, then the default export's members. `{}` when nothing matches: the module's\n * templates are then not refreshed, never replaced by another export's.\n */\nexport function selectModuleEmailTemplateDefinitions(moduleExports: Record<string, unknown>, ownTemplateRefs: readonly string[]): Record<string, unknown> {\n const isMap = (value: unknown): value is Record<string, unknown> => value !== null && typeof value === 'object' && !Array.isArray(value);\n const matches = (value: unknown): value is Record<string, unknown> => isMap(value) && ownTemplateRefs.some((ref) => Object.hasOwn(value, ref));\n const preferred = ['emailTemplateDefinitions', 'moduleEmailTemplateDefinitions'];\n const defaultExport = isMap(moduleExports.default) ? moduleExports.default : {};\n const candidates = [\n ...preferred.map((name) => moduleExports[name]),\n ...Object.entries(moduleExports).filter(([name]) => !preferred.includes(name) && name !== 'default').map(([, value]) => value),\n ...preferred.map((name) => defaultExport[name]),\n ...Object.values(defaultExport),\n ];\n return candidates.find(matches) ?? {};\n}\n\n/**\n * What the generation step may write for a business module's templates (#3904 review F2, F5):\n *\n * - `determined: true`: the templates of each ref family go under `<root>/<directoriesByRefPrefix[prefix]>/…`;\n * - `determined: false`: where the module registers its templates cannot be read (no file calls the scanner, or none of\n * its calls has literal arguments). The generation step then writes NOTHING for the module and says why, instead of\n * writing into a folder nothing registers. `check:module-layout` is what corrects such a module.\n */\nexport type ModuleEmailTemplateLayout =\n | {\n readonly determined: true;\n /** Application-relative definitions file the layout was read from. */\n readonly definitionsFile: string;\n readonly directoriesByRefPrefix: Readonly<Record<string, string>>;\n readonly undeterminedScannerCalls: number;\n }\n | { readonly determined: false; readonly reason: string };\n\n/**\n * A business module's email placement, as the `email-template-placement-info` introspection reports it (#3904): the\n * APPLICATION-relative root, `<the backend service's path>/src/modules/<module>/<root>` (the service's path read from where\n * the service is, review F4, not assumed to be `backend-api`), and the layout the generation step may write under it.\n */\nexport function moduleEmailTemplatePlacement(input: { readonly applicationRoot: string; readonly backendPackageRoot: string; readonly moduleId: string }): {\n readonly backend: string;\n readonly layout: ModuleEmailTemplateLayout;\n} {\n const root = resolveModuleEmailRoot(join(input.backendPackageRoot, 'src', 'modules', input.moduleId));\n const servicePath = relative(input.applicationRoot, input.backendPackageRoot).split(sep).join('/') || '.';\n const moduleDirectory = `${servicePath}/src/modules/${input.moduleId}`;\n const backend = root.rootDirectory === '.' ? moduleDirectory : `${moduleDirectory}/${root.rootDirectory}`;\n if (!root.discovered) {\n return {\n backend,\n layout: {\n determined: false,\n reason: `no file under ${moduleDirectory} calls scanEmailTemplateDirectory (imported from @wildo-ai/saas-backend-lib), so where the `\n + 'module registers its templates cannot be read and nothing is written for it. Register them from '\n + `${moduleDirectory}/${CONVENTIONAL_MODULE_EMAIL_ROOT}/${CONVENTIONAL_MODULE_EMAIL_DEFINITIONS_FILE}, scanning \\`resources\\` and \\`system\\``,\n },\n };\n }\n if (Object.keys(root.directoriesByRefPrefix).length === 0) {\n return {\n backend,\n layout: {\n determined: false,\n reason: `${moduleDirectory}/${root.definitionsFile} calls scanEmailTemplateDirectory with a \\`subdir\\` or \\`keyFromPath\\` that is not a `\n + 'literal, so which folder registers which refs cannot be read and nothing is written for it. Write `subdir` as a string and '\n + '`keyFromPath` as a function returning `email.${…}` or `system.${…}`',\n },\n };\n }\n return {\n backend,\n layout: {\n determined: true,\n definitionsFile: `${moduleDirectory}/${root.definitionsFile}`,\n directoriesByRefPrefix: root.directoriesByRefPrefix,\n undeterminedScannerCalls: root.undeterminedScannerCalls,\n },\n };\n}\n\n/** A business module's email root, APPLICATION-relative: {@link moduleEmailTemplatePlacement}'s `backend`. */\nexport function moduleEmailRootApplicationPath(input: { readonly applicationRoot: string; readonly backendPackageRoot: string; readonly moduleId: string }): string {\n return moduleEmailTemplatePlacement(input).backend;\n}\n\n/** The compiled definitions file the preview imports for a business module (#3904): `dist` mirrors `src` (`rootDir: src`). */\nexport function moduleEmailDefinitionsEntryPath(backendDistRoot: string, moduleId: string): string {\n const moduleSource = join(dirname(backendDistRoot), 'src', 'modules', moduleId);\n return join(backendDistRoot, 'modules', moduleId, compiledDefinitionsFile(resolveModuleEmailRoot(moduleSource).definitionsFile));\n}\n"]}
@@ -133,6 +133,19 @@ export declare class ExpertPersonaCompanionService {
133
133
  * bound", which marks rather than refuses.
134
134
  */
135
135
  contentSafety?: ContentSafetyBackendService | undefined);
136
+ /**
137
+ * Whether the build is unfinished, as the eligibility board reads it (`isBuildUnfinished`, #4022), for a drift
138
+ * assessment whose caller does not hold the board's state: a deliberation refusing stale seats. Registered by the
139
+ * playbook-run service, which reads the build plan through the build dispatch; injecting that here would cycle (the
140
+ * build dispatch reaches this service through the logo panel). Unregistered: every input counts, as before #4022.
141
+ *
142
+ * One case where the two readings differ, by construction: the board computes the plan's progress only while the
143
+ * `build-plan` family is readable (not deactivated, not held by a failing module), and the probe always asks the build
144
+ * dispatch. There the board counts the build's writes and a deliberation does not, which costs a staffing run the
145
+ * board offers and never holds a step: the refusal is the side that admits the seat.
146
+ */
147
+ private buildUnfinishedProbe;
148
+ registerBuildUnfinishedProbe(probe: () => Promise<boolean>): void;
136
149
  derive(options: ExpertPersonaDeriveOptions, traceContext?: AgentTraceContext): Promise<ExpertPersonaDeriveResult>;
137
150
  /**
138
151
  * The committed charters whose shaping inputs changed after them (#2819), judged by `assessExpertCharterInputDrift`
@@ -156,8 +169,15 @@ export declare class ExpertPersonaCompanionService {
156
169
  *
157
170
  * Never throws: with no git, or an unreadable repository, it dates nothing and returns `[]`, so a board read or a
158
171
  * deliberation never fails over an annotation.
172
+ *
173
+ * While the build is unfinished, a change to an input the build writes (the design system, the accepted mark) is not
174
+ * counted (#4022, `assessExpertCharterInputDrift`). `buildUnfinished` is the board's own reading of its state; a caller
175
+ * that does not hold one (a deliberation) omits it and the registered probe answers, so the board and the refusal read
176
+ * the same predicate. A probe that throws counts every input, as an unregistered one does.
159
177
  */
160
- assessCharterDrift(charters: unknown): Promise<readonly ExpertCharterInputDrift[]>;
178
+ assessCharterDrift(charters: unknown, options?: {
179
+ readonly buildUnfinished?: boolean;
180
+ }): Promise<readonly ExpertCharterInputDrift[]>;
161
181
  /** The application-relative directory every charter and the aggregator live in (#3237 review A). */
162
182
  describePersonasDirectory(): string;
163
183
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"expert-persona.companion.service.d.ts","sourceRoot":"","sources":["../../../../src/expert-personas/services/expert-persona.companion.service.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,0BAA0B,EAC1B,aAAa,EAEb,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EAE1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAIL,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAOL,KAAK,oBAAo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E,MAAM,GAAG,SAAS,MAAM,EAAE;IASrE;;;;;;OAMG;IACI,MAAM,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAStF,OAAO,CAAC,WAAW,CAAoC;YAEzC,gBAAgB;IAwM9B,OAAO,CAAC,eAAe;IAmBvB;;;;;;;OAOG;YACW,oBAAoB;IAoElC;;;;;;;OAOG;YACW,wBAAwB;IAsBtC;;;;;;;OAOG;YACW,qBAAqB;IAoCnC;;;;;OAKG;YACW,gBAAgB;IAoC9B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAqB3B,8EAA8E;IAC9E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAMkB;IAE7D,6EAA6E;IAC7E,OAAO,CAAC,gBAAgB;IAkBxB,6EAA6E;IAC7E,OAAO,CAAC,mBAAmB;IAwB3B,+EAA+E;IAC/E,OAAO,CAAC,mBAAmB;YA4Bb,kBAAkB;IAuBhC;;;;OAIG;YACW,oBAAoB;IA8BlC;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IASxB,uGAAuG;IACvG,OAAO,CAAC,qBAAqB;IAe7B,6EAA6E;IAC7E,OAAO,CAAC,0BAA0B;CAcnC"}
1
+ {"version":3,"file":"expert-persona.companion.service.d.ts","sourceRoot":"","sources":["../../../../src/expert-personas/services/expert-persona.companion.service.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,0BAA0B,EAC1B,aAAa,EAEb,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EAE1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAIL,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAOL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AAMvC,OAAO,EAQL,KAAK,uBAAuB,EAG7B,MAAM,wCAAwC,CAAC;AAKhD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4DAA4D,CAAC;AAC/G,OAAO,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AI,MAAM;IAI1C;;;;OAIG;IACI,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE;IASrE;;;;;;OAMG;IACI,MAAM,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAStF,OAAO,CAAC,WAAW,CAAoC;YAEzC,gBAAgB;IAwM9B,OAAO,CAAC,eAAe;IAmBvB;;;;;;;OAOG;YACW,oBAAoB;IAoElC;;;;;;;OAOG;YACW,wBAAwB;IAsBtC;;;;;;;OAOG;YACW,qBAAqB;IAoCnC;;;;;OAKG;YACW,gBAAgB;IAoC9B;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAqB3B,8EAA8E;IAC9E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAMkB;IAE7D,6EAA6E;IAC7E,OAAO,CAAC,gBAAgB;IAkBxB,6EAA6E;IAC7E,OAAO,CAAC,mBAAmB;IAwB3B,+EAA+E;IAC/E,OAAO,CAAC,mBAAmB;YA4Bb,kBAAkB;IAuBhC;;;;OAIG;YACW,oBAAoB;IA8BlC;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IASxB,uGAAuG;IACvG,OAAO,CAAC,qBAAqB;IAe7B,6EAA6E;IAC7E,OAAO,CAAC,0BAA0B;CAcnC"}
@@ -18,7 +18,7 @@ import { ErrorBuilderBackendService, LoggerService, SAAS_SERVICE_TYPES, describe
18
18
  import { AppFrontendType, ErrorCustomMessageReference, ErrorType, } from '@wildo-ai/saas-models';
19
19
  import { ExpertPersonaCharterSchema, ExpertPersonaIssueKind, ExpertPersonaIssueSeverity, ExpertShapingInputKind, getExpertRoleTemplate, validateExpertPersonaCharters, } from '@wildo-ai/saas-specifications';
20
20
  import { ApplicationSpecificationFamily, BRAND_RESOLVED_ASSETS_MODULE_FILE, EXPERT_SHAPING_INPUT_FAMILY_BINDINGS, } from '@wildo-ai/saas-specifications/application-creation';
21
- import { applyCompanionExportWiring, COMPANION_EXPORT_WIRING_FILES, PlaybookInputChangeSource, assessExpertCharterInputDrift, getFamilyPackageRelativePath, writeSpecificationFileAtomically, assertSpecificationWritePermitted, } from '@wildo-ai/application-creation-runtime';
21
+ import { applyCompanionExportWiring, COMPANION_EXPORT_WIRING_FILES, PlaybookInputChangeSource, assessExpertCharterInputDrift, EXPERT_SHAPING_INPUT_WRITTEN_BY_THE_BUILD, getFamilyPackageRelativePath, writeSpecificationFileAtomically, assertSpecificationWritePermitted, } from '@wildo-ai/application-creation-runtime';
22
22
  import { readSpecificationFamiliesWholeValueBasis } from '../../core/context/specification-family-data.companion.js';
23
23
  import { assertPersonaSourceMayBeReplaced } from './persona-source-ownership.js';
24
24
  import { COMPANION_SERVICE_TYPES } from '../../core/inject/models/service-types.js';
@@ -94,6 +94,21 @@ let ExpertPersonaCompanionService = class ExpertPersonaCompanionService {
94
94
  this.logDebug = this.logger.debugByType('ExpertPersonaCompanionService');
95
95
  this.logger.setDebugTypeLogging('ExpertPersonaCompanionService', true);
96
96
  }
97
+ /**
98
+ * Whether the build is unfinished, as the eligibility board reads it (`isBuildUnfinished`, #4022), for a drift
99
+ * assessment whose caller does not hold the board's state: a deliberation refusing stale seats. Registered by the
100
+ * playbook-run service, which reads the build plan through the build dispatch; injecting that here would cycle (the
101
+ * build dispatch reaches this service through the logo panel). Unregistered: every input counts, as before #4022.
102
+ *
103
+ * One case where the two readings differ, by construction: the board computes the plan's progress only while the
104
+ * `build-plan` family is readable (not deactivated, not held by a failing module), and the probe always asks the build
105
+ * dispatch. There the board counts the build's writes and a deliberation does not, which costs a staffing run the
106
+ * board offers and never holds a step: the refusal is the side that admits the seat.
107
+ */
108
+ buildUnfinishedProbe;
109
+ registerBuildUnfinishedProbe(probe) {
110
+ this.buildUnfinishedProbe = probe;
111
+ }
97
112
  // ──────────────────────────────────────────────────────────────
98
113
  // DERIVE (propose)
99
114
  // ──────────────────────────────────────────────────────────────
@@ -200,8 +215,13 @@ let ExpertPersonaCompanionService = class ExpertPersonaCompanionService {
200
215
  *
201
216
  * Never throws: with no git, or an unreadable repository, it dates nothing and returns `[]`, so a board read or a
202
217
  * deliberation never fails over an annotation.
218
+ *
219
+ * While the build is unfinished, a change to an input the build writes (the design system, the accepted mark) is not
220
+ * counted (#4022, `assessExpertCharterInputDrift`). `buildUnfinished` is the board's own reading of its state; a caller
221
+ * that does not hold one (a deliberation) omits it and the registered probe answers, so the board and the refusal read
222
+ * the same predicate. A probe that throws counts every input, as an unregistered one does.
203
223
  */
204
- async assessCharterDrift(charters) {
224
+ async assessCharterDrift(charters, options) {
205
225
  if (this.git === undefined || !Array.isArray(charters) || charters.length === 0)
206
226
  return [];
207
227
  try {
@@ -255,13 +275,25 @@ let ExpertPersonaCompanionService = class ExpertPersonaCompanionService {
255
275
  const commit = committedAt.get(file);
256
276
  return commit === undefined ? undefined : { at: commit, source: PlaybookInputChangeSource.COMMITTED_LATER };
257
277
  };
258
- return assessExpertCharterInputDrift({
278
+ const assess = (buildUnfinished) => assessExpertCharterInputDrift({
259
279
  charters,
280
+ buildUnfinished,
260
281
  charterChangedAt: (roleRef) => changedAt(charterPath(roleRef), false)?.at,
261
282
  inputChangedAt: (kind) => (inputPaths.get(kind) ?? [])
262
283
  .flatMap((file) => changedAt(file) ?? [])
263
284
  .reduce((latest, date) => (latest === undefined || date.at > latest.at ? date : latest), undefined),
264
285
  });
286
+ if (options?.buildUnfinished !== undefined)
287
+ return assess(options.buildUnfinished);
288
+ /*
289
+ * The probe reads the build plan's landing (a gated derivation), so it is asked only when its answer can change
290
+ * the drift: when an input the build writes changed after a charter (#4022 review F7).
291
+ */
292
+ const counted = assess(false);
293
+ const buildWrittenChange = counted.some((entry) => entry.changedInputs.some(({ kind }) => EXPERT_SHAPING_INPUT_WRITTEN_BY_THE_BUILD[kind]));
294
+ if (!buildWrittenChange)
295
+ return counted;
296
+ return await this.buildUnfinishedProbe?.().catch(() => false) === true ? assess(true) : counted;
265
297
  }
266
298
  catch (error) {
267
299
  this.logDebug('expert charter drift could not be dated (nothing reported)', { error: describeCaughtError(error) });