@wildo-ai/saas-specifications 1.1.8 → 1.1.9

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-specification-family-identity.schemas.d.ts +9 -0
  2. package/dist/esm/_core/application-specification-family-identity.schemas.d.ts.map +1 -1
  3. package/dist/esm/_core/application-specification-family-identity.schemas.js +9 -0
  4. package/dist/esm/_core/application-specification-family-identity.schemas.js.map +1 -1
  5. package/dist/esm/_core/brand/brand-name-choice.d.ts +136 -0
  6. package/dist/esm/_core/brand/brand-name-choice.d.ts.map +1 -0
  7. package/dist/esm/_core/brand/brand-name-choice.js +193 -0
  8. package/dist/esm/_core/brand/brand-name-choice.js.map +1 -0
  9. package/dist/esm/_core/brand/brand-name-screening-generation.schemas.d.ts +108 -0
  10. package/dist/esm/_core/brand/brand-name-screening-generation.schemas.d.ts.map +1 -0
  11. package/dist/esm/_core/brand/brand-name-screening-generation.schemas.js +59 -0
  12. package/dist/esm/_core/brand/brand-name-screening-generation.schemas.js.map +1 -0
  13. package/dist/esm/_core/brand/brand-name-screening-validation.d.ts +51 -0
  14. package/dist/esm/_core/brand/brand-name-screening-validation.d.ts.map +1 -0
  15. package/dist/esm/_core/brand/brand-name-screening-validation.js +157 -0
  16. package/dist/esm/_core/brand/brand-name-screening-validation.js.map +1 -0
  17. package/dist/esm/_core/brand/brand-name-screening-view.d.ts +120 -0
  18. package/dist/esm/_core/brand/brand-name-screening-view.d.ts.map +1 -0
  19. package/dist/esm/_core/brand/brand-name-screening-view.js +47 -0
  20. package/dist/esm/_core/brand/brand-name-screening-view.js.map +1 -0
  21. package/dist/esm/_core/brand/brand-name-screening.family-aspects.d.ts +3 -0
  22. package/dist/esm/_core/brand/brand-name-screening.family-aspects.d.ts.map +1 -0
  23. package/dist/esm/_core/brand/brand-name-screening.family-aspects.js +42 -0
  24. package/dist/esm/_core/brand/brand-name-screening.family-aspects.js.map +1 -0
  25. package/dist/esm/_core/brand/brand-name-screening.schemas.d.ts +310 -0
  26. package/dist/esm/_core/brand/brand-name-screening.schemas.d.ts.map +1 -0
  27. package/dist/esm/_core/brand/brand-name-screening.schemas.js +272 -0
  28. package/dist/esm/_core/brand/brand-name-screening.schemas.js.map +1 -0
  29. package/dist/esm/_core/brand/brand-snapshot.schemas.d.ts +23 -0
  30. package/dist/esm/_core/brand/brand-snapshot.schemas.d.ts.map +1 -1
  31. package/dist/esm/_core/brand/brand-snapshot.schemas.js +32 -0
  32. package/dist/esm/_core/brand/brand-snapshot.schemas.js.map +1 -1
  33. package/dist/esm/_core/build-plan/build-plan-task-graph-generation.schemas.d.ts +10 -0
  34. package/dist/esm/_core/build-plan/build-plan-task-graph-generation.schemas.d.ts.map +1 -1
  35. package/dist/esm/_core/build-plan/build-plan-task-graph-validation.d.ts +57 -0
  36. package/dist/esm/_core/build-plan/build-plan-task-graph-validation.d.ts.map +1 -1
  37. package/dist/esm/_core/build-plan/build-plan-task-graph-validation.js +89 -0
  38. package/dist/esm/_core/build-plan/build-plan-task-graph-validation.js.map +1 -1
  39. package/dist/esm/_core/build-plan/build-plan-task-graph.schemas.d.ts +79 -19
  40. package/dist/esm/_core/build-plan/build-plan-task-graph.schemas.d.ts.map +1 -1
  41. package/dist/esm/_core/build-plan/build-plan-task-graph.schemas.js +61 -11
  42. package/dist/esm/_core/build-plan/build-plan-task-graph.schemas.js.map +1 -1
  43. package/dist/esm/_core/build-plan/build-plan.family-aspects.d.ts.map +1 -1
  44. package/dist/esm/_core/build-plan/build-plan.family-aspects.js +18 -2
  45. package/dist/esm/_core/build-plan/build-plan.family-aspects.js.map +1 -1
  46. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot-generation.schemas.d.ts +28 -4
  47. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot-generation.schemas.d.ts.map +1 -1
  48. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot-generation.schemas.js +53 -5
  49. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot-generation.schemas.js.map +1 -1
  50. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot-validation.d.ts +24 -4
  51. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot-validation.d.ts.map +1 -1
  52. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot-validation.js +64 -4
  53. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot-validation.js.map +1 -1
  54. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot.schemas.d.ts +59 -0
  55. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot.schemas.d.ts.map +1 -1
  56. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot.schemas.js +64 -0
  57. package/dist/esm/_core/business-model-lite/business-model-lite-snapshot.schemas.js.map +1 -1
  58. package/dist/esm/_core/business-model-lite/pricing-plan.schemas.d.ts +3 -0
  59. package/dist/esm/_core/business-model-lite/pricing-plan.schemas.d.ts.map +1 -1
  60. package/dist/esm/_core/business-model-lite/pricing-plan.schemas.js +16 -0
  61. package/dist/esm/_core/business-model-lite/pricing-plan.schemas.js.map +1 -1
  62. package/dist/esm/_core/capability-composition/capability-composition-validation.d.ts +7 -1
  63. package/dist/esm/_core/capability-composition/capability-composition-validation.d.ts.map +1 -1
  64. package/dist/esm/_core/capability-composition/capability-composition-validation.js +34 -28
  65. package/dist/esm/_core/capability-composition/capability-composition-validation.js.map +1 -1
  66. package/dist/esm/_core/capability-composition/capability-composition.schemas.d.ts +75 -4
  67. package/dist/esm/_core/capability-composition/capability-composition.schemas.d.ts.map +1 -1
  68. package/dist/esm/_core/capability-composition/capability-composition.schemas.js +62 -4
  69. package/dist/esm/_core/capability-composition/capability-composition.schemas.js.map +1 -1
  70. package/dist/esm/_core/compliance-documents/computed-document-facts.schemas.d.ts.map +1 -1
  71. package/dist/esm/_core/compliance-documents/computed-document-facts.schemas.js +7 -0
  72. package/dist/esm/_core/compliance-documents/computed-document-facts.schemas.js.map +1 -1
  73. package/dist/esm/_core/compliance-documents/launch-blockers.schemas.d.ts +153 -0
  74. package/dist/esm/_core/compliance-documents/launch-blockers.schemas.d.ts.map +1 -0
  75. package/dist/esm/_core/compliance-documents/launch-blockers.schemas.js +241 -0
  76. package/dist/esm/_core/compliance-documents/launch-blockers.schemas.js.map +1 -0
  77. package/dist/esm/_core/domain-plan/domain-plan-output-set-validation.d.ts +8 -1
  78. package/dist/esm/_core/domain-plan/domain-plan-output-set-validation.d.ts.map +1 -1
  79. package/dist/esm/_core/domain-plan/domain-plan-output-set-validation.js +19 -1
  80. package/dist/esm/_core/domain-plan/domain-plan-output-set-validation.js.map +1 -1
  81. package/dist/esm/_core/domain-plan/domain-plan-output-set.schemas.d.ts +61 -3
  82. package/dist/esm/_core/domain-plan/domain-plan-output-set.schemas.d.ts.map +1 -1
  83. package/dist/esm/_core/domain-plan/domain-plan-output-set.schemas.js +73 -3
  84. package/dist/esm/_core/domain-plan/domain-plan-output-set.schemas.js.map +1 -1
  85. package/dist/esm/_core/experience-plan/experience-plan.family-aspects.js +1 -1
  86. package/dist/esm/_core/experience-plan/experience-plan.family-aspects.js.map +1 -1
  87. package/dist/esm/_core/experience-plan/experience-plan.schemas.d.ts.map +1 -1
  88. package/dist/esm/_core/experience-plan/experience-plan.schemas.js +1 -0
  89. package/dist/esm/_core/experience-plan/experience-plan.schemas.js.map +1 -1
  90. package/dist/esm/_core/family-aspects.registry.d.ts.map +1 -1
  91. package/dist/esm/_core/family-aspects.registry.js +2 -0
  92. package/dist/esm/_core/family-aspects.registry.js.map +1 -1
  93. package/dist/esm/_core/index.d.ts +6 -0
  94. package/dist/esm/_core/index.d.ts.map +1 -1
  95. package/dist/esm/_core/index.js +6 -0
  96. package/dist/esm/_core/index.js.map +1 -1
  97. package/dist/esm/_core/integration-plan/integration-plan.family-aspects.d.ts.map +1 -1
  98. package/dist/esm/_core/integration-plan/integration-plan.family-aspects.js +5 -1
  99. package/dist/esm/_core/integration-plan/integration-plan.family-aspects.js.map +1 -1
  100. package/dist/esm/_core/market/market-icp.schemas.d.ts +7 -0
  101. package/dist/esm/_core/market/market-icp.schemas.d.ts.map +1 -1
  102. package/dist/esm/_core/market/market-icp.schemas.js +7 -0
  103. package/dist/esm/_core/market/market-icp.schemas.js.map +1 -1
  104. package/dist/esm/_core/market/market-language-coverage.d.ts +62 -0
  105. package/dist/esm/_core/market/market-language-coverage.d.ts.map +1 -0
  106. package/dist/esm/_core/market/market-language-coverage.js +48 -0
  107. package/dist/esm/_core/market/market-language-coverage.js.map +1 -0
  108. package/dist/esm/_core/market/market-snapshot-validation.js +2 -2
  109. package/dist/esm/_core/market/market-snapshot-validation.js.map +1 -1
  110. package/dist/esm/application-creation/application-creator-inputs.application-creation.schemas.d.ts +63 -2
  111. package/dist/esm/application-creation/application-creator-inputs.application-creation.schemas.d.ts.map +1 -1
  112. package/dist/esm/application-creation/application-creator-inputs.application-creation.schemas.js +73 -5
  113. package/dist/esm/application-creation/application-creator-inputs.application-creation.schemas.js.map +1 -1
  114. package/dist/esm/application-creation/application-line.application-creation.schemas.d.ts.map +1 -1
  115. package/dist/esm/application-creation/application-line.application-creation.schemas.js +2 -0
  116. package/dist/esm/application-creation/application-line.application-creation.schemas.js.map +1 -1
  117. package/dist/esm/application-creation/playbooks.application-creation.schemas.d.ts +28 -0
  118. package/dist/esm/application-creation/playbooks.application-creation.schemas.d.ts.map +1 -1
  119. package/dist/esm/application-creation/playbooks.application-creation.schemas.js +19 -1
  120. package/dist/esm/application-creation/playbooks.application-creation.schemas.js.map +1 -1
  121. package/dist/esm/application-creation/structured-artifact-landing.application-creation.schemas.d.ts +1 -0
  122. package/dist/esm/application-creation/structured-artifact-landing.application-creation.schemas.d.ts.map +1 -1
  123. package/dist/esm/application-creation/structured-artifact-landing.application-creation.schemas.js +1 -0
  124. package/dist/esm/application-creation/structured-artifact-landing.application-creation.schemas.js.map +1 -1
  125. package/dist/esm/application-creation.exports.d.ts +7 -0
  126. package/dist/esm/application-creation.exports.d.ts.map +1 -1
  127. package/dist/esm/application-creation.exports.js +7 -0
  128. package/dist/esm/application-creation.exports.js.map +1 -1
  129. package/dist/esm/assurance/application-risk-signals.derivations.d.ts +20 -0
  130. package/dist/esm/assurance/application-risk-signals.derivations.d.ts.map +1 -1
  131. package/dist/esm/assurance/application-risk-signals.derivations.js +81 -0
  132. package/dist/esm/assurance/application-risk-signals.derivations.js.map +1 -1
  133. package/dist/esm/assurance/governed-document-release.d.ts +9 -0
  134. package/dist/esm/assurance/governed-document-release.d.ts.map +1 -1
  135. package/dist/esm/assurance/governed-document-release.js +9 -0
  136. package/dist/esm/assurance/governed-document-release.js.map +1 -1
  137. package/dist/esm/companion-exports.d.ts +10 -1
  138. package/dist/esm/companion-exports.d.ts.map +1 -1
  139. package/dist/esm/companion-exports.js.map +1 -1
  140. package/dist/esm/engine/infrastructure/resources/job-executions.resource.specification.d.ts +1 -0
  141. package/dist/esm/engine/infrastructure/resources/job-executions.resource.specification.d.ts.map +1 -1
  142. package/package.json +8 -8
  143. package/dist/esm/assurance/__tests__/authority-evaluation-instant.fixture.d.ts +0 -24
  144. package/dist/esm/assurance/__tests__/authority-evaluation-instant.fixture.d.ts.map +0 -1
  145. package/dist/esm/assurance/__tests__/authority-evaluation-instant.fixture.js +0 -24
  146. package/dist/esm/assurance/__tests__/authority-evaluation-instant.fixture.js.map +0 -1
  147. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -0,0 +1,241 @@
1
+ /**
2
+ * The "before you can launch" list: every open compliance decision that stands between a created
3
+ * application and a real user, each with where it is decided and what settles it (#2238).
4
+ *
5
+ * ## Why it exists
6
+ *
7
+ * A creation run ended without saying what was still open. In run 004 the operator's legal entity and
8
+ * hosting region, two governance questions, the retention classes, the subject-data recipients and the
9
+ * sign-up acceptance were all undecided, and they surfaced as `wildo config validate` warnings in logs,
10
+ * or not at all. Spread across logs, none of them is a list anyone acts on.
11
+ *
12
+ * ## It MARKS, it never blocks
13
+ *
14
+ * Nothing calls this to decide whether creation may proceed. `application-creation-directive.md`
15
+ * forbids a compliance workflow standing in front of creation; Gate 3 is where these points become
16
+ * gates, and this is what that gate will read. So the list has no severity and no pass/fail verdict:
17
+ * it is what is open, stated plainly.
18
+ *
19
+ * ## It is DERIVED, never asked
20
+ *
21
+ * Every entry is a function of something the application already holds, by the same predicate the
22
+ * surface that owns it already uses (`compliance-is-derived-from-the-product.md`,
23
+ * `derive-before-you-ask.md`):
24
+ *
25
+ * | entry | derived from |
26
+ * |---|---|
27
+ * | operator identity part | {@link outstandingOperatorComplianceIdentityParts}, total over {@link OperatorComplianceIdentityPart} |
28
+ * | retention class | {@link undeclaredRetentionClasses}, total over `DataRetentionClass` |
29
+ * | subject-data recipients | the generated recipients module is absent — the predicate behind `wildo config validate`'s warning |
30
+ * | governance question | the creation question queue's `GOVERNANCE_FACT` items (`wildo creation questions`) |
31
+ * | sign-up acceptance | the recorded governed-document releases in force, their approval, and whether their runtime module exists |
32
+ *
33
+ * The governance population is the QUEUE's, deliberately: a fact still needed by a DRAFTED governed document. A document
34
+ * not drafted yet asks nothing, so its facts are not listed here — the creation run drafting it is what surfaces them.
35
+ * Gate 3 must not read an empty governance section as "every governed document is complete".
36
+ *
37
+ * Settling an item removes it on the next read, because nothing here is stored: the caller reads each
38
+ * input fresh and this function recomputes. A total derivation also means an identity part or a
39
+ * retention class added to its vocabulary tomorrow appears here for every application at once.
40
+ *
41
+ * ## An input that could not be read is NOT an empty list
42
+ *
43
+ * Each input is optional for exactly that reason. An unreadable configuration or question queue is
44
+ * reported in {@link LaunchBlockerList.unevaluatedSources}, never as "nothing open" — a launch list that
45
+ * reads clean because its source failed is the most dangerous answer it could give
46
+ * (`negative-results-require-a-positive-probe.md`).
47
+ */
48
+ import { z } from "zod";
49
+ import { GovernedDocumentInteractionKind, GovernedDocumentReleaseApprovalState, governedDocumentReleaseIsInForce, OperatorComplianceIdentityPart, outstandingOperatorComplianceIdentityParts, undeclaredRetentionClasses, } from "@wildo-ai/saas-models";
50
+ /*
51
+ * entrypoint-closure-waiver: this root-reachable module imports ONE value from the assurance-only release module —
52
+ * `GOVERNED_DOCUMENT_RELEASES_GENERATED_RELATIVE_PATH`, a string constant whose declared type is a string literal.
53
+ * No nominal type (enum, class, brand) crosses: the constant is used only inside prose this module builds, and no
54
+ * exported signature here names anything from that module, so a root-only consumer has nothing to name.
55
+ */
56
+ import { GOVERNED_DOCUMENT_RELEASES_GENERATED_RELATIVE_PATH } from "../../assurance/governed-document-release.js";
57
+ import { SUBJECT_DATA_RECIPIENTS_GENERATED_RELATIVE_PATH } from "./subject-data-recipients.schemas.js";
58
+ /** WHAT is open — one member per kind of launch decision, each with its own settling path. */
59
+ export var LaunchBlockerKind;
60
+ (function (LaunchBlockerKind) {
61
+ /** A part of `operatorComplianceIdentity` is undeclared: the legal entity, the hosting region, the privacy contact… */
62
+ LaunchBlockerKind["OPERATOR_IDENTITY_PART_UNDECLARED"] = "operator-identity-part-undeclared";
63
+ /** A governed-document question waits on the person; it is answered in the workbench's governance panel. */
64
+ LaunchBlockerKind["GOVERNANCE_QUESTION_UNANSWERED"] = "governance-question-unanswered";
65
+ /** A `DataRetentionClass` has no declared period in `dataRetention`. */
66
+ LaunchBlockerKind["RETENTION_CLASS_UNDECLARED"] = "retention-class-undeclared";
67
+ /** No subject-data recipients module, so every subject export says recipients are not declared. */
68
+ LaunchBlockerKind["SUBJECT_DATA_RECIPIENTS_UNDECLARED"] = "subject-data-recipients-undeclared";
69
+ /** No recorded release lets a person accept it, so sign-up records no acceptance of the terms or the privacy notice. */
70
+ LaunchBlockerKind["SIGN_UP_ACCEPTANCE_NOT_OFFERED"] = "sign-up-acceptance-not-offered";
71
+ /** A release offers acceptance, but its runtime module was never generated, so the running application does not offer it. */
72
+ LaunchBlockerKind["SIGN_UP_ACCEPTANCE_NOT_CARRIED"] = "sign-up-acceptance-not-carried";
73
+ /**
74
+ * Every release offering acceptance is UNAPPROVED. Registration offers it only while `compliance.governedDocumentApprovalGate`
75
+ * is off; once the gate is armed — which Gate 3 does — registration offers nothing. Marked whatever the gate's state today,
76
+ * because this list is what Gate 3 reads.
77
+ */
78
+ LaunchBlockerKind["SIGN_UP_ACCEPTANCE_UNAPPROVED"] = "sign-up-acceptance-unapproved";
79
+ })(LaunchBlockerKind || (LaunchBlockerKind = {}));
80
+ /** An input the list is derived from — named so an unreadable one can be reported as such. */
81
+ export var LaunchBlockerSource;
82
+ (function (LaunchBlockerSource) {
83
+ /** `wildo.saas.config.ts`: the operator identity and the retention schedule. */
84
+ LaunchBlockerSource["APPLICATION_CONFIG"] = "application-config";
85
+ /** The creation question queue: the governance questions. */
86
+ LaunchBlockerSource["QUESTION_QUEUE"] = "question-queue";
87
+ /** The specifications package's recorded governed-document releases: sign-up acceptance. */
88
+ LaunchBlockerSource["DOCUMENT_RELEASES"] = "document-releases";
89
+ })(LaunchBlockerSource || (LaunchBlockerSource = {}));
90
+ /** One open decision. */
91
+ export const LaunchBlockerSchema = z.strictObject({
92
+ /** Stable across reads (`<kind>:<subject>`), so a reader can tell which item was settled between two reads. */
93
+ ref: z.string().min(1),
94
+ kind: z.enum(LaunchBlockerKind),
95
+ /** What is open, in one sentence. */
96
+ statement: z.string().min(1),
97
+ /** Where the decision lives — a file and field, or the surface that holds it. */
98
+ decidedIn: z.string().min(1),
99
+ /** The command to run or the edit to make that settles it. */
100
+ settledBy: z.string().min(1),
101
+ });
102
+ /** A source that could not be read, and why — so its entries read as UNKNOWN rather than absent. */
103
+ export const LaunchBlockerUnevaluatedSourceSchema = z.strictObject({
104
+ source: z.enum(LaunchBlockerSource),
105
+ reason: z.string().min(1),
106
+ });
107
+ /** The whole list, as the companion serves it and a run report renders it. */
108
+ export const LaunchBlockerListSchema = z.strictObject({
109
+ computedAt: z.string().min(1),
110
+ blockers: z.array(LaunchBlockerSchema),
111
+ unevaluatedSources: z.array(LaunchBlockerUnevaluatedSourceSchema),
112
+ });
113
+ const CONFIG_FILE = "wildo.saas.config.ts";
114
+ const BACKEND_CONFIG_FILE = "backend-api/src/saas-config.backend.ts";
115
+ /**
116
+ * What each identity part is, in a reader's words. TOTAL over the enum, so a part added to the identity
117
+ * is a compile error here until the list can name it.
118
+ */
119
+ const IDENTITY_PART_DESCRIPTION = {
120
+ [OperatorComplianceIdentityPart.LEGAL_ENTITY_NAME]: "the legal entity that operates the service",
121
+ [OperatorComplianceIdentityPart.REGISTERED_ADDRESS]: "the operator's registered address",
122
+ [OperatorComplianceIdentityPart.PRIVACY_CONTACT]: "how a data subject reaches the operator about privacy",
123
+ [OperatorComplianceIdentityPart.ROLE_ALLOCATIONS]: "the operator's role (controller or processor) per population of data",
124
+ [OperatorComplianceIdentityPart.LAWFUL_BASES]: "the lawful basis relied on for each processing purpose",
125
+ [OperatorComplianceIdentityPart.SUBJECT_REQUEST_IDENTITY_VERIFICATION]: "how a person exercising a data-subject right is verified",
126
+ [OperatorComplianceIdentityPart.HOSTING_REGIONS]: "where the operator's own infrastructure hosts the data",
127
+ };
128
+ /**
129
+ * The launch list, derived. Pure: the caller reads every input fresh, so a settled item is gone on the
130
+ * next call. Order follows how a creator settles them — who you are, the questions waiting on you, then
131
+ * what the configuration and the running application still lack.
132
+ */
133
+ export function deriveLaunchBlockers(inputs) {
134
+ const blockers = [];
135
+ const unevaluatedSources = [];
136
+ const unreadable = (source) => {
137
+ unevaluatedSources.push({ source, reason: inputs.unreadableReasons?.[source] ?? "it could not be read" });
138
+ };
139
+ if (inputs.applicationConfig === undefined) {
140
+ unreadable(LaunchBlockerSource.APPLICATION_CONFIG);
141
+ }
142
+ else {
143
+ for (const part of outstandingOperatorComplianceIdentityParts(inputs.applicationConfig.operatorComplianceIdentity)) {
144
+ blockers.push({
145
+ ref: `${LaunchBlockerKind.OPERATOR_IDENTITY_PART_UNDECLARED}:${part}`,
146
+ kind: LaunchBlockerKind.OPERATOR_IDENTITY_PART_UNDECLARED,
147
+ statement: `Not yet decided: ${IDENTITY_PART_DESCRIPTION[part]}.`,
148
+ decidedIn: `${CONFIG_FILE} → operatorComplianceIdentity.${part}`,
149
+ settledBy: `Declare \`operatorComplianceIdentity.${part}\` in ${CONFIG_FILE}. Never a placeholder: a produced notice quotes it as fact.`,
150
+ });
151
+ }
152
+ }
153
+ if (inputs.governanceQuestions === undefined) {
154
+ unreadable(LaunchBlockerSource.QUESTION_QUEUE);
155
+ }
156
+ else {
157
+ for (const question of inputs.governanceQuestions) {
158
+ blockers.push({
159
+ ref: `${LaunchBlockerKind.GOVERNANCE_QUESTION_UNANSWERED}:${question.questionId}`,
160
+ kind: LaunchBlockerKind.GOVERNANCE_QUESTION_UNANSWERED,
161
+ statement: `Unanswered governance question${question.definitionRef === null ? "" : ` for ${question.definitionRef}`}: ${question.prompt}`,
162
+ decidedIn: "the workbench's governance panel (a governed document's facts are landed as one sitting that names who decided)",
163
+ settledBy: `Answer it in the workbench's governance panel; \`wildo creation questions\` lists it as ${question.questionId}.`,
164
+ });
165
+ }
166
+ }
167
+ if (inputs.applicationConfig !== undefined) {
168
+ for (const dataClass of undeclaredRetentionClasses(inputs.applicationConfig.dataRetention)) {
169
+ blockers.push({
170
+ ref: `${LaunchBlockerKind.RETENTION_CLASS_UNDECLARED}:${dataClass}`,
171
+ kind: LaunchBlockerKind.RETENTION_CLASS_UNDECLARED,
172
+ statement: `No retention period is declared for ${dataClass}; a notice can only say it is not established.`,
173
+ decidedIn: `${CONFIG_FILE} → dataRetention.${dataClass}`,
174
+ settledBy: `Declare \`dataRetention.${dataClass}\` (retentionDays and rationale) in ${CONFIG_FILE}, then run \`wildo config data-retention\`.`,
175
+ });
176
+ }
177
+ }
178
+ /*
179
+ * The same predicate as the `subject-data-recipients` validate domain's warning: the module is absent.
180
+ * A STALE or uncarried module is that domain's FAILURE and is reported there; this list names the
181
+ * undecided state, which is the one a creation run leaves behind.
182
+ */
183
+ if (!inputs.subjectDataRecipientsModulePresent) {
184
+ blockers.push({
185
+ ref: LaunchBlockerKind.SUBJECT_DATA_RECIPIENTS_UNDECLARED,
186
+ kind: LaunchBlockerKind.SUBJECT_DATA_RECIPIENTS_UNDECLARED,
187
+ statement: "Subject-data recipients are not declared, so every subject export says so and every erasure is marked unmeasured.",
188
+ decidedIn: `${SUBJECT_DATA_RECIPIENTS_GENERATED_RELATIVE_PATH}, composed as compliance.subjectDataRecipients in ${BACKEND_CONFIG_FILE}`,
189
+ settledBy: `Run \`wildo config subject-data-recipients\` and compose \`compliance.subjectDataRecipients\` in ${BACKEND_CONFIG_FILE}.`,
190
+ });
191
+ }
192
+ /*
193
+ * Sign-up acceptance. The engine records it: a release whose `allowedInteractionKinds` include
194
+ * CONTRACT_ACCEPTED is offered at registration and accepting it writes a per-version acceptance row
195
+ * and an audit event. So the open decision is never "build a mechanism" — it is "no release offers it",
196
+ * "the release never reached the running application", or "only an unapproved release offers it".
197
+ */
198
+ if (inputs.documentReleases === undefined) {
199
+ unreadable(LaunchBlockerSource.DOCUMENT_RELEASES);
200
+ }
201
+ else {
202
+ /*
203
+ * In force NOW and allowing CONTRACT_ACCEPTED, as the registration control selects. Its third condition, the approval
204
+ * gate (`requiresApprovedGovernedDocuments`), lives in the backend configuration this list does not read, so it is
205
+ * not assumed either way: an offer resting only on unapproved releases is marked on its own below.
206
+ */
207
+ const offering = inputs.documentReleases.filter((release) => governedDocumentReleaseIsInForce(release, inputs.computedAt)
208
+ && release.allowedInteractionKinds.includes(GovernedDocumentInteractionKind.CONTRACT_ACCEPTED));
209
+ if (offering.length === 0) {
210
+ blockers.push({
211
+ ref: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_NOT_OFFERED,
212
+ kind: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_NOT_OFFERED,
213
+ statement: "How the terms and the privacy notice are accepted at sign-up is undecided: no recorded release in force allows CONTRACT_ACCEPTED, so registration records no acceptance.",
214
+ decidedIn: `the specifications package's documentReleaseCompositions, carried as compliance.governedDocumentReleases in ${BACKEND_CONFIG_FILE} (how acceptance is collected: compliance.governedDocumentAcceptanceMode)`,
215
+ settledBy: `Compose a release of the terms or privacy notice that allows CONTRACT_ACCEPTED in documentReleaseCompositions, run \`wildo config document-releases\`, and compose \`compliance.governedDocumentReleases\` in ${BACKEND_CONFIG_FILE}.`,
216
+ });
217
+ }
218
+ else {
219
+ if (!inputs.documentReleasesModulePresent) {
220
+ blockers.push({
221
+ ref: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_NOT_CARRIED,
222
+ kind: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_NOT_CARRIED,
223
+ statement: `${offering.length} recorded release(s) allow acceptance at sign-up, but ${GOVERNED_DOCUMENT_RELEASES_GENERATED_RELATIVE_PATH} does not exist, so the running application offers none.`,
224
+ decidedIn: `${GOVERNED_DOCUMENT_RELEASES_GENERATED_RELATIVE_PATH}, composed as compliance.governedDocumentReleases in ${BACKEND_CONFIG_FILE}`,
225
+ settledBy: `Run \`wildo config document-releases\` and compose \`compliance.governedDocumentReleases\` in ${BACKEND_CONFIG_FILE}.`,
226
+ });
227
+ }
228
+ if (!offering.some((release) => release.approvalState === GovernedDocumentReleaseApprovalState.APPROVED)) {
229
+ blockers.push({
230
+ ref: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_UNAPPROVED,
231
+ kind: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_UNAPPROVED,
232
+ statement: `The ${offering.length} release(s) offered for acceptance at sign-up are unapproved: registration offers them only while compliance.governedDocumentApprovalGate is off, and offers nothing once it is armed.`,
233
+ decidedIn: "the release's approvalDecisions in documentReleaseCompositions; compliance.governedDocumentApprovalGate decides whether an unapproved release is offered",
234
+ settledBy: "Compose an approved release (approvalDecisions on its documentReleaseCompositions entry, with the next releaseVersion where one is already recorded), then run `wildo config document-releases`.",
235
+ });
236
+ }
237
+ }
238
+ }
239
+ return { computedAt: inputs.computedAt, blockers, unevaluatedSources };
240
+ }
241
+ //# sourceMappingURL=launch-blockers.schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launch-blockers.schemas.js","sourceRoot":"","sources":["../../../../../src/_core/compliance-documents/launch-blockers.schemas.ts"],"names":[],"mapp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6BAA6B;oBACpD,IAAI,EAAE,iBAAiB,CAAC,6BAA6B;oBACrD,SAAS,EAAE,OAAO,QAAQ,CAAC,MAAM,wLAAwL;oBACzN,SAAS,EAAE,0JAA0J;oBACrK,SAAS,EAAE,kMAAkM;iBAC9M,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,kBAAkB,EAAE,CAAC;AACzE,CAAC","sourcesContent":["/**\n * The \"before you can launch\" list: every open compliance decision that stands between a created\n * application and a real user, each with where it is decided and what settles it (#2238).\n *\n * ## Why it exists\n *\n * A creation run ended without saying what was still open. In run 004 the operator's legal entity and\n * hosting region, two governance questions, the retention classes, the subject-data recipients and the\n * sign-up acceptance were all undecided, and they surfaced as `wildo config validate` warnings in logs,\n * or not at all. Spread across logs, none of them is a list anyone acts on.\n *\n * ## It MARKS, it never blocks\n *\n * Nothing calls this to decide whether creation may proceed. `application-creation-directive.md`\n * forbids a compliance workflow standing in front of creation; Gate 3 is where these points become\n * gates, and this is what that gate will read. So the list has no severity and no pass/fail verdict:\n * it is what is open, stated plainly.\n *\n * ## It is DERIVED, never asked\n *\n * Every entry is a function of something the application already holds, by the same predicate the\n * surface that owns it already uses (`compliance-is-derived-from-the-product.md`,\n * `derive-before-you-ask.md`):\n *\n * | entry | derived from |\n * |---|---|\n * | operator identity part | {@link outstandingOperatorComplianceIdentityParts}, total over {@link OperatorComplianceIdentityPart} |\n * | retention class | {@link undeclaredRetentionClasses}, total over `DataRetentionClass` |\n * | subject-data recipients | the generated recipients module is absent — the predicate behind `wildo config validate`'s warning |\n * | governance question | the creation question queue's `GOVERNANCE_FACT` items (`wildo creation questions`) |\n * | sign-up acceptance | the recorded governed-document releases in force, their approval, and whether their runtime module exists |\n *\n * The governance population is the QUEUE's, deliberately: a fact still needed by a DRAFTED governed document. A document\n * not drafted yet asks nothing, so its facts are not listed here — the creation run drafting it is what surfaces them.\n * Gate 3 must not read an empty governance section as \"every governed document is complete\".\n *\n * Settling an item removes it on the next read, because nothing here is stored: the caller reads each\n * input fresh and this function recomputes. A total derivation also means an identity part or a\n * retention class added to its vocabulary tomorrow appears here for every application at once.\n *\n * ## An input that could not be read is NOT an empty list\n *\n * Each input is optional for exactly that reason. An unreadable configuration or question queue is\n * reported in {@link LaunchBlockerList.unevaluatedSources}, never as \"nothing open\" — a launch list that\n * reads clean because its source failed is the most dangerous answer it could give\n * (`negative-results-require-a-positive-probe.md`).\n */\n\nimport { z } from \"zod\";\n\nimport {\n GovernedDocumentInteractionKind,\n GovernedDocumentReleaseApprovalState,\n governedDocumentReleaseIsInForce,\n OperatorComplianceIdentityPart,\n outstandingOperatorComplianceIdentityParts,\n undeclaredRetentionClasses,\n type ApplicationOperatorComplianceIdentity,\n type ApplicationRetentionSchedule,\n type GovernedDocumentRelease,\n} from \"@wildo-ai/saas-models\";\n\n/*\n * entrypoint-closure-waiver: this root-reachable module imports ONE value from the assurance-only release module —\n * `GOVERNED_DOCUMENT_RELEASES_GENERATED_RELATIVE_PATH`, a string constant whose declared type is a string literal.\n * No nominal type (enum, class, brand) crosses: the constant is used only inside prose this module builds, and no\n * exported signature here names anything from that module, so a root-only consumer has nothing to name.\n */\nimport { GOVERNED_DOCUMENT_RELEASES_GENERATED_RELATIVE_PATH } from \"../../assurance/governed-document-release\";\nimport { SUBJECT_DATA_RECIPIENTS_GENERATED_RELATIVE_PATH } from \"./subject-data-recipients.schemas\";\n\n/** WHAT is open — one member per kind of launch decision, each with its own settling path. */\nexport enum LaunchBlockerKind {\n /** A part of `operatorComplianceIdentity` is undeclared: the legal entity, the hosting region, the privacy contact… */\n OPERATOR_IDENTITY_PART_UNDECLARED = \"operator-identity-part-undeclared\",\n /** A governed-document question waits on the person; it is answered in the workbench's governance panel. */\n GOVERNANCE_QUESTION_UNANSWERED = \"governance-question-unanswered\",\n /** A `DataRetentionClass` has no declared period in `dataRetention`. */\n RETENTION_CLASS_UNDECLARED = \"retention-class-undeclared\",\n /** No subject-data recipients module, so every subject export says recipients are not declared. */\n SUBJECT_DATA_RECIPIENTS_UNDECLARED = \"subject-data-recipients-undeclared\",\n /** No recorded release lets a person accept it, so sign-up records no acceptance of the terms or the privacy notice. */\n SIGN_UP_ACCEPTANCE_NOT_OFFERED = \"sign-up-acceptance-not-offered\",\n /** A release offers acceptance, but its runtime module was never generated, so the running application does not offer it. */\n SIGN_UP_ACCEPTANCE_NOT_CARRIED = \"sign-up-acceptance-not-carried\",\n /**\n * Every release offering acceptance is UNAPPROVED. Registration offers it only while `compliance.governedDocumentApprovalGate`\n * is off; once the gate is armed — which Gate 3 does — registration offers nothing. Marked whatever the gate's state today,\n * because this list is what Gate 3 reads.\n */\n SIGN_UP_ACCEPTANCE_UNAPPROVED = \"sign-up-acceptance-unapproved\",\n}\n\n/** An input the list is derived from — named so an unreadable one can be reported as such. */\nexport enum LaunchBlockerSource {\n /** `wildo.saas.config.ts`: the operator identity and the retention schedule. */\n APPLICATION_CONFIG = \"application-config\",\n /** The creation question queue: the governance questions. */\n QUESTION_QUEUE = \"question-queue\",\n /** The specifications package's recorded governed-document releases: sign-up acceptance. */\n DOCUMENT_RELEASES = \"document-releases\",\n}\n\n/** One open decision. */\nexport const LaunchBlockerSchema = z.strictObject({\n /** Stable across reads (`<kind>:<subject>`), so a reader can tell which item was settled between two reads. */\n ref: z.string().min(1),\n kind: z.enum(LaunchBlockerKind),\n /** What is open, in one sentence. */\n statement: z.string().min(1),\n /** Where the decision lives — a file and field, or the surface that holds it. */\n decidedIn: z.string().min(1),\n /** The command to run or the edit to make that settles it. */\n settledBy: z.string().min(1),\n});\nexport type LaunchBlocker = z.infer<typeof LaunchBlockerSchema>;\n\n/** A source that could not be read, and why — so its entries read as UNKNOWN rather than absent. */\nexport const LaunchBlockerUnevaluatedSourceSchema = z.strictObject({\n source: z.enum(LaunchBlockerSource),\n reason: z.string().min(1),\n});\nexport type LaunchBlockerUnevaluatedSource = z.infer<typeof LaunchBlockerUnevaluatedSourceSchema>;\n\n/** The whole list, as the companion serves it and a run report renders it. */\nexport const LaunchBlockerListSchema = z.strictObject({\n computedAt: z.string().min(1),\n blockers: z.array(LaunchBlockerSchema),\n unevaluatedSources: z.array(LaunchBlockerUnevaluatedSourceSchema),\n});\nexport type LaunchBlockerList = z.infer<typeof LaunchBlockerListSchema>;\n\n/** A queued governed-document question, as much of it as the list names. */\nexport interface LaunchBlockerGovernanceQuestion {\n /** The queue's id, `governance-fact:<rowId>` — what `wildo creation questions` prints. */\n readonly questionId: string;\n /** The governed document whose draft needs the answer. */\n readonly definitionRef: string | null;\n /** The question, in the words the person is asked. */\n readonly prompt: string;\n}\n\n/** Everything the list is derived from. `undefined` means the input could not be READ, never that it is empty. */\nexport interface LaunchBlockerInputs {\n readonly computedAt: string;\n /** The application's configuration, read fresh. `undefined` when it could not be loaded. */\n readonly applicationConfig?: {\n readonly operatorComplianceIdentity?: ApplicationOperatorComplianceIdentity;\n readonly dataRetention?: ApplicationRetentionSchedule;\n };\n /** Whether {@link SUBJECT_DATA_RECIPIENTS_GENERATED_RELATIVE_PATH} exists in the application. */\n readonly subjectDataRecipientsModulePresent: boolean;\n /** The governed-document questions waiting on the person. `undefined` when the queue could not be read. */\n readonly governanceQuestions?: readonly LaunchBlockerGovernanceQuestion[];\n /** The recorded releases (`documentReleaseSet`). `undefined` when the specifications package could not be read. */\n readonly documentReleases?: readonly GovernedDocumentRelease[];\n /** Whether {@link GOVERNED_DOCUMENT_RELEASES_GENERATED_RELATIVE_PATH} exists in the application. */\n readonly documentReleasesModulePresent: boolean;\n /** Why each unreadable input could not be read, for the report. */\n readonly unreadableReasons?: Partial<Record<LaunchBlockerSource, string>>;\n}\n\nconst CONFIG_FILE = \"wildo.saas.config.ts\";\nconst BACKEND_CONFIG_FILE = \"backend-api/src/saas-config.backend.ts\";\n\n/**\n * What each identity part is, in a reader's words. TOTAL over the enum, so a part added to the identity\n * is a compile error here until the list can name it.\n */\nconst IDENTITY_PART_DESCRIPTION: Readonly<Record<OperatorComplianceIdentityPart, string>> = {\n [OperatorComplianceIdentityPart.LEGAL_ENTITY_NAME]: \"the legal entity that operates the service\",\n [OperatorComplianceIdentityPart.REGISTERED_ADDRESS]: \"the operator's registered address\",\n [OperatorComplianceIdentityPart.PRIVACY_CONTACT]: \"how a data subject reaches the operator about privacy\",\n [OperatorComplianceIdentityPart.ROLE_ALLOCATIONS]: \"the operator's role (controller or processor) per population of data\",\n [OperatorComplianceIdentityPart.LAWFUL_BASES]: \"the lawful basis relied on for each processing purpose\",\n [OperatorComplianceIdentityPart.SUBJECT_REQUEST_IDENTITY_VERIFICATION]: \"how a person exercising a data-subject right is verified\",\n [OperatorComplianceIdentityPart.HOSTING_REGIONS]: \"where the operator's own infrastructure hosts the data\",\n};\n\n/**\n * The launch list, derived. Pure: the caller reads every input fresh, so a settled item is gone on the\n * next call. Order follows how a creator settles them — who you are, the questions waiting on you, then\n * what the configuration and the running application still lack.\n */\nexport function deriveLaunchBlockers(inputs: LaunchBlockerInputs): LaunchBlockerList {\n const blockers: LaunchBlocker[] = [];\n const unevaluatedSources: LaunchBlockerUnevaluatedSource[] = [];\n const unreadable = (source: LaunchBlockerSource): void => {\n unevaluatedSources.push({ source, reason: inputs.unreadableReasons?.[source] ?? \"it could not be read\" });\n };\n\n if (inputs.applicationConfig === undefined) {\n unreadable(LaunchBlockerSource.APPLICATION_CONFIG);\n } else {\n for (const part of outstandingOperatorComplianceIdentityParts(inputs.applicationConfig.operatorComplianceIdentity)) {\n blockers.push({\n ref: `${LaunchBlockerKind.OPERATOR_IDENTITY_PART_UNDECLARED}:${part}`,\n kind: LaunchBlockerKind.OPERATOR_IDENTITY_PART_UNDECLARED,\n statement: `Not yet decided: ${IDENTITY_PART_DESCRIPTION[part]}.`,\n decidedIn: `${CONFIG_FILE} → operatorComplianceIdentity.${part}`,\n settledBy: `Declare \\`operatorComplianceIdentity.${part}\\` in ${CONFIG_FILE}. Never a placeholder: a produced notice quotes it as fact.`,\n });\n }\n }\n\n if (inputs.governanceQuestions === undefined) {\n unreadable(LaunchBlockerSource.QUESTION_QUEUE);\n } else {\n for (const question of inputs.governanceQuestions) {\n blockers.push({\n ref: `${LaunchBlockerKind.GOVERNANCE_QUESTION_UNANSWERED}:${question.questionId}`,\n kind: LaunchBlockerKind.GOVERNANCE_QUESTION_UNANSWERED,\n statement: `Unanswered governance question${question.definitionRef === null ? \"\" : ` for ${question.definitionRef}`}: ${question.prompt}`,\n decidedIn: \"the workbench's governance panel (a governed document's facts are landed as one sitting that names who decided)\",\n settledBy: `Answer it in the workbench's governance panel; \\`wildo creation questions\\` lists it as ${question.questionId}.`,\n });\n }\n }\n\n if (inputs.applicationConfig !== undefined) {\n for (const dataClass of undeclaredRetentionClasses(inputs.applicationConfig.dataRetention)) {\n blockers.push({\n ref: `${LaunchBlockerKind.RETENTION_CLASS_UNDECLARED}:${dataClass}`,\n kind: LaunchBlockerKind.RETENTION_CLASS_UNDECLARED,\n statement: `No retention period is declared for ${dataClass}; a notice can only say it is not established.`,\n decidedIn: `${CONFIG_FILE} → dataRetention.${dataClass}`,\n settledBy: `Declare \\`dataRetention.${dataClass}\\` (retentionDays and rationale) in ${CONFIG_FILE}, then run \\`wildo config data-retention\\`.`,\n });\n }\n }\n\n /*\n * The same predicate as the `subject-data-recipients` validate domain's warning: the module is absent.\n * A STALE or uncarried module is that domain's FAILURE and is reported there; this list names the\n * undecided state, which is the one a creation run leaves behind.\n */\n if (!inputs.subjectDataRecipientsModulePresent) {\n blockers.push({\n ref: LaunchBlockerKind.SUBJECT_DATA_RECIPIENTS_UNDECLARED,\n kind: LaunchBlockerKind.SUBJECT_DATA_RECIPIENTS_UNDECLARED,\n statement: \"Subject-data recipients are not declared, so every subject export says so and every erasure is marked unmeasured.\",\n decidedIn: `${SUBJECT_DATA_RECIPIENTS_GENERATED_RELATIVE_PATH}, composed as compliance.subjectDataRecipients in ${BACKEND_CONFIG_FILE}`,\n settledBy: `Run \\`wildo config subject-data-recipients\\` and compose \\`compliance.subjectDataRecipients\\` in ${BACKEND_CONFIG_FILE}.`,\n });\n }\n\n /*\n * Sign-up acceptance. The engine records it: a release whose `allowedInteractionKinds` include\n * CONTRACT_ACCEPTED is offered at registration and accepting it writes a per-version acceptance row\n * and an audit event. So the open decision is never \"build a mechanism\" — it is \"no release offers it\",\n * \"the release never reached the running application\", or \"only an unapproved release offers it\".\n */\n if (inputs.documentReleases === undefined) {\n unreadable(LaunchBlockerSource.DOCUMENT_RELEASES);\n } else {\n /*\n * In force NOW and allowing CONTRACT_ACCEPTED, as the registration control selects. Its third condition, the approval\n * gate (`requiresApprovedGovernedDocuments`), lives in the backend configuration this list does not read, so it is\n * not assumed either way: an offer resting only on unapproved releases is marked on its own below.\n */\n const offering = inputs.documentReleases.filter((release) =>\n governedDocumentReleaseIsInForce(release, inputs.computedAt)\n && release.allowedInteractionKinds.includes(GovernedDocumentInteractionKind.CONTRACT_ACCEPTED));\n if (offering.length === 0) {\n blockers.push({\n ref: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_NOT_OFFERED,\n kind: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_NOT_OFFERED,\n statement: \"How the terms and the privacy notice are accepted at sign-up is undecided: no recorded release in force allows CONTRACT_ACCEPTED, so registration records no acceptance.\",\n decidedIn: `the specifications package's documentReleaseCompositions, carried as compliance.governedDocumentReleases in ${BACKEND_CONFIG_FILE} (how acceptance is collected: compliance.governedDocumentAcceptanceMode)`,\n settledBy: `Compose a release of the terms or privacy notice that allows CONTRACT_ACCEPTED in documentReleaseCompositions, run \\`wildo config document-releases\\`, and compose \\`compliance.governedDocumentReleases\\` in ${BACKEND_CONFIG_FILE}.`,\n });\n } else {\n if (!inputs.documentReleasesModulePresent) {\n blockers.push({\n ref: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_NOT_CARRIED,\n kind: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_NOT_CARRIED,\n statement: `${offering.length} recorded release(s) allow acceptance at sign-up, but ${GOVERNED_DOCUMENT_RELEASES_GENERATED_RELATIVE_PATH} does not exist, so the running application offers none.`,\n decidedIn: `${GOVERNED_DOCUMENT_RELEASES_GENERATED_RELATIVE_PATH}, composed as compliance.governedDocumentReleases in ${BACKEND_CONFIG_FILE}`,\n settledBy: `Run \\`wildo config document-releases\\` and compose \\`compliance.governedDocumentReleases\\` in ${BACKEND_CONFIG_FILE}.`,\n });\n }\n if (!offering.some((release) => release.approvalState === GovernedDocumentReleaseApprovalState.APPROVED)) {\n blockers.push({\n ref: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_UNAPPROVED,\n kind: LaunchBlockerKind.SIGN_UP_ACCEPTANCE_UNAPPROVED,\n statement: `The ${offering.length} release(s) offered for acceptance at sign-up are unapproved: registration offers them only while compliance.governedDocumentApprovalGate is off, and offers nothing once it is armed.`,\n decidedIn: \"the release's approvalDecisions in documentReleaseCompositions; compliance.governedDocumentApprovalGate decides whether an unapproved release is offered\",\n settledBy: \"Compose an approved release (approvalDecisions on its documentReleaseCompositions entry, with the next releaseVersion where one is already recorded), then run `wildo config document-releases`.\",\n });\n }\n }\n }\n\n return { computedAt: inputs.computedAt, blockers, unevaluatedSources };\n}\n"]}
@@ -14,7 +14,14 @@ export declare enum DomainPlanValidationIssueCode {
14
14
  RELATIONSHIP_ENDPOINTS_IDENTICAL = "relationship-endpoints-identical",
15
15
  RELATIONSHIP_ENDPOINT_NOT_INVENTORIED = "relationship-endpoint-not-inventoried",
16
16
  RELATIONSHIP_CARDINALITY_MISSING = "relationship-cardinality-missing",
17
- RELATIONSHIP_OWNERSHIP_MISSING = "relationship-ownership-missing"
17
+ RELATIONSHIP_OWNERSHIP_MISSING = "relationship-ownership-missing",
18
+ /**
19
+ * A one-sided cardinality whose "one" end is said to hold the reference — e.g. `one-to-many` with
20
+ * `source-holds-reference`. Read source → target, the many side holds the reference, so the two
21
+ * intents cannot both be true. Refused here rather than left to the semantic judge, which used to
22
+ * catch it as a GAP after the model had already spent its turn.
23
+ */
24
+ RELATIONSHIP_OWNERSHIP_CONTRADICTS_CARDINALITY = "relationship-ownership-contradicts-cardinality"
18
25
  }
19
26
  export declare const DomainPlanValidationIssueSchema: z.ZodObject<{
20
27
  code: z.ZodEnum<typeof DomainPlanValidationIssueCode>;
@@ -1 +1 @@
1
- {"version":3,"file":"domain-plan-output-set-validation.d.ts","sourceRoot":"","sources":["../../../../../src/_core/domain-plan/domain-plan-output-set-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvG,oBAAY,iCAAiC;IAC3C,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,oBAAY,6BAA6B;IACvC,mBAAmB,wBAAwB;IAC3C,sCAAsC,2CAA2C;IACjF,2BAA2B,gCAAgC;IAC3D,kCAAkC,uCAAuC;IACzE,0BAA0B,+BAA+B;IACzD,sBAAsB,2BAA2B;IACjD,gCAAgC,qCAAqC;IACrE,qCAAqC,0CAA0C;IAC/E,gCAAgC,qCAAqC;IACrE,8BAA8B,mCAAmC;CAClE;AAED,eAAO,MAAM,+BAA+B;;;;;;iBAM1C,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,yCAAyC;;;;;;;;;iBAGpD,CAAC;AACH,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yCAAyC,CAAC,CAAC;AAE5G;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,mBAAmB,GAAG,mCAAmC,CA4I3G"}
1
+ {"version":3,"file":"domain-plan-output-set-validation.d.ts","sourceRoot":"","sources":["../../../../../src/_core/domain-plan/domain-plan-output-set-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,kCAAkC,CAAC;AAE1C,oBAAY,iCAAiC;IAC3C,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,oBAAY,6BAA6B;IACvC,mBAAmB,wBAAwB;IAC3C,sCAAsC,2CAA2C;IACjF,2BAA2B,gCAAgC;IAC3D,kCAAkC,uCAAuC;IACzE,0BAA0B,+BAA+B;IACzD,sBAAsB,2BAA2B;IACjD,gCAAgC,qCAAqC;IACrE,qCAAqC,0CAA0C;IAC/E,gCAAgC,qCAAqC;IACrE,8BAA8B,mCAAmC;IACjE;;;;;OAKG;IACH,8CAA8C,mDAAmD;CAClG;AAED,eAAO,MAAM,+BAA+B;;;;;;iBAM1C,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,eAAO,MAAM,yCAAyC;;;;;;;;;iBAGpD,CAAC;AACH,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yCAAyC,CAAC,CAAC;AAE5G;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,mBAAmB,GAAG,mCAAmC,CA6J3G"}
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { DomainPlanOutputSetSchema } from './domain-plan-output-set.schemas.js';
2
+ import { DomainPlanOutputSetSchema, DomainRelationshipCardinalityIntent, DomainRelationshipOwnershipIntent, domainRelationshipOwnershipContradictsCardinality, domainRelationshipOwnershipRequiredByCardinality, } from './domain-plan-output-set.schemas.js';
3
3
  export var DomainPlanValidationIssueSeverity;
4
4
  (function (DomainPlanValidationIssueSeverity) {
5
5
  DomainPlanValidationIssueSeverity["ERROR"] = "error";
@@ -17,6 +17,13 @@ export var DomainPlanValidationIssueCode;
17
17
  DomainPlanValidationIssueCode["RELATIONSHIP_ENDPOINT_NOT_INVENTORIED"] = "relationship-endpoint-not-inventoried";
18
18
  DomainPlanValidationIssueCode["RELATIONSHIP_CARDINALITY_MISSING"] = "relationship-cardinality-missing";
19
19
  DomainPlanValidationIssueCode["RELATIONSHIP_OWNERSHIP_MISSING"] = "relationship-ownership-missing";
20
+ /**
21
+ * A one-sided cardinality whose "one" end is said to hold the reference — e.g. `one-to-many` with
22
+ * `source-holds-reference`. Read source → target, the many side holds the reference, so the two
23
+ * intents cannot both be true. Refused here rather than left to the semantic judge, which used to
24
+ * catch it as a GAP after the model had already spent its turn.
25
+ */
26
+ DomainPlanValidationIssueCode["RELATIONSHIP_OWNERSHIP_CONTRADICTS_CARDINALITY"] = "relationship-ownership-contradicts-cardinality";
20
27
  })(DomainPlanValidationIssueCode || (DomainPlanValidationIssueCode = {}));
21
28
  export const DomainPlanValidationIssueSchema = z.object({
22
29
  code: z.enum(DomainPlanValidationIssueCode),
@@ -102,6 +109,17 @@ export function validateDomainPlanOutputSet(input) {
102
109
  if (relationship.ownershipIntent === undefined) {
103
110
  addIssue(issues, DomainPlanValidationIssueCode.RELATIONSHIP_OWNERSHIP_MISSING, `${path}.ownershipIntent`, 'Relationship ownership intent is required before semantic evaluation.', [relationship.relationshipRef]);
104
111
  }
112
+ if (domainRelationshipOwnershipContradictsCardinality(relationship)) {
113
+ // Both are defined here: the predicate is false while either is undecided.
114
+ const required = domainRelationshipOwnershipRequiredByCardinality(relationship.cardinalityIntent);
115
+ const reversed = relationship.cardinalityIntent === DomainRelationshipCardinalityIntent.ONE_TO_MANY
116
+ ? DomainRelationshipCardinalityIntent.MANY_TO_ONE
117
+ : DomainRelationshipCardinalityIntent.ONE_TO_MANY;
118
+ addIssue(issues, DomainPlanValidationIssueCode.RELATIONSHIP_OWNERSHIP_CONTRADICTS_CARDINALITY, `${path}.ownershipIntent`, `Relationship "${relationship.relationshipRef}" says ${relationship.cardinalityIntent} from ${relationship.sourceResourceRef} (source) to `
119
+ + `${relationship.targetResourceRef} (target) with ${relationship.ownershipIntent}. Cardinality is read source → target, and the "many" side `
120
+ + `holds the reference, so ${relationship.cardinalityIntent} requires ${required}. If ${relationship.ownershipIntent === DomainRelationshipOwnershipIntent.SOURCE_HOLDS_REFERENCE ? relationship.sourceResourceRef : relationship.targetResourceRef} `
121
+ + `really holds the reference, the cardinality is ${reversed}.`, [relationship.relationshipRef, relationship.sourceResourceRef, relationship.targetResourceRef]);
122
+ }
105
123
  });
106
124
  issues.sort((left, right) => `${left.code}\u0000${left.path}\u0000${left.message}`.localeCompare(`${right.code}\u0000${right.path}\u0000${right.message}`));
107
125
  return DomainPlanOutputSetValidationResultSchema.parse({
@@ -1 +1 @@
1
- {"version":3,"file":"domain-plan-output-set-validation.js","sourceRoot":"","sources":["../../../../../src/_core/domain-plan/domain-plan-output-set-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,yBAAyB,EAA4B,MAAM,kCAAkC,CAAC;AAEvG,MAAM,CAAN,IAAY,iCAGX;AAHD,WAAY,iCAAiC;IAC3C,oDAAe,CAAA;IACf,wDAAmB,CAAA;AACrB,CAAC,EAHW,iCAAiC,KAAjC,iCAAiC,QAG5C;AAED,MAAM,CAAN,IAAY,6BAWX;AAXD,WAAY,6BAA6B;IACvC,4EAA2C,CAAA;IAC3C,kHAAiF,CAAA;IACjF,4FAA2D,CAAA;IAC3D,0GAAyE,CAAA;IACzE,0FAAyD,CAAA;IACzD,kFAAiD,CAAA;IACjD,sGAAqE,CAAA;IACrE,gHAA+E,CAAA;IAC/E,sGAAqE,CAAA;IACrE,kGAAiE,CAAA;AACnE,CAAC,EAXW,6BAA6B,KAA7B,6BAA6B,QAWxC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC;IACtD,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,6BAA6B,CAAC;IAC3C,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,iCAAiC,CAAC;IACnD,IAAI,EAAE,CAAC,CAAC,MAAM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CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,iCAAiC,CAAC,KAAK,CAAC;QAC1F,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CAAC,MAAyB;IAC7C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC5C,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7F,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,QAAQ,CACf,MAAmC,EACnC,IAAmC,EACnC,IAAY,EACZ,OAAe,EACf,WAAqB;IAErB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,iCAAiC,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;AACvG,CAAC","sourcesContent":["import { z } from 'zod';\n\nimport { DomainPlanOutputSetSchema, type DomainPlanOutputSet } from './domain-plan-output-set.schemas';\n\nexport enum DomainPlanValidationIssueSeverity {\n ERROR = 'error',\n WARNING = 'warning',\n}\n\nexport enum DomainPlanValidationIssueCode {\n DUPLICATE_MODULE_ID = 'duplicate-module-id',\n DUPLICATE_RESOURCE_IN_MODULE_INVENTORY = 'duplicate-resource-in-module-inventory',\n RESOURCE_WITHOUT_MAIN_OWNER = 'resource-without-main-owner',\n RESOURCE_WITH_MULTIPLE_MAIN_OWNERS = 'resource-with-multiple-main-owners',\n DUPLICATE_RELATIONSHIP_REF = 'duplicate-relationship-ref',\n DUPLICATE_RELATIONSHIP = 'duplicate-relationship',\n RELATIONSHIP_ENDPOINTS_IDENTICAL = 'relationship-endpoints-identical',\n RELATIONSHIP_ENDPOINT_NOT_INVENTORIED = 'relationship-endpoint-not-inventoried',\n RELATIONSHIP_CARDINALITY_MISSING = 'relationship-cardinality-missing',\n RELATIONSHIP_OWNERSHIP_MISSING = 'relationship-ownership-missing',\n}\n\nexport const DomainPlanValidationIssueSchema = z.object({\n code: z.enum(DomainPlanValidationIssueCode),\n severity: z.enum(DomainPlanValidationIssueSeverity),\n path: z.string().min(1),\n message: z.string().min(1),\n relatedRefs: z.array(z.string().min(1)),\n});\nexport type DomainPlanValidationIssue = z.infer<typeof DomainPlanValidationIssueSchema>;\n\nexport const DomainPlanOutputSetValidationResultSchema = z.object({\n valid: z.boolean(),\n issues: z.array(DomainPlanValidationIssueSchema),\n});\nexport type DomainPlanOutputSetValidationResult = z.infer<typeof DomainPlanOutputSetValidationResultSchema>;\n\n/**\n * Deterministic structural validation before semantic evaluation. It diagnoses\n * a staged payload; it neither accepts family state nor substitutes for the\n * required `domain-plan-coherent` evaluator.\n */\nexport function validateDomainPlanOutputSet(input: DomainPlanOutputSet): DomainPlanOutputSetValidationResult {\n const outputSet = DomainPlanOutputSetSchema.parse(input);\n const issues: DomainPlanValidationIssue[] = [];\n const moduleIndexesById = groupIndexes(outputSet.modules.map((module) => module.relatedModuleId));\n for (const [moduleId, indexes] of moduleIndexesById) {\n for (const duplicateIndex of indexes.slice(1)) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.DUPLICATE_MODULE_ID,\n `modules[${duplicateIndex}].relatedModuleId`,\n `Module id is declared more than once: ${moduleId}`,\n [moduleId],\n );\n }\n }\n\n const mainOwnerIndexesByResource = new Map<string, Set<number>>();\n const inventoriedResources = new Set<string>();\n outputSet.modules.forEach((module, moduleIndex) => {\n const mainResources = new Set<string>();\n const supportingResources = new Set<string>();\n module.mainResources.forEach((resourceRef, resourceIndex) => {\n inventoriedResources.add(resourceRef);\n if (mainResources.has(resourceRef)) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.DUPLICATE_RESOURCE_IN_MODULE_INVENTORY,\n `modules[${moduleIndex}].mainResources[${resourceIndex}]`,\n `Resource is repeated in the module's main inventory: ${resourceRef}`,\n [module.relatedModuleId, resourceRef],\n );\n }\n mainResources.add(resourceRef);\n const owners = mainOwnerIndexesByResource.get(resourceRef) ?? new Set<number>();\n owners.add(moduleIndex);\n mainOwnerIndexesByResource.set(resourceRef, owners);\n });\n module.supportingResources.forEach((resourceRef, resourceIndex) => {\n inventoriedResources.add(resourceRef);\n if (supportingResources.has(resourceRef) || mainResources.has(resourceRef)) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.DUPLICATE_RESOURCE_IN_MODULE_INVENTORY,\n `modules[${moduleIndex}].supportingResources[${resourceIndex}]`,\n `Resource is repeated or occupies both inventory roles in one module: ${resourceRef}`,\n [module.relatedModuleId, resourceRef],\n );\n }\n supportingResources.add(resourceRef);\n });\n });\n\n for (const resourceRef of [...inventoriedResources].sort()) {\n const owners = [...(mainOwnerIndexesByResource.get(resourceRef) ?? new Set<number>())].sort((left, right) => left - right);\n if (owners.length === 0) {\n addIssue(issues, DomainPlanValidationIssueCode.RESOURCE_WITHOUT_MAIN_OWNER, 'modules', `Inventoried resource has no main owning module: ${resourceRef}`, [resourceRef]);\n }\n if (owners.length > 1) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RESOURCE_WITH_MULTIPLE_MAIN_OWNERS,\n `modules[${owners[1]}].mainResources`,\n `Resource has more than one main owning module: ${resourceRef}`,\n [resourceRef, ...owners.map((index) => outputSet.modules[index]!.relatedModuleId)],\n );\n }\n }\n\n const relationshipIndexesByRef = groupIndexes(outputSet.relationships.map((relationship) => relationship.relationshipRef));\n const relationshipIndexesByEndpoints = groupIndexes(\n outputSet.relationships.map((relationship) => [relationship.sourceResourceRef, relationship.targetResourceRef].sort().join('\\u0000')),\n );\n outputSet.relationships.forEach((relationship, relationshipIndex) => {\n const path = `relationships[${relationshipIndex}]`;\n const sameRefIndexes = relationshipIndexesByRef.get(relationship.relationshipRef) ?? [];\n if (sameRefIndexes.length > 1 && sameRefIndexes[0] !== relationshipIndex) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.DUPLICATE_RELATIONSHIP_REF,\n `${path}.relationshipRef`,\n `Relationship ref is declared more than once: ${relationship.relationshipRef}`,\n [relationship.relationshipRef],\n );\n }\n const endpointKey = [relationship.sourceResourceRef, relationship.targetResourceRef].sort().join('\\u0000');\n const sameEndpointIndexes = relationshipIndexesByEndpoints.get(endpointKey) ?? [];\n if (sameEndpointIndexes.length > 1 && sameEndpointIndexes[0] !== relationshipIndex) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.DUPLICATE_RELATIONSHIP,\n path,\n 'The same resource endpoints are related more than once.',\n [relationship.sourceResourceRef, relationship.targetResourceRef],\n );\n }\n if (relationship.sourceResourceRef === relationship.targetResourceRef) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RELATIONSHIP_ENDPOINTS_IDENTICAL,\n path,\n 'A relationship must name two distinct resource endpoints.',\n [relationship.sourceResourceRef],\n );\n }\n for (const [field, resourceRef] of [['sourceResourceRef', relationship.sourceResourceRef], ['targetResourceRef', relationship.targetResourceRef]] as const) {\n if (!inventoriedResources.has(resourceRef)) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RELATIONSHIP_ENDPOINT_NOT_INVENTORIED,\n `${path}.${field}`,\n `Relationship endpoint is absent from the module inventory: ${resourceRef}`,\n [relationship.relationshipRef, resourceRef],\n );\n }\n }\n if (relationship.cardinalityIntent === undefined) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RELATIONSHIP_CARDINALITY_MISSING,\n `${path}.cardinalityIntent`,\n 'Relationship cardinality intent is required before semantic evaluation.',\n [relationship.relationshipRef],\n );\n }\n if (relationship.ownershipIntent === undefined) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RELATIONSHIP_OWNERSHIP_MISSING,\n `${path}.ownershipIntent`,\n 'Relationship ownership intent is required before semantic evaluation.',\n [relationship.relationshipRef],\n );\n }\n });\n\n issues.sort((left, right) => `${left.code}\\u0000${left.path}\\u0000${left.message}`.localeCompare(`${right.code}\\u0000${right.path}\\u0000${right.message}`));\n return DomainPlanOutputSetValidationResultSchema.parse({\n valid: !issues.some((issue) => issue.severity === DomainPlanValidationIssueSeverity.ERROR),\n issues,\n });\n}\n\nfunction groupIndexes(values: readonly string[]): Map<string, number[]> {\n const grouped = new Map<string, number[]>();\n values.forEach((value, index) => grouped.set(value, [...(grouped.get(value) ?? []), index]));\n return grouped;\n}\n\nfunction addIssue(\n issues: DomainPlanValidationIssue[],\n code: DomainPlanValidationIssueCode,\n path: string,\n message: string,\n relatedRefs: string[],\n): void {\n issues.push({ code, severity: DomainPlanValidationIssueSeverity.ERROR, path, message, relatedRefs });\n}\n"]}
1
+ {"version":3,"file":"domain-plan-output-set-validation.js","sourceRoot":"","sources":["../../../../../src/_core/domain-plan/domain-plan-output-set-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,yBAAyB,EACzB,mCAAmC,EACnC,iCAAiC,EACjC,iDAAiD,EACjD,gDAAgD,GAEjD,MAAM,kCAAkC,CAAC;AAE1C,MAAM,CAAN,IAAY,iCAGX;AAHD,WAAY,iCAAiC;IAC3C,oDAAe,CAAA;IACf,wDAAmB,CAAA;AACrB,CAAC,EAHW,iCAAiC,KAAjC,iCAAiC,QAG5C;AAED,MAAM,CAAN,IAAY,6BAkBX;AAlBD,WAAY,6BAA6B;IACvC,4EAA2C,CAAA;IAC3C,kHAAiF,CAAA;IACjF,4FAA2D,CAAA;IAC3D,0GAAyE,CAAA;IACzE,0FAAyD,CAAA;IACzD,kFAAiD,CAAA;IACjD,sGAAqE,CAAA;IACrE,gHAA+E,CAAA;IAC/E,sGAAqE,CAAA;IACrE,kGAAiE,CAAA;IACjE;;;;;OAKG;IACH,kIAAiG,CAAA;AACnG,CAAC,EAlBW,6BAA6B,KAA7B,6BAA6B,QAkBxC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC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AAoB,CAAC;IAC5C,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7F,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,QAAQ,CACf,MAAmC,EACnC,IAAmC,EACnC,IAAY,EACZ,OAAe,EACf,WAAqB;IAErB,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,iCAAiC,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;AACvG,CAAC","sourcesContent":["import { z } from 'zod';\n\nimport {\n DomainPlanOutputSetSchema,\n DomainRelationshipCardinalityIntent,\n DomainRelationshipOwnershipIntent,\n domainRelationshipOwnershipContradictsCardinality,\n domainRelationshipOwnershipRequiredByCardinality,\n type DomainPlanOutputSet,\n} from './domain-plan-output-set.schemas';\n\nexport enum DomainPlanValidationIssueSeverity {\n ERROR = 'error',\n WARNING = 'warning',\n}\n\nexport enum DomainPlanValidationIssueCode {\n DUPLICATE_MODULE_ID = 'duplicate-module-id',\n DUPLICATE_RESOURCE_IN_MODULE_INVENTORY = 'duplicate-resource-in-module-inventory',\n RESOURCE_WITHOUT_MAIN_OWNER = 'resource-without-main-owner',\n RESOURCE_WITH_MULTIPLE_MAIN_OWNERS = 'resource-with-multiple-main-owners',\n DUPLICATE_RELATIONSHIP_REF = 'duplicate-relationship-ref',\n DUPLICATE_RELATIONSHIP = 'duplicate-relationship',\n RELATIONSHIP_ENDPOINTS_IDENTICAL = 'relationship-endpoints-identical',\n RELATIONSHIP_ENDPOINT_NOT_INVENTORIED = 'relationship-endpoint-not-inventoried',\n RELATIONSHIP_CARDINALITY_MISSING = 'relationship-cardinality-missing',\n RELATIONSHIP_OWNERSHIP_MISSING = 'relationship-ownership-missing',\n /**\n * A one-sided cardinality whose \"one\" end is said to hold the reference — e.g. `one-to-many` with\n * `source-holds-reference`. Read source → target, the many side holds the reference, so the two\n * intents cannot both be true. Refused here rather than left to the semantic judge, which used to\n * catch it as a GAP after the model had already spent its turn.\n */\n RELATIONSHIP_OWNERSHIP_CONTRADICTS_CARDINALITY = 'relationship-ownership-contradicts-cardinality',\n}\n\nexport const DomainPlanValidationIssueSchema = z.object({\n code: z.enum(DomainPlanValidationIssueCode),\n severity: z.enum(DomainPlanValidationIssueSeverity),\n path: z.string().min(1),\n message: z.string().min(1),\n relatedRefs: z.array(z.string().min(1)),\n});\nexport type DomainPlanValidationIssue = z.infer<typeof DomainPlanValidationIssueSchema>;\n\nexport const DomainPlanOutputSetValidationResultSchema = z.object({\n valid: z.boolean(),\n issues: z.array(DomainPlanValidationIssueSchema),\n});\nexport type DomainPlanOutputSetValidationResult = z.infer<typeof DomainPlanOutputSetValidationResultSchema>;\n\n/**\n * Deterministic structural validation before semantic evaluation. It diagnoses\n * a staged payload; it neither accepts family state nor substitutes for the\n * required `domain-plan-coherent` evaluator.\n */\nexport function validateDomainPlanOutputSet(input: DomainPlanOutputSet): DomainPlanOutputSetValidationResult {\n const outputSet = DomainPlanOutputSetSchema.parse(input);\n const issues: DomainPlanValidationIssue[] = [];\n const moduleIndexesById = groupIndexes(outputSet.modules.map((module) => module.relatedModuleId));\n for (const [moduleId, indexes] of moduleIndexesById) {\n for (const duplicateIndex of indexes.slice(1)) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.DUPLICATE_MODULE_ID,\n `modules[${duplicateIndex}].relatedModuleId`,\n `Module id is declared more than once: ${moduleId}`,\n [moduleId],\n );\n }\n }\n\n const mainOwnerIndexesByResource = new Map<string, Set<number>>();\n const inventoriedResources = new Set<string>();\n outputSet.modules.forEach((module, moduleIndex) => {\n const mainResources = new Set<string>();\n const supportingResources = new Set<string>();\n module.mainResources.forEach((resourceRef, resourceIndex) => {\n inventoriedResources.add(resourceRef);\n if (mainResources.has(resourceRef)) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.DUPLICATE_RESOURCE_IN_MODULE_INVENTORY,\n `modules[${moduleIndex}].mainResources[${resourceIndex}]`,\n `Resource is repeated in the module's main inventory: ${resourceRef}`,\n [module.relatedModuleId, resourceRef],\n );\n }\n mainResources.add(resourceRef);\n const owners = mainOwnerIndexesByResource.get(resourceRef) ?? new Set<number>();\n owners.add(moduleIndex);\n mainOwnerIndexesByResource.set(resourceRef, owners);\n });\n module.supportingResources.forEach((resourceRef, resourceIndex) => {\n inventoriedResources.add(resourceRef);\n if (supportingResources.has(resourceRef) || mainResources.has(resourceRef)) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.DUPLICATE_RESOURCE_IN_MODULE_INVENTORY,\n `modules[${moduleIndex}].supportingResources[${resourceIndex}]`,\n `Resource is repeated or occupies both inventory roles in one module: ${resourceRef}`,\n [module.relatedModuleId, resourceRef],\n );\n }\n supportingResources.add(resourceRef);\n });\n });\n\n for (const resourceRef of [...inventoriedResources].sort()) {\n const owners = [...(mainOwnerIndexesByResource.get(resourceRef) ?? new Set<number>())].sort((left, right) => left - right);\n if (owners.length === 0) {\n addIssue(issues, DomainPlanValidationIssueCode.RESOURCE_WITHOUT_MAIN_OWNER, 'modules', `Inventoried resource has no main owning module: ${resourceRef}`, [resourceRef]);\n }\n if (owners.length > 1) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RESOURCE_WITH_MULTIPLE_MAIN_OWNERS,\n `modules[${owners[1]}].mainResources`,\n `Resource has more than one main owning module: ${resourceRef}`,\n [resourceRef, ...owners.map((index) => outputSet.modules[index]!.relatedModuleId)],\n );\n }\n }\n\n const relationshipIndexesByRef = groupIndexes(outputSet.relationships.map((relationship) => relationship.relationshipRef));\n const relationshipIndexesByEndpoints = groupIndexes(\n outputSet.relationships.map((relationship) => [relationship.sourceResourceRef, relationship.targetResourceRef].sort().join('\\u0000')),\n );\n outputSet.relationships.forEach((relationship, relationshipIndex) => {\n const path = `relationships[${relationshipIndex}]`;\n const sameRefIndexes = relationshipIndexesByRef.get(relationship.relationshipRef) ?? [];\n if (sameRefIndexes.length > 1 && sameRefIndexes[0] !== relationshipIndex) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.DUPLICATE_RELATIONSHIP_REF,\n `${path}.relationshipRef`,\n `Relationship ref is declared more than once: ${relationship.relationshipRef}`,\n [relationship.relationshipRef],\n );\n }\n const endpointKey = [relationship.sourceResourceRef, relationship.targetResourceRef].sort().join('\\u0000');\n const sameEndpointIndexes = relationshipIndexesByEndpoints.get(endpointKey) ?? [];\n if (sameEndpointIndexes.length > 1 && sameEndpointIndexes[0] !== relationshipIndex) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.DUPLICATE_RELATIONSHIP,\n path,\n 'The same resource endpoints are related more than once.',\n [relationship.sourceResourceRef, relationship.targetResourceRef],\n );\n }\n if (relationship.sourceResourceRef === relationship.targetResourceRef) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RELATIONSHIP_ENDPOINTS_IDENTICAL,\n path,\n 'A relationship must name two distinct resource endpoints.',\n [relationship.sourceResourceRef],\n );\n }\n for (const [field, resourceRef] of [['sourceResourceRef', relationship.sourceResourceRef], ['targetResourceRef', relationship.targetResourceRef]] as const) {\n if (!inventoriedResources.has(resourceRef)) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RELATIONSHIP_ENDPOINT_NOT_INVENTORIED,\n `${path}.${field}`,\n `Relationship endpoint is absent from the module inventory: ${resourceRef}`,\n [relationship.relationshipRef, resourceRef],\n );\n }\n }\n if (relationship.cardinalityIntent === undefined) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RELATIONSHIP_CARDINALITY_MISSING,\n `${path}.cardinalityIntent`,\n 'Relationship cardinality intent is required before semantic evaluation.',\n [relationship.relationshipRef],\n );\n }\n if (relationship.ownershipIntent === undefined) {\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RELATIONSHIP_OWNERSHIP_MISSING,\n `${path}.ownershipIntent`,\n 'Relationship ownership intent is required before semantic evaluation.',\n [relationship.relationshipRef],\n );\n }\n if (domainRelationshipOwnershipContradictsCardinality(relationship)) {\n // Both are defined here: the predicate is false while either is undecided.\n const required = domainRelationshipOwnershipRequiredByCardinality(relationship.cardinalityIntent!)!;\n const reversed = relationship.cardinalityIntent === DomainRelationshipCardinalityIntent.ONE_TO_MANY\n ? DomainRelationshipCardinalityIntent.MANY_TO_ONE\n : DomainRelationshipCardinalityIntent.ONE_TO_MANY;\n addIssue(\n issues,\n DomainPlanValidationIssueCode.RELATIONSHIP_OWNERSHIP_CONTRADICTS_CARDINALITY,\n `${path}.ownershipIntent`,\n `Relationship \"${relationship.relationshipRef}\" says ${relationship.cardinalityIntent} from ${relationship.sourceResourceRef} (source) to `\n + `${relationship.targetResourceRef} (target) with ${relationship.ownershipIntent}. Cardinality is read source → target, and the \"many\" side `\n + `holds the reference, so ${relationship.cardinalityIntent} requires ${required}. If ${relationship.ownershipIntent === DomainRelationshipOwnershipIntent.SOURCE_HOLDS_REFERENCE ? relationship.sourceResourceRef : relationship.targetResourceRef} `\n + `really holds the reference, the cardinality is ${reversed}.`,\n [relationship.relationshipRef, relationship.sourceResourceRef, relationship.targetResourceRef],\n );\n }\n });\n\n issues.sort((left, right) => `${left.code}\\u0000${left.path}\\u0000${left.message}`.localeCompare(`${right.code}\\u0000${right.path}\\u0000${right.message}`));\n return DomainPlanOutputSetValidationResultSchema.parse({\n valid: !issues.some((issue) => issue.severity === DomainPlanValidationIssueSeverity.ERROR),\n issues,\n });\n}\n\nfunction groupIndexes(values: readonly string[]): Map<string, number[]> {\n const grouped = new Map<string, number[]>();\n values.forEach((value, index) => grouped.set(value, [...(grouped.get(value) ?? []), index]));\n return grouped;\n}\n\nfunction addIssue(\n issues: DomainPlanValidationIssue[],\n code: DomainPlanValidationIssueCode,\n path: string,\n message: string,\n relatedRefs: string[],\n): void {\n issues.push({ code, severity: DomainPlanValidationIssueSeverity.ERROR, path, message, relatedRefs });\n}\n"]}
@@ -2,20 +2,78 @@ import { z } from 'zod';
2
2
  import '@wildo-ai/zod-decorators';
3
3
  /** Portable semantic schema claimed by a staged domain-plan candidate. */
4
4
  export declare const DOMAIN_PLAN_OUTPUT_SET_SCHEMA_REF = "wildo:domain-plan-output-set:v1";
5
- /** Closed conceptual cardinality carried by a planning relationship draft. */
5
+ /**
6
+ * Closed conceptual cardinality carried by a planning relationship draft, ALWAYS READ FROM SOURCE TO
7
+ * TARGET: `<how many sources>-to-<how many targets>`, as in "many customers to one country context".
8
+ *
9
+ * ## Why `MANY_TO_ONE` exists (2026-10-01)
10
+ *
11
+ * The vocabulary used to stop at `ONE_TO_MANY`, and it named no reading direction. The ordinary
12
+ * foreign-key edge — "each customer belongs to one country context", the customer holding the
13
+ * reference — is many-to-one read from the reference holder, and it could not be said. Every model
14
+ * labelled it `ONE_TO_MANY` (the only label with "many" in it that is not many-to-many), and a judge
15
+ * reading the label source → target then called it a contradiction of its own rationale. The first
16
+ * real run that met it (app-creation-test-004) had three such edges; Wonder CRM's committed plan had
17
+ * ten, and so did the framework's own test fixture, which is why nobody noticed: the label had been
18
+ * wrong in the same direction everywhere it was written.
19
+ *
20
+ * ## Rejected: two per-end multiplicity fields
21
+ *
22
+ * `sourceMultiplicity` / `targetMultiplicity` (`one | many`) were considered, and rejected on the
23
+ * reason the defect existed: "the source's multiplicity" is itself readable both ways (UML writes a
24
+ * multiplicity at the end it CONSTRAINS, which is the opposite end from the one it describes). The
25
+ * pair label with a stated direction is what modellers, ORMs (`@ManyToOne`) and ERD tools already say,
26
+ * and the direction is now stated here, in the generation brief, and in the judge's criterion.
27
+ *
28
+ * The cardinality and {@link DomainRelationshipOwnershipIntent} are not independent for the two
29
+ * one-sided members: the "many" side of a one-to-many association is the side that holds the
30
+ * reference. {@link domainRelationshipOwnershipContradictsCardinality} is that rule, and the family
31
+ * validator refuses a draft that breaks it.
32
+ */
6
33
  export declare enum DomainRelationshipCardinalityIntent {
34
+ /** Each source relates to at most one target, and each target to at most one source. Either end may hold the reference. */
7
35
  ONE_TO_ONE = "one-to-one",
36
+ /**
37
+ * One source relates to MANY targets; each target belongs to one source ("a project has many tasks",
38
+ * project → task). The TARGET holds the reference, so this pairs only with `TARGET_HOLDS_REFERENCE`.
39
+ */
8
40
  ONE_TO_MANY = "one-to-many",
41
+ /**
42
+ * MANY sources relate to one target; each source belongs to one target ("each task belongs to one
43
+ * project", task → project). The SOURCE holds the reference, so this pairs only with
44
+ * `SOURCE_HOLDS_REFERENCE`. The ordinary foreign-key edge, read from the resource carrying the key.
45
+ */
46
+ MANY_TO_ONE = "many-to-one",
47
+ /** Each source relates to many targets and each target to many sources. Either end may own the association. */
9
48
  MANY_TO_MANY = "many-to-many"
10
49
  }
11
50
  /**
12
- * Conceptual ownership direction only. This does not choose a physical foreign
13
- * key, junction table, discriminator, or persistence implementation.
51
+ * Conceptual ownership direction only: which END of the draft holds the reference. This does not
52
+ * choose a physical foreign key, junction table, discriminator, or persistence implementation.
53
+ *
54
+ * Fixed by the cardinality for the two one-sided cardinalities (see
55
+ * {@link DomainRelationshipCardinalityIntent}); a genuine choice only for one-to-one and many-to-many.
14
56
  */
15
57
  export declare enum DomainRelationshipOwnershipIntent {
16
58
  SOURCE_HOLDS_REFERENCE = "source-holds-reference",
17
59
  TARGET_HOLDS_REFERENCE = "target-holds-reference"
18
60
  }
61
+ /**
62
+ * The ownership a cardinality REQUIRES, or `undefined` when either end may hold the reference.
63
+ *
64
+ * Total over the cardinality vocabulary (the `switch` has no default), so a member added tomorrow is a
65
+ * compile error here rather than a silently unconstrained label.
66
+ */
67
+ export declare function domainRelationshipOwnershipRequiredByCardinality(cardinality: DomainRelationshipCardinalityIntent): DomainRelationshipOwnershipIntent | undefined;
68
+ /**
69
+ * True when a draft states both intents and they cannot both be true: a one-sided cardinality whose
70
+ * "one" end is said to hold the reference. Undecided intents are not a contradiction — they are
71
+ * reported as missing by the validator, separately.
72
+ */
73
+ export declare function domainRelationshipOwnershipContradictsCardinality(draft: {
74
+ readonly cardinalityIntent?: DomainRelationshipCardinalityIntent | undefined;
75
+ readonly ownershipIntent?: DomainRelationshipOwnershipIntent | undefined;
76
+ }): boolean;
19
77
  /**
20
78
  * Persistable relationship intent. Cardinality and ownership remain optional
21
79
  * here so an imperfect draft can be staged and diagnosed without being
@@ -1 +1 @@
1
- {"version":3,"file":"domain-plan-output-set.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/_core/domain-plan/domain-plan-output-set.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,0BAA0B,CAAC;AAMlC,0EAA0E;AAC1E,eAAO,MAAM,iCAAiC,oCAAoC,CAAC;AAEnF,8EAA8E;AAC9E,oBAAY,mCAAmC;IAC7C,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;CAC9B;AAED;;;GAGG;AACH,oBAAY,iCAAiC;IAC3C,sBAAsB,2BAA2B;IACjD,sBAAsB,2BAA2B;CAClD;AAED;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;;;;;iBAOxC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,oBAAY,sBAAsB;IAChC;;;OAGG;IACH,aAAa,kBAAkB;IAC/B,mFAAmF;IACnF,KAAK,UAAU;CAChB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;iBAiBpC,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
1
+ {"version":3,"file":"domain-plan-output-set.schemas.d.ts","sourceRoot":"","sources":["../../../../../src/_core/domain-plan/domain-plan-output-set.schemas.ts"],"names":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