@hyperscale0/udl 2.6.1 → 3.0.0

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 (213) hide show
  1. package/CHANGELOG.md +2 -330
  2. package/LICENSING.md +1 -2
  3. package/README.md +3 -114
  4. package/TRADEMARKS.md +2 -2
  5. package/dist/diagnostics.d.ts +21 -201
  6. package/dist/diagnostics.d.ts.map +1 -1
  7. package/dist/diagnostics.js +29 -193
  8. package/dist/diagnostics.js.map +1 -1
  9. package/dist/evolution.d.ts +3 -132
  10. package/dist/evolution.d.ts.map +1 -1
  11. package/dist/evolution.js +29 -633
  12. package/dist/evolution.js.map +1 -1
  13. package/dist/finance.d.ts +5 -72
  14. package/dist/finance.d.ts.map +1 -1
  15. package/dist/finance.js +233 -737
  16. package/dist/finance.js.map +1 -1
  17. package/dist/index.d.ts +7 -18
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +7 -12
  20. package/dist/index.js.map +1 -1
  21. package/dist/instrument-references.d.ts.map +1 -1
  22. package/dist/instrument-references.js +3 -2
  23. package/dist/instrument-references.js.map +1 -1
  24. package/dist/schema.d.ts +2079 -4564
  25. package/dist/schema.d.ts.map +1 -1
  26. package/dist/schema.js +270 -1609
  27. package/dist/schema.js.map +1 -1
  28. package/dist/validation.d.ts +8 -104
  29. package/dist/validation.d.ts.map +1 -1
  30. package/dist/validation.js +653 -3271
  31. package/dist/validation.js.map +1 -1
  32. package/docs/README.md +147 -14
  33. package/package.json +7 -11
  34. package/spec/README.md +151 -164
  35. package/spec/darb.udl.json +249 -0
  36. package/spec/udl.schema.json +4104 -3202
  37. package/src/diagnostics.ts +51 -246
  38. package/src/evolution.ts +39 -1045
  39. package/src/finance.ts +287 -1127
  40. package/src/index.ts +18 -142
  41. package/src/instrument-references.ts +3 -2
  42. package/src/schema.ts +285 -1843
  43. package/src/validation.ts +870 -5611
  44. package/conformance/README.md +0 -82
  45. package/conformance/evolution/action-contract.expected.json +0 -10
  46. package/conformance/evolution/action-contract.live.udl +0 -44
  47. package/conformance/evolution/action-contract.next.udl +0 -45
  48. package/conformance/evolution/product-identity.expected.json +0 -10
  49. package/conformance/evolution/product-identity.live.udl +0 -55
  50. package/conformance/evolution/product-identity.next.udl +0 -55
  51. package/conformance/evolution/version-required.expected.json +0 -10
  52. package/conformance/evolution/version-required.live.udl +0 -55
  53. package/conformance/evolution/version-required.next.udl +0 -58
  54. package/conformance/invalid/action-without-transition.expected.json +0 -10
  55. package/conformance/invalid/action-without-transition.udl +0 -60
  56. package/conformance/invalid/agent-description-too-long.expected.json +0 -10
  57. package/conformance/invalid/agent-description-too-long.udl +0 -57
  58. package/conformance/invalid/blank-title.expected.json +0 -10
  59. package/conformance/invalid/blank-title.udl +0 -54
  60. package/conformance/invalid/call-binds-results.expected.json +0 -10
  61. package/conformance/invalid/call-binds-results.udl +0 -314
  62. package/conformance/invalid/call-unknown-action.expected.json +0 -10
  63. package/conformance/invalid/call-unknown-action.udl +0 -314
  64. package/conformance/invalid/composition-dial-duplicate-key.expected.json +0 -10
  65. package/conformance/invalid/composition-dial-duplicate-key.udl +0 -73
  66. package/conformance/invalid/depth-budget.expected.json +0 -10
  67. package/conformance/invalid/depth-budget.udl +0 -49
  68. package/conformance/invalid/duplicate-subject.expected.json +0 -10
  69. package/conformance/invalid/duplicate-subject.udl +0 -230
  70. package/conformance/invalid/forged-effects.expected.json +0 -10
  71. package/conformance/invalid/forged-effects.udl +0 -76
  72. package/conformance/invalid/format-version.expected.json +0 -10
  73. package/conformance/invalid/format-version.udl +0 -54
  74. package/conformance/invalid/instrument-id-not-snake-case.expected.json +0 -10
  75. package/conformance/invalid/instrument-id-not-snake-case.udl +0 -54
  76. package/conformance/invalid/invalid-aggregate-gate-shape.expected.json +0 -10
  77. package/conformance/invalid/invalid-aggregate-gate-shape.udl +0 -1819
  78. package/conformance/invalid/invalid-check-duration.expected.json +0 -10
  79. package/conformance/invalid/invalid-check-duration.udl +0 -219
  80. package/conformance/invalid/invalid-dial-anchor.expected.json +0 -10
  81. package/conformance/invalid/invalid-dial-anchor.udl +0 -219
  82. package/conformance/invalid/invalid-exception-parent-ref.expected.json +0 -10
  83. package/conformance/invalid/invalid-exception-parent-ref.udl +0 -2487
  84. package/conformance/invalid/invalid-exposure-shape.expected.json +0 -10
  85. package/conformance/invalid/invalid-exposure-shape.udl +0 -1819
  86. package/conformance/invalid/invalid-journeys.expected.json +0 -10
  87. package/conformance/invalid/invalid-journeys.udl +0 -77
  88. package/conformance/invalid/invalid-remainder.expected.json +0 -10
  89. package/conformance/invalid/invalid-remainder.udl +0 -220
  90. package/conformance/invalid/invalid-schema-keyword.expected.json +0 -10
  91. package/conformance/invalid/invalid-schema-keyword.udl +0 -220
  92. package/conformance/invalid/invalid-utf8.expected.json +0 -10
  93. package/conformance/invalid/invalid-utf8.udl +0 -1
  94. package/conformance/invalid/leaf-effect-mismatch.expected.json +0 -10
  95. package/conformance/invalid/leaf-effect-mismatch.udl +0 -314
  96. package/conformance/invalid/malformed-json.expected.json +0 -10
  97. package/conformance/invalid/malformed-json.udl +0 -1
  98. package/conformance/invalid/missing-create-action.expected.json +0 -10
  99. package/conformance/invalid/missing-create-action.udl +0 -48
  100. package/conformance/invalid/missing-exception-amount-field.expected.json +0 -10
  101. package/conformance/invalid/missing-exception-amount-field.udl +0 -2487
  102. package/conformance/invalid/missing-exception-contract.expected.json +0 -14
  103. package/conformance/invalid/missing-exception-contract.udl +0 -2523
  104. package/conformance/invalid/missing-exception-reason-field.expected.json +0 -10
  105. package/conformance/invalid/missing-exception-reason-field.udl +0 -2487
  106. package/conformance/invalid/not-an-object.expected.json +0 -10
  107. package/conformance/invalid/not-an-object.udl +0 -1
  108. package/conformance/invalid/payout-reconcile-not-a-bank-debit.expected.json +0 -10
  109. package/conformance/invalid/payout-reconcile-not-a-bank-debit.udl +0 -259
  110. package/conformance/invalid/piece-plan-without-partition.expected.json +0 -10
  111. package/conformance/invalid/piece-plan-without-partition.udl +0 -305
  112. package/conformance/invalid/private-action-independent-approval.expected.json +0 -10
  113. package/conformance/invalid/private-action-independent-approval.udl +0 -314
  114. package/conformance/invalid/quote-freeze-set-incomplete.expected.json +0 -10
  115. package/conformance/invalid/quote-freeze-set-incomplete.udl +0 -261
  116. package/conformance/invalid/quote-named-reference-gate.expected.json +0 -10
  117. package/conformance/invalid/quote-named-reference-gate.udl +0 -50
  118. package/conformance/invalid/reconcile-named-reference-gate.expected.json +0 -10
  119. package/conformance/invalid/reconcile-named-reference-gate.udl +0 -50
  120. package/conformance/invalid/unfund-order-not-reversed.expected.json +0 -10
  121. package/conformance/invalid/unfund-order-not-reversed.udl +0 -314
  122. package/conformance/invalid/unknown-key.expected.json +0 -10
  123. package/conformance/invalid/unknown-key.udl +0 -55
  124. package/conformance/invalid/unknown-reference-gate-field.expected.json +0 -10
  125. package/conformance/invalid/unknown-reference-gate-field.udl +0 -1819
  126. package/conformance/invalid/unknown-required-field.expected.json +0 -10
  127. package/conformance/invalid/unknown-required-field.udl +0 -220
  128. package/conformance/invalid/unreachable-state.expected.json +0 -10
  129. package/conformance/invalid/unreachable-state.udl +0 -55
  130. package/conformance/invalid/wrong-exception-amount-field.expected.json +0 -10
  131. package/conformance/invalid/wrong-exception-amount-field.udl +0 -2487
  132. package/conformance/invalid/wrong-exception-reason-field.expected.json +0 -10
  133. package/conformance/invalid/wrong-exception-reason-field.udl +0 -2487
  134. package/conformance/valid/agent-description.expected.json +0 -6
  135. package/conformance/valid/agent-description.udl +0 -66
  136. package/conformance/valid/attested.expected.json +0 -6
  137. package/conformance/valid/attested.udl +0 -251
  138. package/conformance/valid/cards.expected.json +0 -6
  139. package/conformance/valid/cards.udl +0 -1579
  140. package/conformance/valid/commerce-escrow.expected.json +0 -6
  141. package/conformance/valid/commerce-escrow.udl +0 -1512
  142. package/conformance/valid/compiled-crowdfunding.expected.json +0 -6
  143. package/conformance/valid/compiled-crowdfunding.udl +0 -1843
  144. package/conformance/valid/compiled-watch-club.expected.json +0 -6
  145. package/conformance/valid/compiled-watch-club.udl +0 -2486
  146. package/conformance/valid/complete-contract.expected.json +0 -6
  147. package/conformance/valid/complete-contract.udl +0 -218
  148. package/conformance/valid/effect-signatures.expected.json +0 -6
  149. package/conformance/valid/effect-signatures.udl +0 -75
  150. package/conformance/valid/hand-edited.expected.json +0 -6
  151. package/conformance/valid/hand-edited.udl +0 -1
  152. package/conformance/valid/insured-car-marketplace.expected.json +0 -6
  153. package/conformance/valid/insured-car-marketplace.udl +0 -1050
  154. package/conformance/valid/insured-travel.expected.json +0 -6
  155. package/conformance/valid/insured-travel.udl +0 -3469
  156. package/conformance/valid/minimal.expected.json +0 -6
  157. package/conformance/valid/minimal.udl +0 -62
  158. package/conformance/valid/piece-plan-calls.expected.json +0 -6
  159. package/conformance/valid/piece-plan-calls.udl +0 -314
  160. package/conformance/valid/protection.expected.json +0 -6
  161. package/conformance/valid/protection.udl +0 -1551
  162. package/conformance/valid/string-escaping.expected.json +0 -6
  163. package/conformance/valid/string-escaping.udl +0 -54
  164. package/conformance/valid/vocabulary.expected.json +0 -6
  165. package/conformance/valid/vocabulary.udl +0 -2012
  166. package/dist/allocation.d.ts +0 -60
  167. package/dist/allocation.d.ts.map +0 -1
  168. package/dist/allocation.js +0 -177
  169. package/dist/allocation.js.map +0 -1
  170. package/dist/check-profiles.d.ts +0 -57
  171. package/dist/check-profiles.d.ts.map +0 -1
  172. package/dist/check-profiles.js +0 -62
  173. package/dist/check-profiles.js.map +0 -1
  174. package/dist/distribution.d.ts +0 -15
  175. package/dist/distribution.d.ts.map +0 -1
  176. package/dist/distribution.js +0 -49
  177. package/dist/distribution.js.map +0 -1
  178. package/dist/effects.d.ts +0 -58
  179. package/dist/effects.d.ts.map +0 -1
  180. package/dist/effects.js +0 -1126
  181. package/dist/effects.js.map +0 -1
  182. package/dist/reference.d.ts +0 -3
  183. package/dist/reference.d.ts.map +0 -1
  184. package/dist/reference.js +0 -28
  185. package/dist/reference.js.map +0 -1
  186. package/dist/vocabulary.d.ts +0 -23
  187. package/dist/vocabulary.d.ts.map +0 -1
  188. package/dist/vocabulary.js +0 -1052
  189. package/dist/vocabulary.js.map +0 -1
  190. package/docs/funding-custody.md +0 -165
  191. package/docs/guide/01-a-document.md +0 -37
  192. package/docs/guide/02-money-steps.md +0 -23
  193. package/docs/guide/03-laws.md +0 -18
  194. package/docs/guide/04-fees-and-remainder.md +0 -36
  195. package/docs/guide/05-checks-updates-dials.md +0 -7
  196. package/docs/guide/06-effects.md +0 -11
  197. package/docs/guide/07-evolution.md +0 -11
  198. package/docs/guide/08-implementing.md +0 -13
  199. package/docs/guide/09-schedules-and-allocation.md +0 -132
  200. package/docs/llms-full.txt +0 -2008
  201. package/docs/llms.txt +0 -14
  202. package/docs/piece-plans.md +0 -148
  203. package/docs/reference/canonical.md +0 -16
  204. package/docs/reference/clauses.md +0 -1585
  205. package/docs/reference/cli.md +0 -24
  206. package/docs/reference/diagnostics.md +0 -38
  207. package/skills/udl/SKILL.md +0 -28
  208. package/src/allocation.ts +0 -259
  209. package/src/check-profiles.ts +0 -80
  210. package/src/distribution.ts +0 -61
  211. package/src/effects.ts +0 -1920
  212. package/src/reference.ts +0 -31
  213. package/src/vocabulary.ts +0 -1635
@@ -1,257 +1,62 @@
1
- export type UdlIssueCategory =
2
- | "invalid_evolution"
3
- | "invalid_json"
4
- | "invalid_semantics"
5
- | "invalid_shape"
6
- | "invalid_utf8"
7
- | "resource_limit";
8
-
9
- export type UdlDiagnosticFamily =
10
- | "admission"
11
- | "document"
12
- | "evolution"
13
- | "finance"
14
- | "gates"
15
- | "lifecycle"
16
- | "schema";
17
-
18
- const diagnosticDefinitions = {
19
- UDL1001: {
20
- category: "invalid_utf8",
21
- family: "admission",
22
- title: "Invalid UTF-8",
23
- fix: "Encode the document as valid UTF-8.",
24
- },
25
- UDL1002: {
26
- category: "invalid_json",
27
- family: "admission",
28
- title: "Invalid JSON",
29
- fix: "Repair the JSON syntax before validation.",
30
- },
31
- UDL1003: {
32
- category: "invalid_shape",
33
- family: "admission",
34
- title: "Invalid document shape",
35
- fix: "Match the published UDL JSON Schema.",
36
- },
37
- UDL1004: {
38
- category: "resource_limit",
39
- family: "admission",
40
- title: "Resource limit exceeded",
41
- fix: "Reduce the source size, nesting, values, strings, references, or financial paths named by the message.",
42
- },
43
-
44
- UDL2001: {
45
- category: "invalid_semantics",
46
- family: "document",
47
- title: "Duplicate declaration",
48
- fix: "Give each declaration a unique name.",
49
- },
50
- UDL2002: {
51
- category: "invalid_semantics",
52
- family: "document",
53
- title: "Document law violation",
54
- fix: "Repair the declaration, subject contract, or derived effects named by the message.",
55
- },
56
- UDL2005: {
57
- category: "invalid_semantics",
58
- family: "document",
59
- title: "Derived effects mismatch",
60
- fix: "Regenerate the action effects from its clauses.",
61
- },
62
- UDL2010: {
63
- category: "invalid_semantics",
64
- family: "document",
65
- title: "Action graph violation",
66
- fix: "Order all actions and calls without cycles or collisions, within depth and count limits.",
67
- },
68
- UDL2011: {
69
- category: "invalid_semantics",
70
- family: "document",
71
- title: "Action binding violation",
72
- fix: "Bind parameters to declared instance, piece, or caller variables without forward references or duplicate captures.",
73
- },
74
- UDL2012: {
75
- category: "invalid_semantics",
76
- family: "document",
77
- title: "Action authority violation",
78
- fix: "Match principal, approval, and recovery policies and keep field paths within tenant boundary.",
79
- },
80
- UDL2013: {
81
- category: "invalid_semantics",
82
- family: "document",
83
- title: "Action effect or evidence violation",
84
- fix: "Provide valid effect kind, matching effect signature, and non-empty evidence for every leaf.",
85
- },
86
-
87
- UDL3001: {
88
- category: "invalid_semantics",
89
- family: "lifecycle",
90
- title: "Lifecycle is not closed",
91
- fix: "Declare every state and action transition, and make every state reachable.",
92
- },
93
-
94
- UDL4001: {
95
- category: "invalid_semantics",
96
- family: "finance",
97
- title: "Money graph violation",
98
- fix: "Balance every funded amount and close every hold on each lifecycle path.",
99
- },
100
- UDL4002: {
101
- category: "invalid_semantics",
102
- family: "finance",
103
- title: "Piece partition violation",
104
- fix: "Match piece plan total, amounts, and payees to required immutable fields and declared partition.",
105
- },
106
-
107
- UDL5001: {
108
- category: "invalid_semantics",
109
- family: "gates",
110
- title: "Reference gate violation",
111
- fix: "Point the gate at a declared instrument, action, state, field, and reference.",
112
- },
113
- UDL5002: {
114
- category: "invalid_semantics",
115
- family: "gates",
116
- title: "Check requirement violation",
117
- fix: "Use a declared check with compatible evidence and recurrence.",
118
- },
119
- UDL5003: {
120
- category: "invalid_semantics",
121
- family: "gates",
122
- title: "Exposure gate violation",
123
- fix: "Use declared account and money fields for the exposure gate.",
124
- },
125
- UDL5004: {
126
- category: "invalid_semantics",
127
- family: "gates",
128
- title: "Aggregate law violation",
129
- fix: "Point the aggregate at compatible parent and child fields.",
130
- },
131
- UDL5005: {
132
- category: "invalid_semantics",
133
- family: "gates",
134
- title: "Settlement or payout violation",
135
- fix: "Use a declared settlement account and a compatible payout statement line.",
136
- },
137
- UDL5006: {
138
- category: "invalid_semantics",
139
- family: "gates",
140
- title: "Quote and commit violation",
141
- fix: "Declare one complete quote freeze set and one matching commit action.",
142
- },
143
- UDL5007: {
144
- category: "invalid_semantics",
145
- family: "gates",
146
- title: "Reconcile exception child violation",
147
- fix: "Name a declared child whose reference points back to this instrument.",
148
- },
149
- UDL5008: {
150
- category: "invalid_semantics",
151
- family: "gates",
152
- title: "Action clause violation",
153
- fix: "Repair the clause fields and keep incompatible clauses separate.",
154
- },
155
- UDL5009: {
156
- category: "invalid_semantics",
157
- family: "gates",
158
- title: "Reconcile exception amount field is missing or optional",
159
- fix: "Name the exception child's required money field in amountField.",
160
- },
161
- UDL5010: {
162
- category: "invalid_semantics",
163
- family: "gates",
164
- title: "Reconcile exception amount field has the wrong type",
165
- fix: "Point amountField at a money field declared by the exception child.",
166
- },
167
- UDL5011: {
168
- category: "invalid_semantics",
169
- family: "gates",
170
- title: "Reconcile exception reason field is missing or optional",
171
- fix: "Name the exception child's required text field in reasonField.",
172
- },
173
- UDL5012: {
174
- category: "invalid_semantics",
175
- family: "gates",
176
- title: "Reconcile exception reason field has the wrong type",
177
- fix: "Point reasonField at a required plain text field declared by the exception child.",
178
- },
179
- UDL5013: {
180
- category: "invalid_semantics",
181
- family: "gates",
182
- title: "Piece stage violation",
183
- fix: "Reference a declared piece plan and stage in the containing instrument.",
184
- },
185
-
186
- UDL6001: {
187
- category: "invalid_semantics",
188
- family: "schema",
189
- title: "Unsupported JSON Schema",
190
- fix: "Use only the sealed UDL JSON Schema subset.",
191
- },
192
-
193
- UDL7001: {
194
- category: "invalid_evolution",
195
- family: "evolution",
196
- title: "Stored contract changed",
197
- fix: "Keep stored identities and contracts unchanged, and add only allowed optional declarations.",
198
- },
199
- UDL7002: {
200
- category: "invalid_evolution",
201
- family: "evolution",
202
- title: "Version was not increased",
203
- fix: "Increase the product version for every semantic change.",
204
- },
205
- } as const satisfies Record<
206
- string,
207
- {
208
- readonly category: UdlIssueCategory;
209
- readonly family: UdlDiagnosticFamily;
210
- readonly fix: string;
211
- readonly title: string;
212
- }
213
- >;
214
-
215
- export type UdlIssueCode = keyof typeof diagnosticDefinitions;
216
-
217
- export interface UdlDiagnostic {
218
- readonly category: UdlIssueCategory;
219
- readonly code: UdlIssueCode;
220
- readonly family: UdlDiagnosticFamily;
221
- readonly fix: string;
222
- readonly title: string;
223
- }
224
-
225
- export const udlDiagnostics: readonly UdlDiagnostic[] = Object.entries(
226
- diagnosticDefinitions,
227
- ).map(([code, diagnostic]) => ({
228
- code: code as UdlIssueCode,
229
- ...diagnostic,
230
- }));
231
-
232
- export function udlDiagnostic(code: string): UdlDiagnostic | undefined {
233
- return udlDiagnostics.find((diagnostic) => diagnostic.code === code);
234
- }
235
-
1
+ export type UdlIssueCode =
2
+ | "UDL1001"
3
+ | "UDL1002"
4
+ | "UDL1003"
5
+ | "UDL1004"
6
+ | "UDL2001"
7
+ | "UDL2002"
8
+ | "UDL2010"
9
+ | "UDL3001"
10
+ | "UDL4001"
11
+ | "UDL5001"
12
+ | "UDL7001"
13
+ | "UDL7002";
236
14
  export interface UdlIssue {
237
- readonly category: UdlIssueCategory;
238
- readonly code: UdlIssueCode;
239
- readonly fix: string;
240
- readonly message: string;
241
- readonly path: string;
15
+ code: UdlIssueCode;
16
+ path: string;
17
+ message: string;
18
+ fix: string;
19
+ category: string;
242
20
  }
243
-
21
+ const fixes: Record<UdlIssueCode, string> = {
22
+ UDL1001: "Encode the source as UTF-8.",
23
+ UDL1002: "Repair JSON syntax.",
24
+ UDL1003: "Use the UDL 3 typed grammar.",
25
+ UDL1004: "Reduce the declared structure or expansion.",
26
+ UDL2001: "Give each declaration a distinct name.",
27
+ UDL2002: "Repair the named type or declaration.",
28
+ UDL2010: "Remove the invocation cycle or reduce its expansion.",
29
+ UDL3001: "Declare reachable states and one transition per action.",
30
+ UDL4001:
31
+ "Fund owned accounts before spending and close them with zero balances.",
32
+ UDL5001: "Use a declared reference of the required type.",
33
+ UDL7001: "Preserve existing instance meaning or recreate the estate.",
34
+ UDL7002: "Increase the contract version.",
35
+ };
244
36
  export function issue(
245
37
  code: UdlIssueCode,
246
38
  path: string,
247
- messageDetail?: string,
39
+ message: string,
248
40
  ): UdlIssue {
249
- const diagnostic = diagnosticDefinitions[code];
250
41
  return {
251
- category: diagnostic.category,
252
42
  code,
253
- fix: diagnostic.fix,
254
- message: messageDetail ?? diagnostic.title,
255
43
  path,
44
+ message,
45
+ fix: fixes[code],
46
+ category:
47
+ code === "UDL1003"
48
+ ? "invalid_shape"
49
+ : code === "UDL1004"
50
+ ? "resource_limit"
51
+ : "invalid_semantics",
256
52
  };
257
53
  }
54
+ export const udlDiagnostics = Object.entries(fixes).map(([code, fix]) => ({
55
+ code,
56
+ fix,
57
+ title: fix,
58
+ category: "invalid_semantics",
59
+ family: "document",
60
+ }));
61
+ export const udlDiagnostic = (code: string) =>
62
+ udlDiagnostics.find((d) => d.code === code);