@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,38 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # Grammar vocabulary
4
-
5
- The parser is hand-written. This page records the exported lexer vocabulary, the UDL clause vocabulary it binds, and the current standard-library module names.
6
-
7
- ## Keywords
8
-
9
- `action`, `as`, `asset`, `commit`, `const`, `expect`, `expose`, `expires`, `export`, `from`, `import`, `instrument`, `module`, `party`, `port`, `program`, `quote`, `rate`, `reconcile`, `settlement`, `subject`, `type`, `use`
10
-
11
- ## Punctuation
12
-
13
- `{`, `}`, `(`, `)`, `[`, `]`, `:`, `,`, `;`, `=`, `|`, `.`, `<`, `>`, `?` and `->`
14
-
15
- ## Typed clause spellings
16
-
17
- `funding`, `receipt distribution`, `requires allocation`, `allocation`, `contributions`, `allocate`, `contribution stage`, `date order`, `unique`, `transitions refs`, `cascade`, `action library`, `agent description`, `calls`, `requires input`, `engine owned`, `capture engine`, `capture input`, `commit`, `quote`, `decided amount`, `deadline`, `decision`, `computes distribute`, `description`, `due`, `earnable`, `event name`, `examples`, `input`, `moves`, `payout`, `piece plan`, `piece stage`, `port`, `principal`, `public action`, `reconcile`, `computes remainder`, `requires aggregate`, `requires checks`, `requires drained`, `requires exposure`, `requires refs`, `sandbox failure point`, `sets at`, `computes signed_sum`, `steps`, `summary`, `updates`, `notify`, `agent description`, `aggregate invariants`, `caller parked states`, `description`, `dials`, `distinct parties`, `computes derived`, `computes fees`, `id prefix`, `nav`, `partitions`, `subject`, `summary`, `surface visibility`, `template binding`, `template id`, `title`, `update`, `request authority`
18
-
19
- ## Standard-library modules
20
-
21
- - `advance`
22
- - `cancellable_booking`
23
- - `captured_payment`
24
- - `conditional_disbursement`
25
- - `credit_facility`
26
- - `held_payment`
27
- - `instant_transfer`
28
- - `metered`
29
- - `pooled_split`
30
- - `premium_forward`
31
- - `reconciled_payout`
32
- - `rotating_pool`
33
- - `scheduled`
34
- - `security_deposit`
35
- - `settlement_batch`
36
- - `swap`
37
- - `threshold_pool`
38
- - `weighted_distribution`
@@ -1,112 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # advance
4
-
5
- Source: [`std/money_flows/advance.hsx`](../../../std/money_flows/advance.hsx)
6
-
7
- ## Export
8
-
9
- `advance<C>`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `funder` | `party` | Yes | The party providing the upfront capital. |
16
- | `to` | `party` | Yes | The party receiving the advance and responsible for repayment. |
17
- | `amount` | `money<C>` | Yes | Total advanced principal in minor units of currency `C`. |
18
- | `fee` | `optional<percent>` | No | Optional markup percentage fee charged on the advance (basis points precision). |
19
- | `count` | `optional<integer>` | No | Optional number of scheduled installment repayments. |
20
- | `every` | `optional<text>` | No | Optional recurrence duration between installments (e.g. `"P30D"`). |
21
- | `first_due` | `optional<date>` | No | Optional date for the first installment repayment. |
22
- | `against` | `optional<ref>` | No | Optional reference to a hold instrument whose release will be carved to repay the advance. |
23
- | `repayment_source` | `optional<party>` | No | Optional party repaying when distinct from the capital recipient. |
24
- | `profit_to` | `optional<party>` | No | Optional recipient of profit, separated from principal repayments. |
25
- | `dated` | `optional<boolean>` | No | Require an explicit signed date for each repayment instead of duration offsets. |
26
-
27
- Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
28
-
29
- ## Module guidance
30
-
31
- Upfront capital disbursement repaid by carving future held payment releases or over scheduled installments.
32
-
33
- ### Purpose
34
-
35
- `advance` provides working capital, merchant cash advances, or contractor pre-funding from a funder to a recipient.
36
- Repayment occurs either automatically by intercepting (carving) releases from a linked escrow hold (`against`),
37
- or over calendar-anchored installment repayments (`count`, `every`, `first_due`).
38
-
39
- ### Selection guidance
40
-
41
- - vs `credit_facility`: `advance` disburses a single upfront lump-sum principal that is repaid over time.
42
- `credit_facility` establishes a reusable revolving credit line with multiple draws up to a limit,
43
- where repayments restore available borrowing capacity.
44
- - vs `conditional_disbursement`: `advance` expects repayment of the advanced principal plus optional fees.
45
- `conditional_disbursement` disburses non-repayable grants, claims, or milestone payments against external evidence.
46
- - vs `held_payment`: `held_payment` holds customer funds in escrow until delivery. An `advance` can carve repayments
47
- directly out of a `held_payment`'s release using `against`.
48
-
49
- ### Parameters
50
-
51
- - `funder`: The party providing the upfront capital.
52
- - `to`: The party receiving the advance and responsible for repayment.
53
- - `amount`: Total advanced principal in minor units of currency `C`.
54
- - `fee`: Optional markup percentage fee charged on the advance (basis points precision).
55
- - `count`: Optional number of scheduled installment repayments.
56
- - `every`: Optional recurrence duration between installments (e.g. `"P30D"`).
57
- - `first_due`: Optional date for the first installment repayment.
58
- - `repayment_source`: Optional party repaying when distinct from the capital recipient.
59
- - `profit_to`: Optional recipient of profit, separated from principal repayments.
60
- - `dated`: Require an explicit signed date for each repayment instead of duration offsets.
61
- - `against`: Optional reference to a hold instrument whose release will be carved to repay the advance.
62
-
63
- ### Decision ports
64
-
65
- None. Repayment is driven by linked hold releases or scheduled calendar dates.
66
-
67
- ### Example
68
-
69
- ```hsx
70
- program advance_example "Advance example"
71
- import { advance } from "std/money_flows"
72
- party funder: business
73
- party recipient: business
74
- settlement advance_payment = advance {
75
- funder: funder
76
- to: recipient
77
- amount: principal: money(SAR)
78
- fee: 2.5%
79
- count: 2
80
- every: P30D
81
- first_due: firstDueAt
82
- }
83
- ```
84
-
85
- ## Declared clauses
86
-
87
- - `agent description`
88
- - `description`
89
- - `due`
90
- - `id prefix`
91
- - `moves`
92
- - `partitions`
93
- - `steps`
94
- - `summary`
95
- - `title`
96
-
97
- 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.
98
-
99
- ## Decision ports
100
-
101
- None.
102
-
103
- ## Actions and clauses
104
-
105
- | Action | Clauses lowered |
106
- | --- | --- |
107
- | `create` | `agent description`, `moves`, `steps`, `summary` |
108
- | `disburse` | `agent description`, `moves`, `steps`, `summary` |
109
- | `settle` | `agent description`, `moves`, `steps`, `summary` |
110
- | `create` | `agent description`, `moves`, `steps`, `summary` |
111
- | `disburse` | `agent description`, `moves`, `steps`, `summary` |
112
- | `collect_repayment_[i]` | `agent description`, `due`, `moves`, `steps`, `summary` |
@@ -1,159 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # cancellable_booking
4
-
5
- Source: [`std/money_flows/cancellable_booking.hsx`](../../../std/money_flows/cancellable_booking.hsx)
6
-
7
- ## Export
8
-
9
- `cancellable_booking<C>`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `guest` | `optional<party>` | No | The booking customer paying the fee and receiving refunds. |
16
- | `host` | `optional<party>` | No | The service provider receiving the payout or retained cancellation penalty. |
17
- | `amount` | `optional<money<C>>` | No | Total booking price in minor units of currency `C`. |
18
- | `starts_at` | `optional<date>` | No | Stored ISO 8601 date when the booking begins. |
19
- | `late_penalty_bps` | `optional<integer>` | No | Penalty in basis points applied when cancelling within the late window. |
20
- | `late_within` | `optional<text>` | No | ISO 8601 duration defining the late window before `starts_at` (e.g. `"P2D"` for 2 days). |
21
- | `early_penalty_bps` | `optional<integer>` | No | Penalty in basis points applied when cancelling before the late window. |
22
- | `offer_life` | `optional<text>` | No | ISO 8601 duration defining how long a quoted cancellation offer remains valid (e.g. `"PT30M"`). |
23
- | `cancel_bands` | `optional<list<block>>` | No | Supply cancel_bands to select deposit/balance custody instead of quoted cancellation. |
24
- | `price_value` | `optional<text>` | No | price_value and supplier_cost fix the price; deposit_bps derives the deposit. |
25
- | `supplier_cost` | `optional<text>` | No | price_value and supplier_cost fix the price; deposit_bps derives the deposit. |
26
- | `departure` | `optional<text>` | No | balance_before and confirmation_window are positive fixed durations relative to departure. |
27
- | `balance_before` | `optional<text>` | No | balance_before and confirmation_window are positive fixed durations relative to departure. |
28
- | `confirmation_window` | `optional<text>` | No | balance_before and confirmation_window are positive fixed durations relative to departure. |
29
- | `unpaid_band` | `optional<integer>` | No | The unpaid_band index selects a retained deposit policy. |
30
- | `acceptance` | `optional<block>` | No | acceptance optionally supplies an aggregate gate. |
31
- | `deposit_bps` | `optional<integer>` | No | price_value and supplier_cost fix the price; deposit_bps derives the deposit. |
32
- | `tax_bps` | `optional<integer>` | No | tax_bps applies to margin after the supplier share. |
33
- | `authority_type` | `optional<text>` | No | authority_type and supplier_role bind release to a consumed confirmation decision. |
34
- | `supplier_role` | `optional<text>` | No | authority_type and supplier_role bind release to a consumed confirmation decision. |
35
- | `collects` | `optional<json>` | No | collects optionally cascades named actions to linked instruments on deposit. |
36
-
37
- Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
38
-
39
- ## Module guidance
40
-
41
- Time-anchored reservation holding booking funds in escrow with dynamically quoted cancellation penalties.
42
-
43
- ### Purpose
44
-
45
- `cancellable_booking` holds booking fees in escrow from a guest for a host until a scheduled start date.
46
- It fits hospitality, travel reservations, studio rentals, event tickets, and appointments where guests
47
- can cancel prior to start, but cancellation penalties depend on how close to the start date cancellation occurs.
48
-
49
- ### Selection guidance
50
-
51
- - vs `held_payment`: Both hold money in escrow and both quote a cancellation before it is spent.
52
- `cancellable_booking` prices the penalty against the time left before `starts_at`, so the charge moves
53
- as the start approaches; `held_payment` has no start date and quotes one flat charge.
54
- Choose `cancellable_booking` whenever cancellation fees are time-sensitive.
55
- - vs `security_deposit`: `security_deposit` holds funds to cover damages claimed by the holder.
56
- `cancellable_booking` holds the service fee itself and releases to the host upon `starts_at` or refunds net of penalty.
57
-
58
- ### Parameters
59
-
60
- - `guest`: The booking customer paying the fee and receiving refunds.
61
- - `host`: The service provider receiving the payout or retained cancellation penalty.
62
- - `amount`: Total booking price in minor units of currency `C`.
63
- - `starts_at`: Stored ISO 8601 date when the booking begins.
64
- - `late_penalty_bps`: Penalty in basis points applied when cancelling within the late window.
65
- - `late_within`: ISO 8601 duration defining the late window before `starts_at` (e.g. `"P2D"` for 2 days).
66
- - `early_penalty_bps`: Penalty in basis points applied when cancelling before the late window.
67
- - `offer_life`: ISO 8601 duration defining how long a quoted cancellation offer remains valid (e.g. `"PT30M"`).
68
-
69
- ### Decision ports
70
-
71
- None. Action transitions are driven by guest API calls (`take`, `cancel`, `confirm`) and scheduled completion (`complete` due at `starts_at`).
72
-
73
- ### Example
74
-
75
- ```hsx
76
- program studio_booking "Studio booking"
77
- import { cancellable_booking } from "std/money_flows"
78
- party guest: person
79
- party studio: business
80
- settlement studio_session = cancellable_booking {
81
- guest: guest
82
- host: studio
83
- amount: sessionPrice: money(SAR)
84
- starts_at: startsAt
85
- late_penalty_bps: 5000
86
- late_within: "P2D"
87
- early_penalty_bps: 1000
88
- offer_life: "PT30M"
89
- }
90
- ```
91
-
92
- ### Finite cancellation bands
93
-
94
- Supply cancel_bands to select deposit/balance custody instead of quoted cancellation.
95
- Each band has name, refund (full, balance or none), starts_at after the first band,
96
- and supplier_bps when money is retained. The unpaid_band index selects a retained
97
- deposit policy. Omit it to return the deposit; a full-refund band also returns it. price_value and supplier_cost fix the price; deposit_bps derives
98
- the deposit. balance_before and confirmation_window are positive fixed durations
99
- relative to departure. tax_bps applies to margin after the supplier share.
100
- authority_type and supplier_role bind release to a consumed confirmation decision.
101
- collects optionally cascades named actions to linked instruments on deposit.
102
- acceptance optionally supplies an aggregate gate. All actions are private until
103
- expose selects them. Ordered band starts and deadlines prevent a late sweep from
104
- extending an earlier band's cancellation rights. Full timeout refund returns price.
105
- Seven derivations suffice for three bands; larger finite policies use up to the
106
- UDL bound of 64 derived amounts. shift_date(date, duration, "before") subtracts a
107
- fixed duration; omitting the direction adds it. Invalid dates or durations refuse.
108
-
109
- ## Declared clauses
110
-
111
- - `agent description`
112
- - `caller parked states`
113
- - `cascade`
114
- - `commit`
115
- - `deadline`
116
- - `description`
117
- - `distinct parties`
118
- - `due`
119
- - `id prefix`
120
- - `input`
121
- - `moves`
122
- - `partitions`
123
- - `port`
124
- - `quote`
125
- - `requires drained`
126
- - `sandbox failure point`
127
- - `steps`
128
- - `summary`
129
- - `title`
130
- - `unique`
131
- - `updates`
132
-
133
- 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.
134
-
135
- ## Decision ports
136
-
137
- None.
138
-
139
- ## Actions and clauses
140
-
141
- | Action | Clauses lowered |
142
- | --- | --- |
143
- | `create` | `agent description`, `moves`, `steps`, `summary` |
144
- | `take` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
145
- | `complete` | `due`, `moves`, `steps`, `summary` |
146
- | `cancel` | `agent description`, `moves`, `quote`, `steps`, `summary` |
147
- | `confirm` | `agent description`, `commit`, `moves`, `steps`, `summary` |
148
- | `retain` | `agent description`, `moves`, `steps`, `summary` |
149
- | `create` | `agent description`, `deadline`, `steps`, `unique` |
150
- | `deposit` | `agent description`, `cascade`, `deadline`, `moves`, `port`, `steps` |
151
- | `expire` | `agent description`, `due`, `requires drained`, `steps` |
152
- | `[balance_action]` | `agent description`, `deadline`, `moves`, `port`, `steps` |
153
- | `[open_action]` | `agent description`, `due`, `steps` |
154
- | `[cancel_action]` | `agent description`, `deadline`, `moves`, `port`, `steps` |
155
- | `cancel_unpaid` | `agent description`, `due`, `moves`, `steps` |
156
- | `await_confirmation` | `agent description`, `due`, `steps` |
157
- | `confirm` | `agent description`, `deadline`, `input`, `steps`, `updates` |
158
- | `release` | `agent description`, `moves`, `steps` |
159
- | `refund_unconfirmed` | `agent description`, `due`, `moves`, `steps` |
@@ -1,115 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # captured_payment
4
-
5
- Source: [`std/money_flows/captured_payment.hsx`](../../../std/money_flows/captured_payment.hsx)
6
-
7
- ## Export
8
-
9
- `captured_payment<C>`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `payer` | `party` | Yes | Party whose account balance is reserved during authorization. |
16
- | `payee` | `party` | Yes | Beneficiary party capturing authorized funds. |
17
- | `amount` | `money<C>` | Yes | Maximum authorized reservation in minor units of currency `C`. |
18
- | `reserve_until` | `date` | Yes | Expiration date for the authorization hold. |
19
- | `correction` | `condition` | Yes | Condition port allowing post-settlement amount corrections. |
20
- | `external_reversal` | `condition` | Yes | Condition port allowing external processor chargebacks/reversals. |
21
- | `derived_amount` | `optional<block>` | No | Optional block declaring percentage fee calculation. |
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
- Two-phase authorization and capture payment flow for card and merchant processing.
28
-
29
- ### Purpose
30
-
31
- `captured_payment` reserves funds against a payer's account and allows the payee to capture the authorized
32
- balance in one or multiple slices before a reservation expiry date (`reserve_until`). It fits ecommerce checkouts,
33
- card processing, hotel authorizations, and pay-at-pump fuel payments where final amounts vary or settle later.
34
-
35
- ### Selection guidance
36
-
37
- - vs `instant_transfer`: `instant_transfer` immediately transfers money from payer to payee in a single irreversible
38
- step without reservation or settlement delays. `captured_payment` separates authorization from capture, allowing
39
- incremental captures, voids, amount corrections via the `correction` port, and external network reversals via `external_reversal`.
40
- - vs `held_payment`: `held_payment` holds the full amount in third-party escrow pending release. `captured_payment`
41
- reserves funds directly on payer balance and settles incrementally directly to payee.
42
-
43
- ### Parameters
44
-
45
- - `payer`: Party whose account balance is reserved during authorization.
46
- - `payee`: Beneficiary party capturing authorized funds.
47
- - `amount`: Maximum authorized reservation in minor units of currency `C`.
48
- - `reserve_until`: Expiration date for the authorization hold.
49
- - `correction`: Condition port allowing post-settlement amount corrections.
50
- - `external_reversal`: Condition port allowing external processor chargebacks/reversals.
51
- - `derived_amount`: Optional block declaring percentage fee calculation.
52
-
53
- ### Decision ports
54
-
55
- - `correction`: Condition allowing payee or processor to submit an amount correction after settlement.
56
- - `external_reversal`: Condition allowing bank or card network to execute an external reversal.
57
-
58
- ### Example
59
-
60
- ```hsx
61
- program captured_payment_example "Captured payment example"
62
- import { captured_payment } from "std/money_flows"
63
- party payer: person
64
- party payee: business
65
- settlement card_payment = captured_payment {
66
- payer: payer
67
- payee: payee
68
- amount: authorizedAmount: money(SAR)
69
- reserve_until: reserveUntil
70
- correction: port correct_capture
71
- external_reversal: port reverse_capture within P14D
72
- }
73
- port correct_capture { allowed: [payee] }
74
- port reverse_capture {
75
- allowed: [payee]
76
- shape: { externalReference: text }
77
- }
78
- ```
79
-
80
- ## Declared clauses
81
-
82
- - `agent description`
83
- - `capture input`
84
- - `deadline`
85
- - `description`
86
- - `due`
87
- - `input`
88
- - `moves`
89
- - `port`
90
- - `sandbox failure point`
91
- - `steps`
92
- - `summary`
93
- - `title`
94
-
95
- 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.
96
-
97
- ## Decision ports
98
-
99
- - `correction`
100
- - `external_reversal`
101
-
102
- ## Actions and clauses
103
-
104
- | Action | Clauses lowered |
105
- | --- | --- |
106
- | `create` | `agent description`, `moves`, `steps`, `summary` |
107
- | `authorize` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
108
- | `capture` | `agent description`, `deadline`, `description`, `input`, `moves`, `sandbox failure point`, `steps`, `summary` |
109
- | `capture_more` | `agent description`, `deadline`, `description`, `input`, `moves`, `steps`, `summary` |
110
- | `settle` | `agent description`, `deadline`, `moves`, `steps`, `summary` |
111
- | `void` | `agent description`, `moves`, `steps`, `summary` |
112
- | `expire` | `due`, `moves`, `steps`, `summary` |
113
- | `settle_on_expiry` | `due`, `moves`, `steps`, `summary` |
114
- | `[correction_name]` | `agent description`, `capture input`, `input`, `moves`, `port`, `steps`, `summary` |
115
- | `[reversal_name]` | `agent description`, `capture input`, `deadline`, `input`, `moves`, `port`, `steps`, `summary` |
@@ -1,101 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # conditional_disbursement
4
-
5
- Source: [`std/money_flows/conditional_disbursement.hsx`](../../../std/money_flows/conditional_disbursement.hsx)
6
-
7
- ## Export
8
-
9
- `conditional_disbursement<C>`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `source` | `party` | Yes | The funding party providing the money. |
16
- | `destination` | `party` | Yes | The beneficiary party receiving approved disbursements. |
17
- | `cap` | `money<C>` | Yes | Maximum total amount that can be disbursed across all child approvals in minor units of currency `C`. |
18
- | `amount` | `money<C>` | Yes | Binding name for child approval amount values. |
19
- | `decision` | `condition` | Yes | Port conditioning approval, requiring evidence reference. |
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
- Capped disbursement from a source party to a destination party gated on stored external decision evidence.
26
-
27
- ### Purpose
28
-
29
- `conditional_disbursement` manages evidence-contingent payouts subject to a cumulative cap.
30
- It fits insurance claim settlements, grant tranches, subsidy distributions, and escrow milestones
31
- where each approved payment requires explicit external evidence and the total paid must not exceed `cap`.
32
-
33
- ### Selection guidance
34
-
35
- - vs `advance`: `conditional_disbursement` disburses non-repayable funds against external evidence
36
- up to a declared cap. `advance` pays money up front with the expectation of repayment through carved
37
- hold releases or scheduled installments.
38
- - vs `instant_transfer`: `instant_transfer` moves money immediately with no evidence gate or cap.
39
- `conditional_disbursement` requires an external decision port and evidence reference before any child amount moves.
40
-
41
- ### Parameters
42
-
43
- - `source`: The funding party providing the money.
44
- - `destination`: The beneficiary party receiving approved disbursements.
45
- - `cap`: Maximum total amount that can be disbursed across all child approvals in minor units of currency `C`.
46
- - `amount`: Binding name for child approval amount values.
47
- - `decision`: Port conditioning approval, requiring evidence reference.
48
-
49
- ### Decision ports
50
-
51
- - `decision`: External port providing decision evidence required to approve child disbursement amounts.
52
-
53
- ### Example
54
-
55
- ```hsx
56
- program conditional_disbursement_example "Conditional disbursement example"
57
- import { conditional_disbursement } from "std/money_flows"
58
- party source: business
59
- party claimant: person
60
- settlement claim_payment = conditional_disbursement {
61
- source: source
62
- destination: claimant
63
- cap: policyLimit: money(SAR)
64
- amount: approvedAmount: money(SAR)
65
- decision: port approve_claim
66
- }
67
- port approve_claim {
68
- allowed: [source]
69
- shape: { evidenceReference: text }
70
- }
71
- ```
72
-
73
- ## Declared clauses
74
-
75
- - `agent description`
76
- - `capture input`
77
- - `description`
78
- - `id prefix`
79
- - `input`
80
- - `moves`
81
- - `port`
82
- - `steps`
83
- - `summary`
84
- - `title`
85
- - `unique`
86
-
87
- 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.
88
-
89
- ## Decision ports
90
-
91
- - `decision`
92
-
93
- ## Actions and clauses
94
-
95
- | Action | Clauses lowered |
96
- | --- | --- |
97
- | `create` | `agent description`, `moves`, `steps`, `summary` |
98
- | `deny` | `agent description`, `capture input`, `input`, `moves`, `port`, `steps`, `summary` |
99
- | `create` | `agent description`, `moves`, `steps`, `summary`, `unique` |
100
- | `approve` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `steps`, `summary` |
101
- | `pay` | `agent description`, `moves`, `steps`, `summary` |
@@ -1,108 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
2
-
3
- # credit_facility
4
-
5
- Source: [`std/money_flows/credit_facility.hsx`](../../../std/money_flows/credit_facility.hsx)
6
-
7
- ## Export
8
-
9
- `credit_facility<C>`
10
-
11
- ## Parameters
12
-
13
- | Parameter | Type | Required | Meaning |
14
- | --- | --- | --- | --- |
15
- | `lender` | `party` | Yes | The financing institution or party providing the credit capacity. |
16
- | `borrower` | `party` | Yes | The borrowing party authorized to draw against the facility limit. |
17
- | `draw_destination` | `party` | Yes | Account or party receiving disbursed draw proceeds. |
18
- | `limit` | `money<C>` | Yes | Total revolving borrowing limit in minor units of currency `C`. |
19
- | `expires_at` | `date` | Yes | Expiration date after which new draws cannot be opened. |
20
- | `obligation` | `ref` | Yes | Reference to a scheduled obligation instrument handling draw repayments. |
21
-
22
- Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
23
-
24
- ## Module guidance
25
-
26
- Revolving credit line providing reusable borrowing capacity up to a limit backed by scheduled obligations.
27
-
28
- ### Purpose
29
-
30
- `credit_facility` manages revolving commercial credit, inventory financing, and overdraft facilities.
31
- A borrower can draw funds multiple times up to `limit` into `draw_destination`. Each draw creates a child
32
- record linked to a scheduled `obligation`. Repayments restore available borrowing capacity until `expires_at`.
33
-
34
- ### Selection guidance
35
-
36
- - vs `advance`: `credit_facility` provides revolving, reusable credit lines where multiple draws can occur
37
- and repayments restore capacity. `advance` is a single upfront lump-sum disbursement with a fixed repayment plan.
38
- - vs `scheduled`: `scheduled` defines repayment installments or recurring transfers. `credit_facility` delegates
39
- draw repayments to a `scheduled` obligation while tracking total facility utilization and limit compliance.
40
-
41
- ### Parameters
42
-
43
- - `lender`: The financing institution or party providing the credit capacity.
44
- - `borrower`: The borrowing party authorized to draw against the facility limit.
45
- - `draw_destination`: Account or party receiving disbursed draw proceeds.
46
- - `limit`: Total revolving borrowing limit in minor units of currency `C`.
47
- - `expires_at`: Expiration date after which new draws cannot be opened.
48
- - `obligation`: Reference to a scheduled obligation instrument handling draw repayments.
49
-
50
- ### Decision ports
51
-
52
- None on the facility itself. Mandates and decision ports are declared on the linked `obligation` instrument.
53
-
54
- ### Example
55
-
56
- ```hsx
57
- program credit_facility_example "Credit facility example"
58
- import { credit_facility, scheduled } from "std/money_flows"
59
- party lender: business
60
- party borrower: business
61
- party draw_destination: business
62
- party repayment_source: business
63
- settlement repayment = scheduled {
64
- mode: obligation
65
- payer: repayment_source
66
- payee: lender
67
- debtor: borrower
68
- amount: principal: money(SAR)
69
- count: 2
70
- every: P30D
71
- first_due: firstDueAt
72
- }
73
- settlement facility = credit_facility {
74
- lender: lender
75
- borrower: borrower
76
- draw_destination: draw_destination
77
- limit: facilityLimit: money(SAR)
78
- expires_at: expiresAt
79
- obligation: repayment.obligation
80
- }
81
- ```
82
-
83
- ## Declared clauses
84
-
85
- - `agent description`
86
- - `description`
87
- - `due`
88
- - `id prefix`
89
- - `moves`
90
- - `steps`
91
- - `summary`
92
- - `title`
93
-
94
- 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.
95
-
96
- ## Decision ports
97
-
98
- None.
99
-
100
- ## Actions and clauses
101
-
102
- | Action | Clauses lowered |
103
- | --- | --- |
104
- | `create` | `agent description`, `moves`, `steps`, `summary` |
105
- | `freeze` | `due`, `moves`, `steps`, `summary` |
106
- | `close` | `agent description`, `moves`, `steps`, `summary` |
107
- | `create` | `agent description`, `moves`, `steps`, `summary` |
108
- | `resolve` | `agent description`, `moves`, `steps`, `summary` |