@hyperscale0/hsx 1.0.0-rc.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/CHANGELOG.md +32 -4
  2. package/README.md +58 -36
  3. package/bin/hsx.ts +2 -0
  4. package/dist/bin/hsx.js +2 -0
  5. package/dist/bin/hsx.js.map +1 -1
  6. package/dist/src/ast.d.ts +10 -2
  7. package/dist/src/ast.d.ts.map +1 -1
  8. package/dist/src/ast.js +24 -0
  9. package/dist/src/ast.js.map +1 -1
  10. package/dist/src/cli.d.ts +3 -1
  11. package/dist/src/cli.d.ts.map +1 -1
  12. package/dist/src/cli.js +25 -5
  13. package/dist/src/cli.js.map +1 -1
  14. package/dist/src/compile.d.ts +9 -5
  15. package/dist/src/compile.d.ts.map +1 -1
  16. package/dist/src/compile.js +9 -3
  17. package/dist/src/compile.js.map +1 -1
  18. package/dist/src/cost.d.ts +3 -1
  19. package/dist/src/cost.d.ts.map +1 -1
  20. package/dist/src/cost.js +124 -94
  21. package/dist/src/cost.js.map +1 -1
  22. package/dist/src/diagnostics.d.ts.map +1 -1
  23. package/dist/src/diagnostics.js +89 -5
  24. package/dist/src/diagnostics.js.map +1 -1
  25. package/dist/src/emit.d.ts +4 -3
  26. package/dist/src/emit.d.ts.map +1 -1
  27. package/dist/src/emit.js +28 -233
  28. package/dist/src/emit.js.map +1 -1
  29. package/dist/src/format.js.map +1 -1
  30. package/dist/src/index.d.ts +4 -3
  31. package/dist/src/index.d.ts.map +1 -1
  32. package/dist/src/index.js +3 -1
  33. package/dist/src/index.js.map +1 -1
  34. package/dist/src/ir.d.ts.map +1 -1
  35. package/dist/src/lex.d.ts.map +1 -1
  36. package/dist/src/lsp/server.d.ts +32 -0
  37. package/dist/src/lsp/server.d.ts.map +1 -0
  38. package/dist/src/lsp/server.js +391 -0
  39. package/dist/src/lsp/server.js.map +1 -0
  40. package/dist/src/modules.d.ts +2 -0
  41. package/dist/src/modules.d.ts.map +1 -1
  42. package/dist/src/modules.js +14 -14
  43. package/dist/src/modules.js.map +1 -1
  44. package/dist/src/parse.js +3 -3
  45. package/dist/src/parse.js.map +1 -1
  46. package/dist/src/std-bundle.d.ts +2 -0
  47. package/dist/src/std-bundle.d.ts.map +1 -0
  48. package/dist/src/std-bundle.js +88 -0
  49. package/dist/src/std-bundle.js.map +1 -0
  50. package/dist/src/std-library.d.ts +5 -0
  51. package/dist/src/std-library.d.ts.map +1 -0
  52. package/dist/src/std-library.js +9 -0
  53. package/dist/src/std-library.js.map +1 -0
  54. package/dist/src/typecheck.d.ts.map +1 -1
  55. package/dist/src/typecheck.js +859 -156
  56. package/dist/src/typecheck.js.map +1 -1
  57. package/dist/src/version.d.ts +1 -1
  58. package/dist/src/version.d.ts.map +1 -1
  59. package/dist/src/version.js +1 -1
  60. package/dist/src/version.js.map +1 -1
  61. package/docs/README.md +12 -0
  62. package/docs/assets/hsx.svg +18 -0
  63. package/docs/guide/01-first-program.md +2 -2
  64. package/docs/guide/02-money.md +1 -1
  65. package/docs/guide/03-instruments.md +44 -3
  66. package/docs/guide/04-lifecycles.md +18 -3
  67. package/docs/guide/05-fees-and-splits.md +2 -2
  68. package/docs/guide/06-schedules.md +1 -1
  69. package/docs/guide/07-composition.md +8 -2
  70. package/docs/guide/08-writing-a-module.md +13 -2
  71. package/docs/guide/09-cost.md +3 -3
  72. package/docs/guide/10-diagnostics.md +1 -1
  73. package/docs/llms-full.txt +458 -194
  74. package/docs/llms.txt +2 -2
  75. package/docs/playground.md +55 -0
  76. package/docs/reference/cli.md +5 -3
  77. package/docs/reference/diagnostics.md +223 -37
  78. package/docs/reference/grammar.md +2 -2
  79. package/docs/reference/std/advance.md +2 -2
  80. package/docs/reference/std/cancellable_booking.md +10 -10
  81. package/docs/reference/std/captured_payment.md +14 -14
  82. package/docs/reference/std/conditional_disbursement.md +3 -3
  83. package/docs/reference/std/credit_facility.md +2 -2
  84. package/docs/reference/std/held_payment.md +37 -33
  85. package/docs/reference/std/instant_transfer.md +8 -8
  86. package/docs/reference/std/metered.md +2 -2
  87. package/docs/reference/std/pooled_split.md +2 -2
  88. package/docs/reference/std/premium_forward.md +13 -13
  89. package/docs/reference/std/reconciled_payout.md +2 -2
  90. package/docs/reference/std/recurring_collection.md +2 -2
  91. package/docs/reference/std/rotating_pool.md +2 -2
  92. package/docs/reference/std/scheduled.md +18 -18
  93. package/docs/reference/std/security_deposit.md +14 -14
  94. package/docs/reference/std/settlement_batch.md +2 -2
  95. package/docs/reference/std/swap.md +18 -18
  96. package/docs/reference/std/threshold_pool.md +2 -2
  97. package/docs/reference/std/weighted_distribution.md +2 -2
  98. package/docs/reference/types.md +1 -1
  99. package/docs/reference/udl-output.md +2 -3
  100. package/examples/01-first-program/README.md +1 -1
  101. package/examples/01-first-program/tip-jar.hsx +1 -1
  102. package/examples/02-imports-and-archetypes/README.md +1 -4
  103. package/examples/02-imports-and-archetypes/photo-booth.hsx +1 -1
  104. package/examples/03-diagnostics/corner-shop-fixed.hsx +1 -1
  105. package/examples/03-diagnostics/corner-shop.hsx +1 -1
  106. package/examples/04-complete-product/README.md +0 -3
  107. package/examples/04-complete-product/study-hall.hsx +1 -1
  108. package/examples/05-watch-club/README.md +0 -3
  109. package/examples/05-watch-club/watch-club.hsx +1 -1
  110. package/examples/README.md +35 -4
  111. package/examples/advance/advance.hsx +1 -1
  112. package/examples/advance/advance.udl +10 -5
  113. package/examples/cancellable_booking/cancellable_booking.hsx +1 -1
  114. package/examples/cancellable_booking/cancellable_booking.udl +3 -1
  115. package/examples/captured_payment/captured_payment.hsx +1 -1
  116. package/examples/captured_payment/captured_payment.udl +4 -1
  117. package/examples/conditional_disbursement/conditional_disbursement.hsx +1 -1
  118. package/examples/conditional_disbursement/conditional_disbursement.udl +5 -3
  119. package/examples/cost-table.json +1602 -382
  120. package/examples/credit_facility/credit_facility.hsx +1 -1
  121. package/examples/credit_facility/credit_facility.udl +16 -9
  122. package/examples/held_payment/held_payment.hsx +1 -1
  123. package/examples/held_payment/held_payment.udl +38 -3
  124. package/examples/instant_transfer/instant_transfer.hsx +1 -1
  125. package/examples/instant_transfer/instant_transfer.udl +11 -5
  126. package/examples/metered/metered.hsx +1 -1
  127. package/examples/metered/metered.udl +4 -2
  128. package/examples/pooled_split/pooled_split.hsx +1 -1
  129. package/examples/pooled_split/pooled_split.udl +6 -3
  130. package/examples/premium_forward/premium_forward.hsx +1 -1
  131. package/examples/premium_forward/premium_forward.udl +10 -4
  132. package/examples/reconciled_payout/reconciled_payout.hsx +1 -1
  133. package/examples/reconciled_payout/reconciled_payout.udl +4 -2
  134. package/examples/recurring_collection/recurring_collection.hsx +1 -1
  135. package/examples/recurring_collection/recurring_collection.udl +12 -7
  136. package/examples/rotating_pool/rotating_pool.hsx +1 -1
  137. package/examples/rotating_pool/rotating_pool.udl +14 -4
  138. package/examples/scheduled/scheduled.hsx +1 -1
  139. package/examples/scheduled/scheduled.udl +9 -4
  140. package/examples/security_deposit/security_deposit.hsx +1 -1
  141. package/examples/security_deposit/security_deposit.udl +17 -3
  142. package/examples/settlement_batch/settlement_batch.hsx +1 -1
  143. package/examples/swap/swap.hsx +1 -1
  144. package/examples/swap/swap.udl +12 -6
  145. package/examples/threshold_pool/threshold_pool.hsx +1 -1
  146. package/examples/threshold_pool/threshold_pool.udl +4 -2
  147. package/examples/weighted_distribution/weighted_distribution.hsx +1 -1
  148. package/examples/weighted_distribution/weighted_distribution.udl +4 -2
  149. package/package.json +15 -6
  150. package/skills/hsx/SKILL.md +26 -26
  151. package/src/ast.ts +34 -2
  152. package/src/cli.ts +32 -13
  153. package/src/compile.ts +15 -7
  154. package/src/cost.ts +176 -104
  155. package/src/diagnostics.ts +89 -4
  156. package/src/emit.ts +34 -266
  157. package/src/index.ts +10 -7
  158. package/src/lsp/server.ts +460 -0
  159. package/src/modules.ts +21 -13
  160. package/src/parse.ts +3 -3
  161. package/src/std-bundle.ts +91 -0
  162. package/src/std-library.ts +12 -0
  163. package/src/typecheck.ts +1147 -235
  164. package/src/version.ts +1 -1
  165. package/std/SEMANTICS.md +12 -3
  166. package/std/{settlements → money_flows}/advance.hsx +1 -1
  167. package/std/{settlements → money_flows}/cancellable_booking.hsx +4 -3
  168. package/std/{settlements → money_flows}/captured_payment.hsx +35 -6
  169. package/std/{settlements → money_flows}/conditional_disbursement.hsx +17 -16
  170. package/std/{settlements → money_flows}/credit_facility.hsx +1 -2
  171. package/std/{settlements → money_flows}/held_payment.hsx +59 -25
  172. package/std/money_flows/index.hsx +3 -0
  173. package/std/{settlements → money_flows}/instant_transfer.hsx +2 -3
  174. package/std/{settlements → money_flows}/metered.hsx +1 -1
  175. package/std/{settlements → money_flows}/pooled_split.hsx +3 -3
  176. package/std/{settlements → money_flows}/premium_forward.hsx +22 -23
  177. package/std/{settlements → money_flows}/reconciled_payout.hsx +3 -3
  178. package/std/{settlements → money_flows}/recurring_collection.hsx +1 -1
  179. package/std/{settlements → money_flows}/rotating_pool.hsx +8 -6
  180. package/std/{settlements → money_flows}/scheduled.hsx +22 -27
  181. package/std/{settlements → money_flows}/security_deposit.hsx +38 -14
  182. package/std/{settlements → money_flows}/settlement_batch.hsx +3 -3
  183. package/std/{settlements → money_flows}/swap.hsx +41 -16
  184. package/std/{settlements → money_flows}/threshold_pool.hsx +5 -5
  185. package/std/{settlements → money_flows}/weighted_distribution.hsx +6 -6
  186. package/docs/sessions/2026-09-02-two-instruments.hsx +0 -21
  187. package/docs/sessions/2026-09-02-two-instruments.md +0 -41
  188. package/std/settlements/index.hsx +0 -3
@@ -1,5 +1,5 @@
1
1
  /** Package version reported by the command line. */
2
- export declare const HSX_VERSION = "1.0.0-rc.1";
2
+ export declare const HSX_VERSION = "2.0.0";
3
3
  /** Canonical UDL contract version emitted by this compiler. */
4
4
  export declare const HSX_TARGET_UDL_VERSION = 1;
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,eAAO,MAAM,WAAW,eAAe,CAAC;AAExC,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,IAAI,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,IAAI,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /** Package version reported by the command line. */
2
- export const HSX_VERSION = "1.0.0-rc.1";
2
+ export const HSX_VERSION = "2.0.0";
3
3
  /** Canonical UDL contract version emitted by this compiler. */
4
4
  export const HSX_TARGET_UDL_VERSION = 1;
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AAExC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC"}
package/docs/README.md CHANGED
@@ -18,6 +18,18 @@ The generated [reference](./reference/) follows the compiler, UDL vocabulary,
18
18
  and standard-library files. Run `bun run docs:build` after changing one of
19
19
  those sources. `bun run docs:check` compares every generated byte.
20
20
 
21
+ The [browser playground](./playground.md) provides a static editing surface with
22
+ live compilation, diagnostics inspection, and example programs. The hosted
23
+ playground is served at https://hyperscale0.ai/playground.
24
+
25
+ ## Examples and tooling
26
+
27
+ - [Standard library examples](../examples/README.md)
28
+ - [Browser playground](./playground.md)
29
+ - [VS Code extension](../editors/vscode/README.md)
30
+
31
+ ## Agent references
32
+
21
33
  Agents can start with [llms.txt](./llms.txt) or load the
22
34
  [HSX skill](../skills/hsx/SKILL.md). [llms-full.txt](./llms-full.txt) combines
23
35
  the guide and generated reference in reading order.
@@ -0,0 +1,18 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1200" height="360" viewBox="0 0 1200 360" role="img" aria-labelledby="title desc">
2
+ <title id="title">HSX</title>
3
+ <desc id="desc">Write a financial product. Compile its contract.</desc>
4
+ <rect width="1200" height="360" fill="#050505"/>
5
+ <path d="M48 48H1152M48 304H1152M944 48V304" fill="none" stroke="#303030"/>
6
+ <rect x="48" y="76" width="10" height="10" fill="#2f7dff"/>
7
+ <g font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace">
8
+ <text x="72" y="86" fill="#a3a3a3" font-size="14" letter-spacing="2">HYPERSCALE / DOCUMENTATION</text>
9
+ <text x="44" y="194" fill="#ffffff" font-size="76" letter-spacing="-4">HSX</text>
10
+ <text x="48" y="243" fill="#a3a3a3" font-size="20">Write a financial product. Compile its contract.</text>
11
+ <text x="48" y="334" fill="#a3a3a3" font-size="12" letter-spacing="2">LANGUAGE / STANDARD LIBRARY / COMPILER</text>
12
+ <text x="991" y="279" fill="#a3a3a3" font-size="12">SOURCE → CONTRACT</text>
13
+ </g>
14
+ <g fill="none" stroke="#2f7dff" stroke-width="2">
15
+ <path d="M990 110H1058V178H1126V246H1058V178H990Z"/>
16
+ <path d="M1058 110H1126V178H1058"/>
17
+ </g>
18
+ </svg>
@@ -1,12 +1,12 @@
1
1
  # Your first program
2
2
 
3
- An HSX file declares one program, the parties that take part, and the instruments that define its money rules. A settlement applies a standard-library instrument. The compiler checks the application and emits canonical UDL with a Business Frame, an origin map, and a cost manifest.
3
+ An HSX file declares one program, the parties that take part, and the instruments that define its money rules. A settlement applies a standard-library instrument. The compiler checks the application and emits canonical UDL with an origin map and a cost manifest.
4
4
 
5
5
  This program sends a tip from a listener to a host:
6
6
 
7
7
  ```hsx
8
8
  program tip_jar "Tip jar"
9
- import { instant_transfer } from "std/settlements"
9
+ import { instant_transfer } from "std/money_flows"
10
10
  party listener: person
11
11
  party host: business
12
12
  settlement tip = instant_transfer {
@@ -1,6 +1,6 @@
1
1
  # Money
2
2
 
3
- HSX indexes money by currency. `money<SAR>` is the field type inside a general instrument. `amount: total: money(SAR)` binds a settlement parameter to a new SAR money field. Values use integer minor units, so `1250` means SAR 12.50.
3
+ HSX indexes money by currency. `money<SAR>` is the field type inside a general instrument. `amount: total: money(SAR)` binds a settlement parameter to a new SAR money field. Values use integer minor units, so `1250` means SAR 12.50. The emitted UDL field keeps the currency as `x-hyperscale-currency`, which is how the platform learns a program's ledger currency.
4
4
 
5
5
  Money of different currencies never unifies. Percent literals use basis-point precision: `2%` is 200 basis points and `2.5%` is 250 basis points. The compiler floors percentage-derived minor units and assigns any declared remainder according to the selected instrument.
6
6
 
@@ -1,10 +1,10 @@
1
1
  # Instruments
2
2
 
3
- Start with the standard library. Import a settlement module by export name from `std/settlements`, then apply it under a local settlement name. The local name becomes the emitted instrument id.
3
+ Start with the money flows library (open/hsx/std). Import a money flow by export name from `std/money_flows`, then apply it under a local settlement name. The local name becomes the emitted instrument id.
4
4
 
5
5
  ```hsx
6
6
  program equipment_hire "Equipment hire"
7
- import { scheduled } from "std/settlements"
7
+ import { scheduled } from "std/money_flows"
8
8
  party renter: person
9
9
  party owner: business
10
10
  settlement installments = scheduled {
@@ -19,4 +19,45 @@ settlement installments = scheduled {
19
19
 
20
20
  Required parameters state the instrument's core contract. Optional parameters add bounded behavior such as a deadline, cancellation allocation, fee, or policy. Omit an optional block when the product does not need it. Do not pass an empty block as a substitute unless the module documents that form.
21
21
 
22
- The generated standard-library reference lists every module, parameter, action, port, and emitted clause. Read that page before choosing a module. Prefer one module that already states the required lifecycle over a custom instrument with copied mechanics.
22
+ The generated money flows reference lists every module, parameter, action, port, and emitted clause. Read that page before choosing a module. Prefer one module that already states the required lifecycle over a custom instrument with copied mechanics.
23
+
24
+ ## Account fields
25
+
26
+ 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.
27
+
28
+ ```hsx
29
+ fields {
30
+ customerAccountId: account<SAR>;
31
+ amount: money<SAR>;
32
+ }
33
+ ```
34
+
35
+ ## Port declarations and action clauses
36
+
37
+ HSX supports two distinct port syntaxes depending on scope:
38
+
39
+ 1. **Top-level port declarations** declare a named port at program scope using `allowed: [...]`.
40
+ 2. **Action-level port clauses** define caller permissions directly inside an instrument action using `allowed_parties: [...]`.
41
+
42
+ Top-level port declaration:
43
+
44
+ ```hsx
45
+ port confirm_delivery {
46
+ allowed: [buyer];
47
+ }
48
+ ```
49
+
50
+ Action-level port clause:
51
+
52
+ ```hsx
53
+ action release {
54
+ agent_description: "Release escrowed funds to the payee."
55
+ steps: [];
56
+ moves: [];
57
+ port {
58
+ allowed_parties: [payer];
59
+ }
60
+ }
61
+ ```
62
+
63
+ Writing `allowed:` inside an action-level `port` clause triggers diagnostic `HSX1508`. Use `allowed_parties: [...]` inside action clauses, and reserve `allowed: [...]` for top-level port declarations.
@@ -5,6 +5,7 @@ A lifecycle lists every state, names one initial state, and declares action tran
5
5
  ```hsx
6
6
  program approvals "Approvals"
7
7
  instrument approval {
8
+ agent_description: "Manage a bounded approval decision across pending, approved, and rejected states."
8
9
  title: "Approval"
9
10
  summary: "A bounded approval decision"
10
11
  fields {}
@@ -14,12 +15,26 @@ instrument approval {
14
15
  on approve: pending -> approved;
15
16
  on reject: pending -> rejected;
16
17
  }
17
- action create { steps: []; moves: []; }
18
- action approve { steps: []; moves: []; }
19
- action reject { steps: []; moves: []; }
18
+ action create {
19
+ agent_description: "Create an approval record in pending state."
20
+ steps: [];
21
+ moves: [];
22
+ }
23
+ action approve {
24
+ agent_description: "Approve the pending decision."
25
+ steps: [];
26
+ moves: [];
27
+ }
28
+ action reject {
29
+ agent_description: "Reject the pending decision."
30
+ steps: [];
31
+ moves: [];
32
+ }
20
33
  }
21
34
  ```
22
35
 
36
+ Every callable custom instrument action becomes an agent tool and requires an `agent_description` string. Instruments that declare callable actions also require an `agent_description` string. Actions that declare a `due` clause are exempt system actions that run on a schedule instead of an agent call. The compiler emits `HSX1509` when an author omits `agent_description` on an instrument or callable action.
37
+
23
38
  Standard-library instruments bind ports to caller decisions. A deadline appears as stored date data and a `due` clause on the action that may run at that date. An unwind states how a failed or cancelled path drains held value. The compiler refuses a reachable exit that strands money.
24
39
 
25
40
  Keep lifecycle changes additive after composition. Add a new action or state when old instances can still obey the previous contract. Do not rename a state or tighten an active transition in place.
@@ -4,7 +4,7 @@ Standard-library payment modules accept bounded fee forms. A payer fee sits on t
4
4
 
5
5
  ```hsx
6
6
  program lesson_market "Lesson market"
7
- import { instant_transfer, pooled_split } from "std/settlements"
7
+ import { instant_transfer, pooled_split } from "std/money_flows"
8
8
  party student: person
9
9
  party tutor: business
10
10
  party assistant: business
@@ -29,7 +29,7 @@ Every percentage partition must total 100 percent. `pooled_split` distributes a
29
29
 
30
30
  ```hsx
31
31
  program studio_booking "Studio booking"
32
- import { cancellable_booking } from "std/settlements"
32
+ import { cancellable_booking } from "std/money_flows"
33
33
  party guest: person
34
34
  party studio: business
35
35
  settlement session = cancellable_booking {
@@ -4,7 +4,7 @@ HSX schedules are finite. A literal `count`, an interval, and a first due date l
4
4
 
5
5
  ```hsx
6
6
  program installments "Installments"
7
- import { scheduled } from "std/settlements"
7
+ import { scheduled } from "std/money_flows"
8
8
  party buyer: person
9
9
  party seller: business
10
10
  settlement plan = scheduled {
@@ -4,7 +4,7 @@ One program can apply several instruments. Each instrument keeps its own lifecyc
4
4
 
5
5
  ```hsx
6
6
  program studio_sales "Studio sales"
7
- import { instant_transfer, scheduled } from "std/settlements"
7
+ import { instant_transfer, scheduled } from "std/money_flows"
8
8
  party buyer: person
9
9
  party studio: business
10
10
  settlement purchase = instant_transfer {
@@ -31,7 +31,7 @@ Keep each money route in one instrument. Connect instruments with evidence and r
31
31
 
32
32
  ```hsx
33
33
  program supplier_payment "Supplier payment"
34
- import { reconciled_payout } from "std/settlements"
34
+ import { reconciled_payout } from "std/money_flows"
35
35
  party treasury: business
36
36
  party supplier: business
37
37
  settlement payout = reconciled_payout {
@@ -44,3 +44,9 @@ settlement payout = reconciled_payout {
44
44
  matched_ceiling: 500
45
45
  }
46
46
  ```
47
+
48
+ ## Recomposition and exposed actions
49
+
50
+ When evolving an existing Product with new instruments or flows, the composer plans the candidate program against the active Product Build.
51
+
52
+ Public action exposures preserve stable semantic identities across builds. Unchanged authored instruments and catalog instruments retain their exposures without false removal and re-addition churn. Only genuinely new, removed, or rebound action aliases appear in the exposure delta.
@@ -5,6 +5,7 @@ A module is ordinary HSX source. It declares a dotted module name and exports te
5
5
  ```hsx
6
6
  program approval_example "Approval example"
7
7
  instrument approval() {
8
+ agent_description: "Reusable approval lifecycle template."
8
9
  title: "Approval"
9
10
  summary: "A reusable approval lifecycle"
10
11
  fields {}
@@ -13,12 +14,22 @@ instrument approval() {
13
14
  initial pending;
14
15
  on approve: pending -> approved;
15
16
  }
16
- action create { steps: []; moves: []; }
17
- action approve { steps: []; moves: []; }
17
+ action create {
18
+ agent_description: "Create a pending approval record."
19
+ steps: [];
20
+ moves: [];
21
+ }
22
+ action approve {
23
+ agent_description: "Approve the pending decision."
24
+ steps: [];
25
+ moves: [];
26
+ }
18
27
  }
19
28
  instrument review = approval()
20
29
  ```
21
30
 
31
+ Custom instruments and callable actions require `agent_description: "..."`. An agent uses these descriptions as tool instructions when invoking actions on an instance. Actions that declare a `due` clause run without an agent call and remain exempt from this requirement. Omitting `agent_description` on callable actions or their containing instruments triggers `HSX1509`.
32
+
22
33
  A parameter list makes an instrument a template, including an empty list. A concrete instrument without a parameter list emits directly when its file compiles. Export only the declarations that callers need.
23
34
 
24
35
  Imported exports carry the local declarations they reference. Identical declarations unify. Conflicting declarations report `HSX1009`. Keep module parameters typed, keep loops finite, and use UDL clause vocabulary for instrument and action mechanics.
@@ -4,7 +4,7 @@ Compilation emits a deterministic cost manifest beside the UDL document. The man
4
4
 
5
5
  ```hsx
6
6
  program direct_sale "Direct sale"
7
- import { instant_transfer } from "std/settlements"
7
+ import { instant_transfer } from "std/money_flows"
8
8
  party buyer: person
9
9
  party seller: business
10
10
  settlement sale = instant_transfer {
@@ -17,8 +17,8 @@ settlement sale = instant_transfer {
17
17
 
18
18
  Read an action line as `instrument.action`, followed by the effect signature and its count. The payer tells whether the product or end customer bears the row. `perEventMinor` prices one occurrence in the cost table's billing currency. A row with `bps` also names a volume meter.
19
19
 
20
- The monthly estimate is an expression over declared meter variables. Billing supplies observed readings to that frozen expression. Recomposition emits a new manifest for the next commercial snapshot. It does not rewrite a prior manifest.
20
+ The monthly estimate is an expression over declared meter variables. Billing supplies observed readings to that frozen expression. Recomposition emits a new manifest for the next commercial snapshot. It does not rewrite a prior manifest. During recomposition planning, compose plan calculates the candidate program's proposed estimate and reconciles it against the current Build's frozen pricing quote. The existing Product retains its frozen quote until the recomposition is applied.
21
21
 
22
- An effect without a price row reports `HSX1301`. An invalid price reports `HSX1302`. A missing cost table also reports `HSX1301`. Use the single rate card shipped at `examples/cost-table.json`; do not create a second table for documentation.
22
+ An effect without a price row reports `HSX1301`. An invalid price reports `HSX1302`. A missing cost table also reports `HSX1301`. `examples/cost-table.json` ships one rate card per priced billing currency; the compiler picks the card whose currency the program's money fields move. Money in a currency no card prices reports `HSX1304`, and money in two currencies reports `HSX1305`: a program bills in one ledger currency. Do not create another table for documentation.
23
23
 
24
24
  Do not confuse an action `quote` with the commercial cost manifest. `cancellable_booking.cancel` quotes a customer-visible cancellation penalty and `confirm` commits it. The compiler counts an instrument that carries a quote as unwind work because an expired or abandoned offer still needs bounded cleanup. The cost manifest prices that runtime work from the shipped rate card. It does not replace, spend, or alter the quoted financial amount.
@@ -13,7 +13,7 @@ Use one loop: compile, find the first error code in the diagnostics reference, a
13
13
 
14
14
  ```hsx
15
15
  program repaired_transfer "Repaired transfer"
16
- import { instant_transfer } from "std/settlements"
16
+ import { instant_transfer } from "std/money_flows"
17
17
  party sender: person
18
18
  party recipient: business
19
19
  settlement transfer = instant_transfer {