@hyperscale0/hsx 2.4.0 → 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 (249) hide show
  1. package/CHANGELOG.md +2 -400
  2. package/README.md +3 -92
  3. package/dist/src/ast.d.ts +99 -310
  4. package/dist/src/ast.d.ts.map +1 -1
  5. package/dist/src/ast.js +16 -69
  6. package/dist/src/ast.js.map +1 -1
  7. package/dist/src/cli.d.ts +6 -19
  8. package/dist/src/cli.d.ts.map +1 -1
  9. package/dist/src/cli.js +76 -315
  10. package/dist/src/cli.js.map +1 -1
  11. package/dist/src/compile.d.ts +23 -73
  12. package/dist/src/compile.d.ts.map +1 -1
  13. package/dist/src/compile.js +1113 -148
  14. package/dist/src/compile.js.map +1 -1
  15. package/dist/src/cost.d.ts +8 -77
  16. package/dist/src/cost.d.ts.map +1 -1
  17. package/dist/src/cost.js +13 -422
  18. package/dist/src/cost.js.map +1 -1
  19. package/dist/src/format.d.ts +8 -7
  20. package/dist/src/format.d.ts.map +1 -1
  21. package/dist/src/format.js +9 -175
  22. package/dist/src/format.js.map +1 -1
  23. package/dist/src/headers.d.ts +35 -0
  24. package/dist/src/headers.d.ts.map +1 -0
  25. package/dist/src/headers.js +108 -0
  26. package/dist/src/headers.js.map +1 -0
  27. package/dist/src/index.d.ts +6 -12
  28. package/dist/src/index.d.ts.map +1 -1
  29. package/dist/src/index.js +4 -9
  30. package/dist/src/index.js.map +1 -1
  31. package/dist/src/lex.d.ts +8 -28
  32. package/dist/src/lex.d.ts.map +1 -1
  33. package/dist/src/lex.js +88 -146
  34. package/dist/src/lex.js.map +1 -1
  35. package/dist/src/parse.d.ts +4 -17
  36. package/dist/src/parse.d.ts.map +1 -1
  37. package/dist/src/parse.js +402 -1040
  38. package/dist/src/parse.js.map +1 -1
  39. package/dist/src/std-bundle.d.ts.map +1 -1
  40. package/dist/src/std-bundle.js +12 -20
  41. package/dist/src/std-bundle.js.map +1 -1
  42. package/dist/src/std-library.d.ts +1 -1
  43. package/dist/src/std-library.d.ts.map +1 -1
  44. package/dist/src/std-library.js +1 -5
  45. package/dist/src/std-library.js.map +1 -1
  46. package/dist/src/tunables.d.ts +7 -0
  47. package/dist/src/tunables.d.ts.map +1 -0
  48. package/dist/src/tunables.js +26 -0
  49. package/dist/src/tunables.js.map +1 -0
  50. package/dist/src/version.d.ts +2 -4
  51. package/dist/src/version.d.ts.map +1 -1
  52. package/dist/src/version.js +2 -4
  53. package/dist/src/version.js.map +1 -1
  54. package/docs/README.md +179 -41
  55. package/docs/headers.md +44 -0
  56. package/examples/cost-table.json +99 -751
  57. package/examples/library.hsx +59 -0
  58. package/package.json +9 -17
  59. package/src/ast.ts +82 -441
  60. package/src/cli.ts +77 -362
  61. package/src/compile.ts +1535 -247
  62. package/src/cost.ts +28 -671
  63. package/src/format.ts +12 -256
  64. package/src/headers.ts +126 -0
  65. package/src/index.ts +7 -39
  66. package/src/lex.ts +99 -195
  67. package/src/parse.ts +403 -1209
  68. package/src/std-bundle.ts +12 -20
  69. package/src/std-library.ts +2 -7
  70. package/src/tunables.ts +31 -0
  71. package/src/version.ts +2 -5
  72. package/std/approvals.hsx +17 -0
  73. package/std/cards.hsx +63 -0
  74. package/std/collections.hsx +31 -0
  75. package/std/escrow.hsx +43 -0
  76. package/std/financing.hsx +372 -0
  77. package/std/insurance.hsx +59 -0
  78. package/std/lending.hsx +115 -0
  79. package/std/marketplace.hsx +24 -0
  80. package/std/money.hsx +195 -0
  81. package/std/savings.hsx +44 -0
  82. package/std/travel.hsx +98 -0
  83. package/std/wallet.hsx +41 -0
  84. package/dist/src/diagnostics.d.ts +0 -13
  85. package/dist/src/diagnostics.d.ts.map +0 -1
  86. package/dist/src/diagnostics.js +0 -587
  87. package/dist/src/diagnostics.js.map +0 -1
  88. package/dist/src/emit.d.ts +0 -51
  89. package/dist/src/emit.d.ts.map +0 -1
  90. package/dist/src/emit.js +0 -192
  91. package/dist/src/emit.js.map +0 -1
  92. package/dist/src/entry-overrides.d.ts +0 -58
  93. package/dist/src/entry-overrides.d.ts.map +0 -1
  94. package/dist/src/entry-overrides.js +0 -284
  95. package/dist/src/entry-overrides.js.map +0 -1
  96. package/dist/src/ir.d.ts +0 -73
  97. package/dist/src/ir.d.ts.map +0 -1
  98. package/dist/src/ir.js +0 -15
  99. package/dist/src/ir.js.map +0 -1
  100. package/dist/src/limits.d.ts +0 -23
  101. package/dist/src/limits.d.ts.map +0 -1
  102. package/dist/src/limits.js +0 -23
  103. package/dist/src/limits.js.map +0 -1
  104. package/dist/src/lsp/server.d.ts +0 -32
  105. package/dist/src/lsp/server.d.ts.map +0 -1
  106. package/dist/src/lsp/server.js +0 -391
  107. package/dist/src/lsp/server.js.map +0 -1
  108. package/dist/src/modules.d.ts +0 -38
  109. package/dist/src/modules.d.ts.map +0 -1
  110. package/dist/src/modules.js +0 -372
  111. package/dist/src/modules.js.map +0 -1
  112. package/dist/src/typecheck.d.ts +0 -8
  113. package/dist/src/typecheck.d.ts.map +0 -1
  114. package/dist/src/typecheck.js +0 -4131
  115. package/dist/src/typecheck.js.map +0 -1
  116. package/docs/guide/01-first-program.md +0 -24
  117. package/docs/guide/02-money.md +0 -25
  118. package/docs/guide/03-instruments.md +0 -93
  119. package/docs/guide/04-lifecycles.md +0 -40
  120. package/docs/guide/05-fees-and-splits.md +0 -45
  121. package/docs/guide/06-schedules.md +0 -26
  122. package/docs/guide/07-composition.md +0 -52
  123. package/docs/guide/08-writing-a-module.md +0 -85
  124. package/docs/guide/09-cost.md +0 -24
  125. package/docs/guide/10-diagnostics.md +0 -27
  126. package/docs/llms-full.txt +0 -3684
  127. package/docs/llms.txt +0 -44
  128. package/docs/piece-plans.md +0 -120
  129. package/docs/playground.md +0 -55
  130. package/docs/reference/cli.md +0 -36
  131. package/docs/reference/diagnostics.md +0 -901
  132. package/docs/reference/grammar.md +0 -38
  133. package/docs/reference/std/advance.md +0 -112
  134. package/docs/reference/std/cancellable_booking.md +0 -159
  135. package/docs/reference/std/captured_payment.md +0 -115
  136. package/docs/reference/std/conditional_disbursement.md +0 -101
  137. package/docs/reference/std/credit_facility.md +0 -108
  138. package/docs/reference/std/held_payment.md +0 -173
  139. package/docs/reference/std/instant_transfer.md +0 -97
  140. package/docs/reference/std/metered.md +0 -89
  141. package/docs/reference/std/pooled_split.md +0 -95
  142. package/docs/reference/std/premium_forward.md +0 -119
  143. package/docs/reference/std/reconciled_payout.md +0 -103
  144. package/docs/reference/std/rotating_pool.md +0 -130
  145. package/docs/reference/std/scheduled.md +0 -136
  146. package/docs/reference/std/security_deposit.md +0 -138
  147. package/docs/reference/std/settlement_batch.md +0 -123
  148. package/docs/reference/std/swap.md +0 -133
  149. package/docs/reference/std/threshold_pool.md +0 -138
  150. package/docs/reference/std/weighted_distribution.md +0 -135
  151. package/docs/reference/types.md +0 -61
  152. package/docs/reference/udl-output.md +0 -13
  153. package/examples/01-first-program/README.md +0 -45
  154. package/examples/01-first-program/tip-jar.hsx +0 -17
  155. package/examples/02-imports-and-modules/README.md +0 -96
  156. package/examples/02-imports-and-modules/photo-booth.hsx +0 -37
  157. package/examples/03-diagnostics/README.md +0 -68
  158. package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
  159. package/examples/03-diagnostics/corner-shop.hsx +0 -19
  160. package/examples/04-complete-product/README.md +0 -84
  161. package/examples/04-complete-product/study-hall.hsx +0 -67
  162. package/examples/05-authored-instrument/README.md +0 -5
  163. package/examples/05-authored-instrument/payment.hsx +0 -37
  164. package/examples/05-watch-club/README.md +0 -6
  165. package/examples/05-watch-club/watch-club.hsx +0 -123
  166. package/examples/README.md +0 -48
  167. package/examples/advance/README.md +0 -3
  168. package/examples/advance/advance.hsx +0 -13
  169. package/examples/advance/advance.udl +0 -367
  170. package/examples/cancellable_booking/README.md +0 -3
  171. package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
  172. package/examples/cancellable_booking/cancellable_booking.udl +0 -413
  173. package/examples/captured_payment/README.md +0 -3
  174. package/examples/captured_payment/captured_payment.hsx +0 -17
  175. package/examples/captured_payment/captured_payment.udl +0 -686
  176. package/examples/conditional_disbursement/README.md +0 -3
  177. package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -15
  178. package/examples/conditional_disbursement/conditional_disbursement.udl +0 -418
  179. package/examples/credit_facility/README.md +0 -3
  180. package/examples/credit_facility/credit_facility.hsx +0 -24
  181. package/examples/credit_facility/credit_facility.udl +0 -1396
  182. package/examples/held_payment/README.md +0 -3
  183. package/examples/held_payment/held_payment.hsx +0 -13
  184. package/examples/held_payment/held_payment.udl +0 -569
  185. package/examples/instant_transfer/README.md +0 -3
  186. package/examples/instant_transfer/instant_transfer.hsx +0 -16
  187. package/examples/instant_transfer/instant_transfer.udl +0 -376
  188. package/examples/metered/README.md +0 -3
  189. package/examples/metered/metered.hsx +0 -13
  190. package/examples/metered/metered.udl +0 -253
  191. package/examples/pooled_split/README.md +0 -3
  192. package/examples/pooled_split/pooled_split.hsx +0 -15
  193. package/examples/pooled_split/pooled_split.udl +0 -432
  194. package/examples/premium_forward/README.md +0 -3
  195. package/examples/premium_forward/premium_forward.hsx +0 -19
  196. package/examples/premium_forward/premium_forward.udl +0 -604
  197. package/examples/reconciled_payout/README.md +0 -3
  198. package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
  199. package/examples/reconciled_payout/reconciled_payout.udl +0 -312
  200. package/examples/rotating_pool/README.md +0 -3
  201. package/examples/rotating_pool/rotating_pool.hsx +0 -18
  202. package/examples/rotating_pool/rotating_pool.udl +0 -4370
  203. package/examples/scheduled/README.md +0 -3
  204. package/examples/scheduled/scheduled.hsx +0 -12
  205. package/examples/scheduled/scheduled.udl +0 -355
  206. package/examples/security_deposit/README.md +0 -3
  207. package/examples/security_deposit/security_deposit.hsx +0 -21
  208. package/examples/security_deposit/security_deposit.udl +0 -320
  209. package/examples/settlement_batch/README.md +0 -3
  210. package/examples/settlement_batch/settlement_batch.hsx +0 -19
  211. package/examples/settlement_batch/settlement_batch.udl +0 -757
  212. package/examples/swap/README.md +0 -3
  213. package/examples/swap/swap.hsx +0 -19
  214. package/examples/swap/swap.udl +0 -892
  215. package/examples/threshold_pool/README.md +0 -3
  216. package/examples/threshold_pool/threshold_pool.hsx +0 -16
  217. package/examples/threshold_pool/threshold_pool.udl +0 -680
  218. package/examples/weighted_distribution/README.md +0 -3
  219. package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
  220. package/examples/weighted_distribution/weighted_distribution.udl +0 -348
  221. package/skills/hsx/SKILL.md +0 -449
  222. package/src/diagnostics.ts +0 -620
  223. package/src/emit.ts +0 -282
  224. package/src/entry-overrides.ts +0 -428
  225. package/src/ir.ts +0 -113
  226. package/src/limits.ts +0 -22
  227. package/src/lsp/server.ts +0 -460
  228. package/src/modules.ts +0 -452
  229. package/src/typecheck.ts +0 -5381
  230. package/std/SEMANTICS.md +0 -44
  231. package/std/money_flows/advance.hsx +0 -235
  232. package/std/money_flows/cancellable_booking.hsx +0 -402
  233. package/std/money_flows/captured_payment.hsx +0 -220
  234. package/std/money_flows/conditional_disbursement.hsx +0 -226
  235. package/std/money_flows/credit_facility.hsx +0 -214
  236. package/std/money_flows/held_payment.hsx +0 -812
  237. package/std/money_flows/index.hsx +0 -4
  238. package/std/money_flows/instant_transfer.hsx +0 -231
  239. package/std/money_flows/metered.hsx +0 -104
  240. package/std/money_flows/pooled_split.hsx +0 -109
  241. package/std/money_flows/premium_forward.hsx +0 -307
  242. package/std/money_flows/reconciled_payout.hsx +0 -119
  243. package/std/money_flows/rotating_pool.hsx +0 -305
  244. package/std/money_flows/scheduled.hsx +0 -599
  245. package/std/money_flows/security_deposit.hsx +0 -248
  246. package/std/money_flows/settlement_batch.hsx +0 -173
  247. package/std/money_flows/swap.hsx +0 -1192
  248. package/std/money_flows/threshold_pool.hsx +0 -307
  249. package/std/money_flows/weighted_distribution.hsx +0 -237
@@ -1,604 +0,0 @@
1
- {
2
- "instruments": [
3
- {
4
- "actionOrder": [
5
- "create",
6
- "fund_piece_1",
7
- "fund_piece_2",
8
- "bind_policy",
9
- "forward_piece_2",
10
- "unfund_piece_1",
11
- "abandon",
12
- "record_endorsement",
13
- "lapse"
14
- ],
15
- "actions": {
16
- "abandon": {
17
- "agentDescription": "Close a premium that was never funded. The escrow account must be empty, so this refuses once any piece is in it. It moves no money and the settlement ends here.",
18
- "moves": [],
19
- "publicAction": "abandonPremium",
20
- "requiresDrainedAccount": {
21
- "path": "refs.escrowAccountId"
22
- },
23
- "steps": [],
24
- "summary": "Abandon the settlement before any money is held"
25
- },
26
- "bind_policy": {
27
- "agentDescription": "Bind the policy through bind_policy and forward the carrier's share out of escrow. The premium must be fully funded first, and the call carries the decision reference the product asks for. Money leaves escrow here and does not come back.",
28
- "effects": {
29
- "decides": [
30
- {
31
- "signature": "decides.tenant_port",
32
- "source": "port"
33
- }
34
- ],
35
- "moves": [
36
- {
37
- "signature": "moves.transfer.internal",
38
- "source": "moves[0]"
39
- }
40
- ]
41
- },
42
- "input": {
43
- "additionalProperties": false,
44
- "properties": {},
45
- "required": [],
46
- "type": "object"
47
- },
48
- "moves": [
49
- {
50
- "bind": {
51
- "amount": {
52
- "from": "instance",
53
- "path": "fields.piece1Amount"
54
- },
55
- "currency": {
56
- "from": "const",
57
- "value": "SAR"
58
- },
59
- "destinationAccountId": {
60
- "from": "instance",
61
- "path": "fields.carrierAccountId"
62
- },
63
- "metadata.instrumentId": {
64
- "from": "const",
65
- "value": "premium"
66
- },
67
- "metadata.instrumentInstanceId": {
68
- "from": "instance",
69
- "path": "instrumentInstanceId"
70
- },
71
- "metadata.phase": {
72
- "from": "const",
73
- "value": "bind_policy"
74
- },
75
- "productId": {
76
- "from": "instance",
77
- "path": "productId"
78
- },
79
- "sourceAccountId": {
80
- "from": "instance",
81
- "path": "refs.escrowAccountId"
82
- }
83
- },
84
- "capture": {
85
- "bindPolicyTransferTransferId": "transferId"
86
- },
87
- "key": "transfer",
88
- "operation": "internal_transfer.create"
89
- }
90
- ],
91
- "port": {
92
- "allowedParties": [
93
- "payer",
94
- "beneficiary"
95
- ]
96
- },
97
- "publicAction": "bindPolicyPremium",
98
- "sandboxFailurePoint": "release",
99
- "steps": [],
100
- "summary": "Confirm through bind_policy and start the forward payout"
101
- },
102
- "create": {
103
- "agentDescription": "Open the premium and provision the escrow account that holds the funds. This is the first call on the settlement, and funding refuses until it lands. It moves no money.",
104
- "moves": [],
105
- "publicAction": "createPremium",
106
- "steps": [
107
- {
108
- "bind": {
109
- "currency": {
110
- "from": "const",
111
- "value": "SAR"
112
- },
113
- "owner.id": {
114
- "from": "instance",
115
- "path": "productId"
116
- },
117
- "owner.type": {
118
- "from": "const",
119
- "value": "product"
120
- },
121
- "productId": {
122
- "from": "instance",
123
- "path": "productId"
124
- },
125
- "role": {
126
- "from": "const",
127
- "value": "product_escrow"
128
- }
129
- },
130
- "capture": {
131
- "escrowAccountId": "accountId"
132
- },
133
- "operation": "account.escrow.provision"
134
- }
135
- ],
136
- "summary": "Create a premium settlement"
137
- },
138
- "forward_piece_2": {
139
- "agentDescription": "Pay the platform commission out of escrow to the fee collection account, which closes the forward. bind_policy must have run first. Money leaves escrow here and does not come back.",
140
- "effects": {
141
- "moves": [
142
- {
143
- "signature": "moves.transfer.internal",
144
- "source": "moves[0]"
145
- }
146
- ]
147
- },
148
- "moves": [
149
- {
150
- "bind": {
151
- "amount": {
152
- "from": "instance",
153
- "path": "fields.piece2Amount"
154
- },
155
- "currency": {
156
- "from": "const",
157
- "value": "SAR"
158
- },
159
- "destinationAccountId": {
160
- "from": "instance",
161
- "path": "fields.platformAccountId"
162
- },
163
- "metadata.instrumentId": {
164
- "from": "const",
165
- "value": "premium"
166
- },
167
- "metadata.instrumentInstanceId": {
168
- "from": "instance",
169
- "path": "instrumentInstanceId"
170
- },
171
- "metadata.phase": {
172
- "from": "const",
173
- "value": "forward_piece_2"
174
- },
175
- "productId": {
176
- "from": "instance",
177
- "path": "productId"
178
- },
179
- "sourceAccountId": {
180
- "from": "instance",
181
- "path": "refs.escrowAccountId"
182
- }
183
- },
184
- "capture": {
185
- "forwardPiece2TransferTransferId": "transferId"
186
- },
187
- "key": "transfer",
188
- "operation": "internal_transfer.create"
189
- }
190
- ],
191
- "publicAction": "forwardPiece2Premium",
192
- "steps": [],
193
- "summary": "Forward piece 2 of the held amount"
194
- },
195
- "fund_piece_1": {
196
- "agentDescription": "Move the carrier's share of the premium from the policyholder into escrow. The settlement must exist and be unfunded. It debits the policyholder for real, and piece 2 still has to fund before the policy can bind.",
197
- "effects": {
198
- "moves": [
199
- {
200
- "signature": "moves.collection.pay_in",
201
- "source": "moves[0]"
202
- }
203
- ]
204
- },
205
- "moves": [
206
- {
207
- "bind": {
208
- "amount": {
209
- "from": "instance",
210
- "path": "fields.piece1Amount"
211
- },
212
- "currency": {
213
- "from": "const",
214
- "value": "SAR"
215
- },
216
- "destinationAccountId": {
217
- "from": "instance",
218
- "path": "refs.escrowAccountId"
219
- },
220
- "metadata.instrumentId": {
221
- "from": "const",
222
- "value": "premium"
223
- },
224
- "metadata.instrumentInstanceId": {
225
- "from": "instance",
226
- "path": "instrumentInstanceId"
227
- },
228
- "metadata.phase": {
229
- "from": "const",
230
- "value": "fund_piece_1"
231
- },
232
- "productId": {
233
- "from": "instance",
234
- "path": "productId"
235
- },
236
- "sourceAccountId": {
237
- "from": "instance",
238
- "path": "fields.policyholderAccountId"
239
- }
240
- },
241
- "capture": {
242
- "fundPiece1TransferTransferId": "transferId"
243
- },
244
- "key": "transfer",
245
- "operation": "internal_transfer.create"
246
- }
247
- ],
248
- "publicAction": "fundPiece1Premium",
249
- "sandboxFailurePoint": "funding",
250
- "steps": [],
251
- "summary": "Fund piece 1 of the held amount into escrow"
252
- },
253
- "fund_piece_2": {
254
- "agentDescription": "Move the platform commission piece from the policyholder into escrow, which completes funding. Piece 1 must be in escrow first. It debits the policyholder for real, and the premium is then held whole.",
255
- "effects": {
256
- "moves": [
257
- {
258
- "signature": "moves.collection.pay_in",
259
- "source": "moves[0]"
260
- }
261
- ]
262
- },
263
- "moves": [
264
- {
265
- "bind": {
266
- "amount": {
267
- "from": "instance",
268
- "path": "fields.piece2Amount"
269
- },
270
- "currency": {
271
- "from": "const",
272
- "value": "SAR"
273
- },
274
- "destinationAccountId": {
275
- "from": "instance",
276
- "path": "refs.escrowAccountId"
277
- },
278
- "metadata.instrumentId": {
279
- "from": "const",
280
- "value": "premium"
281
- },
282
- "metadata.instrumentInstanceId": {
283
- "from": "instance",
284
- "path": "instrumentInstanceId"
285
- },
286
- "metadata.phase": {
287
- "from": "const",
288
- "value": "fund_piece_2"
289
- },
290
- "productId": {
291
- "from": "instance",
292
- "path": "productId"
293
- },
294
- "sourceAccountId": {
295
- "from": "instance",
296
- "path": "fields.policyholderAccountId"
297
- }
298
- },
299
- "capture": {
300
- "fundPiece2TransferTransferId": "transferId"
301
- },
302
- "key": "transfer",
303
- "operation": "internal_transfer.create"
304
- }
305
- ],
306
- "publicAction": "fundPiece2Premium",
307
- "sandboxFailurePoint": "funding",
308
- "steps": [],
309
- "summary": "Fund piece 2 of the held amount into escrow"
310
- },
311
- "lapse": {
312
- "due": {
313
- "field": "renewalDueAt"
314
- },
315
- "effects": {
316
- "schedules": [
317
- {
318
- "signature": "schedules.due",
319
- "source": "due"
320
- }
321
- ]
322
- },
323
- "moves": [],
324
- "requiresDrainedAccount": {
325
- "path": "refs.escrowAccountId"
326
- },
327
- "steps": [],
328
- "summary": "Mark the forwarded policy lapsed at its stored renewal due condition"
329
- },
330
- "record_endorsement": {
331
- "agentDescription": "Record one endorsement against a policy that already forwarded, from evidence the caller supplies. The forward must be released first, and only the carrier may call it. It moves no money and it does not change the premium.",
332
- "captureInput": {
333
- "evidenceReference": "evidenceReference"
334
- },
335
- "effects": {
336
- "decides": [
337
- {
338
- "signature": "decides.tenant_port",
339
- "source": "port"
340
- }
341
- ]
342
- },
343
- "input": {
344
- "additionalProperties": false,
345
- "properties": {
346
- "evidenceReference": {
347
- "description": "Required decision reference retained in the operation receipt",
348
- "maxLength": 180,
349
- "minLength": 1,
350
- "type": "string"
351
- }
352
- },
353
- "required": [
354
- "evidenceReference"
355
- ],
356
- "type": "object"
357
- },
358
- "moves": [],
359
- "port": {
360
- "allowedParties": [
361
- "beneficiary"
362
- ]
363
- },
364
- "publicAction": "recordEndorsementPremium",
365
- "steps": [],
366
- "summary": "Record one non-money endorsement from external evidence"
367
- },
368
- "unfund_piece_1": {
369
- "agentDescription": "Return the carrier's share from escrow to the policyholder and abandon the forward. It runs only while funding stopped after piece 1, before the policy binds. The settlement ends abandoned.",
370
- "effects": {
371
- "moves": [
372
- {
373
- "signature": "moves.transfer.internal",
374
- "source": "moves[0]"
375
- }
376
- ]
377
- },
378
- "moves": [
379
- {
380
- "bind": {
381
- "amount": {
382
- "from": "instance",
383
- "path": "fields.piece1Amount"
384
- },
385
- "currency": {
386
- "from": "const",
387
- "value": "SAR"
388
- },
389
- "destinationAccountId": {
390
- "from": "instance",
391
- "path": "fields.policyholderAccountId"
392
- },
393
- "metadata.instrumentId": {
394
- "from": "const",
395
- "value": "premium"
396
- },
397
- "metadata.instrumentInstanceId": {
398
- "from": "instance",
399
- "path": "instrumentInstanceId"
400
- },
401
- "metadata.phase": {
402
- "from": "const",
403
- "value": "unfund_piece_1"
404
- },
405
- "productId": {
406
- "from": "instance",
407
- "path": "productId"
408
- },
409
- "sourceAccountId": {
410
- "from": "instance",
411
- "path": "refs.escrowAccountId"
412
- }
413
- },
414
- "capture": {
415
- "unfundPiece1TransferTransferId": "transferId"
416
- },
417
- "key": "transfer",
418
- "operation": "internal_transfer.create"
419
- }
420
- ],
421
- "publicAction": "unfundPiece1Premium",
422
- "steps": [],
423
- "summary": "Return piece 1 to the policyholder on abandonment"
424
- }
425
- },
426
- "agentDescription": "Reach for premium when the policyholder pays an insurance premium ahead of cover and the carrier must not be paid until the policy binds. The premiumAmount sits in this settlement's own escrow until bind_policy fires. Binding then forwards 98% to the carrier and 2% to the platform.",
427
- "description": "Premium forward: the policyholder funds the premiumAmount into this settlement's own escrow; binding through bind_policy forwards it to the carrier exactly once, minus the platform commission",
428
- "fields": {
429
- "carrierAccountId": {
430
- "description": "The carrier account",
431
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
432
- "type": "string",
433
- "x-hyperscale-reference-filter": {
434
- "column": "role",
435
- "values": [
436
- "customer_balance"
437
- ]
438
- }
439
- },
440
- "currency": {
441
- "description": "ISO 4217 currency code",
442
- "maxLength": 3,
443
- "minLength": 3,
444
- "pattern": "^[A-Z]{3}$",
445
- "type": "string"
446
- },
447
- "piece1Amount": {
448
- "description": "98% of premiumAmount (carries the integer-division remainder): released to the carrier. Computed as floor(premiumAmount * 9800 / 10000) in SAR minor units",
449
- "pattern": "^[1-9][0-9]{0,17}$",
450
- "type": "string",
451
- "x-hyperscale-currency": "SAR"
452
- },
453
- "piece2Amount": {
454
- "description": "2% of premiumAmount: released to the platform. Computed as floor(premiumAmount * 200 / 10000) in SAR minor units",
455
- "pattern": "^[1-9][0-9]{0,17}$",
456
- "type": "string",
457
- "x-hyperscale-currency": "SAR"
458
- },
459
- "platformAccountId": {
460
- "description": "The product fee collection account",
461
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
462
- "type": "string",
463
- "x-hyperscale-fee-collection-port": true,
464
- "x-hyperscale-reference-filter": {
465
- "column": "role",
466
- "values": [
467
- "customer_balance",
468
- "product_revenue"
469
- ]
470
- }
471
- },
472
- "policyReference": {
473
- "description": "Immutable external policy reference recorded with this forward",
474
- "maxLength": 180,
475
- "minLength": 1,
476
- "type": "string"
477
- },
478
- "policyholderAccountId": {
479
- "description": "The policyholder account",
480
- "pattern": "^acct_(sandbox|live)_[a-z0-9]{8,64}$",
481
- "type": "string",
482
- "x-hyperscale-reference-filter": {
483
- "column": "role",
484
- "values": [
485
- "customer_balance"
486
- ]
487
- }
488
- },
489
- "premiumAmount": {
490
- "description": "The gross held amount in SAR minor units; the piece fields below partition it exactly",
491
- "pattern": "^[1-9][0-9]{0,17}$",
492
- "type": "string",
493
- "x-hyperscale-currency": "SAR"
494
- },
495
- "renewalDueAt": {
496
- "description": "Stored renewal due condition for the forwarded policy",
497
- "format": "hyperscale-date-time",
498
- "type": "string"
499
- }
500
- },
501
- "id": "premium",
502
- "idPrefix": "prem",
503
- "lifecycle": {
504
- "initial": "created",
505
- "states": [
506
- "created",
507
- "funding_1",
508
- "funded",
509
- "releasing_1",
510
- "released",
511
- "abandoned",
512
- "endorsed",
513
- "lapsed"
514
- ],
515
- "transitions": {
516
- "abandon": {
517
- "from": [
518
- "created"
519
- ],
520
- "to": "abandoned"
521
- },
522
- "bind_policy": {
523
- "from": [
524
- "funded"
525
- ],
526
- "to": "releasing_1"
527
- },
528
- "forward_piece_2": {
529
- "from": [
530
- "releasing_1"
531
- ],
532
- "to": "released"
533
- },
534
- "fund_piece_1": {
535
- "from": [
536
- "created"
537
- ],
538
- "to": "funding_1"
539
- },
540
- "fund_piece_2": {
541
- "from": [
542
- "funding_1"
543
- ],
544
- "to": "funded"
545
- },
546
- "lapse": {
547
- "from": [
548
- "released",
549
- "endorsed"
550
- ],
551
- "to": "lapsed"
552
- },
553
- "record_endorsement": {
554
- "from": [
555
- "released"
556
- ],
557
- "to": "endorsed"
558
- },
559
- "unfund_piece_1": {
560
- "from": [
561
- "funding_1"
562
- ],
563
- "to": "abandoned"
564
- }
565
- }
566
- },
567
- "parties": {
568
- "beneficiary": "carrierAccountId",
569
- "payer": "policyholderAccountId"
570
- },
571
- "partitions": [
572
- {
573
- "pieceFields": [
574
- "piece1Amount",
575
- "piece2Amount"
576
- ],
577
- "totalField": "premiumAmount"
578
- }
579
- ],
580
- "required": [
581
- "policyholderAccountId",
582
- "carrierAccountId",
583
- "platformAccountId",
584
- "premiumAmount",
585
- "piece1Amount",
586
- "piece2Amount",
587
- "policyReference",
588
- "renewalDueAt",
589
- "currency"
590
- ],
591
- "summary": "Premium held for the carrier until the policy binds",
592
- "templateBinding": {
593
- "id": "premium_forward",
594
- "parameters": {}
595
- },
596
- "title": "Premium"
597
- }
598
- ],
599
- "product": "premium_forward_example",
600
- "subjects": [],
601
- "title": "Premium forward example",
602
- "udl": 1,
603
- "version": 1
604
- }
@@ -1,3 +0,0 @@
1
- # reconciled_payout
2
-
3
- This example applies the `reconciled_payout` standard-library module. Its sibling UDL file pins the canonical compiler output byte for byte. The company and parties are invented.
@@ -1,13 +0,0 @@
1
- program reconciled_payout_example "Reconciled payout example"
2
- import { reconciled_payout } from "std/money_flows"
3
- party treasury: business
4
- party supplier: business
5
- settlement supplier_payout = reconciled_payout {
6
- payer: treasury
7
- beneficiary: supplier
8
- amount: netPayable: money(SAR)
9
- beneficiary_ref: supplierBeneficiaryId
10
- settle_by: settleBy
11
- matched_within: 100
12
- matched_ceiling: 500
13
- }