@hyperscale0/hsx 2.0.0 → 2.0.2
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 +25 -0
- package/dist/src/cli.d.ts +1 -1
- package/dist/src/diagnostics.d.ts.map +1 -1
- package/dist/src/diagnostics.js +7 -0
- package/dist/src/diagnostics.js.map +1 -1
- package/dist/src/std-bundle.js +19 -19
- package/dist/src/std-bundle.js.map +1 -1
- package/dist/src/typecheck.js +89 -1
- package/dist/src/typecheck.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/docs/guide/01-first-program.md +1 -1
- package/docs/guide/09-cost.md +1 -1
- package/docs/llms-full.txt +64 -39
- package/docs/llms.txt +2 -2
- package/docs/reference/cli.md +2 -2
- package/docs/reference/diagnostics.md +21 -1
- package/docs/reference/grammar.md +1 -1
- package/docs/reference/std/advance.md +1 -1
- package/docs/reference/std/cancellable_booking.md +1 -1
- package/docs/reference/std/captured_payment.md +1 -1
- package/docs/reference/std/conditional_disbursement.md +1 -1
- package/docs/reference/std/credit_facility.md +1 -1
- package/docs/reference/std/held_payment.md +41 -36
- package/docs/reference/std/instant_transfer.md +1 -1
- package/docs/reference/std/metered.md +1 -1
- package/docs/reference/std/pooled_split.md +1 -1
- package/docs/reference/std/premium_forward.md +1 -1
- package/docs/reference/std/reconciled_payout.md +1 -1
- package/docs/reference/std/recurring_collection.md +1 -1
- package/docs/reference/std/rotating_pool.md +1 -1
- package/docs/reference/std/scheduled.md +1 -1
- package/docs/reference/std/security_deposit.md +1 -1
- package/docs/reference/std/settlement_batch.md +1 -1
- package/docs/reference/std/swap.md +1 -1
- package/docs/reference/std/threshold_pool.md +1 -1
- package/docs/reference/std/weighted_distribution.md +1 -1
- package/docs/reference/types.md +1 -1
- package/docs/reference/udl-output.md +1 -1
- package/examples/advance/advance.udl +6 -6
- package/examples/cancellable_booking/cancellable_booking.udl +10 -10
- package/examples/captured_payment/captured_payment.udl +6 -6
- package/examples/conditional_disbursement/conditional_disbursement.udl +2 -2
- package/examples/cost-table.json +18 -78
- package/examples/credit_facility/credit_facility.udl +10 -10
- package/examples/held_payment/held_payment.udl +23 -12
- package/examples/instant_transfer/instant_transfer.udl +6 -6
- package/examples/metered/metered.udl +4 -4
- package/examples/pooled_split/pooled_split.udl +10 -10
- package/examples/premium_forward/premium_forward.udl +12 -12
- package/examples/recurring_collection/recurring_collection.udl +8 -8
- package/examples/rotating_pool/rotating_pool.udl +78 -78
- package/examples/scheduled/scheduled.udl +6 -6
- package/examples/security_deposit/security_deposit.udl +2 -2
- package/examples/swap/swap.udl +22 -22
- package/examples/threshold_pool/threshold_pool.udl +10 -10
- package/examples/weighted_distribution/weighted_distribution.udl +2 -2
- package/package.json +3 -3
- package/skills/hsx/SKILL.md +2 -2
- package/src/diagnostics.ts +10 -0
- package/src/std-bundle.ts +19 -19
- package/src/typecheck.ts +105 -1
- package/src/version.ts +1 -1
- package/std/money_flows/advance.hsx +45 -0
- package/std/money_flows/cancellable_booking.hsx +45 -0
- package/std/money_flows/captured_payment.hsx +55 -0
- package/std/money_flows/conditional_disbursement.hsx +46 -0
- package/std/money_flows/credit_facility.hsx +57 -0
- package/std/money_flows/held_payment.hsx +152 -3
- package/std/money_flows/instant_transfer.hsx +42 -0
- package/std/money_flows/metered.hsx +41 -0
- package/std/money_flows/pooled_split.hsx +41 -0
- package/std/money_flows/premium_forward.hsx +51 -0
- package/std/money_flows/reconciled_payout.hsx +42 -0
- package/std/money_flows/recurring_collection.hsx +45 -0
- package/std/money_flows/rotating_pool.hsx +51 -0
- package/std/money_flows/scheduled.hsx +53 -0
- package/std/money_flows/security_deposit.hsx +58 -0
- package/std/money_flows/settlement_batch.hsx +51 -0
- package/std/money_flows/swap.hsx +53 -0
- package/std/money_flows/threshold_pool.hsx +51 -0
- package/std/money_flows/weighted_distribution.hsx +54 -0
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
module std.money_flows.weighted_distribution
|
|
2
2
|
|
|
3
|
+
// Frozen largest-remainder distribution splitting one pool across dynamic recipients by recorded weights.
|
|
4
|
+
//
|
|
5
|
+
// ### Purpose
|
|
6
|
+
// `weighted_distribution` distributes dividend pools, creator royalties, liquidation proceeds, and investment returns.
|
|
7
|
+
// Child entitlement rows are recorded for each recipient with their respective weight. Once all recipients are recorded,
|
|
8
|
+
// an evidence-backed snapshot freezes the entitlement set. Each recipient is then paid their exact largest-remainder
|
|
9
|
+
// share such that all payouts sum exactly to `amount` without rounding leaks.
|
|
10
|
+
//
|
|
11
|
+
// ### Selection guidance
|
|
12
|
+
// - vs `pooled_split`: `weighted_distribution` handles dynamic recipient rosters recorded as child rows and frozen
|
|
13
|
+
// via snapshot. `pooled_split` hardcodes a fixed set of recipients and static percentages at definition time.
|
|
14
|
+
// - vs `settlement_batch`: `weighted_distribution` splits one funding pool out to many recipients.
|
|
15
|
+
// `settlement_batch` aggregates many inbound charges and adjustments into a single net payout.
|
|
16
|
+
//
|
|
17
|
+
// ### Parameters
|
|
18
|
+
// - `source`: The funding party providing the distribution pool.
|
|
19
|
+
// - `recipient`: The archetype party representing entitled recipients.
|
|
20
|
+
// - `amount`: Total distribution pool in minor units of currency `C`.
|
|
21
|
+
// - `record_at`: Date when entitlement eligibility is established.
|
|
22
|
+
// - `weight`: Binding name for individual recipient weight amounts.
|
|
23
|
+
// - `max_recipients`: Exact number of entitlement rows required before snapshotting.
|
|
24
|
+
// - `snapshot`: Port freezing the entitlement set against stored decision evidence.
|
|
25
|
+
// - `rounding_policy`: Mathematical rounding policy (`largest_remainder`).
|
|
26
|
+
// - `withholding_policy`: Tax or withholding policy (`refuse`).
|
|
27
|
+
// - `correction_policy`: Error correction policy (`new_distribution`).
|
|
28
|
+
// - `flat`: Optional flat distribution configuration block.
|
|
29
|
+
// - `id_prefix_override`: Optional custom prefix for generated instrument IDs.
|
|
30
|
+
//
|
|
31
|
+
// ### Decision ports
|
|
32
|
+
// - `snapshot`: Port freezing the entitlement set with an evidence reference, preventing further entries.
|
|
33
|
+
//
|
|
34
|
+
// ### Example
|
|
35
|
+
// ```hsx
|
|
36
|
+
// program weighted_distribution_example "Weighted distribution example"
|
|
37
|
+
// import { weighted_distribution } from "std/money_flows"
|
|
38
|
+
// party distribution_source: business
|
|
39
|
+
// party recipient: business
|
|
40
|
+
// settlement proceeds = weighted_distribution {
|
|
41
|
+
// source: distribution_source
|
|
42
|
+
// recipient: recipient
|
|
43
|
+
// amount: distributableAmount: money(SAR)
|
|
44
|
+
// weight: entitlementWeight: money(SAR)
|
|
45
|
+
// max_recipients: 12
|
|
46
|
+
// record_at: recordAt
|
|
47
|
+
// snapshot: port snapshot_entitlements
|
|
48
|
+
// rounding_policy: largest_remainder
|
|
49
|
+
// withholding_policy: refuse
|
|
50
|
+
// correction_policy: new_distribution
|
|
51
|
+
// }
|
|
52
|
+
// port snapshot_entitlements {
|
|
53
|
+
// allowed: [distribution_source]
|
|
54
|
+
// shape: { evidenceReference: text }
|
|
55
|
+
// }
|
|
56
|
+
// ```
|
|
3
57
|
export instrument weighted_distribution<C>(
|
|
4
58
|
source: party,
|
|
5
59
|
recipient: party,
|