@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
@@ -16,7 +16,7 @@ module std.money_flows.weighted_distribution
16
16
  //
17
17
  // ### Parameters
18
18
  // - `source`: The funding party providing the distribution pool.
19
- // - `recipient`: The archetype party representing entitled recipients.
19
+ // - `recipient`: The party representing entitled recipients.
20
20
  // - `amount`: Total distribution pool in minor units of currency `C`.
21
21
  // - `record_at`: Date when entitlement eligibility is established.
22
22
  // - `weight`: Binding name for individual recipient weight amounts.
@@ -54,11 +54,20 @@ module std.money_flows.weighted_distribution
54
54
  // shape: { evidenceReference: text }
55
55
  // }
56
56
  // ```
57
+ // ### Receipt-backed distributions
58
+ // receipts selects repeated distributions from immutable allocation receipts.
59
+ // It names round, receipt, path, mode (cash or loss), fee_bps and vat_bps.
60
+ // The funding snapshot owns ticket weights and original wallet destinations.
61
+ // Cash floors each ratio after fee and fee VAT; a named account receives residual.
62
+ // Loss assigns principal by largest remainder without cash, fee or VAT.
63
+ // Each receipt is consumed once; a new receipt may fund a new distribution record.
64
+ // This mode does not use caller-entered weights or a once-only settled principal pool.
65
+ //
57
66
  export instrument weighted_distribution<C>(
58
- source: party,
59
- recipient: party,
60
- amount: money<C>,
61
- record_at: date,
67
+ source: optional<party>,
68
+ recipient: optional<party>,
69
+ amount: optional<money<C>>,
70
+ record_at: optional<date>,
62
71
  weight: optional<money<C>>,
63
72
  max_recipients: optional<integer>,
64
73
  snapshot: optional<condition>,
@@ -66,8 +75,10 @@ export instrument weighted_distribution<C>(
66
75
  withholding_policy: optional<text>,
67
76
  correction_policy: optional<text>,
68
77
  flat: optional<block>,
78
+ receipts: optional<block>,
69
79
  id_prefix_override: optional<text>,
70
80
  ) {
81
+ when_not(receipts) {
71
82
  when_not(flat) {
72
83
  fields {
73
84
  currency { type: text; description: "ISO 4217 currency code"; minLength: 3; maxLength: 3; pattern: "^[A-Z]{3}$"; }
@@ -192,4 +203,35 @@ export instrument weighted_distribution<C>(
192
203
  steps: [];
193
204
  }
194
205
  }
206
+ }
207
+ when(receipts) {
208
+ let(round_type): get(receipts, "round");
209
+ let(receipt_type): get(receipts, "receipt");
210
+ fields {
211
+ roundId: ref<round_type>;
212
+ receiptId: ref<receipt_type>;
213
+ currency { type: text; pattern: "^[A-Z]{3}$"; minLength: 3; maxLength: 3; }
214
+ feeAccountId { type: account<C>; "x-hyperscale-reference-filter": { column: role; values: [customer_balance]; }; }
215
+ taxAccountId { type: account<C>; "x-hyperscale-reference-filter": { column: role; values: [customer_balance]; }; }
216
+ residualAccountId { type: account<C>; "x-hyperscale-reference-filter": { column: role; values: [customer_balance]; }; }
217
+ }
218
+ parties { fee: feeAccountId; tax: taxAccountId; beneficiary: residualAccountId; }
219
+ lifecycle { states distributed; initial distributed; }
220
+ title: sentence(instrument);
221
+ summary: "Receipt-backed frozen-weight distribution";
222
+ agent_description: "Consume one allocation receipt against the round's frozen tickets. Cash distributions carve fee and VAT, floor each ticket share and pay the residual to its named owner. Loss mode records principal loss without cash.";
223
+ action create {
224
+ public: none;
225
+ agent_description: "Distribute one receipt once. All amounts and sources come from the consumed receipt and frozen funding snapshot.";
226
+ requires refs: { field: roundId; statuses: [settled]; match: { "fields.currency": fields.currency; }; };
227
+ receipt distribution: {
228
+ round_field: roundId; snapshot_ref: fundingSnapshot;
229
+ receipt_field: receiptId; receipt_path: get(receipts, "path"); mode: get(receipts, "mode");
230
+ fee_bps: get(receipts, "fee_bps"); vat_bps: get(receipts, "vat_bps");
231
+ fee_account_field: feeAccountId; tax_account_field: taxAccountId; residual_account_field: residualAccountId;
232
+ capture: distributionReceipt;
233
+ };
234
+ steps: [];
235
+ }
236
+ }
195
237
  }
@@ -1,25 +0,0 @@
1
- <!-- Generated by scripts/docs/build.ts for HSX 2.1.0. Do not edit. -->
2
-
3
- # recurring_collection
4
-
5
- Source: [`std/money_flows/recurring_collection.hsx`](../../../std/money_flows/recurring_collection.hsx)
6
-
7
- ## Export
8
-
9
- `recurring_collection`
10
-
11
- ## Parameters
12
-
13
- - `marker: optional<text>`
14
-
15
- ## Decision ports
16
-
17
- None.
18
-
19
- ## Actions and clauses
20
-
21
- | Action | Clauses lowered |
22
- | --------- | --------------------------------------- |
23
- | `create` | `agent description`, `steps`, `summary` |
24
- | `collect` | `agent description`, `steps`, `summary` |
25
- | `end` | `agent description`, `steps`, `summary` |
@@ -1,3 +0,0 @@
1
- # recurring_collection
2
-
3
- This example applies the `recurring_collection` standard-library module. Its sibling UDL file pins the canonical compiler output byte for byte. The company and parties are invented.
@@ -1,21 +0,0 @@
1
- program recurring_collection_example "Recurring collection example"
2
- import { recurring_collection, scheduled } from "std/money_flows"
3
- party debtor: person
4
- party repayment_source: business
5
- party recipient: business
6
- settlement obligation = scheduled {
7
- mode: obligation
8
- payer: repayment_source
9
- payee: recipient
10
- debtor: debtor
11
- amount: principal: money(SAR)
12
- count: 2
13
- every: P30D
14
- first_due: firstDueAt
15
- mandate: port mandate_evidence
16
- }
17
- settlement collection = recurring_collection {}
18
- port mandate_evidence {
19
- allowed: [repayment_source]
20
- shape: { evidenceReference: text }
21
- }