@hyperscale0/udl 2.0.3 → 2.1.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 (58) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +15 -1
  3. package/conformance/invalid/call-binds-results.expected.json +10 -0
  4. package/conformance/invalid/call-binds-results.udl +314 -0
  5. package/conformance/invalid/call-unknown-action.expected.json +10 -0
  6. package/conformance/invalid/call-unknown-action.udl +314 -0
  7. package/conformance/invalid/leaf-effect-mismatch.expected.json +10 -0
  8. package/conformance/invalid/leaf-effect-mismatch.udl +314 -0
  9. package/conformance/invalid/piece-plan-without-partition.expected.json +10 -0
  10. package/conformance/invalid/piece-plan-without-partition.udl +305 -0
  11. package/conformance/invalid/private-action-independent-approval.expected.json +10 -0
  12. package/conformance/invalid/private-action-independent-approval.udl +314 -0
  13. package/conformance/invalid/unfund-order-not-reversed.expected.json +10 -0
  14. package/conformance/invalid/unfund-order-not-reversed.udl +314 -0
  15. package/conformance/valid/piece-plan-calls.expected.json +6 -0
  16. package/conformance/valid/piece-plan-calls.udl +314 -0
  17. package/dist/diagnostics.d.ts +36 -0
  18. package/dist/diagnostics.d.ts.map +1 -1
  19. package/dist/diagnostics.js +36 -0
  20. package/dist/diagnostics.js.map +1 -1
  21. package/dist/effects.d.ts +24 -3
  22. package/dist/effects.d.ts.map +1 -1
  23. package/dist/effects.js +906 -8
  24. package/dist/effects.js.map +1 -1
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/limits.d.ts +2 -0
  30. package/dist/limits.d.ts.map +1 -1
  31. package/dist/limits.js +2 -0
  32. package/dist/limits.js.map +1 -1
  33. package/dist/schema.d.ts +594 -11
  34. package/dist/schema.d.ts.map +1 -1
  35. package/dist/schema.js +111 -1
  36. package/dist/schema.js.map +1 -1
  37. package/dist/validation.d.ts.map +1 -1
  38. package/dist/validation.js +289 -4
  39. package/dist/validation.js.map +1 -1
  40. package/docs/assets/brand/manifest.json +30 -0
  41. package/docs/assets/brand/udl-horizontal-white.svg +1 -0
  42. package/docs/assets/brand/udl-horizontal.svg +1 -0
  43. package/docs/assets/brand/udl-stacked-white.svg +1 -0
  44. package/docs/assets/brand/udl-stacked.svg +1 -0
  45. package/docs/assets/udl.svg +7 -14
  46. package/docs/llms-full.txt +199 -32
  47. package/docs/llms.txt +1 -1
  48. package/docs/reference/clauses.md +162 -1
  49. package/docs/reference/cli.md +1 -1
  50. package/docs/reference/diagnostics.md +38 -32
  51. package/package.json +2 -2
  52. package/spec/udl.schema.json +321 -1
  53. package/src/diagnostics.ts +36 -0
  54. package/src/effects.ts +1603 -9
  55. package/src/index.ts +15 -0
  56. package/src/limits.ts +2 -0
  57. package/src/schema.ts +149 -2
  58. package/src/validation.ts +469 -4
@@ -0,0 +1,314 @@
1
+ {
2
+ "instruments": [
3
+ {
4
+ "actionOrder": [
5
+ "create",
6
+ "fund_piece",
7
+ "payout_piece"
8
+ ],
9
+ "actions": {
10
+ "create": {
11
+ "moves": [],
12
+ "steps": [],
13
+ "summary": "Create watch instrument"
14
+ },
15
+ "fund_piece": {
16
+ "calls": [
17
+ {
18
+ "action": "transfers.execute_fund",
19
+ "bind": {
20
+ "inst": "$instance",
21
+ "p": "$piece"
22
+ },
23
+ "id": "call_fund"
24
+ }
25
+ ],
26
+ "effects": {
27
+ "moves": [
28
+ {
29
+ "signature": "moves.transfer.internal",
30
+ "source": "fund_piece.call_fund.leaf_fund"
31
+ }
32
+ ]
33
+ },
34
+ "input": {
35
+ "additionalProperties": false,
36
+ "properties": {
37
+ "pieceId": {
38
+ "enum": [
39
+ "p1",
40
+ "p2"
41
+ ],
42
+ "type": "string"
43
+ }
44
+ },
45
+ "required": [
46
+ "pieceId"
47
+ ],
48
+ "type": "object"
49
+ },
50
+ "moves": [],
51
+ "pieceStage": {
52
+ "plan": "split_plan",
53
+ "stage": "fund"
54
+ },
55
+ "steps": [],
56
+ "summary": "Fund one piece in stage"
57
+ },
58
+ "payout_piece": {
59
+ "calls": [
60
+ {
61
+ "action": "transfers.execute_release",
62
+ "bind": {
63
+ "inst": "$instance",
64
+ "p": "$piece"
65
+ },
66
+ "id": "call_rel"
67
+ }
68
+ ],
69
+ "effects": {
70
+ "moves": [
71
+ {
72
+ "signature": "moves.transfer.internal",
73
+ "source": "payout_piece.call_rel.leaf_rel"
74
+ }
75
+ ]
76
+ },
77
+ "input": {
78
+ "additionalProperties": false,
79
+ "properties": {
80
+ "pieceId": {
81
+ "enum": [
82
+ "p1",
83
+ "p2"
84
+ ],
85
+ "type": "string"
86
+ }
87
+ },
88
+ "required": [
89
+ "pieceId"
90
+ ],
91
+ "type": "object"
92
+ },
93
+ "moves": [],
94
+ "pieceStage": {
95
+ "plan": "split_plan",
96
+ "stage": "release"
97
+ },
98
+ "steps": [],
99
+ "summary": "Release piece"
100
+ }
101
+ },
102
+ "actionLibrary": {
103
+ "transfers": {
104
+ "actionOrder": [
105
+ "execute_fund",
106
+ "execute_release"
107
+ ],
108
+ "actions": {
109
+ "execute_fund": {
110
+ "approval": "inherit",
111
+ "calls": [],
112
+ "leaves": [
113
+ {
114
+ "bind": {
115
+ "amount": "$p.amount",
116
+ "destinationAccountId": "$p.release_to",
117
+ "sourceAccountId": "$inst.fields.buyerAccount"
118
+ },
119
+ "effects": [
120
+ {
121
+ "kind": "moves",
122
+ "signature": "moves.transfer.internal"
123
+ }
124
+ ],
125
+ "evidence": "bank transfer confirmation receipt",
126
+ "id": "leaf_fund",
127
+ "operation": "internal_transfer.create"
128
+ }
129
+ ],
130
+ "order": [
131
+ "leaf_fund"
132
+ ],
133
+ "parameters": {
134
+ "inst": {
135
+ "kind": "instance"
136
+ },
137
+ "p": {
138
+ "kind": "piece"
139
+ }
140
+ },
141
+ "principal": "api_key",
142
+ "recovery": "local"
143
+ },
144
+ "execute_release": {
145
+ "approval": "inherit",
146
+ "calls": [],
147
+ "leaves": [
148
+ {
149
+ "bind": {
150
+ "amount": "$p.amount",
151
+ "destinationAccountId": "$p.release_to",
152
+ "sourceAccountId": "$inst.fields.escrowAccount"
153
+ },
154
+ "effects": [
155
+ {
156
+ "kind": "moves",
157
+ "signature": "moves.transfer.internal"
158
+ }
159
+ ],
160
+ "evidence": "release to payee confirmation",
161
+ "id": "leaf_rel",
162
+ "operation": "internal_transfer.create"
163
+ }
164
+ ],
165
+ "order": [
166
+ "leaf_rel"
167
+ ],
168
+ "parameters": {
169
+ "inst": {
170
+ "kind": "instance"
171
+ },
172
+ "p": {
173
+ "kind": "piece"
174
+ }
175
+ },
176
+ "principal": "api_key",
177
+ "recovery": "local"
178
+ }
179
+ }
180
+ }
181
+ },
182
+ "fields": {
183
+ "buyerAccount": {
184
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
185
+ "type": "string"
186
+ },
187
+ "currency": {
188
+ "const": "USD",
189
+ "pattern": "^[A-Z]{3}$",
190
+ "type": "string"
191
+ },
192
+ "escrowAccount": {
193
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
194
+ "type": "string"
195
+ },
196
+ "p1Amount": {
197
+ "pattern": "^[1-9][0-9]{0,17}$",
198
+ "type": "string",
199
+ "x-hyperscale-currency": "USD"
200
+ },
201
+ "p1Refund": {
202
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
203
+ "type": "string"
204
+ },
205
+ "p1Release": {
206
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
207
+ "type": "string"
208
+ },
209
+ "p2Amount": {
210
+ "pattern": "^[1-9][0-9]{0,17}$",
211
+ "type": "string",
212
+ "x-hyperscale-currency": "USD"
213
+ },
214
+ "p2Refund": {
215
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
216
+ "type": "string"
217
+ },
218
+ "p2Release": {
219
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
220
+ "type": "string"
221
+ },
222
+ "totalAmount": {
223
+ "pattern": "^[1-9][0-9]{0,17}$",
224
+ "type": "string",
225
+ "x-hyperscale-currency": "USD"
226
+ }
227
+ },
228
+ "id": "escrow_watch",
229
+ "idPrefix": "ew",
230
+ "lifecycle": {
231
+ "initial": "draft",
232
+ "states": [
233
+ "draft",
234
+ "funded",
235
+ "released"
236
+ ],
237
+ "transitions": {
238
+ "fund_piece": {
239
+ "from": [
240
+ "draft"
241
+ ],
242
+ "to": "funded"
243
+ },
244
+ "payout_piece": {
245
+ "from": [
246
+ "funded"
247
+ ],
248
+ "to": "released"
249
+ }
250
+ }
251
+ },
252
+ "partitions": [
253
+ {
254
+ "pieceFields": [
255
+ "p1Amount",
256
+ "p2Amount"
257
+ ],
258
+ "totalField": "totalAmount"
259
+ }
260
+ ],
261
+ "piecePlan": {
262
+ "fund_order": [
263
+ "p1",
264
+ "p2"
265
+ ],
266
+ "id": "split_plan",
267
+ "pieces": [
268
+ {
269
+ "amount": "p1Amount",
270
+ "id": "p1",
271
+ "refund_to": "p1Refund",
272
+ "release_to": "p1Release"
273
+ },
274
+ {
275
+ "amount": "p2Amount",
276
+ "id": "p2",
277
+ "refund_to": "p2Refund",
278
+ "release_to": "p2Release"
279
+ }
280
+ ],
281
+ "refund_order": [
282
+ "p1"
283
+ ],
284
+ "release_order": [
285
+ "p1",
286
+ "p2"
287
+ ],
288
+ "total": "totalAmount",
289
+ "unfund_order": [
290
+ "p1",
291
+ "p2"
292
+ ]
293
+ },
294
+ "required": [
295
+ "totalAmount",
296
+ "p1Amount",
297
+ "p2Amount",
298
+ "p1Release",
299
+ "p1Refund",
300
+ "p2Release",
301
+ "p2Refund",
302
+ "buyerAccount",
303
+ "escrowAccount"
304
+ ],
305
+ "summary": "Escrow watch contract with piece plan",
306
+ "title": "Escrow Watch"
307
+ }
308
+ ],
309
+ "product": "escrow_watch",
310
+ "subjects": [],
311
+ "title": "Escrow Watch Document",
312
+ "udl": 1,
313
+ "version": 1
314
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "canonical": "piece-plan-calls.udl",
3
+ "digest": "b919b17d78d4c25851f45ae7512026d4d9dfe36601cbf72ecdc07483f3265005",
4
+ "summary": "A two-piece plan funded and released one piece at a time through private action calls.",
5
+ "verdict": "valid"
6
+ }
@@ -0,0 +1,314 @@
1
+ {
2
+ "instruments": [
3
+ {
4
+ "actionLibrary": {
5
+ "transfers": {
6
+ "actionOrder": [
7
+ "execute_fund",
8
+ "execute_release"
9
+ ],
10
+ "actions": {
11
+ "execute_fund": {
12
+ "approval": "inherit",
13
+ "calls": [],
14
+ "leaves": [
15
+ {
16
+ "bind": {
17
+ "amount": "$p.amount",
18
+ "destinationAccountId": "$p.release_to",
19
+ "sourceAccountId": "$inst.fields.buyerAccount"
20
+ },
21
+ "effects": [
22
+ {
23
+ "kind": "moves",
24
+ "signature": "moves.transfer.internal"
25
+ }
26
+ ],
27
+ "evidence": "bank transfer confirmation receipt",
28
+ "id": "leaf_fund",
29
+ "operation": "internal_transfer.create"
30
+ }
31
+ ],
32
+ "order": [
33
+ "leaf_fund"
34
+ ],
35
+ "parameters": {
36
+ "inst": {
37
+ "kind": "instance"
38
+ },
39
+ "p": {
40
+ "kind": "piece"
41
+ }
42
+ },
43
+ "principal": "api_key",
44
+ "recovery": "local"
45
+ },
46
+ "execute_release": {
47
+ "approval": "inherit",
48
+ "calls": [],
49
+ "leaves": [
50
+ {
51
+ "bind": {
52
+ "amount": "$p.amount",
53
+ "destinationAccountId": "$p.release_to",
54
+ "sourceAccountId": "$inst.fields.escrowAccount"
55
+ },
56
+ "effects": [
57
+ {
58
+ "kind": "moves",
59
+ "signature": "moves.transfer.internal"
60
+ }
61
+ ],
62
+ "evidence": "release to payee confirmation",
63
+ "id": "leaf_rel",
64
+ "operation": "internal_transfer.create"
65
+ }
66
+ ],
67
+ "order": [
68
+ "leaf_rel"
69
+ ],
70
+ "parameters": {
71
+ "inst": {
72
+ "kind": "instance"
73
+ },
74
+ "p": {
75
+ "kind": "piece"
76
+ }
77
+ },
78
+ "principal": "api_key",
79
+ "recovery": "local"
80
+ }
81
+ }
82
+ }
83
+ },
84
+ "actionOrder": [
85
+ "create",
86
+ "fund_piece",
87
+ "payout_piece"
88
+ ],
89
+ "actions": {
90
+ "create": {
91
+ "moves": [],
92
+ "steps": [],
93
+ "summary": "Create watch instrument"
94
+ },
95
+ "fund_piece": {
96
+ "calls": [
97
+ {
98
+ "action": "transfers.execute_fund",
99
+ "bind": {
100
+ "inst": "$instance",
101
+ "p": "$piece"
102
+ },
103
+ "id": "call_fund"
104
+ }
105
+ ],
106
+ "effects": {
107
+ "moves": [
108
+ {
109
+ "signature": "moves.transfer.internal",
110
+ "source": "fund_piece.call_fund.leaf_fund"
111
+ }
112
+ ]
113
+ },
114
+ "input": {
115
+ "additionalProperties": false,
116
+ "properties": {
117
+ "pieceId": {
118
+ "enum": [
119
+ "p1",
120
+ "p2"
121
+ ],
122
+ "type": "string"
123
+ }
124
+ },
125
+ "required": [
126
+ "pieceId"
127
+ ],
128
+ "type": "object"
129
+ },
130
+ "moves": [],
131
+ "pieceStage": {
132
+ "plan": "split_plan",
133
+ "stage": "fund"
134
+ },
135
+ "steps": [],
136
+ "summary": "Fund one piece in stage"
137
+ },
138
+ "payout_piece": {
139
+ "calls": [
140
+ {
141
+ "action": "transfers.execute_release",
142
+ "bind": {
143
+ "inst": "$instance",
144
+ "p": "$piece"
145
+ },
146
+ "id": "call_rel"
147
+ }
148
+ ],
149
+ "effects": {
150
+ "moves": [
151
+ {
152
+ "signature": "moves.transfer.internal",
153
+ "source": "payout_piece.call_rel.leaf_rel"
154
+ }
155
+ ]
156
+ },
157
+ "input": {
158
+ "additionalProperties": false,
159
+ "properties": {
160
+ "pieceId": {
161
+ "enum": [
162
+ "p1",
163
+ "p2"
164
+ ],
165
+ "type": "string"
166
+ }
167
+ },
168
+ "required": [
169
+ "pieceId"
170
+ ],
171
+ "type": "object"
172
+ },
173
+ "moves": [],
174
+ "pieceStage": {
175
+ "plan": "split_plan",
176
+ "stage": "release"
177
+ },
178
+ "steps": [],
179
+ "summary": "Release piece"
180
+ }
181
+ },
182
+ "fields": {
183
+ "buyerAccount": {
184
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
185
+ "type": "string"
186
+ },
187
+ "currency": {
188
+ "const": "USD",
189
+ "pattern": "^[A-Z]{3}$",
190
+ "type": "string"
191
+ },
192
+ "escrowAccount": {
193
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
194
+ "type": "string"
195
+ },
196
+ "p1Amount": {
197
+ "pattern": "^[1-9][0-9]{0,17}$",
198
+ "type": "string",
199
+ "x-hyperscale-currency": "USD"
200
+ },
201
+ "p1Refund": {
202
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
203
+ "type": "string"
204
+ },
205
+ "p1Release": {
206
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
207
+ "type": "string"
208
+ },
209
+ "p2Amount": {
210
+ "pattern": "^[1-9][0-9]{0,17}$",
211
+ "type": "string",
212
+ "x-hyperscale-currency": "USD"
213
+ },
214
+ "p2Refund": {
215
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
216
+ "type": "string"
217
+ },
218
+ "p2Release": {
219
+ "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
220
+ "type": "string"
221
+ },
222
+ "totalAmount": {
223
+ "pattern": "^[1-9][0-9]{0,17}$",
224
+ "type": "string",
225
+ "x-hyperscale-currency": "USD"
226
+ }
227
+ },
228
+ "id": "escrow_watch",
229
+ "idPrefix": "ew",
230
+ "lifecycle": {
231
+ "initial": "draft",
232
+ "states": [
233
+ "draft",
234
+ "funded",
235
+ "released"
236
+ ],
237
+ "transitions": {
238
+ "fund_piece": {
239
+ "from": [
240
+ "draft"
241
+ ],
242
+ "to": "funded"
243
+ },
244
+ "payout_piece": {
245
+ "from": [
246
+ "funded"
247
+ ],
248
+ "to": "released"
249
+ }
250
+ }
251
+ },
252
+ "partitions": [
253
+ {
254
+ "pieceFields": [
255
+ "p1Amount",
256
+ "p2Amount"
257
+ ],
258
+ "totalField": "totalAmount"
259
+ }
260
+ ],
261
+ "piecePlan": {
262
+ "fund_order": [
263
+ "p1",
264
+ "p2"
265
+ ],
266
+ "id": "split_plan",
267
+ "pieces": [
268
+ {
269
+ "amount": "p1Amount",
270
+ "id": "p1",
271
+ "refund_to": "p1Refund",
272
+ "release_to": "p1Release"
273
+ },
274
+ {
275
+ "amount": "p2Amount",
276
+ "id": "p2",
277
+ "refund_to": "p2Refund",
278
+ "release_to": "p2Release"
279
+ }
280
+ ],
281
+ "refund_order": [
282
+ "p1"
283
+ ],
284
+ "release_order": [
285
+ "p1",
286
+ "p2"
287
+ ],
288
+ "total": "totalAmount",
289
+ "unfund_order": [
290
+ "p2",
291
+ "p1"
292
+ ]
293
+ },
294
+ "required": [
295
+ "totalAmount",
296
+ "p1Amount",
297
+ "p2Amount",
298
+ "p1Release",
299
+ "p1Refund",
300
+ "p2Release",
301
+ "p2Refund",
302
+ "buyerAccount",
303
+ "escrowAccount"
304
+ ],
305
+ "summary": "Escrow watch contract with piece plan",
306
+ "title": "Escrow Watch"
307
+ }
308
+ ],
309
+ "product": "escrow_watch",
310
+ "subjects": [],
311
+ "title": "Escrow Watch Document",
312
+ "udl": 1,
313
+ "version": 1
314
+ }
@@ -43,6 +43,30 @@ declare const diagnosticDefinitions: {
43
43
  readonly title: "Derived effects mismatch";
44
44
  readonly fix: "Regenerate the action effects from its clauses.";
45
45
  };
46
+ readonly UDL2010: {
47
+ readonly category: "invalid_semantics";
48
+ readonly family: "document";
49
+ readonly title: "Action graph violation";
50
+ readonly fix: "Order all actions and calls without cycles or collisions, within depth and count limits.";
51
+ };
52
+ readonly UDL2011: {
53
+ readonly category: "invalid_semantics";
54
+ readonly family: "document";
55
+ readonly title: "Action binding violation";
56
+ readonly fix: "Bind parameters to declared instance, piece, or caller variables without forward references or duplicate captures.";
57
+ };
58
+ readonly UDL2012: {
59
+ readonly category: "invalid_semantics";
60
+ readonly family: "document";
61
+ readonly title: "Action authority violation";
62
+ readonly fix: "Match principal, approval, and recovery policies and keep field paths within tenant boundary.";
63
+ };
64
+ readonly UDL2013: {
65
+ readonly category: "invalid_semantics";
66
+ readonly family: "document";
67
+ readonly title: "Action effect or evidence violation";
68
+ readonly fix: "Provide valid effect kind, matching effect signature, and non-empty evidence for every leaf.";
69
+ };
46
70
  readonly UDL3001: {
47
71
  readonly category: "invalid_semantics";
48
72
  readonly family: "lifecycle";
@@ -55,6 +79,12 @@ declare const diagnosticDefinitions: {
55
79
  readonly title: "Money graph violation";
56
80
  readonly fix: "Balance every funded amount and close every hold on each lifecycle path.";
57
81
  };
82
+ readonly UDL4002: {
83
+ readonly category: "invalid_semantics";
84
+ readonly family: "finance";
85
+ readonly title: "Piece partition violation";
86
+ readonly fix: "Match piece plan total, amounts, and payees to required immutable fields and declared partition.";
87
+ };
58
88
  readonly UDL5001: {
59
89
  readonly category: "invalid_semantics";
60
90
  readonly family: "gates";
@@ -127,6 +157,12 @@ declare const diagnosticDefinitions: {
127
157
  readonly title: "Reconcile exception reason field has the wrong type";
128
158
  readonly fix: "Point reasonField at a required plain text field declared by the exception child.";
129
159
  };
160
+ readonly UDL5013: {
161
+ readonly category: "invalid_semantics";
162
+ readonly family: "gates";
163
+ readonly title: "Piece stage violation";
164
+ readonly fix: "Reference a declared piece plan and stage in the containing instrument.";
165
+ };
130
166
  readonly UDL6001: {
131
167
  readonly category: "invalid_semantics";
132
168
  readonly family: "schema";