@hyperscale0/hsx 2.4.0 → 3.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 (249) hide show
  1. package/CHANGELOG.md +2 -400
  2. package/README.md +3 -92
  3. package/dist/src/ast.d.ts +99 -310
  4. package/dist/src/ast.d.ts.map +1 -1
  5. package/dist/src/ast.js +16 -69
  6. package/dist/src/ast.js.map +1 -1
  7. package/dist/src/cli.d.ts +6 -19
  8. package/dist/src/cli.d.ts.map +1 -1
  9. package/dist/src/cli.js +76 -315
  10. package/dist/src/cli.js.map +1 -1
  11. package/dist/src/compile.d.ts +23 -73
  12. package/dist/src/compile.d.ts.map +1 -1
  13. package/dist/src/compile.js +1113 -148
  14. package/dist/src/compile.js.map +1 -1
  15. package/dist/src/cost.d.ts +8 -77
  16. package/dist/src/cost.d.ts.map +1 -1
  17. package/dist/src/cost.js +13 -422
  18. package/dist/src/cost.js.map +1 -1
  19. package/dist/src/format.d.ts +8 -7
  20. package/dist/src/format.d.ts.map +1 -1
  21. package/dist/src/format.js +9 -175
  22. package/dist/src/format.js.map +1 -1
  23. package/dist/src/headers.d.ts +35 -0
  24. package/dist/src/headers.d.ts.map +1 -0
  25. package/dist/src/headers.js +108 -0
  26. package/dist/src/headers.js.map +1 -0
  27. package/dist/src/index.d.ts +6 -12
  28. package/dist/src/index.d.ts.map +1 -1
  29. package/dist/src/index.js +4 -9
  30. package/dist/src/index.js.map +1 -1
  31. package/dist/src/lex.d.ts +8 -28
  32. package/dist/src/lex.d.ts.map +1 -1
  33. package/dist/src/lex.js +88 -146
  34. package/dist/src/lex.js.map +1 -1
  35. package/dist/src/parse.d.ts +4 -17
  36. package/dist/src/parse.d.ts.map +1 -1
  37. package/dist/src/parse.js +402 -1040
  38. package/dist/src/parse.js.map +1 -1
  39. package/dist/src/std-bundle.d.ts.map +1 -1
  40. package/dist/src/std-bundle.js +12 -20
  41. package/dist/src/std-bundle.js.map +1 -1
  42. package/dist/src/std-library.d.ts +1 -1
  43. package/dist/src/std-library.d.ts.map +1 -1
  44. package/dist/src/std-library.js +1 -5
  45. package/dist/src/std-library.js.map +1 -1
  46. package/dist/src/tunables.d.ts +7 -0
  47. package/dist/src/tunables.d.ts.map +1 -0
  48. package/dist/src/tunables.js +26 -0
  49. package/dist/src/tunables.js.map +1 -0
  50. package/dist/src/version.d.ts +2 -4
  51. package/dist/src/version.d.ts.map +1 -1
  52. package/dist/src/version.js +2 -4
  53. package/dist/src/version.js.map +1 -1
  54. package/docs/README.md +179 -41
  55. package/docs/headers.md +44 -0
  56. package/examples/cost-table.json +99 -751
  57. package/examples/library.hsx +59 -0
  58. package/package.json +9 -17
  59. package/src/ast.ts +82 -441
  60. package/src/cli.ts +77 -362
  61. package/src/compile.ts +1535 -247
  62. package/src/cost.ts +28 -671
  63. package/src/format.ts +12 -256
  64. package/src/headers.ts +126 -0
  65. package/src/index.ts +7 -39
  66. package/src/lex.ts +99 -195
  67. package/src/parse.ts +403 -1209
  68. package/src/std-bundle.ts +12 -20
  69. package/src/std-library.ts +2 -7
  70. package/src/tunables.ts +31 -0
  71. package/src/version.ts +2 -5
  72. package/std/approvals.hsx +17 -0
  73. package/std/cards.hsx +63 -0
  74. package/std/collections.hsx +31 -0
  75. package/std/escrow.hsx +43 -0
  76. package/std/financing.hsx +372 -0
  77. package/std/insurance.hsx +59 -0
  78. package/std/lending.hsx +115 -0
  79. package/std/marketplace.hsx +24 -0
  80. package/std/money.hsx +195 -0
  81. package/std/savings.hsx +44 -0
  82. package/std/travel.hsx +98 -0
  83. package/std/wallet.hsx +41 -0
  84. package/dist/src/diagnostics.d.ts +0 -13
  85. package/dist/src/diagnostics.d.ts.map +0 -1
  86. package/dist/src/diagnostics.js +0 -587
  87. package/dist/src/diagnostics.js.map +0 -1
  88. package/dist/src/emit.d.ts +0 -51
  89. package/dist/src/emit.d.ts.map +0 -1
  90. package/dist/src/emit.js +0 -192
  91. package/dist/src/emit.js.map +0 -1
  92. package/dist/src/entry-overrides.d.ts +0 -58
  93. package/dist/src/entry-overrides.d.ts.map +0 -1
  94. package/dist/src/entry-overrides.js +0 -284
  95. package/dist/src/entry-overrides.js.map +0 -1
  96. package/dist/src/ir.d.ts +0 -73
  97. package/dist/src/ir.d.ts.map +0 -1
  98. package/dist/src/ir.js +0 -15
  99. package/dist/src/ir.js.map +0 -1
  100. package/dist/src/limits.d.ts +0 -23
  101. package/dist/src/limits.d.ts.map +0 -1
  102. package/dist/src/limits.js +0 -23
  103. package/dist/src/limits.js.map +0 -1
  104. package/dist/src/lsp/server.d.ts +0 -32
  105. package/dist/src/lsp/server.d.ts.map +0 -1
  106. package/dist/src/lsp/server.js +0 -391
  107. package/dist/src/lsp/server.js.map +0 -1
  108. package/dist/src/modules.d.ts +0 -38
  109. package/dist/src/modules.d.ts.map +0 -1
  110. package/dist/src/modules.js +0 -372
  111. package/dist/src/modules.js.map +0 -1
  112. package/dist/src/typecheck.d.ts +0 -8
  113. package/dist/src/typecheck.d.ts.map +0 -1
  114. package/dist/src/typecheck.js +0 -4131
  115. package/dist/src/typecheck.js.map +0 -1
  116. package/docs/guide/01-first-program.md +0 -24
  117. package/docs/guide/02-money.md +0 -25
  118. package/docs/guide/03-instruments.md +0 -93
  119. package/docs/guide/04-lifecycles.md +0 -40
  120. package/docs/guide/05-fees-and-splits.md +0 -45
  121. package/docs/guide/06-schedules.md +0 -26
  122. package/docs/guide/07-composition.md +0 -52
  123. package/docs/guide/08-writing-a-module.md +0 -85
  124. package/docs/guide/09-cost.md +0 -24
  125. package/docs/guide/10-diagnostics.md +0 -27
  126. package/docs/llms-full.txt +0 -3684
  127. package/docs/llms.txt +0 -44
  128. package/docs/piece-plans.md +0 -120
  129. package/docs/playground.md +0 -55
  130. package/docs/reference/cli.md +0 -36
  131. package/docs/reference/diagnostics.md +0 -901
  132. package/docs/reference/grammar.md +0 -38
  133. package/docs/reference/std/advance.md +0 -112
  134. package/docs/reference/std/cancellable_booking.md +0 -159
  135. package/docs/reference/std/captured_payment.md +0 -115
  136. package/docs/reference/std/conditional_disbursement.md +0 -101
  137. package/docs/reference/std/credit_facility.md +0 -108
  138. package/docs/reference/std/held_payment.md +0 -173
  139. package/docs/reference/std/instant_transfer.md +0 -97
  140. package/docs/reference/std/metered.md +0 -89
  141. package/docs/reference/std/pooled_split.md +0 -95
  142. package/docs/reference/std/premium_forward.md +0 -119
  143. package/docs/reference/std/reconciled_payout.md +0 -103
  144. package/docs/reference/std/rotating_pool.md +0 -130
  145. package/docs/reference/std/scheduled.md +0 -136
  146. package/docs/reference/std/security_deposit.md +0 -138
  147. package/docs/reference/std/settlement_batch.md +0 -123
  148. package/docs/reference/std/swap.md +0 -133
  149. package/docs/reference/std/threshold_pool.md +0 -138
  150. package/docs/reference/std/weighted_distribution.md +0 -135
  151. package/docs/reference/types.md +0 -61
  152. package/docs/reference/udl-output.md +0 -13
  153. package/examples/01-first-program/README.md +0 -45
  154. package/examples/01-first-program/tip-jar.hsx +0 -17
  155. package/examples/02-imports-and-modules/README.md +0 -96
  156. package/examples/02-imports-and-modules/photo-booth.hsx +0 -37
  157. package/examples/03-diagnostics/README.md +0 -68
  158. package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
  159. package/examples/03-diagnostics/corner-shop.hsx +0 -19
  160. package/examples/04-complete-product/README.md +0 -84
  161. package/examples/04-complete-product/study-hall.hsx +0 -67
  162. package/examples/05-authored-instrument/README.md +0 -5
  163. package/examples/05-authored-instrument/payment.hsx +0 -37
  164. package/examples/05-watch-club/README.md +0 -6
  165. package/examples/05-watch-club/watch-club.hsx +0 -123
  166. package/examples/README.md +0 -48
  167. package/examples/advance/README.md +0 -3
  168. package/examples/advance/advance.hsx +0 -13
  169. package/examples/advance/advance.udl +0 -367
  170. package/examples/cancellable_booking/README.md +0 -3
  171. package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
  172. package/examples/cancellable_booking/cancellable_booking.udl +0 -413
  173. package/examples/captured_payment/README.md +0 -3
  174. package/examples/captured_payment/captured_payment.hsx +0 -17
  175. package/examples/captured_payment/captured_payment.udl +0 -686
  176. package/examples/conditional_disbursement/README.md +0 -3
  177. package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -15
  178. package/examples/conditional_disbursement/conditional_disbursement.udl +0 -418
  179. package/examples/credit_facility/README.md +0 -3
  180. package/examples/credit_facility/credit_facility.hsx +0 -24
  181. package/examples/credit_facility/credit_facility.udl +0 -1396
  182. package/examples/held_payment/README.md +0 -3
  183. package/examples/held_payment/held_payment.hsx +0 -13
  184. package/examples/held_payment/held_payment.udl +0 -569
  185. package/examples/instant_transfer/README.md +0 -3
  186. package/examples/instant_transfer/instant_transfer.hsx +0 -16
  187. package/examples/instant_transfer/instant_transfer.udl +0 -376
  188. package/examples/metered/README.md +0 -3
  189. package/examples/metered/metered.hsx +0 -13
  190. package/examples/metered/metered.udl +0 -253
  191. package/examples/pooled_split/README.md +0 -3
  192. package/examples/pooled_split/pooled_split.hsx +0 -15
  193. package/examples/pooled_split/pooled_split.udl +0 -432
  194. package/examples/premium_forward/README.md +0 -3
  195. package/examples/premium_forward/premium_forward.hsx +0 -19
  196. package/examples/premium_forward/premium_forward.udl +0 -604
  197. package/examples/reconciled_payout/README.md +0 -3
  198. package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
  199. package/examples/reconciled_payout/reconciled_payout.udl +0 -312
  200. package/examples/rotating_pool/README.md +0 -3
  201. package/examples/rotating_pool/rotating_pool.hsx +0 -18
  202. package/examples/rotating_pool/rotating_pool.udl +0 -4370
  203. package/examples/scheduled/README.md +0 -3
  204. package/examples/scheduled/scheduled.hsx +0 -12
  205. package/examples/scheduled/scheduled.udl +0 -355
  206. package/examples/security_deposit/README.md +0 -3
  207. package/examples/security_deposit/security_deposit.hsx +0 -21
  208. package/examples/security_deposit/security_deposit.udl +0 -320
  209. package/examples/settlement_batch/README.md +0 -3
  210. package/examples/settlement_batch/settlement_batch.hsx +0 -19
  211. package/examples/settlement_batch/settlement_batch.udl +0 -757
  212. package/examples/swap/README.md +0 -3
  213. package/examples/swap/swap.hsx +0 -19
  214. package/examples/swap/swap.udl +0 -892
  215. package/examples/threshold_pool/README.md +0 -3
  216. package/examples/threshold_pool/threshold_pool.hsx +0 -16
  217. package/examples/threshold_pool/threshold_pool.udl +0 -680
  218. package/examples/weighted_distribution/README.md +0 -3
  219. package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
  220. package/examples/weighted_distribution/weighted_distribution.udl +0 -348
  221. package/skills/hsx/SKILL.md +0 -449
  222. package/src/diagnostics.ts +0 -620
  223. package/src/emit.ts +0 -282
  224. package/src/entry-overrides.ts +0 -428
  225. package/src/ir.ts +0 -113
  226. package/src/limits.ts +0 -22
  227. package/src/lsp/server.ts +0 -460
  228. package/src/modules.ts +0 -452
  229. package/src/typecheck.ts +0 -5381
  230. package/std/SEMANTICS.md +0 -44
  231. package/std/money_flows/advance.hsx +0 -235
  232. package/std/money_flows/cancellable_booking.hsx +0 -402
  233. package/std/money_flows/captured_payment.hsx +0 -220
  234. package/std/money_flows/conditional_disbursement.hsx +0 -226
  235. package/std/money_flows/credit_facility.hsx +0 -214
  236. package/std/money_flows/held_payment.hsx +0 -812
  237. package/std/money_flows/index.hsx +0 -4
  238. package/std/money_flows/instant_transfer.hsx +0 -231
  239. package/std/money_flows/metered.hsx +0 -104
  240. package/std/money_flows/pooled_split.hsx +0 -109
  241. package/std/money_flows/premium_forward.hsx +0 -307
  242. package/std/money_flows/reconciled_payout.hsx +0 -119
  243. package/std/money_flows/rotating_pool.hsx +0 -305
  244. package/std/money_flows/scheduled.hsx +0 -599
  245. package/std/money_flows/security_deposit.hsx +0 -248
  246. package/std/money_flows/settlement_batch.hsx +0 -173
  247. package/std/money_flows/swap.hsx +0 -1192
  248. package/std/money_flows/threshold_pool.hsx +0 -307
  249. package/std/money_flows/weighted_distribution.hsx +0 -237
@@ -1,620 +0,0 @@
1
- export interface HsxDiagnosticCatalogEntry {
2
- readonly code: `HSX${number}`;
3
- readonly stage: "bind" | "lower" | "parse" | "typecheck";
4
- readonly title: string;
5
- readonly fix: string;
6
- readonly example: string | null;
7
- readonly reason?: string;
8
- }
9
-
10
- const instrument = (
11
- body: string,
12
- fields = "",
13
- ): string => `program catalog_probe "Catalog probe"
14
- instrument probe {
15
- agent_description: "Probe instrument for catalog diagnostics.";
16
- fields { ${fields} }
17
- lifecycle { states created; initial created; }
18
- action create {
19
- agent_description: "Create a probe instance.";
20
- steps: [];
21
- }
22
- ${body}
23
- }`;
24
-
25
- /** Stable public descriptions for every diagnostic code emitted by HSX. */
26
- export const hsxDiagnostics: readonly HsxDiagnosticCatalogEntry[] = [
27
- {
28
- code: "HSX1000",
29
- stage: "typecheck",
30
- title: "Missing file declaration",
31
- fix: "Add one program header or module declaration.",
32
- example: "",
33
- },
34
- {
35
- code: "HSX1001",
36
- stage: "bind",
37
- title: "Unbound name",
38
- fix: "Declare or import the name before using it.",
39
- example:
40
- 'program catalog_probe "Catalog probe"\ninstrument probe = missing()',
41
- },
42
- {
43
- code: "HSX1002",
44
- stage: "typecheck",
45
- title: "Duplicate program declaration",
46
- fix: "Keep exactly one program declaration.",
47
- example: `${instrument("")}\nprogram second "Second"`,
48
- },
49
- {
50
- code: "HSX1003",
51
- stage: "typecheck",
52
- title: "Invalid declaration name",
53
- fix: "Use lowercase snake_case for program and instrument names.",
54
- example: 'program NotSnake "Catalog probe"',
55
- },
56
- {
57
- code: "HSX1004",
58
- stage: "typecheck",
59
- title: "Duplicate declaration",
60
- fix: "Keep one declaration or give each declaration a distinct name.",
61
- example: `${instrument("")}\ninstrument probe { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }`,
62
- },
63
- {
64
- code: "HSX1005",
65
- stage: "typecheck",
66
- title: "Invalid field name",
67
- fix: "Rename the field in lower camelCase.",
68
- // The parser normalizes every accepted source field spelling to lower camelCase.
69
- example: null,
70
- reason:
71
- "The parser normalizes every accepted field spelling before typechecking.",
72
- },
73
- {
74
- code: "HSX1006",
75
- stage: "bind",
76
- title: "Invalid module import",
77
- fix: "Resolve one module that exports each imported name exactly once.",
78
- // A source string cannot control the compiler host's module resolver.
79
- example: null,
80
- reason: "This refusal requires a compiler-host module resolver result.",
81
- },
82
- {
83
- code: "HSX1007",
84
- stage: "typecheck",
85
- title: "Invalid cross-instrument reference",
86
- fix: "Name an existing target instrument in the ref type.",
87
- example: `program catalog_probe "Catalog probe"
88
- instrument probe {
89
- fields { parentId { type: ref; description: "Parent"; } }
90
- lifecycle { states created; initial created; }
91
- action create { steps: []; }
92
- }`,
93
- },
94
- {
95
- code: "HSX1008",
96
- stage: "typecheck",
97
- title: "Invalid subject or decision port",
98
- fix: "Complete the declaration and bind every referenced decision port.",
99
- example: `${instrument("")}\nsubject vehicle { title: "Vehicle"; }`,
100
- },
101
- {
102
- code: "HSX1009",
103
- stage: "bind",
104
- title: "Imported declaration collision",
105
- fix: "Rename the importer-owned declaration or the module-local declaration.",
106
- // A source string cannot create a collision in a compiler-host module result.
107
- example: null,
108
- reason:
109
- "This refusal requires declarations returned by a compiler-host module resolver.",
110
- },
111
- {
112
- code: "HSX1010",
113
- stage: "typecheck",
114
- title: "Wrong type-argument count",
115
- fix: "Supply exactly the type arguments declared by the instrument function.",
116
- example: `program catalog_probe "Catalog probe"
117
- export instrument template<C>() { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
118
- instrument probe = template<SAR, USD>()`,
119
- },
120
- {
121
- code: "HSX1011",
122
- stage: "typecheck",
123
- title: "Missing required argument",
124
- fix: "Pass every required instrument-function argument.",
125
- example: `program catalog_probe "Catalog probe"
126
- export instrument template(value: text) { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
127
- instrument probe = template()`,
128
- },
129
- {
130
- code: "HSX1012",
131
- stage: "typecheck",
132
- title: "Unknown named argument",
133
- fix: "Remove the argument or use a parameter declared by the instrument function.",
134
- example: `program catalog_probe "Catalog probe"
135
- export instrument template() { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
136
- instrument probe = template(typo: true)`,
137
- },
138
- {
139
- code: "HSX1013",
140
- stage: "typecheck",
141
- title: "Duplicate named argument",
142
- fix: "Pass each named argument once.",
143
- example: `program catalog_probe "Catalog probe"
144
- export instrument template(value: text) { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
145
- instrument probe = template(value: "one", value: "two")`,
146
- },
147
- {
148
- code: "HSX1014",
149
- stage: "parse",
150
- title: "JSON supplied as HSX",
151
- fix: "Replace the JSON object with HSX declarations.",
152
- example: '{ "hsx": 1 }',
153
- },
154
- {
155
- code: "HSX1015",
156
- stage: "typecheck",
157
- title: "Invalid composed program identity",
158
- fix: "Give the composed program a bounded product id and title.",
159
- // This diagnostic requires a compiler-host published catalog.
160
- example: null,
161
- reason: "This refusal requires a compiler-host published catalog.",
162
- },
163
- {
164
- code: "HSX1016",
165
- stage: "typecheck",
166
- title: "Empty published composition",
167
- fix: "Select at least one published instrument with use.",
168
- // This diagnostic requires a compiler-host published catalog.
169
- example: null,
170
- reason: "This refusal requires a compiler-host published catalog.",
171
- },
172
- {
173
- code: "HSX1017",
174
- stage: "typecheck",
175
- title: "Duplicate published instrument",
176
- fix: "Keep one use declaration for each published instrument.",
177
- // This diagnostic requires a compiler-host published catalog.
178
- example: null,
179
- reason: "This refusal requires a compiler-host published catalog.",
180
- },
181
- {
182
- code: "HSX1018",
183
- stage: "typecheck",
184
- title: "Unavailable published instrument",
185
- fix: "Use an instrument id from the supplied published catalog.",
186
- example: 'program catalog_probe "Catalog probe"\nuse missing',
187
- },
188
- {
189
- code: "HSX1020",
190
- stage: "typecheck",
191
- title: "Invalid public action name",
192
- fix: "Expose each action once under a distinct lower camelCase name.",
193
- // This diagnostic requires a compiler-host published catalog.
194
- example: null,
195
- reason: "This refusal requires a compiler-host published catalog.",
196
- },
197
- {
198
- code: "HSX1021",
199
- stage: "typecheck",
200
- title: "Invalid exposed action",
201
- fix: "Expose an action on an explicitly used published instrument.",
202
- // This diagnostic requires a compiler-host published catalog.
203
- example: null,
204
- reason: "This refusal requires a compiler-host published catalog.",
205
- },
206
- {
207
- code: "HSX1022",
208
- stage: "typecheck",
209
- title: "Authored instrument collides with published catalog",
210
- fix: "Rename the authored instrument to avoid colliding with published catalog instruments.",
211
- // This diagnostic requires a compiler-host published catalog.
212
- example: null,
213
- reason: "This refusal requires a compiler-host published catalog.",
214
- },
215
- {
216
- code: "HSX1023",
217
- stage: "typecheck",
218
- title: "Invalid required-field list",
219
- fix: "List declared, non-optional field names once each.",
220
- example: instrument("required: missing;"),
221
- },
222
- {
223
- code: "HSX1024",
224
- stage: "typecheck",
225
- title: "Decision party has no matching account binding",
226
- fix: "Bind the allowed party to an account field and use that binding in the decision action.",
227
- example: `program decision_binding "Decision binding"
228
- party buyer: person
229
- party seller: business
230
- port approve { allowed: [buyer] }
231
- instrument gated(decision: condition) {
232
- fields {}
233
- parties { payer: seller }
234
- lifecycle { states created done; initial created; on approve: created -> done; }
235
- action create { steps: []; }
236
- action [decision] { steps: []; port { allowed_parties: [payer]; } }
237
- }
238
- instrument gate = gated(decision: port approve)`,
239
- },
240
- {
241
- code: "HSX1025",
242
- stage: "typecheck",
243
- title: "Unknown decision port shape type",
244
- fix: "Declare the shape field as text, money(CUR), date, integer, boolean, account(CUR), ref<instrument_id>, id(instrument_id), bps, or percent.",
245
- example: `program catalog_probe "Catalog probe"
246
- import { security_deposit } from "std/money_flows"
247
- party buyer: person
248
- party seller: business
249
- settlement hold = security_deposit {
250
- payer: buyer
251
- holder: seller
252
- amount: depositAmount: money(SAR)
253
- claim: port report_damage
254
- claim_amount: { field: damageAmount, bound: depositAmount, remainder: return }
255
- return: port pass_inspection
256
- }
257
- port report_damage { allowed: [seller] shape { damageAmount: money(SAR) } }
258
- port pass_inspection { allowed: [seller] shape { invalidField: mystery_type } }`,
259
- },
260
- {
261
- code: "HSX1026",
262
- stage: "typecheck",
263
- title: "Decision port input type mismatch with instrument capture field",
264
- fix: "Declare the decision port input field with the type expected by the instrument capture field.",
265
- // This diagnostic requires a compiler-host published catalog.
266
- example: null,
267
- reason: "This refusal requires a compiler-host published catalog.",
268
- },
269
- {
270
- code: "HSX1101",
271
- stage: "typecheck",
272
- title: "Currency mismatch",
273
- fix: "Use the declared currency because money values never coerce.",
274
- example: `${instrument("")}\nconst fee: money<SAR> = USD 1.00`,
275
- },
276
- {
277
- code: "HSX1102",
278
- stage: "typecheck",
279
- title: "Money precision exceeds minor units",
280
- fix: "Round the literal to the currency's minor-unit precision.",
281
- example: `${instrument("")}\nconst fee: money<SAR> = SAR 1.001`,
282
- },
283
- {
284
- code: "HSX1103",
285
- stage: "typecheck",
286
- title: "Invalid numeric value",
287
- fix: "Use an integer, percent, bps, or valid fixed-money binding.",
288
- example: instrument("summary: 1.5;"),
289
- },
290
- {
291
- code: "HSX1104",
292
- stage: "typecheck",
293
- title: "Value has the wrong type",
294
- fix: "Pass the type declared by the parameter or UDL slot.",
295
- example: instrument("summary: money(SAR, 2500);"),
296
- },
297
- {
298
- code: "HSX1105",
299
- stage: "typecheck",
300
- title: "allow_zero needs a money field",
301
- fix: "Put allow_zero: true on a money field, or remove it; amounts are strictly positive unless a money field opts in.",
302
- example: instrument("", "memo { type: text; allow_zero: true; }"),
303
- },
304
- {
305
- code: "HSX1110",
306
- stage: "typecheck",
307
- title: "Unsupported parameter combination",
308
- fix: "Choose a supported compile-time parameter combination.",
309
- example: `program catalog_probe "Catalog probe"
310
- export instrument template() {
311
- unsupported { message: "Not supported"; fix: "Choose another form"; }
312
- fields {}
313
- lifecycle { states created; initial created; }
314
- action create { steps: []; }
315
- }
316
- instrument probe = template()`,
317
- },
318
- {
319
- code: "HSX1201",
320
- stage: "typecheck",
321
- title: "Linear money consumed more than once",
322
- fix: "Leave exactly one sink for each produced money value.",
323
- example: instrument(`fields { amount: money<SAR>; }
324
- action pay { computes remainder rest { amount_ref: total; on_zero: refuse; total_path: fields.amount; }; moves: [{ amount: rest; }, { amount: rest; }]; }`),
325
- },
326
- {
327
- code: "HSX1202",
328
- stage: "typecheck",
329
- title: "Linear money is unconsumed",
330
- fix: "Route each produced money value to one explicit sink.",
331
- example: instrument(`fields { amount: money<SAR>; }
332
- action pay { computes remainder rest { amount_ref: total; on_zero: refuse; total_path: fields.amount; }; }`),
333
- },
334
- {
335
- code: "HSX1301",
336
- stage: "typecheck",
337
- title: "Missing cost-table price",
338
- fix: "Supply a versioned cost table with a row for every emitted effect.",
339
- example: instrument(""),
340
- },
341
- {
342
- code: "HSX1302",
343
- stage: "typecheck",
344
- title: "Invalid cost-table row",
345
- fix: "Use non-negative integer prices and a supported settlement timing.",
346
- // A source string cannot make the compiler host's cost table malformed.
347
- example: null,
348
- reason: "This refusal requires a malformed compiler-host cost table.",
349
- },
350
- {
351
- code: "HSX1303",
352
- stage: "typecheck",
353
- title: "Invalid cost-table currency",
354
- fix: "Use the supported uppercase cost-table currency.",
355
- // A source string cannot change the compiler host's cost-table currency.
356
- example: null,
357
- reason:
358
- "This refusal requires an invalid compiler-host cost-table currency.",
359
- },
360
- {
361
- code: "HSX1304",
362
- stage: "typecheck",
363
- title: "Unpriced ledger currency",
364
- fix: "Move money in a currency the shipped cost tables price.",
365
- example: instrument("", "amount: money<JPY>;"),
366
- },
367
- {
368
- code: "HSX1305",
369
- stage: "typecheck",
370
- title: "More than one ledger currency",
371
- fix: "Move all money in one currency; a program bills in one ledger currency.",
372
- example: instrument("", "amount: money<SAR>; fee: money<USD>;"),
373
- },
374
- {
375
- code: "HSX1306",
376
- stage: "typecheck",
377
- title: "Fixed-currency amount moved in another currency",
378
- fix: "Bind the currency of a money<CUR> move or account step as the constant CUR; the compiler pins a binding that reads the instrument's currency field.",
379
- example: instrument(
380
- `action pay { agent_description: "Pay the amount."; moves: [{ "bind": { "amount": { "from": "instance"; "path": "fields.amount"; }; "currency": { "from": "const"; "value": "USD"; }; "destinationAccountId": { "from": "instance"; "path": "fields.payeeAccountId"; }; "sourceAccountId": { "from": "instance"; "path": "fields.payerAccountId"; }; }; "key": "transfer"; "operation": "internal_transfer.create"; }]; steps: []; }`,
381
- "amount: money<SAR>; payeeAccountId: account<SAR>; payerAccountId: account<SAR>;",
382
- ),
383
- },
384
- {
385
- code: "HSX1401",
386
- stage: "typecheck",
387
- title: "Unbounded action",
388
- fix: "Replace runtime iteration with a bounded compile-time comprehension.",
389
- example: instrument("action run { while { condition: true; }; }"),
390
- },
391
- {
392
- code: "HSX1402",
393
- stage: "typecheck",
394
- title: "Missing lifecycle",
395
- fix: "Declare lifecycle states and an initial state.",
396
- example:
397
- 'program catalog_probe "Catalog probe"\ninstrument probe { fields {}; action create { steps: []; }; }',
398
- },
399
- {
400
- code: "HSX1403",
401
- stage: "typecheck",
402
- title: "Runtime comprehension bound",
403
- fix: "Use an integer literal or literal finite list as the bound.",
404
- example: `program catalog_probe "Catalog probe"
405
- export instrument template(count: integer) {
406
- fields {}
407
- lifecycle { states created; initial created; }
408
- action create { steps: []; }
409
- for item in count { action run_[item] { steps: []; } }
410
- }
411
- instrument probe = template(count: runtimeCount: integer)`,
412
- },
413
- {
414
- code: "HSX1404",
415
- stage: "typecheck",
416
- title: "Comprehension expansion limit",
417
- fix: "Reduce the fixed expansion to the compiler limit.",
418
- example: instrument("for item in 257 { action run_[item] { steps: []; } }"),
419
- },
420
- {
421
- code: "HSX1405",
422
- stage: "typecheck",
423
- title: "Invalid compile-time selection",
424
- fix: "Give compile-time conditions and unsupported branches fixed blocks.",
425
- example: `program catalog_probe "Catalog probe"
426
- export instrument template() { unsupported: true; fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
427
- instrument probe = template()`,
428
- },
429
- {
430
- code: "HSX1406",
431
- stage: "typecheck",
432
- title: "Invalid companion instrument",
433
- fix: "Construct each companion with a compile-time id.",
434
- example: `program catalog_probe "Catalog probe"
435
- export instrument template() {
436
- fields {}
437
- lifecycle { states created; initial created; }
438
- action create { steps: []; }
439
- instruments { invalid: true; }
440
- }
441
- instrument probe = template()`,
442
- },
443
- {
444
- code: "HSX1501",
445
- stage: "typecheck",
446
- title: "Unknown UDL clause",
447
- fix: "Use a clause exported by the targeted UDL vocabulary.",
448
- example: instrument("unknown_clause: true;"),
449
- },
450
- {
451
- code: "HSX1502",
452
- stage: "typecheck",
453
- title: "Program emits no instruments",
454
- fix: "Declare or instantiate at least one instrument.",
455
- example: 'program catalog_probe "Catalog probe"',
456
- },
457
- {
458
- code: "HSX1503",
459
- stage: "typecheck",
460
- title: "Missing fields block",
461
- fix: "Add a fields block, even when it is empty.",
462
- example:
463
- 'program catalog_probe "Catalog probe"\ninstrument probe { lifecycle { states created; initial created; }; action create { steps: []; }; }',
464
- },
465
- {
466
- code: "HSX1504",
467
- stage: "typecheck",
468
- title: "Missing create action",
469
- fix: "Add an action create block.",
470
- example:
471
- 'program catalog_probe "Catalog probe"\ninstrument probe { fields {}; lifecycle { states created; initial created; }; }',
472
- },
473
- {
474
- code: "HSX1505",
475
- stage: "typecheck",
476
- title: "Repeated single-valued clause",
477
- fix: "Keep one occurrence of the clause.",
478
- example: instrument('title: "First"; title: "Second";'),
479
- },
480
- {
481
- code: "HSX1506",
482
- stage: "typecheck",
483
- title: "Conflicting public action settings",
484
- fix: "Keep either public: none or a public action name.",
485
- example: instrument(
486
- "action finish { public: none; public_action: finishProbe; steps: []; }",
487
- ),
488
- },
489
- {
490
- code: "HSX1507",
491
- stage: "typecheck",
492
- title: "Invalid application metadata",
493
- fix: "Keep contract mechanics in the parameterized instrument.",
494
- example: `program catalog_probe "Catalog probe"
495
- export instrument template() { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
496
- instrument probe = template() { fields: {}; }`,
497
- },
498
- {
499
- code: "HSX1508",
500
- stage: "typecheck",
501
- title: "Invalid action-level port syntax",
502
- fix: "Use allowed_parties: [...] inside an action-level port clause; allowed: is for top-level port declarations.",
503
- example: `program catalog_probe "Catalog probe"
504
- party approver: person
505
- instrument probe {
506
- fields {}
507
- lifecycle { states created; initial created; }
508
- action create {
509
- steps: [];
510
- port { allowed: [approver]; }
511
- }
512
- }`,
513
- },
514
- {
515
- code: "HSX1509",
516
- stage: "typecheck",
517
- title: "Callable action without an agent description",
518
- fix: 'Add agent_description: "..." to the instrument and to every action a caller can reach; composer.check refuses the program without them.',
519
- example: `program catalog_probe "Catalog probe"
520
- instrument probe {
521
- fields {}
522
- lifecycle { states created; initial created; }
523
- action create { steps: []; }
524
- }`,
525
- },
526
- {
527
- code: "HSX1601",
528
- stage: "lower",
529
- title: "Invalid UDL shape",
530
- fix: "Correct the named clause so it matches the targeted UDL definition.",
531
- // A source program cannot bypass the typechecker to emit an invalid UDL shape.
532
- example: null,
533
- reason:
534
- "Typed source cannot bypass the checker to emit an invalid UDL shape.",
535
- },
536
- {
537
- code: "HSX1602",
538
- stage: "lower",
539
- title: "Invalid UDL semantics",
540
- fix: "Correct the named clause so it satisfies the targeted UDL law.",
541
- // A source program cannot bypass the typechecker to emit invalid UDL semantics.
542
- example: null,
543
- reason:
544
- "Typed source cannot bypass the checker to emit invalid UDL semantics.",
545
- },
546
- {
547
- code: "HSX1603",
548
- stage: "lower",
549
- title: "Unresolved compiler marker",
550
- fix: "Correct compile-time block keys or parameter bindings.",
551
- example: instrument('title: "__hsx_none__";'),
552
- },
553
- {
554
- code: "HSX1610",
555
- stage: "typecheck",
556
- title: "Invalid piece partition",
557
- fix: "Bind immutable money and account fields to one declared partition.",
558
- example: null,
559
- reason:
560
- "The shared UDL action-plan validator supplies the code and source path.",
561
- },
562
- {
563
- code: "HSX1611",
564
- stage: "typecheck",
565
- title: "Invalid piece stage",
566
- fix: "Use a declared piece stage and let the compiler derive pieceId.",
567
- example: null,
568
- reason:
569
- "The shared UDL action-plan validator supplies the code and source path.",
570
- },
571
- {
572
- code: "HSX1612",
573
- stage: "typecheck",
574
- title: "Invalid action graph",
575
- fix: "Declare an acyclic action graph within the expansion bound.",
576
- example: null,
577
- reason:
578
- "The shared UDL action-plan validator supplies the code and source path.",
579
- },
580
- {
581
- code: "HSX1613",
582
- stage: "typecheck",
583
- title: "Invalid static call binding",
584
- fix: "Bind declared typed targets with unique captures and money consumption.",
585
- example: null,
586
- reason:
587
- "The shared UDL action-plan validator supplies the code and source path.",
588
- },
589
- {
590
- code: "HSX1614",
591
- stage: "typecheck",
592
- title: "Incompatible action boundary",
593
- fix: "Keep the parent principal, approval and recovery boundary.",
594
- example: null,
595
- reason:
596
- "The shared UDL action-plan validator supplies the code and source path.",
597
- },
598
- {
599
- code: "HSX1615",
600
- stage: "typecheck",
601
- title: "Invalid leaf evidence or effects",
602
- fix: "Declare evidence and the exact effects of each expanded leaf.",
603
- example: null,
604
- reason:
605
- "The shared UDL action-plan validator supplies the code and source path.",
606
- },
607
- ] as const;
608
-
609
- /** Preserve the UDL diagnostic family when reporting a typed clause. */
610
- export function hsxClauseDiagnosticCode(code: string): string {
611
- const codes: Readonly<Record<string, string>> = {
612
- UDL4002: "HSX1610",
613
- UDL5013: "HSX1611",
614
- UDL2010: "HSX1612",
615
- UDL2011: "HSX1613",
616
- UDL2012: "HSX1614",
617
- UDL2013: "HSX1615",
618
- };
619
- return codes[code] ?? "HSX1602";
620
- }