@wildo-ai/saas-specifications 1.1.15 → 1.1.17

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 (147) hide show
  1. package/dist/esm/_core/application-maturity/application-maturity-open-items.d.ts +2 -1
  2. package/dist/esm/_core/application-maturity/application-maturity-open-items.d.ts.map +1 -1
  3. package/dist/esm/_core/application-maturity/application-maturity-open-items.js +2 -1
  4. package/dist/esm/_core/application-maturity/application-maturity-open-items.js.map +1 -1
  5. package/dist/esm/_core/application-maturity/application-maturity-validation.js +1 -1
  6. package/dist/esm/_core/application-maturity/application-maturity-validation.js.map +1 -1
  7. package/dist/esm/_core/build-plan/build-plan-relationship-grouping.d.ts.map +1 -1
  8. package/dist/esm/_core/build-plan/build-plan-relationship-grouping.js +5 -2
  9. package/dist/esm/_core/build-plan/build-plan-relationship-grouping.js.map +1 -1
  10. package/dist/esm/_core/build-plan/build-plan-task-graph-generation.schemas.d.ts +251 -0
  11. package/dist/esm/_core/build-plan/build-plan-task-graph-generation.schemas.d.ts.map +1 -1
  12. package/dist/esm/_core/build-plan/build-plan-task-graph-generation.schemas.js +43 -0
  13. package/dist/esm/_core/build-plan/build-plan-task-graph-generation.schemas.js.map +1 -1
  14. package/dist/esm/_core/build-plan/build-plan-task-graph.schemas.d.ts +43 -0
  15. package/dist/esm/_core/build-plan/build-plan-task-graph.schemas.d.ts.map +1 -1
  16. package/dist/esm/_core/build-plan/build-plan-task-graph.schemas.js +58 -0
  17. package/dist/esm/_core/build-plan/build-plan-task-graph.schemas.js.map +1 -1
  18. package/dist/esm/_core/domain-plan/domain-plan-output-set-generation.schemas.d.ts +1 -0
  19. package/dist/esm/_core/domain-plan/domain-plan-output-set-generation.schemas.d.ts.map +1 -1
  20. package/dist/esm/_core/domain-plan/domain-plan-output-set-generation.schemas.js +5 -1
  21. package/dist/esm/_core/domain-plan/domain-plan-output-set-generation.schemas.js.map +1 -1
  22. package/dist/esm/_core/domain-plan/domain-plan-output-set-validation.js +2 -0
  23. package/dist/esm/_core/domain-plan/domain-plan-output-set-validation.js.map +1 -1
  24. package/dist/esm/_core/domain-plan/domain-plan-output-set.schemas.d.ts +3 -0
  25. package/dist/esm/_core/domain-plan/domain-plan-output-set.schemas.d.ts.map +1 -1
  26. package/dist/esm/_core/domain-plan/domain-plan-output-set.schemas.js +12 -1
  27. package/dist/esm/_core/domain-plan/domain-plan-output-set.schemas.js.map +1 -1
  28. package/dist/esm/_core/execution-view-specification.schemas.d.ts +19 -3
  29. package/dist/esm/_core/execution-view-specification.schemas.d.ts.map +1 -1
  30. package/dist/esm/_core/execution-view-specification.schemas.js +11 -1
  31. package/dist/esm/_core/execution-view-specification.schemas.js.map +1 -1
  32. package/dist/esm/_core/market/market-snapshot-generation.schemas.d.ts +15 -0
  33. package/dist/esm/_core/market/market-snapshot-generation.schemas.d.ts.map +1 -1
  34. package/dist/esm/_core/market/market-snapshot-generation.schemas.js +43 -0
  35. package/dist/esm/_core/market/market-snapshot-generation.schemas.js.map +1 -1
  36. package/dist/esm/_core/service-method/service-method-derivation.d.ts +17 -1
  37. package/dist/esm/_core/service-method/service-method-derivation.d.ts.map +1 -1
  38. package/dist/esm/_core/service-method/service-method-derivation.js +46 -0
  39. package/dist/esm/_core/service-method/service-method-derivation.js.map +1 -1
  40. package/dist/esm/_core/service-method/service-method-generation.schemas.d.ts +5 -0
  41. package/dist/esm/_core/service-method/service-method-generation.schemas.d.ts.map +1 -1
  42. package/dist/esm/_core/service-method/service-method.family-aspects.d.ts.map +1 -1
  43. package/dist/esm/_core/service-method/service-method.family-aspects.js +1 -0
  44. package/dist/esm/_core/service-method/service-method.family-aspects.js.map +1 -1
  45. package/dist/esm/_core/service-method/service-method.schemas.d.ts +36 -1
  46. package/dist/esm/_core/service-method/service-method.schemas.d.ts.map +1 -1
  47. package/dist/esm/_core/service-method/service-method.schemas.js +49 -1
  48. package/dist/esm/_core/service-method/service-method.schemas.js.map +1 -1
  49. package/dist/esm/_core/utils/extract-field-specs.d.ts +4 -3
  50. package/dist/esm/_core/utils/extract-field-specs.d.ts.map +1 -1
  51. package/dist/esm/_core/utils/extract-field-specs.js +4 -3
  52. package/dist/esm/_core/utils/extract-field-specs.js.map +1 -1
  53. package/dist/esm/application-creation/playbooks.application-creation.schemas.d.ts +5 -4
  54. package/dist/esm/application-creation/playbooks.application-creation.schemas.d.ts.map +1 -1
  55. package/dist/esm/application-creation/playbooks.application-creation.schemas.js +5 -4
  56. package/dist/esm/application-creation/playbooks.application-creation.schemas.js.map +1 -1
  57. package/dist/esm/assurance/assurance-authority-basis.definitions.d.ts +1 -1
  58. package/dist/esm/assurance/assurance-authority-basis.definitions.js +1 -1
  59. package/dist/esm/assurance/assurance-authority-basis.definitions.js.map +1 -1
  60. package/dist/esm/assurance/assurance-evidence-requirement-bodies.definitions.d.ts.map +1 -1
  61. package/dist/esm/assurance/assurance-evidence-requirement-bodies.definitions.js +13 -5
  62. package/dist/esm/assurance/assurance-evidence-requirement-bodies.definitions.js.map +1 -1
  63. package/dist/esm/assurance/assurance-objective-catalog.definitions.d.ts.map +1 -1
  64. package/dist/esm/assurance/assurance-objective-catalog.definitions.js +9 -2
  65. package/dist/esm/assurance/assurance-objective-catalog.definitions.js.map +1 -1
  66. package/dist/esm/assurance/assurance-verification-requirement-bodies.definitions.d.ts.map +1 -1
  67. package/dist/esm/assurance/assurance-verification-requirement-bodies.definitions.js +8 -4
  68. package/dist/esm/assurance/assurance-verification-requirement-bodies.definitions.js.map +1 -1
  69. package/dist/esm/engine/compliance/resources/signature-requests.resource.specification.d.ts.map +1 -1
  70. package/dist/esm/engine/compliance/resources/signature-requests.resource.specification.js +8 -5
  71. package/dist/esm/engine/compliance/resources/signature-requests.resource.specification.js.map +1 -1
  72. package/dist/esm/engine/engine-resource-specifications.registry.d.ts.map +1 -1
  73. package/dist/esm/engine/engine-resource-specifications.registry.js +4 -0
  74. package/dist/esm/engine/engine-resource-specifications.registry.js.map +1 -1
  75. package/dist/esm/engine/flows-actors/resources/actor-system-executions.resource.specification.d.ts.map +1 -1
  76. package/dist/esm/engine/flows-actors/resources/actor-system-executions.resource.specification.js +4 -1
  77. package/dist/esm/engine/flows-actors/resources/actor-system-executions.resource.specification.js.map +1 -1
  78. package/dist/esm/engine/flows-actors/resources/actor-tasks.resource.specification.d.ts.map +1 -1
  79. package/dist/esm/engine/flows-actors/resources/actor-tasks.resource.specification.js +3 -0
  80. package/dist/esm/engine/flows-actors/resources/actor-tasks.resource.specification.js.map +1 -1
  81. package/dist/esm/engine/flows-actors/resources/remote-agent-task-updates.resource.specification.d.ts +3 -0
  82. package/dist/esm/engine/flows-actors/resources/remote-agent-task-updates.resource.specification.d.ts.map +1 -0
  83. package/dist/esm/engine/flows-actors/resources/remote-agent-task-updates.resource.specification.js +98 -0
  84. package/dist/esm/engine/flows-actors/resources/remote-agent-task-updates.resource.specification.js.map +1 -0
  85. package/dist/esm/engine/flows-actors/resources/remote-agent-tasks.resource.specification.d.ts +3 -0
  86. package/dist/esm/engine/flows-actors/resources/remote-agent-tasks.resource.specification.d.ts.map +1 -0
  87. package/dist/esm/engine/flows-actors/resources/remote-agent-tasks.resource.specification.js +132 -0
  88. package/dist/esm/engine/flows-actors/resources/remote-agent-tasks.resource.specification.js.map +1 -0
  89. package/dist/esm/engine/frontend-components/ai-elements/chat/ai-conversation-thread.frontend-component.specification.js +1 -1
  90. package/dist/esm/engine/frontend-components/ai-elements/chat/ai-conversation-thread.frontend-component.specification.js.map +1 -1
  91. package/dist/esm/engine/frontend-components/app/app-layout-agent-activity-settings.frontend-component.specification.d.ts +5 -0
  92. package/dist/esm/engine/frontend-components/app/app-layout-agent-activity-settings.frontend-component.specification.d.ts.map +1 -0
  93. package/dist/esm/engine/frontend-components/app/app-layout-agent-activity-settings.frontend-component.specification.js +79 -0
  94. package/dist/esm/engine/frontend-components/app/app-layout-agent-activity-settings.frontend-component.specification.js.map +1 -0
  95. package/dist/esm/engine/frontend-components/app/app-layout-connected-accounts-settings.frontend-component.specification.d.ts.map +1 -1
  96. package/dist/esm/engine/frontend-components/app/app-layout-connected-accounts-settings.frontend-component.specification.js +1 -0
  97. package/dist/esm/engine/frontend-components/app/app-layout-connected-accounts-settings.frontend-component.specification.js.map +1 -1
  98. package/dist/esm/engine/frontend-components/data-display/approval-seal.frontend-component.specification.js +3 -3
  99. package/dist/esm/engine/frontend-components/data-display/approval-seal.frontend-component.specification.js.map +1 -1
  100. package/dist/esm/engine/frontend-components/data-display/signature-requests.frontend-component.specification.d.ts +4 -0
  101. package/dist/esm/engine/frontend-components/data-display/signature-requests.frontend-component.specification.d.ts.map +1 -0
  102. package/dist/esm/engine/frontend-components/data-display/signature-requests.frontend-component.specification.js +29 -0
  103. package/dist/esm/engine/frontend-components/data-display/signature-requests.frontend-component.specification.js.map +1 -0
  104. package/dist/esm/engine/frontend-components/flows-actors/low-level-ai-approval.frontend-component.specification.js +1 -1
  105. package/dist/esm/engine/frontend-components/flows-actors/low-level-ai-approval.frontend-component.specification.js.map +1 -1
  106. package/dist/esm/engine/frontend-components/index.d.ts +2 -0
  107. package/dist/esm/engine/frontend-components/index.d.ts.map +1 -1
  108. package/dist/esm/engine/frontend-components/index.js +6 -0
  109. package/dist/esm/engine/frontend-components/index.js.map +1 -1
  110. package/dist/esm/engine/notifications/system-emails/delegated-work.system-emails.specification.d.ts +8 -0
  111. package/dist/esm/engine/notifications/system-emails/delegated-work.system-emails.specification.d.ts.map +1 -0
  112. package/dist/esm/engine/notifications/system-emails/delegated-work.system-emails.specification.js +65 -0
  113. package/dist/esm/engine/notifications/system-emails/delegated-work.system-emails.specification.js.map +1 -0
  114. package/dist/esm/engine/notifications/system-emails/index.d.ts +1 -0
  115. package/dist/esm/engine/notifications/system-emails/index.d.ts.map +1 -1
  116. package/dist/esm/engine/notifications/system-emails/index.js +3 -1
  117. package/dist/esm/engine/notifications/system-emails/index.js.map +1 -1
  118. package/dist/esm/engine/organizations/resources/organization-members.resource.specification.d.ts +9 -0
  119. package/dist/esm/engine/organizations/resources/organization-members.resource.specification.d.ts.map +1 -1
  120. package/dist/esm/engine/organizations/resources/organization-members.resource.specification.js +50 -0
  121. package/dist/esm/engine/organizations/resources/organization-members.resource.specification.js.map +1 -1
  122. package/dist/esm/engine/organizations/resources/organization-relationships.resource.specification.d.ts.map +1 -1
  123. package/dist/esm/engine/organizations/resources/organization-relationships.resource.specification.js +25 -0
  124. package/dist/esm/engine/organizations/resources/organization-relationships.resource.specification.js.map +1 -1
  125. package/dist/esm/engine/providers/antigravity.provider.specification.d.ts +7 -0
  126. package/dist/esm/engine/providers/antigravity.provider.specification.d.ts.map +1 -0
  127. package/dist/esm/engine/providers/antigravity.provider.specification.js +54 -0
  128. package/dist/esm/engine/providers/antigravity.provider.specification.js.map +1 -0
  129. package/dist/esm/engine/providers/google-drive.provider.specification.d.ts.map +1 -1
  130. package/dist/esm/engine/providers/google-drive.provider.specification.js +8 -0
  131. package/dist/esm/engine/providers/google-drive.provider.specification.js.map +1 -1
  132. package/dist/esm/engine/providers/index.d.ts +2 -0
  133. package/dist/esm/engine/providers/index.d.ts.map +1 -1
  134. package/dist/esm/engine/providers/index.js +5 -1
  135. package/dist/esm/engine/providers/index.js.map +1 -1
  136. package/dist/esm/engine/providers/microsoft-onedrive.provider.specification.d.ts.map +1 -1
  137. package/dist/esm/engine/providers/microsoft-onedrive.provider.specification.js +17 -0
  138. package/dist/esm/engine/providers/microsoft-onedrive.provider.specification.js.map +1 -1
  139. package/dist/esm/engine/providers/outbound-bearer-token.provider.specification.d.ts +7 -0
  140. package/dist/esm/engine/providers/outbound-bearer-token.provider.specification.d.ts.map +1 -0
  141. package/dist/esm/engine/providers/outbound-bearer-token.provider.specification.js +41 -0
  142. package/dist/esm/engine/providers/outbound-bearer-token.provider.specification.js.map +1 -0
  143. package/dist/esm/engine/providers/twilio.provider.specification.d.ts.map +1 -1
  144. package/dist/esm/engine/providers/twilio.provider.specification.js +3 -0
  145. package/dist/esm/engine/providers/twilio.provider.specification.js.map +1 -1
  146. package/dist/tsconfig.build.tsbuildinfo +1 -1
  147. package/package.json +8 -8
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import '@wildo-ai/zod-decorators';
3
+ import { ElectronicSignature_Level } from '@wildo-ai/external-connectors-models';
3
4
  import { DataRetentionClass, HumanDecision_RouteKind, ReviewClockBasis } from '@wildo-ai/saas-models';
4
5
  import { BuildPlanAgentShape } from '../build-plan/build-plan-task-graph.schemas';
5
6
  /**
@@ -176,12 +177,35 @@ export declare const ServiceMethodDecisionPointSchema: z.ZodObject<{
176
177
  }, z.core.$strict>>;
177
178
  }, z.core.$strict>;
178
179
  export type ServiceMethodDecisionPoint = z.infer<typeof ServiceMethodDecisionPointSchema>;
180
+ /**
181
+ * How a deliverable is signed once its approval releases it (#2915): the person who approved it signs it, at `level`.
182
+ *
183
+ * The engine's only signer is the approver (`FunctionTool_SignerSource.APPROVER`), so a signature is drawn from the
184
+ * firm's domain, not asked: a deliverable a regulated professional puts their name to (an audit or review opinion, a
185
+ * certified statement, an engagement letter the partner signs) is signed, an ordinary working document is not. `ADVANCED`
186
+ * is the level that identifies the signer and makes any later change detectable (eIDAS Art. 26); `SIMPLE` where the
187
+ * signature only records consent. The engine offers no qualified level (Paul, 2026-10-19), so a deliverable the firm's
188
+ * law requires a handwritten-equivalent signature for is not one the engine signs: the method says so in prose instead.
189
+ *
190
+ * spec-cite: Regulation (EU) No 910/2014 (eIDAS) Art. 26 (requirements for an advanced electronic signature) and Art. 25(2)
191
+ * (a qualified signature has the legal effect of a handwritten one) — paraphrased, not quoted.
192
+ */
193
+ export declare const ServiceMethodDeliverableSignatureSchema: z.ZodObject<{
194
+ level: z.ZodEnum<typeof ElectronicSignature_Level>;
195
+ ground: z.ZodString;
196
+ }, z.core.$strict>;
197
+ export type ServiceMethodDeliverableSignature = z.infer<typeof ServiceMethodDeliverableSignatureSchema>;
179
198
  /** One thing the client receives from a case. */
180
199
  export declare const ServiceMethodDeliverableSchema: z.ZodObject<{
181
200
  deliverableRef: z.ZodString;
182
201
  label: z.ZodString;
183
202
  stageRef: z.ZodString;
184
203
  fromResourceRef: z.ZodString;
204
+ approvedByDecisionRef: z.ZodOptional<z.ZodString>;
205
+ signature: z.ZodOptional<z.ZodObject<{
206
+ level: z.ZodEnum<typeof ElectronicSignature_Level>;
207
+ ground: z.ZodString;
208
+ }, z.core.$strict>>;
185
209
  }, z.core.$strict>;
186
210
  export type ServiceMethodDeliverable = z.infer<typeof ServiceMethodDeliverableSchema>;
187
211
  /** One service the firm delivers. */
@@ -226,6 +250,11 @@ export declare const ServiceMethodServiceSchema: z.ZodObject<{
226
250
  label: z.ZodString;
227
251
  stageRef: z.ZodString;
228
252
  fromResourceRef: z.ZodString;
253
+ approvedByDecisionRef: z.ZodOptional<z.ZodString>;
254
+ signature: z.ZodOptional<z.ZodObject<{
255
+ level: z.ZodEnum<typeof ElectronicSignature_Level>;
256
+ ground: z.ZodString;
257
+ }, z.core.$strict>>;
229
258
  }, z.core.$strict>>>;
230
259
  evidenceRetention: z.ZodObject<{
231
260
  retentionClass: z.ZodEnum<typeof DataRetentionClass>;
@@ -298,6 +327,11 @@ export declare const ServiceMethodSchema: z.ZodObject<{
298
327
  label: z.ZodString;
299
328
  stageRef: z.ZodString;
300
329
  fromResourceRef: z.ZodString;
330
+ approvedByDecisionRef: z.ZodOptional<z.ZodString>;
331
+ signature: z.ZodOptional<z.ZodObject<{
332
+ level: z.ZodEnum<typeof ElectronicSignature_Level>;
333
+ ground: z.ZodString;
334
+ }, z.core.$strict>>;
301
335
  }, z.core.$strict>>>;
302
336
  evidenceRetention: z.ZodObject<{
303
337
  retentionClass: z.ZodEnum<typeof DataRetentionClass>;
@@ -344,7 +378,8 @@ export interface ServiceMethodIssue {
344
378
  * stage exist in its service; an AGENT step names its agent shape and no other step does; an OWNER decision names no
345
379
  * qualification and a ROLE or ASSIGNEE decision names one that exists; only an ASSIGNEE decision names its assignee,
346
380
  * and it must; a business-time deadline needs the review calendar; a step names its performer unless the method owes
347
- * its agent work (#3484), and an owed part is declared once.
381
+ * its agent work (#3484), and an owed part is declared once; a deliverable's approving decision is one of its service's,
382
+ * approves no other deliverable, and a signed deliverable names one (#2915).
348
383
  */
349
384
  export declare function serviceMethodIssues(method: {
350
385
  readonly services: readonly z.input<typeof ServiceMethodServiceSchema>[];
@@ -1 +1 @@
1
- {"version":3,"file":"service-method.schemas.d.ts","sourceRoot":"","sources":["../../../../src/_core/service-method/service-method.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAIL,kBAAkB,EAClB,uBAAuB,EAIvB,gBAAgB,EAGjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAiC,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAEjH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,oBAAY,oBAAoB;IAC9B,EAAE,OAAO;CACV;AAED,uCAAuC;AACvC,oBAAY,0BAA0B;IACpC,0HAA0H;IAC1H,KAAK,UAAU;IACf,2DAA2D;IAC3D,MAAM,WAAW;IACjB,oGAAoG;IACpG,MAAM,WAAW;CAClB;AAED;;;;;;;;;GASG;AACH,oBAAY,qBAAqB;IAC/B;;;;OAIG;IACH,mBAAmB,wBAAwB;IAC3C;;;OAGG;IACH,UAAU,eAAe;CAC1B;AAED,6CAA6C;AAC7C,oBAAY,oBAAoB;IAC9B;;;;;OAKG;IACH,QAAQ,aAAa;IACrB,+FAA+F;IAC/F,gBAAgB,qBAAqB;IACrC,0HAA0H;IAC1H,cAAc,mBAAmB;CAClC;AAsBD,4GAA4G;AAC5G,oBAAY,gCAAgC;IAC1C;;;;;;;OAOG;IACH,IAAI,SAAS;IACb,qGAAqG;IACrG,MAAM,WAAW;CAClB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,gCAAgC;;;;;;kBAO3C,CAAC;AACH,MAA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,GAAG,MAAM,CAAC,EAAE,CAAC;CACpC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,EAAE,CAAC;IACzE,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,EAAE,CAAC;IACtF,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,EAAE,CAAC;IAC5F,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAClD,GAAG,kBAAkB,EAAE,CAwIvB"}
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  // Side-effect import: this module calls `.systemEnum()` at load, so the decorators must be installed first —
3
3
  // never by the importer's luck (#966). A named import used only as a type would be elided and install nothing.
4
4
  import '@wildo-ai/zod-decorators';
5
+ import { ElectronicSignature_Level } from '@wildo-ai/external-connectors-models';
5
6
  import { agentWorkReasonCode, CORE_APP_ROLES, CORE_ORG_ROLES, DataRetentionClass, HumanDecision_RouteKind, LABEL_KEY_SEGMENT_PATTERN, REVIEW_DURATION_PATTERN, ReviewCalendarSchema, ReviewClockBasis, parseReviewDurationMs, roleMayBeHeldByMembership, } from '@wildo-ai/saas-models';
6
7
  import { APPLICATION_ROLE_NAME_PATTERN, BuildPlanAgentShape } from '../build-plan/build-plan-task-graph.schemas.js';
7
8
  /**
@@ -213,6 +214,24 @@ export const ServiceMethodDecisionPointSchema = z.strictObject({
213
214
  basis: z.enum(ReviewClockBasis).systemEnum('ReviewClockBasis').default(ReviewClockBasis.ELAPSED),
214
215
  }).optional(),
215
216
  });
217
+ /**
218
+ * How a deliverable is signed once its approval releases it (#2915): the person who approved it signs it, at `level`.
219
+ *
220
+ * The engine's only signer is the approver (`FunctionTool_SignerSource.APPROVER`), so a signature is drawn from the
221
+ * firm's domain, not asked: a deliverable a regulated professional puts their name to (an audit or review opinion, a
222
+ * certified statement, an engagement letter the partner signs) is signed, an ordinary working document is not. `ADVANCED`
223
+ * is the level that identifies the signer and makes any later change detectable (eIDAS Art. 26); `SIMPLE` where the
224
+ * signature only records consent. The engine offers no qualified level (Paul, 2026-10-19), so a deliverable the firm's
225
+ * law requires a handwritten-equivalent signature for is not one the engine signs: the method says so in prose instead.
226
+ *
227
+ * spec-cite: Regulation (EU) No 910/2014 (eIDAS) Art. 26 (requirements for an advanced electronic signature) and Art. 25(2)
228
+ * (a qualified signature has the legal effect of a handwritten one) — paraphrased, not quoted.
229
+ */
230
+ export const ServiceMethodDeliverableSignatureSchema = z.strictObject({
231
+ level: z.enum(ElectronicSignature_Level).systemEnum('ElectronicSignature_Level'),
232
+ /** Why the domain requires it, in the firm's words — "the engagement partner signs every engagement letter". */
233
+ ground: text(),
234
+ });
216
235
  /** One thing the client receives from a case. */
217
236
  export const ServiceMethodDeliverableSchema = z.strictObject({
218
237
  deliverableRef: slug(),
@@ -221,6 +240,15 @@ export const ServiceMethodDeliverableSchema = z.strictObject({
221
240
  stageRef: slug(),
222
241
  /** The resource it is produced from, by domain-plan ref; it becomes a document generated from that resource. */
223
242
  fromResourceRef: slug(),
243
+ /**
244
+ * The decision point of the same service whose approval releases it to the client (#2915), when one does: the gate
245
+ * realizing that decision then binds the deliverable's file, so its approval seal records exactly what was approved.
246
+ * Absent when no person approves it before the client receives it. One decision approves at most one deliverable: a
247
+ * gated tool binds one file.
248
+ */
249
+ approvedByDecisionRef: slug().optional(),
250
+ /** The signature it needs once approved (#2915). Requires `approvedByDecisionRef`: the approver is who signs. */
251
+ signature: ServiceMethodDeliverableSignatureSchema.optional(),
224
252
  });
225
253
  /** One service the firm delivers. */
226
254
  export const ServiceMethodServiceSchema = z.strictObject({
@@ -287,7 +315,8 @@ export const ServiceMethodSchema = z.object({
287
315
  * stage exist in its service; an AGENT step names its agent shape and no other step does; an OWNER decision names no
288
316
  * qualification and a ROLE or ASSIGNEE decision names one that exists; only an ASSIGNEE decision names its assignee,
289
317
  * and it must; a business-time deadline needs the review calendar; a step names its performer unless the method owes
290
- * its agent work (#3484), and an owed part is declared once.
318
+ * its agent work (#3484), and an owed part is declared once; a deliverable's approving decision is one of its service's,
319
+ * approves no other deliverable, and a signed deliverable names one (#2915).
291
320
  */
292
321
  export function serviceMethodIssues(method) {
293
322
  const issues = [];
@@ -383,9 +412,28 @@ export function serviceMethodIssues(method) {
383
412
  issues.push({ message: `Decision ${decision.decisionRef} counts its deadline in business time, and the method declares no reviewCalendar.`, path: at('decisionPoints', index, 'decisionDeadline', 'basis') });
384
413
  }
385
414
  });
415
+ const decisionRefs = new Set(decisions.map((decision) => decision.decisionRef));
416
+ const approvingDecisions = new Map();
386
417
  deliverables.forEach((deliverable, index) => {
387
418
  if (!stageRefs.has(deliverable.stageRef))
388
419
  issues.push({ message: `Deliverable ${deliverable.deliverableRef} is produced at stage ${deliverable.stageRef}, which ${service.serviceRef} does not declare.`, path: at('deliverables', index, 'stageRef') });
420
+ // #2915: the approval that releases a deliverable is a decision of the same service, and binds one file.
421
+ const approvedBy = deliverable.approvedByDecisionRef;
422
+ if (approvedBy !== undefined) {
423
+ if (!decisionRefs.has(approvedBy)) {
424
+ issues.push({ message: `Deliverable ${deliverable.deliverableRef} is approved by decision ${approvedBy}, which ${service.serviceRef} does not declare.`, path: at('deliverables', index, 'approvedByDecisionRef') });
425
+ }
426
+ const first = approvingDecisions.get(approvedBy);
427
+ if (first !== undefined) {
428
+ issues.push({ message: `Decision ${approvedBy} approves both ${first} and ${deliverable.deliverableRef}; the tool that realizes it binds one file, so give each deliverable its own decision.`, path: at('deliverables', index, 'approvedByDecisionRef') });
429
+ }
430
+ else {
431
+ approvingDecisions.set(approvedBy, deliverable.deliverableRef);
432
+ }
433
+ }
434
+ if (deliverable.signature !== undefined && approvedBy === undefined) {
435
+ issues.push({ message: `Deliverable ${deliverable.deliverableRef} is signed and no decision approves it: the person who approves a deliverable is who signs it, so name the approving decision (approvedByDecisionRef).`, path: at('deliverables', index, 'signature') });
436
+ }
389
437
  });
390
438
  });
391
439
  // #2305 S6: a resource holding the evidence of two services has ONE retention binding, so they must keep it alike;
@@ -1 +1 @@
1
- {"version":3,"file":"service-method.schemas.js","sourceRoot":"","sources":["../../../../src/_core/service-method/service-method.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,6GAA6G;AAC7G,+GAA+G;AAC/G,OAAO,0BAA0B,CAAC;AAElC,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAEjH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAN,IAAY,oBAEX;AAFD,WAAY,oBAAoB;IAC9B,iCAAS,CAAA;AACX,CAAC,EAFW,oBAAoB,KAApB,oBAAoB,QAE/B;AAED,uCAAuC;AACvC,MAAM,CAAN,IAAY,0BAOX;AAPD,WAAY,0BAA0B;IACpC,0HAA0H;IAC1H,6CAAe,CAAA;IACf,2DAA2D;IAC3D,+CAAiB,CAAA;IACjB,oGAAoG;IACpG,+CAAiB,CAAA;AACnB,CAAC,EAPW,0BAA0B,KAA1B,0BAA0B,QAOrC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAN,IAAY,qBAYX;AAZD,WAAY,qBAAqB;IAC/B;;;;OAIG;IACH,oEAA2C,CAAA;IAC3C;;;OAGG;IACH,kDAAyB,CAAA;AAC3B,CA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C,WAAW,CAAC,CAAC;YAC7C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,aAAa,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC;YACrF,CAAC;iBAAM,IAAI,KAAK,CAAC,cAAc,KAAK,cAAc,EAAE,CAAC;gBACnD,MAAM,CAAC,IAAI,CAAC;oBACV,OAAO,EAAE,YAAY,WAAW,sBAAsB,KAAK,CAAC,UAAU,aAAa,KAAK,CAAC,cAAc,YAAY,OAAO,CAAC,UAAU,aAAa,cAAc,qEAAqE;oBACrO,IAAI,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,CAAC;iBACxE,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { z } from 'zod';\n// Side-effect import: this module calls `.systemEnum()` at load, so the decorators must be installed first —\n// never by the importer's luck (#966). A named import used only as a type would be elided and install nothing.\nimport '@wildo-ai/zod-decorators';\n\nimport {\n agentWorkReasonCode,\n CORE_APP_ROLES,\n CORE_ORG_ROLES,\n DataRetentionClass,\n HumanDecision_RouteKind,\n LABEL_KEY_SEGMENT_PATTERN,\n REVIEW_DURATION_PATTERN,\n ReviewCalendarSchema,\n ReviewClockBasis,\n parseReviewDurationMs,\n roleMayBeHeldByMembership,\n} from '@wildo-ai/saas-models';\n\nimport { APPLICATION_ROLE_NAME_PATTERN, BuildPlanAgentShape } from '../build-plan/build-plan-task-graph.schemas';\n\n/**\n * @wildo_source:part:start service-method.config facet:layer:specification facet:family:service-method\n *\n * THE FIRM'S METHOD (#2305): the services a service firm delivers, and for each one how a case is worked — its stages,\n * the steps agents, people and the client take, the decisions only a qualified person may take, what the client\n * receives, how long the evidence is kept and how the service is priced.\n *\n * ## Why this family exists\n *\n * An AI-native service platform is built out of parts the engine already has — agents and autonomous agents, tool\n * approval gates routed to the requester, a role or a named person, a review calendar, expert corrections, a resource\n * declared as the unit of work, roles conferred through a relationship, per-person professional qualifications. Before\n * this family, none of them was reachable from the creation lane except through the wording of a requirement: no\n * family named an agent, a gate or a case, so nothing could check that the method was built whole.\n *\n * This family is the ONE place the method is written down. The families downstream READ it rather than each hold a\n * piece of it, so the method can be reviewed as one thing and its derivation checked as total: the domain plan makes\n * each service's case a resource with its stages as the lifecycle, the build plan makes each case its work unit, each\n * agent step an agent, each decision point a gate or an agent's review question, each service priced per case a usage\n * recording on its case, each deliverable a document, the case's evidence a retention binding, and each role the firm's\n * people hold for a client, other than `ORG_REPRESENTATIVE`, a role its relationship confers. `findServiceMethodDerivationGaps` checks the parts a function\n * can compare (each case's resource, lifecycle and work unit, each agent step's agent, each decision's realization,\n * route, role and qualification, each role's declaration and conferral, each per-case price's recording, each\n * deliverable's document, each evidence resource's retention class): the coherence report names what is missing, and a\n * candidate build plan that leaves out what IT must realize is refused. A decision's deadline, a step's resources and\n * the client's participation are not compared.\n *\n * ## What the creator supplies, and what they do not\n *\n * The creator describes each service in their own words; the playbook drafts this structure; validation checks it;\n * the creator accepts it. Every vocabulary here is the engine's own (routes, agent shapes, retention classes, clock\n * bases, the review calendar), so a method that validates is one the engine can run.\n *\n * Firm-shaped, and reachable from ANY line by need (#2305 D3): the B2B SaaS and internal-tool lines declare it not\n * applicable, and a feature line that needs it brings it back, with the operator-with-clients structure it rests on,\n * laid down by the same function the service-firm line uses (`describeFirmStructureNeed`).\n */\nexport enum ServiceMethodVersion {\n V1 = 'v1',\n}\n\n/** Who performs one step of a case. */\nexport enum ServiceMethodStepPerformer {\n /** An agent does it. The step names the agent's shape, which decides how it is started and the skill it is built with. */\n AGENT = 'AGENT',\n /** One of the firm's people does it in the application. */\n PERSON = 'PERSON',\n /** The client provides or does it (sends documents, answers a question, approves a deliverable). */\n CLIENT = 'CLIENT',\n}\n\n/**\n * A part of the method the creator left NOT DECIDED YET (#3484), which the method then states as OWED rather than leaving\n * absent: an absent part reads as an answer (\"no qualified decisions\", \"no agent work\") in a domain where that answer\n * is consequential.\n *\n * A method-level declaration, because the two interview questions it answers are asked of the whole method, not of one\n * service. Considered and rejected: a \"not decided\" member of {@link ServiceMethodStepPerformer} (it would put a standing\n * among the performers and make every reader of a performer handle a non-performer), and per-decision \"undetermined\"\n * routes (a deferred answer leaves WHICH decisions need a qualified person open, so there is no decision to mark).\n */\nexport enum ServiceMethodOwedPart {\n /**\n * Which decisions in a case a qualified person must take, and who they must be (the `signatories` question). While\n * owed, the method's `qualifications` and `decisionPoints` hold only what is known, and their emptiness is NOT a\n * statement that no decision needs a qualified person.\n */\n QUALIFIED_DECISIONS = 'QUALIFIED_DECISIONS',\n /**\n * Which of the firm's work agents do (the `agent-work` question). While owed, a step whose performer depends on that\n * answer names none, and no agent is derived for it; the client's own steps still name the client.\n */\n AGENT_WORK = 'AGENT_WORK',\n}\n\n/** How a service is priced to the client. */\nexport enum ServiceMethodPricing {\n /**\n * Each case is billed: a metered price whose unit is the service's case, one usage unit recorded when a case closes,\n * once per case however often it is reopened (`recordsUsage` with `oncePerRecord` on the closing operation, #2305 S5).\n * The engine's metered billing is how per-unit pricing is done; no new pricing axis is needed. The business model\n * sells it as a plan priced per usage whose `usageUnit` is the case.\n */\n PER_CASE = 'PER_CASE',\n /** The service is part of a plan the client subscribes to; a case is not billed on its own. */\n INCLUDED_IN_PLAN = 'INCLUDED_IN_PLAN',\n /** The firm bills outside the application (under its engagement letters, from its own tools). Nothing is metered here. */\n BILLED_OUTSIDE = 'BILLED_OUTSIDE',\n}\n\nconst SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n/**\n * A fresh slug schema per field, never one shared instance: the workbench reads an entry's own key out of its reading\n * by decorating that key's schema, and a decoration on a shared instance would reach every field holding it.\n */\nconst slug = () => z.string().regex(SLUG_PATTERN);\n/** A fresh non-empty text schema per field, for the same reason as {@link slug}: the workbench decorates a field's schema. */\nconst text = () => z.string().trim().min(1);\n/**\n * An ISO-8601 duration (`PT8H`, `P2D`) by the engine's own rule for a review deadline (#2305 review): no years or months,\n * and positive. A looser rule here passed `P1M`, which the gate the coding agent declares from it then refused. The\n * pattern stays on the schema so a generation contract carries it; the refinement adds what a pattern cannot say.\n */\nconst reviewDeadlineDuration = () => z.string()\n .regex(REVIEW_DURATION_PATTERN, 'Expected an ISO-8601 duration without years or months, such as \"PT8H\" or \"P2D\".')\n .refine((value) => parseReviewDurationMs(value) !== undefined, 'Expected a positive duration, such as \"PT8H\" or \"P2D\".');\n\n/** The application's own core roles: never a role a member of an organization holds. */\nconst CORE_APP_ROLE_NAMES: ReadonlySet<string> = new Set<string>(Object.values(CORE_APP_ROLES));\n\n/** Whose people hold a qualification's role: the firm's, for the client, or the client's own (#2305 S6). */\nexport enum ServiceMethodQualificationHolder {\n /**\n * The firm's people hold it FOR the client: the client entrusts the firm with it, so it reaches them through the\n * relationship the firm serves the client through (`confers.roles`). Every firm-held role is checked to be conferred,\n * an engine role as much as the application's, except `ORG_REPRESENTATIVE`, which that relationship confers by default.\n * The client's administration (`ORG_OWNER`, `ORG_ADMIN`) is never the firm's: a relationship may not confer it, so the\n * method refuses a firm-held qualification on it. An application role that INHERITS administration is not visible\n * here; the backend's startup check refuses conferring it (`CONFERRED_ROLE_REACHES_ADMINISTRATION`).\n */\n FIRM = 'FIRM',\n /** The client's own staff hold it, as members of the client's organization. Nothing is conferred. */\n CLIENT = 'CLIENT',\n}\n\n/**\n * Who may be trusted with a decision, and on what ground.\n *\n * - `role` — the role whose holders take the decision, as the role table keys it. Required: a decision is always\n * routed to holders of a role, and a named person must hold it too.\n * - `heldBy` — whose people hold that role: the firm's, for the client (conferred through the service relationship,\n * the client entrusting the firm with it), or the client's own staff. Required, because the two need different\n * things built: only a firm-held role is conferred through the relationship.\n * - `professionalQualificationKind` — set when the PERSON must also be qualified (a chartered accountant, a licensed\n * engineer): a kind the application declares in `professionalQualificationKinds`. The decision then admits only a role\n * holder with a verified, current qualification of that kind, read in the organization that employs them. Omitted\n * when the role alone is the right floor.\n *\n * The choice between the two (and a named person, which is a decision point's `route`) is taught by the\n * `professional-qualifications` skill: the role says what the client entrusted, the qualification that this person may\n * sign.\n */\nexport const ServiceMethodQualificationSchema = z.strictObject({\n qualificationRef: slug(),\n /** What the firm calls it — \"qualified accountant\", \"engagement partner\". */\n label: text(),\n role: z.string().regex(APPLICATION_ROLE_NAME_PATTERN),\n heldBy: z.enum(ServiceMethodQualificationHolder).systemEnum('ServiceMethodQualificationHolder'),\n professionalQualificationKind: z.string().regex(LABEL_KEY_SEGMENT_PATTERN).optional(),\n});\nexport type ServiceMethodQualification = z.infer<typeof ServiceMethodQualificationSchema>;\n\n/** The parts of a method owed (#3484): a fresh schema per use, for the reason {@link slug} gives. */\nexport const serviceMethodOwedParts = () => z.array(z.enum(ServiceMethodOwedPart).systemEnum('ServiceMethodOwedPart')).default([]);\n\n/** One case: the unit of work a service is delivered in, and the resource whose rows are the cases. */\nexport const ServiceMethodCaseSchema = z.strictObject({\n /** The resource's planned ref (`closes`, `audit-engagements`): the domain plan inventories it, and the build plan makes it the work unit. */\n caseRef: slug(),\n label: text(),\n /** What opens a case — \"the first business day of the month\", \"the client signs the engagement letter\". */\n opensWhen: text(),\n /** What closes a case — \"the engagement partner signs the period off\". */\n closesWhen: text(),\n});\nexport type ServiceMethodCase = z.infer<typeof ServiceMethodCaseSchema>;\n\n/** One stage of a case. In order: the case's lifecycle, first stage first. */\nexport const ServiceMethodStageSchema = z.strictObject({\n stageRef: slug(),\n label: text(),\n /** What is true of a case in this stage. */\n meaning: text(),\n});\nexport type ServiceMethodStage = z.infer<typeof ServiceMethodStageSchema>;\n\n/** One step of a case: something an agent, a person or the client does in a stage. */\nexport const ServiceMethodStepSchema = z.strictObject({\n stepRef: slug(),\n stageRef: slug(),\n /** What the step does, in the firm's words. */\n does: text(),\n /**\n * Who does it. Absent only while the method declares {@link ServiceMethodOwedPart.AGENT_WORK} owed (#3484): the step's\n * performer then waits on that answer, and nothing is derived for it.\n */\n performedBy: z.enum(ServiceMethodStepPerformer).systemEnum('ServiceMethodStepPerformer').optional(),\n /** AGENT steps only: how the agent is started and talked to. Refused on a PERSON or CLIENT step, and on one with no performer. */\n agentShape: z.enum(BuildPlanAgentShape).systemEnum('BuildPlanAgentShape').optional(),\n /** What the step reads, by domain-plan resource refs. */\n readsRefs: z.array(slug()).default([]),\n /** What it produces or changes, by domain-plan resource refs. */\n producesRefs: z.array(slug()).default([]),\n});\nexport type ServiceMethodStep = z.infer<typeof ServiceMethodStepSchema>;\n\n/**\n * One decision in a case: what is decided at a step, and who may decide it.\n *\n * The route is the engine's: OWNER (the person whose turn raised it confirms it — never qualified, so it names no\n * qualification), ROLE (any holder of the qualification's role, and its professional qualification when it names one)\n * or ASSIGNEE (one named person, who must meet the same floor). Separation of the decider from the requester is\n * enforced by the engine on every non-OWNER route and is not restated here.\n */\nexport const ServiceMethodDecisionPointSchema = z.strictObject({\n decisionRef: slug(),\n stepRef: slug(),\n /** What is decided — \"post the proposed adjustment to the client's books\". */\n decides: text(),\n route: z.enum(HumanDecision_RouteKind).systemEnum('HumanDecision_RouteKind'),\n /** Who is trusted with it. Required on a ROLE or ASSIGNEE route, refused on an OWNER route. */\n qualificationRef: slug().optional(),\n /** ASSIGNEE only: who the one person is, in the firm's words — \"the client's engagement partner\". */\n assignee: text().optional(),\n /** When the decision should be taken, as the engine declares it: a duration, counted on elapsed or business time. */\n decisionDeadline: z.strictObject({\n at: reviewDeadlineDuration(),\n basis: z.enum(ReviewClockBasis).systemEnum('ReviewClockBasis').default(ReviewClockBasis.ELAPSED),\n }).optional(),\n});\nexport type ServiceMethodDecisionPoint = z.infer<typeof ServiceMethodDecisionPointSchema>;\n\n/** One thing the client receives from a case. */\nexport const ServiceMethodDeliverableSchema = z.strictObject({\n deliverableRef: slug(),\n label: text(),\n /** The stage at which it is produced. */\n stageRef: slug(),\n /** The resource it is produced from, by domain-plan ref; it becomes a document generated from that resource. */\n fromResourceRef: slug(),\n});\nexport type ServiceMethodDeliverable = z.infer<typeof ServiceMethodDeliverableSchema>;\n\n/** One service the firm delivers. */\nexport const ServiceMethodServiceSchema = z.strictObject({\n serviceRef: slug(),\n label: text(),\n /** What the client gets from it, and why they come to the firm for it. */\n purpose: text(),\n case: ServiceMethodCaseSchema,\n stages: z.array(ServiceMethodStageSchema).min(1),\n steps: z.array(ServiceMethodStepSchema).min(1),\n decisionPoints: z.array(ServiceMethodDecisionPointSchema).default([]),\n deliverables: z.array(ServiceMethodDeliverableSchema).default([]),\n /**\n * How long a case's evidence is kept, in the engine's retention vocabulary, and on what ground — \"accounting\n * documents are kept ten years under the French commercial code\". Becomes the retention binding of every resource holding\n * the case's evidence: the case resource and each deliverable's resource (#2305 S6). A resource that is evidence of two\n * services is kept in one class, so two services naming it must agree.\n */\n evidenceRetention: z.strictObject({\n retentionClass: z.enum(DataRetentionClass).systemEnum('DataRetentionClass'),\n ground: text(),\n }),\n pricing: z.enum(ServiceMethodPricing).systemEnum('ServiceMethodPricing'),\n});\nexport type ServiceMethodService = z.infer<typeof ServiceMethodServiceSchema>;\n\n/** One reason an expert corrects an agent's work, recorded with each correction. */\nexport const ServiceMethodCorrectionReasonSchema = z.strictObject({\n // A fresh instance: this is the correction-reason aspect's own key, which the workbench hides by decorating it (#2305 review).\n reasonCode: agentWorkReasonCode(),\n label: text(),\n});\nexport type ServiceMethodCorrectionReason = z.infer<typeof ServiceMethodCorrectionReasonSchema>;\n\n/**\n * THE service-method payload.\n *\n * **Artifact-family id: `service-method`.** Produced by the playbook `top_down.service-method` (the creator's services\n * and signatories in, this structure out), or authored by hand, as Wonder Ledger's was. The domain plan and the build\n * plan derive from it, and `findServiceMethodDerivationGaps` checks that they realize it whole.\n *\n * - `services` — at least one: a firm with no service has no method to write down.\n * - `qualifications` — who may be trusted with each decision; every ROLE or ASSIGNEE decision point names one.\n * - `clientParticipation` — what the client provides and approves across cases, in the firm's words.\n * - `reviewCalendar` — when the firm's reviewers are working, the engine's own calendar. Required as soon as a decision\n * deadline counts business time; otherwise optional.\n * - `correctionReasons` — why an expert corrects an agent, recorded with each correction. Empty is an answer.\n * - `owed` — the parts the creator left not decided yet ({@link ServiceMethodOwedPart}), each once. Empty: nothing is owed.\n */\nexport const ServiceMethodSchema = z.object({\n version: z.enum(ServiceMethodVersion).default(ServiceMethodVersion.V1),\n services: z.array(ServiceMethodServiceSchema).min(1),\n qualifications: z.array(ServiceMethodQualificationSchema).default([]),\n clientParticipation: text(),\n reviewCalendar: ReviewCalendarSchema.optional(),\n correctionReasons: z.array(ServiceMethodCorrectionReasonSchema).default([]),\n owed: serviceMethodOwedParts(),\n}).superRefine((method, context) => {\n for (const issue of serviceMethodIssues(method)) context.addIssue({ code: 'custom', message: issue.message, path: issue.path });\n});\nexport type ServiceMethod = z.infer<typeof ServiceMethodSchema>;\n/** @wildo_source:part:end service-method.config */\n\n/** One structural problem in a method, with where it is. */\nexport interface ServiceMethodIssue {\n readonly message: string;\n readonly path: (string | number)[];\n}\n\n/**\n * Everything structurally wrong with a method, each as a sentence naming the fix. The schema refuses a method with any;\n * exported so the family validator and the playbook's repair loop read the same list.\n *\n * Checked: refs unique where they are addressed (services, cases, qualifications across the method; stages, steps,\n * decisions and deliverables within their service); every step's stage, every decision's step, every deliverable's\n * stage exist in its service; an AGENT step names its agent shape and no other step does; an OWNER decision names no\n * qualification and a ROLE or ASSIGNEE decision names one that exists; only an ASSIGNEE decision names its assignee,\n * and it must; a business-time deadline needs the review calendar; a step names its performer unless the method owes\n * its agent work (#3484), and an owed part is declared once.\n */\nexport function serviceMethodIssues(method: {\n readonly services: readonly z.input<typeof ServiceMethodServiceSchema>[];\n readonly qualifications?: readonly z.input<typeof ServiceMethodQualificationSchema>[];\n readonly reviewCalendar?: unknown;\n readonly correctionReasons?: readonly z.input<typeof ServiceMethodCorrectionReasonSchema>[];\n readonly owed?: readonly ServiceMethodOwedPart[];\n}): ServiceMethodIssue[] {\n const issues: ServiceMethodIssue[] = [];\n const duplicate = <T>(items: readonly T[], refOf: (item: T) => string, path: (index: number) => (string | number)[], what: string): void => {\n const seen = new Set<string>();\n items.forEach((item, index) => {\n const ref = refOf(item);\n if (seen.has(ref)) issues.push({ message: `${what} ${ref} is declared twice; name each once.`, path: path(index) });\n seen.add(ref);\n });\n };\n const qualifications = method.qualifications ?? [];\n duplicate(method.services, (service) => service.serviceRef, (index) => ['services', index, 'serviceRef'], 'Service');\n duplicate(method.services, (service) => service.case.caseRef, (index) => ['services', index, 'case', 'caseRef'], 'Case');\n duplicate(qualifications, (qualification) => qualification.qualificationRef, (index) => ['qualifications', index, 'qualificationRef'], 'Qualification');\n // #2305 S6: the client's administration is never conferred to the firm, so a firm-held qualification on it could never\n // be built (the relationship may not confer it, and the decisions would reach nobody).\n qualifications.forEach((qualification, index) => {\n // #2305 review C2: a decision is routed to a role an organization's member holds. An application role, a role only an\n // engine inbound handler holds, and a capability role a relationship lends through a grant are none of those, so a\n // qualification on one could never be held by the person deciding.\n if (CORE_APP_ROLE_NAMES.has(qualification.role) || !roleMayBeHeldByMembership(qualification.role)) {\n issues.push({\n message: `Qualification ${qualification.qualificationRef} names the role ${qualification.role}, which no member of an organization holds (an application role, a role only an inbound handler holds, or a capability lent through a relationship). Name an organization role.`,\n path: ['qualifications', index, 'role'],\n });\n }\n if (qualification.heldBy === ServiceMethodQualificationHolder.FIRM\n && (qualification.role === CORE_ORG_ROLES.ORG_OWNER || qualification.role === CORE_ORG_ROLES.ORG_ADMIN)) {\n issues.push({\n message: `Qualification ${qualification.qualificationRef} is held by the firm's people with the role ${qualification.role}, the client's administration, which no relationship may confer. Name the role the client entrusts the firm with, or mark it held by the client.`,\n path: ['qualifications', index, 'heldBy'],\n });\n }\n });\n duplicate(method.correctionReasons ?? [], (reason) => reason.reasonCode, (index) => ['correctionReasons', index, 'reasonCode'], 'Correction reason');\n duplicate(method.owed ?? [], (part) => part, (index) => ['owed', index], 'Owed part');\n const agentWorkOwed = (method.owed ?? []).includes(ServiceMethodOwedPart.AGENT_WORK);\n const qualificationRefs = new Set(qualifications.map((qualification) => qualification.qualificationRef));\n\n method.services.forEach((service, serviceIndex) => {\n const at = (...rest: (string | number)[]): (string | number)[] => ['services', serviceIndex, ...rest];\n const stages = service.stages ?? [];\n const steps = service.steps ?? [];\n const decisions = service.decisionPoints ?? [];\n const deliverables = service.deliverables ?? [];\n duplicate(stages, (stage) => stage.stageRef, (index) => at('stages', index, 'stageRef'), `Stage of ${service.serviceRef}`);\n duplicate(steps, (step) => step.stepRef, (index) => at('steps', index, 'stepRef'), `Step of ${service.serviceRef}`);\n duplicate(decisions, (decision) => decision.decisionRef, (index) => at('decisionPoints', index, 'decisionRef'), `Decision of ${service.serviceRef}`);\n duplicate(deliverables, (deliverable) => deliverable.deliverableRef, (index) => at('deliverables', index, 'deliverableRef'), `Deliverable of ${service.serviceRef}`);\n const stageRefs = new Set(stages.map((stage) => stage.stageRef));\n const stepRefs = new Set(steps.map((step) => step.stepRef));\n\n steps.forEach((step, index) => {\n if (!stageRefs.has(step.stageRef)) issues.push({ message: `Step ${step.stepRef} is in stage ${step.stageRef}, which ${service.serviceRef} does not declare.`, path: at('steps', index, 'stageRef') });\n if (step.performedBy === ServiceMethodStepPerformer.AGENT && !step.agentShape) {\n issues.push({ message: `Step ${step.stepRef} is performed by an agent and names no agentShape: say how the agent is started.`, path: at('steps', index, 'agentShape') });\n }\n if (step.performedBy === undefined) {\n // #3484: a performer may wait only on the agent-work answer the method says it owes.\n if (!agentWorkOwed) {\n issues.push({ message: `Step ${step.stepRef} names no performer: say who does it, or declare AGENT_WORK in \\`owed\\` when which work agents do is not decided yet.`, path: at('steps', index, 'performedBy') });\n }\n if (step.agentShape) {\n issues.push({ message: `Step ${step.stepRef} names no performer and names an agentShape; only an agent step does.`, path: at('steps', index, 'agentShape') });\n }\n } else if (step.performedBy !== ServiceMethodStepPerformer.AGENT && step.agentShape) {\n issues.push({ message: `Step ${step.stepRef} is performed by a ${String(step.performedBy).toLowerCase()} and names an agentShape; only an agent step does.`, path: at('steps', index, 'agentShape') });\n }\n });\n\n decisions.forEach((decision, index) => {\n if (!stepRefs.has(decision.stepRef)) issues.push({ message: `Decision ${decision.decisionRef} is taken at step ${decision.stepRef}, which ${service.serviceRef} does not declare.`, path: at('decisionPoints', index, 'stepRef') });\n if (decision.route === HumanDecision_RouteKind.OWNER) {\n if (decision.qualificationRef) {\n issues.push({ message: `Decision ${decision.decisionRef} is confirmed by the person who asked (OWNER), whom nothing vets: it names no qualification. Route it to a ROLE to require one.`, path: at('decisionPoints', index, 'qualificationRef') });\n }\n } else if (!decision.qualificationRef) {\n issues.push({ message: `Decision ${decision.decisionRef} is routed to a ${decision.route} and names no qualification: say who may be trusted with it.`, path: at('decisionPoints', index, 'qualificationRef') });\n } else if (!qualificationRefs.has(decision.qualificationRef)) {\n issues.push({ message: `Decision ${decision.decisionRef} names qualification ${decision.qualificationRef}, which the method does not declare.`, path: at('decisionPoints', index, 'qualificationRef') });\n }\n if (decision.route === HumanDecision_RouteKind.ASSIGNEE && !decision.assignee) {\n issues.push({ message: `Decision ${decision.decisionRef} goes to one named person (ASSIGNEE): say who, in the firm's words.`, path: at('decisionPoints', index, 'assignee') });\n }\n if (decision.route !== HumanDecision_RouteKind.ASSIGNEE && decision.assignee) {\n issues.push({ message: `Decision ${decision.decisionRef} names an assignee but is routed to a ${decision.route}; only an ASSIGNEE decision goes to one named person.`, path: at('decisionPoints', index, 'assignee') });\n }\n if (decision.decisionDeadline?.basis === ReviewClockBasis.CALENDAR && !method.reviewCalendar) {\n issues.push({ message: `Decision ${decision.decisionRef} counts its deadline in business time, and the method declares no reviewCalendar.`, path: at('decisionPoints', index, 'decisionDeadline', 'basis') });\n }\n });\n\n deliverables.forEach((deliverable, index) => {\n if (!stageRefs.has(deliverable.stageRef)) issues.push({ message: `Deliverable ${deliverable.deliverableRef} is produced at stage ${deliverable.stageRef}, which ${service.serviceRef} does not declare.`, path: at('deliverables', index, 'stageRef') });\n });\n });\n\n // #2305 S6: a resource holding the evidence of two services has ONE retention binding, so they must keep it alike;\n // otherwise no build plan could bind it for both, and the build plan would be blamed for the method's contradiction.\n const evidenceClass = new Map<string, { readonly serviceRef: string; readonly retentionClass: string }>();\n method.services.forEach((service, serviceIndex) => {\n const retentionClass = service.evidenceRetention?.retentionClass;\n if (retentionClass === undefined) return;\n const resources = new Set([service.case?.caseRef, ...(service.deliverables ?? []).map((deliverable) => deliverable.fromResourceRef)]);\n for (const resourceRef of resources) {\n if (resourceRef === undefined) continue;\n const first = evidenceClass.get(resourceRef);\n if (first === undefined) {\n evidenceClass.set(resourceRef, { serviceRef: service.serviceRef, retentionClass });\n } else if (first.retentionClass !== retentionClass) {\n issues.push({\n message: `Resource ${resourceRef} holds evidence of ${first.serviceRef} (kept as ${first.retentionClass}) and of ${service.serviceRef} (kept as ${retentionClass}); a resource is kept in one class, so the two services must agree.`,\n path: ['services', serviceIndex, 'evidenceRetention', 'retentionClass'],\n });\n }\n }\n });\n return issues;\n}\n"]}
1
+ {"version":3,"file":"service-method.schemas.js","sourceRoot":"","sources":["../../../../src/_core/service-method/service-method.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,6GAA6G;AAC7G,+GAA+G;AAC/G,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,6BAA6B,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAEjH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAN,IAAY,oBAEX;AAFD,WA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,aAAa,cAAc,qEAAqE;oBACrO,IAAI,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,gBAAgB,CAAC;iBACxE,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { z } from 'zod';\n// Side-effect import: this module calls `.systemEnum()` at load, so the decorators must be installed first —\n// never by the importer's luck (#966). A named import used only as a type would be elided and install nothing.\nimport '@wildo-ai/zod-decorators';\n\nimport { ElectronicSignature_Level } from '@wildo-ai/external-connectors-models';\nimport {\n agentWorkReasonCode,\n CORE_APP_ROLES,\n CORE_ORG_ROLES,\n DataRetentionClass,\n HumanDecision_RouteKind,\n LABEL_KEY_SEGMENT_PATTERN,\n REVIEW_DURATION_PATTERN,\n ReviewCalendarSchema,\n ReviewClockBasis,\n parseReviewDurationMs,\n roleMayBeHeldByMembership,\n} from '@wildo-ai/saas-models';\n\nimport { APPLICATION_ROLE_NAME_PATTERN, BuildPlanAgentShape } from '../build-plan/build-plan-task-graph.schemas';\n\n/**\n * @wildo_source:part:start service-method.config facet:layer:specification facet:family:service-method\n *\n * THE FIRM'S METHOD (#2305): the services a service firm delivers, and for each one how a case is worked — its stages,\n * the steps agents, people and the client take, the decisions only a qualified person may take, what the client\n * receives, how long the evidence is kept and how the service is priced.\n *\n * ## Why this family exists\n *\n * An AI-native service platform is built out of parts the engine already has — agents and autonomous agents, tool\n * approval gates routed to the requester, a role or a named person, a review calendar, expert corrections, a resource\n * declared as the unit of work, roles conferred through a relationship, per-person professional qualifications. Before\n * this family, none of them was reachable from the creation lane except through the wording of a requirement: no\n * family named an agent, a gate or a case, so nothing could check that the method was built whole.\n *\n * This family is the ONE place the method is written down. The families downstream READ it rather than each hold a\n * piece of it, so the method can be reviewed as one thing and its derivation checked as total: the domain plan makes\n * each service's case a resource with its stages as the lifecycle, the build plan makes each case its work unit, each\n * agent step an agent, each decision point a gate or an agent's review question, each service priced per case a usage\n * recording on its case, each deliverable a document, the case's evidence a retention binding, and each role the firm's\n * people hold for a client, other than `ORG_REPRESENTATIVE`, a role its relationship confers. `findServiceMethodDerivationGaps` checks the parts a function\n * can compare (each case's resource, lifecycle and work unit, each agent step's agent, each decision's realization,\n * route, role and qualification, each role's declaration and conferral, each per-case price's recording, each\n * deliverable's document, each evidence resource's retention class): the coherence report names what is missing, and a\n * candidate build plan that leaves out what IT must realize is refused. A decision's deadline, a step's resources and\n * the client's participation are not compared.\n *\n * ## What the creator supplies, and what they do not\n *\n * The creator describes each service in their own words; the playbook drafts this structure; validation checks it;\n * the creator accepts it. Every vocabulary here is the engine's own (routes, agent shapes, retention classes, clock\n * bases, the review calendar), so a method that validates is one the engine can run.\n *\n * Firm-shaped, and reachable from ANY line by need (#2305 D3): the B2B SaaS and internal-tool lines declare it not\n * applicable, and a feature line that needs it brings it back, with the operator-with-clients structure it rests on,\n * laid down by the same function the service-firm line uses (`describeFirmStructureNeed`).\n */\nexport enum ServiceMethodVersion {\n V1 = 'v1',\n}\n\n/** Who performs one step of a case. */\nexport enum ServiceMethodStepPerformer {\n /** An agent does it. The step names the agent's shape, which decides how it is started and the skill it is built with. */\n AGENT = 'AGENT',\n /** One of the firm's people does it in the application. */\n PERSON = 'PERSON',\n /** The client provides or does it (sends documents, answers a question, approves a deliverable). */\n CLIENT = 'CLIENT',\n}\n\n/**\n * A part of the method the creator left NOT DECIDED YET (#3484), which the method then states as OWED rather than leaving\n * absent: an absent part reads as an answer (\"no qualified decisions\", \"no agent work\") in a domain where that answer\n * is consequential.\n *\n * A method-level declaration, because the two interview questions it answers are asked of the whole method, not of one\n * service. Considered and rejected: a \"not decided\" member of {@link ServiceMethodStepPerformer} (it would put a standing\n * among the performers and make every reader of a performer handle a non-performer), and per-decision \"undetermined\"\n * routes (a deferred answer leaves WHICH decisions need a qualified person open, so there is no decision to mark).\n */\nexport enum ServiceMethodOwedPart {\n /**\n * Which decisions in a case a qualified person must take, and who they must be (the `signatories` question). While\n * owed, the method's `qualifications` and `decisionPoints` hold only what is known, and their emptiness is NOT a\n * statement that no decision needs a qualified person.\n */\n QUALIFIED_DECISIONS = 'QUALIFIED_DECISIONS',\n /**\n * Which of the firm's work agents do (the `agent-work` question). While owed, a step whose performer depends on that\n * answer names none, and no agent is derived for it; the client's own steps still name the client.\n */\n AGENT_WORK = 'AGENT_WORK',\n}\n\n/** How a service is priced to the client. */\nexport enum ServiceMethodPricing {\n /**\n * Each case is billed: a metered price whose unit is the service's case, one usage unit recorded when a case closes,\n * once per case however often it is reopened (`recordsUsage` with `oncePerRecord` on the closing operation, #2305 S5).\n * The engine's metered billing is how per-unit pricing is done; no new pricing axis is needed. The business model\n * sells it as a plan priced per usage whose `usageUnit` is the case.\n */\n PER_CASE = 'PER_CASE',\n /** The service is part of a plan the client subscribes to; a case is not billed on its own. */\n INCLUDED_IN_PLAN = 'INCLUDED_IN_PLAN',\n /** The firm bills outside the application (under its engagement letters, from its own tools). Nothing is metered here. */\n BILLED_OUTSIDE = 'BILLED_OUTSIDE',\n}\n\nconst SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n/**\n * A fresh slug schema per field, never one shared instance: the workbench reads an entry's own key out of its reading\n * by decorating that key's schema, and a decoration on a shared instance would reach every field holding it.\n */\nconst slug = () => z.string().regex(SLUG_PATTERN);\n/** A fresh non-empty text schema per field, for the same reason as {@link slug}: the workbench decorates a field's schema. */\nconst text = () => z.string().trim().min(1);\n/**\n * An ISO-8601 duration (`PT8H`, `P2D`) by the engine's own rule for a review deadline (#2305 review): no years or months,\n * and positive. A looser rule here passed `P1M`, which the gate the coding agent declares from it then refused. The\n * pattern stays on the schema so a generation contract carries it; the refinement adds what a pattern cannot say.\n */\nconst reviewDeadlineDuration = () => z.string()\n .regex(REVIEW_DURATION_PATTERN, 'Expected an ISO-8601 duration without years or months, such as \"PT8H\" or \"P2D\".')\n .refine((value) => parseReviewDurationMs(value) !== undefined, 'Expected a positive duration, such as \"PT8H\" or \"P2D\".');\n\n/** The application's own core roles: never a role a member of an organization holds. */\nconst CORE_APP_ROLE_NAMES: ReadonlySet<string> = new Set<string>(Object.values(CORE_APP_ROLES));\n\n/** Whose people hold a qualification's role: the firm's, for the client, or the client's own (#2305 S6). */\nexport enum ServiceMethodQualificationHolder {\n /**\n * The firm's people hold it FOR the client: the client entrusts the firm with it, so it reaches them through the\n * relationship the firm serves the client through (`confers.roles`). Every firm-held role is checked to be conferred,\n * an engine role as much as the application's, except `ORG_REPRESENTATIVE`, which that relationship confers by default.\n * The client's administration (`ORG_OWNER`, `ORG_ADMIN`) is never the firm's: a relationship may not confer it, so the\n * method refuses a firm-held qualification on it. An application role that INHERITS administration is not visible\n * here; the backend's startup check refuses conferring it (`CONFERRED_ROLE_REACHES_ADMINISTRATION`).\n */\n FIRM = 'FIRM',\n /** The client's own staff hold it, as members of the client's organization. Nothing is conferred. */\n CLIENT = 'CLIENT',\n}\n\n/**\n * Who may be trusted with a decision, and on what ground.\n *\n * - `role` — the role whose holders take the decision, as the role table keys it. Required: a decision is always\n * routed to holders of a role, and a named person must hold it too.\n * - `heldBy` — whose people hold that role: the firm's, for the client (conferred through the service relationship,\n * the client entrusting the firm with it), or the client's own staff. Required, because the two need different\n * things built: only a firm-held role is conferred through the relationship.\n * - `professionalQualificationKind` — set when the PERSON must also be qualified (a chartered accountant, a licensed\n * engineer): a kind the application declares in `professionalQualificationKinds`. The decision then admits only a role\n * holder with a verified, current qualification of that kind, read in the organization that employs them. Omitted\n * when the role alone is the right floor.\n *\n * The choice between the two (and a named person, which is a decision point's `route`) is taught by the\n * `professional-qualifications` skill: the role says what the client entrusted, the qualification that this person may\n * sign.\n */\nexport const ServiceMethodQualificationSchema = z.strictObject({\n qualificationRef: slug(),\n /** What the firm calls it — \"qualified accountant\", \"engagement partner\". */\n label: text(),\n role: z.string().regex(APPLICATION_ROLE_NAME_PATTERN),\n heldBy: z.enum(ServiceMethodQualificationHolder).systemEnum('ServiceMethodQualificationHolder'),\n professionalQualificationKind: z.string().regex(LABEL_KEY_SEGMENT_PATTERN).optional(),\n});\nexport type ServiceMethodQualification = z.infer<typeof ServiceMethodQualificationSchema>;\n\n/** The parts of a method owed (#3484): a fresh schema per use, for the reason {@link slug} gives. */\nexport const serviceMethodOwedParts = () => z.array(z.enum(ServiceMethodOwedPart).systemEnum('ServiceMethodOwedPart')).default([]);\n\n/** One case: the unit of work a service is delivered in, and the resource whose rows are the cases. */\nexport const ServiceMethodCaseSchema = z.strictObject({\n /** The resource's planned ref (`closes`, `audit-engagements`): the domain plan inventories it, and the build plan makes it the work unit. */\n caseRef: slug(),\n label: text(),\n /** What opens a case — \"the first business day of the month\", \"the client signs the engagement letter\". */\n opensWhen: text(),\n /** What closes a case — \"the engagement partner signs the period off\". */\n closesWhen: text(),\n});\nexport type ServiceMethodCase = z.infer<typeof ServiceMethodCaseSchema>;\n\n/** One stage of a case. In order: the case's lifecycle, first stage first. */\nexport const ServiceMethodStageSchema = z.strictObject({\n stageRef: slug(),\n label: text(),\n /** What is true of a case in this stage. */\n meaning: text(),\n});\nexport type ServiceMethodStage = z.infer<typeof ServiceMethodStageSchema>;\n\n/** One step of a case: something an agent, a person or the client does in a stage. */\nexport const ServiceMethodStepSchema = z.strictObject({\n stepRef: slug(),\n stageRef: slug(),\n /** What the step does, in the firm's words. */\n does: text(),\n /**\n * Who does it. Absent only while the method declares {@link ServiceMethodOwedPart.AGENT_WORK} owed (#3484): the step's\n * performer then waits on that answer, and nothing is derived for it.\n */\n performedBy: z.enum(ServiceMethodStepPerformer).systemEnum('ServiceMethodStepPerformer').optional(),\n /** AGENT steps only: how the agent is started and talked to. Refused on a PERSON or CLIENT step, and on one with no performer. */\n agentShape: z.enum(BuildPlanAgentShape).systemEnum('BuildPlanAgentShape').optional(),\n /** What the step reads, by domain-plan resource refs. */\n readsRefs: z.array(slug()).default([]),\n /** What it produces or changes, by domain-plan resource refs. */\n producesRefs: z.array(slug()).default([]),\n});\nexport type ServiceMethodStep = z.infer<typeof ServiceMethodStepSchema>;\n\n/**\n * One decision in a case: what is decided at a step, and who may decide it.\n *\n * The route is the engine's: OWNER (the person whose turn raised it confirms it — never qualified, so it names no\n * qualification), ROLE (any holder of the qualification's role, and its professional qualification when it names one)\n * or ASSIGNEE (one named person, who must meet the same floor). Separation of the decider from the requester is\n * enforced by the engine on every non-OWNER route and is not restated here.\n */\nexport const ServiceMethodDecisionPointSchema = z.strictObject({\n decisionRef: slug(),\n stepRef: slug(),\n /** What is decided — \"post the proposed adjustment to the client's books\". */\n decides: text(),\n route: z.enum(HumanDecision_RouteKind).systemEnum('HumanDecision_RouteKind'),\n /** Who is trusted with it. Required on a ROLE or ASSIGNEE route, refused on an OWNER route. */\n qualificationRef: slug().optional(),\n /** ASSIGNEE only: who the one person is, in the firm's words — \"the client's engagement partner\". */\n assignee: text().optional(),\n /** When the decision should be taken, as the engine declares it: a duration, counted on elapsed or business time. */\n decisionDeadline: z.strictObject({\n at: reviewDeadlineDuration(),\n basis: z.enum(ReviewClockBasis).systemEnum('ReviewClockBasis').default(ReviewClockBasis.ELAPSED),\n }).optional(),\n});\nexport type ServiceMethodDecisionPoint = z.infer<typeof ServiceMethodDecisionPointSchema>;\n\n/**\n * How a deliverable is signed once its approval releases it (#2915): the person who approved it signs it, at `level`.\n *\n * The engine's only signer is the approver (`FunctionTool_SignerSource.APPROVER`), so a signature is drawn from the\n * firm's domain, not asked: a deliverable a regulated professional puts their name to (an audit or review opinion, a\n * certified statement, an engagement letter the partner signs) is signed, an ordinary working document is not. `ADVANCED`\n * is the level that identifies the signer and makes any later change detectable (eIDAS Art. 26); `SIMPLE` where the\n * signature only records consent. The engine offers no qualified level (Paul, 2026-10-19), so a deliverable the firm's\n * law requires a handwritten-equivalent signature for is not one the engine signs: the method says so in prose instead.\n *\n * spec-cite: Regulation (EU) No 910/2014 (eIDAS) Art. 26 (requirements for an advanced electronic signature) and Art. 25(2)\n * (a qualified signature has the legal effect of a handwritten one) — paraphrased, not quoted.\n */\nexport const ServiceMethodDeliverableSignatureSchema = z.strictObject({\n level: z.enum(ElectronicSignature_Level).systemEnum('ElectronicSignature_Level'),\n /** Why the domain requires it, in the firm's words — \"the engagement partner signs every engagement letter\". */\n ground: text(),\n});\nexport type ServiceMethodDeliverableSignature = z.infer<typeof ServiceMethodDeliverableSignatureSchema>;\n\n/** One thing the client receives from a case. */\nexport const ServiceMethodDeliverableSchema = z.strictObject({\n deliverableRef: slug(),\n label: text(),\n /** The stage at which it is produced. */\n stageRef: slug(),\n /** The resource it is produced from, by domain-plan ref; it becomes a document generated from that resource. */\n fromResourceRef: slug(),\n /**\n * The decision point of the same service whose approval releases it to the client (#2915), when one does: the gate\n * realizing that decision then binds the deliverable's file, so its approval seal records exactly what was approved.\n * Absent when no person approves it before the client receives it. One decision approves at most one deliverable: a\n * gated tool binds one file.\n */\n approvedByDecisionRef: slug().optional(),\n /** The signature it needs once approved (#2915). Requires `approvedByDecisionRef`: the approver is who signs. */\n signature: ServiceMethodDeliverableSignatureSchema.optional(),\n});\nexport type ServiceMethodDeliverable = z.infer<typeof ServiceMethodDeliverableSchema>;\n\n/** One service the firm delivers. */\nexport const ServiceMethodServiceSchema = z.strictObject({\n serviceRef: slug(),\n label: text(),\n /** What the client gets from it, and why they come to the firm for it. */\n purpose: text(),\n case: ServiceMethodCaseSchema,\n stages: z.array(ServiceMethodStageSchema).min(1),\n steps: z.array(ServiceMethodStepSchema).min(1),\n decisionPoints: z.array(ServiceMethodDecisionPointSchema).default([]),\n deliverables: z.array(ServiceMethodDeliverableSchema).default([]),\n /**\n * How long a case's evidence is kept, in the engine's retention vocabulary, and on what ground — \"accounting\n * documents are kept ten years under the French commercial code\". Becomes the retention binding of every resource holding\n * the case's evidence: the case resource and each deliverable's resource (#2305 S6). A resource that is evidence of two\n * services is kept in one class, so two services naming it must agree.\n */\n evidenceRetention: z.strictObject({\n retentionClass: z.enum(DataRetentionClass).systemEnum('DataRetentionClass'),\n ground: text(),\n }),\n pricing: z.enum(ServiceMethodPricing).systemEnum('ServiceMethodPricing'),\n});\nexport type ServiceMethodService = z.infer<typeof ServiceMethodServiceSchema>;\n\n/** One reason an expert corrects an agent's work, recorded with each correction. */\nexport const ServiceMethodCorrectionReasonSchema = z.strictObject({\n // A fresh instance: this is the correction-reason aspect's own key, which the workbench hides by decorating it (#2305 review).\n reasonCode: agentWorkReasonCode(),\n label: text(),\n});\nexport type ServiceMethodCorrectionReason = z.infer<typeof ServiceMethodCorrectionReasonSchema>;\n\n/**\n * THE service-method payload.\n *\n * **Artifact-family id: `service-method`.** Produced by the playbook `top_down.service-method` (the creator's services\n * and signatories in, this structure out), or authored by hand, as Wonder Ledger's was. The domain plan and the build\n * plan derive from it, and `findServiceMethodDerivationGaps` checks that they realize it whole.\n *\n * - `services` — at least one: a firm with no service has no method to write down.\n * - `qualifications` — who may be trusted with each decision; every ROLE or ASSIGNEE decision point names one.\n * - `clientParticipation` — what the client provides and approves across cases, in the firm's words.\n * - `reviewCalendar` — when the firm's reviewers are working, the engine's own calendar. Required as soon as a decision\n * deadline counts business time; otherwise optional.\n * - `correctionReasons` — why an expert corrects an agent, recorded with each correction. Empty is an answer.\n * - `owed` — the parts the creator left not decided yet ({@link ServiceMethodOwedPart}), each once. Empty: nothing is owed.\n */\nexport const ServiceMethodSchema = z.object({\n version: z.enum(ServiceMethodVersion).default(ServiceMethodVersion.V1),\n services: z.array(ServiceMethodServiceSchema).min(1),\n qualifications: z.array(ServiceMethodQualificationSchema).default([]),\n clientParticipation: text(),\n reviewCalendar: ReviewCalendarSchema.optional(),\n correctionReasons: z.array(ServiceMethodCorrectionReasonSchema).default([]),\n owed: serviceMethodOwedParts(),\n}).superRefine((method, context) => {\n for (const issue of serviceMethodIssues(method)) context.addIssue({ code: 'custom', message: issue.message, path: issue.path });\n});\nexport type ServiceMethod = z.infer<typeof ServiceMethodSchema>;\n/** @wildo_source:part:end service-method.config */\n\n/** One structural problem in a method, with where it is. */\nexport interface ServiceMethodIssue {\n readonly message: string;\n readonly path: (string | number)[];\n}\n\n/**\n * Everything structurally wrong with a method, each as a sentence naming the fix. The schema refuses a method with any;\n * exported so the family validator and the playbook's repair loop read the same list.\n *\n * Checked: refs unique where they are addressed (services, cases, qualifications across the method; stages, steps,\n * decisions and deliverables within their service); every step's stage, every decision's step, every deliverable's\n * stage exist in its service; an AGENT step names its agent shape and no other step does; an OWNER decision names no\n * qualification and a ROLE or ASSIGNEE decision names one that exists; only an ASSIGNEE decision names its assignee,\n * and it must; a business-time deadline needs the review calendar; a step names its performer unless the method owes\n * its agent work (#3484), and an owed part is declared once; a deliverable's approving decision is one of its service's,\n * approves no other deliverable, and a signed deliverable names one (#2915).\n */\nexport function serviceMethodIssues(method: {\n readonly services: readonly z.input<typeof ServiceMethodServiceSchema>[];\n readonly qualifications?: readonly z.input<typeof ServiceMethodQualificationSchema>[];\n readonly reviewCalendar?: unknown;\n readonly correctionReasons?: readonly z.input<typeof ServiceMethodCorrectionReasonSchema>[];\n readonly owed?: readonly ServiceMethodOwedPart[];\n}): ServiceMethodIssue[] {\n const issues: ServiceMethodIssue[] = [];\n const duplicate = <T>(items: readonly T[], refOf: (item: T) => string, path: (index: number) => (string | number)[], what: string): void => {\n const seen = new Set<string>();\n items.forEach((item, index) => {\n const ref = refOf(item);\n if (seen.has(ref)) issues.push({ message: `${what} ${ref} is declared twice; name each once.`, path: path(index) });\n seen.add(ref);\n });\n };\n const qualifications = method.qualifications ?? [];\n duplicate(method.services, (service) => service.serviceRef, (index) => ['services', index, 'serviceRef'], 'Service');\n duplicate(method.services, (service) => service.case.caseRef, (index) => ['services', index, 'case', 'caseRef'], 'Case');\n duplicate(qualifications, (qualification) => qualification.qualificationRef, (index) => ['qualifications', index, 'qualificationRef'], 'Qualification');\n // #2305 S6: the client's administration is never conferred to the firm, so a firm-held qualification on it could never\n // be built (the relationship may not confer it, and the decisions would reach nobody).\n qualifications.forEach((qualification, index) => {\n // #2305 review C2: a decision is routed to a role an organization's member holds. An application role, a role only an\n // engine inbound handler holds, and a capability role a relationship lends through a grant are none of those, so a\n // qualification on one could never be held by the person deciding.\n if (CORE_APP_ROLE_NAMES.has(qualification.role) || !roleMayBeHeldByMembership(qualification.role)) {\n issues.push({\n message: `Qualification ${qualification.qualificationRef} names the role ${qualification.role}, which no member of an organization holds (an application role, a role only an inbound handler holds, or a capability lent through a relationship). Name an organization role.`,\n path: ['qualifications', index, 'role'],\n });\n }\n if (qualification.heldBy === ServiceMethodQualificationHolder.FIRM\n && (qualification.role === CORE_ORG_ROLES.ORG_OWNER || qualification.role === CORE_ORG_ROLES.ORG_ADMIN)) {\n issues.push({\n message: `Qualification ${qualification.qualificationRef} is held by the firm's people with the role ${qualification.role}, the client's administration, which no relationship may confer. Name the role the client entrusts the firm with, or mark it held by the client.`,\n path: ['qualifications', index, 'heldBy'],\n });\n }\n });\n duplicate(method.correctionReasons ?? [], (reason) => reason.reasonCode, (index) => ['correctionReasons', index, 'reasonCode'], 'Correction reason');\n duplicate(method.owed ?? [], (part) => part, (index) => ['owed', index], 'Owed part');\n const agentWorkOwed = (method.owed ?? []).includes(ServiceMethodOwedPart.AGENT_WORK);\n const qualificationRefs = new Set(qualifications.map((qualification) => qualification.qualificationRef));\n\n method.services.forEach((service, serviceIndex) => {\n const at = (...rest: (string | number)[]): (string | number)[] => ['services', serviceIndex, ...rest];\n const stages = service.stages ?? [];\n const steps = service.steps ?? [];\n const decisions = service.decisionPoints ?? [];\n const deliverables = service.deliverables ?? [];\n duplicate(stages, (stage) => stage.stageRef, (index) => at('stages', index, 'stageRef'), `Stage of ${service.serviceRef}`);\n duplicate(steps, (step) => step.stepRef, (index) => at('steps', index, 'stepRef'), `Step of ${service.serviceRef}`);\n duplicate(decisions, (decision) => decision.decisionRef, (index) => at('decisionPoints', index, 'decisionRef'), `Decision of ${service.serviceRef}`);\n duplicate(deliverables, (deliverable) => deliverable.deliverableRef, (index) => at('deliverables', index, 'deliverableRef'), `Deliverable of ${service.serviceRef}`);\n const stageRefs = new Set(stages.map((stage) => stage.stageRef));\n const stepRefs = new Set(steps.map((step) => step.stepRef));\n\n steps.forEach((step, index) => {\n if (!stageRefs.has(step.stageRef)) issues.push({ message: `Step ${step.stepRef} is in stage ${step.stageRef}, which ${service.serviceRef} does not declare.`, path: at('steps', index, 'stageRef') });\n if (step.performedBy === ServiceMethodStepPerformer.AGENT && !step.agentShape) {\n issues.push({ message: `Step ${step.stepRef} is performed by an agent and names no agentShape: say how the agent is started.`, path: at('steps', index, 'agentShape') });\n }\n if (step.performedBy === undefined) {\n // #3484: a performer may wait only on the agent-work answer the method says it owes.\n if (!agentWorkOwed) {\n issues.push({ message: `Step ${step.stepRef} names no performer: say who does it, or declare AGENT_WORK in \\`owed\\` when which work agents do is not decided yet.`, path: at('steps', index, 'performedBy') });\n }\n if (step.agentShape) {\n issues.push({ message: `Step ${step.stepRef} names no performer and names an agentShape; only an agent step does.`, path: at('steps', index, 'agentShape') });\n }\n } else if (step.performedBy !== ServiceMethodStepPerformer.AGENT && step.agentShape) {\n issues.push({ message: `Step ${step.stepRef} is performed by a ${String(step.performedBy).toLowerCase()} and names an agentShape; only an agent step does.`, path: at('steps', index, 'agentShape') });\n }\n });\n\n decisions.forEach((decision, index) => {\n if (!stepRefs.has(decision.stepRef)) issues.push({ message: `Decision ${decision.decisionRef} is taken at step ${decision.stepRef}, which ${service.serviceRef} does not declare.`, path: at('decisionPoints', index, 'stepRef') });\n if (decision.route === HumanDecision_RouteKind.OWNER) {\n if (decision.qualificationRef) {\n issues.push({ message: `Decision ${decision.decisionRef} is confirmed by the person who asked (OWNER), whom nothing vets: it names no qualification. Route it to a ROLE to require one.`, path: at('decisionPoints', index, 'qualificationRef') });\n }\n } else if (!decision.qualificationRef) {\n issues.push({ message: `Decision ${decision.decisionRef} is routed to a ${decision.route} and names no qualification: say who may be trusted with it.`, path: at('decisionPoints', index, 'qualificationRef') });\n } else if (!qualificationRefs.has(decision.qualificationRef)) {\n issues.push({ message: `Decision ${decision.decisionRef} names qualification ${decision.qualificationRef}, which the method does not declare.`, path: at('decisionPoints', index, 'qualificationRef') });\n }\n if (decision.route === HumanDecision_RouteKind.ASSIGNEE && !decision.assignee) {\n issues.push({ message: `Decision ${decision.decisionRef} goes to one named person (ASSIGNEE): say who, in the firm's words.`, path: at('decisionPoints', index, 'assignee') });\n }\n if (decision.route !== HumanDecision_RouteKind.ASSIGNEE && decision.assignee) {\n issues.push({ message: `Decision ${decision.decisionRef} names an assignee but is routed to a ${decision.route}; only an ASSIGNEE decision goes to one named person.`, path: at('decisionPoints', index, 'assignee') });\n }\n if (decision.decisionDeadline?.basis === ReviewClockBasis.CALENDAR && !method.reviewCalendar) {\n issues.push({ message: `Decision ${decision.decisionRef} counts its deadline in business time, and the method declares no reviewCalendar.`, path: at('decisionPoints', index, 'decisionDeadline', 'basis') });\n }\n });\n\n const decisionRefs = new Set(decisions.map((decision) => decision.decisionRef));\n const approvingDecisions = new Map<string, string>();\n deliverables.forEach((deliverable, index) => {\n if (!stageRefs.has(deliverable.stageRef)) issues.push({ message: `Deliverable ${deliverable.deliverableRef} is produced at stage ${deliverable.stageRef}, which ${service.serviceRef} does not declare.`, path: at('deliverables', index, 'stageRef') });\n // #2915: the approval that releases a deliverable is a decision of the same service, and binds one file.\n const approvedBy = deliverable.approvedByDecisionRef;\n if (approvedBy !== undefined) {\n if (!decisionRefs.has(approvedBy)) {\n issues.push({ message: `Deliverable ${deliverable.deliverableRef} is approved by decision ${approvedBy}, which ${service.serviceRef} does not declare.`, path: at('deliverables', index, 'approvedByDecisionRef') });\n }\n const first = approvingDecisions.get(approvedBy);\n if (first !== undefined) {\n issues.push({ message: `Decision ${approvedBy} approves both ${first} and ${deliverable.deliverableRef}; the tool that realizes it binds one file, so give each deliverable its own decision.`, path: at('deliverables', index, 'approvedByDecisionRef') });\n } else {\n approvingDecisions.set(approvedBy, deliverable.deliverableRef);\n }\n }\n if (deliverable.signature !== undefined && approvedBy === undefined) {\n issues.push({ message: `Deliverable ${deliverable.deliverableRef} is signed and no decision approves it: the person who approves a deliverable is who signs it, so name the approving decision (approvedByDecisionRef).`, path: at('deliverables', index, 'signature') });\n }\n });\n });\n\n // #2305 S6: a resource holding the evidence of two services has ONE retention binding, so they must keep it alike;\n // otherwise no build plan could bind it for both, and the build plan would be blamed for the method's contradiction.\n const evidenceClass = new Map<string, { readonly serviceRef: string; readonly retentionClass: string }>();\n method.services.forEach((service, serviceIndex) => {\n const retentionClass = service.evidenceRetention?.retentionClass;\n if (retentionClass === undefined) return;\n const resources = new Set([service.case?.caseRef, ...(service.deliverables ?? []).map((deliverable) => deliverable.fromResourceRef)]);\n for (const resourceRef of resources) {\n if (resourceRef === undefined) continue;\n const first = evidenceClass.get(resourceRef);\n if (first === undefined) {\n evidenceClass.set(resourceRef, { serviceRef: service.serviceRef, retentionClass });\n } else if (first.retentionClass !== retentionClass) {\n issues.push({\n message: `Resource ${resourceRef} holds evidence of ${first.serviceRef} (kept as ${first.retentionClass}) and of ${service.serviceRef} (kept as ${retentionClass}); a resource is kept in one class, so the two services must agree.`,\n path: ['services', serviceIndex, 'evidenceRetention', 'retentionClass'],\n });\n }\n }\n });\n return issues;\n}\n"]}
@@ -186,8 +186,8 @@ export declare function extractFieldSpecs(schema: z.ZodTypeAny, registryContext?
186
186
  *
187
187
  * @param registryContext - Optional registry context that turns on
188
188
  * FK target derivation for `foreignKeySpec` fields. The companion
189
- * resource-specifications path passes the resource's relationship
190
- * slice + `currentResourceType`; standalone test fixtures omit it.
189
+ * resource-specifications path passes the assembled registry's compiled
190
+ * relationships (#3051) + `currentResourceType`; standalone test fixtures omit it.
191
191
  */
192
192
  export declare function extractFieldSpecsFromFieldMap(fields: Record<string, z.ZodTypeAny>, origin?: ExtractedFieldSpec['origin'], registryContext?: ExtractFieldSpecsRegistryContext): ExtractedFieldSpec[];
193
193
  /**
@@ -202,7 +202,8 @@ export declare function extractFieldSpecsFromFieldMap(fields: Record<string, z.Z
202
202
  * @param registryContext - Optional registry context that turns on
203
203
  * FK target derivation for `foreignKeySpec` fields. The companion
204
204
  * resource-specifications handler passes
205
- * `{ currentResourceType, relationships: sharedRegistry.resourceRelationships }`;
205
+ * `{ currentResourceType, relationships }` with the registry startup assembles
206
+ * (`assembleResourceRegistry`, #3051), application and engine edges compiled together;
206
207
  * tests and non-resource extractor entry points may omit it.
207
208
  */
208
209
  export declare function extractResourceFieldSpecs(schema: z.ZodTypeAny, inheritanceDefinition?: ResourceConfiguration_InheritanceSchemaDefinition<any, z.ZodTypeAny>, registryContext?: ExtractFieldSpecsRegistryContext): ExtractedFieldSpec[];
@@ -1 +1 @@
1
- {"version":3,"file":"extract-field-specs.d.ts","sourceRoot":"","sources":["../../../../src/_core/utils/extract-field-specs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EACV,iDAAiD,EACjD,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EAerB,KAAK,iBAAiB,EAEtB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAyBlC;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC,iFAAiF;IACjF,IAAI,EAAE,qBAAqB,CAAC;IAC5B,gDAAgD;IAChD,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,gDAAgD;IAChD,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC;;;;OAIG;IACH,aAAa,CAAC,EAAE,yBAAyB,EAAE,CAAC;CAC7C;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,uBAAuB;IACtC,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,GAAG,CAAC,EAAE,iBAAiB,CAAC;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,M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;AA4GD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,CAAC,CAAC,UAAU,EACpB,eAAe,CAAC,EAAE,gCAAgC,GACjD,kBAAkB,EAAE,CAMtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,EACpC,MAAM,GAAE,kBAAkB,CAAC,QAAQ,CAAqB,EACxD,eAAe,CAAC,EAAE,gCAAgC,GACjD,kBAAkB,EAAE,CAEtB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,CAAC,CAAC,UAAU,EACpB,qBAAqB,CAAC,EAAE,iDAAiD,CAAC,GAAG,EAAE,CAAC,CAAC,UAAU,CAAC,EAC5F,eAAe,CAAC,EAAE,gCAAgC,GACjD,kBAAkB,EAAE,CAUtB"}
1
+ {"version":3,"file":"extract-field-specs.d.ts","sourceRoot":"","sources":["../../../../src/_core/utils/extract-field-specs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EACV,iDAAiD,EACjD,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EAerB,KAAK,iBAAiB,EAEtB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAyBlC;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC,iFAAiF;IACjF,IAAI,EAAE,qBAAqB,CAAC;IAC5B,gDAAgD;IAChD,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,gDAAgD;IAChD,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC;;;;OA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5B,CAAC,CAAC;KACJ,CAAC;CACH;AAwGD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,gCAAgC,GAAG,SAAS,GAC5D,IAAI,CAAC,yBAAyB,EAAE,kBAAkB,GAAG,4BAA4B,CAAC,GAAG,SAAS,CA2BhG;AA4GD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,CAAC,CAAC,UAAU,EACpB,eAAe,CAAC,EAAE,gCAAgC,GACjD,kBAAkB,EAAE,CAMtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,EACpC,MAAM,GAAE,kBAAkB,CAAC,QAAQ,CAAqB,EACxD,eAAe,CAAC,EAAE,gCAAgC,GACjD,kBAAkB,EAAE,CAEtB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,CAAC,CAAC,UAAU,EACpB,qBAAqB,CAAC,EAAE,iDAAiD,CAAC,GAAG,EAAE,CAAC,CAAC,UAAU,CAAC,EAC5F,eAAe,CAAC,EAAE,gCAAgC,GACjD,kBAAkB,EAAE,CAUtB"}
@@ -267,8 +267,8 @@ export function extractFieldSpecs(schema, registryContext) {
267
267
  *
268
268
  * @param registryContext - Optional registry context that turns on
269
269
  * FK target derivation for `foreignKeySpec` fields. The companion
270
- * resource-specifications path passes the resource's relationship
271
- * slice + `currentResourceType`; standalone test fixtures omit it.
270
+ * resource-specifications path passes the assembled registry's compiled
271
+ * relationships (#3051) + `currentResourceType`; standalone test fixtures omit it.
272
272
  */
273
273
  export function extractFieldSpecsFromFieldMap(fields, origin = { scope: 'main' }, registryContext) {
274
274
  return extractFieldSpecsFromShape(fields, origin, registryContext);
@@ -285,7 +285,8 @@ export function extractFieldSpecsFromFieldMap(fields, origin = { scope: 'main' }
285
285
  * @param registryContext - Optional registry context that turns on
286
286
  * FK target derivation for `foreignKeySpec` fields. The companion
287
287
  * resource-specifications handler passes
288
- * `{ currentResourceType, relationships: sharedRegistry.resourceRelationships }`;
288
+ * `{ currentResourceType, relationships }` with the registry startup assembles
289
+ * (`assembleResourceRegistry`, #3051), application and engine edges compiled together;
289
290
  * tests and non-resource extractor entry points may omit it.
290
291
  */
291
292
  export function extractResourceFieldSpecs(schema, inheritanceDefinition, registryContext) {
@@ -1 +1 @@
1
- {"version":3,"file":"extract-field-specs.js","sourceRoot":"","sources":["../../../../src/_core/utils/extract-field-specs.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,GAIb,MAAM,0BAA0B,CAAC;AAElC;;;GAGG;AACH,MAAM,mBAAmB,GAAG;IAC1B,YAAY,CAAC,WAAW;IACxB,YAAY,CAAC,WAAW;IACxB,YAAY,CAAC,YAAY;IACzB,YAAY,CAAC,SAAS;IACtB,YAAY,CAAC,aAAa;IAC1B,YAAY,CAAC,SAAS;IACtB,YAAY,CAAC,SAAS;IACtB,YAAY,CAAC,UAAU;IACvB,YAAY,CAAC,SAAS;IACtB,YAAY,CAAC,SAAS;IACtB,YAAY,CAAC,aAAa;IAC1B,YAAY,CAAC,UAAU;IACvB,YAAY,CAAC,eAAe;IAC5B,YAAY,CAAC,gBAAgB;IAC7B,YAAY,CAAC,UAAU;IACvB,YAAY,CAAC,WAAW;CAChB,CAAC;AA4IX;;;GAGG;AACH,SAAS,aAAa,CAAC,QAA6B;IAClD,KAAK,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,QAAQ,CA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ACxB,CAAC;IAED,OAAO;QACL,GAAG,cAAc;QACjB,GAAG,0BAA0B,CAAC,MAAM,EAAE,qBAAqB,EAAE,EAAE,EAAE,eAAe,CAAC;KAClF,CAAC;AACJ,CAAC","sourcesContent":["import type { z } from 'zod';\nimport type {\n ResourceConfiguration_InheritanceSchemaDefinition,\n ResourceRelationship,\n} from '@wildo-ai/saas-models';\nimport {\n CodePrimitiveKind,\n CollectionElementKind,\n getArrayItemSchema,\n getCustomFieldMetadata,\n getZodDef,\n getZodObjectShape,\n getZodType,\n isCodeSchema,\n isDurationSchema,\n isFileSchema,\n isMoneySchema,\n isPhoneSchema,\n isAddressSchema,\n isZodObject,\n unwrapSchema,\n ZodDecorator,\n type CodeEnumMemberRef,\n type CustomFieldMetadata,\n type FieldSpecBaseParams,\n} from '@wildo-ai/zod-decorators';\n\n/**\n * All `{primitive}Spec` decorator keys in `ZodDecorator`.\n * Used to scan `customFieldMetadata` for any spec entry.\n */\nconst SPEC_DECORATOR_KEYS = [\n ZodDecorator.STRING_SPEC,\n ZodDecorator.NUMBER_SPEC,\n ZodDecorator.BOOLEAN_SPEC,\n ZodDecorator.DATE_SPEC,\n ZodDecorator.DATETIME_SPEC,\n ZodDecorator.TIME_SPEC,\n ZodDecorator.ENUM_SPEC,\n ZodDecorator.MONEY_SPEC,\n ZodDecorator.CODE_SPEC,\n ZodDecorator.FILE_SPEC,\n ZodDecorator.DURATION_SPEC,\n ZodDecorator.PHONE_SPEC,\n ZodDecorator.BIGDECIMAL_SPEC,\n ZodDecorator.FOREIGN_KEY_SPEC,\n ZodDecorator.ARRAY_SPEC,\n ZodDecorator.OBJECT_SPEC,\n] as const;\n\n/**\n * Per-branch derived shape for a UNION element. Each entry mirrors the\n * scalar derivation we apply to non-union elements so downstream renderers\n * can describe a `users.appRoles = z.array(z.union([z.enum(...), z.string()]))`\n * shape without flattening the branches into an opaque `UNION` blob.\n */\nexport interface DerivedArrayElementBranch {\n /** Structural family of this branch (`PRIMITIVE` / `ENUM` / `OBJECT` / etc.). */\n kind: CollectionElementKind;\n /** Primitive kind when `kind === PRIMITIVE`. */\n primitiveType?: CodePrimitiveKind;\n}\n\n/**\n * Derived structural shape for an array element — derived purely from the\n * Zod element schema. The framework owns this surface; authors only declare\n * intent (`elementMeaning`, `enumDeclaration`, `notes`) on `arraySpec(...)`.\n */\nexport interface DerivedArrayElement {\n /** Structural family of each array element. */\n kind: CollectionElementKind;\n /** Primitive kind when `kind === PRIMITIVE`. */\n primitiveType?: CodePrimitiveKind;\n /**\n * Per-branch derivation when `kind === UNION` — preserves the structural\n * truth of unions instead of forcing authors to lie about a \"dominant\"\n * branch (B-3 decision: model UNION as a discrete kind with branches).\n */\n unionBranches?: DerivedArrayElementBranch[];\n}\n\n/**\n * Derived target of a `foreignKeySpec(...)` field — sourced from the\n * relationship registry by matching `foreignKeyField === <fieldName>` on\n * a relationship that lists the current resource on EITHER side. The FK\n * column lives on the MANY side (the child) and the target is the\n * opposite side (the parent), regardless of whether the registry author\n * declared the relationship as `(parent, child)` or `(child, parent)`.\n *\n * Populated in Phase 2B when the caller supplies an\n * `ExtractFieldSpecsRegistryContext`. When the caller does NOT supply one\n * (test fixtures, hand-built `additionalFieldSpecs`, non-resource\n * extractor entry points), this slice stays `undefined` — the\n * Phase 4 completeness validator is the single seam that requires it.\n */\nexport interface DerivedForeignKeyTarget {\n /** Resource type the FK points at (registry-derived). */\n resourceType: string;\n /** Optional code-symbol reference to the FK target's resource-type member. */\n ref?: CodeEnumMemberRef;\n}\n\n/**\n * Fail-closed signal for `foreignKeySpec` fields whose target could not\n * be resolved from the relationship registry. The Phase 4 completeness\n * validator consumes this to attribute the missing-relationship error to\n * the registry edge, not the renderer; renderers also surface the gap so\n * downstream prompts stay honest about the missing target instead of\n * silently dropping the FK line.\n *\n * Only emitted when the caller supplied an\n * `ExtractFieldSpecsRegistryContext` AND the lookup failed. When no\n * context is supplied the extractor cannot tell whether the FK is\n * unresolved or simply uninspected, so it stays `undefined`.\n */\nexport interface DerivedForeignKeyTargetUnresolved {\n /** Resource the FK lives on, as supplied by the caller. */\n fromResourceType: string;\n /** The FK field name that failed to resolve. */\n fieldName: string;\n /** Human-readable reason — used as-is in fail-closed error messages. */\n reason: string;\n}\n\n/**\n * Derived metadata that the framework extracts from the Zod schema (and,\n * in Phase 2B, the relationship registry). Authors no longer hand-author\n * structural fields the framework can derive — this object is the\n * single source of structural truth on an extracted spec.\n */\nexport interface ExtractedFieldSpecDerived {\n /** Present when the field is an `arraySpec`. */\n arrayElement?: DerivedArrayElement;\n /** Present when the field is a `foreignKeySpec` and the registry resolves the target (Phase 2B). */\n foreignKeyTarget?: DerivedForeignKeyTarget;\n /** Present when the field is a `foreignKeySpec` and the registry has no matching edge (Phase 2B). */\n foreignKeyTargetUnresolved?: DerivedForeignKeyTargetUnresolved;\n}\n\n/**\n * Caller-supplied context that lets the extractor derive registry-backed\n * facts. Currently scoped to FK target resolution; future registry-aware\n * derivations (e.g. cardinality inference for collection-shaped fields)\n * will read from the same context.\n *\n * Both fields are required for FK derivation to fire — passing\n * `relationships` without `currentResourceType` would let the matcher\n * silently resolve to a different resource's edge and is therefore\n * disallowed by the type itself.\n */\nexport interface ExtractFieldSpecsRegistryContext {\n /** Resource type that owns the schema being walked. */\n currentResourceType: string;\n /** Relationships that may concern the current resource. */\n relationships: readonly ResourceRelationship[];\n}\n\n/**\n * Extracted field specification entry — the JSON-safe representation\n * of a `{primitive}Spec()` decorator found on a schema field.\n */\nexport interface ExtractedFieldSpec {\n /** Field name in the schema. */\n fieldName: string;\n /** Which spec decorator was found (e.g., 'enumSpec', 'stringSpec'). */\n specDecorator: string;\n /** The full params object from the decorator. */\n params: FieldSpecBaseParams & Record<string, unknown>;\n /**\n * Framework-derived structural metadata. Optional because hand-authored\n * `additionalFieldSpecs` entries (companion-side overlays) and tests that\n * call the extractor without context will not carry derived data.\n */\n derived?: ExtractedFieldSpecDerived;\n /**\n * Where this field came from in the resource schema chain.\n * `main` is the root `mainSchema`; `inherited` is a variant-only or overridden\n * field coming from `inheritenceSchemaDefinition`.\n */\n origin?: {\n scope: 'main' | 'inherited';\n variantPath?: Array<{\n discriminatorField: string;\n discriminatorValue: string;\n }>;\n };\n}\n\n/**\n * Finds the first `{primitive}Spec` entry on a field's `customFieldMetadata`.\n * Returns `null` if no spec decorator is present.\n */\nfunction findSpecEntry(metadata: CustomFieldMetadata): { decorator: string; params: FieldSpecBaseParams & Record<string, unknown> } | null {\n for (const key of SPEC_DECORATOR_KEYS) {\n const value = metadata[key];\n if (value) {\n return { decorator: key, params: value as FieldSpecBaseParams & Record<string, unknown> };\n }\n }\n return null;\n}\n\n/**\n * Map a Zod type string (e.g. `'string'`, `'enum'`, `'object'`) plus the\n * decorator-bearing primitive helpers (money/code/file/...) onto our public\n * `CollectionElementKind` + `CodePrimitiveKind` axes. Centralised so that\n * scalar derivation and per-branch UNION derivation stay aligned — diverging\n * the two would mean a `users.appRoles` UNION branch could disagree with a\n * sibling field that uses the same primitive at the top level.\n */\nfunction classifyZodSchema(schema: z.ZodTypeAny): {\n kind: CollectionElementKind;\n primitiveType?: CodePrimitiveKind;\n} {\n const unwrapped = unwrapSchema(schema);\n\n // Decorator-bearing primitive families (money/code/file/duration/phone/address) —\n // detect BEFORE generic Zod-type fallback because they often wrap a number\n // or string at the Zod layer but should surface as their semantic primitive.\n if (isMoneySchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.MONEY };\n if (isCodeSchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.CODE };\n if (isFileSchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.FILE };\n if (isDurationSchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.DURATION };\n if (isPhoneSchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.PHONE };\n if (isAddressSchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.ADDRESS };\n\n const zodType = getZodType(unwrapped);\n switch (zodType) {\n case 'string':\n return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.STRING };\n case 'number':\n case 'int':\n case 'bigint':\n return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.NUMBER };\n case 'boolean':\n return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.BOOLEAN };\n case 'date':\n return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.DATE };\n case 'enum':\n return { kind: CollectionElementKind.ENUM };\n case 'object':\n return { kind: CollectionElementKind.OBJECT };\n case 'array':\n // Nested arrays are unusual at the element level; mark as UNKNOWN so\n // authors notice and either flatten the schema or extend the kinds.\n return { kind: CollectionElementKind.UNKNOWN };\n case 'union':\n return { kind: CollectionElementKind.UNION };\n case 'literal':\n // A bare `z.literal(...)` collapses to a primitive — pick STRING since\n // literal arrays in this codebase have always been string discriminants.\n return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.STRING };\n default:\n return { kind: CollectionElementKind.UNKNOWN };\n }\n}\n\n/**\n * Walk a Zod array's element schema and produce the derived structural shape\n * the renderer needs. UNION elements are expanded into per-branch derivations\n * (B-3) so downstream consumers can describe a heterogeneous element type\n * without lying about a single dominant kind.\n */\nfunction deriveArrayElement(arraySchema: z.ZodTypeAny): DerivedArrayElement | undefined {\n const elementSchema = getArrayItemSchema(arraySchema);\n if (!elementSchema) {\n return undefined;\n }\n const classification = classifyZodSchema(elementSchema);\n\n if (classification.kind === CollectionElementKind.UNION) {\n const unwrapped = unwrapSchema(elementSchema);\n const def = getZodDef(unwrapped);\n const options = Array.isArray(def?.options) ? (def.options as z.ZodTypeAny[]) : [];\n const branches: DerivedArrayElementBranch[] = options.map((branch) => {\n const branchClassification = classifyZodSchema(branch);\n return {\n kind: branchClassification.kind,\n primitiveType: branchClassification.primitiveType,\n };\n });\n return {\n kind: CollectionElementKind.UNION,\n unionBranches: branches.length > 0 ? branches : undefined,\n };\n }\n\n return classification;\n}\n\n/**\n * Resolve the FK target for a `foreignKeySpec(...)` field by matching the\n * field name against `ResourceRelationship.foreignKeyField` on a\n * relationship that lists the current resource on either `resourceType1`\n * or `resourceType2`. The FK column lives on the current resource (the\n * MANY / child side) and the target is the opposite endpoint (the\n * parent), so the matcher accepts the relationship from either declared\n * direction — the registry-author convention is mixed (some edges put\n * the parent first, others put the child first) and forcing one\n * orientation would silently miss FKs.\n *\n * Returns `undefined` (no derived slice) when no registry context is\n * supplied — that signals \"uninspected\" rather than \"unresolved\", and\n * keeps test fixtures / hand-built `additionalFieldSpecs` working\n * unchanged. When a context IS supplied and the lookup fails, the helper\n * emits a `foreignKeyTargetUnresolved` signal so the Phase 4\n * completeness validator can attribute the error to the missing\n * relationship rather than the renderer.\n *\n * Exported for a reader that holds field specs extracted WITHOUT a registry context and the registry\n * separately (#3268): the dev companion receives a resource specification's field specs as data from a\n * worker process, where its own resource registry is not, and resolves the targets against that registry\n * with this same rule rather than a second copy of it.\n */\nexport function deriveForeignKeyTarget(\n fieldName: string,\n registryContext: ExtractFieldSpecsRegistryContext | undefined,\n): Pick<ExtractedFieldSpecDerived, 'foreignKeyTarget' | 'foreignKeyTargetUnresolved'> | undefined {\n if (!registryContext) {\n return undefined;\n }\n const { currentResourceType, relationships } = registryContext;\n const matched = relationships.find(\n (rel) =>\n rel.foreignKeyField === fieldName &&\n (rel.resourceType1 === currentResourceType || rel.resourceType2 === currentResourceType),\n );\n if (matched) {\n const targetResourceType = matched.resourceType1 === currentResourceType\n ? matched.resourceType2\n : matched.resourceType1;\n return {\n foreignKeyTarget: {\n resourceType: targetResourceType,\n },\n };\n }\n return {\n foreignKeyTargetUnresolved: {\n fromResourceType: currentResourceType,\n fieldName,\n reason: `no relationship declares foreignKeyField \"${fieldName}\" with \"${currentResourceType}\" on either side`,\n },\n };\n}\n\n/**\n * Build the `derived` slice for a single decorator hit. `arraySpec` carries\n * pure-Zod structural derivation (kind / primitive / union branches);\n * `foreignKeySpec` carries registry-backed target resolution when the\n * caller threads an `ExtractFieldSpecsRegistryContext`. Returns `undefined`\n * so callers that spread the field spec do not carry an empty\n * `derived: {}`.\n */\nfunction deriveForField(\n decorator: string,\n fieldName: string,\n fieldSchema: z.ZodTypeAny,\n registryContext: ExtractFieldSpecsRegistryContext | undefined,\n): ExtractedFieldSpecDerived | undefined {\n if (decorator === ZodDecorator.ARRAY_SPEC) {\n const arrayElement = deriveArrayElement(fieldSchema);\n return arrayElement ? { arrayElement } : undefined;\n }\n if (decorator === ZodDecorator.FOREIGN_KEY_SPEC) {\n return deriveForeignKeyTarget(fieldName, registryContext);\n }\n return undefined;\n}\n\nfunction extractFieldSpecsFromShape(\n shape: Record<string, z.ZodTypeAny>,\n origin: ExtractedFieldSpec['origin'],\n registryContext: ExtractFieldSpecsRegistryContext | undefined,\n): ExtractedFieldSpec[] {\n const results: ExtractedFieldSpec[] = [];\n\n for (const [fieldName, fieldSchema] of Object.entries(shape)) {\n const metadata = getCustomFieldMetadata(fieldSchema as z.ZodTypeAny);\n const specEntry = findSpecEntry(metadata);\n if (specEntry) {\n const derived = deriveForField(\n specEntry.decorator,\n fieldName,\n fieldSchema as z.ZodTypeAny,\n registryContext,\n );\n results.push({\n fieldName,\n specDecorator: specEntry.decorator,\n params: specEntry.params,\n ...(derived ? { derived } : {}),\n origin,\n });\n }\n }\n\n return results;\n}\n\nfunction extractInheritedFieldSpecs(\n parentSchema: z.ZodTypeAny,\n inheritanceDefinition: ResourceConfiguration_InheritanceSchemaDefinition<any, z.ZodTypeAny>,\n variantPath: NonNullable<NonNullable<ExtractedFieldSpec['origin']>['variantPath']>,\n registryContext: ExtractFieldSpecsRegistryContext | undefined,\n): ExtractedFieldSpec[] {\n const parentShape = getZodObjectShape(parentSchema) as Record<string, z.ZodTypeAny>;\n const results: ExtractedFieldSpec[] = [];\n\n for (const inheritedItem of inheritanceDefinition.inheritedSchemas) {\n const inheritedShape = getZodObjectShape(inheritedItem.schema) as Record<string, z.ZodTypeAny>;\n const nextVariantPath = [\n ...variantPath,\n {\n discriminatorField: inheritanceDefinition.discriminatorField,\n discriminatorValue: inheritedItem.discriminatorFieldValue,\n },\n ];\n\n const variantDeltaShape: Record<string, z.ZodTypeAny> = {};\n for (const [fieldName, fieldSchema] of Object.entries(inheritedShape)) {\n if (!(fieldName in parentShape) || parentShape[fieldName] !== fieldSchema) {\n variantDeltaShape[fieldName] = fieldSchema;\n }\n }\n\n results.push(\n ...extractFieldSpecsFromShape(\n variantDeltaShape,\n {\n scope: 'inherited',\n variantPath: nextVariantPath,\n },\n registryContext,\n ),\n );\n\n if (inheritedItem.inheritenceSchemaDefinition) {\n results.push(\n ...extractInheritedFieldSpecs(\n inheritedItem.schema,\n inheritedItem.inheritenceSchemaDefinition as ResourceConfiguration_InheritanceSchemaDefinition<any, z.ZodTypeAny>,\n nextVariantPath,\n registryContext,\n ),\n );\n }\n }\n\n return results;\n}\n\n/**\n * Extract all `{primitive}Spec` metadata from a Zod object schema.\n *\n * Walks the top-level shape of the schema and collects any field that has\n * a `{primitive}Spec` decorator attached. Returns a flat array of\n * `ExtractedFieldSpec` entries, ready for serialization.\n *\n * Only inspects top-level fields (not nested object fields). Nested\n * objects with their own spec decorators would need recursive extraction\n * if required in the future.\n *\n * @param schema - A Zod object schema (typically a resource's `mainSchema`)\n * @param registryContext - Optional registry context that turns on\n * FK target derivation for `foreignKeySpec` fields. When omitted,\n * `derived.foreignKeyTarget` stays `undefined` for FK fields and the\n * Phase 4 completeness validator is responsible for surfacing missing\n * relationships independently.\n * @returns Array of extracted field specs, empty if no specs are found\n */\nexport function extractFieldSpecs(\n schema: z.ZodTypeAny,\n registryContext?: ExtractFieldSpecsRegistryContext,\n): ExtractedFieldSpec[] {\n if (!isZodObject(schema)) {\n throw new Error('extractFieldSpecs() requires a Zod object schema.');\n }\n const shape = getZodObjectShape(schema) as Record<string, z.ZodTypeAny>;\n return extractFieldSpecsFromShape(shape, { scope: 'main' }, registryContext);\n}\n\n/**\n * Extract `{primitive}Spec` metadata from a map of already-resolved field\n * schemas, such as `ResourceSpecificationConfig.fields`.\n *\n * This is the safest companion-side path when the specifications package\n * already owns the decorated field schema instances.\n *\n * @param registryContext - Optional registry context that turns on\n * FK target derivation for `foreignKeySpec` fields. The companion\n * resource-specifications path passes the resource's relationship\n * slice + `currentResourceType`; standalone test fixtures omit it.\n */\nexport function extractFieldSpecsFromFieldMap(\n fields: Record<string, z.ZodTypeAny>,\n origin: ExtractedFieldSpec['origin'] = { scope: 'main' },\n registryContext?: ExtractFieldSpecsRegistryContext,\n): ExtractedFieldSpec[] {\n return extractFieldSpecsFromShape(fields, origin, registryContext);\n}\n\n/**\n * Extract `{primitive}Spec` metadata from a full resource schema surface,\n * including variant-only / overridden fields declared through\n * `inheritenceSchemaDefinition`.\n *\n * The returned entries remain flat and JSON-safe, but inherited fields carry an\n * `origin.variantPath` so downstream consumers can see which discriminator path\n * introduced the field.\n *\n * @param registryContext - Optional registry context that turns on\n * FK target derivation for `foreignKeySpec` fields. The companion\n * resource-specifications handler passes\n * `{ currentResourceType, relationships: sharedRegistry.resourceRelationships }`;\n * tests and non-resource extractor entry points may omit it.\n */\nexport function extractResourceFieldSpecs(\n schema: z.ZodTypeAny,\n inheritanceDefinition?: ResourceConfiguration_InheritanceSchemaDefinition<any, z.ZodTypeAny>,\n registryContext?: ExtractFieldSpecsRegistryContext,\n): ExtractedFieldSpec[] {\n const mainFieldSpecs = extractFieldSpecs(schema, registryContext);\n if (!inheritanceDefinition) {\n return mainFieldSpecs;\n }\n\n return [\n ...mainFieldSpecs,\n ...extractInheritedFieldSpecs(schema, inheritanceDefinition, [], registryContext),\n ];\n}\n"]}
1
+ {"version":3,"file":"extract-field-specs.js","sourceRoot":"","sources":["../../../../src/_core/utils/extract-field-specs.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,iBAAiB,EACjB,qBAAqB,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;;;;;GAkBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAoB,EACpB,eAAkD;IAElD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,MAAM,CAAiC,CAAC;IACxE,OAAO,0BAA0B,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC;AAC/E,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,6BAA6B,CAC3C,MAAoC,EACpC,SAAuC,EAAE,KAAK,EAAE,MAAM,EAAE,EACxD,eAAkD;IAElD,OAAO,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;AACrE,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAAoB,EACpB,qBAA4F,EAC5F,eAAkD;IAElD,MAAM,cAAc,GAAG,iBAAiB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAClE,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC3B,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,OAAO;QACL,GAAG,cAAc;QACjB,GAAG,0BAA0B,CAAC,MAAM,EAAE,qBAAqB,EAAE,EAAE,EAAE,eAAe,CAAC;KAClF,CAAC;AACJ,CAAC","sourcesContent":["import type { z } from 'zod';\nimport type {\n ResourceConfiguration_InheritanceSchemaDefinition,\n ResourceRelationship,\n} from '@wildo-ai/saas-models';\nimport {\n CodePrimitiveKind,\n CollectionElementKind,\n getArrayItemSchema,\n getCustomFieldMetadata,\n getZodDef,\n getZodObjectShape,\n getZodType,\n isCodeSchema,\n isDurationSchema,\n isFileSchema,\n isMoneySchema,\n isPhoneSchema,\n isAddressSchema,\n isZodObject,\n unwrapSchema,\n ZodDecorator,\n type CodeEnumMemberRef,\n type CustomFieldMetadata,\n type FieldSpecBaseParams,\n} from '@wildo-ai/zod-decorators';\n\n/**\n * All `{primitive}Spec` decorator keys in `ZodDecorator`.\n * Used to scan `customFieldMetadata` for any spec entry.\n */\nconst SPEC_DECORATOR_KEYS = [\n ZodDecorator.STRING_SPEC,\n ZodDecorator.NUMBER_SPEC,\n ZodDecorator.BOOLEAN_SPEC,\n ZodDecorator.DATE_SPEC,\n ZodDecorator.DATETIME_SPEC,\n ZodDecorator.TIME_SPEC,\n ZodDecorator.ENUM_SPEC,\n ZodDecorator.MONEY_SPEC,\n ZodDecorator.CODE_SPEC,\n ZodDecorator.FILE_SPEC,\n ZodDecorator.DURATION_SPEC,\n ZodDecorator.PHONE_SPEC,\n ZodDecorator.BIGDECIMAL_SPEC,\n ZodDecorator.FOREIGN_KEY_SPEC,\n ZodDecorator.ARRAY_SPEC,\n ZodDecorator.OBJECT_SPEC,\n] as const;\n\n/**\n * Per-branch derived shape for a UNION element. Each entry mirrors the\n * scalar derivation we apply to non-union elements so downstream renderers\n * can describe a `users.appRoles = z.array(z.union([z.enum(...), z.string()]))`\n * shape without flattening the branches into an opaque `UNION` blob.\n */\nexport interface DerivedArrayElementBranch {\n /** Structural family of this branch (`PRIMITIVE` / `ENUM` / `OBJECT` / etc.). */\n kind: CollectionElementKind;\n /** Primitive kind when `kind === PRIMITIVE`. */\n primitiveType?: CodePrimitiveKind;\n}\n\n/**\n * Derived structural shape for an array element — derived purely from the\n * Zod element schema. The framework owns this surface; authors only declare\n * intent (`elementMeaning`, `enumDeclaration`, `notes`) on `arraySpec(...)`.\n */\nexport interface DerivedArrayElement {\n /** Structural family of each array element. */\n kind: CollectionElementKind;\n /** Primitive kind when `kind === PRIMITIVE`. */\n primitiveType?: CodePrimitiveKind;\n /**\n * Per-branch derivation when `kind === UNION` — preserves the structural\n * truth of unions instead of forcing authors to lie about a \"dominant\"\n * branch (B-3 decision: model UNION as a discrete kind with branches).\n */\n unionBranches?: DerivedArrayElementBranch[];\n}\n\n/**\n * Derived target of a `foreignKeySpec(...)` field — sourced from the\n * relationship registry by matching `foreignKeyField === <fieldName>` on\n * a relationship that lists the current resource on EITHER side. The FK\n * column lives on the MANY side (the child) and the target is the\n * opposite side (the parent), regardless of whether the registry author\n * declared the relationship as `(parent, child)` or `(child, parent)`.\n *\n * Populated in Phase 2B when the caller supplies an\n * `ExtractFieldSpecsRegistryContext`. When the caller does NOT supply one\n * (test fixtures, hand-built `additionalFieldSpecs`, non-resource\n * extractor entry points), this slice stays `undefined` — the\n * Phase 4 completeness validator is the single seam that requires it.\n */\nexport interface DerivedForeignKeyTarget {\n /** Resource type the FK points at (registry-derived). */\n resourceType: string;\n /** Optional code-symbol reference to the FK target's resource-type member. */\n ref?: CodeEnumMemberRef;\n}\n\n/**\n * Fail-closed signal for `foreignKeySpec` fields whose target could not\n * be resolved from the relationship registry. The Phase 4 completeness\n * validator consumes this to attribute the missing-relationship error to\n * the registry edge, not the renderer; renderers also surface the gap so\n * downstream prompts stay honest about the missing target instead of\n * silently dropping the FK line.\n *\n * Only emitted when the caller supplied an\n * `ExtractFieldSpecsRegistryContext` AND the lookup failed. When no\n * context is supplied the extractor cannot tell whether the FK is\n * unresolved or simply uninspected, so it stays `undefined`.\n */\nexport interface DerivedForeignKeyTargetUnresolved {\n /** Resource the FK lives on, as supplied by the caller. */\n fromResourceType: string;\n /** The FK field name that failed to resolve. */\n fieldName: string;\n /** Human-readable reason — used as-is in fail-closed error messages. */\n reason: string;\n}\n\n/**\n * Derived metadata that the framework extracts from the Zod schema (and,\n * in Phase 2B, the relationship registry). Authors no longer hand-author\n * structural fields the framework can derive — this object is the\n * single source of structural truth on an extracted spec.\n */\nexport interface ExtractedFieldSpecDerived {\n /** Present when the field is an `arraySpec`. */\n arrayElement?: DerivedArrayElement;\n /** Present when the field is a `foreignKeySpec` and the registry resolves the target (Phase 2B). */\n foreignKeyTarget?: DerivedForeignKeyTarget;\n /** Present when the field is a `foreignKeySpec` and the registry has no matching edge (Phase 2B). */\n foreignKeyTargetUnresolved?: DerivedForeignKeyTargetUnresolved;\n}\n\n/**\n * Caller-supplied context that lets the extractor derive registry-backed\n * facts. Currently scoped to FK target resolution; future registry-aware\n * derivations (e.g. cardinality inference for collection-shaped fields)\n * will read from the same context.\n *\n * Both fields are required for FK derivation to fire — passing\n * `relationships` without `currentResourceType` would let the matcher\n * silently resolve to a different resource's edge and is therefore\n * disallowed by the type itself.\n */\nexport interface ExtractFieldSpecsRegistryContext {\n /** Resource type that owns the schema being walked. */\n currentResourceType: string;\n /** Relationships that may concern the current resource. */\n relationships: readonly ResourceRelationship[];\n}\n\n/**\n * Extracted field specification entry — the JSON-safe representation\n * of a `{primitive}Spec()` decorator found on a schema field.\n */\nexport interface ExtractedFieldSpec {\n /** Field name in the schema. */\n fieldName: string;\n /** Which spec decorator was found (e.g., 'enumSpec', 'stringSpec'). */\n specDecorator: string;\n /** The full params object from the decorator. */\n params: FieldSpecBaseParams & Record<string, unknown>;\n /**\n * Framework-derived structural metadata. Optional because hand-authored\n * `additionalFieldSpecs` entries (companion-side overlays) and tests that\n * call the extractor without context will not carry derived data.\n */\n derived?: ExtractedFieldSpecDerived;\n /**\n * Where this field came from in the resource schema chain.\n * `main` is the root `mainSchema`; `inherited` is a variant-only or overridden\n * field coming from `inheritenceSchemaDefinition`.\n */\n origin?: {\n scope: 'main' | 'inherited';\n variantPath?: Array<{\n discriminatorField: string;\n discriminatorValue: string;\n }>;\n };\n}\n\n/**\n * Finds the first `{primitive}Spec` entry on a field's `customFieldMetadata`.\n * Returns `null` if no spec decorator is present.\n */\nfunction findSpecEntry(metadata: CustomFieldMetadata): { decorator: string; params: FieldSpecBaseParams & Record<string, unknown> } | null {\n for (const key of SPEC_DECORATOR_KEYS) {\n const value = metadata[key];\n if (value) {\n return { decorator: key, params: value as FieldSpecBaseParams & Record<string, unknown> };\n }\n }\n return null;\n}\n\n/**\n * Map a Zod type string (e.g. `'string'`, `'enum'`, `'object'`) plus the\n * decorator-bearing primitive helpers (money/code/file/...) onto our public\n * `CollectionElementKind` + `CodePrimitiveKind` axes. Centralised so that\n * scalar derivation and per-branch UNION derivation stay aligned — diverging\n * the two would mean a `users.appRoles` UNION branch could disagree with a\n * sibling field that uses the same primitive at the top level.\n */\nfunction classifyZodSchema(schema: z.ZodTypeAny): {\n kind: CollectionElementKind;\n primitiveType?: CodePrimitiveKind;\n} {\n const unwrapped = unwrapSchema(schema);\n\n // Decorator-bearing primitive families (money/code/file/duration/phone/address) —\n // detect BEFORE generic Zod-type fallback because they often wrap a number\n // or string at the Zod layer but should surface as their semantic primitive.\n if (isMoneySchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.MONEY };\n if (isCodeSchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.CODE };\n if (isFileSchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.FILE };\n if (isDurationSchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.DURATION };\n if (isPhoneSchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.PHONE };\n if (isAddressSchema(unwrapped)) return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.ADDRESS };\n\n const zodType = getZodType(unwrapped);\n switch (zodType) {\n case 'string':\n return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.STRING };\n case 'number':\n case 'int':\n case 'bigint':\n return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.NUMBER };\n case 'boolean':\n return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.BOOLEAN };\n case 'date':\n return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.DATE };\n case 'enum':\n return { kind: CollectionElementKind.ENUM };\n case 'object':\n return { kind: CollectionElementKind.OBJECT };\n case 'array':\n // Nested arrays are unusual at the element level; mark as UNKNOWN so\n // authors notice and either flatten the schema or extend the kinds.\n return { kind: CollectionElementKind.UNKNOWN };\n case 'union':\n return { kind: CollectionElementKind.UNION };\n case 'literal':\n // A bare `z.literal(...)` collapses to a primitive — pick STRING since\n // literal arrays in this codebase have always been string discriminants.\n return { kind: CollectionElementKind.PRIMITIVE, primitiveType: CodePrimitiveKind.STRING };\n default:\n return { kind: CollectionElementKind.UNKNOWN };\n }\n}\n\n/**\n * Walk a Zod array's element schema and produce the derived structural shape\n * the renderer needs. UNION elements are expanded into per-branch derivations\n * (B-3) so downstream consumers can describe a heterogeneous element type\n * without lying about a single dominant kind.\n */\nfunction deriveArrayElement(arraySchema: z.ZodTypeAny): DerivedArrayElement | undefined {\n const elementSchema = getArrayItemSchema(arraySchema);\n if (!elementSchema) {\n return undefined;\n }\n const classification = classifyZodSchema(elementSchema);\n\n if (classification.kind === CollectionElementKind.UNION) {\n const unwrapped = unwrapSchema(elementSchema);\n const def = getZodDef(unwrapped);\n const options = Array.isArray(def?.options) ? (def.options as z.ZodTypeAny[]) : [];\n const branches: DerivedArrayElementBranch[] = options.map((branch) => {\n const branchClassification = classifyZodSchema(branch);\n return {\n kind: branchClassification.kind,\n primitiveType: branchClassification.primitiveType,\n };\n });\n return {\n kind: CollectionElementKind.UNION,\n unionBranches: branches.length > 0 ? branches : undefined,\n };\n }\n\n return classification;\n}\n\n/**\n * Resolve the FK target for a `foreignKeySpec(...)` field by matching the\n * field name against `ResourceRelationship.foreignKeyField` on a\n * relationship that lists the current resource on either `resourceType1`\n * or `resourceType2`. The FK column lives on the current resource (the\n * MANY / child side) and the target is the opposite endpoint (the\n * parent), so the matcher accepts the relationship from either declared\n * direction — the registry-author convention is mixed (some edges put\n * the parent first, others put the child first) and forcing one\n * orientation would silently miss FKs.\n *\n * Returns `undefined` (no derived slice) when no registry context is\n * supplied — that signals \"uninspected\" rather than \"unresolved\", and\n * keeps test fixtures / hand-built `additionalFieldSpecs` working\n * unchanged. When a context IS supplied and the lookup fails, the helper\n * emits a `foreignKeyTargetUnresolved` signal so the Phase 4\n * completeness validator can attribute the error to the missing\n * relationship rather than the renderer.\n *\n * Exported for a reader that holds field specs extracted WITHOUT a registry context and the registry\n * separately (#3268): the dev companion receives a resource specification's field specs as data from a\n * worker process, where its own resource registry is not, and resolves the targets against that registry\n * with this same rule rather than a second copy of it.\n */\nexport function deriveForeignKeyTarget(\n fieldName: string,\n registryContext: ExtractFieldSpecsRegistryContext | undefined,\n): Pick<ExtractedFieldSpecDerived, 'foreignKeyTarget' | 'foreignKeyTargetUnresolved'> | undefined {\n if (!registryContext) {\n return undefined;\n }\n const { currentResourceType, relationships } = registryContext;\n const matched = relationships.find(\n (rel) =>\n rel.foreignKeyField === fieldName &&\n (rel.resourceType1 === currentResourceType || rel.resourceType2 === currentResourceType),\n );\n if (matched) {\n const targetResourceType = matched.resourceType1 === currentResourceType\n ? matched.resourceType2\n : matched.resourceType1;\n return {\n foreignKeyTarget: {\n resourceType: targetResourceType,\n },\n };\n }\n return {\n foreignKeyTargetUnresolved: {\n fromResourceType: currentResourceType,\n fieldName,\n reason: `no relationship declares foreignKeyField \"${fieldName}\" with \"${currentResourceType}\" on either side`,\n },\n };\n}\n\n/**\n * Build the `derived` slice for a single decorator hit. `arraySpec` carries\n * pure-Zod structural derivation (kind / primitive / union branches);\n * `foreignKeySpec` carries registry-backed target resolution when the\n * caller threads an `ExtractFieldSpecsRegistryContext`. Returns `undefined`\n * so callers that spread the field spec do not carry an empty\n * `derived: {}`.\n */\nfunction deriveForField(\n decorator: string,\n fieldName: string,\n fieldSchema: z.ZodTypeAny,\n registryContext: ExtractFieldSpecsRegistryContext | undefined,\n): ExtractedFieldSpecDerived | undefined {\n if (decorator === ZodDecorator.ARRAY_SPEC) {\n const arrayElement = deriveArrayElement(fieldSchema);\n return arrayElement ? { arrayElement } : undefined;\n }\n if (decorator === ZodDecorator.FOREIGN_KEY_SPEC) {\n return deriveForeignKeyTarget(fieldName, registryContext);\n }\n return undefined;\n}\n\nfunction extractFieldSpecsFromShape(\n shape: Record<string, z.ZodTypeAny>,\n origin: ExtractedFieldSpec['origin'],\n registryContext: ExtractFieldSpecsRegistryContext | undefined,\n): ExtractedFieldSpec[] {\n const results: ExtractedFieldSpec[] = [];\n\n for (const [fieldName, fieldSchema] of Object.entries(shape)) {\n const metadata = getCustomFieldMetadata(fieldSchema as z.ZodTypeAny);\n const specEntry = findSpecEntry(metadata);\n if (specEntry) {\n const derived = deriveForField(\n specEntry.decorator,\n fieldName,\n fieldSchema as z.ZodTypeAny,\n registryContext,\n );\n results.push({\n fieldName,\n specDecorator: specEntry.decorator,\n params: specEntry.params,\n ...(derived ? { derived } : {}),\n origin,\n });\n }\n }\n\n return results;\n}\n\nfunction extractInheritedFieldSpecs(\n parentSchema: z.ZodTypeAny,\n inheritanceDefinition: ResourceConfiguration_InheritanceSchemaDefinition<any, z.ZodTypeAny>,\n variantPath: NonNullable<NonNullable<ExtractedFieldSpec['origin']>['variantPath']>,\n registryContext: ExtractFieldSpecsRegistryContext | undefined,\n): ExtractedFieldSpec[] {\n const parentShape = getZodObjectShape(parentSchema) as Record<string, z.ZodTypeAny>;\n const results: ExtractedFieldSpec[] = [];\n\n for (const inheritedItem of inheritanceDefinition.inheritedSchemas) {\n const inheritedShape = getZodObjectShape(inheritedItem.schema) as Record<string, z.ZodTypeAny>;\n const nextVariantPath = [\n ...variantPath,\n {\n discriminatorField: inheritanceDefinition.discriminatorField,\n discriminatorValue: inheritedItem.discriminatorFieldValue,\n },\n ];\n\n const variantDeltaShape: Record<string, z.ZodTypeAny> = {};\n for (const [fieldName, fieldSchema] of Object.entries(inheritedShape)) {\n if (!(fieldName in parentShape) || parentShape[fieldName] !== fieldSchema) {\n variantDeltaShape[fieldName] = fieldSchema;\n }\n }\n\n results.push(\n ...extractFieldSpecsFromShape(\n variantDeltaShape,\n {\n scope: 'inherited',\n variantPath: nextVariantPath,\n },\n registryContext,\n ),\n );\n\n if (inheritedItem.inheritenceSchemaDefinition) {\n results.push(\n ...extractInheritedFieldSpecs(\n inheritedItem.schema,\n inheritedItem.inheritenceSchemaDefinition as ResourceConfiguration_InheritanceSchemaDefinition<any, z.ZodTypeAny>,\n nextVariantPath,\n registryContext,\n ),\n );\n }\n }\n\n return results;\n}\n\n/**\n * Extract all `{primitive}Spec` metadata from a Zod object schema.\n *\n * Walks the top-level shape of the schema and collects any field that has\n * a `{primitive}Spec` decorator attached. Returns a flat array of\n * `ExtractedFieldSpec` entries, ready for serialization.\n *\n * Only inspects top-level fields (not nested object fields). Nested\n * objects with their own spec decorators would need recursive extraction\n * if required in the future.\n *\n * @param schema - A Zod object schema (typically a resource's `mainSchema`)\n * @param registryContext - Optional registry context that turns on\n * FK target derivation for `foreignKeySpec` fields. When omitted,\n * `derived.foreignKeyTarget` stays `undefined` for FK fields and the\n * Phase 4 completeness validator is responsible for surfacing missing\n * relationships independently.\n * @returns Array of extracted field specs, empty if no specs are found\n */\nexport function extractFieldSpecs(\n schema: z.ZodTypeAny,\n registryContext?: ExtractFieldSpecsRegistryContext,\n): ExtractedFieldSpec[] {\n if (!isZodObject(schema)) {\n throw new Error('extractFieldSpecs() requires a Zod object schema.');\n }\n const shape = getZodObjectShape(schema) as Record<string, z.ZodTypeAny>;\n return extractFieldSpecsFromShape(shape, { scope: 'main' }, registryContext);\n}\n\n/**\n * Extract `{primitive}Spec` metadata from a map of already-resolved field\n * schemas, such as `ResourceSpecificationConfig.fields`.\n *\n * This is the safest companion-side path when the specifications package\n * already owns the decorated field schema instances.\n *\n * @param registryContext - Optional registry context that turns on\n * FK target derivation for `foreignKeySpec` fields. The companion\n * resource-specifications path passes the assembled registry's compiled\n * relationships (#3051) + `currentResourceType`; standalone test fixtures omit it.\n */\nexport function extractFieldSpecsFromFieldMap(\n fields: Record<string, z.ZodTypeAny>,\n origin: ExtractedFieldSpec['origin'] = { scope: 'main' },\n registryContext?: ExtractFieldSpecsRegistryContext,\n): ExtractedFieldSpec[] {\n return extractFieldSpecsFromShape(fields, origin, registryContext);\n}\n\n/**\n * Extract `{primitive}Spec` metadata from a full resource schema surface,\n * including variant-only / overridden fields declared through\n * `inheritenceSchemaDefinition`.\n *\n * The returned entries remain flat and JSON-safe, but inherited fields carry an\n * `origin.variantPath` so downstream consumers can see which discriminator path\n * introduced the field.\n *\n * @param registryContext - Optional registry context that turns on\n * FK target derivation for `foreignKeySpec` fields. The companion\n * resource-specifications handler passes\n * `{ currentResourceType, relationships }` with the registry startup assembles\n * (`assembleResourceRegistry`, #3051), application and engine edges compiled together;\n * tests and non-resource extractor entry points may omit it.\n */\nexport function extractResourceFieldSpecs(\n schema: z.ZodTypeAny,\n inheritanceDefinition?: ResourceConfiguration_InheritanceSchemaDefinition<any, z.ZodTypeAny>,\n registryContext?: ExtractFieldSpecsRegistryContext,\n): ExtractedFieldSpec[] {\n const mainFieldSpecs = extractFieldSpecs(schema, registryContext);\n if (!inheritanceDefinition) {\n return mainFieldSpecs;\n }\n\n return [\n ...mainFieldSpecs,\n ...extractInheritedFieldSpecs(schema, inheritanceDefinition, [], registryContext),\n ];\n}\n"]}