@viberaven/sessions 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/NOTICE +5 -1
  2. package/README.md +16 -0
  3. package/THIRD_PARTY_NOTICES +1 -1
  4. package/package.json +4 -2
  5. package/runtime-infn/engine/frozen/runtime/engine-host.mjs +390 -0
  6. package/runtime-infn/engine/frozen/runtime/engine-logs/static-layout.json +21357 -0
  7. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/amcheck.tar.gz +0 -0
  8. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/auth_delay.tar.gz +0 -0
  9. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/auto_explain.tar.gz +0 -0
  10. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/basebackup_to_shell.tar.gz +0 -0
  11. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/basic_archive.tar.gz +0 -0
  12. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/bloom.tar.gz +0 -0
  13. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gin.tar.gz +0 -0
  14. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gist.tar.gz +0 -0
  15. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-5L4W4HOZ.js +3 -0
  16. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-C56CJGL3.js +6 -0
  17. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-CMNLZGEJ.js +2 -0
  18. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-DAMXLPQW.js +2 -0
  19. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-EZSFBMVG.js +2 -0
  20. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-GS6VKQIC.js +2 -0
  21. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-OCWZREWN.js +2 -0
  22. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-UQDQKWPM.js +2 -0
  23. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-YFZE77YQ.js +9 -0
  24. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/citext.tar.gz +0 -0
  25. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/amcheck.js +2 -0
  26. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/auto_explain.js +2 -0
  27. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/bloom.js +2 -0
  28. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gin.js +2 -0
  29. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gist.js +2 -0
  30. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/citext.js +2 -0
  31. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/cube.js +2 -0
  32. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_int.js +2 -0
  33. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_xsyn.js +2 -0
  34. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/earthdistance.js +2 -0
  35. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/file_fdw.js +2 -0
  36. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/fuzzystrmatch.js +2 -0
  37. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/hstore.js +2 -0
  38. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/intarray.js +2 -0
  39. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/isn.js +2 -0
  40. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/lo.js +2 -0
  41. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/ltree.js +2 -0
  42. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/moddatetime.js +2 -0
  43. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pageinspect.js +2 -0
  44. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_buffercache.js +2 -0
  45. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_freespacemap.js +2 -0
  46. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_stat_statements.js +2 -0
  47. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_surgery.js +2 -0
  48. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_trgm.js +2 -0
  49. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_visibility.js +2 -0
  50. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_walinspect.js +2 -0
  51. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pgcrypto.js +2 -0
  52. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/seg.js +2 -0
  53. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tablefunc.js +2 -0
  54. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tcn.js +2 -0
  55. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_rows.js +2 -0
  56. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_time.js +2 -0
  57. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/unaccent.js +2 -0
  58. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/uuid_ossp.js +2 -0
  59. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/cube.tar.gz +0 -0
  60. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/dblink.tar.gz +0 -0
  61. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/dict_int.tar.gz +0 -0
  62. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/dict_xsyn.tar.gz +0 -0
  63. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/earthdistance.tar.gz +0 -0
  64. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/file_fdw.tar.gz +0 -0
  65. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/base.js +2 -0
  66. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs-frontend.js +2 -0
  67. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs2opfs.js +2 -0
  68. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/nodefs.js +2 -0
  69. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fs/opfs-ahp.js +4 -0
  70. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/fuzzystrmatch.tar.gz +0 -0
  71. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/hstore.tar.gz +0 -0
  72. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/index.js +2 -0
  73. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.js +2 -0
  74. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.wasm +0 -0
  75. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/intagg.tar.gz +0 -0
  76. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/intarray.tar.gz +0 -0
  77. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/isn.tar.gz +0 -0
  78. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/live/index.js +134 -0
  79. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/lo.tar.gz +0 -0
  80. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/ltree.tar.gz +0 -0
  81. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/node-postgres/index.js +2 -0
  82. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/oid2name.tar.gz +0 -0
  83. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pageinspect.tar.gz +0 -0
  84. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/passwordcheck.tar.gz +0 -0
  85. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_buffercache.tar.gz +0 -0
  86. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_freespacemap.tar.gz +0 -0
  87. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_logicalinspect.tar.gz +0 -0
  88. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_overexplain.tar.gz +0 -0
  89. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_prewarm.tar.gz +0 -0
  90. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_stat_statements.tar.gz +0 -0
  91. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_surgery.tar.gz +0 -0
  92. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_trgm.tar.gz +0 -0
  93. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_visibility.tar.gz +0 -0
  94. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pg_walinspect.tar.gz +0 -0
  95. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pgcrypto.tar.gz +0 -0
  96. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.data +37614 -8
  97. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.js +2 -0
  98. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.wasm +0 -0
  99. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pgrowlocks.tar.gz +0 -0
  100. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/pgstattuple.tar.gz +0 -0
  101. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/postgres_fdw.tar.gz +0 -0
  102. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/seg.tar.gz +0 -0
  103. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/spi.tar.gz +0 -0
  104. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tablefunc.tar.gz +0 -0
  105. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tcn.tar.gz +0 -0
  106. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/templating.js +2 -0
  107. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/test_decoding.tar.gz +0 -0
  108. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_rows.tar.gz +0 -0
  109. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_time.tar.gz +0 -0
  110. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/unaccent.tar.gz +0 -0
  111. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/uuid-ossp.tar.gz +0 -0
  112. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/vacuumlo.tar.gz +0 -0
  113. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/worker/index.js +2 -0
  114. package/runtime-infn/engine/frozen/runtime/pglite/packages/pglite/dist/xml2.tar.gz +0 -0
  115. package/runtime-infn/race/pin.mjs +12 -0
  116. package/runtime-infn/runtime-manifest.json +580 -0
  117. package/runtime-infn/wait/initial-image.tgz +0 -0
  118. package/runtime-infn/wait/wire.mjs +39 -0
  119. package/runtime-infnprod/engine/frozen/runtime/engine-host.mjs +391 -0
  120. package/runtime-infnprod/engine/frozen/runtime/engine-logs/static-layout.json +21357 -0
  121. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/amcheck.tar.gz +0 -0
  122. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/auth_delay.tar.gz +0 -0
  123. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/auto_explain.tar.gz +0 -0
  124. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/basebackup_to_shell.tar.gz +0 -0
  125. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/basic_archive.tar.gz +0 -0
  126. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/bloom.tar.gz +0 -0
  127. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gin.tar.gz +0 -0
  128. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/btree_gist.tar.gz +0 -0
  129. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-5L4W4HOZ.js +3 -0
  130. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-C56CJGL3.js +6 -0
  131. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-CMNLZGEJ.js +2 -0
  132. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-DAMXLPQW.js +2 -0
  133. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-EZSFBMVG.js +2 -0
  134. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-GS6VKQIC.js +2 -0
  135. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-OCWZREWN.js +2 -0
  136. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-UQDQKWPM.js +2 -0
  137. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/chunk-YFZE77YQ.js +9 -0
  138. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/citext.tar.gz +0 -0
  139. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/amcheck.js +2 -0
  140. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/auto_explain.js +2 -0
  141. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/bloom.js +2 -0
  142. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gin.js +2 -0
  143. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/btree_gist.js +2 -0
  144. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/citext.js +2 -0
  145. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/cube.js +2 -0
  146. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_int.js +2 -0
  147. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/dict_xsyn.js +2 -0
  148. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/earthdistance.js +2 -0
  149. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/file_fdw.js +2 -0
  150. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/fuzzystrmatch.js +2 -0
  151. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/hstore.js +2 -0
  152. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/intarray.js +2 -0
  153. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/isn.js +2 -0
  154. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/lo.js +2 -0
  155. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/ltree.js +2 -0
  156. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/moddatetime.js +2 -0
  157. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pageinspect.js +2 -0
  158. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_buffercache.js +2 -0
  159. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_freespacemap.js +2 -0
  160. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_stat_statements.js +2 -0
  161. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_surgery.js +2 -0
  162. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_trgm.js +2 -0
  163. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_visibility.js +2 -0
  164. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pg_walinspect.js +2 -0
  165. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/pgcrypto.js +2 -0
  166. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/seg.js +2 -0
  167. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tablefunc.js +2 -0
  168. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tcn.js +2 -0
  169. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_rows.js +2 -0
  170. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/tsm_system_time.js +2 -0
  171. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/unaccent.js +2 -0
  172. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/contrib/uuid_ossp.js +2 -0
  173. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/cube.tar.gz +0 -0
  174. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/dblink.tar.gz +0 -0
  175. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/dict_int.tar.gz +0 -0
  176. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/dict_xsyn.tar.gz +0 -0
  177. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/earthdistance.tar.gz +0 -0
  178. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/file_fdw.tar.gz +0 -0
  179. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/base.js +2 -0
  180. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs-frontend.js +2 -0
  181. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/memfs2opfs.js +2 -0
  182. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/nodefs.js +2 -0
  183. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fs/opfs-ahp.js +4 -0
  184. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/fuzzystrmatch.tar.gz +0 -0
  185. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/hstore.tar.gz +0 -0
  186. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/index.js +2 -0
  187. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.js +2 -0
  188. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/initdb.wasm +0 -0
  189. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/intagg.tar.gz +0 -0
  190. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/intarray.tar.gz +0 -0
  191. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/isn.tar.gz +0 -0
  192. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/live/index.js +134 -0
  193. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/lo.tar.gz +0 -0
  194. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/ltree.tar.gz +0 -0
  195. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/node-postgres/index.js +2 -0
  196. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/oid2name.tar.gz +0 -0
  197. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pageinspect.tar.gz +0 -0
  198. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/passwordcheck.tar.gz +0 -0
  199. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_buffercache.tar.gz +0 -0
  200. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_freespacemap.tar.gz +0 -0
  201. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_logicalinspect.tar.gz +0 -0
  202. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_overexplain.tar.gz +0 -0
  203. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_prewarm.tar.gz +0 -0
  204. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_stat_statements.tar.gz +0 -0
  205. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_surgery.tar.gz +0 -0
  206. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_trgm.tar.gz +0 -0
  207. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_visibility.tar.gz +0 -0
  208. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pg_walinspect.tar.gz +0 -0
  209. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pgcrypto.tar.gz +0 -0
  210. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.data +37614 -8
  211. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.js +2 -0
  212. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pglite.wasm +0 -0
  213. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pgrowlocks.tar.gz +0 -0
  214. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/pgstattuple.tar.gz +0 -0
  215. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/postgres_fdw.tar.gz +0 -0
  216. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/seg.tar.gz +0 -0
  217. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/spi.tar.gz +0 -0
  218. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tablefunc.tar.gz +0 -0
  219. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tcn.tar.gz +0 -0
  220. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/templating.js +2 -0
  221. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/test_decoding.tar.gz +0 -0
  222. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_rows.tar.gz +0 -0
  223. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/tsm_system_time.tar.gz +0 -0
  224. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/unaccent.tar.gz +0 -0
  225. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/uuid-ossp.tar.gz +0 -0
  226. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/vacuumlo.tar.gz +0 -0
  227. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/worker/index.js +2 -0
  228. package/runtime-infnprod/engine/frozen/runtime/pglite/packages/pglite/dist/xml2.tar.gz +0 -0
  229. package/runtime-infnprod/race/pin.mjs +12 -0
  230. package/runtime-infnprod/runtime-manifest.json +581 -0
  231. package/runtime-infnprod/wait/initial-image.tgz +0 -0
  232. package/runtime-infnprod/wait/wire.mjs +39 -0
  233. package/src/index.d.ts +6 -1
  234. package/src/index.mjs +9 -8
  235. package/src/runtime-integrity.mjs +24 -1
package/NOTICE CHANGED
@@ -12,7 +12,11 @@ database implementation. See LICENSE and licenses/PostgreSQL.txt.
12
12
  The shipped engine is a modified PGlite/PostgreSQL build. Modifications implement
13
13
  independent backend contexts, shared-kernel integration, scheduling, lifecycle,
14
14
  signal handling and JSPI suspension at the operating-system boundary. The
15
- modified generated runtime assets are pglite.wasm, pglite.js and the corresponding
15
+ INFN and INFNPROD builds also expose opt-in suspension at in-function SQL
16
+ boundaries. Their prebuilt assets are retained in runtime-infn/ and
17
+ runtime-infnprod/.
18
+
19
+ The modified generated runtime assets are pglite.wasm, pglite.js and the corresponding
16
20
  PGlite runtime chunks; runtime/engine/frozen/runtime/engine-host.mjs and the wire/pin helpers provide
17
21
  VibeRaven's host. No engine compilation or source modification is performed by
18
22
  this package's build or swap scripts. Copies in runtime/ retain the exact approved
package/README.md CHANGED
@@ -114,6 +114,22 @@ The minimal package slot is a subset of the original qualified runtime inputs:
114
114
  - PostgreSQL 18.6; 113 unchanged runtime files. The omitted inputs include private
115
115
  validation adapters, source patches, sourcemaps and unused CJS artifacts.
116
116
 
117
+ Node callers can pass `runtime: 'l4' | 'infn' | 'infnprod'` to `createHost` and
118
+ select the same runtime in `loadExtensions(names, runtime)`. Node and browser
119
+ default to L4. Check a Node runtime's manifest with `verifyRuntimeVersion(runtime)`.
120
+ The INFN builds park at in-function boundaries only when the host's
121
+ `spiBoundaries(pid, site)` callback returns `true`. The caller advances a parked
122
+ backend with `host.resumeSPI(pid)`.
123
+
124
+ | Runtime | SHA-256 |
125
+ | --- | --- |
126
+ | `infn` | `d3ae894be3080a1c3fd50cf7ddd9f46774829aed000c8db89bc44eae9c9a1493` |
127
+ | `infnprod` | `62b3d9f13596860b86ef9ce3a3328993a1d32bcaa36c2b9aac02609b69559773` |
128
+
129
+ The two candidates are byte-for-byte portable build slots. Each ships its own
130
+ manifest and dependency closure. `npm run verify:runtime` checks all three slots
131
+ and runs before `npm pack`. CLI `race --deep` selects `infnprod`.
132
+
117
133
  ## Limitations
118
134
 
119
135
  Tests cover supplied SQL, inputs and bounded statement issue orders. They do not
@@ -1,4 +1,4 @@
1
- THIRD-PARTY NOTICES — @viberaven/sessions 0.1.0
1
+ THIRD-PARTY NOTICES — @viberaven/sessions 0.2.0
2
2
 
3
3
  VibeRaven additions: Copyright 2026 VibeRaven contributors, Apache-2.0.
4
4
  This file retains full license texts and notices for the bundled engine and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viberaven/sessions",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Several real PostgreSQL 18.6 sessions in one PGlite WebAssembly instance for concurrency tests and replay. Part of VibeRaven.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -15,7 +15,7 @@
15
15
  "tag": "next"
16
16
  },
17
17
  "engines": {
18
- "node": ">=24"
18
+ "node": ">=20"
19
19
  },
20
20
  "exports": {
21
21
  ".": {
@@ -37,6 +37,8 @@
37
37
  "files": [
38
38
  "src",
39
39
  "runtime",
40
+ "runtime-infn",
41
+ "runtime-infnprod",
40
42
  "dist/browser.mjs",
41
43
  "LICENSE",
42
44
  "NOTICE",
@@ -0,0 +1,390 @@
1
+ import fs from 'node:fs';
2
+ import assert from 'node:assert/strict';
3
+ import {PGlite} from './pglite/packages/pglite/dist/index.js';
4
+ import {simpleQuery,startup,parseWire} from '../../../wait/wire.mjs';
5
+
6
+ export class BackendStartExit extends Error {
7
+ constructor(status,bytes){super('backend exited during startup');this.status=status;this.bytes=bytes;}
8
+ }
9
+
10
+ function hasFatalResponse(bytes){
11
+ for(let o=0;o+5<=bytes.length;){
12
+ const n=bytes.readInt32BE(o+1),end=o+1+n;assert(n>=4&&end<=bytes.length,'invalid startup response');
13
+ if(bytes[o]===69){
14
+ const fields={};let p=o+5;
15
+ while(p<end&&bytes[p]){const key=String.fromCharCode(bytes[p++]),q=bytes.indexOf(0,p);assert(q>=p&&q<end);fields[key]=bytes.toString('utf8',p,q);p=q+1;}
16
+ if((fields.V??fields.S)==='FATAL')return true;
17
+ }
18
+ o=end;
19
+ }
20
+ return false;
21
+ }
22
+
23
+ // One Wasm instance. Only the OS boundary schedules work. Shared memory and
24
+ // PostgreSQL's own lock queues determine which parked continuations can run.
25
+ export class EngineHost {
26
+ static async create(options={}) {
27
+ assert.equal(typeof WebAssembly.Suspending,'function','JSPI host required');
28
+ const h=new EngineHost();
29
+ h.options=options;h.layout=JSON.parse(fs.readFileSync(new URL('./engine-logs/static-layout.json',import.meta.url)));
30
+ h.spans=h.layout.spans.map((s,i)=>({...s,key:'main:'+i}));h.initial=new Map();
31
+ h.backends=new Map();h.signals=new Map();h.parked=new Map();h.jobs=[];h.log=[];h.waits=[];
32
+ h.busy=false;h.scheduled=false;h.active=null;h.switches=0;h.nextSlot=2;h.freeSlots=[];h.timers=new Map();
33
+ h.parkingObservers=new Map();h.operations=new Map();h.failure=null;h.startups=1;h.syncMailbox=[];h.checkpointTickets=new Map();h.nextCheckpointTicket=1;
34
+ h.failureNotification=new Promise(resolve=>{h.reportFailure=resolve;});
35
+ h.descriptorOwners=new Map();h.asyncEntries=new Set();h.osActivations=new Set();h.synchronousDepth=0;h.quantumDeadline=0;
36
+ h.event=event=>{h.log.push(event);if(process.env.L2_EVENT_LOG)fs.appendFileSync(process.env.L2_EVENT_LOG,JSON.stringify(event)+'\n');};
37
+ const extension={name:'contexts',setup:async(pg,opts)=>({emscriptenOpts:{...opts,postRun:[...(opts.postRun??[]),m=>{
38
+ h.mod=m;
39
+ const files=m.FS,create=files.createStream,close=files.closeStream;
40
+ files.createStream=function(...args){const stream=create.apply(this,args);h.descriptorOwners.set(stream.fd,{pid:h.active??42,stream});return stream;};
41
+ files.closeStream=function(fd){h.descriptorOwners.delete(fd);return close.call(this,fd);};
42
+ for(const stream of files.streams)if(stream)h.descriptorOwners.set(stream.fd,{pid:42,stream});
43
+ m.sessionsOwnFd=(pid,fd)=>{
44
+ const stream=files.streams[fd];assert(stream,'missing transferred descriptor');h.descriptorOwners.set(fd,{pid,stream});
45
+ };
46
+ const original=m.callMain;
47
+ m.callMain=args=>{
48
+ if(!h.pristine){
49
+ h.event({event:'bootstrap-main',mode:args[0]??''});
50
+ if(args[0]==='--single'){
51
+ h.pristine=h.capture();for(const [k,v]of h.pristine)h.initial.set(k,v);
52
+ }
53
+ h.active=42;
54
+ if(!h.backends.has(42))h.backends.set(42,{pid:42,image:h.capture(),sp:m.stackSave(),slot:1});
55
+ assert(!h.operations.has(42),'overlapping bootstrap entry');
56
+ h.busy=true;const bootstrap={bootstrap:true};h.operations.set(42,bootstrap);
57
+ return Promise.resolve().then(()=>original(args)).finally(()=>{
58
+ h.save();h.operations.delete(42);h.busy=false;h.kick();
59
+ });
60
+ }
61
+ return original(args);
62
+ };
63
+ m.attachDsoLoaded=(name,start,size)=>{
64
+ if(!size||h.spans.some(s=>s.key==='dso:'+name))return;
65
+ const span={key:'dso:'+name,start,size};h.spans.push(span);h.initial.set(span.key,m.HEAPU8.slice(start,start+size));
66
+ };
67
+ for(const d of m.attachDsos??[])m.attachDsoLoaded(d.name,d.start,d.size);
68
+ m.attachSignal=(pid,sig)=>{
69
+ h.event({event:'signal-send',source:h.active,pid,sig});
70
+ const target=pid===0?h.active:Math.abs(pid);
71
+ if(!h.backends.has(target))return -1;
72
+ if(sig){if(target===h.active)h.deliver(sig);else h.signal(target,sig);}return 0;
73
+ };
74
+ m.sessionsWait=(latch,timeout)=>h.sleep(latch,timeout);
75
+ m.sessionsCanYield=()=>h.canYield();
76
+ m.sessionsYield=()=>h.sleep(0,0,true);
77
+ m.sessionsSPIEnabled=()=>!h.synchronousDepth&&h.asyncEntries.has(h.active)&&
78
+ !h.osActivations.has(h.active)&&h.options.spiBoundaries?.(h.active)===true;
79
+ m.sessionsSPIPark=()=>h.sleep(0,-1,true,'spi');
80
+ m.sessionsTimer=(which,sec,usec)=>h.timer(which,sec,usec);
81
+ m.sessionsSync=(tag,size,type)=>h.syncRequest(tag,size,type);
82
+ m.sessionsNextSync=(tag,size,type)=>h.nextSyncRequest(tag,size,type);
83
+ m.sessionsCheckpointStart=flags=>h.startCheckpoint(flags);
84
+ m.sessionsCheckpointWait=ticket=>h.waitCheckpoint(ticket);
85
+ m.sessionsCheckpointRelease=ticket=>h.releaseCheckpoint(ticket);
86
+ }]}})};
87
+ h.db=await PGlite.create({...options,children:undefined,
88
+ extensions:{...options.extensions,contexts:extension},
89
+ startParams:[...PGlite.defaultStartParams,'-c','shared_memory_type=sysv','-c','dynamic_shared_memory_type=sysv',...(options.extraStartParams??[])],
90
+ onStderr:text=>{h.log.push({event:'stderr',text});options.onStderr?.(text);},
91
+ onStdout:text=>{h.log.push({event:'stdout',text});options.onStdout?.(text);}});
92
+ assert(h.pristine&&h.mod,'initial private image unavailable');
93
+ h.active=42;h.backends.set(42,{pid:42,image:h.capture(),sp:h.mod.stackSave(),slot:1});
94
+ h.log.push({event:'backend-ready',pid:42});
95
+ for(const pid of options.children??[])await h.attach(pid);
96
+ return h;
97
+ }
98
+ capture(){return new Map(this.spans.map(s=>[s.key,this.mod.HEAPU8.slice(s.start,s.start+s.size)]));}
99
+ restore(image){for(const s of this.spans){const b=image.get(s.key)??this.initial.get(s.key);assert(b,'uninitialized DSO image');this.mod.HEAPU8.set(b,s.start);}}
100
+ save(){if(this.active!==null){const b=this.backends.get(this.active);assert(b);b.image=this.capture();b.sp=this.mod.stackSave();}}
101
+ select(pid){
102
+ assert(this.backends.has(pid),'unknown backend');
103
+ if(this.active!==pid){this.save();const b=this.backends.get(pid);this.restore(b.image);this.mod.stackRestore(b.sp);this.active=pid;this.switches++;}
104
+ const signals=this.signals.get(pid);this.signals.delete(pid);
105
+ if(signals)for(const sig of signals)this.deliver(sig);
106
+ }
107
+ deliver(sig){
108
+ this.event({event:'signal-deliver',pid:this.active,sig});this.synchronousDepth++;
109
+ try{if(sig===14)this.mod._pgl_sessions_alarm();else this.mod._pgl_sessions_deliver(sig);}
110
+ finally{this.synchronousDepth--;}
111
+ }
112
+ canYield(){
113
+ if(this.synchronousDepth||!this.asyncEntries.has(this.active))return false;
114
+ const now=Date.now();if(now<this.quantumDeadline)return false;
115
+ this.quantumDeadline=now+4;return true;
116
+ }
117
+ schedule(pid,work,interrupt=false){
118
+ if(this.failure)return Promise.reject(this.failure);
119
+ return new Promise((resolve,reject)=>{this.jobs.push({pid,work,resolve,reject,interrupt});this.kick();});
120
+ }
121
+ kick(){if(!this.scheduled){this.scheduled=true;queueMicrotask(()=>{this.scheduled=false;this.pump();});}}
122
+ pump(){
123
+ if(this.busy||this.failure)return;
124
+ for(const [pid,w]of this.parked){
125
+ if(!w.queued&&(w.kind==='spi'?w.released:w.kind==='service'?(w.notified||w.request.done):(w.timedOut||this.latchSet(w)))){w.queued=true;this.jobs.push({pid,wake:w});}
126
+ }
127
+ const index=this.jobs.findIndex(j=>j.wake||j.interrupt||!this.operations.has(j.pid));
128
+ if(index<0)return;
129
+ const [job]=this.jobs.splice(index,1);
130
+ if(!this.backends.has(job.pid)&&job.interrupt){job.resolve?.();this.kick();return;}
131
+ if(job.wake){
132
+ const w=job.wake;if(this.parked.get(job.pid)!==w){this.kick();return;}
133
+ this.busy=true;this.select(job.pid);this.mod.stackRestore(w.sp);this.parked.delete(job.pid);
134
+ clearTimeout(w.timeoutHandle);w.returned=true;
135
+ if(w.kind==='service'){
136
+ assert.equal(w.request.waiter,w);w.request.waiter=null;
137
+ this.event({event:'service-wake',pid:job.pid,ticket:w.request.ticket,done:w.request.done});
138
+ w.resolve(w.request.done?1:0);
139
+ }else if(w.kind==='spi'){
140
+ this.event({event:'spi-resume',pid:job.pid});
141
+ w.resolve();
142
+ }else{
143
+ w.returnedSet=this.latchSet(w);
144
+ this.event({event:'wake',pid:job.pid,latch:w.latch,latchSet:w.returnedSet,timedOut:!!w.timedOut});
145
+ w.resolve(w.returnedSet?1:0);
146
+ }
147
+ // Ownership remains with the resumed C activation until it sleeps again
148
+ // or its exported entry completes. Never resolve two C stacks together.
149
+ return;
150
+ }
151
+ this.busy=true;
152
+ if(!job.interrupt)this.operations.set(job.pid,job);
153
+ try{this.select(job.pid);}catch(e){job.reject(e);this.fail(e);return;}
154
+ Promise.resolve().then(job.work).then(job.resolve,job.reject).finally(()=>{
155
+ if(!job.interrupt)this.operations.delete(job.pid);
156
+ if(!this.options.oneSession||this.backends.size>1)this.save();
157
+ this.busy=false;this.kick();
158
+ });
159
+ }
160
+ fail(error){
161
+ if(this.failure)return;
162
+ this.failure=error;for(const j of this.jobs.splice(0))j.reject?.(error);
163
+ for(const timer of this.timers.values())clearTimeout(timer);this.timers.clear();
164
+ for(const parked of this.parked.values())clearTimeout(parked.timeoutHandle);
165
+ // A fatal host error is not a resume permission. Leave C continuations
166
+ // parked and notify the owning runner, which records the failed engine.
167
+ this.reportFailure(error);
168
+ }
169
+ latchSet(w){
170
+ if(!w.latch)return false;
171
+ if(this.active!==w.pid){
172
+ const span=this.spans.find(s=>w.latch>=s.start&&w.latch+4<=s.start+s.size);
173
+ if(span){
174
+ const b=this.backends.get(w.pid).image.get(span.key)??this.initial.get(span.key);
175
+ return new DataView(b.buffer,b.byteOffset+w.latch-span.start,4).getInt32(0,true)!==0;
176
+ }
177
+ }
178
+ return new DataView(this.mod.HEAPU8.buffer).getInt32(w.latch,true)!==0;
179
+ }
180
+ sleep(latch,timeout,cooperative=false,kind=cooperative?'yield':latch?'latch':'timer'){
181
+ const pid=this.active;assert(this.busy&&this.backends.has(pid));assert(!this.parked.has(pid));
182
+ if(latch&&new DataView(this.mod.HEAPU8.buffer).getInt32(latch,true)!==0)return Promise.resolve(1);
183
+ return new Promise(resolve=>{
184
+ const osService=this.osActivations.has(pid);
185
+ const w={pid,latch,timeout,cooperative,osService,kind,sp:this.mod.stackSave(),resolve,queued:false};
186
+ this.parked.set(pid,w);if(!cooperative&&!osService)this.waits.push(w);this.save();this.busy=false;
187
+ this.event({event:kind==='spi'?'spi-park':cooperative?'yield':'park',pid,latch,timeout});
188
+ if(timeout>=0)w.timeoutHandle=setTimeout(()=>{w.timedOut=true;this.kick();},timeout);
189
+ if(!cooperative&&!osService){
190
+ for(const notify of this.parkingObservers.get(pid)??[])notify(w);
191
+ this.parkingObservers.delete(pid);this.onWait?.(w);
192
+ }
193
+ this.kick();
194
+ });
195
+ }
196
+ resumeSPI(pid){
197
+ const waiter=this.parked.get(pid);
198
+ assert(waiter?.kind==='spi'&&!waiter.released,'no resumable SPI boundary');
199
+ waiter.released=true;this.kick();
200
+ }
201
+ waitUntilParked(pid){
202
+ if(this.parked.has(pid)&&!this.parked.get(pid).cooperative&&!this.parked.get(pid).osService)return Promise.resolve(this.parked.get(pid));
203
+ return Promise.race([new Promise(resolve=>{const a=this.parkingObservers.get(pid)??[];a.push(resolve);this.parkingObservers.set(pid,a);}),this.failureNotification.then(e=>{throw e;})]);
204
+ }
205
+ timer(which,sec,usec){
206
+ if(which!==0)return -1;
207
+ const pid=this.active;if(pid===null)return 0;
208
+ clearTimeout(this.timers.get(pid));this.timers.delete(pid);
209
+ const ms=sec*1000+usec/1000;
210
+ this.event({event:'timer-arm',pid,milliseconds:ms});
211
+ if(ms>0){
212
+ const handle=setTimeout(()=>{
213
+ this.timers.delete(pid);
214
+ this.event({event:'timer-fire',pid});
215
+ if(this.backends.has(pid))this.signal(pid,14);
216
+ },Math.max(1,ms));this.timers.set(pid,handle);
217
+ }
218
+ return 0;
219
+ }
220
+ startCheckpoint(flags){
221
+ const owner=this.active,ticket=this.nextCheckpointTicket++;
222
+ assert(ticket>0&&ticket<0x7fffffff,'checkpoint ticket ceiling');
223
+ assert(owner!==42&&this.backends.has(owner),'checkpoint requester outside backend lifetime');
224
+ const request={ticket,owner,flags,done:false,waiter:null};this.checkpointTickets.set(ticket,request);
225
+ this.event({event:'checkpoint-request',pid:owner,ticket,flags});
226
+ this.schedule(42,()=>this.runCheckpoint(request)).then(()=>{
227
+ request.done=true;this.event({event:'checkpoint-complete',ticket});this.kick();
228
+ },cause=>this.fail(new Error('checkpoint coordinator failed',{cause})));
229
+ return ticket;
230
+ }
231
+ async runCheckpoint(request){
232
+ const m=this.mod,sp=m.stackSave();this.asyncEntries.add(42);this.osActivations.add(42);
233
+ try{assert.equal(await m._pgl_sessions_checkpoint_request(request.flags),1,'checkpoint coordinator did not complete');}
234
+ finally{this.osActivations.delete(42);this.asyncEntries.delete(42);m.stackRestore(sp);}
235
+ }
236
+ waitCheckpoint(ticket){
237
+ const request=this.checkpointTickets.get(ticket),pid=this.active;
238
+ assert(request&&request.owner===pid,'invalid checkpoint waiter');
239
+ assert(this.busy&&!this.parked.has(pid)&&!request.waiter,'overlapping checkpoint waiter');
240
+ if(request.done)return Promise.resolve(1);
241
+ return new Promise(resolve=>{
242
+ const w={kind:'service',pid,request,sp:this.mod.stackSave(),resolve,queued:false,notified:false};
243
+ request.waiter=w;this.parked.set(pid,w);this.save();this.busy=false;
244
+ this.event({event:'service-park',pid,ticket});this.kick();
245
+ });
246
+ }
247
+ releaseCheckpoint(ticket){
248
+ const request=this.checkpointTickets.get(ticket);
249
+ assert(request&&request.owner===this.active&&!request.waiter,'invalid checkpoint ticket release');
250
+ this.checkpointTickets.delete(ticket);this.event({event:'checkpoint-release',ticket,done:request.done});
251
+ // The scheduled kernel request owns its own reference and continues even
252
+ // when native CHECK_FOR_INTERRUPTS unwinds its abandoned caller.
253
+ }
254
+ nextSyncRequest(tag,size,type){
255
+ assert.equal(this.active,42,'sync mailbox consumed outside coordinator');
256
+ const request=this.syncMailbox[0];if(!request)return 0;
257
+ assert.equal(size,request.bytes.length,'FileTag ABI mismatch');
258
+ this.mod.HEAPU8.set(request.bytes,tag);new DataView(this.mod.HEAPU8.buffer).setInt32(type,request.type,true);
259
+ this.syncMailbox.shift();return 1;
260
+ }
261
+ syncRequest(tag,size,type){
262
+ const caller=this.active;
263
+ assert(this.backends.has(42)&&this.backends.has(caller)&&caller!==42,'sync service outside backend lifetime');
264
+ assert(Number.isInteger(size)&&size>0&&size<=256,'invalid FileTag size');
265
+ this.syncMailbox.push({bytes:this.mod.HEAPU8.slice(tag,tag+size),type});
266
+ // A live coordinator consumes its mailbox only from the native Absorb
267
+ // boundary. Never reenter its suspended checkpoint activation.
268
+ if(this.operations.has(42)||this.parked.has(42))return 1;
269
+ this.synchronousDepth++;
270
+ try{this.select(42);assert.equal(this.mod._pgl_sessions_absorb_sync_service(),1,'sync mailbox registration failed');return 1;}
271
+ catch(cause){const error=new Error('sync coordinator failed',{cause});this.fail(error);throw error;}
272
+ finally{this.select(caller);this.synchronousDepth--;}
273
+ }
274
+ signal(pid,sig){
275
+ if(!this.backends.has(pid))return;
276
+ const signals=this.signals.get(pid)??new Set();signals.add(sig);this.signals.set(pid,signals);
277
+ // Idle and parked backends both receive the real C signal handler with
278
+ // their own private globals selected. It sets the real latch/interrupts.
279
+ this.schedule(pid,()=>this.serviceIdle(pid),true).catch(e=>this.fail(e));
280
+ }
281
+ async serviceIdle(pid){
282
+ const waiter=this.parked.get(pid);
283
+ if(waiter?.kind==='service'){waiter.notified=true;this.kick();return;}
284
+ if(this.operations.has(pid)||waiter)return;
285
+ const m=this.mod,sp=m.stackSave(),io=this.io(Buffer.alloc(0),bytes=>this.onAsyncData?.(pid,bytes));
286
+ const operation={idle:true};this.operations.set(pid,operation);let exit;
287
+ this.asyncEntries.add(pid);
288
+ try{await m._pgl_sessions_idle_interrupt();}
289
+ catch(e){if(e.status===undefined||!hasFatalResponse(Buffer.concat(io.output)))throw e;exit=e.status;}
290
+ finally{this.asyncEntries.delete(pid);this.operations.delete(pid);io.finish();m.stackRestore(sp);}
291
+ if(exit!==undefined){this.retire(pid);this.onBackendExit?.({pid,status:exit});}
292
+ }
293
+ io(input,onData){
294
+ const m=this.mod;let offset=0;const output=[];
295
+ const read=m.addFunction((ptr,n)=>{const len=Math.min(n,input.length-offset);m.HEAPU8.set(input.subarray(offset,offset+len),ptr);offset+=len;return len;},'ipi');
296
+ const write=m.addFunction((ptr,n)=>{const b=Buffer.from(m.HEAPU8.slice(ptr,ptr+n));output.push(b);onData?.(b);return n;},'ipi');
297
+ const lookup=name=>{const v=this.layout.inputs.find(x=>x.input.endsWith('.'+name));assert(v,'missing IO shim section');return v.start;};
298
+ const view=new DataView(m.HEAPU8.buffer),readAddr=lookup('pgl_read'),writeAddr=lookup('pgl_write');
299
+ const oldRead=view.getUint32(readAddr,true),oldWrite=view.getUint32(writeAddr,true);
300
+ m._pgl_set_rw_cbs(read,write);
301
+ return {output,get remaining(){return input.length-offset;},finish(){m._pgl_set_rw_cbs(oldRead,oldWrite);m.removeFunction(read);m.removeFunction(write);}};
302
+ }
303
+ async attach(pid,packet=startup('l2-backend')){
304
+ assert(!this.backends.has(pid));
305
+ const slot=this.freeSlots.pop()??this.nextSlot++;
306
+ const path='/tmp/l2-child-'+pid;
307
+ await this.schedule(42,()=>{
308
+ const m=this.mod,sp=m.stackSave(),p=m.stringToUTF8OnStack(path);
309
+ try{assert.equal(m._pgl_sessions_prepare_child(slot,p,pid),0,'child serialization failed');}finally{m.stackRestore(sp);}
310
+ });
311
+ // Create the stack before restoring the clean child-private template. The
312
+ // allocator and virtual filesystem remain shared, as they do in WAIT.
313
+ await this.schedule(42,()=>{
314
+ const stack=this.mod._pgl_sessions_stack();assert(stack>0);const sp=stack+8*1024*1024;
315
+ this.backends.set(pid,{pid,slot,stack,sp,image:new Map(this.pristine)});
316
+ });
317
+ return this.schedule(pid,async()=>{
318
+ const m=this.mod,b=this.backends.get(pid);m._pgl_setPGliteActive(1);m._pgl_sessions_setpid(pid);m.stackRestore(b.sp);
319
+ const io=this.io(packet);let exit;
320
+ try{exit=await m.callMain(['--forkchild=backend',path]);}
321
+ finally{m.stackRestore(b.sp);io.finish();}
322
+ const bytes=Buffer.concat(io.output),response=parseWire(bytes);
323
+ if(exit!==99&&hasFatalResponse(bytes)){
324
+ this.retire(pid);throw new BackendStartExit(exit,bytes);
325
+ }
326
+ assert.equal(exit,99,JSON.stringify(response));assert(!response.results.some(x=>x.error),JSON.stringify(response));
327
+ this.log.push({event:'child-entry',pid,slot,exit,startup:response});return bytes;
328
+ });
329
+ }
330
+ raw(pid,input,onData){
331
+ return this.schedule(pid,async()=>{
332
+ const m=this.mod,sp=m.stackSave(),io=this.io(input,onData);let exit;
333
+ this.asyncEntries.add(pid);
334
+ try {
335
+ while(io.remaining>0||m._pq_buffer_remaining_data()>0){
336
+ try{await m._PostgresMainLoopOnce();}
337
+ catch(e){
338
+ m.stackRestore(sp);
339
+ if(e.status===100){this.synchronousDepth++;try{m._PostgresMainLongJmp();}finally{this.synchronousDepth--;}continue;}
340
+ if(e.status===undefined||!hasFatalResponse(Buffer.concat(io.output)))throw e;
341
+ exit=e.status;break;
342
+ }
343
+ }
344
+ if(exit===undefined){m._PostgresSendReadyForQueryIfNecessary();m._pgl_pq_flush();}
345
+ } finally {this.asyncEntries.delete(pid);io.finish();m.stackRestore(sp);}
346
+ const bytes=Buffer.concat(io.output);this.onProtocol?.({pid,bytes});
347
+ if(exit!==undefined){this.retire(pid);this.onBackendExit?.({pid,status:exit});}
348
+ return bytes;
349
+ });
350
+ }
351
+ async query(pid,sql){const bytes=await this.raw(pid,simpleQuery(sql));return parseWire(bytes);}
352
+ retire(pid){
353
+ const m=this.mod,b=this.backends.get(pid);assert(b&&pid!==42&&this.active===pid,'retirement outside backend');
354
+ clearTimeout(this.timers.get(pid));this.timers.delete(pid);this.signals.delete(pid);this.parkingObservers.delete(pid);this.asyncEntries.delete(pid);
355
+ assert(!this.parked.has(pid),'retiring a suspended backend');
356
+ for(const [ticket,request]of this.checkpointTickets)if(request.owner===pid){assert(!request.waiter,'retiring a live checkpoint waiter');this.checkpointTickets.delete(ticket);this.event({event:'checkpoint-owner-exit',ticket,done:request.done});}
357
+ const releasedAllocations=m._pgl_sessions_cleanup_memory();let closedDescriptors=0;
358
+ for(const [fd,owner]of [...this.descriptorOwners])if(owner.pid===pid){
359
+ if(m.FS.streams[fd]===owner.stream){m.FS.close(owner.stream);closedDescriptors++;}
360
+ else this.descriptorOwners.delete(fd);
361
+ }
362
+ this.log.push({event:'backend-closed',pid,slot:b.slot,releasedAllocations,closedDescriptors});
363
+ this.save();this.active=null;this.backends.delete(pid);
364
+ const release=()=>{
365
+ assert.equal(m._pgl_sessions_release_child(b.slot),0,'backend slot not safely retired');
366
+ m._free(b.stack);this.freeSlots.push(b.slot);
367
+ };
368
+ if(this.operations.has(42)||this.parked.has(42))this.schedule(42,release).catch(e=>this.fail(e));
369
+ else{this.select(42);release();}
370
+ }
371
+ async disconnect(pid){
372
+ if(!this.backends.has(pid)||pid===42)return;
373
+ const waiter=this.parked.get(pid);
374
+ if(waiter)this.signal(pid,2);
375
+ if(waiter?.kind==='spi'&&!waiter.released)this.resumeSPI(pid);
376
+ await this.schedule(pid,async()=>{
377
+ const m=this.mod,b=this.backends.get(pid),sp=m.stackSave(),io=this.io(Buffer.from([88,0,0,0,4]));
378
+ m._pgl_setPGliteActive(0);
379
+ try{await m._PostgresMainLoopOnce();}catch(e){if(e.status!==0)throw e;}
380
+ finally{io.finish();m.stackRestore(sp);m._pgl_setPGliteActive(1);}
381
+ this.retire(pid);
382
+ });
383
+ }
384
+ async close(){
385
+ for(const pid of [...this.backends.keys()].filter(p=>p!==42))await this.disconnect(pid);
386
+ for(const t of this.timers.values())clearTimeout(t);this.timers.clear();
387
+ await this.schedule(42,()=>this.db.close());
388
+ }
389
+ }
390
+ export const createHost=options=>EngineHost.create(options);