velocious 1.0.666 → 1.0.668

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 (174) hide show
  1. package/README.md +40 -11
  2. package/build/background-jobs/adapter-client.js +22 -0
  3. package/build/background-jobs/adapter.js +15 -0
  4. package/build/background-jobs/client.js +147 -1
  5. package/build/background-jobs/job-semantics.js +30 -0
  6. package/build/background-jobs/job.js +26 -1
  7. package/build/background-jobs/local-adapter.js +36 -8
  8. package/build/background-jobs/local-store.js +410 -39
  9. package/build/background-jobs/main.js +69 -2
  10. package/build/background-jobs/platform-job.js +26 -1
  11. package/build/background-jobs/runtime.js +58 -0
  12. package/build/background-jobs/store.js +374 -6
  13. package/build/background-jobs/types.js +27 -2
  14. package/build/background-jobs/web/controller.js +1 -0
  15. package/build/configuration.js +30 -6
  16. package/build/database/drivers/mssql/column.js +2 -2
  17. package/build/database/drivers/mssql/table.js +19 -5
  18. package/build/database/pool/async-tracked-multi-connection.js +2 -1
  19. package/build/database/query/alter-table-base.js +8 -1
  20. package/build/database/record/attachments/store.js +2 -2
  21. package/build/environment-handlers/node/cli/commands/test/timing-manifest/merge.js +2 -48
  22. package/build/environment-handlers/node/cli/commands/test.js +17 -69
  23. package/build/frontend-model-controller.js +22 -2
  24. package/build/frontend-models/websocket-channel.js +18 -0
  25. package/build/http-server/client/websocket-session.js +41 -4
  26. package/build/http-server/websocket-channel.js +14 -0
  27. package/build/http-server/websocket-event-log-store.js +85 -12
  28. package/build/http-server/websocket-events-host.js +17 -7
  29. package/build/src/background-jobs/adapter-client.d.ts +17 -0
  30. package/build/src/background-jobs/adapter-client.d.ts.map +1 -1
  31. package/build/src/background-jobs/adapter-client.js +19 -1
  32. package/build/src/background-jobs/adapter.d.ts +15 -0
  33. package/build/src/background-jobs/adapter.d.ts.map +1 -1
  34. package/build/src/background-jobs/adapter.js +14 -1
  35. package/build/src/background-jobs/client.d.ts +17 -0
  36. package/build/src/background-jobs/client.d.ts.map +1 -1
  37. package/build/src/background-jobs/client.js +129 -1
  38. package/build/src/background-jobs/job-semantics.d.ts +18 -0
  39. package/build/src/background-jobs/job-semantics.d.ts.map +1 -1
  40. package/build/src/background-jobs/job-semantics.js +28 -1
  41. package/build/src/background-jobs/job.d.ts +15 -0
  42. package/build/src/background-jobs/job.d.ts.map +1 -1
  43. package/build/src/background-jobs/job.js +21 -2
  44. package/build/src/background-jobs/local-adapter.d.ts +23 -8
  45. package/build/src/background-jobs/local-adapter.d.ts.map +1 -1
  46. package/build/src/background-jobs/local-adapter.js +35 -9
  47. package/build/src/background-jobs/local-store.d.ts +120 -5
  48. package/build/src/background-jobs/local-store.d.ts.map +1 -1
  49. package/build/src/background-jobs/local-store.js +366 -40
  50. package/build/src/background-jobs/main.d.ts +24 -2
  51. package/build/src/background-jobs/main.d.ts.map +1 -1
  52. package/build/src/background-jobs/main.js +68 -3
  53. package/build/src/background-jobs/platform-job.d.ts +15 -0
  54. package/build/src/background-jobs/platform-job.d.ts.map +1 -1
  55. package/build/src/background-jobs/platform-job.js +19 -2
  56. package/build/src/background-jobs/runtime.d.ts +39 -0
  57. package/build/src/background-jobs/runtime.d.ts.map +1 -1
  58. package/build/src/background-jobs/runtime.js +49 -1
  59. package/build/src/background-jobs/store.d.ts +100 -1
  60. package/build/src/background-jobs/store.d.ts.map +1 -1
  61. package/build/src/background-jobs/store.js +334 -8
  62. package/build/src/background-jobs/types.d.ts +97 -4
  63. package/build/src/background-jobs/types.d.ts.map +1 -1
  64. package/build/src/background-jobs/types.js +28 -3
  65. package/build/src/background-jobs/web/controller.d.ts.map +1 -1
  66. package/build/src/background-jobs/web/controller.js +2 -1
  67. package/build/src/configuration.d.ts +18 -1
  68. package/build/src/configuration.d.ts.map +1 -1
  69. package/build/src/configuration.js +28 -6
  70. package/build/src/database/drivers/mssql/column.d.ts.map +1 -1
  71. package/build/src/database/drivers/mssql/column.js +2 -2
  72. package/build/src/database/drivers/mssql/table.d.ts.map +1 -1
  73. package/build/src/database/drivers/mssql/table.js +19 -5
  74. package/build/src/database/pool/async-tracked-multi-connection.d.ts.map +1 -1
  75. package/build/src/database/pool/async-tracked-multi-connection.js +3 -2
  76. package/build/src/database/query/alter-table-base.d.ts.map +1 -1
  77. package/build/src/database/query/alter-table-base.js +9 -2
  78. package/build/src/database/record/attachments/store.js +3 -3
  79. package/build/src/environment-handlers/node/cli/commands/test/timing-manifest/merge.d.ts.map +1 -1
  80. package/build/src/environment-handlers/node/cli/commands/test/timing-manifest/merge.js +3 -47
  81. package/build/src/environment-handlers/node/cli/commands/test.d.ts +2 -28
  82. package/build/src/environment-handlers/node/cli/commands/test.d.ts.map +1 -1
  83. package/build/src/environment-handlers/node/cli/commands/test.js +10 -61
  84. package/build/src/frontend-model-controller.d.ts.map +1 -1
  85. package/build/src/frontend-model-controller.js +18 -3
  86. package/build/src/frontend-models/websocket-channel.d.ts +9 -0
  87. package/build/src/frontend-models/websocket-channel.d.ts.map +1 -1
  88. package/build/src/frontend-models/websocket-channel.js +16 -1
  89. package/build/src/http-server/client/websocket-session.d.ts +25 -2
  90. package/build/src/http-server/client/websocket-session.d.ts.map +1 -1
  91. package/build/src/http-server/client/websocket-session.js +40 -5
  92. package/build/src/http-server/websocket-channel.d.ts +11 -0
  93. package/build/src/http-server/websocket-channel.d.ts.map +1 -1
  94. package/build/src/http-server/websocket-channel.js +14 -1
  95. package/build/src/http-server/websocket-event-log-store.d.ts +60 -41
  96. package/build/src/http-server/websocket-event-log-store.d.ts.map +1 -1
  97. package/build/src/http-server/websocket-event-log-store.js +79 -12
  98. package/build/src/http-server/websocket-events-host.d.ts +10 -3
  99. package/build/src/http-server/websocket-events-host.d.ts.map +1 -1
  100. package/build/src/http-server/websocket-events-host.js +17 -8
  101. package/build/src/testing/test-files-finder.d.ts +17 -117
  102. package/build/src/testing/test-files-finder.d.ts.map +1 -1
  103. package/build/src/testing/test-files-finder.js +29 -294
  104. package/build/src/testing/test-filter-parser.d.ts +32 -22
  105. package/build/src/testing/test-filter-parser.d.ts.map +1 -1
  106. package/build/src/testing/test-filter-parser.js +25 -217
  107. package/build/src/testing/test-profile-activity.d.ts +1 -6
  108. package/build/src/testing/test-profile-activity.d.ts.map +1 -1
  109. package/build/src/testing/test-profile-activity.js +2 -12
  110. package/build/src/testing/test-profile-output.d.ts +1 -40
  111. package/build/src/testing/test-profile-output.d.ts.map +1 -1
  112. package/build/src/testing/test-profile-output.js +2 -217
  113. package/build/src/testing/test-profiler.d.ts +15 -659
  114. package/build/src/testing/test-profiler.d.ts.map +1 -1
  115. package/build/src/testing/test-profiler.js +35 -833
  116. package/build/src/testing/test-runner.d.ts +10 -1
  117. package/build/src/testing/test-runner.d.ts.map +1 -1
  118. package/build/src/testing/test-runner.js +26 -4
  119. package/build/src/testing/test-suite-splitter.d.ts +1 -128
  120. package/build/src/testing/test-suite-splitter.d.ts.map +1 -1
  121. package/build/src/testing/test-suite-splitter.js +2 -259
  122. package/build/src/testing/timing-manifest.d.ts +5 -93
  123. package/build/src/testing/timing-manifest.d.ts.map +1 -1
  124. package/build/src/testing/timing-manifest.js +4 -283
  125. package/build/src/testing/velocious-attempt-executor.d.ts.map +1 -1
  126. package/build/src/testing/velocious-attempt-executor.js +8 -2
  127. package/build/testing/test-files-finder.js +32 -343
  128. package/build/testing/test-filter-parser.js +29 -248
  129. package/build/testing/test-profile-activity.js +1 -12
  130. package/build/testing/test-profile-output.js +8 -253
  131. package/build/testing/test-profiler.js +38 -895
  132. package/build/testing/test-runner.js +33 -9
  133. package/build/testing/test-suite-splitter.js +1 -301
  134. package/build/testing/timing-manifest.js +10 -344
  135. package/build/testing/velocious-attempt-executor.js +7 -1
  136. package/package.json +3 -3
  137. package/scripts/test-browser.js +30 -6
  138. package/scripts/verify-docker-dev-environment.js +13 -1
  139. package/src/background-jobs/adapter-client.js +22 -0
  140. package/src/background-jobs/adapter.js +15 -0
  141. package/src/background-jobs/client.js +147 -1
  142. package/src/background-jobs/job-semantics.js +30 -0
  143. package/src/background-jobs/job.js +26 -1
  144. package/src/background-jobs/local-adapter.js +36 -8
  145. package/src/background-jobs/local-store.js +410 -39
  146. package/src/background-jobs/main.js +69 -2
  147. package/src/background-jobs/platform-job.js +26 -1
  148. package/src/background-jobs/runtime.js +58 -0
  149. package/src/background-jobs/store.js +374 -6
  150. package/src/background-jobs/types.js +27 -2
  151. package/src/background-jobs/web/controller.js +1 -0
  152. package/src/configuration.js +30 -6
  153. package/src/database/drivers/mssql/column.js +2 -2
  154. package/src/database/drivers/mssql/table.js +19 -5
  155. package/src/database/pool/async-tracked-multi-connection.js +2 -1
  156. package/src/database/query/alter-table-base.js +8 -1
  157. package/src/database/record/attachments/store.js +2 -2
  158. package/src/environment-handlers/node/cli/commands/test/timing-manifest/merge.js +2 -48
  159. package/src/environment-handlers/node/cli/commands/test.js +17 -69
  160. package/src/frontend-model-controller.js +22 -2
  161. package/src/frontend-models/websocket-channel.js +18 -0
  162. package/src/http-server/client/websocket-session.js +41 -4
  163. package/src/http-server/websocket-channel.js +14 -0
  164. package/src/http-server/websocket-event-log-store.js +85 -12
  165. package/src/http-server/websocket-events-host.js +17 -7
  166. package/src/testing/test-files-finder.js +32 -343
  167. package/src/testing/test-filter-parser.js +29 -248
  168. package/src/testing/test-profile-activity.js +1 -12
  169. package/src/testing/test-profile-output.js +8 -253
  170. package/src/testing/test-profiler.js +38 -895
  171. package/src/testing/test-runner.js +33 -9
  172. package/src/testing/test-suite-splitter.js +1 -301
  173. package/src/testing/timing-manifest.js +10 -344
  174. package/src/testing/velocious-attempt-executor.js +7 -1
@@ -529,7 +529,6 @@ export default class BackgroundJobsMain {
529
529
  await this.store.reconcileQueueConcurrency()
530
530
  if (this.lifecycleState !== expectedLifecycleState) return false
531
531
  this._setupDispatchTriggers()
532
- this._setupStartupHandoffReclaim()
533
532
  this._startOrphanSweep()
534
533
  await this._startScheduler()
535
534
  if (this.lifecycleState !== expectedLifecycleState) {
@@ -542,6 +541,7 @@ export default class BackgroundJobsMain {
542
541
  this._activeOwnershipReady = true
543
542
  this._creditReadyWorkers()
544
543
  await this._drain()
544
+ if (this.lifecycleState === expectedLifecycleState) this._setupStartupHandoffReclaim()
545
545
  return this.lifecycleState === expectedLifecycleState
546
546
  }
547
547
 
@@ -1157,6 +1157,8 @@ export default class BackgroundJobsMain {
1157
1157
  if (message?.type === "enqueue" && !message.producerProof) jsonSocket.send({type: "enqueue-error", error: "Background jobs generation is retired"})
1158
1158
  if (message?.type === "replace-scheduled") jsonSocket.send({type: "replace-scheduled-error", error: "Background jobs generation is retired"})
1159
1159
  if (message?.type === "cancel-scheduled") jsonSocket.send({type: "cancel-scheduled-error", error: "Background jobs generation is retired"})
1160
+ if (message?.type === "get-scheduled-job") jsonSocket.send({type: "get-scheduled-job-error", error: "Background jobs generation is retired"})
1161
+ if (message?.type === "wake-scheduled") jsonSocket.send({type: "wake-scheduled-error", error: "Background jobs generation is retired"})
1160
1162
  if (message?.type !== "enqueue" || !message.producerProof) return
1161
1163
  }
1162
1164
 
@@ -1172,6 +1174,16 @@ export default class BackgroundJobsMain {
1172
1174
 
1173
1175
  if (message?.type === "cancel-scheduled") {
1174
1176
  await this._handleCancelScheduled({jsonSocket, message})
1177
+ return
1178
+ }
1179
+
1180
+ if (message?.type === "get-scheduled-job") {
1181
+ await this._handleGetScheduledJob({jsonSocket, message})
1182
+ return
1183
+ }
1184
+
1185
+ if (message?.type === "wake-scheduled") {
1186
+ await this._handleWakeScheduled({jsonSocket, message})
1175
1187
  }
1176
1188
  }
1177
1189
 
@@ -1599,6 +1611,61 @@ export default class BackgroundJobsMain {
1599
1611
  }
1600
1612
  }
1601
1613
 
1614
+ /**
1615
+ * Handles a stable schedule lookup and returns only normalized adapter jobs.
1616
+ * @param {object} args - Options.
1617
+ * @param {JsonSocket} args.jsonSocket - JSON socket.
1618
+ * @param {import("./types.js").BackgroundJobGetScheduledMessage} args.message - Message.
1619
+ * @returns {Promise<void>} - Resolves when handled.
1620
+ */
1621
+ async _handleGetScheduledJob({jsonSocket, message}) {
1622
+ try {
1623
+ const result = await this.store.getScheduledJob(message.scheduleKey, {
1624
+ includeLatestTerminal: message.includeLatestTerminal
1625
+ })
1626
+
1627
+ jsonSocket.send({type: "scheduled-job", ...result})
1628
+ } catch (error) {
1629
+ this._handleClientMutationError({
1630
+ context: {scheduleKey: message.scheduleKey, stage: "background-job-get-scheduled"},
1631
+ error,
1632
+ fallbackMessage: "Failed to read scheduled job",
1633
+ jsonSocket,
1634
+ logMessage: "Failed to read scheduled background job:",
1635
+ responseType: "get-scheduled-job-error"
1636
+ })
1637
+ }
1638
+ }
1639
+
1640
+ /**
1641
+ * Handles a stable schedule wake and re-arms dispatch after its transaction commits.
1642
+ * @param {object} args - Options.
1643
+ * @param {JsonSocket} args.jsonSocket - JSON socket.
1644
+ * @param {import("./types.js").BackgroundJobWakeScheduledMessage} args.message - Message.
1645
+ * @returns {Promise<void>} - Resolves when handled.
1646
+ */
1647
+ async _handleWakeScheduled({jsonSocket, message}) {
1648
+ try {
1649
+ const result = await this.store.wakeScheduled(message.scheduleKey)
1650
+
1651
+ if (result.outcome === "woken" || result.outcome === "already_due") {
1652
+ this._notifyEnqueued()
1653
+ await this._drain()
1654
+ }
1655
+
1656
+ jsonSocket.send({type: "schedule-woken", ...result})
1657
+ } catch (error) {
1658
+ this._handleClientMutationError({
1659
+ context: {scheduleKey: message.scheduleKey, stage: "background-job-wake-scheduled"},
1660
+ error,
1661
+ fallbackMessage: "Failed to wake scheduled job",
1662
+ jsonSocket,
1663
+ logMessage: "Failed to wake scheduled background job:",
1664
+ responseType: "wake-scheduled-error"
1665
+ })
1666
+ }
1667
+ }
1668
+
1602
1669
  /**
1603
1670
  * Returns safe validation failures and reports unexpected client mutations.
1604
1671
  * @param {object} args - Options.
@@ -1607,7 +1674,7 @@ export default class BackgroundJobsMain {
1607
1674
  * @param {string} args.fallbackMessage - Client-safe fallback message.
1608
1675
  * @param {JsonSocket} args.jsonSocket - JSON socket.
1609
1676
  * @param {string} args.logMessage - Error log prefix.
1610
- * @param {"enqueue-error" | "replace-scheduled-error" | "cancel-scheduled-error"} args.responseType - Response type.
1677
+ * @param {"enqueue-error" | "replace-scheduled-error" | "cancel-scheduled-error" | "get-scheduled-job-error" | "wake-scheduled-error"} args.responseType - Response type.
1611
1678
  * @returns {void}
1612
1679
  */
1613
1680
  _handleClientMutationError({context, error, fallbackMessage, jsonSocket, logMessage, responseType}) {
@@ -1,7 +1,13 @@
1
1
  // @ts-check
2
2
 
3
3
  import BackgroundJobRescheduleSignal from "./reschedule-signal.js"
4
- import {cancelScheduledBackgroundJob, enqueueBackgroundJob, replaceScheduledBackgroundJob} from "./runtime.js"
4
+ import {
5
+ cancelScheduledBackgroundJob,
6
+ enqueueBackgroundJob,
7
+ getScheduledBackgroundJob,
8
+ replaceScheduledBackgroundJob,
9
+ wakeScheduledBackgroundJob
10
+ } from "./runtime.js"
5
11
 
6
12
  /**
7
13
  * Base class for background jobs.
@@ -186,6 +192,25 @@ export default class VelociousJob {
186
192
  return await cancelScheduledBackgroundJob(scheduleKey)
187
193
  }
188
194
 
195
+ /**
196
+ * Reads current ownership and optional terminal history for a stable key.
197
+ * @param {string} scheduleKey - Stable logical schedule key.
198
+ * @param {{includeLatestTerminal?: boolean}} [options] - Lookup options.
199
+ * @returns {Promise<import("./types.js").BackgroundJobScheduledLookupResult>} - Normalized stable schedule jobs.
200
+ */
201
+ static async getScheduledJob(scheduleKey, options = {}) {
202
+ return await getScheduledBackgroundJob(scheduleKey, options)
203
+ }
204
+
205
+ /**
206
+ * Expedites a future queued owner without creating another job.
207
+ * @param {string} scheduleKey - Stable logical schedule key.
208
+ * @returns {Promise<import("./types.js").BackgroundJobWakeResult>} - Wake result.
209
+ */
210
+ static async wakeScheduled(scheduleKey) {
211
+ return await wakeScheduledBackgroundJob(scheduleKey)
212
+ }
213
+
189
214
  /**
190
215
  * Runs split args and options.
191
216
  * @param {Array<ReturnType<typeof JSON.parse>>} args - Job args.
@@ -161,3 +161,61 @@ export async function cancelScheduledBackgroundJobForConfiguration({configuratio
161
161
 
162
162
  return await client.cancelScheduled({scheduleKey})
163
163
  }
164
+
165
+ /**
166
+ * Reads stable schedule ownership in background mode.
167
+ * @param {string} scheduleKey - Stable logical schedule key.
168
+ * @param {{includeLatestTerminal?: boolean}} [options] - Lookup options.
169
+ * @returns {Promise<import("./types.js").BackgroundJobScheduledLookupResult>} - Normalized stable schedule jobs.
170
+ */
171
+ export async function getScheduledBackgroundJob(scheduleKey, options = {}) {
172
+ const configuration = currentConfiguration()
173
+
174
+ return await getScheduledBackgroundJobForConfiguration({configuration, scheduleKey, ...options})
175
+ }
176
+
177
+ /**
178
+ * Reads stable schedule ownership using an explicitly resolved configuration.
179
+ * @param {object} args - Lookup request.
180
+ * @param {import("../configuration.js").default} args.configuration - Configuration.
181
+ * @param {string} args.scheduleKey - Stable logical schedule key.
182
+ * @param {boolean} [args.includeLatestTerminal] - Whether to include latest terminal history.
183
+ * @returns {Promise<import("./types.js").BackgroundJobScheduledLookupResult>} - Normalized stable schedule jobs.
184
+ */
185
+ export async function getScheduledBackgroundJobForConfiguration({configuration, scheduleKey, includeLatestTerminal}) {
186
+ if (configuration.getBackgroundJobsConfig().mode === "inline") {
187
+ throw new Error("getScheduledJob is not supported in inline mode")
188
+ }
189
+
190
+ const client = configuration.getEnvironmentHandler().backgroundJobsClient({configuration})
191
+
192
+ return await client.getScheduledJob({scheduleKey, includeLatestTerminal})
193
+ }
194
+
195
+ /**
196
+ * Wakes a stable schedule owner in background mode.
197
+ * @param {string} scheduleKey - Stable logical schedule key.
198
+ * @returns {Promise<import("./types.js").BackgroundJobWakeResult>} - Wake result.
199
+ */
200
+ export async function wakeScheduledBackgroundJob(scheduleKey) {
201
+ const configuration = currentConfiguration()
202
+
203
+ return await wakeScheduledBackgroundJobForConfiguration({configuration, scheduleKey})
204
+ }
205
+
206
+ /**
207
+ * Wakes a stable schedule owner using an explicitly resolved configuration.
208
+ * @param {object} args - Wake request.
209
+ * @param {import("../configuration.js").default} args.configuration - Configuration.
210
+ * @param {string} args.scheduleKey - Stable logical schedule key.
211
+ * @returns {Promise<import("./types.js").BackgroundJobWakeResult>} - Wake result.
212
+ */
213
+ export async function wakeScheduledBackgroundJobForConfiguration({configuration, scheduleKey}) {
214
+ if (configuration.getBackgroundJobsConfig().mode === "inline") {
215
+ throw new Error("wakeScheduled is not supported in inline mode")
216
+ }
217
+
218
+ const client = configuration.getEnvironmentHandler().backgroundJobsClient({configuration})
219
+
220
+ return await client.wakeScheduled({scheduleKey})
221
+ }