@hyperscale0/hsx 2.4.1 → 3.0.1
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.
- package/CHANGELOG.md +4 -406
- package/README.md +3 -92
- package/dist/src/ast.d.ts +99 -310
- package/dist/src/ast.d.ts.map +1 -1
- package/dist/src/ast.js +16 -69
- package/dist/src/ast.js.map +1 -1
- package/dist/src/cli.d.ts +6 -19
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +77 -315
- package/dist/src/cli.js.map +1 -1
- package/dist/src/compile.d.ts +23 -73
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +1113 -148
- package/dist/src/compile.js.map +1 -1
- package/dist/src/cost.d.ts +8 -77
- package/dist/src/cost.d.ts.map +1 -1
- package/dist/src/cost.js +13 -422
- package/dist/src/cost.js.map +1 -1
- package/dist/src/format.d.ts +8 -7
- package/dist/src/format.d.ts.map +1 -1
- package/dist/src/format.js +9 -175
- package/dist/src/format.js.map +1 -1
- package/dist/src/headers.d.ts +35 -0
- package/dist/src/headers.d.ts.map +1 -0
- package/dist/src/headers.js +108 -0
- package/dist/src/headers.js.map +1 -0
- package/dist/src/index.d.ts +6 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/lex.d.ts +8 -28
- package/dist/src/lex.d.ts.map +1 -1
- package/dist/src/lex.js +88 -146
- package/dist/src/lex.js.map +1 -1
- package/dist/src/parse.d.ts +4 -17
- package/dist/src/parse.d.ts.map +1 -1
- package/dist/src/parse.js +402 -1040
- package/dist/src/parse.js.map +1 -1
- package/dist/src/std-bundle.d.ts.map +1 -1
- package/dist/src/std-bundle.js +12 -20
- package/dist/src/std-bundle.js.map +1 -1
- package/dist/src/std-library.d.ts +1 -1
- package/dist/src/std-library.d.ts.map +1 -1
- package/dist/src/std-library.js +1 -5
- package/dist/src/std-library.js.map +1 -1
- package/dist/src/tunables.d.ts +7 -0
- package/dist/src/tunables.d.ts.map +1 -0
- package/dist/src/tunables.js +26 -0
- package/dist/src/tunables.js.map +1 -0
- package/dist/src/version.d.ts +2 -4
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +2 -4
- package/dist/src/version.js.map +1 -1
- package/docs/README.md +179 -41
- package/docs/headers.md +44 -0
- package/examples/cost-table.json +99 -751
- package/examples/library.hsx +59 -0
- package/package.json +9 -17
- package/src/ast.ts +82 -441
- package/src/cli.ts +78 -362
- package/src/compile.ts +1535 -247
- package/src/cost.ts +28 -671
- package/src/format.ts +12 -256
- package/src/headers.ts +126 -0
- package/src/index.ts +7 -39
- package/src/lex.ts +99 -195
- package/src/parse.ts +403 -1209
- package/src/std-bundle.ts +12 -20
- package/src/std-library.ts +2 -7
- package/src/tunables.ts +31 -0
- package/src/version.ts +2 -5
- package/std/approvals.hsx +17 -0
- package/std/cards.hsx +63 -0
- package/std/collections.hsx +31 -0
- package/std/escrow.hsx +43 -0
- package/std/financing.hsx +372 -0
- package/std/insurance.hsx +59 -0
- package/std/lending.hsx +115 -0
- package/std/marketplace.hsx +24 -0
- package/std/money.hsx +195 -0
- package/std/savings.hsx +44 -0
- package/std/travel.hsx +98 -0
- package/std/wallet.hsx +41 -0
- package/dist/src/diagnostics.d.ts +0 -13
- package/dist/src/diagnostics.d.ts.map +0 -1
- package/dist/src/diagnostics.js +0 -587
- package/dist/src/diagnostics.js.map +0 -1
- package/dist/src/emit.d.ts +0 -51
- package/dist/src/emit.d.ts.map +0 -1
- package/dist/src/emit.js +0 -192
- package/dist/src/emit.js.map +0 -1
- package/dist/src/entry-overrides.d.ts +0 -58
- package/dist/src/entry-overrides.d.ts.map +0 -1
- package/dist/src/entry-overrides.js +0 -284
- package/dist/src/entry-overrides.js.map +0 -1
- package/dist/src/ir.d.ts +0 -73
- package/dist/src/ir.d.ts.map +0 -1
- package/dist/src/ir.js +0 -15
- package/dist/src/ir.js.map +0 -1
- package/dist/src/limits.d.ts +0 -23
- package/dist/src/limits.d.ts.map +0 -1
- package/dist/src/limits.js +0 -23
- package/dist/src/limits.js.map +0 -1
- package/dist/src/lsp/server.d.ts +0 -32
- package/dist/src/lsp/server.d.ts.map +0 -1
- package/dist/src/lsp/server.js +0 -391
- package/dist/src/lsp/server.js.map +0 -1
- package/dist/src/modules.d.ts +0 -38
- package/dist/src/modules.d.ts.map +0 -1
- package/dist/src/modules.js +0 -372
- package/dist/src/modules.js.map +0 -1
- package/dist/src/typecheck.d.ts +0 -8
- package/dist/src/typecheck.d.ts.map +0 -1
- package/dist/src/typecheck.js +0 -4160
- package/dist/src/typecheck.js.map +0 -1
- package/docs/guide/01-first-program.md +0 -24
- package/docs/guide/02-money.md +0 -25
- package/docs/guide/03-instruments.md +0 -93
- package/docs/guide/04-lifecycles.md +0 -40
- package/docs/guide/05-fees-and-splits.md +0 -45
- package/docs/guide/06-schedules.md +0 -26
- package/docs/guide/07-composition.md +0 -52
- package/docs/guide/08-writing-a-module.md +0 -85
- package/docs/guide/09-cost.md +0 -24
- package/docs/guide/10-diagnostics.md +0 -27
- package/docs/llms-full.txt +0 -3684
- package/docs/llms.txt +0 -44
- package/docs/piece-plans.md +0 -120
- package/docs/playground.md +0 -55
- package/docs/reference/cli.md +0 -36
- package/docs/reference/diagnostics.md +0 -901
- package/docs/reference/grammar.md +0 -38
- package/docs/reference/std/advance.md +0 -112
- package/docs/reference/std/cancellable_booking.md +0 -159
- package/docs/reference/std/captured_payment.md +0 -115
- package/docs/reference/std/conditional_disbursement.md +0 -101
- package/docs/reference/std/credit_facility.md +0 -108
- package/docs/reference/std/held_payment.md +0 -173
- package/docs/reference/std/instant_transfer.md +0 -97
- package/docs/reference/std/metered.md +0 -89
- package/docs/reference/std/pooled_split.md +0 -95
- package/docs/reference/std/premium_forward.md +0 -119
- package/docs/reference/std/reconciled_payout.md +0 -103
- package/docs/reference/std/rotating_pool.md +0 -130
- package/docs/reference/std/scheduled.md +0 -136
- package/docs/reference/std/security_deposit.md +0 -138
- package/docs/reference/std/settlement_batch.md +0 -123
- package/docs/reference/std/swap.md +0 -133
- package/docs/reference/std/threshold_pool.md +0 -138
- package/docs/reference/std/weighted_distribution.md +0 -135
- package/docs/reference/types.md +0 -61
- package/docs/reference/udl-output.md +0 -13
- package/examples/01-first-program/README.md +0 -45
- package/examples/01-first-program/tip-jar.hsx +0 -17
- package/examples/02-imports-and-modules/README.md +0 -96
- package/examples/02-imports-and-modules/photo-booth.hsx +0 -37
- package/examples/03-diagnostics/README.md +0 -68
- package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
- package/examples/03-diagnostics/corner-shop.hsx +0 -19
- package/examples/04-complete-product/README.md +0 -84
- package/examples/04-complete-product/study-hall.hsx +0 -67
- package/examples/05-authored-instrument/README.md +0 -5
- package/examples/05-authored-instrument/payment.hsx +0 -37
- package/examples/05-watch-club/README.md +0 -6
- package/examples/05-watch-club/watch-club.hsx +0 -123
- package/examples/README.md +0 -48
- package/examples/advance/README.md +0 -3
- package/examples/advance/advance.hsx +0 -13
- package/examples/advance/advance.udl +0 -367
- package/examples/cancellable_booking/README.md +0 -3
- package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
- package/examples/cancellable_booking/cancellable_booking.udl +0 -413
- package/examples/captured_payment/README.md +0 -3
- package/examples/captured_payment/captured_payment.hsx +0 -17
- package/examples/captured_payment/captured_payment.udl +0 -686
- package/examples/conditional_disbursement/README.md +0 -3
- package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -15
- package/examples/conditional_disbursement/conditional_disbursement.udl +0 -418
- package/examples/credit_facility/README.md +0 -3
- package/examples/credit_facility/credit_facility.hsx +0 -24
- package/examples/credit_facility/credit_facility.udl +0 -1396
- package/examples/held_payment/README.md +0 -3
- package/examples/held_payment/held_payment.hsx +0 -13
- package/examples/held_payment/held_payment.udl +0 -569
- package/examples/instant_transfer/README.md +0 -3
- package/examples/instant_transfer/instant_transfer.hsx +0 -16
- package/examples/instant_transfer/instant_transfer.udl +0 -376
- package/examples/metered/README.md +0 -3
- package/examples/metered/metered.hsx +0 -13
- package/examples/metered/metered.udl +0 -253
- package/examples/pooled_split/README.md +0 -3
- package/examples/pooled_split/pooled_split.hsx +0 -15
- package/examples/pooled_split/pooled_split.udl +0 -432
- package/examples/premium_forward/README.md +0 -3
- package/examples/premium_forward/premium_forward.hsx +0 -19
- package/examples/premium_forward/premium_forward.udl +0 -604
- package/examples/reconciled_payout/README.md +0 -3
- package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
- package/examples/reconciled_payout/reconciled_payout.udl +0 -312
- package/examples/rotating_pool/README.md +0 -3
- package/examples/rotating_pool/rotating_pool.hsx +0 -18
- package/examples/rotating_pool/rotating_pool.udl +0 -4370
- package/examples/scheduled/README.md +0 -3
- package/examples/scheduled/scheduled.hsx +0 -12
- package/examples/scheduled/scheduled.udl +0 -355
- package/examples/security_deposit/README.md +0 -3
- package/examples/security_deposit/security_deposit.hsx +0 -21
- package/examples/security_deposit/security_deposit.udl +0 -320
- package/examples/settlement_batch/README.md +0 -3
- package/examples/settlement_batch/settlement_batch.hsx +0 -19
- package/examples/settlement_batch/settlement_batch.udl +0 -757
- package/examples/swap/README.md +0 -3
- package/examples/swap/swap.hsx +0 -19
- package/examples/swap/swap.udl +0 -892
- package/examples/threshold_pool/README.md +0 -3
- package/examples/threshold_pool/threshold_pool.hsx +0 -16
- package/examples/threshold_pool/threshold_pool.udl +0 -680
- package/examples/weighted_distribution/README.md +0 -3
- package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
- package/examples/weighted_distribution/weighted_distribution.udl +0 -348
- package/skills/hsx/SKILL.md +0 -449
- package/src/diagnostics.ts +0 -620
- package/src/emit.ts +0 -282
- package/src/entry-overrides.ts +0 -428
- package/src/ir.ts +0 -113
- package/src/limits.ts +0 -22
- package/src/lsp/server.ts +0 -460
- package/src/modules.ts +0 -452
- package/src/typecheck.ts +0 -5515
- package/std/SEMANTICS.md +0 -44
- package/std/money_flows/advance.hsx +0 -235
- package/std/money_flows/cancellable_booking.hsx +0 -402
- package/std/money_flows/captured_payment.hsx +0 -220
- package/std/money_flows/conditional_disbursement.hsx +0 -226
- package/std/money_flows/credit_facility.hsx +0 -214
- package/std/money_flows/held_payment.hsx +0 -812
- package/std/money_flows/index.hsx +0 -4
- package/std/money_flows/instant_transfer.hsx +0 -231
- package/std/money_flows/metered.hsx +0 -104
- package/std/money_flows/pooled_split.hsx +0 -109
- package/std/money_flows/premium_forward.hsx +0 -307
- package/std/money_flows/reconciled_payout.hsx +0 -119
- package/std/money_flows/rotating_pool.hsx +0 -305
- package/std/money_flows/scheduled.hsx +0 -599
- package/std/money_flows/security_deposit.hsx +0 -248
- package/std/money_flows/settlement_batch.hsx +0 -173
- package/std/money_flows/swap.hsx +0 -1192
- package/std/money_flows/threshold_pool.hsx +0 -307
- package/std/money_flows/weighted_distribution.hsx +0 -237
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
<!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
# threshold_pool
|
|
4
|
-
|
|
5
|
-
Source: [`std/money_flows/threshold_pool.hsx`](../../../std/money_flows/threshold_pool.hsx)
|
|
6
|
-
|
|
7
|
-
## Export
|
|
8
|
-
|
|
9
|
-
`threshold_pool<C>`
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
| Parameter | Type | Required | Meaning |
|
|
14
|
-
| --- | --- | --- | --- |
|
|
15
|
-
| `contributor` | `optional<party>` | No | The party representing individual contributors. |
|
|
16
|
-
| `beneficiary` | `optional<party>` | No | The beneficiary party receiving the settled pool if the target is met. |
|
|
17
|
-
| `target` | `money<C>` | Yes | Total target funding threshold in minor units of currency `C`. |
|
|
18
|
-
| `commitment` | `money<C>` | Yes | Binding name for individual contributor commitment amounts. |
|
|
19
|
-
| `max_contributors` | `optional<integer>` | No | Optional maximum count of admitted contributors. |
|
|
20
|
-
| `close_by` | `date` | Yes | Stored date deadline by which the target must be met. |
|
|
21
|
-
| `close_policy` | `optional<text>` | No | Policy determining pool close behavior (`threshold`). |
|
|
22
|
-
| `overfund_policy` | `optional<text>` | No | Policy on commitments exceeding the target (`reject`). |
|
|
23
|
-
| `cancel_policy` | `optional<text>` | No | Contributor withdrawal policy before close (`before_close`). |
|
|
24
|
-
| `fail_policy` | `optional<text>` | No | Refund policy if the pool fails to hit target (`whole_commitment_refund`). |
|
|
25
|
-
| `beneficiary_account` | `optional<account<C>>` | No | Optional direct account reference for the beneficiary. |
|
|
26
|
-
| `memo` | `optional<text>` | No | Optional memo text stored on the pool. |
|
|
27
|
-
| `contribution_instrument` | `optional<block>` | No | Optional custom contribution child instrument block. |
|
|
28
|
-
| `wording` | `optional<block>` | No | Optional custom UI wording block. |
|
|
29
|
-
| `funding_join` | `optional<block>` | No | funding_join configures the flat contribution-instrument mode for a priced obligation. |
|
|
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
|
-
All-or-nothing capital accumulation pool collecting commitments toward a target amount before a close deadline.
|
|
36
|
-
|
|
37
|
-
### Purpose
|
|
38
|
-
|
|
39
|
-
`threshold_pool` powers all-or-nothing crowdfunding, capital calls, collective purchasing, and consortium rounds.
|
|
40
|
-
Multiple contributors pledge commitments toward a monetary `target`. Commitments sit in escrow until the pool
|
|
41
|
-
reaches the target before `close_by` (activating and settling funds to the beneficiary), or fails (triggering full refunds).
|
|
42
|
-
|
|
43
|
-
### Selection guidance
|
|
44
|
-
|
|
45
|
-
- vs `rotating_pool`: `threshold_pool` is all-or-nothing fundraising where many contributors fund a single beneficiary.
|
|
46
|
-
`rotating_pool` is a peer savings circle where members contribute identically in each cycle and rotate who receives the pot.
|
|
47
|
-
- vs `weighted_distribution`: `threshold_pool` pools funds inward from many contributors to one beneficiary.
|
|
48
|
-
`weighted_distribution` pays funds outward from one source pool to many weighted recipients.
|
|
49
|
-
|
|
50
|
-
### Parameters
|
|
51
|
-
|
|
52
|
-
- `contributor`: The party representing individual contributors.
|
|
53
|
-
- `beneficiary`: The beneficiary party receiving the settled pool if the target is met.
|
|
54
|
-
- `target`: Total target funding threshold in minor units of currency `C`.
|
|
55
|
-
- `commitment`: Binding name for individual contributor commitment amounts.
|
|
56
|
-
- `max_contributors`: Optional maximum count of admitted contributors.
|
|
57
|
-
- `close_by`: Stored date deadline by which the target must be met.
|
|
58
|
-
- `close_policy`: Policy determining pool close behavior (`threshold`).
|
|
59
|
-
- `overfund_policy`: Policy on commitments exceeding the target (`reject`).
|
|
60
|
-
- `cancel_policy`: Contributor withdrawal policy before close (`before_close`).
|
|
61
|
-
- `fail_policy`: Refund policy if the pool fails to hit target (`whole_commitment_refund`).
|
|
62
|
-
- `beneficiary_account`: Optional direct account reference for the beneficiary.
|
|
63
|
-
- `memo`: Optional memo text stored on the pool.
|
|
64
|
-
- `contribution_instrument`: Optional custom contribution child instrument block.
|
|
65
|
-
- `wording`: Optional custom UI wording block.
|
|
66
|
-
|
|
67
|
-
### Decision ports
|
|
68
|
-
|
|
69
|
-
None. Lifecycle transitions (`activate`, `fail`, `close`) are driven by target threshold evaluation and the `close_by` date.
|
|
70
|
-
|
|
71
|
-
### Example
|
|
72
|
-
|
|
73
|
-
```hsx
|
|
74
|
-
program capital_pool_example "Capital pool example"
|
|
75
|
-
import { threshold_pool } from "std/money_flows"
|
|
76
|
-
party contributor: person
|
|
77
|
-
party company: business
|
|
78
|
-
settlement round = threshold_pool {
|
|
79
|
-
contributor: contributor
|
|
80
|
-
beneficiary: company
|
|
81
|
-
target: targetAmount: money(SAR)
|
|
82
|
-
commitment: commitmentAmount: money(SAR)
|
|
83
|
-
max_contributors: 100
|
|
84
|
-
close_by: closeBy
|
|
85
|
-
close_policy: threshold
|
|
86
|
-
overfund_policy: reject
|
|
87
|
-
cancel_policy: before_close
|
|
88
|
-
fail_policy: whole_commitment_refund
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Funding join
|
|
93
|
-
|
|
94
|
-
funding_join configures the flat contribution-instrument mode for a priced
|
|
95
|
-
obligation. Opening freezes minimum ticket, investor cap, profit and schedule
|
|
96
|
-
terms. Closing binds the obligation, freezes committed ticket identities and
|
|
97
|
-
moves the principal once into its funding account. A ticket's engine-owned
|
|
98
|
-
collection action has no independent payment or clock trigger.
|
|
99
|
-
|
|
100
|
-
## Declared clauses
|
|
101
|
-
|
|
102
|
-
- `agent description`
|
|
103
|
-
- `aggregate invariants`
|
|
104
|
-
- `caller parked states`
|
|
105
|
-
- `description`
|
|
106
|
-
- `due`
|
|
107
|
-
- `examples`
|
|
108
|
-
- `funding`
|
|
109
|
-
- `id prefix`
|
|
110
|
-
- `input`
|
|
111
|
-
- `moves`
|
|
112
|
-
- `steps`
|
|
113
|
-
- `summary`
|
|
114
|
-
- `title`
|
|
115
|
-
- `updates`
|
|
116
|
-
|
|
117
|
-
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.
|
|
118
|
-
|
|
119
|
-
## Decision ports
|
|
120
|
-
|
|
121
|
-
None.
|
|
122
|
-
|
|
123
|
-
## Actions and clauses
|
|
124
|
-
|
|
125
|
-
| Action | Clauses lowered |
|
|
126
|
-
| --- | --- |
|
|
127
|
-
| `create` | `agent description`, `moves`, `steps`, `summary` |
|
|
128
|
-
| `activate` | `due`, `moves`, `steps`, `summary` |
|
|
129
|
-
| `fail` | `due`, `moves`, `steps`, `summary` |
|
|
130
|
-
| `close` | `agent description`, `moves`, `steps`, `summary` |
|
|
131
|
-
| `create` | `agent description`, `moves`, `steps`, `summary` |
|
|
132
|
-
| `cancel` | `agent description`, `moves`, `steps`, `summary` |
|
|
133
|
-
| `collect` | `agent description`, `moves`, `steps`, `summary` |
|
|
134
|
-
| `refund` | `agent description`, `moves`, `steps`, `summary` |
|
|
135
|
-
| `create` | `agent description`, `examples`, `moves`, `steps` |
|
|
136
|
-
| `activate` | `due`, `examples`, `moves`, `steps` |
|
|
137
|
-
| `fail` | `due`, `examples`, `moves`, `steps` |
|
|
138
|
-
| `close` | `agent description`, `examples`, `funding`, `input`, `moves`, `steps`, `updates` |
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
<!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
# weighted_distribution
|
|
4
|
-
|
|
5
|
-
Source: [`std/money_flows/weighted_distribution.hsx`](../../../std/money_flows/weighted_distribution.hsx)
|
|
6
|
-
|
|
7
|
-
## Export
|
|
8
|
-
|
|
9
|
-
`weighted_distribution<C>`
|
|
10
|
-
|
|
11
|
-
## Parameters
|
|
12
|
-
|
|
13
|
-
| Parameter | Type | Required | Meaning |
|
|
14
|
-
| --- | --- | --- | --- |
|
|
15
|
-
| `source` | `optional<party>` | No | The funding party providing the distribution pool. |
|
|
16
|
-
| `recipient` | `optional<party>` | No | The party representing entitled recipients. |
|
|
17
|
-
| `amount` | `optional<money<C>>` | No | Total distribution pool in minor units of currency `C`. |
|
|
18
|
-
| `record_at` | `optional<date>` | No | Date when entitlement eligibility is established. |
|
|
19
|
-
| `weight` | `optional<money<C>>` | No | Binding name for individual recipient weight amounts. |
|
|
20
|
-
| `max_recipients` | `optional<integer>` | No | Exact number of entitlement rows required before snapshotting. |
|
|
21
|
-
| `snapshot` | `optional<condition>` | No | Port freezing the entitlement set against stored decision evidence. |
|
|
22
|
-
| `rounding_policy` | `optional<text>` | No | Mathematical rounding policy (`largest_remainder`). |
|
|
23
|
-
| `withholding_policy` | `optional<text>` | No | Tax or withholding policy (`refuse`). |
|
|
24
|
-
| `correction_policy` | `optional<text>` | No | Error correction policy (`new_distribution`). |
|
|
25
|
-
| `flat` | `optional<block>` | No | Optional flat distribution configuration block. |
|
|
26
|
-
| `receipts` | `optional<block>` | No | receipts selects repeated distributions from immutable allocation receipts. |
|
|
27
|
-
| `id_prefix_override` | `optional<text>` | No | Optional custom prefix for generated instrument IDs. |
|
|
28
|
-
|
|
29
|
-
Required means required by the template signature. A selected mode may also need parameters marked optional; the guidance below describes those combinations.
|
|
30
|
-
|
|
31
|
-
## Module guidance
|
|
32
|
-
|
|
33
|
-
Frozen largest-remainder distribution splitting one pool across dynamic recipients by recorded weights.
|
|
34
|
-
|
|
35
|
-
### Purpose
|
|
36
|
-
|
|
37
|
-
`weighted_distribution` distributes dividend pools, creator royalties, liquidation proceeds, and investment returns.
|
|
38
|
-
Child entitlement rows are recorded for each recipient with their respective weight. Once all recipients are recorded,
|
|
39
|
-
an evidence-backed snapshot freezes the entitlement set. Each recipient is then paid their exact largest-remainder
|
|
40
|
-
share such that all payouts sum exactly to `amount` without rounding leaks.
|
|
41
|
-
|
|
42
|
-
### Selection guidance
|
|
43
|
-
|
|
44
|
-
- vs `pooled_split`: `weighted_distribution` handles dynamic recipient rosters recorded as child rows and frozen
|
|
45
|
-
via snapshot. `pooled_split` hardcodes a fixed set of recipients and static percentages at definition time.
|
|
46
|
-
- vs `settlement_batch`: `weighted_distribution` splits one funding pool out to many recipients.
|
|
47
|
-
`settlement_batch` aggregates many inbound charges and adjustments into a single net payout.
|
|
48
|
-
|
|
49
|
-
### Parameters
|
|
50
|
-
|
|
51
|
-
- `source`: The funding party providing the distribution pool.
|
|
52
|
-
- `recipient`: The party representing entitled recipients.
|
|
53
|
-
- `amount`: Total distribution pool in minor units of currency `C`.
|
|
54
|
-
- `record_at`: Date when entitlement eligibility is established.
|
|
55
|
-
- `weight`: Binding name for individual recipient weight amounts.
|
|
56
|
-
- `max_recipients`: Exact number of entitlement rows required before snapshotting.
|
|
57
|
-
- `snapshot`: Port freezing the entitlement set against stored decision evidence.
|
|
58
|
-
- `rounding_policy`: Mathematical rounding policy (`largest_remainder`).
|
|
59
|
-
- `withholding_policy`: Tax or withholding policy (`refuse`).
|
|
60
|
-
- `correction_policy`: Error correction policy (`new_distribution`).
|
|
61
|
-
- `flat`: Optional flat distribution configuration block.
|
|
62
|
-
- `id_prefix_override`: Optional custom prefix for generated instrument IDs.
|
|
63
|
-
|
|
64
|
-
### Decision ports
|
|
65
|
-
|
|
66
|
-
- `snapshot`: Port freezing the entitlement set with an evidence reference, preventing further entries.
|
|
67
|
-
|
|
68
|
-
### Example
|
|
69
|
-
|
|
70
|
-
```hsx
|
|
71
|
-
program weighted_distribution_example "Weighted distribution example"
|
|
72
|
-
import { weighted_distribution } from "std/money_flows"
|
|
73
|
-
party distribution_source: business
|
|
74
|
-
party recipient: business
|
|
75
|
-
settlement proceeds = weighted_distribution {
|
|
76
|
-
source: distribution_source
|
|
77
|
-
recipient: recipient
|
|
78
|
-
amount: distributableAmount: money(SAR)
|
|
79
|
-
weight: entitlementWeight: money(SAR)
|
|
80
|
-
max_recipients: 12
|
|
81
|
-
record_at: recordAt
|
|
82
|
-
snapshot: port snapshot_entitlements
|
|
83
|
-
rounding_policy: largest_remainder
|
|
84
|
-
withholding_policy: refuse
|
|
85
|
-
correction_policy: new_distribution
|
|
86
|
-
}
|
|
87
|
-
port snapshot_entitlements {
|
|
88
|
-
allowed: [distribution_source]
|
|
89
|
-
shape: { evidenceReference: text }
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Receipt-backed distributions
|
|
94
|
-
|
|
95
|
-
receipts selects repeated distributions from immutable allocation receipts.
|
|
96
|
-
It names round, receipt, path, mode (cash or loss), fee_bps and vat_bps.
|
|
97
|
-
The funding snapshot owns ticket weights and original wallet destinations.
|
|
98
|
-
Cash floors each ratio after fee and fee VAT; a named account receives residual.
|
|
99
|
-
Loss assigns principal by largest remainder without cash, fee or VAT.
|
|
100
|
-
Each receipt is consumed once; a new receipt may fund a new distribution record.
|
|
101
|
-
This mode does not use caller-entered weights or a once-only settled principal pool.
|
|
102
|
-
|
|
103
|
-
## Declared clauses
|
|
104
|
-
|
|
105
|
-
- `agent description`
|
|
106
|
-
- `aggregate invariants`
|
|
107
|
-
- `capture input`
|
|
108
|
-
- `description`
|
|
109
|
-
- `due`
|
|
110
|
-
- `id prefix`
|
|
111
|
-
- `input`
|
|
112
|
-
- `moves`
|
|
113
|
-
- `port`
|
|
114
|
-
- `requires refs`
|
|
115
|
-
- `steps`
|
|
116
|
-
- `summary`
|
|
117
|
-
- `title`
|
|
118
|
-
|
|
119
|
-
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.
|
|
120
|
-
|
|
121
|
-
## Decision ports
|
|
122
|
-
|
|
123
|
-
- `snapshot`
|
|
124
|
-
|
|
125
|
-
## Actions and clauses
|
|
126
|
-
|
|
127
|
-
| Action | Clauses lowered |
|
|
128
|
-
| --- | --- |
|
|
129
|
-
| `create` | `agent description`, `moves`, `steps`, `summary` |
|
|
130
|
-
| `[snapshot]` | `agent description`, `capture input`, `description`, `input`, `moves`, `port`, `steps`, `summary` |
|
|
131
|
-
| `create` | `agent description`, `moves`, `steps`, `summary` |
|
|
132
|
-
| `payout` | `agent description`, `moves`, `steps`, `summary` |
|
|
133
|
-
| `create` | `agent description`, `moves`, `requires refs`, `steps`, `summary` |
|
|
134
|
-
| `payout` | `due`, `moves`, `steps`, `summary` |
|
|
135
|
-
| `create` | `agent description`, `steps` |
|
package/docs/reference/types.md
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
<!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
# Types
|
|
4
|
-
|
|
5
|
-
HSX checks types before it emits UDL. Money and account values carry a currency parameter, and no implicit currency conversion exists.
|
|
6
|
-
|
|
7
|
-
| Kind | Meaning |
|
|
8
|
-
| --- | --- |
|
|
9
|
-
| `account` | A currency-indexed ledger account reference. |
|
|
10
|
-
| `boolean` | A compile-time or stored true or false value. |
|
|
11
|
-
| `bps` | An integer basis-point value. |
|
|
12
|
-
| `condition` | A declared decision port. |
|
|
13
|
-
| `date` | A stored date-time string checked by UDL. |
|
|
14
|
-
| `integer` | A bounded whole number. |
|
|
15
|
-
| `money` | A currency-indexed minor-unit amount. |
|
|
16
|
-
| `party` | A declared program party. |
|
|
17
|
-
| `percent` | An exact percentage with basis-point precision. |
|
|
18
|
-
| `ref` | A typed reference to another instrument. |
|
|
19
|
-
| `text` | A finite string value. |
|
|
20
|
-
| `unknown` | An internal checker result that source must resolve before lowering. |
|
|
21
|
-
|
|
22
|
-
## Account fields
|
|
23
|
-
|
|
24
|
-
When declaring fields of type `account<C>`, the HSX compiler automatically lowers the field schema with the UDL2002 account pattern (`^acct_(sandbox|live)_[a-z0-9]{8,64}$`). Authors do not need to write an explicit `pattern` clause on account fields.
|
|
25
|
-
|
|
26
|
-
```hsx
|
|
27
|
-
fields {
|
|
28
|
-
customerAccountId {
|
|
29
|
-
type: account<SAR>;
|
|
30
|
-
"x-hyperscale-reference-filter": { column: role; values: [customer_balance]; };
|
|
31
|
-
}
|
|
32
|
-
amount: money<SAR>;
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
The account type pins the currency and identifier shape. The reference filter
|
|
37
|
-
pins the allowed ledger roles. Product admission requires every account field
|
|
38
|
-
to declare a non-empty role list. Choose roles that match the accounts the
|
|
39
|
-
program will use; `customer_balance` is the role in this example.
|
|
40
|
-
|
|
41
|
-
Use the quoted `"x-hyperscale-reference-filter"` key inside the field block,
|
|
42
|
-
with `column: role` and `values: [...]`. There is no shorter role annotation.
|
|
43
|
-
A bare `customerAccountId: account<SAR>;` compiles as HSX but does not satisfy
|
|
44
|
-
the host's account-role admission law.
|
|
45
|
-
|
|
46
|
-
## Money fields
|
|
47
|
-
|
|
48
|
-
A `money<C>` field admits a minor-unit integer string and refuses zero: it lowers to the pattern `^[1-9][0-9]{0,17}$`. Marking the field `optional: true` lets a caller omit it; it does not let a caller send `"0"`. When zero is a real value for the field, opt in with `allow_zero: true`, which lowers to `^(0|[1-9][0-9]{0,17})$`:
|
|
49
|
-
|
|
50
|
-
```hsx
|
|
51
|
-
fields {
|
|
52
|
-
amount: money<SAR>;
|
|
53
|
-
discount { type: money<SAR>; optional: true; allow_zero: true; }
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
`allow_zero` on any other type is HSX1105. Decision port shapes set it on their money fields, because a decided amount may be zero.
|
|
58
|
-
|
|
59
|
-
## Date fields
|
|
60
|
-
|
|
61
|
-
A `date` field lowers to the UDL `hyperscale-date-time` format. Callers may send any RFC 3339 offset, such as `2026-10-03T09:00:00+03:00`; the host admits it and stores the UTC instant, `2026-10-03T06:00:00.000Z`. A value already in `Z` is stored byte for byte. A local date-time without an offset is refused.
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!-- Generated by scripts/docs/build.ts for HSX 2.4.1. Do not edit. -->
|
|
2
|
-
|
|
3
|
-
# UDL output
|
|
4
|
-
|
|
5
|
-
An accepted compile returns three artifacts.
|
|
6
|
-
|
|
7
|
-
| Artifact | Contents |
|
|
8
|
-
| --- | --- |
|
|
9
|
-
| `document` | The canonical UDL object. Serialize it with `serializeUdl` from `@hyperscale0/udl`. |
|
|
10
|
-
| `originMap` | Canonical UDL paths mapped to authored HSX spans. |
|
|
11
|
-
| `costManifest` | The deterministic manifest pinned to the supplied rate card. |
|
|
12
|
-
|
|
13
|
-
Canonical UDL sorts object keys, preserves array order, uses two-space JSON indentation, and ends with one line feed.
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# 1 · Your first program
|
|
2
|
-
|
|
3
|
-
[`tip-jar.hsx`](./tip-jar.hsx) is the smallest HSX program that moves money.
|
|
4
|
-
A listener tips a podcast host and the money goes straight through.
|
|
5
|
-
|
|
6
|
-
```bash
|
|
7
|
-
hsx check tip-jar.hsx # prints nothing, exits 0
|
|
8
|
-
hsx build tip-jar.hsx # the compiled IR
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## The four things in the file
|
|
12
|
-
|
|
13
|
-
**`program tip_jar "Tip jar"`** names the company. Exactly one per file. The
|
|
14
|
-
name is `snake_case` and becomes the IR document's `product`; the title is
|
|
15
|
-
optional and is what people read.
|
|
16
|
-
|
|
17
|
-
**`import { instant_transfer } from "std/money_flows"`** brings in one settlement brick.
|
|
18
|
-
`"settlement"` is the only module there is, and it holds seventeen settlement
|
|
19
|
-
bricks. A brick you have not imported cannot be instantiated, so the imports
|
|
20
|
-
at the top tell you what shape of company this is before you read a line of it.
|
|
21
|
-
|
|
22
|
-
**`party listener: person`** declares who is involved. A party is a `person`
|
|
23
|
-
or a `business`. Both are needed here: `instant_transfer` names a payer and a
|
|
24
|
-
payee, and both must be declared parties.
|
|
25
|
-
|
|
26
|
-
**`settlement tip = instant_transfer { … }`** is the money. `payer` and
|
|
27
|
-
`payee` name declared parties; `amount: tipAmount: money(SAR)` declares a
|
|
28
|
-
field the instance stores, called `tipAmount`, holding an amount in SAR.
|
|
29
|
-
|
|
30
|
-
That doubled colon reads oddly the first time. The module's parameter is
|
|
31
|
-
`amount`; its value is a typed binding, `tipAmount: money(SAR)`, which names
|
|
32
|
-
the field AND its type. You choose the field name because it shows up in the
|
|
33
|
-
generated API, and `amount` is HSX's word, not your product's.
|
|
34
|
-
|
|
35
|
-
## What it compiles to
|
|
36
|
-
|
|
37
|
-
One instrument with one action that moves money, and one money event, `tip_pay_1`.
|
|
38
|
-
Notice what is NOT there: no escrow flag, because nothing is held. Compare
|
|
39
|
-
that with example 2, where the money waits for someone to decide.
|
|
40
|
-
|
|
41
|
-
## Try breaking it
|
|
42
|
-
|
|
43
|
-
Change `payee: host` to `payee: hosts` and run `hsx check` again. The
|
|
44
|
-
compiler tells you there is no party named `hosts`, and points at the column
|
|
45
|
-
where you wrote it. That is example 3's whole subject.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// The smallest HSX program that moves money.
|
|
2
|
-
//
|
|
3
|
-
// A listener tips a podcast host. Nothing is held, nobody has to decide
|
|
4
|
-
// anything, and the money goes straight through.
|
|
5
|
-
|
|
6
|
-
program tip_jar "Tip jar"
|
|
7
|
-
|
|
8
|
-
import { instant_transfer } from "std/money_flows"
|
|
9
|
-
|
|
10
|
-
party listener: person
|
|
11
|
-
party host: business
|
|
12
|
-
|
|
13
|
-
settlement tip = instant_transfer {
|
|
14
|
-
payer: listener
|
|
15
|
-
payee: host
|
|
16
|
-
amount: tipAmount: money(SAR)
|
|
17
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# 2 · Imports, modules, and the port
|
|
2
|
-
|
|
3
|
-
[`photo-booth.hsx`](./photo-booth.hsx) is a photo-booth rental company. The
|
|
4
|
-
renter pays up front, but the money does not reach the company until the booth
|
|
5
|
-
is delivered.
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
hsx check photo-booth.hsx
|
|
9
|
-
hsx build photo-booth.hsx --out ir.json
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Holding money changes everything
|
|
13
|
-
|
|
14
|
-
`instant_transfer` in example 1 had no custody: money left the payer and
|
|
15
|
-
arrived at the payee in one step. `held_payment` puts the money in the
|
|
16
|
-
settlement's own escrow and holds it there until something says to let go.
|
|
17
|
-
That "something" is the interesting part.
|
|
18
|
-
|
|
19
|
-
```hsx
|
|
20
|
-
release: port confirm_delivery
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
A **port** is the typed seam where the tenant's own backend decides. HSX does
|
|
24
|
-
not model delivery, and the platform has no way to know whether a booth showed
|
|
25
|
-
up. So the language does not pretend: it declares who may answer the question
|
|
26
|
-
and what the answer looks like, and the answer comes from outside.
|
|
27
|
-
|
|
28
|
-
```hsx
|
|
29
|
-
port confirm_delivery {
|
|
30
|
-
allowed: [company]
|
|
31
|
-
shape {
|
|
32
|
-
boothId: id(booth)
|
|
33
|
-
deliveredOn: date
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
`allowed` is required and must name declared parties. `shape` is optional; its
|
|
39
|
-
field types are `text`, `date`, `id(<asset>)`, and `money(<CUR>)`.
|
|
40
|
-
|
|
41
|
-
## Assets are the things, not the money
|
|
42
|
-
|
|
43
|
-
```hsx
|
|
44
|
-
asset booth: good { title_transfer: off_platform }
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
`title_transfer: off_platform` records that ownership of the booth changes
|
|
48
|
-
hands outside the platform. Money stays on-platform; this flag describes the
|
|
49
|
-
object.
|
|
50
|
-
|
|
51
|
-
## Fees have a side, and the side matters
|
|
52
|
-
|
|
53
|
-
```hsx
|
|
54
|
-
fees { renter: 1%, company: 3% }
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Those two percentages behave completely differently, and the difference is
|
|
58
|
-
fixed by the compiler, not by you:
|
|
59
|
-
|
|
60
|
-
- The **payer-side** fee (`renter: 1%`) is charged **on top** at funding and
|
|
61
|
-
moves renter → platform directly. It never enters escrow, so no exit
|
|
62
|
-
refunds it.
|
|
63
|
-
- The **payee-side** fee (`company: 3%`) is **carved out** of the amount at
|
|
64
|
-
release. The renter pays the booking fee, and the company receives 97% of it.
|
|
65
|
-
|
|
66
|
-
## Cancellation splits to the basis point
|
|
67
|
-
|
|
68
|
-
```hsx
|
|
69
|
-
on_cancel(funded) { renter: 90%, company: 10% }
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
The shares must total exactly 100%. Not 99.99%, not 100.01%. A 0% share is
|
|
73
|
-
refused outright: drop the party from the block instead of promising them
|
|
74
|
-
nothing.
|
|
75
|
-
|
|
76
|
-
## Where the piece fields come from
|
|
77
|
-
|
|
78
|
-
Look at the compiled instrument's `fields` and you will find `piece1Amount`,
|
|
79
|
-
`piece2Amount`, `piece3Amount` next to `bookingFee`, plus a `partitions`
|
|
80
|
-
clause proving they sum to it exactly.
|
|
81
|
-
|
|
82
|
-
Release pays out 97/3 (company, platform). Cancellation pays out 90/10
|
|
83
|
-
(renter, company). The compiler cuts the amount at every boundary either exit
|
|
84
|
-
cares about, which lands on 90 / 7 / 3, and then every exit is a whole number
|
|
85
|
-
of pieces:
|
|
86
|
-
|
|
87
|
-
| Piece | Release | Cancel |
|
|
88
|
-
| -------------------- | -------- | ------- |
|
|
89
|
-
| `piece1Amount` (90%) | company | renter |
|
|
90
|
-
| `piece2Amount` (7%) | company | company |
|
|
91
|
-
| `piece3Amount` (3%) | platform | company |
|
|
92
|
-
|
|
93
|
-
Each piece is `floor(bookingFee × bps / 10000)` in minor units, and the
|
|
94
|
-
division remainder goes to `piece1Amount`. Nothing rounds; nothing is lost.
|
|
95
|
-
This is what "the runtime does the plumbing" actually means, and it is why the
|
|
96
|
-
source is 20 lines instead of a lifecycle table.
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Imports, modules, and the decision port.
|
|
2
|
-
//
|
|
3
|
-
// A photo-booth rental company. The renter pays up front, but the money sits
|
|
4
|
-
// in escrow until the booth is delivered. The company's own backend answers
|
|
5
|
-
// "was it delivered?" through the `confirm_delivery` port; nothing on the
|
|
6
|
-
// platform guesses. If the booking falls through after funding, the renter
|
|
7
|
-
// gets almost everything back and the company keeps a small penalty.
|
|
8
|
-
|
|
9
|
-
program photo_booth "Photo booth rentals"
|
|
10
|
-
|
|
11
|
-
import { held_payment } from "std/money_flows"
|
|
12
|
-
|
|
13
|
-
party renter: person
|
|
14
|
-
party company: business
|
|
15
|
-
|
|
16
|
-
asset booth: good { title_transfer: off_platform }
|
|
17
|
-
|
|
18
|
-
settlement booking = held_payment {
|
|
19
|
-
payer: renter
|
|
20
|
-
payee: company
|
|
21
|
-
amount: bookingFee: money(SAR)
|
|
22
|
-
|
|
23
|
-
// The platform takes 3% out of the company's payout, and charges the
|
|
24
|
-
// renter 1% on top of the booking fee at funding.
|
|
25
|
-
fees { renter: 1%, company: 3% }
|
|
26
|
-
|
|
27
|
-
release: port confirm_delivery
|
|
28
|
-
on_cancel(funded) { renter: 90%, company: 10% }
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
port confirm_delivery {
|
|
32
|
-
allowed: [company]
|
|
33
|
-
shape {
|
|
34
|
-
boothId: id(booth)
|
|
35
|
-
deliveredOn: date
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# 3 · Reading diagnostics
|
|
2
|
-
|
|
3
|
-
[`corner-shop.hsx`](./corner-shop.hsx) is wrong on purpose. Three mistakes,
|
|
4
|
-
one per idea. [`corner-shop-fixed.hsx`](./corner-shop-fixed.hsx) is the same
|
|
5
|
-
program repaired.
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
hsx check corner-shop.hsx # exits 1
|
|
9
|
-
hsx check corner-shop-fixed.hsx # exits 0, prints nothing
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## What comes back
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
corner-shop.hsx:15:12: error [check] settlement basket payee must name a declared party; there is no party named grocer
|
|
16
|
-
corner-shop.hsx:17:17: error [check] settlement basket decides release through port confirm_pickup, but no port with that name is declared
|
|
17
|
-
corner-shop.hsx:18:21: error [check] the on_cancel split must account for exactly 100%; these shares total 60%
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Every diagnostic carries a 1-indexed line and column, a severity, the stage
|
|
21
|
-
that raised it, and one sentence. Coordinates always point at the source you
|
|
22
|
-
wrote, never at a path inside the compiled IR.
|
|
23
|
-
|
|
24
|
-
## The three mistakes
|
|
25
|
-
|
|
26
|
-
**Line 15, a name that was never declared.** `payee: grocer` names a party
|
|
27
|
-
that does not exist. Parties, assets, settlements, and ports share one flat
|
|
28
|
-
namespace, and everything in it must be declared. The fix is one line:
|
|
29
|
-
`party grocer: business`.
|
|
30
|
-
|
|
31
|
-
**Line 17, a decision with nothing behind it.** `release: port confirm_pickup`
|
|
32
|
-
says the release is decided by a port called `confirm_pickup`, and no such
|
|
33
|
-
port is declared. HSX will not invent a decider: someone real has to answer,
|
|
34
|
-
and the file has to say who. The fix declares the port and names who may
|
|
35
|
-
answer it.
|
|
36
|
-
|
|
37
|
-
**Line 18, money that does not add up.** `on_cancel(funded) { shopper: 60% }`
|
|
38
|
-
leaves 40% of the held amount unaccounted for. There is no default recipient
|
|
39
|
-
and no implicit remainder. The message does the arithmetic for you and says
|
|
40
|
-
what the shares actually total.
|
|
41
|
-
|
|
42
|
-
## All three at once, and why
|
|
43
|
-
|
|
44
|
-
The compiler reports every error it can rather than stopping at the first, so
|
|
45
|
-
one run tells you everything you have to fix.
|
|
46
|
-
|
|
47
|
-
But it will not report errors from two different stages in the same run.
|
|
48
|
-
Compiling is three stages, parse then check then lower, and a stage only runs
|
|
49
|
-
the one before it produced something to work with. All three errors here are
|
|
50
|
-
`[check]`. Introduce a syntax error, say by deleting a closing brace, and you
|
|
51
|
-
get one `[parse]` diagnostic and nothing else: a file that does not parse has
|
|
52
|
-
no meaning to check, so anything else the compiler said about it would be
|
|
53
|
-
guesswork.
|
|
54
|
-
|
|
55
|
-
## Errors, warnings, verdicts
|
|
56
|
-
|
|
57
|
-
There are three verdicts:
|
|
58
|
-
|
|
59
|
-
| Verdict | Artifacts | |
|
|
60
|
-
| --------- | --------- | ------------------------------------------ |
|
|
61
|
-
| `valid` | present | Nothing to say. |
|
|
62
|
-
| `warning` | present | It compiled, and the lint voice has notes. |
|
|
63
|
-
| `invalid` | absent | It cannot be compiled. |
|
|
64
|
-
|
|
65
|
-
Warnings are lint, not soft errors: a party nobody involves, an import nothing
|
|
66
|
-
instantiates, a 0% fee, a port nothing releases through. They never block, and
|
|
67
|
-
the artifacts of a `warning` compile are complete and usable. If you want them
|
|
68
|
-
to block in CI, `hsx check --strict` exits 1 on a warning.
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// The same program with all three mistakes repaired: the grocer is declared,
|
|
2
|
-
// the port the release decides through exists, and the cancellation split
|
|
3
|
-
// accounts for the whole held amount.
|
|
4
|
-
|
|
5
|
-
program corner_shop "Corner shop"
|
|
6
|
-
|
|
7
|
-
import { held_payment } from "std/money_flows"
|
|
8
|
-
|
|
9
|
-
party shopper: person
|
|
10
|
-
party grocer: business
|
|
11
|
-
|
|
12
|
-
settlement basket = held_payment {
|
|
13
|
-
payer: shopper
|
|
14
|
-
payee: grocer
|
|
15
|
-
amount: basketTotal: money(SAR)
|
|
16
|
-
release: port confirm_pickup
|
|
17
|
-
on_cancel(funded) { shopper: 60%, grocer: 40% }
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
port confirm_pickup {
|
|
21
|
-
allowed: [grocer]
|
|
22
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// This program is wrong on purpose. Three separate mistakes, one per idea:
|
|
2
|
-
// a name that was never declared, a decision with no port behind it, and a
|
|
3
|
-
// cancellation split that does not add up.
|
|
4
|
-
//
|
|
5
|
-
// Run `hsx check corner-shop.hsx` and read what comes back.
|
|
6
|
-
|
|
7
|
-
program corner_shop "Corner shop"
|
|
8
|
-
|
|
9
|
-
import { held_payment } from "std/money_flows"
|
|
10
|
-
|
|
11
|
-
party shopper: person
|
|
12
|
-
|
|
13
|
-
settlement basket = held_payment {
|
|
14
|
-
payer: shopper
|
|
15
|
-
payee: grocer
|
|
16
|
-
amount: basketTotal: money(SAR)
|
|
17
|
-
release: port confirm_pickup
|
|
18
|
-
on_cancel(funded) { shopper: 60% }
|
|
19
|
-
}
|