@hyperscale0/hsx 2.4.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 (249) hide show
  1. package/CHANGELOG.md +2 -408
  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 -4160
  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 -5515
  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,173 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # held_payment
4
-
5
- Source: [`std/money_flows/held_payment.hsx`](../../../std/money_flows/held_payment.hsx)
6
-
7
- ## Export
8
-
9
- `held_payment<C>`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `payer` | `party` | Yes | The funding party providing the money. |
16
- | `payee` | `party` | Yes | The beneficiary party receiving the released funds. |
17
- | `amount` | `money<C>` | Yes | Total amount in minor units of currency `C`. |
18
- | `release` | `condition` | Yes | Condition required to release funds. Supports decision ports (`port <name>`), date deadlines (`at(<date>)`), or disjunctions (`port <name> &#124; at(<date>)`). |
19
- | `fees` | `optional<block>` | No | Optional block declaring percentage or fixed fee cuts, e.g. `{ buyer: 1%, seller: 2% }`. |
20
- | `on_cancel` | `optional<block>` | No | Optional block defining refund splits if cancelled while funded, e.g. `(funded) { buyer: 90%, seller: 10% }`. |
21
- | `derived_amount` | `optional<block>` | No | Optional block declaring machine-derived fees calculated as a percentage of another field. |
22
- | `release_to` | `optional<party>` | No | Optional third-party destination for release. |
23
- | `whole_amount` | `optional<block>` | No | Optional block enabling single-action funding and release of principal plus on-top fee. |
24
- | `release_action` | `optional<text>` | No | Optional custom name for the release action. |
25
- | `whole_fee` | `optional<money<C>>` | No | Optional money amount for the whole-amount fee. |
26
- | `reference` | `optional<text>` | No | Optional string reference stored on the instance. |
27
- | `upstream` | `optional<ref>` | No | Optional reference to a parent instrument. |
28
- | `id_prefix_override` | `optional<text>` | No | Optional custom prefix for generated instrument IDs. |
29
- | `cancel_charge_bps` | `optional<integer>` | No | Optional cancellation charge in basis points. Declaring it gives the settlement a quoted cancellation: `quote_cancellation` prices the charge and the refund and freezes both, `cancel` pays the refund to the payer, and `retain_cancellation_charge` pays the charge to the payee. A zero charge keeps the flow with a zero fee. |
30
- | `cancel_offer_life` | `optional<text>` | No | ISO 8601 duration a cancellation quote stays open, required with `cancel_charge_bps`. |
31
- | `private_actions` | `optional<boolean>` | No | Suppress automatic aliases. Publish chosen actions with `expose`. |
32
-
33
- Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
34
-
35
- ## Module guidance
36
-
37
- Escrow settlement holding funds from a payer before releasing to a payee upon a verified condition or deadline.
38
-
39
- ### Purpose
40
-
41
- `held_payment` holds customer funds in a dedicated product escrow account away from both payer and payee.
42
- It fits milestone-gated commerce, vehicle escrow, contractor holdbacks, and goods purchases where funds
43
- must remain reserved until delivery confirmation or inspection.
44
-
45
- ### Selection guidance
46
-
47
- - vs `cancellable_booking`: Both hold funds in custody and both can quote a cancellation before it is
48
- spent. `held_payment` quotes one flat charge declared by `cancel_charge_bps`, because it has no scheduled
49
- start to price against, and `on_cancel` remains the way to unwind it on static splits instead.
50
- Choose `cancellable_booking` when the charge must follow the time left before a scheduled start date.
51
- - vs `security_deposit`: `held_payment` releases or cancels the principal according to predefined splits.
52
- Choose `security_deposit` when the holder must assess damages and claim an arbitrary partial amount
53
- via a `decided amount` clause while returning the unspent remainder to the payer.
54
- - vs `swap`: `held_payment` is a one-way transfer from payer to payee. Choose `swap` for bilateral or
55
- multi-party atomic exchanges where all parties must fund their legs into escrow before simultaneous release.
56
- - vs `premium_forward`: Choose `premium_forward` for insurance premium collection requiring carrier policy
57
- binding conditions, broker commission retention, policy endorsements, and lapse schedules.
58
-
59
- ### Parameters
60
-
61
- - `payer`: The funding party providing the money.
62
- - `payee`: The beneficiary party receiving the released funds.
63
- - `amount`: Total amount in minor units of currency `C`.
64
- - `release`: Condition required to release funds. Supports decision ports (`port <name>`), date deadlines
65
- (`at(<date>)`), or disjunctions (`port <name> | at(<date>)`).
66
- - `fees`: Optional block declaring percentage or fixed fee cuts, e.g. `{ buyer: 1%, seller: 2% }`.
67
- - `on_cancel`: Optional block defining refund splits if cancelled while funded, e.g. `(funded) { buyer: 90%, seller: 10% }`.
68
- - `derived_amount`: Optional block declaring machine-derived fees calculated as a percentage of another field.
69
- - `release_to`: Optional third-party destination for release.
70
- - `whole_amount`: Optional block enabling single-action funding and release of principal plus on-top fee.
71
- - `release_action`: Optional custom name for the release action.
72
- - `whole_fee`: Optional money amount for the whole-amount fee.
73
- - `reference`: Optional string reference stored on the instance.
74
- - `upstream`: Optional reference to a parent instrument.
75
- - `id_prefix_override`: Optional custom prefix for generated instrument IDs.
76
- - `cancel_charge_bps`: Optional cancellation charge in basis points. Declaring it gives the settlement a
77
- quoted cancellation: `quote_cancellation` prices the charge and the refund and freezes both,
78
- `cancel` pays the refund to the payer, and `retain_cancellation_charge` pays the charge to the payee.
79
- A zero charge keeps the flow with a zero fee.
80
- - `cancel_offer_life`: ISO 8601 duration a cancellation quote stays open, required with `cancel_charge_bps`.
81
-
82
- - `private_actions`: Suppress automatic aliases. Publish chosen actions with `expose`.
83
-
84
- ### Decision ports
85
-
86
- - `release`: Port deciding release authorization, answered by allowed parties declared in the port.
87
-
88
- ### Example
89
-
90
- ```hsx
91
- program held_payment_example "Held payment example"
92
- import { held_payment } from "std/money_flows"
93
- party buyer: person
94
- party seller: business
95
- settlement sale = held_payment {
96
- payer: buyer
97
- payee: seller
98
- amount: price: money(SAR)
99
- fees { buyer: 1% }
100
- on_cancel(funded) { buyer: 100% }
101
- release: port confirm_delivery | at(releaseDueAt)
102
- }
103
- port confirm_delivery { allowed: [buyer] }
104
- ```
105
-
106
- ## Declared clauses
107
-
108
- - `agent description`
109
- - `caller parked states`
110
- - `commit`
111
- - `deadline`
112
- - `description`
113
- - `distinct parties`
114
- - `due`
115
- - `event name`
116
- - `id prefix`
117
- - `input`
118
- - `moves`
119
- - `partitions`
120
- - `port`
121
- - `quote`
122
- - `requires drained`
123
- - `sandbox failure point`
124
- - `steps`
125
- - `summary`
126
- - `title`
127
-
128
- This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
129
-
130
- ## Decision ports
131
-
132
- - `release`
133
-
134
- ## Actions and clauses
135
-
136
- | Action | Clauses lowered |
137
- | --- | --- |
138
- | `fund_piece_2` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
139
- | `fund_piece_3` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
140
- | `collect_service_fee` | `agent description`, `moves`, `steps`, `summary` |
141
- | `release_piece_2` | `agent description`, `moves`, `steps`, `summary` |
142
- | `release_piece_3` | `agent description`, `moves`, `steps`, `summary` |
143
- | `refund_piece_2` | `agent description`, `moves`, `steps`, `summary` |
144
- | `refund_piece_3` | `agent description`, `moves`, `steps`, `summary` |
145
- | `unfund_piece_1` | `agent description`, `moves`, `steps`, `summary` |
146
- | `unfund_piece_2` | `agent description`, `moves`, `steps`, `summary` |
147
- | `unfund_piece_3` | `agent description`, `moves`, `steps`, `summary` |
148
- | `create` | `agent description`, `moves`, `steps`, `summary` |
149
- | `fund_piece_1` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
150
- | `[release_name]` | `agent description`, `deadline`, `input`, `moves`, `port`, `sandbox failure point`, `steps`, `summary` |
151
- | `release_on_deadline` | `due`, `moves`, `steps`, `summary` |
152
- | `cancel` | `agent description`, `deadline`, `moves`, `steps`, `summary` |
153
- | `quote_cancellation` | `agent description`, `deadline`, `moves`, `quote`, `steps`, `summary` |
154
- | `cancel` | `agent description`, `commit`, `deadline`, `moves`, `steps`, `summary` |
155
- | `retain_cancellation_charge` | `agent description`, `moves`, `steps`, `summary` |
156
- | `fund_piece_2` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
157
- | `release_piece_2` | `agent description`, `moves`, `steps`, `summary` |
158
- | `unfund_piece_1` | `agent description`, `moves`, `steps`, `summary` |
159
- | `fund_piece_2` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
160
- | `release_piece_2` | `agent description`, `moves`, `steps`, `summary` |
161
- | `refund_piece_2` | `agent description`, `moves`, `steps`, `summary` |
162
- | `unfund_piece_1` | `agent description`, `moves`, `steps`, `summary` |
163
- | `abandon` | `agent description`, `moves`, `steps`, `summary` |
164
- | `dispute` | `agent description`, `deadline`, `description`, `moves`, `steps`, `summary` |
165
- | `resume` | `agent description`, `description`, `moves`, `steps`, `summary` |
166
- | `create` | `agent description`, `moves`, `steps`, `summary` |
167
- | `fund` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
168
- | `[release_action]` | `agent description`, `deadline`, `moves`, `port`, `sandbox failure point`, `steps`, `summary` |
169
- | `release_on_deadline` | `due`, `event name`, `moves`, `steps`, `summary` |
170
- | `cancel` | `agent description`, `deadline`, `event name`, `moves`, `steps`, `summary` |
171
- | `abandon` | `agent description`, `moves`, `requires drained`, `steps`, `summary` |
172
- | `dispute` | `agent description`, `deadline`, `description`, `moves`, `steps`, `summary` |
173
- | `resume` | `agent description`, `description`, `moves`, `steps`, `summary` |
@@ -1,97 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # instant_transfer
4
-
5
- Source: [`std/money_flows/instant_transfer.hsx`](../../../std/money_flows/instant_transfer.hsx)
6
-
7
- ## Export
8
-
9
- `instant_transfer<C>`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `payer` | `party` | Yes | Funding party whose account is debited. |
16
- | `payee` | `party` | Yes | Recipient party whose account is credited. |
17
- | `amount` | `money<C>` | Yes | Transfer amount in minor units of currency `C`. |
18
- | `fees` | `optional<block>` | No | Optional fee configuration block specifying flat fees, percentage fees, or bracketed fee tiers for payer and/or payee. |
19
- | `derived_amount` | `optional<block>` | No | Optional block declaring derived platform fees calculated from the transfer amount. |
20
-
21
- Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
22
-
23
- ## Module guidance
24
-
25
- Direct, single-step push transfer from payer to payee with optional tiered or percentage fees.
26
-
27
- ### Purpose
28
-
29
- `instant_transfer` debits a payer and credits a payee immediately in a single execution step.
30
- It fits peer-to-peer transfers, direct disbursements, instant payouts, wallet reloads, and simple point-of-sale payments.
31
-
32
- ### Selection guidance
33
-
34
- - vs `captured_payment`: `instant_transfer` moves money in one atomic step without prior authorization holds,
35
- incremental captures, voids, or post-settlement correction ports. Use `captured_payment` when authorization must precede capture.
36
- - vs `conditional_disbursement`: `instant_transfer` executes immediately without external decision evidence
37
- or cumulative cap tracking. Use `conditional_disbursement` when payments require evidence submission or aggregate milestone caps.
38
- - vs `held_payment`: `instant_transfer` never holds funds in an intermediary escrow account.
39
-
40
- ### Parameters
41
-
42
- - `payer`: Funding party whose account is debited.
43
- - `payee`: Recipient party whose account is credited.
44
- - `amount`: Transfer amount in minor units of currency `C`.
45
- - `fees`: Optional fee configuration block specifying flat fees, percentage fees, or bracketed fee tiers for payer and/or payee.
46
- - `derived_amount`: Optional block declaring derived platform fees calculated from the transfer amount.
47
-
48
- ### Decision ports
49
-
50
- None. Transfers execute immediately upon invocation.
51
-
52
- ### Example
53
-
54
- ```hsx
55
- program instant_transfer_example "Instant transfer example"
56
- import { instant_transfer } from "std/money_flows"
57
- party customer: person
58
- party merchant: business
59
- settlement transfer = instant_transfer {
60
- payer: customer
61
- payee: merchant
62
- amount: transferAmount: money(SAR)
63
- fees {
64
- customer: checkoutFee: money(SAR)
65
- merchant {
66
- tier { from: 0, to: 10000, fee: 1% }
67
- tier { from: 10000, fee: highValueFee: money(SAR) }
68
- }
69
- }
70
- }
71
- ```
72
-
73
- ## Declared clauses
74
-
75
- - `agent description`
76
- - `description`
77
- - `moves`
78
- - `partitions`
79
- - `sandbox failure point`
80
- - `steps`
81
- - `summary`
82
- - `title`
83
-
84
- This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
85
-
86
- ## Decision ports
87
-
88
- None.
89
-
90
- ## Actions and clauses
91
-
92
- | Action | Clauses lowered |
93
- | --- | --- |
94
- | `create` | `agent description`, `moves`, `steps`, `summary` |
95
- | `pay_piece_1` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
96
- | `pay_piece_2` | `agent description`, `moves`, `steps`, `summary` |
97
- | `collect_service_fee` | `agent description`, `moves`, `steps`, `summary` |
@@ -1,89 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # metered
4
-
5
- Source: [`std/money_flows/metered.hsx`](../../../std/money_flows/metered.hsx)
6
-
7
- ## Export
8
-
9
- `metered`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `payer` | `party` | Yes | The customer being billed for usage. |
16
- | `payee` | `party` | Yes | The service provider receiving usage revenue. |
17
- | `close_by` | `date` | Yes | Date when the metering period closes, preventing further usage charges. |
18
- | `rates` | `unknown` | Yes | Block mapping rate metric names to their per-unit money prices committed at period open. |
19
-
20
- Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
21
-
22
- ## Module guidance
23
-
24
- Usage-based billing against a committed rate card over an open period until a stored close date.
25
-
26
- ### Purpose
27
-
28
- `metered` bills customers for variable resource consumption such as API requests, compute hours,
29
- storage gigabytes, or utility consumption. The rate card is fixed when the period opens, and individual
30
- usage events are charged incrementally until the billing period closes on `close_by`.
31
-
32
- ### Selection guidance
33
-
34
- - vs `scheduled`: `metered` charges variable amounts per event calculated from consumed units and committed
35
- rate card prices. `scheduled` executes transfers on fixed calendar recurrence intervals (`every`, `first_due`)
36
- with predetermined amounts or installments.
37
-
38
- ### Parameters
39
-
40
- - `payer`: The customer being billed for usage.
41
- - `payee`: The service provider receiving usage revenue.
42
- - `close_by`: Date when the metering period closes, preventing further usage charges.
43
- - `rates`: Block mapping rate metric names to their per-unit money prices committed at period open.
44
-
45
- ### Decision ports
46
-
47
- None. Charges are driven by caller billing actions and period closure.
48
-
49
- ### Example
50
-
51
- ```hsx
52
- program metered_example "Metered example"
53
- import { metered } from "std/money_flows"
54
- party customer: business
55
- party provider: business
56
- settlement usage = metered {
57
- payer: customer
58
- payee: provider
59
- close_by: periodEnd
60
- rates {
61
- api_call: callRate: money(SAR)
62
- storage_gib: storageRate: money(SAR)
63
- }
64
- }
65
- ```
66
-
67
- ## Declared clauses
68
-
69
- - `agent description`
70
- - `description`
71
- - `due`
72
- - `moves`
73
- - `steps`
74
- - `summary`
75
- - `title`
76
-
77
- This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
78
-
79
- ## Decision ports
80
-
81
- None.
82
-
83
- ## Actions and clauses
84
-
85
- | Action | Clauses lowered |
86
- | --- | --- |
87
- | `create` | `agent description`, `steps`, `summary` |
88
- | `charge_[item]` | `agent description`, `moves`, `steps`, `summary` |
89
- | `close_period` | `due`, `steps`, `summary` |
@@ -1,95 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # pooled_split
4
-
5
- Source: [`std/money_flows/pooled_split.hsx`](../../../std/money_flows/pooled_split.hsx)
6
-
7
- ## Export
8
-
9
- `pooled_split<C>`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `payer` | `party` | Yes | The funding party providing the pooled amount. |
16
- | `amount` | `money<C>` | Yes | Total pooled amount in minor units of currency `C`. |
17
- | `payout_due` | `date` | Yes | Stored payout date when the pool distributes to all recipients. |
18
- | `split` | `block` | Yes | Block declaring each recipient's percentage share and `remainder_to` recipient for rounding remainders. |
19
-
20
- Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
21
-
22
- ## Module guidance
23
-
24
- Fixed multi-recipient revenue or period pool funded share-by-share and released automatically on a due date.
25
-
26
- ### Purpose
27
-
28
- `pooled_split` pools a period total from one payer and splits it across a fixed roster of recipients
29
- according to predetermined percentage shares (with integer division remainder assigned to `remainder_to`).
30
- Callers fund the pool share-by-share, and payouts disburse automatically to each recipient on `payout_due`.
31
-
32
- ### Selection guidance
33
-
34
- - vs `weighted_distribution`: `pooled_split` hardcodes a fixed set of recipients and static percentage shares
35
- directly in the contract. `weighted_distribution` handles dynamic recipient counts where arbitrary weights
36
- are recorded as child records and frozen via a snapshot port before distribution.
37
- - vs `settlement_batch`: `settlement_batch` aggregates multiple payments from many sources into one net payout.
38
- `pooled_split` takes one period total from one payer and partitions it out to multiple recipients.
39
-
40
- ### Parameters
41
-
42
- - `payer`: The funding party providing the pooled amount.
43
- - `amount`: Total pooled amount in minor units of currency `C`.
44
- - `payout_due`: Stored payout date when the pool distributes to all recipients.
45
- - `split`: Block declaring each recipient's percentage share and `remainder_to` recipient for rounding remainders.
46
-
47
- ### Decision ports
48
-
49
- None. Payout distribution triggers automatically from the stored `payout_due` date.
50
-
51
- ### Example
52
-
53
- ```hsx
54
- program pooled_split_example "Pooled split example"
55
- import { pooled_split } from "std/money_flows"
56
- party payer: business
57
- party first_recipient: business
58
- party second_recipient: business
59
- settlement pool = pooled_split {
60
- payer: payer
61
- amount: poolAmount: money(SAR)
62
- payout_due: payoutDueAt
63
- split {
64
- first_recipient: 60%
65
- second_recipient: 40%
66
- remainder_to: first_recipient
67
- }
68
- }
69
- ```
70
-
71
- ## Declared clauses
72
-
73
- - `agent description`
74
- - `description`
75
- - `due`
76
- - `id prefix`
77
- - `moves`
78
- - `partitions`
79
- - `steps`
80
- - `summary`
81
- - `title`
82
-
83
- This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
84
-
85
- ## Decision ports
86
-
87
- None.
88
-
89
- ## Actions and clauses
90
-
91
- | Action | Clauses lowered |
92
- | --- | --- |
93
- | `create` | `agent description`, `moves`, `steps`, `summary` |
94
- | `fund_share_[index]` | `agent description`, `moves`, `steps`, `summary` |
95
- | `distribute_share_[index]` | `due`, `moves`, `steps`, `summary` |
@@ -1,119 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # premium_forward
4
-
5
- Source: [`std/money_flows/premium_forward.hsx`](../../../std/money_flows/premium_forward.hsx)
6
-
7
- ## Export
8
-
9
- `premium_forward<C>`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `payer` | `party` | Yes | The policyholder paying the insurance premium. |
16
- | `carrier` | `party` | Yes | The insurance carrier underwriting the policy. |
17
- | `amount` | `money<C>` | Yes | Total gross premium in minor units of currency `C`. |
18
- | `bind` | `condition` | Yes | Condition port triggering policy binding and premium forwarding. |
19
- | `commission` | `percent` | Yes | Platform commission percentage retained from the gross premium. |
20
- | `policy_ref` | `optional<text>` | No | Optional policy identifier string. |
21
- | `renewal_due` | `optional<date>` | No | Optional date anchor when the policy is due for renewal. |
22
- | `endorsement` | `optional<condition>` | No | Optional condition port for recording policy endorsements. |
23
-
24
- Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
25
-
26
- ## Module guidance
27
-
28
- Insurance premium escrow holding customer funds until policy binding, then partitioning net carrier premium and commission.
29
-
30
- ### Purpose
31
-
32
- `premium_forward` manages insurance premium collection, broker commission retention, and carrier remittance.
33
- A policyholder funds the premium into dedicated escrow. The funds remain held until the policy binds via the `bind` port.
34
- Upon binding, the gross premium is automatically partitioned: the platform fee/commission is retained, and the net
35
- balance forwards to the carrier. It also supports policy endorsements and renewal schedules.
36
-
37
- ### Selection guidance
38
-
39
- - vs `held_payment`: `premium_forward` is tailored for insurance lifecycles, featuring automatic commission splits
40
- upon binding and policy endorsement tracking. `held_payment` is general commercial escrow without insurance
41
- underwriting binding semantics or gross-to-net fee partitioning.
42
- - vs `conditional_disbursement`: `premium_forward` collects and forwards inbound policy premiums to carriers.
43
- `conditional_disbursement` pays outbound claim settlements to claimants against stored evidence.
44
-
45
- ### Parameters
46
-
47
- - `payer`: The policyholder paying the insurance premium.
48
- - `carrier`: The insurance carrier underwriting the policy.
49
- - `amount`: Total gross premium in minor units of currency `C`.
50
- - `bind`: Condition port triggering policy binding and premium forwarding.
51
- - `commission`: Platform commission percentage retained from the gross premium.
52
- - `policy_ref`: Optional policy identifier string.
53
- - `renewal_due`: Optional date anchor when the policy is due for renewal.
54
- - `endorsement`: Optional condition port for recording policy endorsements.
55
-
56
- ### Decision ports
57
-
58
- - `bind`: Port authorizing policy binding, triggering carrier payout and commission retention.
59
- - `endorsement`: Port allowing carrier endorsement evidence to be recorded.
60
-
61
- ### Example
62
-
63
- ```hsx
64
- program premium_forward_example "Premium forward example"
65
- import { premium_forward } from "std/money_flows"
66
- party policyholder: person
67
- party carrier: business
68
- settlement premium = premium_forward {
69
- payer: policyholder
70
- carrier: carrier
71
- amount: premiumAmount: money(SAR)
72
- commission: 2%
73
- bind: port bind_policy
74
- policy_ref: policyReference
75
- renewal_due: renewalDueAt
76
- endorsement: port record_endorsement
77
- }
78
- port bind_policy { allowed: [policyholder, carrier] }
79
- port record_endorsement {
80
- allowed: [carrier]
81
- shape: { evidenceReference: text }
82
- }
83
- ```
84
-
85
- ## Declared clauses
86
-
87
- - `agent description`
88
- - `capture input`
89
- - `description`
90
- - `due`
91
- - `input`
92
- - `moves`
93
- - `partitions`
94
- - `port`
95
- - `sandbox failure point`
96
- - `steps`
97
- - `summary`
98
- - `title`
99
-
100
- This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
101
-
102
- ## Decision ports
103
-
104
- - `bind`
105
- - `endorsement`
106
-
107
- ## Actions and clauses
108
-
109
- | Action | Clauses lowered |
110
- | --- | --- |
111
- | `create` | `agent description`, `steps`, `summary` |
112
- | `fund_piece_1` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
113
- | `fund_piece_2` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
114
- | `[bind]` | `agent description`, `input`, `moves`, `port`, `sandbox failure point`, `steps`, `summary` |
115
- | `forward_piece_2` | `agent description`, `moves`, `steps`, `summary` |
116
- | `unfund_piece_1` | `agent description`, `moves`, `steps`, `summary` |
117
- | `abandon` | `agent description`, `steps`, `summary` |
118
- | `[endorsement]` | `agent description`, `capture input`, `input`, `port`, `steps`, `summary` |
119
- | `lapse` | `due`, `steps`, `summary` |
@@ -1,103 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # reconciled_payout
4
-
5
- Source: [`std/money_flows/reconciled_payout.hsx`](../../../std/money_flows/reconciled_payout.hsx)
6
-
7
- ## Export
8
-
9
- `reconciled_payout<C>`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `payer` | `party` | Yes | The funding party providing the payout. |
16
- | `beneficiary` | `party` | Yes | The beneficiary party receiving the external payout. |
17
- | `amount` | `money<C>` | Yes | Instructed payout amount in minor units of currency `C`. |
18
- | `beneficiary_ref` | `text` | Yes | Registered external beneficiary ID for bank routing. |
19
- | `settle_by` | `date` | Yes | Cut-off date when unmatched expectation amounts become formal break records. |
20
- | `matched_within` | `integer` | Yes | Match tolerance window in basis points or minor units. |
21
- | `matched_ceiling` | `integer` | Yes | Maximum acceptable tolerance ceiling between instructed amount and settled debit. |
22
-
23
- Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
24
-
25
- ## Module guidance
26
-
27
- Outbound bank payout instruction with end-to-end reconciliation against external bank statement feeds.
28
-
29
- ### Purpose
30
-
31
- `reconciled_payout` manages high-assurance payouts to external suppliers, partners, or customers where payment
32
- is not complete until confirmed by bank statement data. An instruction is dispatched to the beneficiary and an expectation
33
- record is opened. Incoming statement debit lines match against the expectation within configurable tolerance thresholds
34
- (`matched_within`, `matched_ceiling`). If the statement debit does not match before `settle_by`, a formal break row is raised.
35
-
36
- ### Selection guidance
37
-
38
- - vs `settlement_batch`: `reconciled_payout` executes and reconciles an individual bank payout instruction.
39
- `settlement_batch` aggregates periodic captures, fees, and signed adjustments to calculate a net payable batch.
40
- - vs `instant_transfer`: `instant_transfer` executes an immediate internal ledger transfer between platform accounts.
41
- `reconciled_payout` dispatches funds across external banking rails with reconciliation tolerances and break tracking.
42
-
43
- ### Parameters
44
-
45
- - `payer`: The funding party providing the payout.
46
- - `beneficiary`: The beneficiary party receiving the external payout.
47
- - `amount`: Instructed payout amount in minor units of currency `C`.
48
- - `beneficiary_ref`: Registered external beneficiary ID for bank routing.
49
- - `settle_by`: Cut-off date when unmatched expectation amounts become formal break records.
50
- - `matched_within`: Match tolerance window in basis points or minor units.
51
- - `matched_ceiling`: Maximum acceptable tolerance ceiling between instructed amount and settled debit.
52
-
53
- ### Decision ports
54
-
55
- None. Payout dispatch and settlement matching follow the declared schedule, bank statement lines, and tolerance rules.
56
-
57
- ### Example
58
-
59
- ```hsx
60
- program reconciled_payout_example "Reconciled payout example"
61
- import { reconciled_payout } from "std/money_flows"
62
- party treasury: business
63
- party supplier: business
64
- settlement supplier_payout = reconciled_payout {
65
- payer: treasury
66
- beneficiary: supplier
67
- amount: netPayable: money(SAR)
68
- beneficiary_ref: supplierBeneficiaryId
69
- settle_by: settleBy
70
- matched_within: 100
71
- matched_ceiling: 500
72
- }
73
- ```
74
-
75
- ## Declared clauses
76
-
77
- - `agent description`
78
- - `description`
79
- - `dials`
80
- - `due`
81
- - `id prefix`
82
- - `moves`
83
- - `payout`
84
- - `reconcile`
85
- - `steps`
86
- - `summary`
87
- - `title`
88
-
89
- This inventory covers all branches and nested instruments in the module. The selected parameters determine which clauses and actions the compiler emits. Indexed action names expand over the declared finite list.
90
-
91
- ## Decision ports
92
-
93
- None.
94
-
95
- ## Actions and clauses
96
-
97
- | Action | Clauses lowered |
98
- | --- | --- |
99
- | `create` | `agent description`, `moves`, `steps`, `summary` |
100
- | `instruct` | `agent description`, `moves`, `payout`, `steps`, `summary` |
101
- | `settle` | `due`, `moves`, `reconcile`, `steps`, `summary` |
102
- | `create` | `agent description`, `moves`, `steps`, `summary` |
103
- | `carry` | `agent description`, `moves`, `steps`, `summary` |