@hyperscale0/hsx 1.0.0 → 1.0.123

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 (316) hide show
  1. package/CHANGELOG.md +5 -256
  2. package/LICENSE.md +356 -0
  3. package/NOTICE.md +8 -0
  4. package/README.md +44 -44
  5. package/bin/hsx.ts +0 -7
  6. package/dist/bin/hsx.d.ts +0 -4
  7. package/dist/bin/hsx.d.ts.map +1 -1
  8. package/dist/bin/hsx.js +0 -6
  9. package/dist/bin/hsx.js.map +1 -1
  10. package/dist/src/ast.d.ts +113 -308
  11. package/dist/src/ast.d.ts.map +1 -1
  12. package/dist/src/ast.js +7 -71
  13. package/dist/src/ast.js.map +1 -1
  14. package/dist/src/attachment-economics.d.ts +5 -0
  15. package/dist/src/attachment-economics.d.ts.map +1 -0
  16. package/dist/src/attachment-economics.js +55 -0
  17. package/dist/src/attachment-economics.js.map +1 -0
  18. package/dist/src/binding-contract.d.ts +22 -0
  19. package/dist/src/binding-contract.d.ts.map +1 -0
  20. package/dist/src/binding-contract.js +74 -0
  21. package/dist/src/binding-contract.js.map +1 -0
  22. package/dist/src/cli.d.ts +4 -19
  23. package/dist/src/cli.d.ts.map +1 -1
  24. package/dist/src/cli.js +89 -276
  25. package/dist/src/cli.js.map +1 -1
  26. package/dist/src/compile.d.ts +34 -66
  27. package/dist/src/compile.d.ts.map +1 -1
  28. package/dist/src/compile.js +2949 -117
  29. package/dist/src/compile.js.map +1 -1
  30. package/dist/src/cost.d.ts +8 -75
  31. package/dist/src/cost.d.ts.map +1 -1
  32. package/dist/src/cost.js +54 -364
  33. package/dist/src/cost.js.map +1 -1
  34. package/dist/src/diagnostics.d.ts +14 -9
  35. package/dist/src/diagnostics.d.ts.map +1 -1
  36. package/dist/src/diagnostics.js +39 -416
  37. package/dist/src/diagnostics.js.map +1 -1
  38. package/dist/src/examples-bundle.d.ts +3 -0
  39. package/dist/src/examples-bundle.d.ts.map +1 -0
  40. package/dist/src/examples-bundle.js +18 -0
  41. package/dist/src/examples-bundle.js.map +1 -0
  42. package/dist/src/examples.d.ts +10 -0
  43. package/dist/src/examples.d.ts.map +1 -0
  44. package/dist/src/examples.js +2 -0
  45. package/dist/src/examples.js.map +1 -0
  46. package/dist/src/format.d.ts +8 -7
  47. package/dist/src/format.d.ts.map +1 -1
  48. package/dist/src/format.js +9 -175
  49. package/dist/src/format.js.map +1 -1
  50. package/dist/src/header-source.d.ts +3 -0
  51. package/dist/src/header-source.d.ts.map +1 -0
  52. package/dist/src/header-source.js +41 -0
  53. package/dist/src/header-source.js.map +1 -0
  54. package/dist/src/headers.d.ts +64 -0
  55. package/dist/src/headers.d.ts.map +1 -0
  56. package/dist/src/headers.js +167 -0
  57. package/dist/src/headers.js.map +1 -0
  58. package/dist/src/index.d.ts +7 -11
  59. package/dist/src/index.d.ts.map +1 -1
  60. package/dist/src/index.js +4 -9
  61. package/dist/src/index.js.map +1 -1
  62. package/dist/src/keywords.d.ts +56 -0
  63. package/dist/src/keywords.d.ts.map +1 -0
  64. package/dist/src/keywords.js +133 -0
  65. package/dist/src/keywords.js.map +1 -0
  66. package/dist/src/language.d.ts +26 -0
  67. package/dist/src/language.d.ts.map +1 -0
  68. package/dist/src/language.js +440 -0
  69. package/dist/src/language.js.map +1 -0
  70. package/dist/src/lex.d.ts +13 -28
  71. package/dist/src/lex.d.ts.map +1 -1
  72. package/dist/src/lex.js +119 -145
  73. package/dist/src/lex.js.map +1 -1
  74. package/dist/src/parse.d.ts +4 -17
  75. package/dist/src/parse.d.ts.map +1 -1
  76. package/dist/src/parse.js +484 -1036
  77. package/dist/src/parse.js.map +1 -1
  78. package/dist/src/std-bundle.d.ts.map +1 -1
  79. package/dist/src/std-bundle.js +11 -84
  80. package/dist/src/std-bundle.js.map +1 -1
  81. package/dist/src/std-library.d.ts +1 -1
  82. package/dist/src/std-library.d.ts.map +1 -1
  83. package/dist/src/std-library.js +1 -5
  84. package/dist/src/std-library.js.map +1 -1
  85. package/dist/src/tunables.d.ts +7 -0
  86. package/dist/src/tunables.d.ts.map +1 -0
  87. package/dist/src/tunables.js +27 -0
  88. package/dist/src/tunables.js.map +1 -0
  89. package/docs/README.md +528 -26
  90. package/docs/assets/brand/hsx-horizontal-white.svg +1 -0
  91. package/docs/assets/brand/hsx-horizontal.svg +1 -0
  92. package/docs/assets/brand/hsx-stacked-white.svg +1 -0
  93. package/docs/assets/brand/hsx-stacked.svg +1 -0
  94. package/docs/assets/brand/manifest.json +30 -0
  95. package/docs/assets/hsx.svg +11 -0
  96. package/examples/cards.hsx +34 -0
  97. package/examples/collections.hsx +37 -0
  98. package/examples/cost-table.json +633 -385
  99. package/examples/escrow.hsx +24 -0
  100. package/examples/financing.hsx +32 -0
  101. package/examples/insurance.hsx +30 -0
  102. package/examples/lending.hsx +57 -0
  103. package/examples/library.hsx +15 -0
  104. package/examples/marketplace.hsx +32 -0
  105. package/examples/money.hsx +19 -0
  106. package/examples/rental-deposit.hsx +60 -0
  107. package/examples/repair-approval.hsx +44 -0
  108. package/examples/reporting.hsx +28 -0
  109. package/examples/savings.hsx +21 -0
  110. package/examples/serviced.hsx +25 -0
  111. package/examples/wallet.hsx +24 -0
  112. package/package.json +25 -23
  113. package/src/ast.ts +83 -440
  114. package/src/attachment-economics.ts +103 -0
  115. package/src/binding-contract.ts +104 -0
  116. package/src/cli.ts +95 -325
  117. package/src/compile.ts +4063 -209
  118. package/src/cost.ts +71 -574
  119. package/src/diagnostics.ts +57 -437
  120. package/src/examples-bundle.ts +19 -0
  121. package/src/examples.ts +9 -0
  122. package/src/format.ts +12 -256
  123. package/src/header-source.ts +54 -0
  124. package/src/headers.ts +195 -0
  125. package/src/index.ts +18 -33
  126. package/src/keywords.ts +134 -0
  127. package/src/language.ts +629 -0
  128. package/src/lex.ts +131 -192
  129. package/src/parse.ts +489 -1195
  130. package/src/std-bundle.ts +12 -88
  131. package/src/std-library.ts +2 -7
  132. package/src/tunables.ts +36 -0
  133. package/std/cards.hsx +85 -0
  134. package/std/collections.hsx +90 -0
  135. package/std/escrow.hsx +73 -0
  136. package/std/financing.hsx +683 -0
  137. package/std/insurance.hsx +89 -0
  138. package/std/lending.hsx +138 -0
  139. package/std/marketplace.hsx +123 -0
  140. package/std/money.hsx +173 -0
  141. package/std/reporting.hsx +753 -0
  142. package/std/savings.hsx +68 -0
  143. package/std/wallet.hsx +57 -0
  144. package/LICENSE +0 -661
  145. package/LICENSING.md +0 -52
  146. package/TRADEMARKS.md +0 -35
  147. package/dist/src/emit.d.ts +0 -34
  148. package/dist/src/emit.d.ts.map +0 -1
  149. package/dist/src/emit.js +0 -137
  150. package/dist/src/emit.js.map +0 -1
  151. package/dist/src/entry-overrides.d.ts +0 -58
  152. package/dist/src/entry-overrides.d.ts.map +0 -1
  153. package/dist/src/entry-overrides.js +0 -284
  154. package/dist/src/entry-overrides.js.map +0 -1
  155. package/dist/src/ir.d.ts +0 -66
  156. package/dist/src/ir.d.ts.map +0 -1
  157. package/dist/src/ir.js +0 -15
  158. package/dist/src/ir.js.map +0 -1
  159. package/dist/src/limits.d.ts +0 -21
  160. package/dist/src/limits.d.ts.map +0 -1
  161. package/dist/src/limits.js +0 -21
  162. package/dist/src/limits.js.map +0 -1
  163. package/dist/src/lsp/server.d.ts +0 -32
  164. package/dist/src/lsp/server.d.ts.map +0 -1
  165. package/dist/src/lsp/server.js +0 -391
  166. package/dist/src/lsp/server.js.map +0 -1
  167. package/dist/src/modules.d.ts +0 -38
  168. package/dist/src/modules.d.ts.map +0 -1
  169. package/dist/src/modules.js +0 -368
  170. package/dist/src/modules.js.map +0 -1
  171. package/dist/src/typecheck.d.ts +0 -8
  172. package/dist/src/typecheck.d.ts.map +0 -1
  173. package/dist/src/typecheck.js +0 -2958
  174. package/dist/src/typecheck.js.map +0 -1
  175. package/dist/src/version.d.ts +0 -5
  176. package/dist/src/version.d.ts.map +0 -1
  177. package/dist/src/version.js +0 -5
  178. package/dist/src/version.js.map +0 -1
  179. package/docs/guide/01-first-program.md +0 -24
  180. package/docs/guide/02-money.md +0 -25
  181. package/docs/guide/03-instruments.md +0 -22
  182. package/docs/guide/04-lifecycles.md +0 -25
  183. package/docs/guide/05-fees-and-splits.md +0 -45
  184. package/docs/guide/06-schedules.md +0 -22
  185. package/docs/guide/07-composition.md +0 -46
  186. package/docs/guide/08-writing-a-module.md +0 -26
  187. package/docs/guide/09-cost.md +0 -24
  188. package/docs/guide/10-diagnostics.md +0 -27
  189. package/docs/llms-full.txt +0 -1739
  190. package/docs/llms.txt +0 -45
  191. package/docs/playground.md +0 -54
  192. package/docs/reference/cli.md +0 -35
  193. package/docs/reference/diagnostics.md +0 -619
  194. package/docs/reference/grammar.md +0 -39
  195. package/docs/reference/std/advance.md +0 -35
  196. package/docs/reference/std/cancellable_booking.md +0 -35
  197. package/docs/reference/std/captured_payment.md +0 -43
  198. package/docs/reference/std/conditional_disbursement.md +0 -33
  199. package/docs/reference/std/credit_facility.md +0 -35
  200. package/docs/reference/std/held_payment.md +0 -64
  201. package/docs/reference/std/instant_transfer.md +0 -30
  202. package/docs/reference/std/metered.md +0 -27
  203. package/docs/reference/std/pooled_split.md +0 -26
  204. package/docs/reference/std/premium_forward.md +0 -39
  205. package/docs/reference/std/reconciled_payout.md +0 -33
  206. package/docs/reference/std/recurring_collection.md +0 -25
  207. package/docs/reference/std/rotating_pool.md +0 -42
  208. package/docs/reference/std/scheduled.md +0 -51
  209. package/docs/reference/std/security_deposit.md +0 -46
  210. package/docs/reference/std/settlement_batch.md +0 -42
  211. package/docs/reference/std/swap.md +0 -46
  212. package/docs/reference/std/threshold_pool.md +0 -47
  213. package/docs/reference/std/weighted_distribution.md +0 -39
  214. package/docs/reference/types.md +0 -20
  215. package/docs/reference/udl-output.md +0 -13
  216. package/docs/sessions/2026-09-02-two-instruments.hsx +0 -21
  217. package/docs/sessions/2026-09-02-two-instruments.md +0 -41
  218. package/examples/01-first-program/README.md +0 -45
  219. package/examples/01-first-program/tip-jar.hsx +0 -17
  220. package/examples/02-imports-and-archetypes/README.md +0 -96
  221. package/examples/02-imports-and-archetypes/photo-booth.hsx +0 -37
  222. package/examples/03-diagnostics/README.md +0 -68
  223. package/examples/03-diagnostics/corner-shop-fixed.hsx +0 -22
  224. package/examples/03-diagnostics/corner-shop.hsx +0 -19
  225. package/examples/04-complete-product/README.md +0 -84
  226. package/examples/04-complete-product/study-hall.hsx +0 -67
  227. package/examples/05-watch-club/README.md +0 -9
  228. package/examples/05-watch-club/watch-club.hsx +0 -124
  229. package/examples/README.md +0 -18
  230. package/examples/advance/README.md +0 -3
  231. package/examples/advance/advance.hsx +0 -13
  232. package/examples/advance/advance.udl +0 -339
  233. package/examples/cancellable_booking/README.md +0 -3
  234. package/examples/cancellable_booking/cancellable_booking.hsx +0 -14
  235. package/examples/cancellable_booking/cancellable_booking.udl +0 -391
  236. package/examples/captured_payment/README.md +0 -3
  237. package/examples/captured_payment/captured_payment.hsx +0 -21
  238. package/examples/captured_payment/captured_payment.udl +0 -677
  239. package/examples/conditional_disbursement/README.md +0 -3
  240. package/examples/conditional_disbursement/conditional_disbursement.hsx +0 -17
  241. package/examples/conditional_disbursement/conditional_disbursement.udl +0 -412
  242. package/examples/credit_facility/README.md +0 -3
  243. package/examples/credit_facility/credit_facility.hsx +0 -27
  244. package/examples/credit_facility/credit_facility.udl +0 -1373
  245. package/examples/held_payment/README.md +0 -3
  246. package/examples/held_payment/held_payment.hsx +0 -13
  247. package/examples/held_payment/held_payment.udl +0 -507
  248. package/examples/instant_transfer/README.md +0 -3
  249. package/examples/instant_transfer/instant_transfer.hsx +0 -16
  250. package/examples/instant_transfer/instant_transfer.udl +0 -364
  251. package/examples/metered/README.md +0 -3
  252. package/examples/metered/metered.hsx +0 -13
  253. package/examples/metered/metered.udl +0 -247
  254. package/examples/pooled_split/README.md +0 -3
  255. package/examples/pooled_split/pooled_split.hsx +0 -15
  256. package/examples/pooled_split/pooled_split.udl +0 -425
  257. package/examples/premium_forward/README.md +0 -3
  258. package/examples/premium_forward/premium_forward.hsx +0 -19
  259. package/examples/premium_forward/premium_forward.udl +0 -594
  260. package/examples/reconciled_payout/README.md +0 -3
  261. package/examples/reconciled_payout/reconciled_payout.hsx +0 -13
  262. package/examples/reconciled_payout/reconciled_payout.udl +0 -303
  263. package/examples/recurring_collection/README.md +0 -3
  264. package/examples/recurring_collection/recurring_collection.hsx +0 -21
  265. package/examples/recurring_collection/recurring_collection.udl +0 -1130
  266. package/examples/rotating_pool/README.md +0 -3
  267. package/examples/rotating_pool/rotating_pool.hsx +0 -18
  268. package/examples/rotating_pool/rotating_pool.udl +0 -4352
  269. package/examples/scheduled/README.md +0 -3
  270. package/examples/scheduled/scheduled.hsx +0 -12
  271. package/examples/scheduled/scheduled.udl +0 -335
  272. package/examples/security_deposit/README.md +0 -3
  273. package/examples/security_deposit/security_deposit.hsx +0 -21
  274. package/examples/security_deposit/security_deposit.udl +0 -293
  275. package/examples/settlement_batch/README.md +0 -3
  276. package/examples/settlement_batch/settlement_batch.hsx +0 -19
  277. package/examples/settlement_batch/settlement_batch.udl +0 -753
  278. package/examples/swap/README.md +0 -3
  279. package/examples/swap/swap.hsx +0 -19
  280. package/examples/swap/swap.udl +0 -876
  281. package/examples/threshold_pool/README.md +0 -3
  282. package/examples/threshold_pool/threshold_pool.hsx +0 -16
  283. package/examples/threshold_pool/threshold_pool.udl +0 -667
  284. package/examples/weighted_distribution/README.md +0 -3
  285. package/examples/weighted_distribution/weighted_distribution.hsx +0 -20
  286. package/examples/weighted_distribution/weighted_distribution.udl +0 -337
  287. package/skills/hsx/SKILL.md +0 -483
  288. package/src/emit.ts +0 -201
  289. package/src/entry-overrides.ts +0 -428
  290. package/src/ir.ts +0 -99
  291. package/src/limits.ts +0 -20
  292. package/src/lsp/server.ts +0 -460
  293. package/src/modules.ts +0 -446
  294. package/src/typecheck.ts +0 -3876
  295. package/src/version.ts +0 -5
  296. package/std/SEMANTICS.md +0 -130
  297. package/std/settlements/advance.hsx +0 -177
  298. package/std/settlements/cancellable_booking.hsx +0 -87
  299. package/std/settlements/captured_payment.hsx +0 -144
  300. package/std/settlements/conditional_disbursement.hsx +0 -185
  301. package/std/settlements/credit_facility.hsx +0 -167
  302. package/std/settlements/held_payment.hsx +0 -578
  303. package/std/settlements/index.hsx +0 -3
  304. package/std/settlements/instant_transfer.hsx +0 -190
  305. package/std/settlements/metered.hsx +0 -67
  306. package/std/settlements/pooled_split.hsx +0 -68
  307. package/std/settlements/premium_forward.hsx +0 -257
  308. package/std/settlements/reconciled_payout.hsx +0 -77
  309. package/std/settlements/recurring_collection.hsx +0 -27
  310. package/std/settlements/rotating_pool.hsx +0 -252
  311. package/std/settlements/scheduled.hsx +0 -641
  312. package/std/settlements/security_deposit.hsx +0 -166
  313. package/std/settlements/settlement_batch.hsx +0 -122
  314. package/std/settlements/swap.hsx +0 -1114
  315. package/std/settlements/threshold_pool.hsx +0 -221
  316. package/std/settlements/weighted_distribution.hsx +0 -141
@@ -1,420 +1,43 @@
1
- const instrument = (body) => `program catalog_probe "Catalog probe"
2
- instrument probe {
3
- fields {}
4
- lifecycle { states created; initial created; }
5
- action create { steps: []; }
6
- ${body}
7
- }`;
8
- /** Stable public descriptions for every diagnostic code emitted by HSX. */
9
- export const hsxDiagnostics = [
10
- {
11
- code: "HSX1000",
12
- stage: "typecheck",
13
- title: "Missing file declaration",
14
- fix: "Add one program header or module declaration.",
15
- example: "",
16
- },
17
- {
18
- code: "HSX1001",
19
- stage: "bind",
20
- title: "Unbound name",
21
- fix: "Declare or import the name before using it.",
22
- example: 'program catalog_probe "Catalog probe"\ninstrument probe = missing()',
23
- },
24
- {
25
- code: "HSX1002",
26
- stage: "typecheck",
27
- title: "Duplicate program declaration",
28
- fix: "Keep exactly one program declaration.",
29
- example: `${instrument("")}\nprogram second "Second"`,
30
- },
31
- {
32
- code: "HSX1003",
33
- stage: "typecheck",
34
- title: "Invalid declaration name",
35
- fix: "Use lowercase snake_case for program and instrument names.",
36
- example: 'program NotSnake "Catalog probe"',
37
- },
38
- {
39
- code: "HSX1004",
40
- stage: "typecheck",
41
- title: "Duplicate declaration",
42
- fix: "Keep one declaration or give each declaration a distinct name.",
43
- example: `${instrument("")}\ninstrument probe { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }`,
44
- },
45
- {
46
- code: "HSX1005",
47
- stage: "typecheck",
48
- title: "Invalid field name",
49
- fix: "Rename the field in lower camelCase.",
50
- // The parser normalizes every accepted source field spelling to lower camelCase.
51
- example: null,
52
- reason: "The parser normalizes every accepted field spelling before typechecking.",
53
- },
54
- {
55
- code: "HSX1006",
56
- stage: "bind",
57
- title: "Invalid module import",
58
- fix: "Resolve one module that exports each imported name exactly once.",
59
- // A source string cannot control the compiler host's module resolver.
60
- example: null,
61
- reason: "This refusal requires a compiler-host module resolver result.",
62
- },
63
- {
64
- code: "HSX1007",
65
- stage: "typecheck",
66
- title: "Invalid cross-instrument reference",
67
- fix: "Name an existing target instrument in the ref type.",
68
- example: `program catalog_probe "Catalog probe"
69
- instrument probe {
70
- fields { parentId { type: ref; description: "Parent"; } }
71
- lifecycle { states created; initial created; }
72
- action create { steps: []; }
73
- }`,
74
- },
75
- {
76
- code: "HSX1008",
77
- stage: "typecheck",
78
- title: "Invalid subject or decision port",
79
- fix: "Complete the declaration and bind every referenced decision port.",
80
- example: `${instrument("")}\nsubject vehicle { title: "Vehicle"; }`,
81
- },
82
- {
83
- code: "HSX1009",
84
- stage: "bind",
85
- title: "Imported declaration collision",
86
- fix: "Rename the importer-owned declaration or the module-local declaration.",
87
- // A source string cannot create a collision in a compiler-host module result.
88
- example: null,
89
- reason: "This refusal requires declarations returned by a compiler-host module resolver.",
90
- },
91
- {
92
- code: "HSX1010",
93
- stage: "typecheck",
94
- title: "Wrong type-argument count",
95
- fix: "Supply exactly the type arguments declared by the instrument function.",
96
- example: `program catalog_probe "Catalog probe"
97
- export instrument template<C>() { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
98
- instrument probe = template<SAR, USD>()`,
99
- },
100
- {
101
- code: "HSX1011",
102
- stage: "typecheck",
103
- title: "Missing required argument",
104
- fix: "Pass every required instrument-function argument.",
105
- example: `program catalog_probe "Catalog probe"
106
- export instrument template(value: text) { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
107
- instrument probe = template()`,
108
- },
109
- {
110
- code: "HSX1012",
111
- stage: "typecheck",
112
- title: "Unknown named argument",
113
- fix: "Remove the argument or use a parameter declared by the instrument function.",
114
- example: `program catalog_probe "Catalog probe"
115
- export instrument template() { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
116
- instrument probe = template(typo: true)`,
117
- },
118
- {
119
- code: "HSX1013",
120
- stage: "typecheck",
121
- title: "Duplicate named argument",
122
- fix: "Pass each named argument once.",
123
- example: `program catalog_probe "Catalog probe"
124
- export instrument template(value: text) { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
125
- instrument probe = template(value: "one", value: "two")`,
126
- },
127
- {
128
- code: "HSX1014",
129
- stage: "parse",
130
- title: "JSON supplied as HSX",
131
- fix: "Replace the JSON object with HSX declarations.",
132
- example: '{ "hsx": 1 }',
133
- },
134
- {
135
- code: "HSX1015",
136
- stage: "typecheck",
137
- title: "Invalid composed program identity",
138
- fix: "Give the composed program a bounded product id and title.",
139
- // This diagnostic requires a compiler-host published catalog.
140
- example: null,
141
- reason: "This refusal requires a compiler-host published catalog.",
142
- },
143
- {
144
- code: "HSX1016",
145
- stage: "typecheck",
146
- title: "Empty published composition",
147
- fix: "Select at least one published instrument with use.",
148
- // This diagnostic requires a compiler-host published catalog.
149
- example: null,
150
- reason: "This refusal requires a compiler-host published catalog.",
151
- },
152
- {
153
- code: "HSX1017",
154
- stage: "typecheck",
155
- title: "Duplicate published instrument",
156
- fix: "Keep one use declaration for each published instrument.",
157
- // This diagnostic requires a compiler-host published catalog.
158
- example: null,
159
- reason: "This refusal requires a compiler-host published catalog.",
160
- },
161
- {
162
- code: "HSX1018",
163
- stage: "typecheck",
164
- title: "Unavailable published instrument",
165
- fix: "Use an instrument id from the supplied published catalog.",
166
- example: 'program catalog_probe "Catalog probe"\nuse missing',
167
- },
168
- {
169
- code: "HSX1020",
170
- stage: "typecheck",
171
- title: "Invalid public action name",
172
- fix: "Expose each action once under a distinct lower camelCase name.",
173
- // This diagnostic requires a compiler-host published catalog.
174
- example: null,
175
- reason: "This refusal requires a compiler-host published catalog.",
176
- },
177
- {
178
- code: "HSX1021",
179
- stage: "typecheck",
180
- title: "Invalid exposed action",
181
- fix: "Expose an action on an explicitly used published instrument.",
182
- // This diagnostic requires a compiler-host published catalog.
183
- example: null,
184
- reason: "This refusal requires a compiler-host published catalog.",
185
- },
186
- {
187
- code: "HSX1022",
188
- stage: "typecheck",
189
- title: "Authored instrument in a composition",
190
- fix: "Publish the instrument separately, then select it with use.",
191
- // This diagnostic requires a compiler-host published catalog.
192
- example: null,
193
- reason: "This refusal requires a compiler-host published catalog.",
194
- },
195
- {
196
- code: "HSX1023",
197
- stage: "typecheck",
198
- title: "Invalid required-field list",
199
- fix: "List declared, non-optional field names once each.",
200
- example: instrument("required: missing;"),
201
- },
202
- {
203
- code: "HSX1101",
204
- stage: "typecheck",
205
- title: "Currency mismatch",
206
- fix: "Use the declared currency because money values never coerce.",
207
- example: `${instrument("")}\nconst fee: money<SAR> = USD 1.00`,
208
- },
209
- {
210
- code: "HSX1102",
211
- stage: "typecheck",
212
- title: "Money precision exceeds minor units",
213
- fix: "Round the literal to the currency's minor-unit precision.",
214
- example: `${instrument("")}\nconst fee: money<SAR> = SAR 1.001`,
215
- },
216
- {
217
- code: "HSX1103",
218
- stage: "typecheck",
219
- title: "Invalid numeric value",
220
- fix: "Use an integer, percent, bps, or valid fixed-money binding.",
221
- example: instrument("summary: 1.5;"),
222
- },
223
- {
224
- code: "HSX1104",
225
- stage: "typecheck",
226
- title: "Value has the wrong type",
227
- fix: "Pass the type declared by the parameter or UDL slot.",
228
- example: instrument("summary: money(SAR, 2500);"),
229
- },
230
- {
231
- code: "HSX1110",
232
- stage: "typecheck",
233
- title: "Unsupported parameter combination",
234
- fix: "Choose a supported compile-time parameter combination.",
235
- example: `program catalog_probe "Catalog probe"
236
- export instrument template() {
237
- unsupported { message: "Not supported"; fix: "Choose another form"; }
238
- fields {}
239
- lifecycle { states created; initial created; }
240
- action create { steps: []; }
1
+ export class CompileFailure extends Error {
2
+ diagnostic;
3
+ constructor(diagnostic) {
4
+ super(diagnostic.message);
5
+ this.diagnostic = diagnostic;
6
+ }
241
7
  }
242
- instrument probe = template()`,
243
- },
244
- {
245
- code: "HSX1201",
246
- stage: "typecheck",
247
- title: "Linear money consumed more than once",
248
- fix: "Leave exactly one sink for each produced money value.",
249
- example: instrument(`fields { amount: money<SAR>; }
250
- action pay { computes remainder rest { amount_ref: total; on_zero: refuse; total_path: fields.amount; }; moves: [{ amount: rest; }, { amount: rest; }]; }`),
251
- },
252
- {
253
- code: "HSX1202",
254
- stage: "typecheck",
255
- title: "Linear money is unconsumed",
256
- fix: "Route each produced money value to one explicit sink.",
257
- example: instrument(`fields { amount: money<SAR>; }
258
- action pay { computes remainder rest { amount_ref: total; on_zero: refuse; total_path: fields.amount; }; }`),
259
- },
260
- {
261
- code: "HSX1301",
262
- stage: "typecheck",
263
- title: "Missing cost-table price",
264
- fix: "Supply a versioned cost table with a row for every emitted effect.",
265
- example: instrument(""),
266
- },
267
- {
268
- code: "HSX1302",
269
- stage: "typecheck",
270
- title: "Invalid cost-table row",
271
- fix: "Use non-negative integer prices and a supported settlement timing.",
272
- // A source string cannot make the compiler host's cost table malformed.
273
- example: null,
274
- reason: "This refusal requires a malformed compiler-host cost table.",
275
- },
276
- {
277
- code: "HSX1303",
278
- stage: "typecheck",
279
- title: "Invalid cost-table currency",
280
- fix: "Use the supported uppercase cost-table currency.",
281
- // A source string cannot change the compiler host's cost-table currency.
282
- example: null,
283
- reason: "This refusal requires an invalid compiler-host cost-table currency.",
284
- },
285
- {
286
- code: "HSX1401",
287
- stage: "typecheck",
288
- title: "Unbounded action",
289
- fix: "Replace runtime iteration with a bounded compile-time comprehension.",
290
- example: instrument("action run { while { condition: true; }; }"),
291
- },
292
- {
293
- code: "HSX1402",
294
- stage: "typecheck",
295
- title: "Missing lifecycle",
296
- fix: "Declare lifecycle states and an initial state.",
297
- example: 'program catalog_probe "Catalog probe"\ninstrument probe { fields {}; action create { steps: []; }; }',
298
- },
299
- {
300
- code: "HSX1403",
301
- stage: "typecheck",
302
- title: "Runtime comprehension bound",
303
- fix: "Use an integer literal or literal finite list as the bound.",
304
- example: `program catalog_probe "Catalog probe"
305
- export instrument template(count: integer) {
306
- fields {}
307
- lifecycle { states created; initial created; }
308
- action create { steps: []; }
309
- for item in count { action run_[item] { steps: []; } }
8
+ export function fail(expr, message, fix) {
9
+ return failWithCode(expr, "HSX1001", message, fix);
310
10
  }
311
- instrument probe = template(count: runtimeCount: integer)`,
312
- },
313
- {
314
- code: "HSX1404",
315
- stage: "typecheck",
316
- title: "Comprehension expansion limit",
317
- fix: "Reduce the fixed expansion to the compiler limit.",
318
- example: instrument("for item in 257 { action run_[item] { steps: []; } }"),
319
- },
320
- {
321
- code: "HSX1405",
322
- stage: "typecheck",
323
- title: "Invalid compile-time selection",
324
- fix: "Give compile-time conditions and unsupported branches fixed blocks.",
325
- example: `program catalog_probe "Catalog probe"
326
- export instrument template() { unsupported: true; fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
327
- instrument probe = template()`,
328
- },
329
- {
330
- code: "HSX1406",
331
- stage: "typecheck",
332
- title: "Invalid companion instrument",
333
- fix: "Construct each companion with a compile-time id.",
334
- example: `program catalog_probe "Catalog probe"
335
- export instrument template() {
336
- fields {}
337
- lifecycle { states created; initial created; }
338
- action create { steps: []; }
339
- instruments { invalid: true; }
11
+ export function failWithCode(expr, code, message, fix) {
12
+ throw new CompileFailure({
13
+ code,
14
+ message,
15
+ fix,
16
+ span: expr.span,
17
+ ...(expr.source ? { source: expr.source } : {}),
18
+ });
19
+ }
20
+ // Levenshtein distance where swapping two adjacent letters counts as one edit.
21
+ function editDistance(a, b) {
22
+ const d = Array.from({ length: a.length + 1 }, (_, i) => Array.from({ length: b.length + 1 }, (_, j) => i === 0 ? j : j === 0 ? i : 0));
23
+ for (let i = 1; i <= a.length; i++)
24
+ for (let j = 1; j <= b.length; j++) {
25
+ d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
26
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1])
27
+ d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
28
+ }
29
+ return d[a.length][b.length];
30
+ }
31
+ /** " Did you mean `x`?" for the closest candidate within a third of the name's length, else "". */
32
+ export function didYouMean(name, candidates) {
33
+ const limit = Math.max(1, Math.floor(name.length / 3));
34
+ let best;
35
+ let bestDistance = limit + 1;
36
+ for (const candidate of candidates) {
37
+ const distance = editDistance(name, candidate);
38
+ if (distance < bestDistance)
39
+ [best, bestDistance] = [candidate, distance];
40
+ }
41
+ return best === undefined ? "" : ` Did you mean \`${best}\`?`;
340
42
  }
341
- instrument probe = template()`,
342
- },
343
- {
344
- code: "HSX1501",
345
- stage: "typecheck",
346
- title: "Unknown UDL clause",
347
- fix: "Use a clause exported by the targeted UDL vocabulary.",
348
- example: instrument("unknown_clause: true;"),
349
- },
350
- {
351
- code: "HSX1502",
352
- stage: "typecheck",
353
- title: "Program emits no instruments",
354
- fix: "Declare or instantiate at least one instrument.",
355
- example: 'program catalog_probe "Catalog probe"',
356
- },
357
- {
358
- code: "HSX1503",
359
- stage: "typecheck",
360
- title: "Missing fields block",
361
- fix: "Add a fields block, even when it is empty.",
362
- example: 'program catalog_probe "Catalog probe"\ninstrument probe { lifecycle { states created; initial created; }; action create { steps: []; }; }',
363
- },
364
- {
365
- code: "HSX1504",
366
- stage: "typecheck",
367
- title: "Missing create action",
368
- fix: "Add an action create block.",
369
- example: 'program catalog_probe "Catalog probe"\ninstrument probe { fields {}; lifecycle { states created; initial created; }; }',
370
- },
371
- {
372
- code: "HSX1505",
373
- stage: "typecheck",
374
- title: "Repeated single-valued clause",
375
- fix: "Keep one occurrence of the clause.",
376
- example: instrument('title: "First"; title: "Second";'),
377
- },
378
- {
379
- code: "HSX1506",
380
- stage: "typecheck",
381
- title: "Conflicting public action settings",
382
- fix: "Keep either public: none or a public action name.",
383
- example: instrument("action finish { public: none; public_action: finishProbe; steps: []; }"),
384
- },
385
- {
386
- code: "HSX1507",
387
- stage: "typecheck",
388
- title: "Invalid application metadata",
389
- fix: "Keep contract mechanics in the parameterized instrument.",
390
- example: `program catalog_probe "Catalog probe"
391
- export instrument template() { fields {}; lifecycle { states created; initial created; }; action create { steps: []; }; }
392
- instrument probe = template() { fields: {}; }`,
393
- },
394
- {
395
- code: "HSX1601",
396
- stage: "lower",
397
- title: "Invalid UDL shape",
398
- fix: "Correct the named clause so it matches the targeted UDL definition.",
399
- // A source program cannot bypass the typechecker to emit an invalid UDL shape.
400
- example: null,
401
- reason: "Typed source cannot bypass the checker to emit an invalid UDL shape.",
402
- },
403
- {
404
- code: "HSX1602",
405
- stage: "lower",
406
- title: "Invalid UDL semantics",
407
- fix: "Correct the named clause so it satisfies the targeted UDL law.",
408
- // A source program cannot bypass the typechecker to emit invalid UDL semantics.
409
- example: null,
410
- reason: "Typed source cannot bypass the checker to emit invalid UDL semantics.",
411
- },
412
- {
413
- code: "HSX1603",
414
- stage: "lower",
415
- title: "Unresolved compiler marker",
416
- fix: "Correct compile-time block keys or parameter bindings.",
417
- example: instrument('title: "__hsx_none__";'),
418
- },
419
- ];
420
43
  //# sourceMappingURL=diagnostics.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/diagnostics.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,GAAG,CACjB,IAAY,EACJ,EAAE,CAAC;;;;;IAKT,IAAI;EACN,CAAC;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,cAAc,GAAyC;IAClE;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D,CAAC;IACH,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAE,CAAC,CAAC,CAAC,MAAM,CAAE,CAAC;AACjC,CAAC;AACD,mGAAmG;AACnG,MAAM,UAAU,UAAU,CACxB,IAAY,EACZ,UAA6B;IAE7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACvD,IAAI,IAAwB,CAAC;IAC7B,IAAI,YAAY,GAAG,KAAK,GAAG,CAAC,CAAC;IAC7B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/C,IAAI,QAAQ,GAAG,YAAY;YAAE,CAAC,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,mBAAmB,IAAI,KAAK,CAAC;AAChE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { HsxExample } from "./examples.ts";
2
+ export declare const examples: HsxExample[];
3
+ //# sourceMappingURL=examples-bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examples-bundle.d.ts","sourceRoot":"","sources":["../../src/examples-bundle.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,eAAO,MAAM,QAAQ,EAAE,UAAU,EAgBhC,CAAC"}
@@ -0,0 +1,18 @@
1
+ export const examples = [
2
+ { "id": "cards", "title": "Team expense cards", "summary": "A company issues expense cards to employees and reserves each supplier payment before capture.", "headers": ["cards"], "source": "// A company issues expense cards to employees and reserves each supplier payment before capture.\nprogram team_expense_cards \"Team expense cards\"\nuse cards\nparty supplier: business\n\nobject employee \"Employee card\" {\n fields { employeeName: text, department: text }\n columns: [employeeName, department]\n attach holder = cards.cardholder {\n expose create as create_holder\n holder: owner\n expose activate as activate_employee\n expose suspend as suspend_employee\n }\n attach card = cards.card {\n expose create as create_card\n holder: holder, spend_limit: 5000 SAR\n expose activate as activate_card\n expose freeze as freeze_card\n expose unfreeze as unfreeze_card\n }\n attach payment = cards.authorization {\n expose create as create_payment\n card: card, merchant: supplier\n expose approve as approve_payment\n expose capture as capture_payment\n expose reverse as reverse_payment\n }\n attach receipt = cards.transaction {\n expose create as create_receipt\n authorization: payment\n expose refund as refund_payment\n }\n}\n" },
3
+ { "id": "collections", "title": "Small business collections", "summary": "A business lender refers overdue instalments to an agency with limits on collection contacts.", "headers": ["collections", "financing"], "source": "// A business lender refers overdue instalments to an agency with limits on collection contacts.\nprogram business_collections \"Small business collections\"\nuse collections\nuse financing\nparty agency: business\n\nobject facility \"Business loan\" {\n fields { businessName: text, purpose: text, price: money }\n columns: [businessName, purpose, price]\n attach allowance = financing.limits { expose create as create_allowance, expose approve as approve_borrower, borrower: owner, per_borrower: 100000 SAR }\n attach budget = financing.portfolio_limit { expose create as create_budget, expose approve as approve_budget, limit: 2000000 SAR }\n attach loan = financing.installments {\n expose create as create_loan\n borrower: owner, capital: operator\n months: 12, profit: 6%, disburse_to: borrower\n limits: allowance, portfolio: budget\n expose sign as sign_loan\n expose disburse as release_loan\n expose payoff as repay_early\n }\n attach recovery = collections.case {\n expose create as create_recovery\n on: loan, agency: agency\n expose assign as assign_case\n expose recover as recover_payment\n expose recall as recall_case\n }\n attach contact = collections.contact {\n expose create as create_contact\n case: recovery, agency: agency\n }\n}\n\nexpose facility.loan.payment.create as create_payment\nexpose facility.loan.payment.pay as pay_instalment\nexpose facility.loan.payment.refund as refund_payment\nexpose facility.loan.payoff_quote.create as request_payoff_quote\n" },
4
+ { "id": "escrow", "title": "Used device sales", "summary": "Buyers fund a used device purchase, then accept delivery or raise a dispute before release.", "headers": ["escrow"], "source": "// Buyers fund a used device purchase, then accept delivery or raise a dispute before release.\nprogram used_device_sales \"Used device sales\"\nuse escrow\n\nobject device \"Device\" {\n fields {\n model: text\n condition: text\n serialNumber: text\n price: money\n }\n columns: [model, condition, price]\n attach sale = escrow.hold {\n expose create as create_sale\n payer: actor, payee: owner\n expose fund as pay_for_device\n expose deliver as confirm_delivery\n expose accept as accept_device\n expose dispute as report_problem\n expose verify_return as verify_return\n expose refund as refund_buyer\n expose cancel as cancel_sale\n }\n}\n" },
5
+ { "id": "financing", "title": "Tuition instalments", "summary": "A tuition lender funds a student's fees over three interest-free instalments with borrowing limits.", "headers": ["financing"], "source": "// A tuition lender funds a student's fees over three interest-free instalments with borrowing limits.\nprogram tuition_instalments \"Tuition instalments\"\nuse financing\n\nobject enrolment \"Enrolment\" {\n fields { student: text, course: text, price: money }\n columns: [student, course, price]\n attach allowance = financing.limits {\n expose create as create_allowance\n borrower: owner, per_borrower: 12000 SAR\n expose approve as approve_student\n }\n attach budget = financing.portfolio_limit {\n expose create as create_budget\n limit: 500000 SAR\n expose approve as approve_budget\n }\n attach tuition = financing.installments {\n expose create as create_tuition\n borrower: owner, capital: operator\n months: 3, profit: 0%, disburse_to: borrower\n limits: allowance, portfolio: budget\n expose sign as sign_tuition_plan\n expose disburse as fund_tuition\n expose payoff as repay_early\n }\n}\n\nexpose enrolment.tuition.payment.create as create_payment\nexpose enrolment.tuition.payment.pay as pay_instalment\nexpose enrolment.tuition.payment.refund as refund_payment\nexpose enrolment.tuition.payoff_quote.create as request_payoff_quote\n" },
6
+ { "id": "insurance", "title": "Device insurance", "summary": "A device retailer collects the purchase price and attaches cover with a claim review process.", "headers": ["insurance", "money"], "source": "// A device retailer collects the purchase price and attaches cover with a claim review process.\nprogram device_insurance \"Device insurance\"\nuse insurance\nuse money\nparty inspector: staff role claims\n\nobject device \"Insured device\" {\n fields { model: text, serialNumber: text, purchaseDate: date }\n columns: [model, serialNumber, purchaseDate]\n attach purchase = money.transfer {\n expose create as create_purchase\n payer: owner, payee: operator\n economics pay { purpose: earning, sourceParty: owner }\n expose pay as pay_for_device\n }\n // Bind device_insurer to an ADL adapter before creating cover. Premiums net of commission go to its account.\n attach protection = insurance.cover {\n expose create as create_protection\n holder: owner, adapter: \"device_insurer\", commission: 10%, covers: purchase\n expose activate as activate_cover\n expose cancel as cancel_cover\n }\n attach claim = insurance.claim {\n expose create as create_claim\n cover: protection, inspector: inspector\n expose approve as approve_claim\n expose deny as deny_claim\n expose pay as pay_claim\n }\n}\n" },
7
+ { "id": "lending", "title": "Community business lending", "summary": "A lending composition with limit approvals, wallet commitments and cash distribution transitions.", "headers": ["lending", "financing", "wallet"], "source": "// A lending composition with limit approvals, wallet commitments and cash distribution transitions.\nprogram community_business_lending \"Community business lending\"\nuse lending\nuse financing\nuse wallet\n\nobject business \"Business funding\" {\n fields { businessName: text, purpose: text, price: money }\n columns: [businessName, purpose, price]\n attach allowance = financing.limits {\n expose create as create_allowance\n borrower: owner, per_borrower: 100000 SAR\n expose approve as approve_borrower\n }\n attach budget = financing.portfolio_limit {\n expose create as create_budget\n limit: 2000000 SAR\n expose approve as approve_budget\n }\n attach loan = financing.installments {\n expose create as create_loan\n borrower: owner, capital: operator\n months: 12, profit: 6%, disburse_to: borrower\n limits: allowance, portfolio: budget\n expose sign as sign_loan\n expose disburse as release_loan\n expose payoff as repay_early\n }\n attach investor_balance = wallet.balance {\n expose create as create_investor_balance\n holder: actor\n expose activate as open_wallet\n expose topup as add_funds\n }\n attach funding = lending.round {\n borrower: owner, plan: loan\n expose create as open_funding\n expose close as close_funding\n }\n attach investment = lending.commitment {\n round: funding, wallet: investor_balance, investor: actor\n expose create as invest\n expose withdraw as withdraw_investment\n }\n attach returns = lending.distribution {\n expose create as create_returns\n round: funding, receipt: loan.settlement\n expose prepare_cash as prepare_returns\n expose distribute_cash as distribute_returns\n }\n}\n\nexpose business.loan.payment.create as create_payment\nexpose business.loan.payment.pay as pay_instalment\nexpose business.loan.payment.refund as refund_payment\nexpose business.loan.payoff_quote.create as request_payoff_quote\nexpose business.returns.share.create as create_return_share\n" },
8
+ { "id": "library", "title": "Financed car sales", "summary": "A minimal financed car sale connects escrow to a three-instalment plan and lending limits.", "headers": ["escrow", "financing"], "source": "// A minimal financed car sale connects escrow to a three-instalment plan and lending limits.\nprogram cars \"Financed car sales\"\nuse escrow\nuse financing\nobject car \"Cars\" {\n fields { make: text, model: text, year: integer }\n attach sale = escrow.hold { expose create as create_sale, payer: actor, payee: owner, expose fund as sell }\n attach limits = financing.limits { expose create as create_limits, borrower: actor, per_borrower: 60000 SAR }\n attach ceiling = financing.portfolio_limit { expose create as create_ceiling, limit: 1500000 SAR }\n attach plan = financing.installments {\n borrower: actor, capital: operator, share: 25%\n months: 3, profit: 2.5%, funds: sale, limits: limits, portfolio: ceiling\n expose create as finance\n }\n}\n" },
9
+ { "id": "marketplace", "title": "Freelance marketplace", "summary": "Freelancers publish offers and clients place orders with funds held until work is accepted.", "headers": ["marketplace", "escrow"], "source": "// Freelancers publish offers and clients place orders with funds held until work is accepted.\nprogram freelance_marketplace \"Freelance marketplace\"\nuse marketplace\nuse escrow\n\nobject project \"Project\" {\n fields { brief: text, deliverable: text, price: money }\n columns: [brief, deliverable, price]\n attach offer = marketplace.listing {\n expose create as create_offer\n seller: owner\n expose publish as publish_offer\n expose withdraw as withdraw_offer\n }\n attach order = marketplace.order {\n expose create as create_order\n listing: offer, buyer: actor\n expose commit as place_order\n expose fulfill as finish_order\n }\n attach payment = escrow.hold {\n expose create as create_payment\n payer: actor, payee: owner\n expose fund as fund_project\n expose deliver as submit_work\n expose accept as accept_work\n expose dispute as dispute_work\n expose verify_return as verify_return\n expose refund as refund_client\n expose cancel as cancel_payment\n }\n}\n" },
10
+ { "id": "money", "title": "Tutoring studio", "summary": "A tutoring studio collects a fixed fee for each lesson and can cancel unpaid bookings.", "headers": ["money"], "source": "// A tutoring studio collects a fixed fee for each lesson and can cancel unpaid bookings.\nprogram tutoring_studio \"Tutoring studio\"\nuse money\n\nobject lesson \"Lesson\" {\n fields {\n student: text\n tutor: text\n startsAt: date\n }\n columns: [student, tutor, startsAt]\n attach payment = money.transfer {\n expose create as create_payment\n payer: actor, payee: operator, amount: 150 SAR\n economics pay { purpose: earning, sourceParty: actor }\n expose pay as pay_for_lesson\n expose cancel as cancel_payment\n }\n}\n" },
11
+ { "id": "rental-deposit", "title": "Equipment rental", "summary": "A business rents equipment with a 1000 SAR deposit and a single 50 SAR late fee. On-time return refunds 1000 SAR; late return pays the operator 50 SAR and refunds 950 SAR.", "headers": [], "source": "// A business rents equipment with a 1000 SAR deposit and a single 50 SAR late fee.\n// On-time return refunds 1000 SAR; late return pays the operator 50 SAR and refunds 950 SAR.\nprogram equipment_rental \"Equipment rental\"\nparty renter: business\n\n// Program-local instruments have fixed terms and parties, not tunable parameters.\ninstrument deposit {\n summary: \"Hold a rental deposit, then return it less any fixed late fee.\"\n fields {\n renter: account of renter\n held: account of self\n amount: money = 1000 SAR\n lateFee: money = 50 SAR\n dueAt: date\n refund: money?\n }\n lifecycle { states: [pending, funded, returned, cancelled], initial: pending }\n action create {\n actor: { party: renter }\n requires self.dueAt > self.now\n }\n action fund {\n from: pending, to: funded, actor: { party: renter }\n deadline: { at: self.dueAt }\n moves self.amount from self.renter to self.held\n }\n action return_on_time {\n from: funded, to: returned, actor: { party: programOperator }\n deadline: { at: self.dueAt }\n subject { returnReference: text }\n moves self.held.balance from self.held to self.renter\n }\n action return_late {\n from: funded, to: returned, actor: { party: programOperator }\n due: { at: self.dueAt }\n subject { returnReference: text }\n calculate: [{ target: refund, op: subtract, base: { field: self.held.balance }, subtract: [{ field: self.lateFee }] }]\n moves self.lateFee from self.held to programOperator\n moves self.refund from self.held to self.renter\n }\n action cancel { from: pending, to: cancelled, actor: { party: renter } }\n}\n\nobject rental \"Equipment rental\" {\n fields { equipment: text }\n columns: [equipment, dueAt]\n attach security = deposit {\n expose create as agree_rental\n expose fund as pay_deposit\n expose return_on_time as return_equipment\n expose return_late as return_equipment_late\n expose cancel as cancel_rental\n }\n}\n\nhide deposit.create\nhide deposit.fund\nhide deposit.return_on_time\nhide deposit.return_late\nhide deposit.cancel\n" },
12
+ { "id": "repair-approval", "title": "Repair approvals", "summary": "A repair shop records inspection and approval evidence before it can complete a job.", "headers": [], "source": "// A repair shop records inspection and approval evidence before it can complete a job.\nprogram repair_shop \"Repair approvals\"\n\ninstrument assessment {\n summary: \"Inspect the repair, collect approval, then record completion.\"\n fields { inspectedAt: date?, approvedAt: date? }\n lifecycle { states: [submitted, inspected, approved, completed, rejected], initial: submitted }\n action create {}\n action inspect {\n from: submitted, to: inspected, actor: { party: programOperator }\n subject { inspectionNotes: text }\n set: { inspectedAt: { field: self.now } }\n }\n action approve {\n from: inspected, to: approved, actor: { party: programOperator }\n subject { approvalReference: text }\n set: { approvedAt: { field: self.now } }\n }\n action reject {\n from: inspected, to: rejected, actor: { party: programOperator }\n }\n action complete {\n from: approved, to: completed, actor: { party: programOperator }\n subject { completionNotes: text }\n }\n}\n\nobject repair \"Repair\" {\n fields { item: text, problem: text }\n columns: [item, problem]\n attach review = assessment {\n expose create as create_review\n expose inspect as inspect_repair\n expose approve as approve_repair\n expose reject as reject_repair\n expose complete as complete_repair\n }\n}\n\nhide assessment.create\nhide assessment.inspect\nhide assessment.approve\nhide assessment.reject\nhide assessment.complete\n" },
13
+ { "id": "reporting", "title": "Equipment loan reports", "summary": "An equipment lender keeps an ageing report over its financed purchases and recorded repayments.", "headers": ["reporting", "financing"], "source": "// An equipment lender keeps an ageing report over its financed purchases and recorded repayments.\nprogram equipment_loan_reports \"Equipment loan reports\"\nuse reporting\nuse financing\n\nobject purchase \"Equipment loan\" {\n fields { businessName: text, equipment: text, price: money }\n columns: [businessName, equipment, price]\n attach allowance = financing.limits {\n expose create as create_allowance\n borrower: owner, per_borrower: 200000 SAR\n expose approve as approve_business\n }\n attach budget = financing.portfolio_limit {\n expose create as create_budget\n limit: 5000000 SAR\n expose approve as approve_budget\n }\n attach loan = financing.installments {\n expose create as create_loan\n borrower: owner, capital: operator\n months: 12, profit: 6%, disburse_to: borrower\n limits: allowance, portfolio: budget\n expose sign as sign_purchase_loan\n expose disburse as fund_purchase\n }\n attach reports = reporting.portfolio { expose create as create_reports, on: loan }\n}\n" },
14
+ { "id": "savings", "title": "Savings circle", "summary": "Six members contribute to a shared pot and receive it in their agreed calendar order.", "headers": ["savings"], "source": "// Six members contribute to a shared pot and receive it in their agreed calendar order.\nprogram neighbourhood_savings \"Savings circle\"\nuse savings\n\nobject group \"Savings group\" {\n fields { groupName: text, purpose: text }\n columns: [groupName, purpose]\n attach circle = savings.circle {\n expose create as create_circle\n contribution: 500 SAR, members: 6, starts: 2027-01-01\n expose disband as disband_circle\n expose close as close_circle\n }\n attach membership = savings.membership {\n expose create as create_membership\n circle: circle, member: actor\n expose activate as confirm_membership\n expose withdraw as leave_circle\n }\n // Contributions and each member's payout follow the declared calendar.\n}\n" },
15
+ { "id": "serviced", "title": "Car financing", "summary": "A car finance company services loans with late charges, payment reminders and early repayment.", "headers": ["escrow", "financing", "collections"], "source": "// A car finance company services loans with late charges, payment reminders and early repayment.\nprogram car_financing \"Car financing\"\nuse escrow\nuse financing\nuse collections\nobject car \"Car\" {\n fields { make: text, model: text, year: integer, vin: text, price: money }\n columns: [make, model, year, vin, price]\n attach sale = escrow.hold { expose create as create_sale, payer: actor, payee: operator, expose fund as purchase }\n attach limits = financing.limits { expose create as create_limits, borrower: actor, per_borrower: 250000 SAR }\n attach ceiling = financing.portfolio_limit { expose create as create_ceiling, limit: 10000000 SAR }\n attach plan = financing.installments {\n borrower: actor, capital: operator\n months: 36, profit: 8.5%, down_payment: 10%\n apply: fines_profit_principal, payoff_rebate: 100%, write_off_after: 90d\n funds: sale, limits: limits, portfolio: ceiling\n expose create as finance, expose sign as sign_contract, expose payoff as payoff\n }\n attach late = financing.late_charge {\n expose create as create_late\n on: plan, grace: 3d, fine: 50 SAR, cap: 25 SAR\n fines_to: operator, costs_to: operator, borrower: actor\n }\n attach reminders = collections.reminder { expose create as create_reminders, on: plan, operator: operator, before_days: 3, overdue_days: 1 }\n}\n" },
16
+ { "id": "wallet", "title": "Workshop credits", "summary": "Members prepay for workshop visits and the studio reserves each spend before charging it.", "headers": ["wallet"], "source": "// Members prepay for workshop visits and the studio reserves each spend before charging it.\nprogram workshop_credits \"Workshop credits\"\nuse wallet\n\nobject membership \"Membership\" {\n fields { memberName: text, membershipNumber: text }\n columns: [memberName, membershipNumber]\n attach balance = wallet.balance {\n expose create as create_balance\n holder: owner\n expose activate as open_balance\n expose topup as add_credit\n expose withdraw as withdraw_credit\n expose close as close_balance\n }\n attach visit = wallet.spend {\n expose create as create_visit\n wallet: balance, payee: operator\n economics pay { purpose: earning, sourceParty: owner }\n expose reserve as reserve_visit\n expose pay as charge_visit\n expose cancel as cancel_visit\n }\n}\n" },
17
+ ];
18
+ //# sourceMappingURL=examples-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examples-bundle.js","sourceRoot":"","sources":["../../src/examples-bundle.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAiB;IACpC,EAAC,IAAI,EAAC,OAAO,EAAC,OAAO,EAAC,oBAAoB,EAAC,SAAS,EAAC,gGAAgG,EAAC,SAAS,EAAC,CAAC,OAAO,CAAC,EAAC,QAAQ,EAAC,mlCAAmlC,EAAC;IACvwC,EAAC,IAAI,EAAC,aAAa,EAAC,OAAO,EAAC,4BAA4B,EAAC,SAAS,EAAC,+FAA+F,EAAC,SAAS,EAAC,CAAC,aAAa,EAAC,WAAW,CAAC,EAAC,QAAQ,EAAC,mgDAAmgD,EAAC;IACttD,EAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,mBAAmB,EAAC,SAAS,EAAC,6FAA6F,EAAC,SAAS,EAAC,CAAC,QAAQ,CAAC,EAAC,QAAQ,EAAC,krBAAkrB,EAAC;IACp2B,EAAC,IAAI,EAAC,WAAW,EAAC,OAAO,EAAC,qBAAqB,EAAC,SAAS,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D,EAAC,IAAI,EAAC,WAAW,EAAC,OAAO,EAAC,wBAAwB,EAAC,SAAS,EAAC,iGAAiG,EAAC,SAAS,EAAC,CAAC,WAAW,EAAC,WAAW,CAAC,EAAC,QAAQ,EAAC,khCAAkhC,EAAC;IAC/tC,EAAC,IAAI,EAAC,SAAS,EAAC,OAAO,EAAC,gBAAgB,EAAC,SAAS,EAAC,uFAAuF,EAAC,SAAS,EAAC,CAAC,SAAS,CAAC,EAAC,QAAQ,EAAC,uvBAAuvB,EAAC;IACl6B,EAAC,IAAI,EAAC,UAAU,EAAC,OAAO,EAAC,eAAe,EAAC,SAAS,EAAC,gGAAgG,EAAC,SAAS,EAAC,CAAC,QAAQ,EAAC,WAAW,EAAC,aAAa,CAAC,EAAC,QAAQ,EAAC,ozCAAozC,EAAC;IACjgD,EAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,kBAAkB,EAAC,SAAS,EAAC,2FAA2F,EAAC,SAAS,EAAC,CAAC,QAAQ,CAAC,EAAC,QAAQ,EAAC,2yBAA2yB,EAAC;CAC39B,CAAC"}
@@ -0,0 +1,10 @@
1
+ /** Authored programs shipped with the compiler, generated from examples/*.hsx. */
2
+ export interface HsxExample {
3
+ id: string;
4
+ title: string;
5
+ summary: string;
6
+ headers: string[];
7
+ source: string;
8
+ }
9
+ export { examples } from "./examples-bundle.ts";
10
+ //# sourceMappingURL=examples.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examples.d.ts","sourceRoot":"","sources":["../../src/examples.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AACD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { examples } from "./examples-bundle.js";
2
+ //# sourceMappingURL=examples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"examples.js","sourceRoot":"","sources":["../../src/examples.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC"}
@@ -1,10 +1,11 @@
1
- import type { Diagnostic } from "./ast.ts";
2
- export type FormatResult = {
3
- readonly formatted: string;
4
- readonly ok: true;
1
+ /** Preserve authored comments and literals; normalize line endings and trailing whitespace. */
2
+ export declare function format(source: string): {
3
+ ok: false;
4
+ diagnostics: import("./ast.ts").Diagnostic[];
5
+ formatted?: never;
5
6
  } | {
6
- readonly diagnostics: readonly Diagnostic[];
7
- readonly ok: false;
7
+ diagnostics?: never;
8
+ ok: true;
9
+ formatted: string;
8
10
  };
9
- export declare function format(source: string): FormatResult;
10
11
  //# sourceMappingURL=format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,UAAU,EAAqB,MAAM,UAAU,CAAC;AAI/E,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;CAAE,GACjD;IAAE,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC;AAExE,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAiBnD"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/format.ts"],"names":[],"mappings":"AACA,+FAA+F;AAC/F,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM;;;;;;;;EAcpC"}