@hyperscale0/hsx 1.0.0-alpha.6 → 1.0.0-rc.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.
Files changed (234) hide show
  1. package/CHANGELOG.md +48 -10
  2. package/LICENSING.md +3 -3
  3. package/README.md +37 -149
  4. package/TRADEMARKS.md +4 -4
  5. package/dist/src/ast.d.ts +129 -10
  6. package/dist/src/ast.d.ts.map +1 -1
  7. package/dist/src/cli.d.ts +2 -1
  8. package/dist/src/cli.d.ts.map +1 -1
  9. package/dist/src/cli.js +148 -12
  10. package/dist/src/cli.js.map +1 -1
  11. package/dist/src/compile.d.ts +41 -4
  12. package/dist/src/compile.d.ts.map +1 -1
  13. package/dist/src/compile.js +82 -15
  14. package/dist/src/compile.js.map +1 -1
  15. package/dist/src/cost.d.ts +78 -0
  16. package/dist/src/cost.d.ts.map +1 -0
  17. package/dist/src/cost.js +369 -0
  18. package/dist/src/cost.js.map +1 -0
  19. package/dist/src/diagnostics.d.ts +11 -0
  20. package/dist/src/diagnostics.d.ts.map +1 -0
  21. package/dist/src/diagnostics.js +420 -0
  22. package/dist/src/diagnostics.js.map +1 -0
  23. package/dist/src/emit.d.ts +35 -0
  24. package/dist/src/emit.d.ts.map +1 -0
  25. package/dist/src/emit.js +359 -0
  26. package/dist/src/emit.js.map +1 -0
  27. package/dist/src/entry-overrides.d.ts +17 -3
  28. package/dist/src/entry-overrides.d.ts.map +1 -1
  29. package/dist/src/entry-overrides.js +180 -35
  30. package/dist/src/entry-overrides.js.map +1 -1
  31. package/dist/src/format.d.ts +10 -0
  32. package/dist/src/format.d.ts.map +1 -0
  33. package/dist/src/format.js +183 -0
  34. package/dist/src/format.js.map +1 -0
  35. package/dist/src/index.d.ts +10 -4
  36. package/dist/src/index.d.ts.map +1 -1
  37. package/dist/src/index.js +8 -3
  38. package/dist/src/index.js.map +1 -1
  39. package/dist/src/ir.d.ts +66 -0
  40. package/dist/src/ir.d.ts.map +1 -0
  41. package/dist/src/ir.js +15 -0
  42. package/dist/src/ir.js.map +1 -0
  43. package/dist/src/lex.d.ts +9 -1
  44. package/dist/src/lex.d.ts.map +1 -1
  45. package/dist/src/lex.js +50 -4
  46. package/dist/src/lex.js.map +1 -1
  47. package/dist/src/limits.d.ts +2 -3
  48. package/dist/src/limits.d.ts.map +1 -1
  49. package/dist/src/limits.js +2 -3
  50. package/dist/src/limits.js.map +1 -1
  51. package/dist/src/modules.d.ts +36 -0
  52. package/dist/src/modules.d.ts.map +1 -0
  53. package/dist/src/modules.js +372 -0
  54. package/dist/src/modules.js.map +1 -0
  55. package/dist/src/parse.d.ts.map +1 -1
  56. package/dist/src/parse.js +590 -17
  57. package/dist/src/parse.js.map +1 -1
  58. package/dist/src/typecheck.d.ts +8 -0
  59. package/dist/src/typecheck.d.ts.map +1 -0
  60. package/dist/src/typecheck.js +2958 -0
  61. package/dist/src/typecheck.js.map +1 -0
  62. package/dist/src/version.d.ts +4 -15
  63. package/dist/src/version.d.ts.map +1 -1
  64. package/dist/src/version.js +4 -15
  65. package/dist/src/version.js.map +1 -1
  66. package/docs/README.md +23 -0
  67. package/docs/guide/01-first-program.md +24 -0
  68. package/docs/guide/02-money.md +25 -0
  69. package/docs/guide/03-instruments.md +22 -0
  70. package/docs/guide/04-lifecycles.md +25 -0
  71. package/docs/guide/05-fees-and-splits.md +45 -0
  72. package/docs/guide/06-schedules.md +22 -0
  73. package/docs/guide/07-composition.md +46 -0
  74. package/docs/guide/08-writing-a-module.md +26 -0
  75. package/docs/guide/09-cost.md +24 -0
  76. package/docs/guide/10-diagnostics.md +27 -0
  77. package/docs/llms-full.txt +1738 -0
  78. package/docs/llms.txt +45 -0
  79. package/docs/reference/cli.md +33 -0
  80. package/docs/reference/diagnostics.md +619 -0
  81. package/docs/reference/grammar.md +39 -0
  82. package/docs/reference/std/advance.md +35 -0
  83. package/docs/reference/std/cancellable_booking.md +35 -0
  84. package/docs/reference/std/captured_payment.md +43 -0
  85. package/docs/reference/std/conditional_disbursement.md +33 -0
  86. package/docs/reference/std/credit_facility.md +35 -0
  87. package/docs/reference/std/held_payment.md +64 -0
  88. package/docs/reference/std/instant_transfer.md +30 -0
  89. package/docs/reference/std/metered.md +27 -0
  90. package/docs/reference/std/pooled_split.md +26 -0
  91. package/docs/reference/std/premium_forward.md +39 -0
  92. package/docs/reference/std/reconciled_payout.md +33 -0
  93. package/docs/reference/std/recurring_collection.md +25 -0
  94. package/docs/reference/std/rotating_pool.md +42 -0
  95. package/docs/reference/std/scheduled.md +51 -0
  96. package/docs/reference/std/security_deposit.md +46 -0
  97. package/docs/reference/std/settlement_batch.md +42 -0
  98. package/docs/reference/std/swap.md +46 -0
  99. package/docs/reference/std/threshold_pool.md +47 -0
  100. package/docs/reference/std/weighted_distribution.md +39 -0
  101. package/docs/reference/types.md +20 -0
  102. package/docs/reference/udl-output.md +14 -0
  103. package/docs/sessions/2026-09-02-two-instruments.hsx +21 -0
  104. package/docs/sessions/2026-09-02-two-instruments.md +41 -0
  105. package/examples/01-first-program/README.md +45 -0
  106. package/examples/01-first-program/tip-jar.hsx +17 -0
  107. package/examples/02-imports-and-archetypes/README.md +99 -0
  108. package/examples/02-imports-and-archetypes/photo-booth.hsx +37 -0
  109. package/examples/03-diagnostics/README.md +68 -0
  110. package/examples/03-diagnostics/corner-shop-fixed.hsx +22 -0
  111. package/examples/03-diagnostics/corner-shop.hsx +19 -0
  112. package/examples/04-complete-product/README.md +87 -0
  113. package/examples/04-complete-product/study-hall.hsx +67 -0
  114. package/examples/05-watch-club/README.md +9 -0
  115. package/examples/05-watch-club/watch-club.hsx +124 -0
  116. package/examples/README.md +18 -0
  117. package/examples/advance/README.md +3 -0
  118. package/examples/advance/advance.hsx +13 -0
  119. package/examples/advance/advance.udl +339 -0
  120. package/examples/cancellable_booking/README.md +3 -0
  121. package/examples/cancellable_booking/cancellable_booking.hsx +14 -0
  122. package/examples/cancellable_booking/cancellable_booking.udl +391 -0
  123. package/examples/captured_payment/README.md +3 -0
  124. package/examples/captured_payment/captured_payment.hsx +21 -0
  125. package/examples/captured_payment/captured_payment.udl +677 -0
  126. package/examples/conditional_disbursement/README.md +3 -0
  127. package/examples/conditional_disbursement/conditional_disbursement.hsx +17 -0
  128. package/examples/conditional_disbursement/conditional_disbursement.udl +412 -0
  129. package/examples/cost-table.json +386 -0
  130. package/examples/credit_facility/README.md +3 -0
  131. package/examples/credit_facility/credit_facility.hsx +27 -0
  132. package/examples/credit_facility/credit_facility.udl +1373 -0
  133. package/examples/held_payment/README.md +3 -0
  134. package/examples/held_payment/held_payment.hsx +13 -0
  135. package/examples/held_payment/held_payment.udl +507 -0
  136. package/examples/instant_transfer/README.md +3 -0
  137. package/examples/instant_transfer/instant_transfer.hsx +16 -0
  138. package/examples/instant_transfer/instant_transfer.udl +364 -0
  139. package/examples/metered/README.md +3 -0
  140. package/examples/metered/metered.hsx +13 -0
  141. package/examples/metered/metered.udl +247 -0
  142. package/examples/pooled_split/README.md +3 -0
  143. package/examples/pooled_split/pooled_split.hsx +15 -0
  144. package/examples/pooled_split/pooled_split.udl +425 -0
  145. package/examples/premium_forward/README.md +3 -0
  146. package/examples/premium_forward/premium_forward.hsx +19 -0
  147. package/examples/premium_forward/premium_forward.udl +594 -0
  148. package/examples/reconciled_payout/README.md +3 -0
  149. package/examples/reconciled_payout/reconciled_payout.hsx +13 -0
  150. package/examples/reconciled_payout/reconciled_payout.udl +303 -0
  151. package/examples/recurring_collection/README.md +3 -0
  152. package/examples/recurring_collection/recurring_collection.hsx +21 -0
  153. package/examples/recurring_collection/recurring_collection.udl +1130 -0
  154. package/examples/rotating_pool/README.md +3 -0
  155. package/examples/rotating_pool/rotating_pool.hsx +18 -0
  156. package/examples/rotating_pool/rotating_pool.udl +4352 -0
  157. package/examples/scheduled/README.md +3 -0
  158. package/examples/scheduled/scheduled.hsx +12 -0
  159. package/examples/scheduled/scheduled.udl +335 -0
  160. package/examples/security_deposit/README.md +3 -0
  161. package/examples/security_deposit/security_deposit.hsx +21 -0
  162. package/examples/security_deposit/security_deposit.udl +293 -0
  163. package/examples/settlement_batch/README.md +3 -0
  164. package/examples/settlement_batch/settlement_batch.hsx +19 -0
  165. package/examples/settlement_batch/settlement_batch.udl +753 -0
  166. package/examples/swap/README.md +3 -0
  167. package/examples/swap/swap.hsx +19 -0
  168. package/examples/swap/swap.udl +876 -0
  169. package/examples/threshold_pool/README.md +3 -0
  170. package/examples/threshold_pool/threshold_pool.hsx +16 -0
  171. package/examples/threshold_pool/threshold_pool.udl +667 -0
  172. package/examples/weighted_distribution/README.md +3 -0
  173. package/examples/weighted_distribution/weighted_distribution.hsx +20 -0
  174. package/examples/weighted_distribution/weighted_distribution.udl +337 -0
  175. package/package.json +19 -6
  176. package/skills/hsx/SKILL.md +483 -0
  177. package/src/ast.ts +163 -9
  178. package/src/cli.ts +164 -12
  179. package/src/compile.ts +160 -20
  180. package/src/cost.ts +579 -0
  181. package/src/diagnostics.ts +442 -0
  182. package/src/emit.ts +447 -0
  183. package/src/entry-overrides.ts +263 -48
  184. package/src/format.ts +261 -0
  185. package/src/index.ts +32 -4
  186. package/src/ir.ts +99 -0
  187. package/src/lex.ts +59 -4
  188. package/src/limits.ts +2 -3
  189. package/src/modules.ts +444 -0
  190. package/src/parse.ts +655 -21
  191. package/src/typecheck.ts +3876 -0
  192. package/src/version.ts +4 -16
  193. package/std/SEMANTICS.md +130 -0
  194. package/std/settlements/advance.hsx +177 -0
  195. package/std/settlements/cancellable_booking.hsx +87 -0
  196. package/std/settlements/captured_payment.hsx +144 -0
  197. package/std/settlements/conditional_disbursement.hsx +185 -0
  198. package/std/settlements/credit_facility.hsx +167 -0
  199. package/std/settlements/held_payment.hsx +578 -0
  200. package/std/settlements/index.hsx +3 -0
  201. package/std/settlements/instant_transfer.hsx +190 -0
  202. package/std/settlements/metered.hsx +67 -0
  203. package/std/settlements/pooled_split.hsx +68 -0
  204. package/std/settlements/premium_forward.hsx +257 -0
  205. package/std/settlements/reconciled_payout.hsx +77 -0
  206. package/std/settlements/recurring_collection.hsx +27 -0
  207. package/std/settlements/rotating_pool.hsx +252 -0
  208. package/std/settlements/scheduled.hsx +641 -0
  209. package/std/settlements/security_deposit.hsx +166 -0
  210. package/std/settlements/settlement_batch.hsx +122 -0
  211. package/std/settlements/swap.hsx +1114 -0
  212. package/std/settlements/threshold_pool.hsx +221 -0
  213. package/std/settlements/weighted_distribution.hsx +141 -0
  214. package/dist/src/archetypes.d.ts +0 -17
  215. package/dist/src/archetypes.d.ts.map +0 -1
  216. package/dist/src/archetypes.js +0 -327
  217. package/dist/src/archetypes.js.map +0 -1
  218. package/dist/src/check.d.ts +0 -12
  219. package/dist/src/check.d.ts.map +0 -1
  220. package/dist/src/check.js +0 -1910
  221. package/dist/src/check.js.map +0 -1
  222. package/dist/src/lower.d.ts +0 -146
  223. package/dist/src/lower.d.ts.map +0 -1
  224. package/dist/src/lower.js +0 -4570
  225. package/dist/src/lower.js.map +0 -1
  226. package/dist/src/model.d.ts +0 -467
  227. package/dist/src/model.d.ts.map +0 -1
  228. package/dist/src/model.js +0 -15
  229. package/dist/src/model.js.map +0 -1
  230. package/spec/hsx-ir.schema.json +0 -920
  231. package/src/archetypes.ts +0 -340
  232. package/src/check.ts +0 -2938
  233. package/src/lower.ts +0 -5416
  234. package/src/model.ts +0 -519
@@ -0,0 +1,442 @@
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
+ ): string => `program catalog_probe "Catalog probe"
13
+ instrument probe {
14
+ fields {}
15
+ lifecycle { states created; initial created; }
16
+ action create { steps: []; }
17
+ ${body}
18
+ }`;
19
+
20
+ /** Stable public descriptions for every diagnostic code emitted by HSX. */
21
+ export const hsxDiagnostics: readonly HsxDiagnosticCatalogEntry[] = [
22
+ {
23
+ code: "HSX1000",
24
+ stage: "typecheck",
25
+ title: "Missing file declaration",
26
+ fix: "Add one program header or module declaration.",
27
+ example: "",
28
+ },
29
+ {
30
+ code: "HSX1001",
31
+ stage: "bind",
32
+ title: "Unbound name",
33
+ fix: "Declare or import the name before using it.",
34
+ example:
35
+ 'program catalog_probe "Catalog probe"\ninstrument probe = missing()',
36
+ },
37
+ {
38
+ code: "HSX1002",
39
+ stage: "typecheck",
40
+ title: "Duplicate program declaration",
41
+ fix: "Keep exactly one program declaration.",
42
+ example: `${instrument("")}\nprogram second "Second"`,
43
+ },
44
+ {
45
+ code: "HSX1003",
46
+ stage: "typecheck",
47
+ title: "Invalid declaration name",
48
+ fix: "Use lowercase snake_case for program and instrument names.",
49
+ example: 'program NotSnake "Catalog probe"',
50
+ },
51
+ {
52
+ code: "HSX1004",
53
+ stage: "typecheck",
54
+ title: "Duplicate declaration",
55
+ fix: "Keep one declaration or give each declaration a distinct name.",
56
+ example: `${instrument("")}\ninstrument probe { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }`,
57
+ },
58
+ {
59
+ code: "HSX1005",
60
+ stage: "typecheck",
61
+ title: "Invalid field name",
62
+ fix: "Rename the field in lower camelCase.",
63
+ // The parser normalizes every accepted source field spelling to lower camelCase.
64
+ example: null,
65
+ reason:
66
+ "The parser normalizes every accepted field spelling before typechecking.",
67
+ },
68
+ {
69
+ code: "HSX1006",
70
+ stage: "bind",
71
+ title: "Invalid module import",
72
+ fix: "Resolve one module that exports each imported name exactly once.",
73
+ // A source string cannot control the compiler host's module resolver.
74
+ example: null,
75
+ reason: "This refusal requires a compiler-host module resolver result.",
76
+ },
77
+ {
78
+ code: "HSX1007",
79
+ stage: "typecheck",
80
+ title: "Invalid cross-instrument reference",
81
+ fix: "Name an existing target instrument in the ref type.",
82
+ example: `program catalog_probe "Catalog probe"
83
+ instrument probe {
84
+ fields { parentId { type: ref; description: "Parent"; } }
85
+ lifecycle { states created; initial created; }
86
+ action create { steps: []; }
87
+ }`,
88
+ },
89
+ {
90
+ code: "HSX1008",
91
+ stage: "typecheck",
92
+ title: "Invalid subject or decision port",
93
+ fix: "Complete the declaration and bind every referenced decision port.",
94
+ example: `${instrument("")}\nsubject vehicle { title: "Vehicle"; }`,
95
+ },
96
+ {
97
+ code: "HSX1009",
98
+ stage: "bind",
99
+ title: "Imported declaration collision",
100
+ fix: "Rename the importer-owned declaration or the module-local declaration.",
101
+ // A source string cannot create a collision in a compiler-host module result.
102
+ example: null,
103
+ reason:
104
+ "This refusal requires declarations returned by a compiler-host module resolver.",
105
+ },
106
+ {
107
+ code: "HSX1010",
108
+ stage: "typecheck",
109
+ title: "Wrong type-argument count",
110
+ fix: "Supply exactly the type arguments declared by the instrument function.",
111
+ example: `program catalog_probe "Catalog probe"
112
+ export instrument template<C>() { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
113
+ instrument probe = template<SAR, USD>()`,
114
+ },
115
+ {
116
+ code: "HSX1011",
117
+ stage: "typecheck",
118
+ title: "Missing required argument",
119
+ fix: "Pass every required instrument-function argument.",
120
+ example: `program catalog_probe "Catalog probe"
121
+ export instrument template(value: text) { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
122
+ instrument probe = template()`,
123
+ },
124
+ {
125
+ code: "HSX1012",
126
+ stage: "typecheck",
127
+ title: "Unknown named argument",
128
+ fix: "Remove the argument or use a parameter declared by the instrument function.",
129
+ example: `program catalog_probe "Catalog probe"
130
+ export instrument template() { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
131
+ instrument probe = template(typo: true)`,
132
+ },
133
+ {
134
+ code: "HSX1013",
135
+ stage: "typecheck",
136
+ title: "Duplicate named argument",
137
+ fix: "Pass each named argument once.",
138
+ example: `program catalog_probe "Catalog probe"
139
+ export instrument template(value: text) { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
140
+ instrument probe = template(value: "one", value: "two")`,
141
+ },
142
+ {
143
+ code: "HSX1014",
144
+ stage: "parse",
145
+ title: "JSON supplied as HSX",
146
+ fix: "Replace the JSON object with HSX declarations.",
147
+ example: '{ "hsx": 1 }',
148
+ },
149
+ {
150
+ code: "HSX1015",
151
+ stage: "typecheck",
152
+ title: "Invalid composed program identity",
153
+ fix: "Give the composed program a bounded product id and title.",
154
+ // This diagnostic requires a compiler-host published catalog.
155
+ example: null,
156
+ reason: "This refusal requires a compiler-host published catalog.",
157
+ },
158
+ {
159
+ code: "HSX1016",
160
+ stage: "typecheck",
161
+ title: "Empty published composition",
162
+ fix: "Select at least one published instrument with use.",
163
+ // This diagnostic requires a compiler-host published catalog.
164
+ example: null,
165
+ reason: "This refusal requires a compiler-host published catalog.",
166
+ },
167
+ {
168
+ code: "HSX1017",
169
+ stage: "typecheck",
170
+ title: "Duplicate published instrument",
171
+ fix: "Keep one use declaration for each published instrument.",
172
+ // This diagnostic requires a compiler-host published catalog.
173
+ example: null,
174
+ reason: "This refusal requires a compiler-host published catalog.",
175
+ },
176
+ {
177
+ code: "HSX1018",
178
+ stage: "typecheck",
179
+ title: "Unavailable published instrument",
180
+ fix: "Use an instrument id from the supplied published catalog.",
181
+ example: 'program catalog_probe "Catalog probe"\nuse missing',
182
+ },
183
+ {
184
+ code: "HSX1020",
185
+ stage: "typecheck",
186
+ title: "Invalid public action name",
187
+ fix: "Expose each action once under a distinct lower camelCase name.",
188
+ // This diagnostic requires a compiler-host published catalog.
189
+ example: null,
190
+ reason: "This refusal requires a compiler-host published catalog.",
191
+ },
192
+ {
193
+ code: "HSX1021",
194
+ stage: "typecheck",
195
+ title: "Invalid exposed action",
196
+ fix: "Expose an action on an explicitly used published instrument.",
197
+ // This diagnostic requires a compiler-host published catalog.
198
+ example: null,
199
+ reason: "This refusal requires a compiler-host published catalog.",
200
+ },
201
+ {
202
+ code: "HSX1022",
203
+ stage: "typecheck",
204
+ title: "Authored instrument in a composition",
205
+ fix: "Publish the instrument separately, then select it with use.",
206
+ // This diagnostic requires a compiler-host published catalog.
207
+ example: null,
208
+ reason: "This refusal requires a compiler-host published catalog.",
209
+ },
210
+ {
211
+ code: "HSX1023",
212
+ stage: "typecheck",
213
+ title: "Invalid required-field list",
214
+ fix: "List declared, non-optional field names once each.",
215
+ example: instrument("required: missing;"),
216
+ },
217
+ {
218
+ code: "HSX1101",
219
+ stage: "typecheck",
220
+ title: "Currency mismatch",
221
+ fix: "Use the declared currency because money values never coerce.",
222
+ example: `${instrument("")}\nconst fee: money<SAR> = USD 1.00`,
223
+ },
224
+ {
225
+ code: "HSX1102",
226
+ stage: "typecheck",
227
+ title: "Money precision exceeds minor units",
228
+ fix: "Round the literal to the currency's minor-unit precision.",
229
+ example: `${instrument("")}\nconst fee: money<SAR> = SAR 1.001`,
230
+ },
231
+ {
232
+ code: "HSX1103",
233
+ stage: "typecheck",
234
+ title: "Invalid numeric value",
235
+ fix: "Use an integer, percent, bps, or valid fixed-money binding.",
236
+ example: instrument("summary: 1.5;"),
237
+ },
238
+ {
239
+ code: "HSX1104",
240
+ stage: "typecheck",
241
+ title: "Value has the wrong type",
242
+ fix: "Pass the type declared by the parameter or UDL slot.",
243
+ example: instrument("summary: money(SAR, 2500);"),
244
+ },
245
+ {
246
+ code: "HSX1110",
247
+ stage: "typecheck",
248
+ title: "Unsupported parameter combination",
249
+ fix: "Choose a supported compile-time parameter combination.",
250
+ example: `program catalog_probe "Catalog probe"
251
+ export instrument template() {
252
+ unsupported { message: "Not supported"; fix: "Choose another form"; }
253
+ fields {}
254
+ lifecycle { states created; initial created; }
255
+ action create { steps: []; }
256
+ }
257
+ instrument probe = template()`,
258
+ },
259
+ {
260
+ code: "HSX1201",
261
+ stage: "typecheck",
262
+ title: "Linear money consumed more than once",
263
+ fix: "Leave exactly one sink for each produced money value.",
264
+ example: instrument(`fields { amount: money<SAR>; }
265
+ action pay { computes remainder rest { amount_ref: total; on_zero: refuse; total_path: fields.amount; }; moves: [{ amount: rest; }, { amount: rest; }]; }`),
266
+ },
267
+ {
268
+ code: "HSX1202",
269
+ stage: "typecheck",
270
+ title: "Linear money is unconsumed",
271
+ fix: "Route each produced money value to one explicit sink.",
272
+ example: instrument(`fields { amount: money<SAR>; }
273
+ action pay { computes remainder rest { amount_ref: total; on_zero: refuse; total_path: fields.amount; }; }`),
274
+ },
275
+ {
276
+ code: "HSX1301",
277
+ stage: "typecheck",
278
+ title: "Missing cost-table price",
279
+ fix: "Supply a versioned cost table with a row for every emitted effect.",
280
+ example: instrument(""),
281
+ },
282
+ {
283
+ code: "HSX1302",
284
+ stage: "typecheck",
285
+ title: "Invalid cost-table row",
286
+ fix: "Use non-negative integer prices and a supported settlement timing.",
287
+ // A source string cannot make the compiler host's cost table malformed.
288
+ example: null,
289
+ reason: "This refusal requires a malformed compiler-host cost table.",
290
+ },
291
+ {
292
+ code: "HSX1303",
293
+ stage: "typecheck",
294
+ title: "Invalid cost-table currency",
295
+ fix: "Use the supported uppercase cost-table currency.",
296
+ // A source string cannot change the compiler host's cost-table currency.
297
+ example: null,
298
+ reason:
299
+ "This refusal requires an invalid compiler-host cost-table currency.",
300
+ },
301
+ {
302
+ code: "HSX1401",
303
+ stage: "typecheck",
304
+ title: "Unbounded action",
305
+ fix: "Replace runtime iteration with a bounded compile-time comprehension.",
306
+ example: instrument("action run { while { condition: true; }; }"),
307
+ },
308
+ {
309
+ code: "HSX1402",
310
+ stage: "typecheck",
311
+ title: "Missing lifecycle",
312
+ fix: "Declare lifecycle states and an initial state.",
313
+ example:
314
+ 'program catalog_probe "Catalog probe"\ninstrument probe { fields {}; action create { steps: []; }; }',
315
+ },
316
+ {
317
+ code: "HSX1403",
318
+ stage: "typecheck",
319
+ title: "Runtime comprehension bound",
320
+ fix: "Use an integer literal or literal finite list as the bound.",
321
+ example: `program catalog_probe "Catalog probe"
322
+ export instrument template(count: integer) {
323
+ fields {}
324
+ lifecycle { states created; initial created; }
325
+ action create { steps: []; }
326
+ for item in count { action run_[item] { steps: []; } }
327
+ }
328
+ instrument probe = template(count: runtimeCount: integer)`,
329
+ },
330
+ {
331
+ code: "HSX1404",
332
+ stage: "typecheck",
333
+ title: "Comprehension expansion limit",
334
+ fix: "Reduce the fixed expansion to the compiler limit.",
335
+ example: instrument("for item in 257 { action run_[item] { steps: []; } }"),
336
+ },
337
+ {
338
+ code: "HSX1405",
339
+ stage: "typecheck",
340
+ title: "Invalid compile-time selection",
341
+ fix: "Give compile-time conditions and unsupported branches fixed blocks.",
342
+ example: `program catalog_probe "Catalog probe"
343
+ export instrument template() { unsupported: true; fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
344
+ instrument probe = template()`,
345
+ },
346
+ {
347
+ code: "HSX1406",
348
+ stage: "typecheck",
349
+ title: "Invalid companion instrument",
350
+ fix: "Construct each companion with a compile-time id.",
351
+ example: `program catalog_probe "Catalog probe"
352
+ export instrument template() {
353
+ fields {}
354
+ lifecycle { states created; initial created; }
355
+ action create { steps: []; }
356
+ instruments { invalid: true; }
357
+ }
358
+ instrument probe = template()`,
359
+ },
360
+ {
361
+ code: "HSX1501",
362
+ stage: "typecheck",
363
+ title: "Unknown UDL clause",
364
+ fix: "Use a clause exported by the targeted UDL vocabulary.",
365
+ example: instrument("unknown_clause: true;"),
366
+ },
367
+ {
368
+ code: "HSX1502",
369
+ stage: "typecheck",
370
+ title: "Program emits no instruments",
371
+ fix: "Declare or instantiate at least one instrument.",
372
+ example: 'program catalog_probe "Catalog probe"',
373
+ },
374
+ {
375
+ code: "HSX1503",
376
+ stage: "typecheck",
377
+ title: "Missing fields block",
378
+ fix: "Add a fields block, even when it is empty.",
379
+ example:
380
+ 'program catalog_probe "Catalog probe"\ninstrument probe { lifecycle { states created; initial created; }; action create { steps: []; }; }',
381
+ },
382
+ {
383
+ code: "HSX1504",
384
+ stage: "typecheck",
385
+ title: "Missing create action",
386
+ fix: "Add an action create block.",
387
+ example:
388
+ 'program catalog_probe "Catalog probe"\ninstrument probe { fields {}; lifecycle { states created; initial created; }; }',
389
+ },
390
+ {
391
+ code: "HSX1505",
392
+ stage: "typecheck",
393
+ title: "Repeated single-valued clause",
394
+ fix: "Keep one occurrence of the clause.",
395
+ example: instrument('title: "First"; title: "Second";'),
396
+ },
397
+ {
398
+ code: "HSX1506",
399
+ stage: "typecheck",
400
+ title: "Conflicting public action settings",
401
+ fix: "Keep either public: none or a public action name.",
402
+ example: instrument(
403
+ "action finish { public: none; public_action: finishProbe; steps: []; }",
404
+ ),
405
+ },
406
+ {
407
+ code: "HSX1507",
408
+ stage: "typecheck",
409
+ title: "Invalid application metadata",
410
+ fix: "Keep contract mechanics in the parameterized instrument.",
411
+ example: `program catalog_probe "Catalog probe"
412
+ export instrument template() { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
413
+ instrument probe = template() { fields: {}; }`,
414
+ },
415
+ {
416
+ code: "HSX1601",
417
+ stage: "lower",
418
+ title: "Invalid UDL shape",
419
+ fix: "Correct the named clause so it matches the targeted UDL definition.",
420
+ // A source program cannot bypass the typechecker to emit an invalid UDL shape.
421
+ example: null,
422
+ reason:
423
+ "Typed source cannot bypass the checker to emit an invalid UDL shape.",
424
+ },
425
+ {
426
+ code: "HSX1602",
427
+ stage: "lower",
428
+ title: "Invalid UDL semantics",
429
+ fix: "Correct the named clause so it satisfies the targeted UDL law.",
430
+ // A source program cannot bypass the typechecker to emit invalid UDL semantics.
431
+ example: null,
432
+ reason:
433
+ "Typed source cannot bypass the checker to emit invalid UDL semantics.",
434
+ },
435
+ {
436
+ code: "HSX1603",
437
+ stage: "lower",
438
+ title: "Unresolved compiler marker",
439
+ fix: "Correct compile-time block keys or parameter bindings.",
440
+ example: instrument('title: "__hsx_none__";'),
441
+ },
442
+ ] as const;