@elaraai/e3-web 0.0.0-stage → 1.0.85

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 (303) hide show
  1. package/LICENSE.md +54 -0
  2. package/README.md +395 -2
  3. package/dist/src/app.d.ts +91 -0
  4. package/dist/src/app.d.ts.map +1 -0
  5. package/dist/src/app.js +112 -0
  6. package/dist/src/app.js.map +1 -0
  7. package/dist/src/bridge/bridge.spec.d.ts +6 -0
  8. package/dist/src/bridge/bridge.spec.d.ts.map +1 -0
  9. package/dist/src/bridge/bridge.spec.js +56 -0
  10. package/dist/src/bridge/bridge.spec.js.map +1 -0
  11. package/dist/src/bridge/page.d.ts +149 -0
  12. package/dist/src/bridge/page.d.ts.map +1 -0
  13. package/dist/src/bridge/page.js +328 -0
  14. package/dist/src/bridge/page.js.map +1 -0
  15. package/dist/src/bridge/protocol.d.ts +181 -0
  16. package/dist/src/bridge/protocol.d.ts.map +1 -0
  17. package/dist/src/bridge/protocol.js +113 -0
  18. package/dist/src/bridge/protocol.js.map +1 -0
  19. package/dist/src/bridge/worker.d.ts +124 -0
  20. package/dist/src/bridge/worker.d.ts.map +1 -0
  21. package/dist/src/bridge/worker.js +185 -0
  22. package/dist/src/bridge/worker.js.map +1 -0
  23. package/dist/src/browser/bridge.page.d.ts +12 -0
  24. package/dist/src/browser/bridge.page.d.ts.map +1 -0
  25. package/dist/src/browser/bridge.page.js +79 -0
  26. package/dist/src/browser/bridge.page.js.map +1 -0
  27. package/dist/src/browser/bridge.spec.d.ts +6 -0
  28. package/dist/src/browser/bridge.spec.d.ts.map +1 -0
  29. package/dist/src/browser/bridge.spec.js +105 -0
  30. package/dist/src/browser/bridge.spec.js.map +1 -0
  31. package/dist/src/browser/bridge.worker.d.ts +6 -0
  32. package/dist/src/browser/bridge.worker.d.ts.map +1 -0
  33. package/dist/src/browser/bridge.worker.js +35 -0
  34. package/dist/src/browser/bridge.worker.js.map +1 -0
  35. package/dist/src/browser/compliance.d.ts +68 -0
  36. package/dist/src/browser/compliance.d.ts.map +1 -0
  37. package/dist/src/browser/compliance.js +30 -0
  38. package/dist/src/browser/compliance.js.map +1 -0
  39. package/dist/src/browser/compliance.page.d.ts +6 -0
  40. package/dist/src/browser/compliance.page.d.ts.map +1 -0
  41. package/dist/src/browser/compliance.page.js +204 -0
  42. package/dist/src/browser/compliance.page.js.map +1 -0
  43. package/dist/src/browser/compliance.spec.d.ts +6 -0
  44. package/dist/src/browser/compliance.spec.d.ts.map +1 -0
  45. package/dist/src/browser/compliance.spec.js +147 -0
  46. package/dist/src/browser/compliance.spec.js.map +1 -0
  47. package/dist/src/browser/e3-api-1.spec.d.ts +6 -0
  48. package/dist/src/browser/e3-api-1.spec.d.ts.map +1 -0
  49. package/dist/src/browser/e3-api-1.spec.js +12 -0
  50. package/dist/src/browser/e3-api-1.spec.js.map +1 -0
  51. package/dist/src/browser/e3-api-2.spec.d.ts +6 -0
  52. package/dist/src/browser/e3-api-2.spec.d.ts.map +1 -0
  53. package/dist/src/browser/e3-api-2.spec.js +12 -0
  54. package/dist/src/browser/e3-api-2.spec.js.map +1 -0
  55. package/dist/src/browser/e3-api-3.spec.d.ts +6 -0
  56. package/dist/src/browser/e3-api-3.spec.d.ts.map +1 -0
  57. package/dist/src/browser/e3-api-3.spec.js +12 -0
  58. package/dist/src/browser/e3-api-3.spec.js.map +1 -0
  59. package/dist/src/browser/e3-api-parts.spec.d.ts +6 -0
  60. package/dist/src/browser/e3-api-parts.spec.d.ts.map +1 -0
  61. package/dist/src/browser/e3-api-parts.spec.js +45 -0
  62. package/dist/src/browser/e3-api-parts.spec.js.map +1 -0
  63. package/dist/src/browser/e3-api.d.ts +28 -0
  64. package/dist/src/browser/e3-api.d.ts.map +1 -0
  65. package/dist/src/browser/e3-api.js +144 -0
  66. package/dist/src/browser/e3-api.js.map +1 -0
  67. package/dist/src/browser/e3-client.worker.d.ts +6 -0
  68. package/dist/src/browser/e3-client.worker.d.ts.map +1 -0
  69. package/dist/src/browser/e3-client.worker.js +19 -0
  70. package/dist/src/browser/e3-client.worker.js.map +1 -0
  71. package/dist/src/browser/e3-forward.d.ts +27 -0
  72. package/dist/src/browser/e3-forward.d.ts.map +1 -0
  73. package/dist/src/browser/e3-forward.js +81 -0
  74. package/dist/src/browser/e3-forward.js.map +1 -0
  75. package/dist/src/browser/e3-forward.spec.d.ts +6 -0
  76. package/dist/src/browser/e3-forward.spec.d.ts.map +1 -0
  77. package/dist/src/browser/e3-forward.spec.js +84 -0
  78. package/dist/src/browser/e3-forward.spec.js.map +1 -0
  79. package/dist/src/browser/e3-port.worker.d.ts +6 -0
  80. package/dist/src/browser/e3-port.worker.d.ts.map +1 -0
  81. package/dist/src/browser/e3-port.worker.js +21 -0
  82. package/dist/src/browser/e3-port.worker.js.map +1 -0
  83. package/dist/src/browser/e3-unit.worker.d.ts +6 -0
  84. package/dist/src/browser/e3-unit.worker.d.ts.map +1 -0
  85. package/dist/src/browser/e3-unit.worker.js +18 -0
  86. package/dist/src/browser/e3-unit.worker.js.map +1 -0
  87. package/dist/src/browser/e3-wire.d.ts +43 -0
  88. package/dist/src/browser/e3-wire.d.ts.map +1 -0
  89. package/dist/src/browser/e3-wire.js +32 -0
  90. package/dist/src/browser/e3-wire.js.map +1 -0
  91. package/dist/src/browser/e3.page.d.ts +21 -0
  92. package/dist/src/browser/e3.page.d.ts.map +1 -0
  93. package/dist/src/browser/e3.page.js +119 -0
  94. package/dist/src/browser/e3.page.js.map +1 -0
  95. package/dist/src/browser/e3.spec.d.ts +6 -0
  96. package/dist/src/browser/e3.spec.d.ts.map +1 -0
  97. package/dist/src/browser/e3.spec.js +358 -0
  98. package/dist/src/browser/e3.spec.js.map +1 -0
  99. package/dist/src/browser/e3.worker.d.ts +6 -0
  100. package/dist/src/browser/e3.worker.d.ts.map +1 -0
  101. package/dist/src/browser/e3.worker.js +38 -0
  102. package/dist/src/browser/e3.worker.js.map +1 -0
  103. package/dist/src/browser/harness.d.ts +175 -0
  104. package/dist/src/browser/harness.d.ts.map +1 -0
  105. package/dist/src/browser/harness.js +375 -0
  106. package/dist/src/browser/harness.js.map +1 -0
  107. package/dist/src/browser/page.d.ts +47 -0
  108. package/dist/src/browser/page.d.ts.map +1 -0
  109. package/dist/src/browser/page.js +47 -0
  110. package/dist/src/browser/page.js.map +1 -0
  111. package/dist/src/browser/repository.page.d.ts +85 -0
  112. package/dist/src/browser/repository.page.d.ts.map +1 -0
  113. package/dist/src/browser/repository.page.js +271 -0
  114. package/dist/src/browser/repository.page.js.map +1 -0
  115. package/dist/src/browser/runner.page.d.ts +6 -0
  116. package/dist/src/browser/runner.page.d.ts.map +1 -0
  117. package/dist/src/browser/runner.page.js +62 -0
  118. package/dist/src/browser/runner.page.js.map +1 -0
  119. package/dist/src/browser/runner.spec.d.ts +6 -0
  120. package/dist/src/browser/runner.spec.d.ts.map +1 -0
  121. package/dist/src/browser/runner.spec.js +46 -0
  122. package/dist/src/browser/runner.spec.js.map +1 -0
  123. package/dist/src/browser/storage.page.d.ts +6 -0
  124. package/dist/src/browser/storage.page.d.ts.map +1 -0
  125. package/dist/src/browser/storage.page.js +289 -0
  126. package/dist/src/browser/storage.page.js.map +1 -0
  127. package/dist/src/browser/storage.spec.d.ts +6 -0
  128. package/dist/src/browser/storage.spec.d.ts.map +1 -0
  129. package/dist/src/browser/storage.spec.js +211 -0
  130. package/dist/src/browser/storage.spec.js.map +1 -0
  131. package/dist/src/browser/unit.worker.d.ts +6 -0
  132. package/dist/src/browser/unit.worker.d.ts.map +1 -0
  133. package/dist/src/browser/unit.worker.js +17 -0
  134. package/dist/src/browser/unit.worker.js.map +1 -0
  135. package/dist/src/execution/WebTaskRunner.d.ts +159 -0
  136. package/dist/src/execution/WebTaskRunner.d.ts.map +1 -0
  137. package/dist/src/execution/WebTaskRunner.js +581 -0
  138. package/dist/src/execution/WebTaskRunner.js.map +1 -0
  139. package/dist/src/execution/WebTaskRunner.spec.d.ts +6 -0
  140. package/dist/src/execution/WebTaskRunner.spec.d.ts.map +1 -0
  141. package/dist/src/execution/WebTaskRunner.spec.js +91 -0
  142. package/dist/src/execution/WebTaskRunner.spec.js.map +1 -0
  143. package/dist/src/execution/e3-platform.d.ts +41 -0
  144. package/dist/src/execution/e3-platform.d.ts.map +1 -0
  145. package/dist/src/execution/e3-platform.js +52 -0
  146. package/dist/src/execution/e3-platform.js.map +1 -0
  147. package/dist/src/execution/in-process.d.ts +32 -0
  148. package/dist/src/execution/in-process.d.ts.map +1 -0
  149. package/dist/src/execution/in-process.js +89 -0
  150. package/dist/src/execution/in-process.js.map +1 -0
  151. package/dist/src/execution/pool.d.ts +172 -0
  152. package/dist/src/execution/pool.d.ts.map +1 -0
  153. package/dist/src/execution/pool.js +352 -0
  154. package/dist/src/execution/pool.js.map +1 -0
  155. package/dist/src/execution/pool.spec.d.ts +6 -0
  156. package/dist/src/execution/pool.spec.d.ts.map +1 -0
  157. package/dist/src/execution/pool.spec.js +252 -0
  158. package/dist/src/execution/pool.spec.js.map +1 -0
  159. package/dist/src/execution/protocol.d.ts +108 -0
  160. package/dist/src/execution/protocol.d.ts.map +1 -0
  161. package/dist/src/execution/protocol.js +27 -0
  162. package/dist/src/execution/protocol.js.map +1 -0
  163. package/dist/src/execution/unit-server.d.ts +131 -0
  164. package/dist/src/execution/unit-server.d.ts.map +1 -0
  165. package/dist/src/execution/unit-server.js +142 -0
  166. package/dist/src/execution/unit-server.js.map +1 -0
  167. package/dist/src/index.d.ts +39 -0
  168. package/dist/src/index.d.ts.map +1 -0
  169. package/dist/src/index.js +37 -0
  170. package/dist/src/index.js.map +1 -0
  171. package/dist/src/index.spec.d.ts +6 -0
  172. package/dist/src/index.spec.d.ts.map +1 -0
  173. package/dist/src/index.spec.js +212 -0
  174. package/dist/src/index.spec.js.map +1 -0
  175. package/dist/src/node.d.ts +12 -0
  176. package/dist/src/node.d.ts.map +1 -0
  177. package/dist/src/node.js +12 -0
  178. package/dist/src/node.js.map +1 -0
  179. package/dist/src/storage/WebStateStore.d.ts +64 -0
  180. package/dist/src/storage/WebStateStore.d.ts.map +1 -0
  181. package/dist/src/storage/WebStateStore.js +237 -0
  182. package/dist/src/storage/WebStateStore.js.map +1 -0
  183. package/dist/src/storage/WebStorage.d.ts +225 -0
  184. package/dist/src/storage/WebStorage.d.ts.map +1 -0
  185. package/dist/src/storage/WebStorage.js +1462 -0
  186. package/dist/src/storage/WebStorage.js.map +1 -0
  187. package/dist/src/storage/adapters.d.ts +610 -0
  188. package/dist/src/storage/adapters.d.ts.map +1 -0
  189. package/dist/src/storage/adapters.js +246 -0
  190. package/dist/src/storage/adapters.js.map +1 -0
  191. package/dist/src/storage/indexeddb.d.ts +93 -0
  192. package/dist/src/storage/indexeddb.d.ts.map +1 -0
  193. package/dist/src/storage/indexeddb.js +384 -0
  194. package/dist/src/storage/indexeddb.js.map +1 -0
  195. package/dist/src/storage/indexeddb.spec.d.ts +6 -0
  196. package/dist/src/storage/indexeddb.spec.d.ts.map +1 -0
  197. package/dist/src/storage/indexeddb.spec.js +77 -0
  198. package/dist/src/storage/indexeddb.spec.js.map +1 -0
  199. package/dist/src/storage/memory.d.ts +275 -0
  200. package/dist/src/storage/memory.d.ts.map +1 -0
  201. package/dist/src/storage/memory.js +724 -0
  202. package/dist/src/storage/memory.js.map +1 -0
  203. package/dist/src/storage/memory.spec.d.ts +6 -0
  204. package/dist/src/storage/memory.spec.d.ts.map +1 -0
  205. package/dist/src/storage/memory.spec.js +71 -0
  206. package/dist/src/storage/memory.spec.js.map +1 -0
  207. package/dist/src/storage/node-files.d.ts +38 -0
  208. package/dist/src/storage/node-files.d.ts.map +1 -0
  209. package/dist/src/storage/node-files.js +148 -0
  210. package/dist/src/storage/node-files.js.map +1 -0
  211. package/dist/src/storage/node-files.spec.d.ts +6 -0
  212. package/dist/src/storage/node-files.spec.d.ts.map +1 -0
  213. package/dist/src/storage/node-files.spec.js +40 -0
  214. package/dist/src/storage/node-files.spec.js.map +1 -0
  215. package/dist/src/storage/opfs.d.ts +145 -0
  216. package/dist/src/storage/opfs.d.ts.map +1 -0
  217. package/dist/src/storage/opfs.js +514 -0
  218. package/dist/src/storage/opfs.js.map +1 -0
  219. package/dist/src/storage/opfs.spec.d.ts +6 -0
  220. package/dist/src/storage/opfs.spec.d.ts.map +1 -0
  221. package/dist/src/storage/opfs.spec.js +51 -0
  222. package/dist/src/storage/opfs.spec.js.map +1 -0
  223. package/dist/src/storage/record-keys.d.ts +78 -0
  224. package/dist/src/storage/record-keys.d.ts.map +1 -0
  225. package/dist/src/storage/record-keys.js +71 -0
  226. package/dist/src/storage/record-keys.js.map +1 -0
  227. package/dist/src/storage/stores.spec.d.ts +6 -0
  228. package/dist/src/storage/stores.spec.d.ts.map +1 -0
  229. package/dist/src/storage/stores.spec.js +326 -0
  230. package/dist/src/storage/stores.spec.js.map +1 -0
  231. package/dist/src/storage/web-locks.d.ts +103 -0
  232. package/dist/src/storage/web-locks.d.ts.map +1 -0
  233. package/dist/src/storage/web-locks.js +228 -0
  234. package/dist/src/storage/web-locks.js.map +1 -0
  235. package/dist/src/testing/adapter-contract.d.ts +116 -0
  236. package/dist/src/testing/adapter-contract.d.ts.map +1 -0
  237. package/dist/src/testing/adapter-contract.js +769 -0
  238. package/dist/src/testing/adapter-contract.js.map +1 -0
  239. package/dist/src/testing/assert.d.ts +75 -0
  240. package/dist/src/testing/assert.d.ts.map +1 -0
  241. package/dist/src/testing/assert.js +146 -0
  242. package/dist/src/testing/assert.js.map +1 -0
  243. package/dist/src/testing/assert.spec.d.ts +6 -0
  244. package/dist/src/testing/assert.spec.d.ts.map +1 -0
  245. package/dist/src/testing/assert.spec.js +62 -0
  246. package/dist/src/testing/assert.spec.js.map +1 -0
  247. package/dist/src/testing/bridge-contract.d.ts +55 -0
  248. package/dist/src/testing/bridge-contract.d.ts.map +1 -0
  249. package/dist/src/testing/bridge-contract.js +376 -0
  250. package/dist/src/testing/bridge-contract.js.map +1 -0
  251. package/dist/src/testing/bridge-handler.d.ts +35 -0
  252. package/dist/src/testing/bridge-handler.d.ts.map +1 -0
  253. package/dist/src/testing/bridge-handler.js +108 -0
  254. package/dist/src/testing/bridge-handler.js.map +1 -0
  255. package/dist/src/testing/callers.d.ts +29 -0
  256. package/dist/src/testing/callers.d.ts.map +1 -0
  257. package/dist/src/testing/callers.js +24 -0
  258. package/dist/src/testing/callers.js.map +1 -0
  259. package/dist/src/testing/e3-fixtures.d.ts +38 -0
  260. package/dist/src/testing/e3-fixtures.d.ts.map +1 -0
  261. package/dist/src/testing/e3-fixtures.js +126 -0
  262. package/dist/src/testing/e3-fixtures.js.map +1 -0
  263. package/dist/src/testing/hold-platform.d.ts +33 -0
  264. package/dist/src/testing/hold-platform.d.ts.map +1 -0
  265. package/dist/src/testing/hold-platform.js +41 -0
  266. package/dist/src/testing/hold-platform.js.map +1 -0
  267. package/dist/src/testing/runner-cases.d.ts +112 -0
  268. package/dist/src/testing/runner-cases.d.ts.map +1 -0
  269. package/dist/src/testing/runner-cases.js +959 -0
  270. package/dist/src/testing/runner-cases.js.map +1 -0
  271. package/dist/src/testing/runner-fixtures.d.ts +13 -0
  272. package/dist/src/testing/runner-fixtures.d.ts.map +1 -0
  273. package/dist/src/testing/runner-fixtures.js +173 -0
  274. package/dist/src/testing/runner-fixtures.js.map +1 -0
  275. package/dist/src/testing/test-platform.d.ts +73 -0
  276. package/dist/src/testing/test-platform.d.ts.map +1 -0
  277. package/dist/src/testing/test-platform.js +143 -0
  278. package/dist/src/testing/test-platform.js.map +1 -0
  279. package/dist/src/transfer/WebTransferBackend.d.ts +780 -0
  280. package/dist/src/transfer/WebTransferBackend.d.ts.map +1 -0
  281. package/dist/src/transfer/WebTransferBackend.js +1140 -0
  282. package/dist/src/transfer/WebTransferBackend.js.map +1 -0
  283. package/dist/src/transfer/WebTransferBackend.spec.d.ts +6 -0
  284. package/dist/src/transfer/WebTransferBackend.spec.d.ts.map +1 -0
  285. package/dist/src/transfer/WebTransferBackend.spec.js +582 -0
  286. package/dist/src/transfer/WebTransferBackend.spec.js.map +1 -0
  287. package/dist/src/transfer/endpoints.d.ts +46 -0
  288. package/dist/src/transfer/endpoints.d.ts.map +1 -0
  289. package/dist/src/transfer/endpoints.js +157 -0
  290. package/dist/src/transfer/endpoints.js.map +1 -0
  291. package/dist/src/units.d.ts +51 -0
  292. package/dist/src/units.d.ts.map +1 -0
  293. package/dist/src/units.js +74 -0
  294. package/dist/src/units.js.map +1 -0
  295. package/dist/src/worker.d.ts +126 -0
  296. package/dist/src/worker.d.ts.map +1 -0
  297. package/dist/src/worker.js +186 -0
  298. package/dist/src/worker.js.map +1 -0
  299. package/dist/src/worker.spec.d.ts +6 -0
  300. package/dist/src/worker.spec.d.ts.map +1 -0
  301. package/dist/src/worker.spec.js +195 -0
  302. package/dist/src/worker.spec.js.map +1 -0
  303. package/package.json +76 -3
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Where each record a `WebStorage` keeps is, in its records adapter: the keys
7
+ * its stores and the run state store over the same records share.
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ import type { RecordKey } from './adapters.js';
12
+ /**
13
+ * The key of each record `WebStorage` keeps, in its records adapter.
14
+ *
15
+ * @remarks
16
+ * A repository's metadata is `['repos', name]`, and everything else of it is
17
+ * under `['repo', name]`, so its records scan and delete by that prefix. The
18
+ * execution state store over the same records keeps a run's state at
19
+ * {@link recordKeys.state}, and its events at {@link recordKeys.events}, which
20
+ * a workspace's removal deletes with its other records.
21
+ */
22
+ export declare const recordKeys: {
23
+ /** A repository's metadata */
24
+ repository: (repo: string) => RecordKey;
25
+ /** Every repository's metadata */
26
+ repositories: () => RecordKey;
27
+ /** Everything of a repository but its metadata */
28
+ of: (repo: string) => RecordKey;
29
+ /** A kind of a repository's records */
30
+ kind: (repo: string, kind: string) => RecordKey;
31
+ /** The repository record */
32
+ record: (repo: string) => RecordKey;
33
+ /** The store upgrade under way, and where its last part stopped, while one is */
34
+ upgrade: (repo: string) => RecordKey;
35
+ /** A package's ref: the package object's hash */
36
+ package: (repo: string, name: string, version: string) => RecordKey;
37
+ /** A workspace's record */
38
+ workspace: (repo: string, name: string) => RecordKey;
39
+ /** An execution attempt's status */
40
+ execution: (repo: string, task: string, inputs: string, id: string) => RecordKey;
41
+ /** An execution attempt's owner */
42
+ owner: (repo: string, task: string, inputs: string, id: string) => RecordKey;
43
+ /** An execution attempt's place in its task's index of the attempts
44
+ * recorded running: an East `null`, there while it is */
45
+ running: (repo: string, task: string, inputs: string, id: string) => RecordKey;
46
+ /** A run's place in its task's index of its runs — its own attempts, never
47
+ * a split task's units — by its id first, so the index scans in the order
48
+ * the runs began: an East `null` */
49
+ taskRun: (repo: string, task: string, id: string, inputs: string) => RecordKey;
50
+ /** The `$plan` a split task's execution is in */
51
+ plan: (repo: string, task: string, inputs: string) => RecordKey;
52
+ /** An entry of the adoption memo */
53
+ adoption: (repo: string, source: string) => RecordKey;
54
+ /** A dataflow run's record */
55
+ run: (repo: string, workspace: string, runId: string) => RecordKey;
56
+ /** A dataset's ref, and the revision its write minted */
57
+ dataset: (repo: string, workspace: string, path: string) => RecordKey;
58
+ /** A chunk of an execution attempt's log, by the byte of the log it starts
59
+ * at, in decimal zero-padded to sixteen digits */
60
+ log: (repo: string, task: string, inputs: string, id: string, stream: string, start: string) => RecordKey;
61
+ /** The state of a resource's exclusive lock */
62
+ lock: (repo: string, resource: string) => RecordKey;
63
+ /** What a resource's exclusive holder last reported of its progress */
64
+ progress: (repo: string, resource: string) => RecordKey;
65
+ /** An object's entry in the catalogue */
66
+ object: (repo: string, hash: string) => RecordKey;
67
+ /** A write of an object's blob in flight */
68
+ pending: (repo: string, blob: string) => RecordKey;
69
+ /** A part of a gc run in steps */
70
+ gcRun: (repo: string, run: string, name: string) => RecordKey;
71
+ /** A dataflow run's state, as `WebStateStore` keeps it */
72
+ state: (repo: string, workspace: string, id: string) => RecordKey;
73
+ /** A dataflow run's events, as `WebStateStore` keeps them apart from its
74
+ * state: a segment of them under each key it extends this by, its first
75
+ * event's sequence number in decimal zero-padded to twenty digits */
76
+ events: (repo: string, workspace: string, id: string) => RecordKey;
77
+ };
78
+ //# sourceMappingURL=record-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-keys.d.ts","sourceRoot":"","sources":["../../../src/storage/record-keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU;IACrB,8BAA8B;uBACX,MAAM,KAAG,SAAS;IACrC,kCAAkC;wBAChB,SAAS;IAC3B,kDAAkD;eACvC,MAAM,KAAG,SAAS;IAC7B,uCAAuC;iBAC1B,MAAM,QAAQ,MAAM,KAAG,SAAS;IAC7C,4BAA4B;mBACb,MAAM,KAAG,SAAS;IACjC,iFAAiF;oBACjE,MAAM,KAAG,SAAS;IAClC,iDAAiD;oBACjC,MAAM,QAAQ,MAAM,WAAW,MAAM,KAAG,SAAS;IACjE,2BAA2B;sBACT,MAAM,QAAQ,MAAM,KAAG,SAAS;IAClD,oCAAoC;sBAClB,MAAM,QAAQ,MAAM,UAAU,MAAM,MAAM,MAAM,KAAG,SAAS;IAC9E,mCAAmC;kBACrB,MAAM,QAAQ,MAAM,UAAU,MAAM,MAAM,MAAM,KAAG,SAAS;IAC1E;8DAC0D;oBAC1C,MAAM,QAAQ,MAAM,UAAU,MAAM,MAAM,MAAM,KAAG,SAAS;IAC5E;;yCAEqC;oBACrB,MAAM,QAAQ,MAAM,MAAM,MAAM,UAAU,MAAM,KAAG,SAAS;IAC5E,iDAAiD;iBACpC,MAAM,QAAQ,MAAM,UAAU,MAAM,KAAG,SAAS;IAC7D,oCAAoC;qBACnB,MAAM,UAAU,MAAM,KAAG,SAAS;IACnD,8BAA8B;gBAClB,MAAM,aAAa,MAAM,SAAS,MAAM,KAAG,SAAS;IAChE,yDAAyD;oBACzC,MAAM,aAAa,MAAM,QAAQ,MAAM,KAAG,SAAS;IACnE;uDACmD;gBACvC,MAAM,QAAQ,MAAM,UAAU,MAAM,MAAM,MAAM,UAAU,MAAM,SAAS,MAAM,KAAG,SAAS;IAEvG,+CAA+C;iBAClC,MAAM,YAAY,MAAM,KAAG,SAAS;IACjD,uEAAuE;qBACtD,MAAM,YAAY,MAAM,KAAG,SAAS;IACrD,yCAAyC;mBAC1B,MAAM,QAAQ,MAAM,KAAG,SAAS;IAC/C,4CAA4C;oBAC5B,MAAM,QAAQ,MAAM,KAAG,SAAS;IAChD,kCAAkC;kBACpB,MAAM,OAAO,MAAM,QAAQ,MAAM,KAAG,SAAS;IAC3D,0DAA0D;kBAC5C,MAAM,aAAa,MAAM,MAAM,MAAM,KAAG,SAAS;IAC/D;;0EAEsE;mBACvD,MAAM,aAAa,MAAM,MAAM,MAAM,KAAG,SAAS;CACjE,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * The key of each record `WebStorage` keeps, in its records adapter.
7
+ *
8
+ * @remarks
9
+ * A repository's metadata is `['repos', name]`, and everything else of it is
10
+ * under `['repo', name]`, so its records scan and delete by that prefix. The
11
+ * execution state store over the same records keeps a run's state at
12
+ * {@link recordKeys.state}, and its events at {@link recordKeys.events}, which
13
+ * a workspace's removal deletes with its other records.
14
+ */
15
+ export const recordKeys = {
16
+ /** A repository's metadata */
17
+ repository: (repo) => ['repos', repo],
18
+ /** Every repository's metadata */
19
+ repositories: () => ['repos'],
20
+ /** Everything of a repository but its metadata */
21
+ of: (repo) => ['repo', repo],
22
+ /** A kind of a repository's records */
23
+ kind: (repo, kind) => ['repo', repo, kind],
24
+ /** The repository record */
25
+ record: (repo) => ['repo', repo, 'record'],
26
+ /** The store upgrade under way, and where its last part stopped, while one is */
27
+ upgrade: (repo) => ['repo', repo, 'upgrade'],
28
+ /** A package's ref: the package object's hash */
29
+ package: (repo, name, version) => ['repo', repo, 'package', name, version],
30
+ /** A workspace's record */
31
+ workspace: (repo, name) => ['repo', repo, 'workspace', name],
32
+ /** An execution attempt's status */
33
+ execution: (repo, task, inputs, id) => ['repo', repo, 'execution', task, inputs, id],
34
+ /** An execution attempt's owner */
35
+ owner: (repo, task, inputs, id) => ['repo', repo, 'owner', task, inputs, id],
36
+ /** An execution attempt's place in its task's index of the attempts
37
+ * recorded running: an East `null`, there while it is */
38
+ running: (repo, task, inputs, id) => ['repo', repo, 'running', task, inputs, id],
39
+ /** A run's place in its task's index of its runs — its own attempts, never
40
+ * a split task's units — by its id first, so the index scans in the order
41
+ * the runs began: an East `null` */
42
+ taskRun: (repo, task, id, inputs) => ['repo', repo, 'taskrun', task, id, inputs],
43
+ /** The `$plan` a split task's execution is in */
44
+ plan: (repo, task, inputs) => ['repo', repo, 'plan', task, inputs],
45
+ /** An entry of the adoption memo */
46
+ adoption: (repo, source) => ['repo', repo, 'adoption', source],
47
+ /** A dataflow run's record */
48
+ run: (repo, workspace, runId) => ['repo', repo, 'run', workspace, runId],
49
+ /** A dataset's ref, and the revision its write minted */
50
+ dataset: (repo, workspace, path) => ['repo', repo, 'dataset', workspace, path],
51
+ /** A chunk of an execution attempt's log, by the byte of the log it starts
52
+ * at, in decimal zero-padded to sixteen digits */
53
+ log: (repo, task, inputs, id, stream, start) => ['repo', repo, 'log', task, inputs, id, stream, start],
54
+ /** The state of a resource's exclusive lock */
55
+ lock: (repo, resource) => ['repo', repo, 'lock', resource],
56
+ /** What a resource's exclusive holder last reported of its progress */
57
+ progress: (repo, resource) => ['repo', repo, 'progress', resource],
58
+ /** An object's entry in the catalogue */
59
+ object: (repo, hash) => ['repo', repo, 'object', hash],
60
+ /** A write of an object's blob in flight */
61
+ pending: (repo, blob) => ['repo', repo, 'pending', blob],
62
+ /** A part of a gc run in steps */
63
+ gcRun: (repo, run, name) => ['repo', repo, 'gc', run, name],
64
+ /** A dataflow run's state, as `WebStateStore` keeps it */
65
+ state: (repo, workspace, id) => ['repo', repo, 'state', workspace, id],
66
+ /** A dataflow run's events, as `WebStateStore` keeps them apart from its
67
+ * state: a segment of them under each key it extends this by, its first
68
+ * event's sequence number in decimal zero-padded to twenty digits */
69
+ events: (repo, workspace, id) => ['repo', repo, 'event', workspace, id],
70
+ };
71
+ //# sourceMappingURL=record-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-keys.js","sourceRoot":"","sources":["../../../src/storage/record-keys.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,8BAA8B;IAC9B,UAAU,EAAE,CAAC,IAAY,EAAa,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC;IACxD,kCAAkC;IAClC,YAAY,EAAE,GAAc,EAAE,CAAC,CAAC,OAAO,CAAC;IACxC,kDAAkD;IAClD,EAAE,EAAE,CAAC,IAAY,EAAa,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC;IAC/C,uCAAuC;IACvC,IAAI,EAAE,CAAC,IAAY,EAAE,IAAY,EAAa,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC;IACrE,4BAA4B;IAC5B,MAAM,EAAE,CAAC,IAAY,EAAa,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC;IAC7D,iFAAiF;IACjF,OAAO,EAAE,CAAC,IAAY,EAAa,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC;IAC/D,iDAAiD;IACjD,OAAO,EAAE,CAAC,IAAY,EAAE,IAAY,EAAE,OAAe,EAAa,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC;IAC7G,2BAA2B;IAC3B,SAAS,EAAE,CAAC,I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AEsE;IACtE,MAAM,EAAE,CAAC,IAAY,EAAE,SAAiB,EAAE,EAAU,EAAa,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC;CAC3G,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=stores.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.spec.d.ts","sourceRoot":"","sources":["../../../src/storage/stores.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,326 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * e3-web's stores held to every contract suite a backend runs, in Node over
7
+ * the adapters in memory — which answer as IndexedDB, OPFS and Web Locks do,
8
+ * and which a page opened with `persist: false` keeps its repositories in —
9
+ * and the machine's files, which the suites name.
10
+ *
11
+ * Over `WebStorage`: the object, ref, dataset-ref, lock and log stores, the
12
+ * repository store, the repository record, gc, the execution cache and the
13
+ * workspace status. Over `WebStateStore`: the execution state store. Over
14
+ * both: the dataflow loop. Then what is `WebStorage`'s own, which no contract
15
+ * suite reaches: what its sweep takes of writes and deletes that never
16
+ * finished, its catalogue's scan, a lock's state that a closed tab left, a
17
+ * log read from the chunks its window covers, and a persisted storage refused
18
+ * where the browser APIs it needs are missing. The browser's own adapters are
19
+ * held to the adapters' contract in Chromium, where a repository written
20
+ * through these stores is read again after a reload
21
+ * (`../browser/storage.spec.ts`).
22
+ */
23
+ import { describe, it } from 'node:test';
24
+ import assert from 'node:assert/strict';
25
+ import { equalFor, variant } from '@elaraai/east';
26
+ import { LockProgressType } from '@elaraai/e3-types';
27
+ import { computeHash, uuidv7 } from '@elaraai/e3-core/portable';
28
+ import { dataflowTests, datasetRefStoreTests, executionCacheTests, executionStateStoreTests, gcTests, lockServiceTests, logStoreTests, objectStoreTests, refStoreTests, repoStoreTests, repositoryRecordTests, workspaceStatusTests, } from '@elaraai/e3-core/test';
29
+ import { MemoryBlobs, MemoryLockSpace, MemoryRecordStore, openMemoryRecords } from './memory.js';
30
+ import { NodeFiles } from './node-files.js';
31
+ import { WebStateStore } from './WebStateStore.js';
32
+ import { WebStorage, openWebStorage, recordKeys } from './WebStorage.js';
33
+ /** The repository each case's backend is created with. */
34
+ const REPO = 'default';
35
+ const TASK = 'a'.repeat(64);
36
+ const INPUTS = 'b'.repeat(64);
37
+ const encoder = new TextEncoder();
38
+ const decoder = new TextDecoder();
39
+ /**
40
+ * Opens storages over one origin's adapters in memory — one records store,
41
+ * one blob store and one lock space — each a tab of its own, with a session
42
+ * of its own, and closed once the test ends.
43
+ */
44
+ function origin(t, blobs = new MemoryBlobs()) {
45
+ const store = new MemoryRecordStore();
46
+ const space = new MemoryLockSpace();
47
+ return async () => {
48
+ const storage = new WebStorage({ records: openMemoryRecords(store), blobs, locks: await space.open(), files: new NodeFiles() });
49
+ t.after(() => storage.close());
50
+ return storage;
51
+ };
52
+ }
53
+ /** A backend with a repository in it, its runs' state kept beside it, and its
54
+ * execution records left, when a case asks, in bytes of its choosing: bytes
55
+ * that do not decode, or a record in an earlier release's form. */
56
+ const backend = async (t) => {
57
+ const storage = await origin(t)();
58
+ await storage.repos.create(REPO);
59
+ const { records } = storage.adapters;
60
+ return {
61
+ storage,
62
+ repo: REPO,
63
+ stateStore: new WebStateStore(records),
64
+ damage: {
65
+ execution: (taskHash, inputsHash, executionId, bytes) => records.transact((tx) => {
66
+ tx.put(recordKeys.execution(REPO, taskHash, inputsHash, executionId), bytes ?? encoder.encode('not a record'));
67
+ return Promise.resolve();
68
+ }),
69
+ },
70
+ };
71
+ };
72
+ /** A backend with no repository yet, whose stores name a repository as its
73
+ * lifecycle does. */
74
+ const repositories = async (t) => ({ storage: await origin(t)(), repoOf: (name) => name });
75
+ describe('WebStorage over the adapters in memory', () => {
76
+ objectStoreTests(backend);
77
+ refStoreTests(backend);
78
+ datasetRefStoreTests(backend);
79
+ lockServiceTests(backend);
80
+ logStoreTests(backend);
81
+ repoStoreTests(repositories);
82
+ repositoryRecordTests(backend);
83
+ gcTests(backend);
84
+ executionCacheTests(backend);
85
+ workspaceStatusTests(backend);
86
+ dataflowTests(backend);
87
+ });
88
+ describe('WebStateStore over records in memory', () => {
89
+ executionStateStoreTests(() => Promise.resolve({ store: new WebStateStore(openMemoryRecords()), repo: REPO }));
90
+ });
91
+ /**
92
+ * Blobs in memory whose writes wait at a gate until it opens: what holds a
93
+ * write of an object in flight, between its record in flight and its blob.
94
+ */
95
+ class GatedBlobs extends MemoryBlobs {
96
+ letThrough;
97
+ opened = new Promise((resolve) => {
98
+ this.letThrough = resolve;
99
+ });
100
+ /** How many writes have reached the gate */
101
+ arrived = 0;
102
+ /** What settles once as many writes have reached the gate, by how many */
103
+ arrivals = new Map();
104
+ /** Settles once `count` writes have reached the gate. */
105
+ reached(count) {
106
+ if (this.arrived >= count)
107
+ return Promise.resolve();
108
+ return new Promise((resolve) => this.arrivals.set(count, resolve));
109
+ }
110
+ /** Lets every write at the gate through, and every one after it. */
111
+ open() {
112
+ this.letThrough();
113
+ }
114
+ async write(key, data) {
115
+ this.arrived++;
116
+ this.arrivals.get(this.arrived)?.();
117
+ await this.opened;
118
+ return super.write(key, data);
119
+ }
120
+ }
121
+ /**
122
+ * Records that count the records their reads return, in a transaction or
123
+ * outside one: how much of the store an operation touches.
124
+ */
125
+ class CountingRecords {
126
+ inner;
127
+ /** The records the reads have returned */
128
+ returned = 0;
129
+ /**
130
+ * @param inner - The records counted
131
+ */
132
+ constructor(inner) {
133
+ this.inner = inner;
134
+ }
135
+ /** Counts what a read returned, and returns it. */
136
+ counted(found, count) {
137
+ this.returned += count;
138
+ return found;
139
+ }
140
+ async get(key) {
141
+ const value = await this.inner.get(key);
142
+ return this.counted(value, value === null ? 0 : 1);
143
+ }
144
+ async scan(prefix, options) {
145
+ const found = await this.inner.scan(prefix, options);
146
+ return this.counted(found, found.length);
147
+ }
148
+ async keys(prefix, options) {
149
+ const found = await this.inner.keys(prefix, options);
150
+ return this.counted(found, found.length);
151
+ }
152
+ transact(work) {
153
+ return this.inner.transact((tx) => work({
154
+ get: async (key) => {
155
+ const value = await tx.get(key);
156
+ return this.counted(value, value === null ? 0 : 1);
157
+ },
158
+ scan: async (prefix, options) => {
159
+ const found = await tx.scan(prefix, options);
160
+ return this.counted(found, found.length);
161
+ },
162
+ keys: async (prefix, options) => {
163
+ const found = await tx.keys(prefix, options);
164
+ return this.counted(found, found.length);
165
+ },
166
+ put: (key, value) => tx.put(key, value),
167
+ delete: (key) => tx.delete(key),
168
+ deletePrefix: (prefix) => tx.deletePrefix(prefix),
169
+ }));
170
+ }
171
+ close() {
172
+ return this.inner.close();
173
+ }
174
+ }
175
+ /** What a deploy holding a lock reports. */
176
+ const PROGRESS = variant('deployment', {
177
+ package: { name: 'pkg', version: '1.0.0' },
178
+ startedAt: new Date('2026-10-01T00:00:00.000Z'),
179
+ files: [],
180
+ records: [],
181
+ });
182
+ describe('what WebStorage keeps beside its objects and records', () => {
183
+ /** Sweeps the repository as gc does last, beside running work. */
184
+ const sweep = (storage, minAge, dryRun) => storage.repos.gcSweepBackend(REPO, new Set(), { minAge, dryRun, held: false });
185
+ it('takes a write in flight past the age gate for abandoned, failing the write, and leaves one younger', async (t) => {
186
+ const blobs = new GatedBlobs();
187
+ const storage = await origin(t, blobs)();
188
+ await storage.repos.create(REPO);
189
+ const bytes = encoder.encode('a write in flight');
190
+ const writing = storage.objects.write(REPO, bytes);
191
+ await blobs.reached(1);
192
+ const inFlight = () => storage.adapters.records.keys(recordKeys.kind(REPO, 'pending'));
193
+ assert.deepEqual(await sweep(storage, 60_000, false), { deletedPartials: 0, skippedYoung: 1 }, 'younger than the age gate: left');
194
+ assert.deepEqual(await sweep(storage, 0, true), { deletedPartials: 1, skippedYoung: 0 }, 'a dry run counts it');
195
+ assert.equal((await inFlight()).length, 1, 'and takes nothing');
196
+ assert.deepEqual(await sweep(storage, 0, false), { deletedPartials: 1, skippedYoung: 0 });
197
+ assert.deepEqual(await inFlight(), []);
198
+ blobs.open();
199
+ await assert.rejects(writing, /taken for abandoned by gc's sweep/);
200
+ assert.equal(await storage.objects.exists(REPO, computeHash(bytes)), false, 'the write stored nothing');
201
+ // The blob it wrote after the sweep had taken it names nothing.
202
+ assert.deepEqual(await sweep(storage, 0, false), { deletedPartials: 1, skippedYoung: 0 });
203
+ assert.deepEqual(await blobs.list([REPO]), []);
204
+ assert.deepEqual(await sweep(storage, 0, false), { deletedPartials: 0, skippedYoung: 0 }, 'nothing is left to take');
205
+ });
206
+ it('takes a blob nothing names, as a delete cut short between an entry and its blob leaves one, whatever its age', async (t) => {
207
+ const blobs = new MemoryBlobs();
208
+ const storage = await origin(t, blobs)();
209
+ await storage.repos.create(REPO);
210
+ const kept = await storage.objects.write(REPO, encoder.encode('kept'));
211
+ const cut = await storage.objects.write(REPO, encoder.encode('cut short'));
212
+ // A delete that took the entry, and never reached the blob
213
+ await storage.adapters.records.transact((tx) => {
214
+ tx.delete(recordKeys.object(REPO, cut));
215
+ return Promise.resolve();
216
+ });
217
+ assert.equal((await blobs.list([REPO])).length, 2);
218
+ assert.deepEqual(await sweep(storage, 60_000, true), { deletedPartials: 1, skippedYoung: 0 }, 'a dry run counts it');
219
+ assert.equal((await blobs.list([REPO])).length, 2, 'and takes nothing');
220
+ assert.deepEqual(await sweep(storage, 60_000, false), { deletedPartials: 1, skippedYoung: 0 });
221
+ assert.equal((await blobs.list([REPO])).length, 1);
222
+ assert.equal(decoder.decode(await storage.objects.read(REPO, kept)), 'kept', 'a blob an entry names stays');
223
+ });
224
+ it('scans its catalogue for gc a thousand objects at a time, listing each object once', async (t) => {
225
+ const storage = await origin(t)();
226
+ await storage.repos.create(REPO);
227
+ const written = new Set();
228
+ for (let i = 0; i < 1001; i++)
229
+ written.add(await storage.objects.write(REPO, encoder.encode(`object ${i}`)));
230
+ const first = await storage.repos.gcScanObjects(REPO);
231
+ assert.equal(first.objects.length, 1000);
232
+ assert.ok(first.cursor !== undefined, 'a page that is not the last names the next');
233
+ const second = await storage.repos.gcScanObjects(REPO, first.cursor);
234
+ assert.equal(second.objects.length, 1);
235
+ assert.equal(second.cursor, undefined, 'the last page names none');
236
+ assert.deepEqual(new Set([...first.objects, ...second.objects].map(({ hash }) => hash)), written);
237
+ });
238
+ it('answers none for the record of an upgrade under way that does not decode, so the step under way starts again', async (t) => {
239
+ const storage = await origin(t)();
240
+ await storage.repos.create(REPO);
241
+ await storage.refs.repositoryUpgradeWrite(REPO, { step: 'a-step', release: '1.0.0', cursor: 'here' });
242
+ await storage.adapters.records.transact((tx) => {
243
+ tx.put(recordKeys.upgrade(REPO), encoder.encode('not a record'));
244
+ return Promise.resolve();
245
+ });
246
+ assert.equal(await storage.refs.repositoryUpgradeRead(REPO), null);
247
+ });
248
+ it('keeps one blob of the bytes two writes store at once', async (t) => {
249
+ const blobs = new GatedBlobs();
250
+ const storage = await origin(t, blobs)();
251
+ await storage.repos.create(REPO);
252
+ const bytes = encoder.encode('written twice at once');
253
+ const writes = [storage.objects.write(REPO, bytes), storage.objects.write(REPO, bytes)];
254
+ await blobs.reached(2);
255
+ blobs.open();
256
+ assert.deepEqual(await Promise.all(writes), [computeHash(bytes), computeHash(bytes)]);
257
+ assert.equal((await blobs.list([REPO])).length, 1, 'the write the other beat to the catalogue let its blob go');
258
+ assert.equal(decoder.decode(await storage.objects.read(REPO, computeHash(bytes))), 'written twice at once');
259
+ assert.deepEqual(await sweep(storage, 0, false), { deletedPartials: 0, skippedYoung: 0 });
260
+ });
261
+ it('takes the state a tab left that closed holding a lock for no one\'s, and lets another tab hold the lock', async (t) => {
262
+ const open = origin(t);
263
+ const [first, second] = [await open(), await open()];
264
+ await first.repos.create(REPO);
265
+ const held = await first.locks.acquire(REPO, 'main', variant('deployment', null));
266
+ assert.ok(held !== null);
267
+ await held.report(PROGRESS);
268
+ const state = await second.locks.getState(REPO, 'main');
269
+ assert.ok(state?.holder.type === 'process' && state.holder.value.bootId === first.adapters.locks.session, 'the other tab sees the holder');
270
+ const progress = await second.locks.getProgress(REPO, 'main');
271
+ assert.ok(progress !== null && equalFor(LockProgressType)(progress, PROGRESS), 'and what it reported');
272
+ // The first tab closes holding the lock: its session ends, and its state
273
+ // is left.
274
+ await first.adapters.locks.close();
275
+ assert.equal(await second.locks.isHolderAlive(state.holder), false);
276
+ assert.equal(await second.locks.getState(REPO, 'main'), null);
277
+ assert.equal(await second.locks.getProgress(REPO, 'main'), null);
278
+ assert.notEqual(await second.adapters.records.get(recordKeys.lock(REPO, 'main')), null, 'its state is left');
279
+ const taken = await second.locks.acquire(REPO, 'main', variant('deployment', null));
280
+ assert.ok(taken !== null, 'the other tab takes the lock');
281
+ const own = await second.locks.getState(REPO, 'main');
282
+ assert.ok(own?.holder.type === 'process' && own.holder.value.bootId === second.adapters.locks.session, 'its state names the other tab');
283
+ assert.equal(await second.locks.getProgress(REPO, 'main'), null, 'which has reported nothing');
284
+ await taken.release();
285
+ assert.equal(await second.adapters.records.get(recordKeys.lock(REPO, 'main')), null, 'a release takes its own state away');
286
+ });
287
+ it('reads a window of a long log from the few chunks that hold it, not from every chunk of the log', async (t) => {
288
+ const records = new CountingRecords(openMemoryRecords());
289
+ const storage = new WebStorage({ records, blobs: new MemoryBlobs(), locks: await new MemoryLockSpace().open(), files: new NodeFiles() });
290
+ t.after(() => storage.close());
291
+ await storage.repos.create(REPO);
292
+ const id = uuidv7();
293
+ // A chatty unit: a thousand appends of ten bytes each
294
+ const lines = Array.from({ length: 1000 }, (_, i) => `line ${String(i).padStart(4, '0')}\n`);
295
+ for (const line of lines)
296
+ await storage.logs.append(REPO, TASK, INPUTS, id, 'stdout', line);
297
+ records.returned = 0;
298
+ const tail = await storage.logs.read(REPO, TASK, INPUTS, id, 'stdout', { offset: 9_985, limit: 10 });
299
+ assert.deepEqual(tail, { data: '0998\nline ', offset: 9_985, size: 10, totalSize: 10_000, complete: false });
300
+ assert.ok(records.returned <= 3, `a window near the end was cut from ${records.returned} records: the last, and the two it spans`);
301
+ records.returned = 0;
302
+ assert.equal((await storage.logs.read(REPO, TASK, INPUTS, id, 'stdout', { offset: 0, limit: 0 })).totalSize, 10_000);
303
+ assert.ok(records.returned <= 1, `the log's size was read from ${records.returned} records: its last`);
304
+ const whole = await storage.logs.read(REPO, TASK, INPUTS, id, 'stdout');
305
+ assert.deepEqual(whole, { data: lines.join(''), offset: 0, size: 10_000, totalSize: 10_000, complete: true }, 'a window of every chunk');
306
+ });
307
+ });
308
+ describe('openWebStorage', () => {
309
+ it('refuses to persist repositories where IndexedDB is missing, as in Node, naming it, and keeps them in memory with persist: false', async () => {
310
+ await assert.rejects(openWebStorage({ name: 'refused' }), (err) => {
311
+ assert.ok(err instanceof Error);
312
+ assert.match(err.message, /it has no IndexedDB /);
313
+ assert.match(err.message, /persist: false to keep repositories in memory/);
314
+ return true;
315
+ });
316
+ const storage = await openWebStorage({ persist: false });
317
+ try {
318
+ await storage.repos.create(REPO);
319
+ assert.deepEqual(await storage.repos.list(), [REPO]);
320
+ }
321
+ finally {
322
+ await storage.close();
323
+ }
324
+ });
325
+ });
326
+ //# sourceMappingURL=stores.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.spec.js","sourceRoot":"","sources":["../../../src/storage/stores.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAoB,MAAM,WAAW,CAAC;AAC3D,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAqB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,2BAA2B,C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MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,yBAAyB,CAAC,CAAC;IAC3I,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,iIAAiI,EAAE,KAAK,IAAI,EAAE;QAC/I,MAAM,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,GAAY,EAAE,EAAE;YACzE,MAAM,CAAC,EAAE,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC;YAChC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC;YAClD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,+CAA+C,CAAC,CAAC;YAC3E,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,CAAC,SAAS,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,CAAC;gBAAS,CAAC;YACT,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;QACxB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Locks through Web Locks (`navigator.locks`), taken by the tab's session.
7
+ *
8
+ * A tab opens one session: an id it holds a Web Lock of its own under for as
9
+ * long as it lives. Every lock the tab takes is a Web Lock too, so when the
10
+ * tab closes, or crashes, the browser frees all of them, the session's among
11
+ * them. A lock holder another tab recorded names the session as its `bootId`,
12
+ * with pid 0, and a tab asks whether that holder is alive by asking Web Locks
13
+ * whether the session's lock is still held. So two tabs over one origin take
14
+ * locks as two processes over one directory do, and a closed tab's locks are
15
+ * free.
16
+ *
17
+ * @packageDocumentation
18
+ */
19
+ import { type LockHold, type LockMode, type LockRequest, type LocksAdapter } from './adapters.js';
20
+ /**
21
+ * How {@link openWebLocks} opens a session.
22
+ */
23
+ export interface WebLocksOptions {
24
+ /** What the name of every Web Lock the session takes begins with, so sets
25
+ * of locks over one origin keep apart: `e3:` unless given */
26
+ readonly prefix?: string;
27
+ /** The lock manager to take them from: the global `navigator.locks` unless
28
+ * given */
29
+ readonly manager?: LockManager;
30
+ }
31
+ /**
32
+ * The name of the Web Lock a session holds for as long as it lives: another
33
+ * tab that waits for it learns when the session has ended.
34
+ *
35
+ * @param prefix - What the session's lock names begin with
36
+ * @param session - The session's id
37
+ * @returns The Web Lock's name
38
+ */
39
+ export declare function sessionLockName(prefix: string, session: string): string;
40
+ /**
41
+ * Opens the tab's session: takes the session's own Web Lock, which the tab
42
+ * holds until the session closes or the tab does.
43
+ *
44
+ * @param options - What the session's lock names begin with, and the lock
45
+ * manager
46
+ * @returns The session's locks
47
+ * @throws {Error} When the page has no Web Locks: it is not a secure context
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const locks = await openWebLocks();
52
+ * const hold = await locks.acquire('main', 'exclusive', { wait: true, timeout: 30_000 });
53
+ * // another tab: await locks.isAlive(session) is true until this tab closes
54
+ * ```
55
+ */
56
+ export declare function openWebLocks(options?: WebLocksOptions): Promise<WebLocks>;
57
+ /** A Web Lock held: its release, which resolves once the lock is free. */
58
+ interface Held {
59
+ release(): Promise<void>;
60
+ }
61
+ /**
62
+ * A tab's session over Web Locks: the {@link LocksAdapter} of a browser.
63
+ *
64
+ * @remarks
65
+ * Requests for a name are made of the lock manager in the order they were
66
+ * made of the session: a request that cannot be granted at once is refused,
67
+ * or waits behind the ones before it, as Web Locks queues them. A timeout
68
+ * bounds a wait for a name another holds; a name that can be granted at once
69
+ * is granted whatever the timeout.
70
+ */
71
+ export declare class WebLocks implements LocksAdapter {
72
+ private readonly manager;
73
+ private readonly prefix;
74
+ readonly session: string;
75
+ private readonly own;
76
+ private closed;
77
+ /** Aborted as the session closes: every request of it still waiting is
78
+ * refused */
79
+ private readonly closing;
80
+ /** The holds the session has not released */
81
+ private readonly holds;
82
+ /** For each name, what the last request for it settles once it has been
83
+ * made of the lock manager */
84
+ private readonly made;
85
+ /**
86
+ * @param manager - The lock manager
87
+ * @param prefix - What the session's lock names begin with
88
+ * @param session - The session's id
89
+ * @param own - The session's own lock
90
+ * @internal
91
+ */
92
+ constructor(manager: LockManager, prefix: string, session: string, own: Held);
93
+ private assertOpen;
94
+ acquire(name: string, mode: LockMode, options?: LockRequest): Promise<LockHold | null>;
95
+ /** Keeps a lock granted as a hold of the session, unless the session has
96
+ * closed meanwhile, when it lets the lock go. */
97
+ private keep;
98
+ held(name: string): Promise<LockMode[]>;
99
+ isAlive(session: string): Promise<boolean>;
100
+ close(): Promise<void>;
101
+ }
102
+ export {};
103
+ //# sourceMappingURL=web-locks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-locks.d.ts","sourceRoot":"","sources":["../../../src/storage/web-locks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAwC,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAExI;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;kEAC8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;gBACY;IACZ,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,wBAAgB,eA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