@claudexor/daemon 3.25.1 → 4.0.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 (453) hide show
  1. package/dist/account-resets.d.ts +2 -2
  2. package/dist/account-resets.d.ts.map +1 -1
  3. package/dist/account-resets.js +15 -0
  4. package/dist/account-resets.js.map +1 -1
  5. package/dist/client.d.ts +25 -6
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +55 -51
  8. package/dist/client.js.map +1 -1
  9. package/dist/command-authority.d.ts +11 -8
  10. package/dist/command-authority.d.ts.map +1 -1
  11. package/dist/command-authority.js +5 -6
  12. package/dist/command-authority.js.map +1 -1
  13. package/dist/command-list-projection.d.ts +0 -1
  14. package/dist/command-list-projection.d.ts.map +1 -1
  15. package/dist/command-list-projection.js +0 -6
  16. package/dist/command-list-projection.js.map +1 -1
  17. package/dist/command-list-select.d.ts +0 -4
  18. package/dist/command-list-select.d.ts.map +1 -1
  19. package/dist/command-list-select.js +1 -115
  20. package/dist/command-list-select.js.map +1 -1
  21. package/dist/command-retention.d.ts +7 -19
  22. package/dist/command-retention.d.ts.map +1 -1
  23. package/dist/command-retention.js +1 -120
  24. package/dist/command-retention.js.map +1 -1
  25. package/dist/command-rpc.d.ts +4 -1
  26. package/dist/command-rpc.d.ts.map +1 -1
  27. package/dist/command-rpc.js +12 -1
  28. package/dist/command-rpc.js.map +1 -1
  29. package/dist/command-store.d.ts +15 -52
  30. package/dist/command-store.d.ts.map +1 -1
  31. package/dist/command-store.js +5 -493
  32. package/dist/command-store.js.map +1 -1
  33. package/dist/daemon-health.d.ts +56 -8
  34. package/dist/daemon-health.d.ts.map +1 -1
  35. package/dist/daemon-health.js +44 -9
  36. package/dist/daemon-health.js.map +1 -1
  37. package/dist/daemon-local-client.d.ts +28 -0
  38. package/dist/daemon-local-client.d.ts.map +1 -0
  39. package/dist/daemon-local-client.js +55 -0
  40. package/dist/daemon-local-client.js.map +1 -0
  41. package/dist/delivery-command.d.ts +4 -4
  42. package/dist/delivery-command.d.ts.map +1 -1
  43. package/dist/delivery-command.js.map +1 -1
  44. package/dist/index.d.ts +23 -8
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +25 -8
  47. package/dist/index.js.map +1 -1
  48. package/dist/interactions.d.ts +12 -28
  49. package/dist/interactions.d.ts.map +1 -1
  50. package/dist/interactions.js +22 -123
  51. package/dist/interactions.js.map +1 -1
  52. package/dist/job-admission.d.ts +26 -0
  53. package/dist/job-admission.d.ts.map +1 -0
  54. package/dist/job-admission.js +67 -0
  55. package/dist/job-admission.js.map +1 -0
  56. package/dist/journal-fold-policy.d.ts +1 -1
  57. package/dist/journal-fold-policy.d.ts.map +1 -1
  58. package/dist/journal-recovery-files.d.ts +1 -41
  59. package/dist/journal-recovery-files.d.ts.map +1 -1
  60. package/dist/journal-recovery-files.js +2 -340
  61. package/dist/journal-recovery-files.js.map +1 -1
  62. package/dist/loop-facts.d.ts +28 -0
  63. package/dist/loop-facts.d.ts.map +1 -0
  64. package/dist/loop-facts.js +97 -0
  65. package/dist/loop-facts.js.map +1 -0
  66. package/dist/memory-facts.d.ts +2 -0
  67. package/dist/memory-facts.d.ts.map +1 -1
  68. package/dist/memory-facts.js +5 -0
  69. package/dist/memory-facts.js.map +1 -1
  70. package/dist/model-operations.d.ts +11 -4
  71. package/dist/model-operations.d.ts.map +1 -1
  72. package/dist/model-operations.js +68 -38
  73. package/dist/model-operations.js.map +1 -1
  74. package/dist/operator-decisions.d.ts +15 -25
  75. package/dist/operator-decisions.d.ts.map +1 -1
  76. package/dist/operator-decisions.js +5 -84
  77. package/dist/operator-decisions.js.map +1 -1
  78. package/dist/projects.d.ts +42 -41
  79. package/dist/projects.d.ts.map +1 -1
  80. package/dist/projects.js +46 -184
  81. package/dist/projects.js.map +1 -1
  82. package/dist/quota-registry-replay.d.ts +2 -2
  83. package/dist/quota-registry-replay.d.ts.map +1 -1
  84. package/dist/quota-registry-replay.js.map +1 -1
  85. package/dist/quota-registry-support.d.ts +4 -1
  86. package/dist/quota-registry-support.d.ts.map +1 -1
  87. package/dist/quota-registry-support.js +15 -2
  88. package/dist/quota-registry-support.js.map +1 -1
  89. package/dist/quota-registry.d.ts +64 -2
  90. package/dist/quota-registry.d.ts.map +1 -1
  91. package/dist/quota-registry.js +10 -3
  92. package/dist/quota-registry.js.map +1 -1
  93. package/dist/quota-resources.d.ts +6 -3
  94. package/dist/quota-resources.d.ts.map +1 -1
  95. package/dist/quota-resources.js +25 -8
  96. package/dist/quota-resources.js.map +1 -1
  97. package/dist/runless-turn-recovery.d.ts +2 -9
  98. package/dist/runless-turn-recovery.d.ts.map +1 -1
  99. package/dist/runless-turn-recovery.js +0 -14
  100. package/dist/runless-turn-recovery.js.map +1 -1
  101. package/dist/server.d.ts +23 -22
  102. package/dist/server.d.ts.map +1 -1
  103. package/dist/server.js +74 -84
  104. package/dist/server.js.map +1 -1
  105. package/dist/store/blob-files.d.ts +71 -0
  106. package/dist/store/blob-files.d.ts.map +1 -0
  107. package/dist/store/blob-files.js +160 -0
  108. package/dist/store/blob-files.js.map +1 -0
  109. package/dist/store/command-prune.d.ts +37 -0
  110. package/dist/store/command-prune.d.ts.map +1 -0
  111. package/dist/store/command-prune.js +123 -0
  112. package/dist/store/command-prune.js.map +1 -0
  113. package/dist/store/command-queries.d.ts +41 -0
  114. package/dist/store/command-queries.d.ts.map +1 -0
  115. package/dist/store/command-queries.js +186 -0
  116. package/dist/store/command-queries.js.map +1 -0
  117. package/dist/store/command-rows.d.ts +66 -0
  118. package/dist/store/command-rows.d.ts.map +1 -0
  119. package/dist/store/command-rows.js +141 -0
  120. package/dist/store/command-rows.js.map +1 -0
  121. package/dist/store/commands.d.ts +49 -0
  122. package/dist/store/commands.d.ts.map +1 -0
  123. package/dist/store/commands.js +247 -0
  124. package/dist/store/commands.js.map +1 -0
  125. package/dist/store/cursors.d.ts +33 -0
  126. package/dist/store/cursors.d.ts.map +1 -0
  127. package/dist/store/cursors.js +82 -0
  128. package/dist/store/cursors.js.map +1 -0
  129. package/dist/store/engine-recovery-files.d.ts +14 -0
  130. package/dist/store/engine-recovery-files.d.ts.map +1 -0
  131. package/dist/store/engine-recovery-files.js +53 -0
  132. package/dist/store/engine-recovery-files.js.map +1 -0
  133. package/dist/store/engine-state-recovery.d.ts +71 -0
  134. package/dist/store/engine-state-recovery.d.ts.map +1 -0
  135. package/dist/store/engine-state-recovery.js +318 -0
  136. package/dist/store/engine-state-recovery.js.map +1 -0
  137. package/dist/store/errors.d.ts +80 -0
  138. package/dist/store/errors.d.ts.map +1 -0
  139. package/dist/store/errors.js +130 -0
  140. package/dist/store/errors.js.map +1 -0
  141. package/dist/store/event-store.d.ts +52 -0
  142. package/dist/store/event-store.d.ts.map +1 -0
  143. package/dist/store/event-store.js +117 -0
  144. package/dist/store/event-store.js.map +1 -0
  145. package/dist/store/external-files.d.ts +40 -0
  146. package/dist/store/external-files.d.ts.map +1 -0
  147. package/dist/store/external-files.js +90 -0
  148. package/dist/store/external-files.js.map +1 -0
  149. package/dist/store/flusher-protocol.d.ts +82 -0
  150. package/dist/store/flusher-protocol.d.ts.map +1 -0
  151. package/dist/store/flusher-protocol.js +23 -0
  152. package/dist/store/flusher-protocol.js.map +1 -0
  153. package/dist/store/flusher-worker.d.ts +24 -0
  154. package/dist/store/flusher-worker.d.ts.map +1 -0
  155. package/dist/store/flusher-worker.js +185 -0
  156. package/dist/store/flusher-worker.js.map +1 -0
  157. package/dist/store/flusher.d.ts +87 -0
  158. package/dist/store/flusher.d.ts.map +1 -0
  159. package/dist/store/flusher.js +264 -0
  160. package/dist/store/flusher.js.map +1 -0
  161. package/dist/store/generations.d.ts +43 -0
  162. package/dist/store/generations.d.ts.map +1 -0
  163. package/dist/store/generations.js +143 -0
  164. package/dist/store/generations.js.map +1 -0
  165. package/dist/store/idempotency.d.ts +25 -0
  166. package/dist/store/idempotency.d.ts.map +1 -0
  167. package/dist/store/idempotency.js +53 -0
  168. package/dist/store/idempotency.js.map +1 -0
  169. package/dist/store/import-context.d.ts +22 -0
  170. package/dist/store/import-context.d.ts.map +1 -0
  171. package/dist/store/import-context.js +87 -0
  172. package/dist/store/import-context.js.map +1 -0
  173. package/dist/store/import-discovery.d.ts +6 -0
  174. package/dist/store/import-discovery.d.ts.map +1 -0
  175. package/dist/store/import-discovery.js +66 -0
  176. package/dist/store/import-discovery.js.map +1 -0
  177. package/dist/store/import-records.d.ts +6 -0
  178. package/dist/store/import-records.d.ts.map +1 -0
  179. package/dist/store/import-records.js +191 -0
  180. package/dist/store/import-records.js.map +1 -0
  181. package/dist/store/import-resources.d.ts +14 -0
  182. package/dist/store/import-resources.d.ts.map +1 -0
  183. package/dist/store/import-resources.js +197 -0
  184. package/dist/store/import-resources.js.map +1 -0
  185. package/dist/store/import-source.d.ts +24 -0
  186. package/dist/store/import-source.d.ts.map +1 -0
  187. package/dist/store/import-source.js +65 -0
  188. package/dist/store/import-source.js.map +1 -0
  189. package/dist/store/import-verify.d.ts +6 -0
  190. package/dist/store/import-verify.d.ts.map +1 -0
  191. package/dist/store/import-verify.js +97 -0
  192. package/dist/store/import-verify.js.map +1 -0
  193. package/dist/store/import-worker.d.ts +18 -0
  194. package/dist/store/import-worker.d.ts.map +1 -0
  195. package/dist/store/import-worker.js +69 -0
  196. package/dist/store/import-worker.js.map +1 -0
  197. package/dist/store/importer.d.ts +42 -0
  198. package/dist/store/importer.d.ts.map +1 -0
  199. package/dist/store/importer.js +239 -0
  200. package/dist/store/importer.js.map +1 -0
  201. package/dist/store/interactions.d.ts +22 -0
  202. package/dist/store/interactions.d.ts.map +1 -0
  203. package/dist/store/interactions.js +82 -0
  204. package/dist/store/interactions.js.map +1 -0
  205. package/dist/store/legacy-journal/frame-codec.d.ts +94 -0
  206. package/dist/store/legacy-journal/frame-codec.d.ts.map +1 -0
  207. package/dist/store/legacy-journal/frame-codec.js +352 -0
  208. package/dist/store/legacy-journal/frame-codec.js.map +1 -0
  209. package/dist/store/legacy-journal/frame-reader.d.ts +30 -0
  210. package/dist/store/legacy-journal/frame-reader.d.ts.map +1 -0
  211. package/dist/store/legacy-journal/frame-reader.js +97 -0
  212. package/dist/store/legacy-journal/frame-reader.js.map +1 -0
  213. package/dist/store/legacy-journal/journal-fold.d.ts +47 -0
  214. package/dist/store/legacy-journal/journal-fold.d.ts.map +1 -0
  215. package/dist/store/legacy-journal/journal-fold.js +81 -0
  216. package/dist/store/legacy-journal/journal-fold.js.map +1 -0
  217. package/dist/store/legacy-journal/journal-partition.d.ts +2 -0
  218. package/dist/store/legacy-journal/journal-partition.d.ts.map +1 -0
  219. package/dist/store/legacy-journal/journal-partition.js +10 -0
  220. package/dist/store/legacy-journal/journal-partition.js.map +1 -0
  221. package/dist/store/legacy-journal/read-only-preparation.d.ts +48 -0
  222. package/dist/store/legacy-journal/read-only-preparation.d.ts.map +1 -0
  223. package/dist/store/legacy-journal/read-only-preparation.js +430 -0
  224. package/dist/store/legacy-journal/read-only-preparation.js.map +1 -0
  225. package/dist/store/maintenance-worker.d.ts +5 -0
  226. package/dist/store/maintenance-worker.d.ts.map +1 -0
  227. package/dist/store/maintenance-worker.js +175 -0
  228. package/dist/store/maintenance-worker.js.map +1 -0
  229. package/dist/store/maintenance.d.ts +124 -0
  230. package/dist/store/maintenance.d.ts.map +1 -0
  231. package/dist/store/maintenance.js +197 -0
  232. package/dist/store/maintenance.js.map +1 -0
  233. package/dist/store/mutation.d.ts +34 -0
  234. package/dist/store/mutation.d.ts.map +1 -0
  235. package/dist/store/mutation.js +85 -0
  236. package/dist/store/mutation.js.map +1 -0
  237. package/dist/store/obligations.d.ts +101 -0
  238. package/dist/store/obligations.d.ts.map +1 -0
  239. package/dist/store/obligations.js +226 -0
  240. package/dist/store/obligations.js.map +1 -0
  241. package/dist/store/operator-decisions.d.ts +23 -0
  242. package/dist/store/operator-decisions.d.ts.map +1 -0
  243. package/dist/store/operator-decisions.js +68 -0
  244. package/dist/store/operator-decisions.js.map +1 -0
  245. package/dist/store/owner-generations.d.ts +33 -0
  246. package/dist/store/owner-generations.d.ts.map +1 -0
  247. package/dist/store/owner-generations.js +63 -0
  248. package/dist/store/owner-generations.js.map +1 -0
  249. package/dist/store/partitions.d.ts +37 -0
  250. package/dist/store/partitions.d.ts.map +1 -0
  251. package/dist/store/partitions.js +68 -0
  252. package/dist/store/partitions.js.map +1 -0
  253. package/dist/store/pragmas.d.ts +32 -0
  254. package/dist/store/pragmas.d.ts.map +1 -0
  255. package/dist/store/pragmas.js +65 -0
  256. package/dist/store/pragmas.js.map +1 -0
  257. package/dist/store/project-router.d.ts +325 -0
  258. package/dist/store/project-router.d.ts.map +1 -0
  259. package/dist/store/project-router.js +298 -0
  260. package/dist/store/project-router.js.map +1 -0
  261. package/dist/store/projects.d.ts +36 -0
  262. package/dist/store/projects.d.ts.map +1 -0
  263. package/dist/store/projects.js +238 -0
  264. package/dist/store/projects.js.map +1 -0
  265. package/dist/store/publish-blob.d.ts +20 -0
  266. package/dist/store/publish-blob.d.ts.map +1 -0
  267. package/dist/store/publish-blob.js +158 -0
  268. package/dist/store/publish-blob.js.map +1 -0
  269. package/dist/store/purge-files.d.ts +30 -0
  270. package/dist/store/purge-files.d.ts.map +1 -0
  271. package/dist/store/purge-files.js +79 -0
  272. package/dist/store/purge-files.js.map +1 -0
  273. package/dist/store/resource-rows.d.ts +40 -0
  274. package/dist/store/resource-rows.d.ts.map +1 -0
  275. package/dist/store/resource-rows.js +103 -0
  276. package/dist/store/resource-rows.js.map +1 -0
  277. package/dist/store/resources.d.ts +67 -0
  278. package/dist/store/resources.d.ts.map +1 -0
  279. package/dist/store/resources.js +147 -0
  280. package/dist/store/resources.js.map +1 -0
  281. package/dist/store/retention.d.ts +91 -0
  282. package/dist/store/retention.d.ts.map +1 -0
  283. package/dist/store/retention.js +169 -0
  284. package/dist/store/retention.js.map +1 -0
  285. package/dist/store/run-events.d.ts +14 -0
  286. package/dist/store/run-events.d.ts.map +1 -0
  287. package/dist/store/run-events.js +35 -0
  288. package/dist/store/run-events.js.map +1 -0
  289. package/dist/store/runtime.d.ts +24 -0
  290. package/dist/store/runtime.d.ts.map +1 -0
  291. package/dist/store/runtime.js +67 -0
  292. package/dist/store/runtime.js.map +1 -0
  293. package/dist/store/schema.d.ts +33 -0
  294. package/dist/store/schema.d.ts.map +1 -0
  295. package/dist/store/schema.js +187 -0
  296. package/dist/store/schema.js.map +1 -0
  297. package/dist/store/setup-bindings.d.ts +20 -0
  298. package/dist/store/setup-bindings.d.ts.map +1 -0
  299. package/dist/store/setup-bindings.js +52 -0
  300. package/dist/store/setup-bindings.js.map +1 -0
  301. package/dist/store/sql-command-router.d.ts +79 -0
  302. package/dist/store/sql-command-router.d.ts.map +1 -0
  303. package/dist/store/sql-command-router.js +92 -0
  304. package/dist/store/sql-command-router.js.map +1 -0
  305. package/dist/store/sql-daemon-services.d.ts +61 -0
  306. package/dist/store/sql-daemon-services.d.ts.map +1 -0
  307. package/dist/store/sql-daemon-services.js +124 -0
  308. package/dist/store/sql-daemon-services.js.map +1 -0
  309. package/dist/store/sql-recovery-export.d.ts +8 -0
  310. package/dist/store/sql-recovery-export.d.ts.map +1 -0
  311. package/dist/store/sql-recovery-export.js +110 -0
  312. package/dist/store/sql-recovery-export.js.map +1 -0
  313. package/dist/store/sql-recovery-inspection.d.ts +22 -0
  314. package/dist/store/sql-recovery-inspection.d.ts.map +1 -0
  315. package/dist/store/sql-recovery-inspection.js +88 -0
  316. package/dist/store/sql-recovery-inspection.js.map +1 -0
  317. package/dist/store/sql-recovery.d.ts +69 -0
  318. package/dist/store/sql-recovery.d.ts.map +1 -0
  319. package/dist/store/sql-recovery.js +169 -0
  320. package/dist/store/sql-recovery.js.map +1 -0
  321. package/dist/store/sql-validation.d.ts +9 -0
  322. package/dist/store/sql-validation.d.ts.map +1 -0
  323. package/dist/store/sql-validation.js +103 -0
  324. package/dist/store/sql-validation.js.map +1 -0
  325. package/dist/store/statement-observer.d.ts +7 -0
  326. package/dist/store/statement-observer.d.ts.map +1 -0
  327. package/dist/store/statement-observer.js +44 -0
  328. package/dist/store/statement-observer.js.map +1 -0
  329. package/dist/store/store.d.ts +110 -0
  330. package/dist/store/store.d.ts.map +1 -0
  331. package/dist/store/store.js +296 -0
  332. package/dist/store/store.js.map +1 -0
  333. package/dist/store/terminal-files.d.ts +21 -0
  334. package/dist/store/terminal-files.d.ts.map +1 -0
  335. package/dist/store/terminal-files.js +115 -0
  336. package/dist/store/terminal-files.js.map +1 -0
  337. package/dist/store/thread-replay.d.ts +12 -0
  338. package/dist/store/thread-replay.d.ts.map +1 -0
  339. package/dist/store/thread-replay.js +49 -0
  340. package/dist/store/thread-replay.js.map +1 -0
  341. package/dist/store/thread-rows.d.ts +25 -0
  342. package/dist/store/thread-rows.d.ts.map +1 -0
  343. package/dist/store/thread-rows.js +141 -0
  344. package/dist/store/thread-rows.js.map +1 -0
  345. package/dist/store/threads.d.ts +105 -0
  346. package/dist/store/threads.d.ts.map +1 -0
  347. package/dist/store/threads.js +423 -0
  348. package/dist/store/threads.js.map +1 -0
  349. package/dist/store/upload-binding-retention.d.ts +26 -0
  350. package/dist/store/upload-binding-retention.d.ts.map +1 -0
  351. package/dist/store/upload-binding-retention.js +142 -0
  352. package/dist/store/upload-binding-retention.js.map +1 -0
  353. package/dist/store/uploads.d.ts +30 -0
  354. package/dist/store/uploads.d.ts.map +1 -0
  355. package/dist/store/uploads.js +238 -0
  356. package/dist/store/uploads.js.map +1 -0
  357. package/dist/store-contracts.d.ts +181 -0
  358. package/dist/store-contracts.d.ts.map +1 -0
  359. package/dist/store-contracts.js +2 -0
  360. package/dist/store-contracts.js.map +1 -0
  361. package/dist/terminal-authority.d.ts +9 -0
  362. package/dist/terminal-authority.d.ts.map +1 -1
  363. package/dist/terminal-authority.js +103 -1
  364. package/dist/terminal-authority.js.map +1 -1
  365. package/dist/thread-lane-checkpoints.d.ts +0 -2
  366. package/dist/thread-lane-checkpoints.d.ts.map +1 -1
  367. package/dist/thread-lane-checkpoints.js +0 -4
  368. package/dist/thread-lane-checkpoints.js.map +1 -1
  369. package/dist/thread-store-support.d.ts +1 -27
  370. package/dist/thread-store-support.d.ts.map +1 -1
  371. package/dist/thread-store-support.js +0 -63
  372. package/dist/thread-store-support.js.map +1 -1
  373. package/dist/threads.d.ts +1 -113
  374. package/dist/threads.d.ts.map +1 -1
  375. package/dist/threads.js +1 -379
  376. package/dist/threads.js.map +1 -1
  377. package/package.json +9 -7
  378. package/dist/command-activity.d.ts +0 -14
  379. package/dist/command-activity.d.ts.map +0 -1
  380. package/dist/command-activity.js +0 -16
  381. package/dist/command-activity.js.map +0 -1
  382. package/dist/journal-events.d.ts +0 -4
  383. package/dist/journal-events.d.ts.map +0 -1
  384. package/dist/journal-events.js +0 -23
  385. package/dist/journal-events.js.map +0 -1
  386. package/dist/journal-maintenance.d.ts +0 -50
  387. package/dist/journal-maintenance.d.ts.map +0 -1
  388. package/dist/journal-maintenance.js +0 -162
  389. package/dist/journal-maintenance.js.map +0 -1
  390. package/dist/journal-manager-journal.d.ts +0 -18
  391. package/dist/journal-manager-journal.d.ts.map +0 -1
  392. package/dist/journal-manager-journal.js +0 -25
  393. package/dist/journal-manager-journal.js.map +0 -1
  394. package/dist/journal-manager-lifecycle.d.ts +0 -11
  395. package/dist/journal-manager-lifecycle.d.ts.map +0 -1
  396. package/dist/journal-manager-lifecycle.js +0 -2
  397. package/dist/journal-manager-lifecycle.js.map +0 -1
  398. package/dist/journal-manager.d.ts +0 -99
  399. package/dist/journal-manager.d.ts.map +0 -1
  400. package/dist/journal-manager.js +0 -559
  401. package/dist/journal-manager.js.map +0 -1
  402. package/dist/journal-prepared-operation.d.ts +0 -53
  403. package/dist/journal-prepared-operation.d.ts.map +0 -1
  404. package/dist/journal-prepared-operation.js +0 -158
  405. package/dist/journal-prepared-operation.js.map +0 -1
  406. package/dist/journal-projection-slot.d.ts +0 -28
  407. package/dist/journal-projection-slot.d.ts.map +0 -1
  408. package/dist/journal-projection-slot.js +0 -71
  409. package/dist/journal-projection-slot.js.map +0 -1
  410. package/dist/journal-projection.d.ts +0 -13
  411. package/dist/journal-projection.d.ts.map +0 -1
  412. package/dist/journal-projection.js +0 -2
  413. package/dist/journal-projection.js.map +0 -1
  414. package/dist/partition-accounts.d.ts +0 -27
  415. package/dist/partition-accounts.d.ts.map +0 -1
  416. package/dist/partition-accounts.js +0 -21
  417. package/dist/partition-accounts.js.map +0 -1
  418. package/dist/project-partition-preparation.d.ts +0 -87
  419. package/dist/project-partition-preparation.d.ts.map +0 -1
  420. package/dist/project-partition-preparation.js +0 -273
  421. package/dist/project-partition-preparation.js.map +0 -1
  422. package/dist/project-partitions.d.ts +0 -214
  423. package/dist/project-partitions.d.ts.map +0 -1
  424. package/dist/project-partitions.js +0 -486
  425. package/dist/project-partitions.js.map +0 -1
  426. package/dist/project-remove.d.ts +0 -11
  427. package/dist/project-remove.d.ts.map +0 -1
  428. package/dist/project-remove.js +0 -65
  429. package/dist/project-remove.js.map +0 -1
  430. package/dist/project-thread-listing.d.ts +0 -14
  431. package/dist/project-thread-listing.d.ts.map +0 -1
  432. package/dist/project-thread-listing.js +0 -37
  433. package/dist/project-thread-listing.js.map +0 -1
  434. package/dist/quota-projection.d.ts +0 -11
  435. package/dist/quota-projection.d.ts.map +0 -1
  436. package/dist/quota-projection.js +0 -10
  437. package/dist/quota-projection.js.map +0 -1
  438. package/dist/resource-store.d.ts +0 -39
  439. package/dist/resource-store.d.ts.map +0 -1
  440. package/dist/resource-store.js +0 -464
  441. package/dist/resource-store.js.map +0 -1
  442. package/dist/run-event-terminal-index.d.ts +0 -13
  443. package/dist/run-event-terminal-index.d.ts.map +0 -1
  444. package/dist/run-event-terminal-index.js +0 -38
  445. package/dist/run-event-terminal-index.js.map +0 -1
  446. package/dist/run-events.d.ts +0 -17
  447. package/dist/run-events.d.ts.map +0 -1
  448. package/dist/run-events.js +0 -31
  449. package/dist/run-events.js.map +0 -1
  450. package/dist/thread-head-ping.d.ts +0 -35
  451. package/dist/thread-head-ping.d.ts.map +0 -1
  452. package/dist/thread-head-ping.js +0 -67
  453. package/dist/thread-head-ping.js.map +0 -1
@@ -0,0 +1,23 @@
1
+ import { existsSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ /** Flusher pass interval (SYNTHESIS_R5 §4.2): a code constant, not a knob. */
4
+ export const FLUSH_INTERVAL_MS = 200;
5
+ /** The `workerData` discriminator every store worker is spawned with. The
6
+ * worker modules self-start on it, so the same module graph serves the dev
7
+ * `dist/` layout (adjacent worker file) and the single-file daemon bundle
8
+ * (the bundle itself is the worker entry and dispatches by this key). */
9
+ export const STORE_WORKER_DATA_KEY = "claudexorStoreWorker";
10
+ /**
11
+ * Where a store worker starts. Beside this module in the built `dist/` tree
12
+ * the worker file exists and is the entry; inside the single-file daemon
13
+ * bundle `import.meta.url` IS the bundle (esbuild defines it so), the
14
+ * adjacent file does not exist, and the bundle itself is the entry — it
15
+ * embeds the worker modules, which self-start on `workerData`.
16
+ */
17
+ export function resolveStoreWorkerEntry(moduleUrl, workerFile) {
18
+ const adjacent = fileURLToPath(new URL(`./${workerFile}`, moduleUrl));
19
+ if (existsSync(adjacent))
20
+ return adjacent;
21
+ return fileURLToPath(moduleUrl);
22
+ }
23
+ //# sourceMappingURL=flusher-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flusher-protocol.js","sourceRoot":"","sources":["../../src/store/flusher-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAErC;;;yEAGyE;AACzE,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAwD5D;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAiB,EAAE,UAAkB;IAC3E,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,KAAK,UAAU,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;IACtE,IAAI,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC1C,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { type MessagePort } from "node:worker_threads";
2
+ import { type FlusherWorkerData } from "./flusher-protocol.js";
3
+ /**
4
+ * The flusher pass (SYNTHESIS_R5 §4.2), every 200 ms:
5
+ * 1. g_target := the highest generation received so far (FIFO: every
6
+ * registration or flush request handled before this tick is covered);
7
+ * 2. one F_FULLFSYNC per directory touched by a covered registration;
8
+ * 3. `PRAGMA data_version` → dirty := anything committed since the last
9
+ * PROVEN barrier (the first pass of a worker life is always dirty);
10
+ * 4. `PRAGMA wal_checkpoint(PASSIVE)` — space reclamation only; its result
11
+ * is reported as a fact and NEVER decides whether to sync;
12
+ * 5. if dirty: the explicit `fsyncSync(walFd)` — the barrier: it fixes the
13
+ * WAL frames and, as a device-wide barrier on macOS, the O_DSYNC file
14
+ * data already handed to the drive. Database pages become durable
15
+ * through the ff-checkpoint (`checkpoint_fullfsync=1` on every
16
+ * checkpointing connection) before the WAL is reused, not through this
17
+ * fsync (R5_AMENDMENTS B5);
18
+ * 6. `synced(g_target)` with the pass facts.
19
+ * The worker never writes a row and never waits for a lock. `node:sqlite` is
20
+ * imported lazily so the daemon package loads on a Node without it and the
21
+ * typed `engine_runtime_unsupported` stays reachable.
22
+ */
23
+ export declare function runFlusherWorker(port: MessagePort, data: FlusherWorkerData): Promise<void>;
24
+ //# sourceMappingURL=flusher-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flusher-worker.d.ts","sourceRoot":"","sources":["../../src/store/flusher-worker.ts"],"names":[],"mappings":"AACA,OAAO,EAAwC,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAI7F,OAAO,EAML,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqJhG"}
@@ -0,0 +1,185 @@
1
+ import { closeSync, fstatSync, fsyncSync, openSync, statSync } from "node:fs";
2
+ import { isMainThread, parentPort, workerData } from "node:worker_threads";
3
+ import { fsyncDirectory } from "@claudexor/util";
4
+ import { applyPragmas, FLUSHER_CONNECTION_PRAGMAS } from "./pragmas.js";
5
+ import { loadEngineRuntime } from "./runtime.js";
6
+ import { FLUSH_INTERVAL_MS, STORE_WORKER_DATA_KEY, } from "./flusher-protocol.js";
7
+ /**
8
+ * The flusher pass (SYNTHESIS_R5 §4.2), every 200 ms:
9
+ * 1. g_target := the highest generation received so far (FIFO: every
10
+ * registration or flush request handled before this tick is covered);
11
+ * 2. one F_FULLFSYNC per directory touched by a covered registration;
12
+ * 3. `PRAGMA data_version` → dirty := anything committed since the last
13
+ * PROVEN barrier (the first pass of a worker life is always dirty);
14
+ * 4. `PRAGMA wal_checkpoint(PASSIVE)` — space reclamation only; its result
15
+ * is reported as a fact and NEVER decides whether to sync;
16
+ * 5. if dirty: the explicit `fsyncSync(walFd)` — the barrier: it fixes the
17
+ * WAL frames and, as a device-wide barrier on macOS, the O_DSYNC file
18
+ * data already handed to the drive. Database pages become durable
19
+ * through the ff-checkpoint (`checkpoint_fullfsync=1` on every
20
+ * checkpointing connection) before the WAL is reused, not through this
21
+ * fsync (R5_AMENDMENTS B5);
22
+ * 6. `synced(g_target)` with the pass facts.
23
+ * The worker never writes a row and never waits for a lock. `node:sqlite` is
24
+ * imported lazily so the daemon package loads on a Node without it and the
25
+ * typed `engine_runtime_unsupported` stays reachable.
26
+ */
27
+ export async function runFlusherWorker(port, data) {
28
+ const hooks = data.hooks ?? {};
29
+ const walPath = `${data.dbPath}-wal`;
30
+ const { sqlite } = await loadEngineRuntime();
31
+ const db = new sqlite.DatabaseSync(data.dbPath, { timeout: 0 });
32
+ applyPragmas(db, FLUSHER_CONNECTION_PRAGMAS);
33
+ const dataVersion = db.prepare("PRAGMA data_version");
34
+ const passive = db.prepare("PRAGMA wal_checkpoint(PASSIVE)");
35
+ const counters = {
36
+ passes: 0,
37
+ barriers: 0,
38
+ dirSyncs: 0,
39
+ busyPassive: 0,
40
+ walReopens: 0,
41
+ };
42
+ const pendingDirs = new Set();
43
+ let gMax = 0;
44
+ let lastProvenDataVersion = null;
45
+ let walFd = null;
46
+ let timer = null;
47
+ let stopped = false;
48
+ const post = (event) => port.postMessage(event);
49
+ const closeWal = () => {
50
+ if (walFd === null)
51
+ return;
52
+ closeSync(walFd);
53
+ walFd = null;
54
+ };
55
+ /** `r+` on the WAL file, never written through; reopened when the inode moved. */
56
+ const ensureWalFd = () => {
57
+ const onDisk = statSync(walPath, { throwIfNoEntry: false });
58
+ if (walFd !== null) {
59
+ if (onDisk && fstatSync(walFd).ino === onDisk.ino)
60
+ return walFd;
61
+ closeWal();
62
+ counters.walReopens += 1;
63
+ }
64
+ walFd = openSync(walPath, "r+");
65
+ return walFd;
66
+ };
67
+ const pass = () => {
68
+ if (stopped)
69
+ return;
70
+ const started = performance.now();
71
+ const gTarget = gMax;
72
+ const dirsSynced = [];
73
+ const dirsMissing = [];
74
+ for (const dir of pendingDirs) {
75
+ // A directory removed since its registration has no entries left to
76
+ // make durable; whoever removed it registered the parent. Any other
77
+ // failure is fatal to this worker life (fail loud, restart).
78
+ try {
79
+ fsyncDirectory(dir);
80
+ dirsSynced.push(dir);
81
+ }
82
+ catch (error) {
83
+ const code = error.code;
84
+ if (code !== "ENOENT" && code !== "ENOTDIR")
85
+ throw error;
86
+ dirsMissing.push(dir);
87
+ }
88
+ }
89
+ pendingDirs.clear();
90
+ counters.dirSyncs += dirsSynced.length;
91
+ const observed = Number(dataVersion.get().data_version);
92
+ const dirty = lastProvenDataVersion === null || observed !== lastProvenDataVersion;
93
+ const checkpointRow = passive.get();
94
+ const checkpoint = checkpointRow
95
+ ? {
96
+ busy: Number(checkpointRow.busy),
97
+ log: Number(checkpointRow.log),
98
+ checkpointed: Number(checkpointRow.checkpointed),
99
+ }
100
+ : null;
101
+ if (checkpoint?.busy)
102
+ counters.busyPassive += 1;
103
+ if (hooks.passDelayMs) {
104
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, hooks.passDelayMs);
105
+ }
106
+ let barrier = false;
107
+ let barrierMs = null;
108
+ if (dirty) {
109
+ const fd = ensureWalFd();
110
+ const t0 = performance.now();
111
+ fsyncSync(fd);
112
+ barrierMs = performance.now() - t0;
113
+ barrier = true;
114
+ counters.barriers += 1;
115
+ lastProvenDataVersion = observed;
116
+ }
117
+ counters.passes += 1;
118
+ const wal = statSync(walPath, { throwIfNoEntry: false });
119
+ post({
120
+ type: "synced",
121
+ report: {
122
+ g: gTarget,
123
+ dirty,
124
+ barrier,
125
+ dirsSynced,
126
+ dirsMissing,
127
+ checkpoint,
128
+ walBytes: wal ? wal.size : null,
129
+ passMs: performance.now() - started,
130
+ barrierMs,
131
+ counters: { ...counters },
132
+ at: Date.now(),
133
+ },
134
+ });
135
+ };
136
+ const stop = () => {
137
+ stopped = true;
138
+ if (timer)
139
+ clearTimeout(timer);
140
+ timer = null;
141
+ closeWal();
142
+ db.close();
143
+ post({ type: "stopped" });
144
+ port.close();
145
+ };
146
+ const schedule = () => {
147
+ if (stopped || hooks.manualTick)
148
+ return;
149
+ timer = setTimeout(() => {
150
+ pass();
151
+ schedule();
152
+ }, FLUSH_INTERVAL_MS);
153
+ };
154
+ port.on("message", (command) => {
155
+ switch (command.type) {
156
+ case "register":
157
+ pendingDirs.add(command.dir);
158
+ gMax = Math.max(gMax, command.g);
159
+ return;
160
+ case "flush":
161
+ gMax = Math.max(gMax, command.g);
162
+ return;
163
+ case "tick":
164
+ if (hooks.manualTick)
165
+ pass();
166
+ return;
167
+ case "exit":
168
+ if (hooks.allowExit)
169
+ process.exit(command.code);
170
+ return;
171
+ case "stop":
172
+ stop();
173
+ return;
174
+ }
175
+ });
176
+ post({ type: "ready", at: Date.now() });
177
+ schedule();
178
+ }
179
+ const spawnData = workerData;
180
+ if (!isMainThread && parentPort && spawnData?.[STORE_WORKER_DATA_KEY] === "flusher") {
181
+ void runFlusherWorker(parentPort, spawnData).catch((error) => {
182
+ throw error;
183
+ });
184
+ }
185
+ //# sourceMappingURL=flusher-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flusher-worker.js","sourceRoot":"","sources":["../../src/store/flusher-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAoB,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GAKtB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAiB,EAAE,IAAuB;IAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,MAAM,MAAM,CAAC;IACrC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,iBAAiB,EAAE,CAAC;IAC7C,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IAChE,YAAY,CAAC,EAAE,EAAE,0BAA0B,CAAC,CAAC;IAC7C,MA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M;gBACT,IAAI,EAAE,CAAC;gBACP,OAAO;QACX,CAAC;IACH,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACxC,QAAQ,EAAE,CAAC;AACb,CAAC;AAED,MAAM,SAAS,GAAG,UAA2D,CAAC;AAC9E,IAAI,CAAC,YAAY,IAAI,UAAU,IAAI,SAAS,EAAE,CAAC,qBAAqB,CAAC,KAAK,SAAS,EAAE,CAAC;IACpF,KAAK,gBAAgB,CAAC,UAAU,EAAE,SAA8B,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QACzF,MAAM,KAAK,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,87 @@
1
+ import { type FlusherCounters, type FlusherHooks, type FlusherPassReport } from "./flusher-protocol.js";
2
+ import "./flusher-worker.js";
3
+ export interface FlusherFacts {
4
+ state: "starting" | "up" | "down";
5
+ interval_ms: number;
6
+ generation: number;
7
+ acknowledged_generation: number;
8
+ pending_registrations: number;
9
+ pending_waiters: number;
10
+ /** Age of the oldest outstanding registration or waiter; 0 when nothing waits. */
11
+ flush_lag_ms: number;
12
+ last_barrier_at: string | null;
13
+ last_pass: {
14
+ at: string;
15
+ pass_ms: number;
16
+ barrier_ms: number | null;
17
+ dirty: boolean;
18
+ barrier: boolean;
19
+ wal_bytes: number | null;
20
+ checkpoint: FlusherPassReport["checkpoint"];
21
+ } | null;
22
+ counters: FlusherCounters & {
23
+ restarts: number;
24
+ deaths: number;
25
+ };
26
+ }
27
+ export interface FlusherControllerOptions {
28
+ dbPath: string;
29
+ workerEntry?: string;
30
+ hooks?: FlusherHooks;
31
+ log?: (line: string) => void;
32
+ onSynced?: (generation: number, report: FlusherPassReport) => void;
33
+ /** Native Worker error transport retains SQLite's code/errcode. */
34
+ onError?: (error: Error) => void;
35
+ }
36
+ /**
37
+ * Main-thread side of the flusher (SYNTHESIS_R5 §4.3): owns the monotonic
38
+ * generation `g`, hands one to every external-file registration and every
39
+ * `flushed()` call, forwards them to the worker in order, and resolves them
40
+ * on `synced(G)`. Unacknowledged registrations live here and are replayed to
41
+ * a restarted worker; waiters that predate a worker death are rejected typed
42
+ * (`store_flush_unavailable`) — the commit is intact, only the power-loss
43
+ * barrier is unproven until the next worker proves one.
44
+ */
45
+ export declare class FlusherController {
46
+ private readonly options;
47
+ private readonly entry;
48
+ private worker;
49
+ private state;
50
+ private generation;
51
+ private acknowledged;
52
+ private readonly outstanding;
53
+ private readonly waiters;
54
+ private lastReport;
55
+ private lastBarrierAt;
56
+ private counters;
57
+ private restarts;
58
+ private deaths;
59
+ private closing;
60
+ private readyInThisLife;
61
+ private restartTimer;
62
+ constructor(options: FlusherControllerOptions);
63
+ /** Spawn the worker and wait until it opened its connection (or died trying). */
64
+ start(): Promise<void>;
65
+ nextGeneration(): number;
66
+ /** A directory whose entries changed (rename/link); fsynced in the covering pass. */
67
+ register(dir: string): number;
68
+ /** A generation with no waiter: "everything up to now" for an obligation to clear on. */
69
+ mark(): number;
70
+ /** Resolves once a pass that started after this call proved its barrier. */
71
+ flushed(): Promise<void>;
72
+ /** Resolves once an already issued generation (a mark or registration) is acknowledged. */
73
+ awaitGeneration(g: number): Promise<void>;
74
+ private addWaiter;
75
+ private eachWaiter;
76
+ facts(): FlusherFacts;
77
+ /** Test seam: run one pass now (worker spawned with `manualTick`). */
78
+ tick(): void;
79
+ /** Test seam: make the worker exit (worker spawned with `allowExit`). */
80
+ requestExit(code: number): void;
81
+ stop(): Promise<void>;
82
+ private send;
83
+ private spawn;
84
+ private onSynced;
85
+ private onDeath;
86
+ }
87
+ //# sourceMappingURL=flusher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flusher.d.ts","sourceRoot":"","sources":["../../src/store/flusher.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB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AO,CAAC,QAAQ;IAmBhB,OAAO,CAAC,OAAO;CAoChB"}
@@ -0,0 +1,264 @@
1
+ import { Worker } from "node:worker_threads";
2
+ import { StoreFlushUnavailableError } from "./errors.js";
3
+ import { FLUSH_INTERVAL_MS, STORE_WORKER_DATA_KEY, resolveStoreWorkerEntry, } from "./flusher-protocol.js";
4
+ // Static import: the worker module must be part of this module graph so the
5
+ // single-file daemon bundle embeds it (its self-start is inert on the main thread).
6
+ import "./flusher-worker.js";
7
+ /**
8
+ * Main-thread side of the flusher (SYNTHESIS_R5 §4.3): owns the monotonic
9
+ * generation `g`, hands one to every external-file registration and every
10
+ * `flushed()` call, forwards them to the worker in order, and resolves them
11
+ * on `synced(G)`. Unacknowledged registrations live here and are replayed to
12
+ * a restarted worker; waiters that predate a worker death are rejected typed
13
+ * (`store_flush_unavailable`) — the commit is intact, only the power-loss
14
+ * barrier is unproven until the next worker proves one.
15
+ */
16
+ export class FlusherController {
17
+ options;
18
+ entry;
19
+ worker = null;
20
+ state = "starting";
21
+ generation = 0;
22
+ acknowledged = 0;
23
+ outstanding = [];
24
+ waiters = new Map();
25
+ lastReport = null;
26
+ lastBarrierAt = null;
27
+ counters = {
28
+ passes: 0,
29
+ barriers: 0,
30
+ dirSyncs: 0,
31
+ busyPassive: 0,
32
+ walReopens: 0,
33
+ };
34
+ restarts = 0;
35
+ deaths = 0;
36
+ closing = false;
37
+ readyInThisLife = false;
38
+ restartTimer = null;
39
+ constructor(options) {
40
+ this.options = options;
41
+ this.entry =
42
+ options.workerEntry ?? resolveStoreWorkerEntry(import.meta.url, "flusher-worker.js");
43
+ }
44
+ /** Spawn the worker and wait until it opened its connection (or died trying). */
45
+ start() {
46
+ return new Promise((resolve) => {
47
+ this.spawn(resolve);
48
+ });
49
+ }
50
+ nextGeneration() {
51
+ this.generation += 1;
52
+ return this.generation;
53
+ }
54
+ /** A directory whose entries changed (rename/link); fsynced in the covering pass. */
55
+ register(dir) {
56
+ const g = this.nextGeneration();
57
+ this.send({ g, since: performance.now(), command: { type: "register", g, dir } });
58
+ return g;
59
+ }
60
+ /** A generation with no waiter: "everything up to now" for an obligation to clear on. */
61
+ mark() {
62
+ const g = this.nextGeneration();
63
+ this.send({ g, since: performance.now(), command: { type: "flush", g } });
64
+ return g;
65
+ }
66
+ /** Resolves once a pass that started after this call proved its barrier. */
67
+ flushed() {
68
+ const g = this.nextGeneration();
69
+ return new Promise((resolve, reject) => {
70
+ this.addWaiter(g, { resolve, reject, since: performance.now() });
71
+ this.send({ g, since: performance.now(), command: { type: "flush", g } });
72
+ });
73
+ }
74
+ /** Resolves once an already issued generation (a mark or registration) is acknowledged. */
75
+ awaitGeneration(g) {
76
+ if (g <= this.acknowledged)
77
+ return Promise.resolve();
78
+ return new Promise((resolve, reject) => {
79
+ this.addWaiter(g, { resolve, reject, since: performance.now() });
80
+ });
81
+ }
82
+ addWaiter(g, waiter) {
83
+ const list = this.waiters.get(g);
84
+ if (list)
85
+ list.push(waiter);
86
+ else
87
+ this.waiters.set(g, [waiter]);
88
+ }
89
+ eachWaiter(fn) {
90
+ for (const [g, list] of this.waiters)
91
+ for (const waiter of list)
92
+ fn(g, waiter);
93
+ }
94
+ facts() {
95
+ const now = performance.now();
96
+ let oldest = null;
97
+ for (const entry of this.outstanding)
98
+ oldest = oldest === null ? entry.since : Math.min(oldest, entry.since);
99
+ this.eachWaiter((_g, waiter) => {
100
+ oldest = oldest === null ? waiter.since : Math.min(oldest, waiter.since);
101
+ });
102
+ const last = this.lastReport;
103
+ return {
104
+ state: this.state,
105
+ interval_ms: FLUSH_INTERVAL_MS,
106
+ generation: this.generation,
107
+ acknowledged_generation: this.acknowledged,
108
+ pending_registrations: this.outstanding.filter((e) => e.command.type === "register").length,
109
+ pending_waiters: [...this.waiters.values()].reduce((n, list) => n + list.length, 0),
110
+ flush_lag_ms: oldest === null ? 0 : Math.round(now - oldest),
111
+ last_barrier_at: this.lastBarrierAt === null ? null : new Date(this.lastBarrierAt).toISOString(),
112
+ last_pass: last
113
+ ? {
114
+ at: new Date(last.at).toISOString(),
115
+ pass_ms: last.passMs,
116
+ barrier_ms: last.barrierMs,
117
+ dirty: last.dirty,
118
+ barrier: last.barrier,
119
+ wal_bytes: last.walBytes,
120
+ checkpoint: last.checkpoint,
121
+ }
122
+ : null,
123
+ counters: { ...this.counters, restarts: this.restarts, deaths: this.deaths },
124
+ };
125
+ }
126
+ /** Test seam: run one pass now (worker spawned with `manualTick`). */
127
+ tick() {
128
+ this.worker?.postMessage({ type: "tick" });
129
+ }
130
+ /** Test seam: make the worker exit (worker spawned with `allowExit`). */
131
+ requestExit(code) {
132
+ this.worker?.postMessage({ type: "exit", code });
133
+ }
134
+ async stop() {
135
+ this.closing = true;
136
+ if (this.restartTimer) {
137
+ clearTimeout(this.restartTimer);
138
+ clearImmediate(this.restartTimer);
139
+ this.restartTimer = null;
140
+ }
141
+ const worker = this.worker;
142
+ this.worker = null;
143
+ this.eachWaiter((g, waiter) => waiter.reject(new StoreFlushUnavailableError(g, "engine store is closing")));
144
+ this.waiters.clear();
145
+ if (!worker)
146
+ return;
147
+ const exited = new Promise((resolve) => worker.once("exit", () => resolve()));
148
+ worker.postMessage({ type: "stop" });
149
+ await Promise.race([exited, new Promise((r) => setTimeout(r, FLUSH_INTERVAL_MS * 5))]);
150
+ await worker.terminate();
151
+ this.state = "down";
152
+ }
153
+ send(entry) {
154
+ this.outstanding.push(entry);
155
+ this.worker?.postMessage(entry.command);
156
+ }
157
+ spawn(onSettled) {
158
+ if (this.closing)
159
+ return;
160
+ const data = {
161
+ [STORE_WORKER_DATA_KEY]: "flusher",
162
+ dbPath: this.options.dbPath,
163
+ hooks: this.options.hooks ?? {},
164
+ };
165
+ const worker = new Worker(this.entry, { workerData: data, name: "claudexor-store-flusher" });
166
+ this.worker = worker;
167
+ this.state = "starting";
168
+ this.readyInThisLife = false;
169
+ let settled = false;
170
+ const settle = () => {
171
+ if (settled)
172
+ return;
173
+ settled = true;
174
+ onSettled?.();
175
+ };
176
+ worker.on("message", (event) => {
177
+ if (this.worker !== worker)
178
+ return;
179
+ if (event.type === "ready") {
180
+ this.readyInThisLife = true;
181
+ this.state = "up";
182
+ settle();
183
+ return;
184
+ }
185
+ if (event.type === "synced")
186
+ this.onSynced(event.report);
187
+ });
188
+ worker.on("error", (error) => {
189
+ if (this.worker !== worker || this.closing)
190
+ return;
191
+ this.options.onError?.(error);
192
+ this.options.log?.(`store flusher worker error: ${error.message}`);
193
+ });
194
+ worker.on("exit", (code) => {
195
+ if (this.worker !== worker)
196
+ return;
197
+ this.worker = null;
198
+ if (this.closing)
199
+ return;
200
+ this.onDeath(code);
201
+ settle();
202
+ });
203
+ // Replay everything the previous life never acknowledged, in generation order.
204
+ for (const entry of this.outstanding)
205
+ worker.postMessage(entry.command);
206
+ }
207
+ onSynced(report) {
208
+ this.lastReport = report;
209
+ this.counters = report.counters;
210
+ if (report.barrier)
211
+ this.lastBarrierAt = report.at;
212
+ if (report.g > this.acknowledged)
213
+ this.acknowledged = report.g;
214
+ let kept = 0;
215
+ for (const entry of this.outstanding) {
216
+ if (entry.g > report.g)
217
+ this.outstanding[kept++] = entry;
218
+ }
219
+ this.outstanding.length = kept;
220
+ for (const [g, list] of this.waiters) {
221
+ if (g <= report.g) {
222
+ this.waiters.delete(g);
223
+ for (const waiter of list)
224
+ waiter.resolve();
225
+ }
226
+ }
227
+ this.options.onSynced?.(report.g, report);
228
+ }
229
+ onDeath(code) {
230
+ this.deaths += 1;
231
+ this.state = "down";
232
+ this.options.log?.(`store flusher worker exited with code ${code}; restarting`);
233
+ // Waiters created before the death are rejected typed; their flush
234
+ // commands are dropped, registrations stay outstanding for the replay.
235
+ this.eachWaiter((g, waiter) => waiter.reject(new StoreFlushUnavailableError(g, `the flusher worker exited with code ${code}`)));
236
+ this.waiters.clear();
237
+ let kept = 0;
238
+ for (const entry of this.outstanding) {
239
+ if (entry.command.type === "register")
240
+ this.outstanding[kept++] = entry;
241
+ }
242
+ this.outstanding.length = kept;
243
+ // A worker that never reported ready failed at startup; retry after one
244
+ // interval instead of spinning on the next tick.
245
+ const restart = () => {
246
+ this.restartTimer = null;
247
+ if (this.closing)
248
+ return;
249
+ this.restarts += 1;
250
+ this.spawn();
251
+ // Drive the new worker's g_target to the current generation so the next
252
+ // pass covers every commit made during the gap.
253
+ this.send({
254
+ g: this.generation,
255
+ since: performance.now(),
256
+ command: { type: "flush", g: this.generation },
257
+ });
258
+ };
259
+ this.restartTimer = this.readyInThisLife
260
+ ? setImmediate(restart)
261
+ : setTimeout(restart, FLUSH_INTERVAL_MS);
262
+ }
263
+ }
264
+ //# sourceMappingURL=flusher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flusher.js","sourceRoot":"","sources":["../../src/store/flusher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,GAOxB,MAAM,uBAAuB,CAAC;AAC/B,4EAA4E;AAC5E,oFAAoF;AACpF,OAAO,qBAAqB,CAAC;AA8C7B;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAiB;IAuBC,OAAO;IAtBnB,KAAK,CAAS;IACvB,MAAM,GAAkB,IAAI,CAAC;IAC7B,KAAK,GAA0B,UAAU,CAAC;IAC1C,UAAU,GAAG,CAAC,CAAC;IACf,YAAY,GAAG,CAAC,CAAC;IACR,WAAW,GAAkB,EAAE,CAAC;IAChC,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC/C,UAAU,GAA6B,IAAI,CAAC;IAC5C,aAAa,GAAkB,IAAI,CAAC;IACpC,QAAQ,GAAoB;QAClC,MAAM,EAAE,CAAC;QACT,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,CAAC;KACd,CAAC;IACM,QAAQ,GAAG,CAA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