@hyperscale0/hsx 2.1.0 → 2.2.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 (110) hide show
  1. package/CHANGELOG.md +36 -7
  2. package/dist/src/cli.d.ts +1 -1
  3. package/dist/src/cli.d.ts.map +1 -1
  4. package/dist/src/cli.js +39 -5
  5. package/dist/src/cli.js.map +1 -1
  6. package/dist/src/compile.d.ts +0 -1
  7. package/dist/src/compile.d.ts.map +1 -1
  8. package/dist/src/compile.js +15 -1
  9. package/dist/src/compile.js.map +1 -1
  10. package/dist/src/cost.d.ts +3 -3
  11. package/dist/src/cost.d.ts.map +1 -1
  12. package/dist/src/cost.js +22 -12
  13. package/dist/src/cost.js.map +1 -1
  14. package/dist/src/parse.d.ts.map +1 -1
  15. package/dist/src/parse.js +10 -14
  16. package/dist/src/parse.js.map +1 -1
  17. package/dist/src/std-bundle.d.ts.map +1 -1
  18. package/dist/src/std-bundle.js +20 -84
  19. package/dist/src/std-bundle.js.map +1 -1
  20. package/dist/src/typecheck.d.ts.map +1 -1
  21. package/dist/src/typecheck.js +171 -39
  22. package/dist/src/typecheck.js.map +1 -1
  23. package/dist/src/version.d.ts +1 -1
  24. package/dist/src/version.js +1 -1
  25. package/docs/README.md +8 -2
  26. package/docs/guide/01-first-program.md +1 -1
  27. package/docs/guide/06-schedules.md +5 -1
  28. package/docs/guide/08-writing-a-module.md +48 -0
  29. package/docs/llms-full.txt +1928 -421
  30. package/docs/llms.txt +2 -3
  31. package/docs/piece-plans.md +120 -0
  32. package/docs/reference/cli.md +6 -5
  33. package/docs/reference/diagnostics.md +9 -9
  34. package/docs/reference/grammar.md +2 -3
  35. package/docs/reference/std/advance.md +94 -17
  36. package/docs/reference/std/cancellable_booking.md +138 -17
  37. package/docs/reference/std/captured_payment.md +96 -24
  38. package/docs/reference/std/conditional_disbursement.md +82 -14
  39. package/docs/reference/std/credit_facility.md +89 -16
  40. package/docs/reference/std/held_payment.md +155 -55
  41. package/docs/reference/std/instant_transfer.md +79 -12
  42. package/docs/reference/std/metered.md +71 -9
  43. package/docs/reference/std/pooled_split.md +76 -7
  44. package/docs/reference/std/premium_forward.md +100 -20
  45. package/docs/reference/std/reconciled_payout.md +84 -14
  46. package/docs/reference/std/rotating_pool.md +112 -24
  47. package/docs/reference/std/scheduled.md +117 -32
  48. package/docs/reference/std/security_deposit.md +119 -27
  49. package/docs/reference/std/settlement_batch.md +105 -24
  50. package/docs/reference/std/swap.md +113 -26
  51. package/docs/reference/std/threshold_pool.md +120 -29
  52. package/docs/reference/std/weighted_distribution.md +117 -21
  53. package/docs/reference/types.md +15 -15
  54. package/docs/reference/udl-output.md +6 -6
  55. package/examples/01-first-program/README.md +1 -1
  56. package/examples/{02-imports-and-archetypes → 02-imports-and-modules}/README.md +1 -1
  57. package/examples/{02-imports-and-archetypes → 02-imports-and-modules}/photo-booth.hsx +1 -1
  58. package/examples/04-complete-product/README.md +1 -1
  59. package/examples/05-authored-instrument/README.md +5 -0
  60. package/examples/05-authored-instrument/payment.hsx +37 -0
  61. package/examples/05-watch-club/watch-club.hsx +0 -1
  62. package/examples/README.md +1 -2
  63. package/examples/advance/advance.udl +29 -6
  64. package/examples/cancellable_booking/cancellable_booking.udl +19 -0
  65. package/examples/captured_payment/captured_payment.hsx +0 -4
  66. package/examples/captured_payment/captured_payment.udl +6 -0
  67. package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -2
  68. package/examples/conditional_disbursement/conditional_disbursement.udl +4 -0
  69. package/examples/cost-table.json +136 -8
  70. package/examples/credit_facility/credit_facility.hsx +0 -3
  71. package/examples/credit_facility/credit_facility.udl +17 -1
  72. package/examples/held_payment/held_payment.udl +16 -0
  73. package/examples/instant_transfer/instant_transfer.udl +6 -0
  74. package/examples/metered/metered.udl +5 -1
  75. package/examples/pooled_split/pooled_split.udl +4 -0
  76. package/examples/premium_forward/premium_forward.udl +4 -0
  77. package/examples/reconciled_payout/reconciled_payout.udl +7 -0
  78. package/examples/rotating_pool/rotating_pool.udl +8 -0
  79. package/examples/scheduled/scheduled.udl +18 -3
  80. package/examples/security_deposit/security_deposit.udl +13 -0
  81. package/examples/settlement_batch/settlement_batch.udl +4 -0
  82. package/examples/swap/swap.udl +10 -0
  83. package/examples/threshold_pool/threshold_pool.udl +11 -0
  84. package/examples/weighted_distribution/weighted_distribution.udl +9 -0
  85. package/package.json +10 -10
  86. package/skills/hsx/SKILL.md +2 -36
  87. package/src/cli.ts +41 -5
  88. package/src/compile.ts +14 -6
  89. package/src/cost.ts +13 -16
  90. package/src/parse.ts +15 -10
  91. package/src/std-bundle.ts +21 -88
  92. package/src/typecheck.ts +207 -34
  93. package/src/version.ts +1 -1
  94. package/std/SEMANTICS.md +33 -128
  95. package/std/money_flows/advance.hsx +39 -26
  96. package/std/money_flows/cancellable_booking.hsx +275 -8
  97. package/std/money_flows/captured_payment.hsx +1 -9
  98. package/std/money_flows/conditional_disbursement.hsx +0 -6
  99. package/std/money_flows/credit_facility.hsx +0 -9
  100. package/std/money_flows/held_payment.hsx +39 -1
  101. package/std/money_flows/index.hsx +2 -1
  102. package/std/money_flows/metered.hsx +1 -5
  103. package/std/money_flows/scheduled.hsx +29 -119
  104. package/std/money_flows/threshold_pool.hsx +40 -5
  105. package/std/money_flows/weighted_distribution.hsx +47 -5
  106. package/docs/reference/std/recurring_collection.md +0 -25
  107. package/examples/recurring_collection/README.md +0 -3
  108. package/examples/recurring_collection/recurring_collection.hsx +0 -21
  109. package/examples/recurring_collection/recurring_collection.udl +0 -1135
  110. package/std/money_flows/recurring_collection.hsx +0 -72
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.1.0. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 2.2.0. Do not edit. -->
2
2
 
3
3
  # rotating_pool
4
4
 
@@ -10,18 +10,99 @@ Source: [`std/money_flows/rotating_pool.hsx`](../../../std/money_flows/rotating_
10
10
 
11
11
  ## Parameters
12
12
 
13
- - `members: optional<list<party>>`
14
- - `contribution: money<C>`
15
- - `count: integer`
16
- - `every: optional<text>`
17
- - `first_due: date`
18
- - `payout_order: optional<list<party>>`
19
- - `default_policy: optional<text>`
20
- - `guarantee_policy: optional<text>`
21
- - `guarantor: optional<party>`
22
- - `exit_policy: optional<text>`
23
- - `memo: optional<text>`
24
- - `membership: optional<block>`
13
+ | Parameter | Type | Required | Meaning |
14
+ | --- | --- | --- | --- |
15
+ | `members` | `optional<list<party>>` | No | List of parties belonging to the rotating group. |
16
+ | `contribution` | `money<C>` | Yes | Fixed contribution amount required from each member per cycle in minor units of currency `C`. |
17
+ | `count` | `integer` | Yes | Total number of cycles in the rotation (matching the member count). |
18
+ | `every` | `optional<text>` | No | Recurrence interval between contribution cycles (e.g. `"P30D"`). |
19
+ | `first_due` | `date` | Yes | Due date for the first cycle's contribution. |
20
+ | `payout_order` | `optional<list<party>>` | No | Ordered list of member parties defining the cycle payout sequence. |
21
+ | `default_policy` | `optional<text>` | No | Policy for handling missed contributions (`due_condition`). |
22
+ | `guarantee_policy` | `optional<text>` | No | Policy for backing defaulted contributions (`funded_only`). |
23
+ | `guarantor` | `optional<party>` | No | Optional guarantor party covering member defaults. |
24
+ | `exit_policy` | `optional<text>` | No | Policy governing member departures (`before_activation_only`). |
25
+ | `memo` | `optional<text>` | No | Optional memo text stored on the pool. |
26
+ | `membership` | `optional<block>` | No | Optional custom membership configuration block. |
27
+
28
+ Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
29
+
30
+ ## Module guidance
31
+
32
+ Rotating savings and credit association (ROSCA) pool where members contribute fixed amounts and take turns receiving the pot.
33
+
34
+ ### Purpose
35
+
36
+ `rotating_pool` coordinates peer savings circles, chit funds, tandas, and committee savings groups.
37
+ A fixed group of members contributes an identical contribution amount each cycle. In each cycle, one designated member
38
+ receives the entire pooled pot according to a predefined `payout_order` until all members have taken their turn.
39
+
40
+ ### Selection guidance
41
+
42
+ - vs `threshold_pool`: `rotating_pool` coordinates recurring multi-party peer savings with rotating payouts.
43
+ `threshold_pool` is all-or-nothing capital accumulation toward a single threshold for one beneficiary.
44
+ - vs `scheduled`: `scheduled` coordinates a single payer to a single payee. `rotating_pool` orchestrates
45
+ a closed circular group of members taking sequential turns.
46
+
47
+ ### Parameters
48
+
49
+ - `members`: List of parties belonging to the rotating group.
50
+ - `contribution`: Fixed contribution amount required from each member per cycle in minor units of currency `C`.
51
+ - `count`: Total number of cycles in the rotation (matching the member count).
52
+ - `every`: Recurrence interval between contribution cycles (e.g. `"P30D"`).
53
+ - `first_due`: Due date for the first cycle's contribution.
54
+ - `payout_order`: Ordered list of member parties defining the cycle payout sequence.
55
+ - `default_policy`: Policy for handling missed contributions (`due_condition`).
56
+ - `guarantee_policy`: Policy for backing defaulted contributions (`funded_only`).
57
+ - `guarantor`: Optional guarantor party covering member defaults.
58
+ - `exit_policy`: Policy governing member departures (`before_activation_only`).
59
+ - `memo`: Optional memo text stored on the pool.
60
+ - `membership`: Optional custom membership configuration block.
61
+
62
+ ### Decision ports
63
+
64
+ None. Cycle advancement and pot payouts follow the declared schedule and membership actions.
65
+
66
+ ### Example
67
+
68
+ ```hsx
69
+ program rotating_pool_example "Rotating pool example"
70
+ import { rotating_pool } from "std/money_flows"
71
+ party member_a: person
72
+ party member_b: person
73
+ party member_c: person
74
+ party guarantor: business
75
+ settlement pool = rotating_pool {
76
+ members: [member_a, member_b, member_c]
77
+ contribution: contributionAmount: money(SAR)
78
+ count: 3
79
+ every: P30D
80
+ first_due: firstContributionAt
81
+ payout_order: [member_b, member_c, member_a]
82
+ default_policy: due_condition
83
+ guarantee_policy: funded_only
84
+ guarantor: guarantor
85
+ exit_policy: before_activation_only
86
+ }
87
+ ```
88
+
89
+ ## Declared clauses
90
+
91
+ - `agent description`
92
+ - `aggregate invariants`
93
+ - `caller parked states`
94
+ - `description`
95
+ - `due`
96
+ - `examples`
97
+ - `id prefix`
98
+ - `moves`
99
+ - `sandbox failure point`
100
+ - `steps`
101
+ - `summary`
102
+ - `title`
103
+ - `unique`
104
+
105
+ 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.
25
106
 
26
107
  ## Decision ports
27
108
 
@@ -29,14 +110,21 @@ None.
29
110
 
30
111
  ## Actions and clauses
31
112
 
32
- | Action | Clauses lowered |
33
- | ---------- | ------------------------------------------------- |
34
- | `create` | `agent description`, `moves`, `steps`, `summary` |
35
- | `cancel` | `agent description`, `moves`, `steps`, `summary` |
36
- | `activate` | `agent description`, `moves`, `steps`, `summary` |
37
- | `create` | `agent description`, `moves`, `steps`, `summary` |
38
- | `close` | `agent description`, `moves`, `steps`, `summary` |
39
- | `create` | `agent description`, `examples`, `moves`, `steps` |
40
- | `activate` | `due`, `examples`, `moves`, `steps` |
41
- | `disband` | `agent description`, `examples`, `moves`, `steps` |
42
- | `close` | `agent description`, `examples`, `moves`, `steps` |
113
+ | Action | Clauses lowered |
114
+ | --- | --- |
115
+ | `create` | `agent description`, `moves`, `steps`, `summary` |
116
+ | `cancel` | `agent description`, `moves`, `steps`, `summary` |
117
+ | `activate` | `agent description`, `moves`, `steps`, `summary` |
118
+ | `ready_cycle_[cycle]` | `agent description`, `moves`, `steps`, `summary` |
119
+ | `advance_cycle_[cycle]` | `agent description`, `moves`, `steps`, `summary` |
120
+ | `create` | `agent description`, `moves`, `steps`, `summary`, `unique` |
121
+ | `contribute_cycle_[cycle]` | `due`, `moves`, `sandbox failure point`, `steps`, `summary` |
122
+ | `mark_default_cycle_[cycle]` | `due`, `moves`, `steps`, `summary` |
123
+ | `guarantee_cycle_[cycle]` | `agent description`, `moves`, `steps`, `summary` |
124
+ | `pay_cycle_[cycle]` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
125
+ | `pay_guaranteed_cycle_[cycle]` | `agent description`, `moves`, `steps`, `summary` |
126
+ | `close` | `agent description`, `moves`, `steps`, `summary` |
127
+ | `create` | `agent description`, `examples`, `moves`, `steps` |
128
+ | `activate` | `due`, `examples`, `moves`, `steps` |
129
+ | `disband` | `agent description`, `examples`, `moves`, `steps` |
130
+ | `close` | `agent description`, `examples`, `moves`, `steps` |
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.1.0. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 2.2.0. Do not edit. -->
2
2
 
3
3
  # scheduled
4
4
 
@@ -10,21 +10,104 @@ Source: [`std/money_flows/scheduled.hsx`](../../../std/money_flows/scheduled.hsx
10
10
 
11
11
  ## Parameters
12
12
 
13
- - `payer: party`
14
- - `payee: party`
15
- - `amount: money<C>`
16
- - `count: optional<integer>`
17
- - `every: text`
18
- - `first_due: date`
19
- - `mode: optional<text>`
20
- - `debtor: optional<party>`
21
- - `advance_to: optional<party>`
22
- - `until: optional<condition>`
23
- - `month_end: optional<text>`
24
- - `period_liability: optional<text>`
25
- - `termination_drain: optional<text>`
26
- - `mandate: optional<condition>`
27
- - `derived_amount: optional<unknown>`
13
+ | Parameter | Type | Required | Meaning |
14
+ | --- | --- | --- | --- |
15
+ | `payer` | `party` | Yes | The paying party (or repayment source). |
16
+ | `payee` | `party` | Yes | The beneficiary party receiving installment funds. |
17
+ | `amount` | `money<C>` | Yes | Total amount to partition into installments or recurring charge amount in minor units of currency `C`. |
18
+ | `count` | `optional<integer>` | No | Optional number of installments for installment or obligation modes. |
19
+ | `every` | `text` | Yes | Recurrence cadence duration string (e.g. `"P30D"`, `"P1M"`). |
20
+ | `first_due` | `date` | Yes | Stored date anchor for the first installment or charge. |
21
+ | `mode` | `optional<text>` | No | Optional mode selector (`obligation`). Omit for standard installment plans. |
22
+ | `debtor` | `optional<party>` | No | Optional debtor party when distinct from the payment source in obligation mode. |
23
+ | `advance_to` | `optional<party>` | No | Optional third-party receiving upfront advance disbursements in obligation mode. |
24
+ | `until` | `optional<condition>` | No | Optional condition port triggering cancellation of recurring subscription runs. |
25
+ | `month_end` | `optional<text>` | No | Optional handling policy for calendar month-end adjustments. |
26
+ | `period_liability` | `optional<text>` | No | Optional liability policy for billing periods. |
27
+ | `termination_drain` | `optional<text>` | No | Optional policy for draining balances on early termination. |
28
+ | `mandate` | `optional<condition>` | No | Optional condition port supplying formal debit mandate evidence. |
29
+ | `derived_amount` | `optional<unknown>` | No | Optional calculated markup or fee rules. |
30
+
31
+ Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
32
+
33
+ ## Module guidance
34
+
35
+ Calendar-anchored payments supporting fixed installment plans, recurring subscriptions, or debt obligations.
36
+
37
+ ### Purpose
38
+
39
+ `scheduled` automates time-anchored payment series between one payer and one payee.
40
+ It supports three modes:
41
+
42
+ 1. Installment plan: Partitions a fixed total amount into `count` installments, each collected on its own stored date.
43
+ 2. Open recurring subscription: Charges a recurring amount on an interval `every` until an `until` port fires.
44
+ 3. Debt obligation: Manages legally binding multi-installment debt with delinquency tracking, mandate evidence, and child payment records.
45
+
46
+ ### Selection guidance
47
+
48
+ - vs `metered`: `scheduled` executes calendar-based recurring charges or fixed installment plans.
49
+ `metered` bills variable usage per event based on a committed rate card.
50
+ - vs `rotating_pool`: `scheduled` coordinates one payer to one payee on a calendar.
51
+ `rotating_pool` coordinates a multi-party peer circle where members rotate turns receiving the entire pot.
52
+
53
+ ### Parameters
54
+
55
+ - `payer`: The paying party (or repayment source).
56
+ - `payee`: The beneficiary party receiving installment funds.
57
+ - `amount`: Total amount to partition into installments or recurring charge amount in minor units of currency `C`.
58
+ - `count`: Optional number of installments for installment or obligation modes.
59
+ - `every`: Recurrence cadence duration string (e.g. `"P30D"`, `"P1M"`).
60
+ - `first_due`: Stored date anchor for the first installment or charge.
61
+ - `mode`: Optional mode selector (`obligation`). Omit for standard installment plans.
62
+ - `debtor`: Optional debtor party when distinct from the payment source in obligation mode.
63
+ - `advance_to`: Optional third-party receiving upfront advance disbursements in obligation mode.
64
+ - `until`: Optional condition port triggering cancellation of recurring subscription runs.
65
+ - `month_end`: Optional handling policy for calendar month-end adjustments.
66
+ - `period_liability`: Optional liability policy for billing periods.
67
+ - `termination_drain`: Optional policy for draining balances on early termination.
68
+ - `mandate`: Optional condition port supplying formal debit mandate evidence.
69
+ - `derived_amount`: Optional calculated markup or fee rules.
70
+
71
+ ### Decision ports
72
+
73
+ - `until`: Port terminating recurring subscriptions.
74
+ - `mandate`: Port supplying mandate verification evidence for direct debit obligations.
75
+
76
+ ### Example
77
+
78
+ ```hsx
79
+ program scheduled_example "Scheduled example"
80
+ import { scheduled } from "std/money_flows"
81
+ party payer: business
82
+ party payee: business
83
+ settlement installments = scheduled {
84
+ payer: payer
85
+ payee: payee
86
+ amount: totalAmount: money(SAR)
87
+ count: 3
88
+ every: P30D
89
+ first_due: firstDueAt
90
+ }
91
+ ```
92
+
93
+ ## Declared clauses
94
+
95
+ - `agent description`
96
+ - `aggregate invariants`
97
+ - `capture input`
98
+ - `description`
99
+ - `due`
100
+ - `input`
101
+ - `moves`
102
+ - `partitions`
103
+ - `port`
104
+ - `sandbox failure point`
105
+ - `sets at`
106
+ - `steps`
107
+ - `summary`
108
+ - `title`
109
+
110
+ 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.
28
111
 
29
112
  ## Decision ports
30
113
 
@@ -33,19 +116,21 @@ Source: [`std/money_flows/scheduled.hsx`](../../../std/money_flows/scheduled.hsx
33
116
 
34
117
  ## Actions and clauses
35
118
 
36
- | Action | Clauses lowered |
37
- | ------------------- | -------------------------------------------------------------------------------------------------------------------------- |
38
- | `create` | `agent description`, `steps`, `summary` |
39
- | `create` | `agent description`, `moves`, `steps`, `summary` |
40
- | `approve` | `agent description`, `steps`, `summary` |
41
- | `advance` | `agent description`, `moves`, `steps`, `summary` |
42
- | `delinquent_action` | `due`, `sets at`, `steps`, `summary` |
43
- | `complete` | `due`, `steps`, `summary` |
44
- | `write_off` | `agent description`, `steps`, `summary` |
45
- | `create` | `agent description`, `steps`, `summary` |
46
- | `repay` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `steps`, `summary` |
47
- | `refund` | `agent description`, `moves`, `steps`, `summary` |
48
- | `create` | `agent description`, `steps`, `summary` |
49
- | `open_period` | `due`, `steps`, `summary` |
50
- | `collect_period` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `sandbox failure point`, `steps`, `summary` |
51
- | `until` | `agent description`, `capture input`, `input`, `port`, `steps`, `summary` |
119
+ | Action | Clauses lowered |
120
+ | --- | --- |
121
+ | `create` | `agent description`, `steps`, `summary` |
122
+ | `pay_installment_[i]` | `due`, `moves`, `sandbox failure point`, `steps`, `summary` |
123
+ | `create` | `agent description`, `moves`, `steps`, `summary` |
124
+ | `approve` | `agent description`, `steps`, `summary` |
125
+ | `advance` | `agent description`, `moves`, `steps`, `summary` |
126
+ | `collect_installment_[i]` | `due`, `steps`, `summary` |
127
+ | `[delinquent_action]` | `due`, `sets at`, `steps`, `summary` |
128
+ | `complete` | `due`, `steps`, `summary` |
129
+ | `write_off` | `agent description`, `steps`, `summary` |
130
+ | `create` | `agent description`, `steps`, `summary` |
131
+ | `repay` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `steps`, `summary` |
132
+ | `refund` | `agent description`, `moves`, `steps`, `summary` |
133
+ | `create` | `agent description`, `steps`, `summary` |
134
+ | `open_period` | `due`, `steps`, `summary` |
135
+ | `collect_period` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `sandbox failure point`, `steps`, `summary` |
136
+ | `[until]` | `agent description`, `capture input`, `input`, `port`, `steps`, `summary` |
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.1.0. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 2.2.0. Do not edit. -->
2
2
 
3
3
  # security_deposit
4
4
 
@@ -10,20 +10,112 @@ Source: [`std/money_flows/security_deposit.hsx`](../../../std/money_flows/securi
10
10
 
11
11
  ## Parameters
12
12
 
13
- - `payer: party`
14
- - `holder: party`
15
- - `amount: money<C>`
16
- - `claim: optional<condition>`
17
- - `return: optional<condition>`
18
- - `claim_amount: optional<block>`
19
- - `deadline: optional<date>`
20
- - `claim_to: optional<party>`
21
- - `return_to: optional<party>`
22
- - `memo: optional<text>`
23
- - `claim_input: optional<block>`
24
- - `claim_capture: optional<block>`
25
- - `fund_failure_point: optional<text>`
26
- - `id_prefix_override: optional<text>`
13
+ | Parameter | Type | Required | Meaning |
14
+ | --- | --- | --- | --- |
15
+ | `payer` | `party` | Yes | The customer providing the deposit collateral. |
16
+ | `holder` | `party` | Yes | The merchant or owner holding the deposit rights. |
17
+ | `amount` | `money<C>` | Yes | Total reserved deposit amount in minor units of currency `C`. |
18
+ | `claim` | `optional<condition>` | No | Optional condition port triggering a damage claim. |
19
+ | `return` | `optional<condition>` | No | Optional condition port triggering full return of the deposit. |
20
+ | `claim_amount` | `optional<block>` | No | Optional block defining partial claim logic (`field`, `bound`, `remainder`). |
21
+ | `deadline` | `optional<date>` | No | Optional stored date anchor for automatic deposit release or expiry. |
22
+ | `claim_to` | `optional<party>` | No | Optional alternate destination for claimed funds. |
23
+ | `return_to` | `optional<party>` | No | Optional alternate destination for returned funds. |
24
+ | `memo` | `optional<text>` | No | Optional memo text stored on the deposit record. |
25
+ | `claim_input` | `optional<block>` | No | Optional custom input schema for the claim action. |
26
+ | `claim_capture` | `optional<block>` | No | Optional capture mappings for claim evidence. |
27
+ | `fund_failure_point` | `optional<text>` | No | Optional configuration for deposit funding failure. |
28
+ | `id_prefix_override` | `optional<text>` | No | Optional custom prefix for generated instrument IDs. |
29
+
30
+ Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
31
+
32
+ ## Module guidance
33
+
34
+ Collateral deposit reserved against a payer's account in favor of a holder, returned in full or claimed against damages.
35
+
36
+ ### Purpose
37
+
38
+ `security_deposit` reserves collateral funds for vehicle rentals, property leasing, equipment hire, and security bonds.
39
+ Funds remain held until the rental or lease concludes. The holder can either return the deposit in full
40
+ or assess damages, claim a decided partial amount, and return the exact unspent remainder.
41
+
42
+ ### Selection guidance
43
+
44
+ - vs `held_payment`: `security_deposit` holds collateral where the standard outcome is returning 100% of the funds
45
+ to the payer, and claims are partial damage assessments. `held_payment` holds payment consideration where the
46
+ standard outcome is releasing 100% of the funds to the payee upon delivery.
47
+ - vs `cancellable_booking`: `cancellable_booking` holds booking fees and applies time-based cancellation penalties.
48
+ `security_deposit` holds damage collateral and supports arbitrary damage claims with remainder refund.
49
+
50
+ ### Parameters
51
+
52
+ - `payer`: The customer providing the deposit collateral.
53
+ - `holder`: The merchant or owner holding the deposit rights.
54
+ - `amount`: Total reserved deposit amount in minor units of currency `C`.
55
+ - `claim`: Optional condition port triggering a damage claim.
56
+ - `return`: Optional condition port triggering full return of the deposit.
57
+ - `claim_amount`: Optional block defining partial claim logic (`field`, `bound`, `remainder`).
58
+ - `deadline`: Optional stored date anchor for automatic deposit release or expiry.
59
+ - `claim_to`: Optional alternate destination for claimed funds.
60
+ - `return_to`: Optional alternate destination for returned funds.
61
+ - `memo`: Optional memo text stored on the deposit record.
62
+ - `claim_input`: Optional custom input schema for the claim action.
63
+ - `claim_capture`: Optional capture mappings for claim evidence.
64
+ - `fund_failure_point`: Optional configuration for deposit funding failure.
65
+ - `id_prefix_override`: Optional custom prefix for generated instrument IDs.
66
+
67
+ ### Decision ports
68
+
69
+ - `claim`: Port permitting the holder to submit a damage claim.
70
+ - `return`: Port permitting the holder to return the deposit to the payer.
71
+
72
+ ### Example
73
+
74
+ ```hsx
75
+ program deposit_example "Deposit example"
76
+ import { security_deposit } from "std/money_flows"
77
+ party renter: person
78
+ party owner: business
79
+ settlement security_deposit = security_deposit {
80
+ payer: renter
81
+ holder: owner
82
+ amount: depositAmount: money(SAR)
83
+ claim: port assess_damage
84
+ claim_amount: decided {
85
+ field: damageAmount
86
+ bound: depositAmount
87
+ remainder: return
88
+ }
89
+ return: port return_deposit
90
+ }
91
+ port assess_damage {
92
+ allowed: [owner]
93
+ shape: { damageAmount: money(SAR), evidence: text }
94
+ }
95
+ port return_deposit { allowed: [owner] }
96
+ ```
97
+
98
+ ## Declared clauses
99
+
100
+ - `agent description`
101
+ - `caller parked states`
102
+ - `capture input`
103
+ - `deadline`
104
+ - `decided amount`
105
+ - `description`
106
+ - `dials`
107
+ - `distinct parties`
108
+ - `due`
109
+ - `id prefix`
110
+ - `input`
111
+ - `moves`
112
+ - `port`
113
+ - `sandbox failure point`
114
+ - `steps`
115
+ - `summary`
116
+ - `title`
117
+
118
+ 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.
27
119
 
28
120
  ## Decision ports
29
121
 
@@ -32,15 +124,15 @@ Source: [`std/money_flows/security_deposit.hsx`](../../../std/money_flows/securi
32
124
 
33
125
  ## Actions and clauses
34
126
 
35
- | Action | Clauses lowered |
36
- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
37
- | `create` | `agent description`, `moves`, `steps`, `summary` |
38
- | `place_deposit` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
39
- | `claim_name` | `agent description`, `input`, `moves`, `port`, `steps`, `summary` |
40
- | `return_name` | `agent description`, `capture input`, `input`, `moves`, `port`, `steps`, `summary` |
41
- | `create` | `agent description`, `deadline`, `moves`, `steps`, `summary` |
42
- | `fund` | `agent description`, `deadline`, `moves`, `sandbox failure point`, `steps`, `summary` |
43
- | `claim` | `agent description`, `capture input`, `deadline`, `decided amount`, `input`, `moves`, `port`, `sandbox failure point`, `steps`, `summary` |
44
- | `return` | `agent description`, `deadline`, `moves`, `port`, `steps`, `summary` |
45
- | `expire` | `due`, `moves`, `steps`, `summary` |
46
- | `cancel` | `agent description`, `moves`, `steps`, `summary` |
127
+ | Action | Clauses lowered |
128
+ | --- | --- |
129
+ | `create` | `agent description`, `moves`, `steps`, `summary` |
130
+ | `place_deposit` | `agent description`, `moves`, `sandbox failure point`, `steps`, `summary` |
131
+ | `[claim_name]` | `agent description`, `input`, `moves`, `port`, `steps`, `summary` |
132
+ | `[return_name]` | `agent description`, `capture input`, `input`, `moves`, `port`, `steps`, `summary` |
133
+ | `create` | `agent description`, `deadline`, `moves`, `steps`, `summary` |
134
+ | `fund` | `agent description`, `deadline`, `moves`, `sandbox failure point`, `steps`, `summary` |
135
+ | `claim` | `agent description`, `capture input`, `deadline`, `decided amount`, `input`, `moves`, `port`, `sandbox failure point`, `steps`, `summary` |
136
+ | `return` | `agent description`, `deadline`, `moves`, `port`, `steps`, `summary` |
137
+ | `expire` | `due`, `moves`, `steps`, `summary` |
138
+ | `cancel` | `agent description`, `moves`, `steps`, `summary` |
@@ -1,4 +1,4 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.1.0. Do not edit. -->
1
+ <!-- Generated by scripts/docs/build.ts for HSX 2.2.0. Do not edit. -->
2
2
 
3
3
  # settlement_batch
4
4
 
@@ -10,15 +10,96 @@ Source: [`std/money_flows/settlement_batch.hsx`](../../../std/money_flows/settle
10
10
 
11
11
  ## Parameters
12
12
 
13
- - `settlement_account: party`
14
- - `source_capture_refs: text`
15
- - `fee_entries: text`
16
- - `external_reversal_offsets: text`
17
- - `close_trigger: date`
18
- - `payout_destination: party`
19
- - `negative_position: text`
20
- - `payout_acknowledgement: condition`
21
- - `payout_beneficiary_ref: text`
13
+ | Parameter | Type | Required | Meaning |
14
+ | --- | --- | --- | --- |
15
+ | `settlement_account` | `party` | Yes | The source clearing account holding captured funds and paying the batch. |
16
+ | `source_capture_refs` | `text` | Yes | Binding name for gross capture references included in the batch. |
17
+ | `fee_entries` | `text` | Yes | Binding name for fee deductions applied to the batch. |
18
+ | `external_reversal_offsets` | `text` | Yes | Binding name for reversal adjustments applied to the batch. |
19
+ | `close_trigger` | `date` | Yes | Date when the batch closes and ceases accepting new transaction entries. |
20
+ | `payout_destination` | `party` | Yes | The merchant or partner account receiving the net payout. |
21
+ | `negative_position` | `text` | Yes | Policy when calculated net payable is zero or negative (`reject`). |
22
+ | `payout_acknowledgement` | `condition` | Yes | Condition port confirming bank receipt of the payout. |
23
+ | `payout_beneficiary_ref` | `text` | Yes | Beneficiary identifier for external bank dispatch. |
24
+
25
+ Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
26
+
27
+ ## Module guidance
28
+
29
+ Periodic aggregation of capture lineage, fee entries, and adjustments into a single net calculated payout.
30
+
31
+ ### Purpose
32
+
33
+ `settlement_batch` settles merchant balances, marketplace vendor earnings, and partner clearing accounts.
34
+ Individual payment captures, platform fees, and reversal adjustments accumulate into an open batch over a period.
35
+ On `close_trigger`, the batch freezes. The platform calculates the signed net payable from gross captures plus credit
36
+ adjustments minus debit adjustments. If positive, an outbound bank payout is instructed and acknowledged.
37
+
38
+ ### Selection guidance
39
+
40
+ - vs `reconciled_payout`: `settlement_batch` aggregates multiple transactions and adjustments over a billing cycle
41
+ to compute a single net payable. `reconciled_payout` manages bank instruction dispatch and statement line reconciliation
42
+ for an individual payout amount.
43
+ - vs `weighted_distribution`: `settlement_batch` consolidates many inbound transactions into one net outbound payout.
44
+ `weighted_distribution` splits one funding pool into many recipient payouts.
45
+
46
+ ### Parameters
47
+
48
+ - `settlement_account`: The source clearing account holding captured funds and paying the batch.
49
+ - `source_capture_refs`: Binding name for gross capture references included in the batch.
50
+ - `fee_entries`: Binding name for fee deductions applied to the batch.
51
+ - `external_reversal_offsets`: Binding name for reversal adjustments applied to the batch.
52
+ - `close_trigger`: Date when the batch closes and ceases accepting new transaction entries.
53
+ - `payout_destination`: The merchant or partner account receiving the net payout.
54
+ - `negative_position`: Policy when calculated net payable is zero or negative (`reject`).
55
+ - `payout_acknowledgement`: Condition port confirming bank receipt of the payout.
56
+ - `payout_beneficiary_ref`: Beneficiary identifier for external bank dispatch.
57
+
58
+ ### Decision ports
59
+
60
+ - `payout_acknowledgement`: Port recording external bank or partner receipt confirmation.
61
+
62
+ ### Example
63
+
64
+ ```hsx
65
+ program settlement_batch_example "Settlement batch example"
66
+ import { settlement_batch } from "std/money_flows"
67
+ party settlement_account: business
68
+ party payout_destination: business
69
+ settlement batch = settlement_batch {
70
+ settlement_account: settlement_account
71
+ source_capture_refs: captureReference
72
+ fee_entries: feeReference
73
+ external_reversal_offsets: reversalReference
74
+ close_trigger: closeAt
75
+ payout_destination: payout_destination
76
+ negative_position: reject
77
+ payout_acknowledgement: port acknowledge_payout
78
+ payout_beneficiary_ref: payoutBeneficiaryId
79
+ }
80
+ port acknowledge_payout {
81
+ allowed: [payout_destination]
82
+ shape: { acknowledgementReference: text }
83
+ }
84
+ ```
85
+
86
+ ## Declared clauses
87
+
88
+ - `agent description`
89
+ - `capture input`
90
+ - `description`
91
+ - `due`
92
+ - `id prefix`
93
+ - `input`
94
+ - `moves`
95
+ - `payout`
96
+ - `port`
97
+ - `reconcile`
98
+ - `steps`
99
+ - `summary`
100
+ - `title`
101
+
102
+ 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.
22
103
 
23
104
  ## Decision ports
24
105
 
@@ -26,17 +107,17 @@ Source: [`std/money_flows/settlement_batch.hsx`](../../../std/money_flows/settle
26
107
 
27
108
  ## Actions and clauses
28
109
 
29
- | Action | Clauses lowered |
30
- | ------------------------ | ------------------------------------------------------------------------------------------------- |
31
- | `create` | `agent description`, `moves`, `steps`, `summary` |
32
- | `close` | `due`, `moves`, `steps`, `summary` |
33
- | `calculate` | `agent description`, `computes signed_sum`, `moves`, `steps`, `summary` |
34
- | `approve` | `agent description`, `moves`, `steps`, `summary` |
35
- | `instruct` | `agent description`, `moves`, `payout`, `steps`, `summary` |
36
- | `payout_acknowledgement` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `steps`, `summary` |
37
- | `reconcile` | `due`, `moves`, `reconcile`, `steps`, `summary` |
38
- | `create` | `agent description`, `moves`, `steps`, `summary` |
39
- | `accrue` | `agent description`, `moves`, `steps`, `summary` |
40
- | `create` | `agent description`, `moves`, `steps`, `summary` |
41
- | `adjust` | `agent description`, `moves`, `steps`, `summary` |
42
- | `correct` | `agent description`, `moves`, `steps`, `summary` |
110
+ | Action | Clauses lowered |
111
+ | --- | --- |
112
+ | `create` | `agent description`, `moves`, `steps`, `summary` |
113
+ | `close` | `due`, `moves`, `steps`, `summary` |
114
+ | `calculate` | `agent description`, `moves`, `steps`, `summary` |
115
+ | `approve` | `agent description`, `moves`, `steps`, `summary` |
116
+ | `instruct` | `agent description`, `moves`, `payout`, `steps`, `summary` |
117
+ | `[payout_acknowledgement]` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `steps`, `summary` |
118
+ | `reconcile` | `due`, `moves`, `reconcile`, `steps`, `summary` |
119
+ | `create` | `agent description`, `moves`, `steps`, `summary` |
120
+ | `accrue` | `agent description`, `moves`, `steps`, `summary` |
121
+ | `create` | `agent description`, `moves`, `steps`, `summary` |
122
+ | `adjust` | `agent description`, `moves`, `steps`, `summary` |
123
+ | `correct` | `agent description`, `moves`, `steps`, `summary` |