eliscript 0.0.1 → 0.0.3

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 (417) hide show
  1. package/README.md +61 -0
  2. package/bootstrap/README.md +26 -0
  3. package/bootstrap/backends/README.md +515 -0
  4. package/bootstrap/backends/async.eli +230 -0
  5. package/bootstrap/backends/binary.eli +173 -0
  6. package/bootstrap/backends/capabilities.eli +74 -0
  7. package/bootstrap/backends/elf.eli +246 -0
  8. package/bootstrap/backends/managed.eli +5976 -0
  9. package/bootstrap/backends/memory.eli +100 -0
  10. package/bootstrap/backends/native.eli +2000 -0
  11. package/bootstrap/backends/numeric.eli +1362 -0
  12. package/bootstrap/backends/optimize.eli +79 -0
  13. package/bootstrap/backends/regexp.eli +2263 -0
  14. package/bootstrap/backends/sha256.eli +138 -0
  15. package/bootstrap/backends/wasm.eli +1161 -0
  16. package/bootstrap/compiler/analyzer.eli +165 -77
  17. package/bootstrap/compiler/compiler.eli +43 -19
  18. package/bootstrap/compiler/emitter.eli +780 -170
  19. package/bootstrap/compiler/expander.eli +136 -45
  20. package/bootstrap/compiler/formatter.eli +8 -1
  21. package/bootstrap/compiler/ir.eli +148 -45
  22. package/bootstrap/compiler/lower.eli +29 -2
  23. package/bootstrap/compiler/project.eli +51 -21
  24. package/bootstrap/compiler/reader.eli +128 -36
  25. package/bootstrap/compiler/source-map.eli +46 -4
  26. package/bootstrap/compiler/symbol.eli +2 -1
  27. package/bootstrap/compiler/syntax.eli +47 -12
  28. package/bootstrap/compiler/transient-analysis.eli +40 -4
  29. package/bootstrap/host/check-cli-legacy.mjs +163 -0
  30. package/bootstrap/host/check-cli.mjs +59 -158
  31. package/bootstrap/host/check-cli.mjs.map +1 -0
  32. package/bootstrap/host/compiler-session.eli +1579 -0
  33. package/bootstrap/host/compiler-tools.eli +513 -0
  34. package/bootstrap/host/eliscript-cli.mjs +53 -33
  35. package/bootstrap/host/eliscript-cli.mjs.map +1 -0
  36. package/bootstrap/host/project-cli-legacy.mjs +295 -0
  37. package/bootstrap/host/project-cli.mjs +74 -289
  38. package/bootstrap/host/project-cli.mjs.map +1 -0
  39. package/bootstrap/host/project-legacy.mjs +1080 -0
  40. package/bootstrap/host/project.mjs +210 -1060
  41. package/bootstrap/host/project.mjs.map +1 -0
  42. package/bootstrap/runtime/UNICODE-LICENSE.txt +39 -0
  43. package/bootstrap/runtime/memory.eli +30379 -0
  44. package/browser/host.mjs +732 -11
  45. package/browser/worker.mjs +6 -3
  46. package/compiler/eliscript-analyzer.el +371 -4
  47. package/compiler/eliscript-cli.el +84 -1
  48. package/compiler/eliscript-emitter.el +1189 -256
  49. package/compiler/eliscript-expander.el +147 -10
  50. package/compiler/eliscript-ir-emitter.el +725 -208
  51. package/compiler/eliscript-lower.el +127 -1
  52. package/compiler/eliscript-portable.el +177 -51
  53. package/compiler/eliscript-project.el +20 -2
  54. package/compiler/eliscript-reader.el +141 -57
  55. package/compiler/eliscript-source-map.el +26 -12
  56. package/compiler/eliscript-transient-analysis.el +382 -19
  57. package/dist/backends/async.mjs +561 -0
  58. package/dist/backends/async.mjs.macro-origins.json +1 -0
  59. package/dist/backends/async.mjs.map +1 -0
  60. package/dist/backends/binary.mjs +381 -0
  61. package/dist/backends/binary.mjs.macro-origins.json +1 -0
  62. package/dist/backends/binary.mjs.map +1 -0
  63. package/dist/backends/capabilities.mjs +237 -0
  64. package/dist/backends/capabilities.mjs.macro-origins.json +1 -0
  65. package/dist/backends/capabilities.mjs.map +1 -0
  66. package/dist/backends/elf.mjs +540 -0
  67. package/dist/backends/elf.mjs.macro-origins.json +1 -0
  68. package/dist/backends/elf.mjs.map +1 -0
  69. package/dist/backends/managed.mjs +10616 -0
  70. package/dist/backends/managed.mjs.macro-origins.json +1 -0
  71. package/dist/backends/managed.mjs.map +1 -0
  72. package/dist/backends/memory.mjs +278 -0
  73. package/dist/backends/memory.mjs.macro-origins.json +1 -0
  74. package/dist/backends/memory.mjs.map +1 -0
  75. package/dist/backends/native.mjs +4099 -0
  76. package/dist/backends/native.mjs.macro-origins.json +1 -0
  77. package/dist/backends/native.mjs.map +1 -0
  78. package/dist/backends/numeric.mjs +2458 -0
  79. package/dist/backends/numeric.mjs.macro-origins.json +1 -0
  80. package/dist/backends/numeric.mjs.map +1 -0
  81. package/dist/backends/optimize.mjs +204 -0
  82. package/dist/backends/optimize.mjs.macro-origins.json +1 -0
  83. package/dist/backends/optimize.mjs.map +1 -0
  84. package/dist/backends/regexp.mjs +2033 -0
  85. package/dist/backends/regexp.mjs.macro-origins.json +1 -0
  86. package/dist/backends/regexp.mjs.map +1 -0
  87. package/dist/backends/sha256.mjs +310 -0
  88. package/dist/backends/sha256.mjs.macro-origins.json +1 -0
  89. package/dist/backends/sha256.mjs.map +1 -0
  90. package/dist/backends/wasm.mjs +2258 -0
  91. package/dist/backends/wasm.mjs.macro-origins.json +1 -0
  92. package/dist/backends/wasm.mjs.map +1 -0
  93. package/dist/bootstrap/analyzer.mjs +1908 -776
  94. package/dist/bootstrap/analyzer.mjs.macro-origins.json +1 -0
  95. package/dist/bootstrap/analyzer.mjs.map +1 -1
  96. package/dist/bootstrap/compiler.mjs +450 -142
  97. package/dist/bootstrap/compiler.mjs.macro-origins.json +1 -0
  98. package/dist/bootstrap/compiler.mjs.map +1 -1
  99. package/dist/bootstrap/emitter.mjs +3083 -909
  100. package/dist/bootstrap/emitter.mjs.macro-origins.json +1 -0
  101. package/dist/bootstrap/emitter.mjs.map +1 -1
  102. package/dist/bootstrap/expander.mjs +2887 -1233
  103. package/dist/bootstrap/expander.mjs.macro-origins.json +1 -0
  104. package/dist/bootstrap/expander.mjs.map +1 -1
  105. package/dist/bootstrap/formatter.mjs +582 -218
  106. package/dist/bootstrap/formatter.mjs.macro-origins.json +1 -0
  107. package/dist/bootstrap/formatter.mjs.map +1 -1
  108. package/dist/bootstrap/ir.mjs +670 -116
  109. package/dist/bootstrap/ir.mjs.macro-origins.json +1 -0
  110. package/dist/bootstrap/ir.mjs.map +1 -1
  111. package/dist/bootstrap/lower.mjs +866 -257
  112. package/dist/bootstrap/lower.mjs.macro-origins.json +1 -0
  113. package/dist/bootstrap/lower.mjs.map +1 -1
  114. package/dist/bootstrap/package.json +1 -0
  115. package/dist/bootstrap/project.mjs +1168 -498
  116. package/dist/bootstrap/project.mjs.macro-origins.json +1 -0
  117. package/dist/bootstrap/project.mjs.map +1 -1
  118. package/dist/bootstrap/reader.mjs +674 -175
  119. package/dist/bootstrap/reader.mjs.macro-origins.json +1 -0
  120. package/dist/bootstrap/reader.mjs.map +1 -1
  121. package/dist/bootstrap/runtime/math.mjs +1117 -0
  122. package/dist/bootstrap/runtime/math.mjs.map +1 -0
  123. package/dist/bootstrap/runtime/unicode-case-data.mjs +10125 -0
  124. package/dist/bootstrap/runtime/unicode-case-data.mjs.map +1 -0
  125. package/dist/bootstrap/runtime/unicode-case.mjs +281 -0
  126. package/dist/bootstrap/runtime/unicode-case.mjs.map +1 -0
  127. package/dist/bootstrap/source-map.mjs +430 -119
  128. package/dist/bootstrap/source-map.mjs.macro-origins.json +1 -0
  129. package/dist/bootstrap/source-map.mjs.map +1 -1
  130. package/dist/bootstrap/symbol.mjs +229 -53
  131. package/dist/bootstrap/symbol.mjs.macro-origins.json +1 -0
  132. package/dist/bootstrap/symbol.mjs.map +1 -1
  133. package/dist/bootstrap/syntax.mjs +205 -7
  134. package/dist/bootstrap/syntax.mjs.macro-origins.json +1 -0
  135. package/dist/bootstrap/syntax.mjs.map +1 -1
  136. package/dist/bootstrap/transient-analysis.mjs +1185 -489
  137. package/dist/bootstrap/transient-analysis.mjs.macro-origins.json +1 -0
  138. package/dist/bootstrap/transient-analysis.mjs.map +1 -1
  139. package/dist/browser/compiler.js +199 -6478
  140. package/dist/browser/host.mjs +1078 -0
  141. package/dist/browser/loader.js +1 -0
  142. package/dist/browser/loader.mjs +231 -0
  143. package/dist/browser/worker.mjs +63 -0
  144. package/dist/compiler-artifact.json +1 -0
  145. package/dist/host/compiler-session.mjs +2980 -0
  146. package/dist/host/compiler-session.mjs.macro-origins.json +1 -0
  147. package/dist/host/compiler-session.mjs.map +1 -0
  148. package/dist/host/compiler-tools.mjs +1084 -0
  149. package/dist/host/compiler-tools.mjs.macro-origins.json +1 -0
  150. package/dist/host/compiler-tools.mjs.map +1 -0
  151. package/dist/literal-sources/runtime/core/collection-internals.eli +60 -0
  152. package/dist/literal-sources/runtime/core/collection.eli +639 -0
  153. package/dist/literal-sources/runtime/core/data-text.eli +290 -0
  154. package/dist/literal-sources/runtime/core/data.eli +22 -0
  155. package/dist/literal-sources/runtime/core/identifier.eli +44 -0
  156. package/dist/literal-sources/runtime/core/lazy-sequence.eli +131 -0
  157. package/dist/literal-sources/runtime/core/list.eli +19 -0
  158. package/dist/literal-sources/runtime/core/map.eli +9 -0
  159. package/dist/literal-sources/runtime/core/metadata-internals.eli +6 -0
  160. package/dist/literal-sources/runtime/core/metadata.eli +40 -0
  161. package/dist/literal-sources/runtime/core/object.eli +8 -0
  162. package/dist/literal-sources/runtime/core/order.eli +123 -0
  163. package/dist/literal-sources/runtime/core/persistent-kind.eli +28 -0
  164. package/dist/literal-sources/runtime/core/protocol-error.eli +32 -0
  165. package/dist/literal-sources/runtime/core/protocol.eli +28 -0
  166. package/dist/literal-sources/runtime/core/queue.eli +9 -0
  167. package/dist/literal-sources/runtime/core/record.eli +191 -0
  168. package/dist/literal-sources/runtime/core/regex.eli +158 -0
  169. package/dist/literal-sources/runtime/core/sequence.eli +305 -0
  170. package/dist/literal-sources/runtime/core/set-algebra.eli +28 -0
  171. package/dist/literal-sources/runtime/core/set.eli +9 -0
  172. package/dist/literal-sources/runtime/core/sorted.eli +408 -0
  173. package/dist/literal-sources/runtime/core/text.eli +14 -0
  174. package/dist/literal-sources/runtime/core/transducer.eli +268 -0
  175. package/dist/literal-sources/runtime/core/transient.eli +17 -0
  176. package/dist/literal-sources/runtime/core/truth.eli +4 -0
  177. package/dist/literal-sources/runtime/core/type.eli +232 -0
  178. package/dist/literal-sources/runtime/core/value-internals.eli +13 -0
  179. package/dist/literal-sources/runtime/core/value.eli +19 -0
  180. package/dist/literal-sources/runtime/core/vector.eli +25 -0
  181. package/dist/literal-sources/runtime/literals.eli +23 -0
  182. package/dist/literal-sources/runtime/testing/value.eli +6 -0
  183. package/dist/literal-sources/runtime/wire/http-rpc.eli +362 -0
  184. package/dist/literal-sources/runtime/wire/markdown.eli +275 -0
  185. package/dist/literal-sources/runtime/wire/schema.eli +193 -0
  186. package/dist/literal-sources/stdlib/bit.eli +36 -0
  187. package/dist/literal-sources/stdlib/core/data.eli +306 -0
  188. package/dist/literal-sources/stdlib/core/object.eli +89 -0
  189. package/dist/literal-sources/stdlib/core/protocol.eli +451 -0
  190. package/dist/literal-sources/stdlib/core/set.eli +312 -0
  191. package/dist/literal-sources/stdlib/core/text.eli +103 -0
  192. package/dist/literal-sources/stdlib/managed-literal-protocols.eli +494 -0
  193. package/dist/literal-sources/stdlib/managed-literals.eli +1469 -0
  194. package/dist/literal-sources/stdlib/managed-queue-state.eli +65 -0
  195. package/dist/literal-sources/stdlib/managed-sorted-state.eli +233 -0
  196. package/dist/literal-sources/stdlib/managed-transient-state.eli +348 -0
  197. package/dist/literal-sources/stdlib/managed-value-state.eli +153 -0
  198. package/dist/literal-sources/stdlib/managed-vector-view-state.eli +102 -0
  199. package/dist/literal-sources/stdlib/persistent-list.eli +145 -0
  200. package/dist/literal-sources/stdlib/persistent-map.eli +724 -0
  201. package/dist/literal-sources/stdlib/persistent-set.eli +236 -0
  202. package/dist/literal-sources/stdlib/persistent-vector.eli +359 -0
  203. package/dist/literal-sources/stdlib/value.eli +325 -0
  204. package/dist/package.json +10 -0
  205. package/dist/runtime/math.mjs +1116 -0
  206. package/dist/runtime/math.mjs.macro-origins.json +1 -0
  207. package/dist/runtime/math.mjs.map +1 -0
  208. package/dist/runtime/unicode-case-data.mjs +10124 -0
  209. package/dist/runtime/unicode-case-data.mjs.macro-origins.json +1 -0
  210. package/dist/runtime/unicode-case-data.mjs.map +1 -0
  211. package/dist/runtime/unicode-case.mjs +280 -0
  212. package/dist/runtime/unicode-case.mjs.macro-origins.json +1 -0
  213. package/dist/runtime/unicode-case.mjs.map +1 -0
  214. package/dist/runtime.eli +30379 -0
  215. package/dist/stage3-release.json +1 -0
  216. package/editor/README.md +1 -1
  217. package/editor/eliscript-mode.el +1 -1
  218. package/editor/eliscript-repl.el +1 -1
  219. package/package.json +106 -11
  220. package/platform/http.mjs +20 -0
  221. package/runtime/array-text.mjs +159 -0
  222. package/runtime/core/map-internals.mjs +27 -9
  223. package/runtime/core/object-impl.mjs +26 -17
  224. package/runtime/core/object-impl.mjs.map +1 -1
  225. package/runtime/core/protocol-impl.mjs +682 -255
  226. package/runtime/core/protocol-impl.mjs.map +1 -1
  227. package/runtime/core/protocol.mjs +4 -0
  228. package/runtime/core/record.mjs +23 -2
  229. package/runtime/core/regex.mjs +4 -0
  230. package/runtime/core/sorted.mjs +53 -0
  231. package/runtime/core/text-impl.mjs +167 -48
  232. package/runtime/core/text-impl.mjs.map +1 -1
  233. package/runtime/core/type.mjs +75 -3
  234. package/runtime/core/vector.mjs +6 -0
  235. package/runtime/math.eli +429 -0
  236. package/runtime/math.mjs +1116 -0
  237. package/runtime/math.mjs.map +1 -0
  238. package/runtime/number-radix.mjs +105 -0
  239. package/runtime/unicode-case-data.eli +29 -0
  240. package/runtime/unicode-case-data.mjs +10124 -0
  241. package/runtime/unicode-case-data.mjs.map +1 -0
  242. package/runtime/unicode-case.eli +100 -0
  243. package/runtime/unicode-case.mjs +280 -0
  244. package/runtime/unicode-case.mjs.map +1 -0
  245. package/runtime/wire/http-rpc.mjs +168 -0
  246. package/runtime/wire/markdown.mjs +196 -0
  247. package/runtime/wire/schema.mjs +109 -0
  248. package/stdlib/README.md +54 -0
  249. package/stdlib/core/protocol.eli +81 -17
  250. package/stdlib/core/seq.eli +1 -1
  251. package/stdlib/core/zipper.eli +172 -72
  252. package/stdlib/gepo.eli +12 -0
  253. package/stdlib/interop/js.eli +56 -15
  254. package/stdlib/managed-literal-protocols.eli +494 -0
  255. package/stdlib/managed-literals.eli +1469 -0
  256. package/stdlib/managed-protocol-error.eli +32 -0
  257. package/stdlib/managed-queue-state.eli +65 -0
  258. package/stdlib/managed-runtime-collection-internals.eli +60 -0
  259. package/stdlib/managed-runtime-collection.eli +639 -0
  260. package/stdlib/managed-runtime-data-text.eli +290 -0
  261. package/stdlib/managed-runtime-data.eli +22 -0
  262. package/stdlib/managed-runtime-identifier.eli +44 -0
  263. package/stdlib/managed-runtime-lazy-sequence.eli +131 -0
  264. package/stdlib/managed-runtime-list.eli +19 -0
  265. package/stdlib/managed-runtime-literals.eli +23 -0
  266. package/stdlib/managed-runtime-map.eli +9 -0
  267. package/stdlib/managed-runtime-metadata-internals.eli +6 -0
  268. package/stdlib/managed-runtime-metadata.eli +40 -0
  269. package/stdlib/managed-runtime-object.eli +8 -0
  270. package/stdlib/managed-runtime-order.eli +123 -0
  271. package/stdlib/managed-runtime-persistent-kind.eli +28 -0
  272. package/stdlib/managed-runtime-protocol.eli +28 -0
  273. package/stdlib/managed-runtime-queue.eli +9 -0
  274. package/stdlib/managed-runtime-record.eli +191 -0
  275. package/stdlib/managed-runtime-regex.eli +158 -0
  276. package/stdlib/managed-runtime-sequence.eli +305 -0
  277. package/stdlib/managed-runtime-set-algebra.eli +28 -0
  278. package/stdlib/managed-runtime-set.eli +9 -0
  279. package/stdlib/managed-runtime-sorted.eli +408 -0
  280. package/stdlib/managed-runtime-text.eli +14 -0
  281. package/stdlib/managed-runtime-transducer.eli +268 -0
  282. package/stdlib/managed-runtime-transient.eli +17 -0
  283. package/stdlib/managed-runtime-truth.eli +4 -0
  284. package/stdlib/managed-runtime-type.eli +232 -0
  285. package/stdlib/managed-runtime-value-internals.eli +13 -0
  286. package/stdlib/managed-runtime-value.eli +19 -0
  287. package/stdlib/managed-runtime-vector.eli +25 -0
  288. package/stdlib/managed-sorted-state.eli +233 -0
  289. package/stdlib/managed-testing-value.eli +6 -0
  290. package/stdlib/managed-transient-state.eli +348 -0
  291. package/stdlib/managed-value-state.eli +153 -0
  292. package/stdlib/managed-vector-view-state.eli +102 -0
  293. package/stdlib/managed-wire-http-rpc.eli +362 -0
  294. package/stdlib/managed-wire-markdown.eli +275 -0
  295. package/stdlib/managed-wire-schema.eli +193 -0
  296. package/stdlib/mdp.eli +7 -0
  297. package/stdlib/mds.eli +4 -0
  298. package/stdlib/persistent-vector.eli +23 -6
  299. package/tools/acceptance/check-legacy.mjs +687 -0
  300. package/tools/acceptance/check.eli +431 -0
  301. package/tools/acceptance/compile-evidence.el +49 -0
  302. package/tools/acceptance/finalize-legacy.mjs +498 -0
  303. package/tools/acceptance/finalize.eli +270 -0
  304. package/tools/backends/benchmark.mjs +175 -0
  305. package/tools/backends/build.mjs +135 -0
  306. package/tools/backends/compile.mjs +94 -0
  307. package/tools/backends/compiler-bootstrap.mjs +1001 -0
  308. package/tools/backends/compiler-browser.mjs +361 -0
  309. package/tools/backends/compiler-build.mjs +1628 -0
  310. package/tools/backends/compiler-cli-legacy.mjs +334 -0
  311. package/tools/backends/compiler-cli.mjs +29 -0
  312. package/tools/backends/compiler-corpus-bit.mjs +234 -0
  313. package/tools/backends/compiler-corpus-cli-adapters-legacy.mjs +362 -0
  314. package/tools/backends/compiler-corpus-cli-adapters.mjs +247 -0
  315. package/tools/backends/compiler-corpus-debugging.mjs +221 -0
  316. package/tools/backends/compiler-corpus-emitter.mjs +324 -0
  317. package/tools/backends/compiler-corpus-evaluation-adapters.mjs +65 -0
  318. package/tools/backends/compiler-corpus-execution-legacy.mjs +769 -0
  319. package/tools/backends/compiler-corpus-execution.mjs +3324 -0
  320. package/tools/backends/compiler-corpus-fuzz.mjs +229 -0
  321. package/tools/backends/compiler-corpus-generations.mjs +208 -0
  322. package/tools/backends/compiler-corpus-host-context-legacy.mjs +114 -0
  323. package/tools/backends/compiler-corpus-host-context.mjs +550 -0
  324. package/tools/backends/compiler-corpus-identity-host.mjs +553 -0
  325. package/tools/backends/compiler-corpus-identity-value-adapters-legacy.mjs +298 -0
  326. package/tools/backends/compiler-corpus-identity-value-adapters.mjs +69 -0
  327. package/tools/backends/compiler-corpus-isolated-exports.mjs +21 -0
  328. package/tools/backends/compiler-corpus-legacy.mjs +1155 -0
  329. package/tools/backends/compiler-corpus-literal-provider.mjs +282 -0
  330. package/tools/backends/compiler-corpus-managed-adapters-legacy.mjs +334 -0
  331. package/tools/backends/compiler-corpus-managed-adapters.mjs +937 -0
  332. package/tools/backends/compiler-corpus-managed-cases.mjs +179 -0
  333. package/tools/backends/compiler-corpus-managed-fixtures-legacy.mjs +879 -0
  334. package/tools/backends/compiler-corpus-managed-fixtures.mjs +1287 -0
  335. package/tools/backends/compiler-corpus-matchers.mjs +173 -0
  336. package/tools/backends/compiler-corpus-original-program.mjs +612 -0
  337. package/tools/backends/compiler-corpus-process.mjs +765 -0
  338. package/tools/backends/compiler-corpus-program-driver.mjs +306 -0
  339. package/tools/backends/compiler-corpus-project-adapters-legacy.mjs +497 -0
  340. package/tools/backends/compiler-corpus-project-adapters.mjs +340 -0
  341. package/tools/backends/compiler-corpus-project-entry-host.mjs +511 -0
  342. package/tools/backends/compiler-corpus-project-transport.mjs +151 -0
  343. package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1438 -0
  344. package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1456 -0
  345. package/tools/backends/compiler-corpus-raw-math-fixture.mjs +346 -0
  346. package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +523 -0
  347. package/tools/backends/compiler-corpus-reference-legacy.mjs +263 -0
  348. package/tools/backends/compiler-corpus-reference.mjs +241 -0
  349. package/tools/backends/compiler-corpus-runtime-adapters-legacy.mjs +843 -0
  350. package/tools/backends/compiler-corpus-runtime-adapters.mjs +663 -0
  351. package/tools/backends/compiler-corpus-source-archive.mjs +206 -0
  352. package/tools/backends/compiler-corpus-tools-artifact-adapters.mjs +410 -0
  353. package/tools/backends/compiler-corpus-tools-cli.mjs +363 -0
  354. package/tools/backends/compiler-corpus-tools-reference.mjs +264 -0
  355. package/tools/backends/compiler-corpus.mjs +2054 -0
  356. package/tools/backends/compiler-debug.mjs +142 -0
  357. package/tools/backends/compiler-matrix.mjs +1955 -0
  358. package/tools/backends/compiler-metadata.mjs +203 -0
  359. package/tools/backends/compiler-package-browser.mjs +120 -0
  360. package/tools/backends/compiler-package-legacy.mjs +654 -0
  361. package/tools/backends/compiler-package.mjs +464 -0
  362. package/tools/backends/compiler-project.mjs +126 -0
  363. package/tools/backends/compiler-session.mjs +843 -0
  364. package/tools/backends/compiler-sha256.mjs +152 -0
  365. package/tools/backends/compiler-unicode-profile-host.mjs +196 -0
  366. package/tools/backends/compiler-worker.mjs +573 -0
  367. package/tools/backends/dist/bootstrap-js-stages.mjs +919 -0
  368. package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -0
  369. package/tools/backends/dist/managed-ir-inventory.mjs +488 -0
  370. package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -0
  371. package/tools/backends/dist/record-grid.mjs +1256 -0
  372. package/tools/backends/dist/record-grid.mjs.map +1 -0
  373. package/tools/backends/dist/release-cli.mjs +462 -0
  374. package/tools/backends/dist/release-cli.mjs.map +1 -0
  375. package/tools/backends/dist/run-artifact.mjs +517 -0
  376. package/tools/backends/dist/run-artifact.mjs.map +1 -0
  377. package/tools/backends/eliscript/compiler-corpus-bit.eli +77 -0
  378. package/tools/backends/eliscript/compiler-corpus-debugging.eli +70 -0
  379. package/tools/backends/eliscript/compiler-corpus-project-entry-host.eli +256 -0
  380. package/tools/backends/managed-foreign-binding.mjs +497 -0
  381. package/tools/backends/managed-host-legacy.mjs +1181 -0
  382. package/tools/backends/managed-host-lifecycle.mjs +310 -0
  383. package/tools/backends/managed-host-object-provider.mjs +155 -0
  384. package/tools/backends/managed-host-object-realm.mjs +797 -0
  385. package/tools/backends/managed-host-proxy.mjs +71 -0
  386. package/tools/backends/managed-host-runtime.mjs +5868 -0
  387. package/tools/backends/managed-host.mjs +716 -0
  388. package/tools/backends/managed-module-graph-legacy.mjs +308 -0
  389. package/tools/backends/managed-module-graph.mjs +694 -0
  390. package/tools/backends/managed-runtime-host-legacy.mjs +195 -0
  391. package/tools/backends/managed-runtime.mjs +939 -0
  392. package/tools/backends/managed-source-view-legacy.mjs +332 -0
  393. package/tools/backends/managed-source-view.mjs +959 -0
  394. package/tools/backends/memory-runtime.mjs +100 -0
  395. package/tools/backends/native-benchmark.mjs +88 -0
  396. package/tools/backends/native-managed-runtime.mjs +677 -0
  397. package/tools/backends/native-memory.mjs +768 -0
  398. package/tools/backends/native-node-memory.mjs +142 -0
  399. package/tools/backends/native-node-runner.mjs +99 -0
  400. package/tools/backends/native-node-watchdog.mjs +19 -0
  401. package/tools/backends/native-node-worker.mjs +75 -0
  402. package/tools/backends/stage3-targets.mjs +493 -0
  403. package/tools/bootstrap-command.el +13 -0
  404. package/tools/bootstrap-runtime.el +101 -0
  405. package/tools/bootstrap-seed.el +55 -0
  406. package/tools/project/check-cli.eli +31 -0
  407. package/tools/project/project-cli.eli +42 -0
  408. package/tools/project/project.eli +122 -0
  409. package/tools/runtime/unicode-case-profiles.mjs +13 -0
  410. package/tools/runtime/unicode-case-runtime.el +57 -0
  411. package/tools/testing/source-debugging-corpus-host.eli +16 -0
  412. package/tools/testing/source-debugging.eli +139 -0
  413. package/tools/testing/stdlib-bit-corpus-host.eli +21 -0
  414. package/tools/testing/stdlib-bit-corpus-host.mjs +118 -0
  415. package/tools/testing/stdlib-bit.eli +104 -0
  416. package/tools/testing/stdlib-bit.mjs +255 -0
  417. package/bin/eliscript-bootstrap +0 -15
@@ -0,0 +1,1155 @@
1
+ import {addOriginalStdlibRuntimeAdapters,isOriginalRuntimeHostOnly,originalRuntimeOnlyCase} from './compiler-corpus-runtime-adapters.mjs';
2
+ import {readFile,readdir} from 'node:fs/promises';
3
+ import {resolve, relative, sep, isAbsolute} from 'node:path';
4
+ import {createHash} from 'node:crypto';
5
+ import {types} from 'node:util';
6
+ import {addOriginalEvaluationPrograms} from './compiler-corpus-evaluation-adapters.mjs';
7
+ import {addOriginalProjectPrograms} from './compiler-corpus-project-adapters.mjs';
8
+ import {addOriginalCLIPrograms} from './compiler-corpus-cli-adapters.mjs';
9
+ import {addOriginalManagedLibraryAdapters} from './compiler-corpus-managed-adapters.mjs';
10
+ import {addOriginalManagedFixtureAdapters} from './compiler-corpus-managed-fixtures.mjs';
11
+ import {addOriginalToolsArtifactPrograms,originalToolsHostGateCase} from './compiler-corpus-tools-artifact-adapters.mjs';
12
+ import {addOriginalIdentityValueAdapters} from './compiler-corpus-identity-value-adapters.mjs';
13
+ import {originalSourceCaseLocators} from './compiler-corpus-managed-cases.mjs';
14
+
15
+ const digest = value => createHash('sha256').update(value).digest('hex');
16
+ const stages = new Set(['reader', 'expander', 'analyzer', 'ir']);
17
+ const originalReportOnlyLocators = new Map([
18
+ ['tests/compiler-runtime-scan.test.mjs','committed compiler runtime scan report matches measured sources'],
19
+ ['tests/compiler-ir-kind.test.mjs','committed compiler IR kind report matches measured sources'],
20
+ ['tests/compiler-indent.test.mjs','committed compiler indentation report matches measured sources'],
21
+ ['tests/compiler-locate.test.mjs','committed compiler location report matches measured sources'],
22
+ ['tests/compiler-binary-comparison.test.mjs','committed binary comparison report matches measured sources'],
23
+ ['tests/compiler-reader-character.test.mjs','committed reader character report matches measured sources'],
24
+ ['tests/compiler-source-map-cursor.test.mjs','committed Source Map cursor report matches measured sources'],
25
+ ]);
26
+ const textDecoder = new TextDecoder('utf-8', {fatal: true, ignoreBOM: true});
27
+
28
+ // This parser admits data literals only. Original host-path interpolations are
29
+ // transported separately; they are never evaluated while loading a corpus.
30
+ function originalDataLiteral(source) {
31
+ let at=0;
32
+ const space=()=>{while(/\s/.test(source[at]??'')&&at<source.length)at++;};
33
+ const string=()=>{
34
+ const start=at++;let escaped=false;
35
+ while(at<source.length){const code=source[at++];if(!escaped&&code==='"')return JSON.parse(source.slice(start,at));if(!escaped&&code==='\\')escaped=true;else escaped=false;}
36
+ throw new TypeError('unterminated original data string');
37
+ };
38
+ const value=()=>{
39
+ space();const code=source[at];
40
+ if(code==='"')return string();
41
+ if(code==='['||code==='{'){
42
+ at++;const array=code==='[',result=array?[]:{},end=array?']':'}';space();
43
+ while(source[at]!==end){
44
+ if(at>=source.length)throw new TypeError('unterminated original data literal');
45
+ if(array)result.push(value());
46
+ else{
47
+ space();let key;
48
+ if(source[at]==='"')key=string();
49
+ else{const match=/^[$A-Z_a-z][$\w]*/.exec(source.slice(at));if(!match)throw new TypeError('original data key is not literal');key=match[0];at+=key.length;}
50
+ space();if(source[at++]!==':')throw new TypeError('original data field lacks a colon');
51
+ Object.defineProperty(result,key,{value:value(),writable:true,enumerable:true,configurable:true});
52
+ }
53
+ space();if(source[at]===end)break;if(source[at++]!==',')throw new TypeError('original data literal contains an expression');space();
54
+ }
55
+ at++;return result;
56
+ }
57
+ const literal=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:[.][0-9]+)?(?:[eE][+-]?[0-9]+)?)(?![$\w.])/.exec(source.slice(at));
58
+ if(!literal)throw new TypeError('original data contains a nonliteral expression');
59
+ at+=literal[0].length;return JSON.parse(literal[0]);
60
+ };
61
+ const result=value();space();if(at!==source.length)throw new TypeError('original data has trailing code');return result;
62
+ }
63
+
64
+ function originalRegion(source,begin,end,from=0){
65
+ const start=source.indexOf(begin,from),finish=start<0?-1:source.indexOf(end,start+begin.length);
66
+ if(start<0||finish<0)throw new TypeError('original inline host boundary changed');
67
+ const text=source.slice(start,finish);
68
+ return{text,start,end:finish,byteStart:Buffer.byteLength(source.slice(0,start)),byteEnd:Buffer.byteLength(source.slice(0,finish)),sha256:digest(Buffer.from(text))};
69
+ }
70
+
71
+ function originalInlineArray(source,begin,end,bindings,joiner){
72
+ const region=originalRegion(source,begin,end),body=region.text.slice(begin.length),lines=body.split('\n').map(line=>line.trim()).filter(Boolean),parts=[];
73
+ for(const line of lines){
74
+ if(bindings.has(line))continue;
75
+ const literal=line.endsWith(',')?line.slice(0,-1):line;
76
+ const plainSingle=literal[0]==="'"&&literal.at(-1)==="'"&&!/[\\']/.test(literal.slice(1,-1));
77
+ if(literal[0]!=='"'&&!plainSingle)throw new TypeError('original inline host contains unsupported dynamic concatenation');
78
+ const value=plainSingle?literal.slice(1,-1):originalDataLiteral(literal);if(typeof value!=='string')throw new TypeError('original inline host item is not a string literal');parts.push(value);
79
+ }
80
+ if(lines.filter(line=>bindings.has(line)).length!==bindings.size)throw new TypeError('original host-path interpolation changed');
81
+ return{...region,code:parts.join(joiner)};
82
+ }
83
+
84
+ function originalTemplate(source, prefix, bindings = new Map()) {
85
+ const start=source.indexOf(prefix);if(start<0)throw new TypeError('original template boundary changed');
86
+ let at=start+prefix.length,code='';
87
+ while(at<source.length){
88
+ const unit=source[at++];
89
+ if(unit==='`')return{code,start,end:at,byteStart:Buffer.byteLength(source.slice(0,start)),byteEnd:Buffer.byteLength(source.slice(0,at)),sha256:digest(Buffer.from(source.slice(start,at)))};
90
+ if(unit==='$'&&source[at]==='{'){
91
+ const end=source.indexOf('}',at+1),name=source.slice(at+1,end);
92
+ if(end<0||!bindings.has(name))throw new TypeError('original template has an unbound interpolation');
93
+ code+=bindings.get(name);at=end+1;continue;
94
+ }
95
+ if(unit!=='\\'){code+=unit;continue;}
96
+ const escape=source[at++],simple={n:'\n',r:'\r',t:'\t',b:'\b',f:'\f',v:'\v','0':'\0','\\':'\\','`':'`','$':'$',"'":"'",'"':'"'};
97
+ if(Object.hasOwn(simple,escape)){code+=simple[escape];continue;}
98
+ if(escape==='\n')continue;
99
+ if(escape==='\r'){if(source[at]==='\n')at++;continue;}
100
+ if(escape==='x'||escape==='u'){
101
+ const count=escape==='x'?2:4,hex=source.slice(at,at+count);
102
+ if(!new RegExp('^[0-9a-fA-F]{'+count+'}$').test(hex))throw new TypeError('original template contains unsupported escape');
103
+ code+=String.fromCharCode(parseInt(hex,16));at+=count;continue;
104
+ }
105
+ throw new TypeError('original template contains unsupported escape');
106
+ }
107
+ throw new TypeError('unterminated original template');
108
+ }
109
+
110
+ function sourcePath(root, filename) {
111
+ if (typeof filename !== 'string' || !filename || isAbsolute(filename) || /[\\:\u0000]/.test(filename)) throw new TypeError('invalid original corpus filename');
112
+ const path = resolve(root, filename), part = relative(resolve(root), path);
113
+ if (isAbsolute(part) || part === '..' || part.startsWith('..' + sep)) throw new TypeError('original corpus filename escapes its root');
114
+ return path;
115
+ }
116
+
117
+ // Archive bytes and decoded source each have one owner per load. Re-decoding
118
+ // the archived base64 at every recipe edge used to allocate another copy of
119
+ // the same compiler/stdlib text for each dependent record.
120
+ export function createOriginalCorpusSourceReader({sourceRoot, read = readFile,
121
+ decode = bytes => textDecoder.decode(bytes)}) {
122
+ const files = new Map(), loading = new Map(), decoded = new Map();
123
+ async function file(filename) {
124
+ if (!files.has(filename)) {
125
+ if (!loading.has(filename)) loading.set(filename, (async () => {
126
+ const bytes = await read(sourcePath(sourceRoot, filename));
127
+ const asset = {file: filename, sha256: digest(bytes), bytes: bytes.length,
128
+ encoding: 'base64', content: bytes.toString('base64')};
129
+ files.set(filename, asset);
130
+ })());
131
+ try {await loading.get(filename);} finally {loading.delete(filename);}
132
+ }
133
+ return files.get(filename);
134
+ }
135
+ async function text(filename) {
136
+ const asset = await file(filename);
137
+ // Recheck after the shared read: concurrent first callers must not each
138
+ // decode. Failed UTF8 reads remain failures and are never cached as text.
139
+ if (!decoded.has(filename)) decoded.set(filename, decode(Buffer.from(asset.content, 'base64')));
140
+ return decoded.get(filename);
141
+ }
142
+ return {file, text, evidence: () => [...files.values()]};
143
+ }
144
+
145
+ // Corpus snapshots own their mutable containers, while primitive source text
146
+ // can be retained without the native clone engine copying it for every edge.
147
+ // Inspect the entire graph before copying anything: an accessor or special
148
+ // object requires one native clone of the ORIGINAL graph, preserving native
149
+ // traversal, getter calls, first errors and cross-object aliases together.
150
+ export function cloneCompilerCorpusData(value) {
151
+ const shapes = new Map(), pending = [value];
152
+ const fallback = () => {shapes.clear();pending.length = 0;return structuredClone(value);};
153
+ while (pending.length) {
154
+ const item = pending.pop(), kind = typeof item;
155
+ if (item === null || kind === 'undefined' || kind === 'string' || kind === 'number' ||
156
+ kind === 'boolean' || kind === 'bigint') continue;
157
+ if (kind !== 'object' || types.isProxy(item)) return fallback();
158
+ if (shapes.has(item)) continue;
159
+ const array = Array.isArray(item), prototype = Object.getPrototypeOf(item);
160
+ if (array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null)
161
+ return fallback();
162
+ const descriptors = Object.getOwnPropertyDescriptors(item), entries = [];
163
+ for (const key of Object.keys(descriptors)) {
164
+ const descriptor = descriptors[key];
165
+ if (!Object.hasOwn(descriptor, 'value')) return fallback();
166
+ // Native structuredClone ignores symbol keys and non-enumerable data.
167
+ // Array length is retained separately so trailing holes survive too.
168
+ if (!descriptor.enumerable) continue;
169
+ entries.push(key, descriptor.value);pending.push(descriptor.value);
170
+ }
171
+ shapes.set(item, {array, length: array ? descriptors.length.value : 0, entries});
172
+ }
173
+ // Both passes are iterative, including cycles and deeply nested records.
174
+ // All containers exist before links are installed, so aliases never depend
175
+ // on which edge was encountered first during the preflight.
176
+ for (const shape of shapes.values()) shape.copy = shape.array ? new Array(shape.length) : {};
177
+ for (const shape of shapes.values()) for (let index = 0; index < shape.entries.length; index += 2) {
178
+ const member = shape.entries[index + 1];
179
+ Object.defineProperty(shape.copy, shape.entries[index], {
180
+ value: member !== null && typeof member === 'object' ? shapes.get(member).copy : member,
181
+ writable: true, enumerable: true, configurable: true,
182
+ });
183
+ }
184
+ return value !== null && typeof value === 'object' ? shapes.get(value).copy : value;
185
+ }
186
+
187
+ export function cloneCompilerCorpusModules(modules) {
188
+ return cloneCompilerCorpusData(modules);
189
+ }
190
+
191
+ function cloneSourceProjectRequest(request) {
192
+ return cloneCompilerCorpusData(request);
193
+ }
194
+
195
+ // This adapter reads the original data; it does not execute its test files,
196
+ // translate their JavaScript or extract source strings from arbitrary scripts.
197
+ export async function loadOriginalCompilerCorpus({sourceRoot, originals}) {
198
+ if (!originals?.manifests || typeof sourceRoot !== 'string') throw new TypeError('original compiler manifests and sourceRoot are required');
199
+ const parity = originals.manifests.find(item => item.id === 'compiler-parity');
200
+ const stable = originals.manifests.find(item => item.id === 'stable-compatibility');
201
+ if (!parity || !stable) throw new Error('both original compiler corpora are required');
202
+ const records = [], claimed = new Set(), irCases = [], fullyMappedSuites = new Set();
203
+ const {file, text, evidence: sourceEvidence} = createOriginalCorpusSourceReader({sourceRoot});
204
+ async function json(filename) {return JSON.parse(await text(filename));}
205
+ const diagnostics = await json('contracts/diagnostic-corpus.json');
206
+ function add(record) {
207
+ for (const id of record.coverage) claimed.add(id);
208
+ records.push(record);
209
+ }
210
+ function bindCoverage(record, ids) {
211
+ if(!records.includes(record)||!Array.isArray(ids)||
212
+ ids.some(id=>typeof id!=='string'||!originals.requiredCoverage.includes(id)))
213
+ throw new TypeError('original coverage must bind an existing recipe and retained identities');
214
+ for(const id of ids){
215
+ if(!record.coverage.includes(id))record.coverage.push(id);
216
+ claimed.add(id);
217
+ }
218
+ }
219
+ const stableFiles = new Set(stable.document.fixtureFiles);
220
+ for (const fixture of parity.document.fixtures) {
221
+ if (!stages.has(fixture.id)) throw new Error('unrepresented original compiler stage: ' + fixture.id);
222
+ const suite = await json(fixture.file);
223
+ for (const classification of ['valid', 'invalid']) {
224
+ // The canonical parity inventory counts an absent classification as
225
+ // zero (the IR corpus has no negative section). A present malformed
226
+ // section remains an error, and the declared count still must match.
227
+ const cases = !Object.hasOwn(suite, classification) && fixture[classification] === 0 ? [] : suite[classification];
228
+ if (!Array.isArray(cases) || cases.length !== fixture[classification]) {
229
+ throw new Error('original fixture case count changed: ' + fixture.file + ':' + classification);
230
+ }
231
+ for (let index = 0; index < cases.length; index++) {
232
+ const item = cases[index];
233
+ const source = Object.hasOwn(item, 'source') ? item.source : await text(item.file);
234
+ if (typeof source !== 'string' || typeof item.filename !== 'string') throw new Error('unrepresented original source case: ' + fixture.file + ':' + index);
235
+ const id = 'compiler-parity:' + fixture.id + ':' + classification + ':' + index;
236
+ await file('tests/bootstrap-' + fixture.id + '-oracle.el');
237
+ const coverage = [id];
238
+ if (stableFiles.has(fixture.file)) coverage.push('stable-compatibility:' + fixture.file);
239
+ const diagnostic = diagnostics.suites?.find(s => s.id === fixture.id)?.cases?.find(c => c.name === item.name);
240
+ const expected = classification === 'invalid'
241
+ ? {kind: 'diagnostic', message: item.error, ...(diagnostic ? {diagnostic: diagnostic.diagnostic} : {})}
242
+ : {kind: 'stage', oracleRequired: true};
243
+ const request = {operation: 'stage', stage: fixture.id, source, filename: item.filename,
244
+ ...(fixture.id === 'analyzer' ? {expand: false} : {}),
245
+ ...(Object.hasOwn(item, 'macroContext') ? {macroContext: structuredClone(item.macroContext)} : {})};
246
+ add({id, kind: 'stage', coverage, request, expected,
247
+ original: {manifest: parity.id, fixture: fixture.file, classification, index, case: structuredClone(item)},
248
+ ...(item.file ? {dependencies: [item.file]} : {})});
249
+ if (fixture.id === 'ir' && classification === 'valid') {
250
+ irCases.push({source,filename:item.filename,name:item.name});
251
+ await file('tests/bootstrap-emitter-oracle.el');
252
+ add({id: id + ':emitter', kind: 'stage', coverage: [...coverage],
253
+ request: {...request, stage: 'emitter', sourceMap: {generatedFile: 'fixture.mjs', sourceName: item.filename}},
254
+ expected: {kind: 'stage', oracleRequired: true},
255
+ original: {manifest: parity.id, fixture: fixture.file, classification, index, case: structuredClone(item),
256
+ suite: 'tests/bootstrap-emitter.test.mjs'}});
257
+ }
258
+ }
259
+ }
260
+ }
261
+ // This is the exact source wrapper used by the retained behavior suite.
262
+ // The unmodified scenario source and all error/recovery fields remain bound.
263
+ for (const filename of stable.document.fixtureFiles) {
264
+ await file(filename);
265
+ if (!filename.endsWith('.json')) continue;
266
+ const document = JSON.parse(await text(filename));
267
+ if (document?.format !== 'eliscript-managed-bdd') continue;
268
+ if (document.version !== 1 || !Array.isArray(document.features)) throw new Error('unsupported original BDD catalog shape');
269
+ const ids = new Set();
270
+ for (const feature of document.features) {
271
+ if (!Array.isArray(feature.scenarios)) throw new Error('original BDD feature has no scenarios');
272
+ for (const scenario of feature.scenarios) {
273
+ if (typeof scenario.id !== 'string' || ids.has(scenario.id) || typeof scenario.source !== 'string') throw new Error('invalid original BDD scenario');
274
+ ids.add(scenario.id);
275
+ const source = ';中😀\n(defconst marker 1)\n' + scenario.source + '\n(export run' + (Object.hasOwn(scenario, 'recover') ? ' recover' : '') + ')';
276
+ const sourceFilename = 'bdd-' + scenario.id + '.eli';
277
+ add({id: 'stable-compatibility:bdd:' + scenario.id, kind: 'project', coverage: ['stable-compatibility:' + filename],
278
+ modules: [{id: 'entry.mjs', filename: sourceFilename, source}], entry: 'entry.mjs',
279
+ request: {operation: 'project'}, auto: 1,
280
+ execution: {kind: 'managed-bdd', export: 'run', scenario: structuredClone(scenario)},
281
+ expected: {kind: 'managed-bdd', scenario: structuredClone(scenario)},
282
+ original: {manifest: stable.id, fixture: filename, feature: feature.name, case: structuredClone(scenario),
283
+ sourceRecipe: {prefix: ';中😀\n(defconst marker 1)\n', suffix: '\n(export run' + (Object.hasOwn(scenario, 'recover') ? ' recover' : '') + ')'},
284
+ suite: 'tests/wasm-managed-behavior.test.mjs'}});
285
+ }
286
+ }
287
+ }
288
+ // The remaining suites construct projects, mutate files, spawn host oracles,
289
+ // invoke portable closures or supply data tables. Their auxiliary files are
290
+ // dependencies of a suite, never invented standalone Eliscript programs.
291
+ const conformance = await json('tests/conformance/manifest.json');
292
+ const features = new Map(conformance.features.map(feature => [feature.id, feature]));
293
+ const locators = [];
294
+ for (const featureId of stable.document.stableCoreFeatureIds) {
295
+ const feature = features.get(featureId);
296
+ if (!feature || feature.status !== 'stable') throw new Error('original stable feature is unavailable: ' + featureId);
297
+ for (let index = 0; index < (feature.evidence ?? []).length; index++) {
298
+ const locator = feature.evidence[index];
299
+ await file(locator.file);
300
+ locators.push({id: 'stable-compatibility:evidence:' + featureId + ':' + index, featureId, ...structuredClone(locator)});
301
+ }
302
+ }
303
+ if (locators.length !== stable.document.evidenceLocatorCount) throw new Error('original stable evidence inventory changed');
304
+ for (const dimension of parity.document.dimensions) for (let index = 0; index < dimension.evidence.length; index++) {
305
+ const locator = dimension.evidence[index];
306
+ await file(locator.file);
307
+ locators.push({id: 'compiler-parity:dimension:' + dimension.id + ':' + index, dimension: dimension.id, ...structuredClone(locator)});
308
+ }
309
+ for(const locator of originals.additionalLocators??[]){
310
+ const original=await file(locator.file);
311
+ if(original.sha256!==locator.originalCase?.sourceSha256)throw new Error('original managed case source changed while binding its corpus');
312
+ locators.push(structuredClone(locator));
313
+ }
314
+ // Bind named fixture locators only after their complete original inventory
315
+ // exists. Preserve case/record/evidence order and put their IDs between the
316
+ // original case ID and the whole-fixture binding, just as for direct cases.
317
+ for(const record of records){
318
+ if(record.kind!=='stage'||record.original?.manifest!==parity.id||
319
+ typeof record.original?.fixture!=='string'||typeof record.original?.case?.name!=='string')continue;
320
+ const named=locators.filter(locator=>locator.file===record.original.fixture&&
321
+ locator.contains===record.original.case.name&&!record.coverage.includes(locator.id));
322
+ record.coverage.splice(1,0,...named.map(locator=>locator.id));
323
+ for(const locator of named)claimed.add(locator.id);
324
+ }
325
+ for (const filename of parity.document.bootstrapSources) await file(filename);
326
+ await file('tests/bootstrap-tests.el');
327
+ if(stableFiles.has('tests/fixtures/bootstrap-symbols.json')){
328
+ const symbolCases=await json('tests/fixtures/bootstrap-symbols.json');
329
+ const functions={segment:['munge-segment','munge_segment'],binding:['binding-name','binding_name'],reference:['reference-name','reference_name']};
330
+ const calls=[];
331
+ for(const [operation,cases]of Object.entries(symbolCases)){
332
+ if(!functions[operation]||!Array.isArray(cases))throw new Error('unrepresented original symbol fixture operation');
333
+ for(const item of cases)calls.push({name:functions[operation][0],javascriptName:functions[operation][1],args:[item.input],
334
+ ...(Object.hasOwn(item,'error')?{error:item.error}:{expected:item.output})});
335
+ }
336
+ const request={operation:'project',entry:'symbol.mjs',sourceMap:true,modules:[{id:'symbol.mjs',filename:'bootstrap/compiler/symbol.eli',source:await text('bootstrap/compiler/symbol.eli')}]};
337
+ add({id:'stable-compatibility:symbol-mapping',kind:'sequence',coverage:['stable-compatibility:tests/fixtures/bootstrap-symbols.json',...locators.filter(item=>item.file==='tests/bootstrap-symbol.test.mjs').map(item=>item.id)],
338
+ original:{suite:'tests/bootstrap-symbol.test.mjs',fixture:'tests/fixtures/bootstrap-symbols.json'},expected:{kind:'sequence'},steps:[
339
+ {id:'first',request,artifact:{kind:'exports',auto:1,calls}},
340
+ {id:'repeat',request:cloneSourceProjectRequest(request),artifact:{kind:'exports',auto:1,calls:structuredClone(calls)},sameProductAs:'first'},
341
+ ]});
342
+ await file('tests/bootstrap-symbol.test.mjs');
343
+ // The original suite consists of the complete frozen calls and exact
344
+ // code/map repeat comparison represented by the two project steps above.
345
+ fullyMappedSuites.add('tests/bootstrap-symbol.test.mjs');
346
+ }
347
+ for(const suite of ['tests/bootstrap-project.test.mjs','tests/macro-file-dependencies.test.mjs','tests/esm-imports.test.mjs','tests/bootstrap-ir-serialization.test.mjs'])await file(suite);
348
+ const portableSources={};for(const name of ['sequence','text','object'])portableSources[name]=await text('stdlib/'+name+'.eli');
349
+ addOriginalRequestRecipes({add,locators,irCases,portableSources});
350
+ const formatterSuite=await addOriginalFormatterRecipes({add,locators,text,file,sourceRoot});
351
+ const generatedNamesSuite=await addOriginalGeneratedNamesRecipes({add,locators,text,file});
352
+ if(generatedNamesSuite)fullyMappedSuites.add(generatedNamesSuite);
353
+ const esmSuite=await addOriginalESMRecipes({add,locators,text,file});
354
+ if(esmSuite)fullyMappedSuites.add(esmSuite);
355
+ for(const suite of await addOriginalCompilerModulePrograms({add,locators,text,file,bootstrapSources:parity.document.bootstrapSources}))fullyMappedSuites.add(suite);
356
+ for(const suite of await addOriginalEvaluationPrograms({add,locators,text,file,bootstrapSources:parity.document.bootstrapSources}))fullyMappedSuites.add(suite);
357
+ for(const suite of await addOriginalProjectPrograms({add,locators,text,file,stableFiles,bootstrapSources:parity.document.bootstrapSources,sourceRoot}))fullyMappedSuites.add(suite);
358
+ for(const suite of await addOriginalCLIPrograms({add,locators,text,file,bootstrapSources:parity.document.bootstrapSources,sourceRoot}))fullyMappedSuites.add(suite);
359
+ if(formatterSuite)fullyMappedSuites.add(formatterSuite);
360
+ // These original scripts consume a generated module (rather than importing
361
+ // the old JS runtime as the implementation under examination).
362
+ const cliSource=await text('tests/cli-test.sh');
363
+ const diagnosticFilename='tests/fixtures/diagnostic-unbound.eli';
364
+ if(stableFiles.has(diagnosticFilename)){
365
+ const assertion=originalRegion(cliSource,'DIAGNOSTIC_FILE="$TEMP_DIR/diagnostic.json" bun -e \'','\n\'\n');
366
+ add({id:'original-sequence:cli-unbound-diagnostic',kind:'sequence',
367
+ coverage:['stable-compatibility:'+diagnosticFilename],expected:{kind:'sequence'},
368
+ original:{fixture:diagnosticFilename,suite:'tests/cli-test.sh',sourceSha256:(await file('tests/cli-test.sh')).sha256,
369
+ regions:[{start:assertion.start,end:assertion.end,byteStart:assertion.byteStart,byteEnd:assertion.byteEnd,sha256:assertion.sha256}]},
370
+ steps:[{id:'original-json-diagnostic',request:{operation:'compile',source:await text(diagnosticFilename),filename:diagnosticFilename},
371
+ error:{code:'ELI-A0001',phase:'analysis',expectFields:[
372
+ {path:['message'],value:'unbound symbol: missing'},{path:['format'],value:'eliscript-diagnostic'},{path:['version'],value:1},{path:['severity'],value:'error'},
373
+ {path:['location','file'],value:diagnosticFilename},{path:['location','start','offset'],value:19},
374
+ {path:['location','start','line'],value:2},{path:['location','start','column'],value:3},
375
+ ]}}]});
376
+ }
377
+ let runtimeSources;
378
+ async function originalRuntimeSources(){
379
+ if(runtimeSources)return runtimeSources;
380
+ const result=[];
381
+ async function walk(directory){
382
+ const entries=await readdir(sourcePath(sourceRoot,directory),{withFileTypes:true});entries.sort((left,right)=>left.name<right.name?-1:left.name>right.name?1:0);
383
+ for(const item of entries){
384
+ const filename=directory+'/'+item.name;
385
+ if(item.isDirectory())await walk(filename);
386
+ else if(item.isFile()&&filename.endsWith('.mjs'))result.push({id:filename,filename,source:await text(filename)});
387
+ }
388
+ }
389
+ await walk('runtime');runtimeSources=result;return result;
390
+ }
391
+ function originalInlineHost(marker){
392
+ const block=cliSource.indexOf(marker),begin=block<0?-1:cliSource.indexOf("bun --eval '\n",block),end=begin<0?-1:cliSource.indexOf("\n')",begin);
393
+ if(block<0||begin<0||end<0)throw new Error('original inline host oracle is unavailable: '+marker);
394
+ return cliSource.slice(begin+"bun --eval '\n".length,end)+'\n';
395
+ }
396
+ const coreSetSuite=await text('tests/core-set.test.mjs'),coreStdlibSuite=await text('tests/core-stdlib.test.mjs');
397
+ const coreSetInline=originalInlineArray(coreSetSuite,' const source = [\n',' ].join("\\n");',new Set([
398
+ '`const usage = await import(${JSON.stringify(pathToFileURL(module).href)});`,',
399
+ ]),'\n');
400
+ const coreSetExpected=originalRegion(coreSetSuite,' const expected = {',';\n expect(await runUsageHost',coreSetSuite.indexOf('test("Eliscript-authored set algebra'));
401
+ const coreSetExpectedValue=originalDataLiteral(coreSetExpected.text.slice(' const expected = '.length));
402
+ const coreStdlibInline=originalInlineArray(coreStdlibSuite,' const nodeCheck = [\n',' ].join("");',new Set([
403
+ ...['apiUsageModule','seqModule','identifierModule','metadataModule','collectionModule'].map((binding,index)=>'`const '+['api','seq','identifier','metadata','collection'][index]+' = await import(${JSON.stringify(pathToFileURL('+binding+').href)});`,'),
404
+ '`const queue = await import(${JSON.stringify(pathToFileURL(resolve(ROOT, "runtime/core/queue.mjs")).href)});`,',
405
+ ]),'');
406
+ const coreUsage=originalRegion(coreStdlibSuite,' const usage = await import(pathToFileURL(usageModule).href);',' const generatedUsage =');
407
+ const coreUsageShape=originalRegion(coreStdlibSuite,' const generatedUsage =',' const api = await import(pathToFileURL(apiUsageModule).href);',coreUsage.end);
408
+ const coreApi=originalRegion(coreStdlibSuite,' const api = await import(pathToFileURL(apiUsageModule).href);',' const nodeCheck = [',coreUsageShape.end);
409
+ const coreTailShape=originalRegion(coreStdlibSuite,' const protocolMap = await Bun.file(`${protocolModule}.map`).json();',' } finally {',coreStdlibInline.end);
410
+ const coreLibraryNames=['protocol','identifier','data-text','metadata','collection','transient','transducer','seq','data'];
411
+ const coreLibraryModules=coreLibraryNames.map(name=>({id:'stdlib/core/'+name+'.mjs',filename:'stdlib/core/'+name+'.eli'}));
412
+ const coreModuleBindings={usageModule:'core-stdlib-usage.mjs',apiUsageModule:'core-language-api-usage.mjs',
413
+ ...Object.fromEntries(coreLibraryNames.map(name=>[({'data-text':'dataText'}[name]??name)+'Module','stdlib/core/'+name+'.mjs']))};
414
+ const coreBindingSource=Object.entries(coreModuleBindings).map(([name,id])=>'const '+name+' = fileURLToPath(new URL('+JSON.stringify('../'+id)+',import.meta.url));').join('\n');
415
+ const coreImports=coreStdlibSuite.slice(0,coreStdlibSuite.indexOf('const ROOT ='));
416
+ const coreOriginalRegions=[coreUsage,coreUsageShape,coreApi,coreStdlibInline,coreTailShape].map(({start,end,byteStart,byteEnd,sha256})=>({start,end,byteStart,byteEnd,sha256}));
417
+ const inlinePlans=[
418
+ {source:'tests/fixtures/core-set-usage.eli',entry:'core-set-usage.mjs',layout:'source',runtime:true,
419
+ extraModules:[{id:'stdlib/core/set.mjs',filename:'stdlib/core/set.eli'}],hostOrigin:'tests/core-set.test.mjs',
420
+ generatedHost:{id:'tests/__eliscript_original_core_set.mjs',source:'import {pathToFileURL} from "node:url";\nconst usage = await import(pathToFileURL(process.argv[2]).href);\n'+coreSetInline.code+'\n'},
421
+ stdoutJSON:coreSetExpectedValue,originalRegions:[coreSetInline,coreSetExpected].map(({start,end,byteStart,byteEnd,sha256})=>({start,end,byteStart,byteEnd,sha256}))},
422
+ {source:'tests/fixtures/core-stdlib-usage.eli',entry:'core-stdlib-usage.mjs',layout:'source',runtime:true,
423
+ extraModules:[...coreLibraryModules,{id:'core-language-api-usage.mjs',filename:'tests/fixtures/core-language-api-usage.eli'}],hostOrigin:'tests/core-stdlib.test.mjs',requiresBun:true,
424
+ extraEntries:['core-language-api-usage.mjs',...coreLibraryModules.map(item=>item.id)],
425
+ generatedHost:{id:'tests/__eliscript_original_core_stdlib.mjs',source:coreImports+'\nimport {fileURLToPath} from "node:url";\n'+coreBindingSource+'\n'+coreUsage.text+
426
+ '\nif(process.env.ELISCRIPT_ORIGINAL_TARGET === "javascript"){\n'+coreUsageShape.text+'\n}\n'+coreApi.text+
427
+ '\nif(process.env.ELISCRIPT_ORIGINAL_TARGET === "javascript"){\n'+coreTailShape.text+'\n}\n'},originalRegions:coreOriginalRegions,
428
+ targetSpecificAssertions:{javascript:['generatedUsage/seqMap/dataMap','protocolMap/identifierMap/dataTextMap/metadataMap/collectionMap/transientMap/transducerMap']},
429
+ },
430
+ {source:'tests/fixtures/core-language-api-usage.eli',entry:'core-language-api-usage.mjs',layout:'source',runtime:true,
431
+ extraModules:coreLibraryModules,hostOrigin:'tests/core-stdlib.test.mjs',originalRegions:[coreStdlibInline].map(({start,end,byteStart,byteEnd,sha256})=>({start,end,byteStart,byteEnd,sha256})),
432
+ generatedHost:{id:'tests/__eliscript_original_core_stdlib_node.mjs',source:'import {fileURLToPath} from "node:url";\n'+coreBindingSource+'\n'+
433
+ 'const api = await import(new URL("../core-language-api-usage.mjs",import.meta.url));\n'+
434
+ ['seq','identifier','metadata','collection'].map(name=>'const '+name+' = await import(new URL('+JSON.stringify('../stdlib/core/'+name+'.mjs')+',import.meta.url));').join('\n')+
435
+ '\nconst queue = await import(new URL("../runtime/core/queue.mjs",import.meta.url));\n'+coreStdlibInline.code+'\n'},
436
+ },
437
+ ];
438
+ const programPlans=[
439
+ ...inlinePlans,
440
+ {source:'tests/fixtures/core.eli'},
441
+ {source:'tests/fixtures/compatibility/stable-core-values.eli',stdout:'tests/fixtures/compatibility/stable-core-values.stdout'},
442
+ {source:'tests/fixtures/compatibility/native-containers-v2.eli',stdout:'tests/fixtures/compatibility/native-containers-v2.stdout'},
443
+ ...[
444
+ ['async','ASYNC_OUTPUT=$(', 'ELISCRIPT_ASYNC_MODULE','[21,42,20,2,3,false,"yes",5]\n'],
445
+ ['exceptions','EXCEPTIONS_OUTPUT=$(', 'ELISCRIPT_EXCEPTIONS_MODULE','[4,"caught:zero",9,7,"async:bad","inner:outer",3]\n'],
446
+ ['vector-patterns','PATTERNS_OUTPUT=$(', 'ELISCRIPT_PATTERNS_MODULE','[[1,2,4,[5,6],9,5,[6],9],[1,2,4,[],null,null,[],null],8,7,42,[7,"caught"]]\n'],
447
+ ['map-patterns','MAP_PATTERNS_OUTPUT=$(', 'ELISCRIPT_MAP_PATTERNS_MODULE','[["Ada",18,"missing"],["Ada",null,null],"anonymous",["Ada","London"],["Ada",5,"text","symbol"],["Ada",7,"text","symbol"],["persistent",9,"text","symbol"],["Ada",18,{"name":"Ada"}],0,[7,"caught"],"portable",["Eliscript",18]]\n'],
448
+ ].map(([name,marker,environment,stdoutText])=>({source:'tests/fixtures/'+name+'.eli',hostEval:originalInlineHost(marker),environment,stdoutText,hostOrigin:'tests/cli-test.sh'})),
449
+ ...['deferred-usage','function-usage','sequence-usage','text-usage','object-usage'].map(name=>({source:'tests/fixtures/'+name+'.eli',stdlib: ['sequence-usage','text-usage','object-usage'].includes(name)?'flat':'nested'})),
450
+ ...['core-expression-forms','language-equality','local-recursive-functions','multi-arity','value-dispatch'].map(name=>({source:'tests/fixtures/'+name+'.eli',host:'tests/fixtures/'+name+'-host.mjs',argument:name==='core-expression-forms'?'url':'path'})),
451
+ {source:'tests/fixtures/bit-usage.eli',host:'tests/fixtures/bit-host.mjs',extraModules:[{id:'tests/fixtures/bit.mjs',filename:'stdlib/bit.eli'}],argumentModules:['tests/fixtures/bit-usage.mjs','tests/fixtures/bit.mjs']},
452
+ {source:'stdlib/persistent-queue.eli',host:'tests/fixtures/persistent-queue-library-host.mjs',layout:'source',runtime:true},
453
+ ...['vector','map','set'].map(collection=>({id:'persistent-core-exit-'+collection,
454
+ source:'stdlib/value.eli',host:'tests/fixtures/persistent-core-exit-host.mjs',stdlib:'flat',
455
+ dependencies:['bit','persistent-list','persistent-vector','persistent-map','persistent-set'],
456
+ hostImports:['persistent-vector','persistent-map','persistent-set'],
457
+ arguments:[{directory:true},{literal:collection}]})),
458
+ {source:'stdlib/state/atom.eli',entry:'state/atom.mjs',host:'tests/fixtures/atom-host.mjs',stdlib:'flat',
459
+ dependencies:['bit','persistent-list','persistent-vector','persistent-map','persistent-set','value'],hostImports:['persistent-vector']},
460
+ {source:'stdlib/interop/js.eli',host:'tests/fixtures/interop-js-host.mjs',layout:'source',stdlib:true,runtime:true,
461
+ dependencies:['bit','persistent-list','persistent-vector','persistent-map','persistent-set','value'],hostImports:['persistent-list','persistent-vector','persistent-map','persistent-set','value']},
462
+ ...[
463
+ ['lazy-sequence',['lazy-sequence','transducer']],
464
+ ['persistent-sorted',['sorted']],
465
+ ['persistent-tree-walk',['walk']],
466
+ ['persistent-zipper',['zipper']],
467
+ ['declarative-protocol',['protocol']],
468
+ ['declarative-record',['protocol','record']],
469
+ ['declarative-type',['protocol','type']],
470
+ ['regex',['regex']],
471
+ ['literal-runtime',[]],
472
+ ].map(([name,dependencies])=>({source:'tests/fixtures/'+name+'.eli',host:'tests/fixtures/'+name+'-host.mjs',layout:'source',runtime:true,
473
+ extraModules:dependencies.map(dependency=>({id:'stdlib/core/'+dependency+'.mjs',filename:'stdlib/core/'+dependency+'.eli'}))})),
474
+ {source:'tests/fixtures/wire.eli',host:'tests/fixtures/wire-host.mjs',layout:'source',runtime:true,
475
+ extraModules:['mdp','mds','gepo'].map(name=>({id:'stdlib/'+name+'.mjs',filename:'stdlib/'+name+'.eli'}))},
476
+ {source:'stdlib/core/text.eli',host:'tests/fixtures/core-text-object-host.mjs',layout:'source',runtime:true,
477
+ extraModules:[{id:'stdlib/core/object.mjs',filename:'stdlib/core/object.eli'}],argumentModules:['stdlib/core/text.mjs','stdlib/core/object.mjs']},
478
+ {source:'stdlib/core/protocol.eli',entry:'stdlib/core/protocol-impl.mjs',host:'tests/fixtures/eliscript-protocol-host.mjs',layout:'source',runtime:true},
479
+ {source:'stdlib/multimethod.eli',host:'tests/fixtures/multimethod-host.mjs',stdlib:'flat',
480
+ extraModules:[{id:'declarative-multimethod.mjs',filename:'tests/fixtures/declarative-multimethod.eli'}],
481
+ argumentModules:['multimethod.mjs','declarative-multimethod.mjs'],hostImports:['hierarchy','persistent-map','persistent-set','persistent-vector']},
482
+ ...['json','numeric','result','metadata','data-text','value','identifier','persistent-list','persistent-vector','persistent-map','persistent-set'].map(name=>({source:'stdlib/'+name+'.eli',stdlib:'flat',host:'tests/fixtures/portable-'+({identifier:'identifier','persistent-list':'list','persistent-vector':'vector','persistent-map':'map','persistent-set':'set'}[name]??name)+'-host.mjs',argument:'path',
483
+ hostImports:({json:['result','persistent-vector','persistent-map','value','identifier','persistent-list','persistent-set'],result:['persistent-vector','persistent-map','value','data-text'],metadata:['value','persistent-list','persistent-vector','persistent-map','persistent-set'],
484
+ 'data-text':['identifier','persistent-list','persistent-map','metadata','persistent-set','value','persistent-vector'],value:['identifier','persistent-list','persistent-vector','persistent-map','persistent-set']})[name]??[],
485
+ ...(name==='value'?{extraModules:[{id:'host-identity-token.mjs',filename:'tests/fixtures/host-identity-token.eli'}],extraEntries:['host-identity-token.mjs']}:{}),
486
+ })),
487
+ ];
488
+ const topLevelStdlib=(await readdir(sourcePath(sourceRoot,'stdlib'))).filter(name=>/^[a-z][a-z-]*[.]eli$/.test(name)).sort();
489
+ for(const plan of programPlans){
490
+ // A host oracle is only attached when it is part of the frozen inventory.
491
+ if(plan.host&&!stableFiles.has(plan.host))continue;
492
+ if(plan.source.startsWith('tests/fixtures/')&&!stableFiles.has(plan.source))continue;
493
+ const prefix=plan.layout==='source'?'stdlib/':plan.stdlib==='flat'?(plan.source.startsWith('stdlib/')?'':'tests/fixtures/'):'tests/fixtures/stdlib/';
494
+ const entry=plan.entry??(plan.layout==='source'?plan.source.slice(0,-4)+'.mjs':plan.source.startsWith('stdlib/')?plan.source.slice('stdlib/'.length,-4)+'.mjs':plan.source.slice(0,-4)+'.mjs');
495
+ const modules=[{id:entry,filename:plan.source,source:await text(plan.source)}];
496
+ for(const item of plan.extraModules??[])modules.push({...item,source:await text(item.filename)});
497
+ if(plan.stdlib)for(const name of plan.dependencies?.map(name=>name+'.eli')??topLevelStdlib){
498
+ const filename='stdlib/'+name;if(filename===plan.source)continue;
499
+ modules.push({id:prefix+name.slice(0,-4)+'.mjs',filename,source:await text(filename)});
500
+ }
501
+ const coverage=['stable-compatibility:'+plan.source];
502
+ for(const item of plan.extraModules??[])if(stableFiles.has(item.filename))coverage.push('stable-compatibility:'+item.filename);
503
+ if(plan.host){await file(plan.host);coverage.push('stable-compatibility:'+plan.host);}
504
+ if(plan.stdout){await file(plan.stdout);coverage.push('stable-compatibility:'+plan.stdout);}
505
+ // Only frozen denominator IDs are claimed. Stdlib sources remain bound
506
+ // dependencies even when the manifest lists their original host oracle.
507
+ const bound=coverage.filter(id=>originals.requiredCoverage.includes(id));
508
+ if(!bound.length)continue;
509
+ await file('tests/fixtures/compiled-eli-node-loader.mjs');
510
+ add({id:'stable-compatibility:program:'+(plan.id??plan.source),kind:'project',coverage:bound,modules,entry,
511
+ request:{operation:'project',resolveImports:true,phased:true,sourceMap:true,...(plan.runtime?{hostSources:await originalRuntimeSources()}:{}),
512
+ entries:[...new Set([entry,...(plan.argumentModules??[]),...(plan.extraEntries??[]),...(plan.hostImports??[]).map(name=>prefix+name+'.mjs')])]},
513
+ execution:{kind:'original-program',host:plan.generatedHost?.id??plan.host??null,hostSource:plan.generatedHost?.source??(plan.host?await text(plan.host):null),hostEval:plan.hostEval??null,environment:plan.environment??null,argument:plan.argument??'path',argumentModules:plan.argumentModules??[entry],...(plan.arguments?{arguments:structuredClone(plan.arguments)}:{}),aliases:true,requiresBun:plan.requiresBun===true},
514
+ expected:{kind:'seed-program',oracleRequired:true,...(plan.stdout?{stdout:await text(plan.stdout)}:{}),...(plan.stdoutText?{stdout:plan.stdoutText}:{}),...(plan.stdoutJSON?{stdoutJSON:plan.stdoutJSON}:{})},
515
+ original:{manifest:stable.id,fixture:plan.source,host:plan.host??plan.hostOrigin??null,stdout:plan.stdout??null,
516
+ ...(plan.originalRegions?{sourceSha256:(await file(plan.hostOrigin)).sha256,locators:locators.filter(item=>item.file===plan.hostOrigin).map(item=>item.id),
517
+ regions:plan.originalRegions,targetSpecificAssertions:plan.targetSpecificAssertions??null}: {})}});
518
+ }
519
+ for(const suite of await addOriginalStdlibRuntimeAdapters({add,records,locators,text,file,region:originalRegion,data:originalDataLiteral,bootstrapSources:parity.document.bootstrapSources}))fullyMappedSuites.add(suite);
520
+ for(const suite of await addOriginalManagedLibraryAdapters({add,locators,text,file,stableFiles,sourceRoot}))fullyMappedSuites.add(suite);
521
+ await addOriginalManagedFixtureAdapters({add,records,bindCoverage,locators,text,file,stableFiles,sourceRoot});
522
+ await addOriginalIdentityValueAdapters({add,locators,text,file,stableFiles,sourceRoot});
523
+ // Retain the artifact/CLI and semantic tools regions separately, including
524
+ // their original case identities and deadlines. Neither claims a whole suite.
525
+ await addOriginalToolsArtifactPrograms({add,locators,text,file,sourceRoot});
526
+ if(stableFiles.has('tests/fixtures/unicode-case-profiles.json')){
527
+ const reference=await json('tests/fixtures/unicode-case-profiles.json');
528
+ if(reference.format!=='eliscript-unicode-case-reference'||!Array.isArray(reference.versions))throw new Error('unrepresented Unicode reference');
529
+ const source='(defconst marker 1) (defun upper (value) (js-call value :toUpperCase)) (defun lower (value) (js-call value :toLowerCase)) (export upper lower)';
530
+ for(const profile of reference.versions)add({id:'stable-compatibility:unicode-profile:'+profile.version,kind:'project',
531
+ coverage:['stable-compatibility:tests/fixtures/unicode-case-profiles.json'],entry:'entry.mjs',modules:[{id:'entry.mjs',filename:'text-format.eli',source}],
532
+ request:{operation:'project'},auto:1,execution:{kind:'unicode-profile',profile:structuredClone(profile)},expected:{kind:'unicode-profile'},
533
+ original:{fixture:'tests/fixtures/unicode-case-profiles.json',suite:'tests/wasm-managed-text-format.test.mjs'}});
534
+ }
535
+ const unadapted=originals.requiredCoverage.filter(id=>!claimed.has(id));
536
+ const missingCaseAdapters=[];
537
+ const originalGateCoverage=[],hostOnlyDependencies=[];
538
+ const semanticFeature=/^(?:language|portable|compiler|project|macro|bootstrap|stdlib|runtime)[.]/;
539
+ const byLocator=new Map(locators.map(item=>[item.id,item]));
540
+ for(const id of unadapted){
541
+ const locator=byLocator.get(id);
542
+ const originalFile=locator?.file??(id.startsWith('stable-compatibility:')?id.slice('stable-compatibility:'.length):null);
543
+ if(originalFile==='tests/fixtures/collection-adapter-isolation.mjs'){
544
+ const suite='tests/collection-protocol.test.mjs';
545
+ const title='native adapters are exact, realm-explicit, and prototype preserving';
546
+ const suiteSource=await text(suite),fixtureSource=await text(originalFile);
547
+ const prefix='test('+JSON.stringify(title)+', async () => {';
548
+ const region=originalRegion(suiteSource,prefix,'\ntest(');
549
+ for(const assertion of ['new URL("./fixtures/collection-adapter-isolation.mjs", import.meta.url)',
550
+ 'const bun = await runHost(process.execPath, fixture);','const node = await runHost("node", fixture);',
551
+ 'expect(bun).toEqual(node);','unchanged: [true, true, true]',
552
+ 'protocolSlotsAbsent: [true, true, true]'])
553
+ if(!region.text.includes(assertion))throw new TypeError('original collection isolation execution changed');
554
+ if(!fixtureSource.includes('"../../runtime/core/collection.mjs"')||
555
+ !fixtureSource.includes('"../../runtime/core/protocol.mjs"')||
556
+ /(?:bin\/eliscript|buildBackends|buildProject|checkProject|compile_ir_string|compile_string|\.eli["'`]|process\.argv|ELISCRIPT_.*(?:MODULE|COMPILER))/.test(fixtureSource))
557
+ throw new TypeError('collection isolation fixture requires a selected compiler adapter');
558
+ const {text:caseSource,...caseRegion}=region;
559
+ originalGateCoverage.push(id);
560
+ hostOnlyDependencies.push({coverageId:id,file:originalFile,
561
+ sourceSha256:(await file(originalFile)).sha256,kind:'host-only-runtime-case-fixture',
562
+ originalAssertion:title,engines:['bun','node'],
563
+ originalCase:{file:suite,sourceSha256:(await file(suite)).sha256,region:caseRegion},
564
+ dependencies:await Promise.all(['runtime/core/collection.mjs','runtime/core/protocol.mjs']
565
+ .map(async filename=>({file:filename,sourceSha256:(await file(filename)).sha256}))),
566
+ reason:'original Bun and Node fixture checks runtime protocol adapter isolation without a compiler or language-product injection'});
567
+ continue;
568
+ }
569
+ if(locator){
570
+ const bound=await originalToolsHostGateCase({locator,source:await text(locator.file),file});
571
+ if(bound){
572
+ originalGateCoverage.push(id);
573
+ hostOnlyDependencies.push({...bound,coverageId:id,file:locator.file,
574
+ sourceSha256:(await file(locator.file)).sha256,locator:structuredClone(locator)});
575
+ continue;
576
+ }
577
+ }
578
+ if(originalFile?.startsWith('tests/')&&(originalFile.endsWith('.mjs')||originalFile==='tests/fixtures/value-hashes.json')&&isOriginalRuntimeHostOnly(originalFile,await text(originalFile))){
579
+ originalGateCoverage.push(id);hostOnlyDependencies.push({coverageId:id,file:originalFile,sourceSha256:(await file(originalFile)).sha256,kind:'host-only-runtime',reason:'unchanged original host runtime; no selected compiler or language-product injection'});continue;
580
+ }
581
+ if(locator&&['tests/persistent-queue.test.mjs','tests/lazy-sequence.test.mjs','tests/persistent-sorted.test.mjs','tests/regex.test.mjs','tests/core-text-object.test.mjs','tests/core-set.test.mjs','tests/core-stdlib.test.mjs'].includes(locator.file)){
582
+ const originalSource=await text(locator.file);
583
+ const runtimeCase=originalRuntimeOnlyCase(locator.file,originalSource,locator.contains);
584
+ if(runtimeCase){
585
+ originalGateCoverage.push(id);
586
+ hostOnlyDependencies.push({coverageId:id,file:locator.file,sourceSha256:(await file(locator.file)).sha256,
587
+ kind:'host-only-runtime-case',region:runtimeCase,
588
+ reason:'unchanged original runtime-only case; the separate compiled-language case remains selected-session evidence'});
589
+ continue;
590
+ }
591
+ }
592
+ if(locator?.file==='tests/diagnostic-corpus.test.mjs'&&[
593
+ 'complete negative diagnostic corpus is frozen and source-derived',
594
+ 'diagnostic corpus rejects missing cases and fixture drift',
595
+ 'diagnostic corpus rejects structured and human diagnostic drift',
596
+ ].includes(locator.contains)){
597
+ const originalSource=await text(locator.file);
598
+ const prefix='test('+JSON.stringify(locator.contains)+', async () => {';
599
+ const start=originalSource.indexOf(prefix);
600
+ if(start<0||originalSource.indexOf(prefix,start+prefix.length)>=0)
601
+ throw new TypeError('original diagnostic manifest case boundary changed');
602
+ const next=originalSource.indexOf('\ntest(',start+prefix.length);
603
+ const end=next<0?originalSource.length:next;
604
+ const caseSource=originalSource.slice(start,end);
605
+ if(!caseSource.includes('checkDiagnosticCorpus(')&&!caseSource.includes('validationErrors('))
606
+ throw new TypeError('original diagnostic manifest case lost its validator');
607
+ const dependencies=[];
608
+ for(const filename of ['tools/diagnostics/check.mjs','contracts/diagnostic-corpus.json',
609
+ 'tests/fixtures/bootstrap-reader.json','tests/fixtures/bootstrap-expander.json','tests/fixtures/bootstrap-analyzer.json']){
610
+ dependencies.push({file:filename,sourceSha256:(await file(filename)).sha256});
611
+ }
612
+ originalGateCoverage.push(id);
613
+ hostOnlyDependencies.push({coverageId:id,file:locator.file,sourceSha256:(await file(locator.file)).sha256,
614
+ kind:'frozen-diagnostic-manifest-case',originalAssertion:locator.contains,locator:structuredClone(locator),dependencies,
615
+ region:{start,end,byteStart:Buffer.byteLength(originalSource.slice(0,start)),byteEnd:Buffer.byteLength(originalSource.slice(0,end)),sha256:digest(Buffer.from(caseSource))},
616
+ reason:'original validator checks frozen diagnostic inventory and mutation rejection; every compiler negative input remains an independent selected-session stage record'});
617
+ continue;
618
+ }
619
+ if(locator?.file==='tests/literal-runtime.test.mjs'&&
620
+ locator.contains==='maintained Eliscript sources use explicit host constructors'){
621
+ const originalSource=await text(locator.file);
622
+ const title='maintained Eliscript sources use explicit host constructors';
623
+ const prefix='test('+JSON.stringify(title)+', async () => {';
624
+ const start=originalSource.indexOf(prefix);
625
+ if(start<0||originalSource.indexOf(prefix,start+prefix.length)>=0)
626
+ throw new TypeError('original source-only audit case boundary changed');
627
+ const {text:caseSource,...caseRegion}=originalRegion(originalSource,prefix,'\ntest(',start);
628
+ if(!caseSource.includes('expect(violations).toEqual([]);'))
629
+ throw new TypeError('original source-only audit assertion changed');
630
+ originalGateCoverage.push(id);
631
+ hostOnlyDependencies.push({coverageId:id,file:locator.file,
632
+ sourceSha256:(await file(locator.file)).sha256,kind:'source-only-case',
633
+ originalAssertion:title,locator:structuredClone(locator),region:caseRegion,
634
+ reason:'unchanged original source constructor audit; all compiled-language cases retain selected-session execution'});
635
+ continue;
636
+ }
637
+ if(locator&&originalReportOnlyLocators.get(locator.file)===locator.contains){
638
+ // This exact locator hashes and validates the frozen report; it never
639
+ // invokes a selected compiler. Its unchanged original gate is required.
640
+ originalGateCoverage.push(id);continue;
641
+ }
642
+ if(locator&&locator.kind!=='ert'&&locator.kind!=='shell'&&(!locator.featureId||semanticFeature.test(locator.featureId))){
643
+ missingCaseAdapters.push({coverageId:id,file:locator.file,contains:locator.contains,featureId:locator.featureId,reason:'original semantic suite still needs its complete selected-session adapter'});
644
+ }else if(id.startsWith('stable-compatibility:tests/fixtures/')){
645
+ const filename=id.slice('stable-compatibility:'.length);
646
+ const transport=/\/(?:compiled-eli-(?:bun-preload|node-loader)|platform-capabilities|worker-value-stream-probe)[.]mjs$/.test(filename);
647
+ const auxiliary=filename.endsWith('.stdout')||filename.endsWith('.el')||filename.endsWith('/package.json')||filename.endsWith('/.gitkeep')||transport;
648
+ if(auxiliary)originalGateCoverage.push(id);
649
+ else missingCaseAdapters.push({coverageId:id,file:filename,reason:'original language fixture or host oracle has not yet been mapped to complete selected-session requests'});
650
+ }else originalGateCoverage.push(id);
651
+ }
652
+ // A suite locator is not exhausted merely because one of its subcases has
653
+ // been adapted. Keep the remaining assertions visible until its full recipe
654
+ // is implemented; auxiliary files themselves never become programs.
655
+ const partialSuites=new Set(records.filter(record=>record.kind==='sequence'&&record.original?.completeLocatorCoverage!==true).map(record=>record.original?.suite).filter(suite=>suite&&!fullyMappedSuites.has(suite)));
656
+ // A separate complete selected-compiler replay may cover the very same
657
+ // locator. A supplementary fragment must not turn that retained execution
658
+ // back into a missing adapter. Bind the exact locator and current suite
659
+ // revision; a fixture or another case in that file is insufficient.
660
+ const completeReplayCoverage=new Set();
661
+ for(const record of records){
662
+ if(record.kind==='project'&&record.execution?.kind==='compiler-session-program'&&
663
+ record.original?.completeLocatorCoverage===true&&
664
+ record.original.coverageScope==='complete-source-mapping-worker-case-only'){
665
+ const suite=record.original.suite,source=await text(suite);
666
+ if(record.original.sourceSha256===(await file(suite)).sha256){
667
+ const cases=originalSourceCaseLocators(suite,source);
668
+ for(const original of record.original.cases??[]){
669
+ const locator=byLocator.get(original.id);
670
+ const exact=cases.find(item=>item.originalCase.sha256===original.sha256&&
671
+ item.originalCase.span.start===original.span?.start&&item.originalCase.span.end===original.span?.end&&
672
+ item.originalCase.sourceSha256===original.sourceSha256&&item.originalCase.timeoutMs===original.timeoutMs);
673
+ if(locator?.file===suite&&typeof locator.contains==='string'&&locator.contains.length&&
674
+ record.coverage.includes(original.id)&&exact&&
675
+ source.slice(exact.originalCase.span.start,exact.originalCase.span.end).includes(locator.contains))
676
+ completeReplayCoverage.add(original.id);
677
+ }
678
+ }
679
+ }
680
+ if(record.kind!=='project'||record.execution?.kind!=='original-program'||
681
+ record.original?.semanticCoverage!=='complete-original-suite-with-selected-compiler-namespaces')continue;
682
+ const coverage=new Set(record.coverage);
683
+ for(const suite of record.original.suites??[]){
684
+ if(suite.sourceSha256!==(await file(suite.file)).sha256)continue;
685
+ for(const id of suite.coverage??[])if(coverage.has(id)&&byLocator.get(id)?.file===suite.file)
686
+ completeReplayCoverage.add(id);
687
+ }
688
+ }
689
+ for(const locator of locators)if(partialSuites.has(locator.file)&&locator.kind!=='ert'&&locator.kind!=='shell'&&!completeReplayCoverage.has(locator.id)&&!missingCaseAdapters.some(item=>item.coverageId===locator.id)){
690
+ missingCaseAdapters.push({coverageId:locator.id,file:locator.file,contains:locator.contains,featureId:locator.featureId,reason:'request recipes exist; remaining original suite assertions are not yet fully mapped'});
691
+ }
692
+ const originalGateEvidence={required:true,verification:'not-executed',execution:structuredClone(stable.document.execution),
693
+ coverageIds:originalGateCoverage,hostOnlyDependencies,locators,fixtures:[...stable.document.fixtureFiles],bootstrapSources:[...parity.document.bootstrapSources],
694
+ dimensions:parity.document.dimensions.map(item=>item.id)};
695
+ const evidence = sourceEvidence();
696
+ return {format: 'eliscript-compiler-matrix-corpus', version: 1,
697
+ manifests: Object.fromEntries(originals.manifests.map(item => [item.id, {sha256: item.sha256, identity: item.identity}])),
698
+ coverageIds: [...originals.requiredCoverage], expectedIds: records.map(record => record.id), records, evidence, originalGateEvidence, missingCaseAdapters};
699
+ }
700
+
701
+ export function compilerCorpusRequest(record, target, options = {}) {
702
+ if (record.kind === 'stage') return cloneCompilerCorpusData(record.request);
703
+ if (record.kind === 'original-suite' || record.kind === 'sequence') return null;
704
+ return {...record.request, operation: 'project', modules: cloneCompilerCorpusModules(record.modules), entry: record.entry, target,
705
+ memory: record.memory ?? options.memory, nativeTarget: record.nativeTarget ?? options.nativeTarget ?? (process.platform === 'linux' ? 'arm64-linux' : 'arm64-macos'),
706
+ nativeFormat: record.nativeFormat ?? options.nativeFormat ?? 'library'};
707
+ }
708
+
709
+ function addOriginalRequestRecipes({add, locators, irCases, portableSources}) {
710
+ const locatorIds = file => {
711
+ const ids = locators.filter(item => item.file === file).map(item => item.id);
712
+ if (!ids.length) throw new Error('original recipe has no retained suite locator: ' + file);
713
+ return ids;
714
+ };
715
+ const addSequence = (id, suite, steps) => add({id: 'original-sequence:' + id, kind: 'sequence',
716
+ coverage: locatorIds(suite), original: {suite}, steps, expected: {kind: 'sequence'}});
717
+ const project = (source, helper) => ({operation: 'project', resolveImports: true, sourceMap: true, entry: 'main.mjs', modules: [
718
+ {id: 'main.mjs', filename: 'main.eli', source},
719
+ ...(helper === undefined ? [] : [{id: 'helper.mjs', filename: 'helper.eli', source: helper}]),
720
+ ]});
721
+ const diskSource = '(import "./helper.eli" answer)\n(print answer)\n';
722
+ const virtualSource = '(import "./helper.eli" answer)\n(print (+ answer 1))\n';
723
+ const helper = '(defconst answer 42)\n(export answer)\n';
724
+ addSequence('project-source-edits', 'tests/bootstrap-project.test.mjs', [
725
+ {id: 'initial', request: project(diskSource, helper), artifact: {kind: 'stdout', expected: '42\n'}},
726
+ {id: 'identical', request: project(diskSource, helper), artifact: {kind: 'stdout', expected: '42\n'}, sameProductAs: 'initial'},
727
+ {id: 'override', request: project(virtualSource, helper), artifact: {kind: 'stdout', expected: '43\n'}},
728
+ {id: 'restore-disk', request: project(diskSource, helper), artifact: {kind: 'stdout', expected: '42\n'}, sameProductAs: 'initial'},
729
+ {id: 'invalid-edit', request: project('(print missing)\n', helper), error: {code: 'ELI-A0001', phase: 'analysis'}},
730
+ {id: 'after-failed-edit', request: project(diskSource, helper), artifact: {kind: 'stdout', expected: '42\n'}, sameProductAs: 'initial'},
731
+ ]);
732
+ const macro = '(defmacro configured-value ()\n (macro-read-file "build-value.txt"))\n(defconst value (configured-value))\n(export value)';
733
+ const macroProject = value => ({...project(macro), macroContext: {capabilities: ['read-file'], files: [
734
+ {specifier: 'unused.txt', content: 'declared-but-unused'}, {specifier: 'build-value.txt', content: value},
735
+ ]}});
736
+ addSequence('macro-file-edits', 'tests/macro-file-dependencies.test.mjs', [
737
+ {id: 'initial', request: macroProject('first-value'), artifact: {kind: 'exports', values: {value: 'first-value'}}},
738
+ {id: 'cache-hit', request: macroProject('first-value'), artifact: {kind: 'exports', values: {value: 'first-value'}}, sameProductAs: 'initial'},
739
+ {id: 'changed-file', request: macroProject('second-value'), artifact: {kind: 'exports', values: {value: 'second-value'}}},
740
+ {id: 'no-capability', request: {operation: 'stage', stage: 'ir', source: macro, filename: 'macro-context.eli'},
741
+ error: {contains: 'macro capability is not enabled: read-file'}},
742
+ {id: 'undeclared-file', request: {operation: 'stage', stage: 'ir', source: macro, filename: 'macro-context.eli', macroContext: {capabilities: ['read-file'], files: []}},
743
+ error: {contains: 'macro file dependency is not declared: build-value.txt'}},
744
+ {id: 'direct-context', request: {operation: 'stage', stage: 'emitter', source: macro, filename: 'macro-context.eli',
745
+ macroContext: {capabilities: ['read-file'], files: [{specifier: 'build-value.txt', content: 'forty-two'}]}}, containsData: 'const value = "forty-two";'},
746
+ ]);
747
+ const provider = [
748
+ 'globalThis.__eliscript_import_effects =', ' (globalThis.__eliscript_import_effects ?? 0) + 1;',
749
+ 'export default 11;', 'export const named_value = 22;', 'export const namespace_value = 33;',
750
+ 'export const effect_count = () => globalThis.__eliscript_import_effects;', '',
751
+ ].join('\n');
752
+ const imports = [
753
+ '(import "./provider.mjs")', '(import "./provider.mjs" :default default-value effect-count named-value)',
754
+ '(import "./provider.mjs" :default namespace-default :as Provider)', '(defun report ()',
755
+ ' (js-array default-value', ' named-value', ' namespace-default',
756
+ ' (get Provider "namespace_value")', ' (effect-count)))', '(export report)', '',
757
+ ].join('\n');
758
+ addSequence('esm-imports', 'tests/esm-imports.test.mjs', [{id: 'imports', request: {...project(imports), resolveImports: false,
759
+ hostModules:[{id:'provider.mjs',specifier:'./provider.mjs',referrer:'main.mjs',allowedExports:['default','effect_count','named_value'],namespace:true}],
760
+ hostSources:[{id:'provider.mjs',filename:'provider.mjs',source:provider}]},
761
+ sidecars: [{file: 'provider.mjs', source: provider}], artifact: {kind: 'exports', isolated: true, calls: [{name: 'report', args: [], expected: [11, 22, 11, 33, 1]}]}}]);
762
+ const protocolCases = [
763
+ ['single-defaults', 'build-operation-request', {mode: 'single', input: 'src/defaults.eli'},
764
+ {format: 'eliscript-build-operation', version: 1, mode: 'single', input: 'src/defaults.eli', output: null, sourceMap: false, portableEntries: []}],
765
+ ['single-portable-order', 'build-operation-request', {mode: 'single', input: 'src/main.eli', output: null, sourceMap: false, portableEntries: ['zeta', 'alpha', 'zeta']},
766
+ {format: 'eliscript-build-operation', version: 1, mode: 'single', input: 'src/main.eli', output: null, sourceMap: false, portableEntries: ['alpha', 'zeta']}],
767
+ ['project-request', 'project-request', {entry: 'src/main.eli', outDir: 'dist', root: null, portableEntries: ['zeta', 'alpha', 'zeta'], useCache: true},
768
+ {format: 'eliscript-project-request', version: 1, entry: 'src/main.eli', outDir: 'dist', root: null,
769
+ portableEntries: ['alpha', 'zeta'], macroCapabilities: [], macroFileDependencies: [], useCache: true}],
770
+ ['check-report', 'project-check-report', {mode: 'standard', root: 'root', entries: ['src/z.eli', 'src/a.eli'], portableEntries: [], modules: [
771
+ {source: 'src/z.eli', dependencies: [], portableEntries: []}, {source: 'src/a.eli', dependencies: ['src/z.eli'], portableEntries: []}]},
772
+ {format: 'eliscript-check-report', version: 1, status: 'ok', mode: 'standard', root: 'root', entries: ['src/a.eli', 'src/z.eli'], portableEntries: [], counts: {modules: 2}, modules: [
773
+ {source: 'src/a.eli', dependencies: ['src/z.eli'], portableEntries: []}, {source: 'src/z.eli', dependencies: [], portableEntries: []}]}],
774
+ ];
775
+ addSequence('project-protocols', 'tests/bootstrap-project.test.mjs', protocolCases.map(([id, name, input, expected]) =>
776
+ ({id, request: {operation: 'protocol', name, input}, expected})));
777
+ const portableSource='(defconst step 2)\n(defportable helper (value) (* value step))\n(defportable work (value) (helper value))\n(defportable unused () 99)\n(defun ordinary () 1)';
778
+ addSequence('portable-transitive-closure','tests/eliscript-tests.el',[
779
+ {id:'selection',request:{operation:'stage',stage:'portable',source:portableSource,filename:'portable.eli',entries:['work'],allowProjectImports:false}},
780
+ {id:'emission',request:{operation:'compile',source:portableSource,filename:'portable.eli',portableEntries:['work']},
781
+ includesJavascript:['const step = 2;','function helper(value)','function work(value)'],excludesJavascript:['function unused','function ordinary']},
782
+ {id:'import-requires-project',request:{operation:'stage',stage:'portable',source:'(import-portable "./math.eli" increment)\n(defportable work (value) (increment value))',filename:'portable.eli',entries:['work'],allowProjectImports:false},
783
+ error:{contains:'portable import increment requires a project build'}},
784
+ ...Object.entries(portableSources).map(([name,source])=>({id:'stdlib-'+name,request:{operation:'compile',source,filename:'stdlib/'+name+'.eli',portableEntries:[{sequence:'map',text:'blank?',object:'omit'}[name]]},
785
+ includesJavascript:{sequence:['function reverse(values)','function map(function$, values)'],text:['function slice(start, end, text)','function whitespace','function trim(text)','function blank'],object:['function keys(object)','function key_in_QMARK_','function omit(object, omitted_keys)']}[name],
786
+ excludesJavascript:{sequence:['function filter','function range'],text:['function join','function repeat'],object:['function map_values','function update']}[name]})),
787
+ ]);
788
+ const cacheModules=[{source:'src/main.eli',output:'src/main.mjs',sourceMap:'src/main.mjs.map',sourceDigest:'source',outputDigest:'output',sourceMapDigest:'map'}];
789
+ const metadataModules=[{source:'src/main.eli',dependencies:[],portableEntries:[]}];
790
+ const cacheLookupInput={enabled:true,manifestStatus:'readable',expectedEntry:'src/main.mjs',graphDigestValid:true,cacheDigestValid:true,compilerDigest:'compiler',mode:'standard',portableEntries:[]};
791
+ const cacheManifest=version=>({format:'eliscript-project',version:1,entry:'src/main.mjs',digest:'manifest',modules:cacheModules,cache:{
792
+ ...(version===2?{format:'eliscript-project-cache'}:{}),version,compilerDigest:'compiler',mode:'standard',portableEntries:[],modules:metadataModules}});
793
+ const reportInput={mode:'standard',root:'root',outDir:'root/dist',entry:'src/main.eli',entryOutput:'src/main.mjs',manifest:'eliscript-project.json',digest:'abc123',portableEntries:[],
794
+ cache:{enabled:true,reason:'verified'},timings:{cacheReadMs:0.1236,workMs:1.2344,manifestWriteMs:0.3456,totalMs:1.7036},modules:[
795
+ {source:'src/value.eli',output:'src/value.mjs',sourceMap:'src/value.mjs.map',status:'compiled',reason:'source-changed',dependencies:[],portableEntries:[]},
796
+ {source:'src/main.eli',output:'src/main.mjs',sourceMap:'src/main.mjs.map',status:'reused',reason:'verified',dependencies:['src/value.eli','src/value.eli'],portableEntries:[]}]};
797
+ addSequence('project-cache-reports','tests/bootstrap-project.test.mjs',[
798
+ {id:'current-cache',request:{operation:'protocol',name:'project-cache-lookup',input:{...cacheLookupInput,manifest:cacheManifest(2)}},expectFields:[
799
+ {path:['reason'],value:'verified'},{path:['cache','sourceVersion'],value:2}]},
800
+ {id:'legacy-cache',request:{operation:'protocol',name:'project-cache-lookup',input:{...cacheLookupInput,manifest:cacheManifest(1)}},expectFields:[
801
+ {path:['reason'],value:'verified'},{path:['cache','sourceVersion'],value:1}]},
802
+ {id:'unreadable-artifact',request:{operation:'protocol',name:'project-cache-decision',input:{record:{$compilerCorpusRef:'current-cache.cache.records.0'},output:'src/main.mjs',sourceMap:'src/main.mjs.map',
803
+ expectedPortableEntries:[],sourceDigest:'changed',outputExists:true,sourceMapExists:true,outputDigest:'output',sourceMapDigest:'map',dependenciesValid:true,artifactFailure:'artifact-unreadable'}},
804
+ expected:{reused:false,reason:'artifact-unreadable'}},
805
+ {id:'report',request:{operation:'protocol',name:'project-build-report',input:reportInput},expectFields:[
806
+ {path:['cache'],value:{enabled:true,status:'partial',reason:'dirty-modules'}},{path:['counts'],value:{modules:2,compiled:1,reused:1}},
807
+ {path:['timings'],value:{cacheReadMs:0.124,workMs:1.234,manifestWriteMs:0.346,totalMs:1.704}},
808
+ {path:['modules',0,'source'],value:'src/main.eli'},{path:['modules',0,'dependencies'],value:['src/value.eli']},{path:['modules',1,'source'],value:'src/value.eli'}]},
809
+ {id:'bad-report',request:{operation:'protocol',name:'project-build-report',input:{...reportInput,cache:{enabled:'yes',reason:'verified'}}},error:{contains:'build report cache enabled must be a boolean'}},
810
+ {id:'empty-entries',request:{operation:'protocol',name:'project-request',input:{entries:[],outDir:'dist',root:'root',portableEntries:[],useCache:true}},error:{code:'ELI-B0001',phase:'project-build'}},
811
+ {id:'invalid-portable-entry',request:{operation:'protocol',name:'project-request',input:{entry:'main.eli',outDir:'dist',root:null,portableEntries:[42],useCache:true}},error:{code:'ELI-B0001',phase:'project-build'}},
812
+ {id:'missing-source-map-output',request:{operation:'protocol',name:'build-operation-request',input:{mode:'single',input:'main.eli',output:null,sourceMap:true,portableEntries:[]}},error:{code:'ELI-B0001',phase:'project-build'}},
813
+ {id:'graph',request:{operation:'protocol',name:'project-plan',input:{entries:['b','a','a'],dependencies:{a:['b'],b:['a']}}},expected:{
814
+ format:'eliscript-project-plan',version:1,mode:'standard',entries:['a','b'],modules:[{id:'a',dependencies:['b']},{id:'b',dependencies:['a']}]}},
815
+ {id:'portable-graph',request:{operation:'protocol',name:'portable-project-plan',input:{entries:[{id:'a',entries:['x']}],resolutions:[
816
+ {id:'a',includes:'z',dependencies:[{id:'c',entries:['q']}]},{id:'a',dependencies:[{id:'b',entries:['y']}]},{id:'b',dependencies:[{id:'a',entries:['z']}]}]}},expectFields:[
817
+ {path:['calls'],value:[{id:'a',entries:['x']},{id:'b',entries:['y']},{id:'a',entries:['x','z']},{id:'c',entries:['q']}]},
818
+ {path:['plan','modules',0,'entries'],value:['x','z']},{path:['plan','modules',0,'dependencies'],value:[{id:'b',entries:['y']},{id:'c',entries:['q']}]}]},
819
+ ]);
820
+ const configuration={schemaVersion:1,entry:'src/main.eli',outDir:'dist'};
821
+ const configurationRequest=input=>({operation:'protocol',name:'project-configuration',input,filename:'eliscript.json'});
822
+ const invalidConfigurations=[
823
+ {...configuration,undeclared:true}, {...configuration,entry:'../main.eli'}, {...configuration,cache:'yes'},
824
+ {schemaVersion:2,entries:[],outDir:'dist'}, {...configuration,macroCapabilities:['network']},
825
+ {...configuration,macroFileDependencies:['build.txt']}, {...configuration,macroCapabilities:['read-file'],macroFileDependencies:['../build.txt']},
826
+ ];
827
+ addSequence('project-configuration','tests/bootstrap-project.test.mjs',[
828
+ {id:'defaults',request:configurationRequest(configuration),expected:{format:'eliscript-project-request',version:1,sourceRoot:'.',entry:'src/main.eli',outDir:'dist',portableEntries:[],macroCapabilities:[],macroFileDependencies:[],cache:true}},
829
+ {id:'multiple-entries',request:configurationRequest({schemaVersion:2,sourceRoot:'src',entries:['z.eli','a.eli'],outDir:'dist'}),expected:{format:'eliscript-project-request',version:2,sourceRoot:'src',entries:['a.eli','z.eli'],outDir:'dist',portableEntries:[],macroCapabilities:[],macroFileDependencies:[],cache:true}},
830
+ {id:'macro-files',request:configurationRequest({schemaVersion:1,sourceRoot:'src',entry:'main.eli',outDir:'dist',macroCapabilities:['read-file'],macroFileDependencies:['z.txt','a.txt']}),expectFields:[
831
+ {path:['macroCapabilities'],value:['read-file']},{path:['macroFileDependencies'],value:['a.txt','z.txt']}]},
832
+ ...invalidConfigurations.map((input,index)=>({id:'invalid-'+index,request:configurationRequest(input),error:{code:'ELI-B0002',phase:'project-config'}})),
833
+ ]);
834
+ const evaluationSuite='tests/bootstrap-evaluation.test.mjs';
835
+ if(locators.some(item=>item.file===evaluationSuite))addSequence('evaluation-descriptions',evaluationSuite,[
836
+ {id:'operation',request:{operation:'protocol',name:'evaluation-operation-request',input:{id:7,operation:'evaluate',source:'(+ 1 2)',filename:'repl.eli'}},expected:{format:'eliscript-evaluation-operation',version:1,id:7,operation:'evaluate',source:'(+ 1 2)',filename:'repl.eli',root:null,line:1,column:1}},
837
+ {id:'reset-source-refusal',request:{operation:'protocol',name:'evaluation-operation-request',input:{operation:'reset',source:'(+ 1 2)'}},error:{contains:'reset evaluation operation does not accept source fields'}},
838
+ {id:'unknown-option',request:{operation:'protocol',name:'evaluation-operation-request',input:{operation:'describe',framework:'anything'}},error:{contains:'unknown evaluation operation key: framework'}},
839
+ {id:'incomplete',request:{operation:'protocol',name:'evaluation-input-description',source:'(+ 1',filename:'repl.eli'},expected:{format:'eliscript-evaluation-input',version:1,status:'incomplete',filename:'repl.eli'}},
840
+ {id:'function',request:{operation:'protocol',name:'evaluation-form-description',source:'(defun value () 42)',filename:'repl.eli'},expected:{format:'eliscript-evaluation-form',version:1,kind:'definition',head:'defun',name:'value',runtimeBinding:true,filename:'repl.eli'}},
841
+ {id:'macro',request:{operation:'protocol',name:'evaluation-form-description',source:'(defmacro twice (value) `(+ ,value ,value))',filename:'repl.eli'},expectFields:[{path:['runtimeBinding'],value:false}]},
842
+ {id:'method',request:{operation:'protocol',name:'evaluation-form-description',source:'(defmethod render :text (value) value)',filename:'repl.eli'},expectFields:[{path:['kind'],value:'expression'}]},
843
+ {id:'protocol',request:{operation:'protocol',name:'evaluation-form-description',source:'(defprotocol IDescribe describe)',filename:'repl.eli'},expectFields:[{path:['kind'],value:'definition'},{path:['name'],value:'IDescribe'},{path:['runtimeBinding'],value:true}]},
844
+ ...['(extend-type Box IDescribe (describe (value) value))','(extend-category "number" IDescribe (describe (value) value))','(extend-default IDescribe (describe (value) value))','(jsx 1)','(fragment 1)','(defcomponent 1)'].map((source,index)=>({id:'expression-'+index,request:{operation:'protocol',name:'evaluation-form-description',source,filename:'repl.eli'},expectFields:[{path:['kind'],value:'expression'}]})),
845
+ {id:'import',request:{operation:'protocol',name:'evaluation-form-description',source:'(import "./value.mjs" value)',filename:'repl.eli'},expectFields:[{path:['kind'],value:'module'}]},
846
+ ]);
847
+ const ref = path => ({$compilerCorpusRef: path});
848
+ const schemaError = contains => ({contains, code: 'ELI-I0001', phase: 'ir-schema'});
849
+ for(let index=0;index<irCases.length;index++){
850
+ const input=irCases[index];
851
+ addSequence('canonical-ir-roundtrip-'+index,'tests/bootstrap-ir-serialization.test.mjs',[
852
+ {id:'program',request:{operation:'compile-ir',source:input.source,filename:input.filename}},
853
+ {id:'canonical',request:{operation:'serialize-ir',ir:ref('program.ir')},canonicalEnvelope:true},
854
+ {id:'roundtrip',request:{operation:'deserialize-ir',canonicalIR:ref('canonical.canonicalIR')},sameFieldsAs:{step:'program',fields:['ir']}},
855
+ {id:'reserialize',request:{operation:'serialize-ir',ir:ref('roundtrip.ir')},sameFieldsAs:{step:'canonical',fields:['canonicalIR']}},
856
+ ]);
857
+ }
858
+ addSequence('canonical-ir-refusals', 'tests/bootstrap-ir-serialization.test.mjs', [
859
+ {id: 'duplicate-fields', request: {operation: 'deserialize-ir', canonicalIR: '{"format":"eliscript-ir","format":"eliscript-ir","program":{"body":[],"filename":"x.eli"},"version":1}'}, error: schemaError('not canonical')},
860
+ {id: 'invalid-json', request: {operation: 'deserialize-ir', canonicalIR: '{'}, error: schemaError('invalid canonical IR JSON')},
861
+ {id: 'wrong-input-type', request: {operation: 'protocol', name: 'deserialize-ir', input: {text: 42}}, error: schemaError('must be a string')},
862
+ {id: 'program', request: {operation: 'compile-ir', source: irCases[0].source, filename: irCases[0].filename}},
863
+ {id: 'canonical', request: {operation: 'serialize-ir', ir: ref('program.ir')}, canonicalEnvelope: true},
864
+ {id: 'roundtrip', request: {operation: 'deserialize-ir', canonicalIR: ref('canonical.canonicalIR')}, sameFieldsAs: {step: 'program', fields: ['ir']}},
865
+ {id: 'reserialize', request: {operation: 'serialize-ir', ir: ref('roundtrip.ir')}, sameFieldsAs: {step: 'canonical', fields: ['canonicalIR']}},
866
+ {id: 'leading-space', request: {operation: 'deserialize-ir', canonicalIR: {$compilerCorpusConcat: [' ', ref('canonical.canonicalIR')]}}, error: schemaError('not canonical')},
867
+ {id: 'future-version', request: {operation: 'deserialize-ir', canonicalIR: {$compilerCorpusReplace: [ref('canonical.canonicalIR'), '"version":1}', '"version":2}']}}, error: schemaError('unsupported IR version')},
868
+ {id:'extra-field',request:{operation:'deserialize-ir',canonicalIR:{$compilerCorpusJsonPatch:[ref('canonical.canonicalIR'),[{path:['extra'],value:true}]]}},error:schemaError('unknown or missing fields')},
869
+ {id:'unknown-kind',request:{operation:'serialize-ir',ir:{$compilerCorpusJsonPatch:[ref('program.ir'),[{path:['body',0,'kind'],value:'future-node'}]]}},error:schemaError('unknown Eliscript IR node kind')},
870
+ {id:'bad-span',request:{operation:'serialize-ir',ir:{$compilerCorpusJsonPatch:[ref('program.ir'),[{path:['body',0,'span','start'],value:-1}]]}},error:schemaError('must be a non-negative integer')},
871
+ {id:'null-child',request:{operation:'serialize-ir',ir:{$compilerCorpusJsonPatch:[ref('program.ir'),[{path:['body',0,'children'],append:null}]]}},error:schemaError('plain data object')},
872
+ {id:'negative-zero',request:{operation:'serialize-ir',ir:{$compilerCorpusJsonPatch:[ref('program.ir'),[{path:['body',0,'value'],negativeZero:true}]]}},containsField:{field:'canonicalIR',text:'"value":-0'}},
873
+ {id:'negative-zero-read',request:{operation:'deserialize-ir',canonicalIR:ref('negative-zero.canonicalIR')},negativeZeroAt:['body',0,'value']},
874
+ ]);
875
+ }
876
+
877
+ async function addOriginalFormatterRecipes({add,locators,text,file,sourceRoot}) {
878
+ const suite='tests/bootstrap-formatter.test.mjs',suiteLocators=locators.filter(item=>item.file===suite);
879
+ if(!suiteLocators.length)return;
880
+ const original=await text(suite),trailing=originalRegion(original,' const trailing = ',';\n');
881
+ const bindings=new Map([['trailing',originalDataLiteral(trailing.text.slice(' const trailing = '.length))]]);
882
+ const input=originalTemplate(original,' const source = `',bindings),expected=originalTemplate(original,' const expected = `');
883
+ const semantic=originalTemplate(original,' const semanticSource = `');
884
+ const origin={suite,sourceSha256:(await file(suite)).sha256,regions:[trailing,input,expected,semantic].map(({start,end,byteStart,byteEnd,sha256})=>({start,end,byteStart,byteEnd,sha256}))};
885
+ const refs=path=>({$compilerCorpusRef:path});
886
+ const append=(id,steps)=>add({id:'original-sequence:formatter-'+id,kind:'sequence',coverage:suiteLocators.map(item=>item.id),
887
+ original:structuredClone(origin),expected:{kind:'sequence'},steps});
888
+ const modules=[];
889
+ for(const name of ['formatter','reader','syntax'])modules.push({id:'bootstrap/compiler/'+name+'.mjs',filename:'bootstrap/compiler/'+name+'.eli',source:await text('bootstrap/compiler/'+name+'.eli')});
890
+ const bridge='(import "./bootstrap/compiler/formatter.mjs" formatter-format formatter-version formatter-width formatter-indent format-source)\n'+
891
+ '(defconst formatName formatter-format) (defconst formatVersion formatter-version) (defconst formatWidth formatter-width) (defconst formatIndent formatter-indent)\n'+
892
+ '(defun format-source-for-host (source filename) (format-source source filename))\n'+
893
+ '(defun diagnostic-report (source mode) (try (format-source source "broken.eli") (catch error (let ((d (get error :eliscriptDiagnostic))) '+
894
+ '(if (= mode 0) (js-array (get d :format) (get d :version) (get d :code) (get d :phase) (get (get d :location) :file)) '+
895
+ '(js-array (get d :code) (get d :phase) (get d :message)))))))\n'+
896
+ '(export formatName formatVersion formatWidth formatIndent format-source-for-host diagnostic-report)';
897
+ const project={operation:'project',resolveImports:true,entry:'entry.mjs',modules:[{id:'entry.mjs',filename:'formatter-original-oracle.eli',source:bridge},...modules]};
898
+ append('metadata-and-errors',[{id:'original-exports',request:project,artifact:{kind:'exports',isolated:true,
899
+ values:{formatName:'eliscript-formatter',formatVersion:1,formatWidth:88,formatIndent:2},calls:[
900
+ {name:'diagnostic-report',javascriptName:'diagnostic_report',args:['(module broken',0],expected:['eliscript-diagnostic',1,'ELI-R0001','reader','broken.eli']},
901
+ {name:'diagnostic-report',javascriptName:'diagnostic_report',args:[42,1],expected:['ELI-F0001','formatter','formatter source must be a string']},
902
+ {name:'format-source-for-host',javascriptName:'format_source_for_host',args:[input.code,'node.eli'],expected:expected.code},
903
+ ]}}]);
904
+ add({id:'original-program:formatter-node',kind:'project',coverage:suiteLocators.map(item=>item.id),
905
+ modules,entry:'bootstrap/compiler/formatter.mjs',request:{operation:'project',resolveImports:true},
906
+ execution:{kind:'original-program',host:null,hostSource:null,environment:'COMPILER_URL',aliases:true,
907
+ hostEval:'import {pathToFileURL} from "node:url";\n'+
908
+ 'const c = await import(pathToFileURL(process.env.COMPILER_URL).href); '+
909
+ 'process.stdout.write(c.format_source('+JSON.stringify(input.code)+", 'node.eli'));"},
910
+ expected:{kind:'seed-program',oracleRequired:true,stdout:expected.code},
911
+ original:{...structuredClone(origin),fixture:'bootstrap/compiler/formatter.eli',host:suite}});
912
+ append('concrete-syntax',[
913
+ {id:'canonical',request:{operation:'format',source:input.code,filename:'formatter-case.eli'},expected:{source:expected.code}},
914
+ {id:'idempotent',request:{operation:'format',source:refs('canonical.source'),filename:'formatter-case.eli'},sameFieldsAs:{step:'canonical',fields:['source']}},
915
+ ]);
916
+ const sources=[];
917
+ async function visit(directory){for(const entry of await readdir(sourcePath(sourceRoot,directory),{withFileTypes:true})){
918
+ const name=directory+'/'+entry.name;if(entry.isDirectory())await visit(name);else if(entry.isFile()&&name.endsWith('.eli'))sources.push(name);
919
+ }}
920
+ await visit('bootstrap/compiler');await visit('stdlib');sources.sort();
921
+ if(sources.length<40)throw new Error('original formatter source corpus has fewer than forty programs');
922
+ for(const [index,filename]of ['formatter-semantic.eli',...sources].entries()){
923
+ const source=index===0?semantic.code:await text(filename);
924
+ append('semantic-'+index,[
925
+ {id:'canonical',request:{operation:'format',source,filename}},
926
+ {id:'idempotent',request:{operation:'format',source:refs('canonical.source'),filename},sameFieldsAs:{step:'canonical',fields:['source']}},
927
+ {id:'original-js',request:{operation:'compile',source,filename}},
928
+ {id:'formatted-js',request:{operation:'compile',source:refs('canonical.source'),filename},sameFieldsAs:{step:'original-js',fields:['javascript']}},
929
+ ]);
930
+ }
931
+ // Every original assertion in this suite now has an executable recipe.
932
+ // Actual acceptance still requires all of these records on the selected cell.
933
+ return suite;
934
+ }
935
+
936
+ async function addOriginalGeneratedNamesRecipes({add,locators,text,file}) {
937
+ const suite='tests/macro-generated-names.test.mjs',coverage=locators.filter(item=>item.file===suite).map(item=>item.id);
938
+ if(!coverage.length)return;
939
+ const original=await text(suite),input=originalTemplate(original,'const source = `');
940
+ const bun=originalRegion(original,' const module = await import(', '\n const nodeCheck = [');
941
+ const node=originalInlineArray(original,' const nodeCheck = [\n',' ].join("");',new Set([
942
+ '`import(${JSON.stringify(pathToFileURL(outputPath).href)})`,',
943
+ ]),'');
944
+ const origin={suite,fixture:suite,host:suite,sourceSha256:(await file(suite)).sha256,
945
+ regions:[input,bun,node].map(({start,end,byteStart,byteEnd,sha256})=>({start,end,byteStart,byteEnd,sha256}))};
946
+ const modules=[{id:'generated-names.mjs',filename:'generated-names.eli',source:input.code}];
947
+ for(const host of ['bun','node']){
948
+ const hostSource='import {pathToFileURL} from "node:url";\n'+(host==='bun'
949
+ ?'import {expect} from "bun:test";\nconst outputPath=process.argv[2];\n'+bun.text
950
+ :'import(pathToFileURL(process.argv[2]).href)'+node.code+';\n');
951
+ add({id:'original-program:macro-generated-names-'+host,kind:'project',coverage,
952
+ modules:cloneCompilerCorpusModules(modules),entry:'generated-names.mjs',request:{operation:'project',sourceMap:true},
953
+ execution:{kind:'original-program',host:'tests/__eliscript_original_generated_names_'+host+'.mjs',hostSource,
954
+ argument:'path',argumentModules:['generated-names.mjs'],aliases:true,requiresBun:host==='bun',hostRuntime:host},
955
+ expected:{kind:'seed-program',oracleRequired:true,stdout:''},original:structuredClone(origin)});
956
+ }
957
+ // The original macro suite compares the entire emitted JavaScript and map
958
+ // against the independent Emacs Seed, in addition to executing both hosts.
959
+ add({id:'original-stage:macro-generated-names-emitter',kind:'stage',coverage,
960
+ request:{operation:'stage',stage:'emitter',source:input.code,filename:'generated-names.eli',
961
+ sourceMap:{generatedFile:'fixture.mjs',sourceName:'generated-names.eli'}},
962
+ expected:{kind:'stage',oracleRequired:true},
963
+ original:{...structuredClone(origin),manifest:'stable-compatibility',
964
+ oracleCase:{name:'macro-generated-names',source:input.code,filename:'generated-names.eli'}}});
965
+ const includes=[],excludes=[];
966
+ const assertion=/expect\(seedJavaScript\)(\.not)?\.toContain\(\s*((?:"(?:\\.|[^"\\])*"|'[^'\\]*'))\s*,?\s*\)/g;
967
+ for(const match of original.matchAll(assertion)){
968
+ const value=match[2][0]==="'"?match[2].slice(1,-1):originalDataLiteral(match[2]);
969
+ (match[1]?excludes:includes).push(value);
970
+ }
971
+ if(includes.length!==3||excludes.length!==1)throw new Error('original generated-name emission assertion inventory changed');
972
+ add({id:'original-sequence:macro-generated-name-emission',kind:'sequence',coverage,original:structuredClone(origin),expected:{kind:'sequence'},steps:[
973
+ {id:'first',request:{operation:'compile',source:input.code,filename:'generated-names.eli',sourceMap:{generatedFile:'generated-names.mjs',sourceName:'generated-names.eli'}},
974
+ includesJavascript:includes,excludesJavascript:excludes},
975
+ {id:'repeat',request:{operation:'compile',source:input.code,filename:'generated-names.eli',sourceMap:{generatedFile:'generated-names.mjs',sourceName:'generated-names.eli'}},sameFieldsAs:{step:'first',fields:['javascript','sourceMap']}},
976
+ ]});
977
+ return suite;
978
+ }
979
+
980
+ async function addOriginalESMRecipes({add,locators,text,file}) {
981
+ const suite='tests/esm-imports.test.mjs',coverage=locators.filter(item=>item.file===suite).map(item=>item.id);
982
+ if(!coverage.length)return;
983
+ const original=await text(suite),provider=originalInlineArray(original,' const provider = [\n',' ].join("\\n");',new Set(),'\n');
984
+ const input=originalInlineArray(original,' const source = [\n',' ].join("\\n");',new Set(),'\n');
985
+ const expectedRegion=originalRegion(original,' const expected = ',';\n');
986
+ const expected=originalDataLiteral(expectedRegion.text.slice(' const expected = '.length));
987
+ if(!Array.isArray(expected))throw new TypeError('original ESM expected result changed');
988
+ const origin={suite,fixture:suite,host:suite,sourceSha256:(await file(suite)).sha256,
989
+ regions:[provider,input,expectedRegion].map(({start,end,byteStart,byteEnd,sha256})=>({start,end,byteStart,byteEnd,sha256}))};
990
+ const includes=[];
991
+ for(const match of original.matchAll(/expect\(seedJavaScript\)\.toContain\(\s*'([^'\\]*)'\s*,?\s*\)/g))includes.push(match[1]);
992
+ if(includes.length!==3)throw new TypeError('original ESM emission assertion inventory changed');
993
+ add({id:'original-stage:esm-imports-emitter',kind:'stage',coverage,
994
+ request:{operation:'stage',stage:'emitter',source:input.code,filename:'imports.eli',sourceMap:{generatedFile:'fixture.mjs',sourceName:'imports.eli'}},
995
+ expected:{kind:'stage',oracleRequired:true},original:{...structuredClone(origin),manifest:'stable-compatibility',
996
+ oracleCase:{name:'esm-imports',source:input.code,filename:'imports.eli'}}});
997
+ add({id:'original-sequence:esm-imports-emission',kind:'sequence',coverage,original:structuredClone(origin),expected:{kind:'sequence'},steps:[
998
+ {id:'emission',request:{operation:'compile',source:input.code,filename:'imports.eli'},includesJavascript:includes},
999
+ ]});
1000
+ for(const host of ['bun','node'])add({id:'original-program:esm-imports-'+host,kind:'project',coverage,
1001
+ modules:[{id:'imports.mjs',filename:'imports.eli',source:input.code}],entry:'imports.mjs',
1002
+ request:{operation:'project',resolveImports:false,sourceMap:true,
1003
+ hostModules:[{id:'provider.mjs',specifier:'./provider.mjs',referrer:'imports.mjs',allowedExports:['default','effect_count','named_value'],namespace:true}],
1004
+ hostSources:[{id:'provider.mjs',filename:'provider.mjs',source:provider.code}]},
1005
+ execution:{kind:'original-program',host:'tests/__eliscript_original_esm_'+host+'.mjs',
1006
+ hostSource:'import {pathToFileURL} from "node:url";\nconst module = await import(pathToFileURL(process.argv[2]).href);\nconsole.log(JSON.stringify(module.report()));\n',
1007
+ argument:'path',argumentModules:['imports.mjs'],aliases:true,requiresBun:host==='bun',hostRuntime:host},
1008
+ expected:{kind:'seed-program',oracleRequired:true,stdout:JSON.stringify(expected)+'\n'},original:structuredClone(origin)});
1009
+ return suite;
1010
+ }
1011
+
1012
+ // These hosts retain the original executable assertions. Only the already
1013
+ // compiled module directory and immutable original source root are supplied by
1014
+ // the matrix runner; none of the compiler algorithms execute in this adapter.
1015
+ async function addOriginalCompilerModulePrograms({add,locators,text,file,bootstrapSources}) {
1016
+ const modules=[],mappedSuites=[];
1017
+ for(const filename of bootstrapSources){
1018
+ if(!filename.startsWith('bootstrap/compiler/')||!filename.endsWith('.eli'))throw new TypeError('original compiler source graph changed');
1019
+ modules.push({id:filename.slice(0,-4)+'.mjs',filename,source:await text(filename)});
1020
+ }
1021
+ const plans=[
1022
+ {name:'bootstrap-reader',suite:'tests/bootstrap-reader.test.mjs',
1023
+ assertion:'bootstrapped reader matches normalized seed syntax and diagnostics',
1024
+ begin:' const reader = await import(',end:'\n}, 30_000);',helperEnd:'\n// Build both complete compiler',
1025
+ stage:'reader',diagnostics:true,repeatGraph:true},
1026
+ {name:'bootstrap-expander',suite:'tests/bootstrap-expander.test.mjs',
1027
+ assertion:'bootstrapped expander matches seed syntax, spans, and diagnostics',begin:' const reader = await import(',stage:'expander',diagnostics:true},
1028
+ {name:'bootstrap-analyzer',suite:'tests/bootstrap-analyzer.test.mjs',
1029
+ assertion:'bootstrapped analyzer matches seed acceptance and diagnostics',begin:' const reader = await import(',stage:'analyzer',diagnostics:true},
1030
+ {name:'bootstrap-ir',suite:'tests/bootstrap-ir.test.mjs',
1031
+ assertion:'bootstrapped lowerer matches complete seed IR trees and spans',begin:' const module = async (name) => import(',stage:'ir'},
1032
+ {name:'bootstrap-emitter',suite:'tests/bootstrap-emitter.test.mjs',
1033
+ assertion:'bootstrapped emitter matches seed ESM and Source Map output',begin:' const module = async (name) => import(',stage:'emitter',child:true},
1034
+ {name:'reader-program-fuzz',suite:'tests/reader-program-fuzz.test.mjs',
1035
+ assertion:'100000 deterministic reader and program mutations preserve every invariant',
1036
+ helperStart:'async function runAcceptanceFuzz()',begin:' await proveFuzzProgramEmission();',end:'\n}, 320_000);',child:true,fuzz:true},
1037
+ {name:'canonical-ir',suite:'tests/bootstrap-ir-serialization.test.mjs',
1038
+ assertion:'canonical IR v1 is lossless, strict, and host reproducible',begin:' const module = async (name) => import(',child:true},
1039
+ {name:'ir-kind',suite:'tests/compiler-ir-kind.test.mjs',
1040
+ assertion:'optimized IR node-kind decisions match the linear reference',begin:' const module = (name) => import(',constants:'compilerSources'},
1041
+ {name:'locate',suite:'tests/compiler-locate.test.mjs',
1042
+ assertion:'ordered compiler mark location matches its scan and copy reference',begin:' const module = (name) => import(',constants:'compilerSources'},
1043
+ {name:'indent',suite:'tests/compiler-indent.test.mjs',
1044
+ assertion:'chunked compiler indentation matches its character reference',begin:' const module = (name) => import(',constants:'compilerSources'},
1045
+ {name:'runtime-scan',suite:'tests/compiler-runtime-scan.test.mjs',
1046
+ assertion:'optimized compiler runtime scan matches its readable reference',begin:' const module = (name) => import(',constants:'compilerSources'},
1047
+ {name:'source-map-cursor',suite:'tests/compiler-source-map-cursor.test.mjs',
1048
+ assertion:'ordered Source Map cursors match their complete scan references',begin:' const module = (name) => import(',constants:'compilerNames'},
1049
+ {name:'reader-character',suite:'tests/compiler-reader-character.test.mjs',
1050
+ assertion:'reader character predicates match their Eliscript references',begin:' const reader = await import('},
1051
+ {name:'binary-comparison',suite:'tests/compiler-binary-comparison.test.mjs',
1052
+ assertion:'binary comparison emission preserves strict argument evaluation',begin:' const compiler = await import(',child:true},
1053
+ ];
1054
+ for(const plan of plans){
1055
+ if(!locators.some(item=>item.file===plan.suite))continue;
1056
+ const original=await text(plan.suite),helpers=originalRegion(original,plan.helperStart??'async function run(',plan.helperEnd??'\ntest(');
1057
+ const body=originalRegion(original,plan.begin,plan.end??'\n } finally {');
1058
+ const transported=plan.assertion+'\n'+helpers.text+'\n'+body.text;
1059
+ const coverage=locators.filter(item=>item.file===plan.suite&&typeof item.contains==='string'&&transported.includes(item.contains)&&originalReportOnlyLocators.get(item.file)!==item.contains).map(item=>item.id);
1060
+ if(!coverage.length)throw new TypeError('original compiler host has no matching assertion locator: '+plan.suite);
1061
+ const regions=[helpers,body],parts=[helpers.text,body.text];
1062
+ let fuzzProofTransport;
1063
+ if(plan.fuzz){
1064
+ const before=' await proveFuzzProgramEmission();',after=' await proveFuzzProgramEmission(directory);';
1065
+ const start=body.text.indexOf(before);
1066
+ if(start!==0||body.text.indexOf(before,before.length)>=0)
1067
+ throw new TypeError('original fuzz semantic proof entry changed');
1068
+ parts[1]=after+body.text.slice(before.length);
1069
+ const generator=await file('tools/fuzz/reader-program-fuzz.mjs');
1070
+ fuzzProofTransport={kind:'selected-compiler-semantic-proof',
1071
+ sourceFile:plan.suite,originalCall:before,selectedCall:after,
1072
+ beforeSha256:digest(Buffer.from(before)),afterSha256:digest(Buffer.from(after)),
1073
+ compilerDirectory:'selected-artifact/bootstrap/compiler',
1074
+ compilerSources:modules.map(module=>({id:module.id,filename:module.filename,
1075
+ sourceSha256:digest(Buffer.from(module.source))})),
1076
+ generator:{file:generator.file,sourceSha256:generator.sha256},
1077
+ independentOracle:'tests/bootstrap-emitter-oracle.el',
1078
+ fallback:false};
1079
+ }
1080
+ if(plan.constants){
1081
+ const constants=originalRegion(original,'const '+plan.constants+' = [','\n];');
1082
+ regions.push(constants);parts.unshift(constants.text+'\n];');
1083
+ }
1084
+ if(plan.repeatGraph){
1085
+ // The original beforeAll compares every emitted compiler file twice.
1086
+ // Keep that assertion on the actual selected target's two products;
1087
+ // the remaining original reader/diagnostic body runs below unchanged.
1088
+ const comparison=originalRegion(original,' for (const name of artifactNames) expect(secondArtifacts.get(name)).toBe(firstArtifacts.get(name));','\n const reader = await import(');
1089
+ regions.push(comparison);
1090
+ const request={operation:'project',resolveImports:true,phased:true,sourceMap:true,
1091
+ modules:cloneCompilerCorpusModules(modules),entry:'bootstrap/compiler/compiler.mjs',entries:modules.map(item=>item.id)};
1092
+ add({id:'original-sequence:compiler-reader-complete-artifacts',kind:'sequence',coverage,
1093
+ original:{suite:plan.suite,sourceSha256:(await file(plan.suite)).sha256,
1094
+ regions:[comparison].map(({start,end,byteStart,byteEnd,sha256})=>({start,end,byteStart,byteEnd,sha256}))},
1095
+ expected:{kind:'sequence'},steps:[
1096
+ {id:'first',request},
1097
+ {id:'repeat',request:cloneSourceProjectRequest(request),sameProductAs:'first'},
1098
+ ]});
1099
+ }
1100
+ const preamble=[
1101
+ 'import {expect} from "bun:test";',
1102
+ 'import {readFile,writeFile,mkdtemp,rm} from "node:fs/promises";',
1103
+ 'import path,{resolve} from "node:path";',
1104
+ 'import {pathToFileURL} from "node:url";',
1105
+ 'const projectDirectory=process.env.ELISCRIPT_ORIGINAL_SOURCE_ROOT;',
1106
+ 'if(!projectDirectory)throw new Error("original compiler host requires its source root");',
1107
+ 'const directory=resolve(process.argv[2],"bootstrap/compiler");',
1108
+ 'const fixturePath=resolve(projectDirectory,'+JSON.stringify('tests/fixtures/bootstrap-'+(plan.stage&&plan.stage!=='emitter'?plan.stage:'ir')+'.json')+');',
1109
+ ...(plan.repeatGraph?[
1110
+ 'const firstArtifacts=new Map([["reader.mjs.map",await readFile(resolve(directory,"reader.mjs.map"),"utf8")]]);',
1111
+ ]:[]),
1112
+ ...(plan.stage?[
1113
+ 'const emacs=process.env.EMACS??"emacs";',
1114
+ 'const oraclePath=resolve(projectDirectory,'+JSON.stringify('tests/bootstrap-'+plan.stage+'-oracle.el')+');',
1115
+ ]:[]),
1116
+ ...(plan.fuzz?[
1117
+ 'const root=projectDirectory;',
1118
+ 'const {fuzzCases}=await import(pathToFileURL(resolve(projectDirectory,"tools/fuzz/reader-program-fuzz.mjs")).href);',
1119
+ 'const fuzzPath=resolve(process.argv[2],"__eliscript_original_fuzz_runner.mjs");',
1120
+ 'process.env.ELISCRIPT_ORIGINAL_COMPILER_DIRECTORY=directory;',
1121
+ 'await writeFile(fuzzPath,'+JSON.stringify([
1122
+ 'import {resolve} from "node:path";',
1123
+ 'import {pathToFileURL} from "node:url";',
1124
+ 'await import(pathToFileURL(resolve(process.env.ELISCRIPT_ORIGINAL_SOURCE_ROOT,"tools/backends/compiler-corpus-host-context.mjs")).href);',
1125
+ 'const {runReaderProgramFuzz,parseArguments,stopReaderProgramFuzz}=await import(pathToFileURL(resolve(process.env.ELISCRIPT_ORIGINAL_SOURCE_ROOT,"tools/fuzz/reader-program-fuzz.mjs")).href);',
1126
+ 'process.once("SIGINT",()=>stopReaderProgramFuzz("SIGINT"));',
1127
+ 'process.once("SIGTERM",()=>stopReaderProgramFuzz("SIGTERM"));',
1128
+ 'try{const report=await runReaderProgramFuzz({...parseArguments(process.argv.slice(2)),compilerDirectory:process.env.ELISCRIPT_ORIGINAL_COMPILER_DIRECTORY});process.stdout.write(JSON.stringify(report)+"\\n");}',
1129
+ 'catch(error){process.stderr.write(String(error.stack??error)+"\\n");process.exitCode=1;}',
1130
+ ].join('\n'))+');',
1131
+ ]:[]),
1132
+ ...(plan.diagnostics?[
1133
+ 'const {diagnosticCorpusSuite}=await import(pathToFileURL(resolve(projectDirectory,"tools/diagnostics/check.mjs")).href);',
1134
+ 'const diagnosticCorpus=await Bun.file(resolve(projectDirectory,"contracts/diagnostic-corpus.json")).json();',
1135
+ 'const diagnosticCases=diagnosticCorpusSuite(diagnosticCorpus,'+JSON.stringify(plan.stage)+').cases;',
1136
+ ]:[]),
1137
+ ].join('\n');
1138
+ add({id:'original-program:compiler-module-'+plan.name,kind:'project',coverage,
1139
+ modules:cloneCompilerCorpusModules(modules),entry:'bootstrap/compiler/compiler.mjs',
1140
+ request:{operation:'project',resolveImports:true,phased:true,sourceMap:true,entries:modules.map(item=>item.id)},
1141
+ execution:{kind:'original-program',host:'tests/__eliscript_original_compiler_'+plan.name+'.mjs',
1142
+ hostSource:preamble+'\n'+parts.join('\n')+'\n',arguments:[{directory:true}],aliases:true,requiresBun:true,
1143
+ runtimeProfile:'compiler',
1144
+ ...(plan.fuzz?{timeoutMs:320000}:{}),
1145
+ ...(plan.child?{childProcesses:'inherit-selected-artifact'}:{}),
1146
+ ...(plan.stage?{compilerSourceMaps:true}:{})},
1147
+ expected:{kind:'seed-program',oracleRequired:true,stdout:''},
1148
+ original:{manifest:'stable-compatibility',suite:plan.suite,fixture:plan.suite,host:plan.suite,
1149
+ sourceSha256:(await file(plan.suite)).sha256,
1150
+ regions:regions.map(({start,end,byteStart,byteEnd,sha256})=>({start,end,byteStart,byteEnd,sha256})),
1151
+ originalAssertion:plan.assertion,...(fuzzProofTransport?{setupReplacement:fuzzProofTransport}:{})}});
1152
+ mappedSuites.push(plan.suite);
1153
+ }
1154
+ return mappedSuites;
1155
+ }