@usine/engine 0.2.0 → 0.4.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 (192) hide show
  1. package/README.md +109 -36
  2. package/dist/board-moves/board-moves.d.ts +20 -0
  3. package/dist/board-moves/board-moves.d.ts.map +1 -0
  4. package/dist/board-moves/board-moves.js +74 -0
  5. package/dist/board-moves/board-moves.js.map +1 -0
  6. package/dist/board-moves/model.d.ts +21 -0
  7. package/dist/board-moves/model.d.ts.map +1 -0
  8. package/dist/board-moves/model.js +22 -0
  9. package/dist/board-moves/model.js.map +1 -0
  10. package/dist/cursor/cursor.d.ts +2 -6
  11. package/dist/cursor/cursor.d.ts.map +1 -1
  12. package/dist/cursor/cursor.js +2 -6
  13. package/dist/cursor/cursor.js.map +1 -1
  14. package/dist/cycle-budget/cycle-budget.d.ts +6 -6
  15. package/dist/cycle-budget/cycle-budget.d.ts.map +1 -1
  16. package/dist/cycle-budget/cycle-budget.js +5 -5
  17. package/dist/cycle-budget/cycle-budget.js.map +1 -1
  18. package/dist/cycle-budget/model.d.ts +2 -2
  19. package/dist/cycle-budget/model.d.ts.map +1 -1
  20. package/dist/cycle-budget/model.js +2 -2
  21. package/dist/cycle-budget/model.js.map +1 -1
  22. package/dist/cycle-budget/queries.d.ts +1 -1
  23. package/dist/cycle-budget/queries.d.ts.map +1 -1
  24. package/dist/cycle-budget/queries.js +3 -3
  25. package/dist/cycle-budget/queries.js.map +1 -1
  26. package/dist/database/database.d.ts +1 -1
  27. package/dist/database/database.d.ts.map +1 -1
  28. package/dist/database/local-sqlite.d.ts +10 -8
  29. package/dist/database/local-sqlite.d.ts.map +1 -1
  30. package/dist/database/local-sqlite.js +16 -9
  31. package/dist/database/local-sqlite.js.map +1 -1
  32. package/dist/database/schema.d.ts +581 -22
  33. package/dist/database/schema.d.ts.map +1 -1
  34. package/dist/database/schema.js +104 -23
  35. package/dist/database/schema.js.map +1 -1
  36. package/dist/{workflow → engine}/admission.d.ts +2 -2
  37. package/dist/engine/admission.d.ts.map +1 -0
  38. package/dist/{workflow → engine}/admission.js +4 -4
  39. package/dist/engine/admission.js.map +1 -0
  40. package/dist/engine/checkout-recovery.d.ts +69 -0
  41. package/dist/engine/checkout-recovery.d.ts.map +1 -0
  42. package/dist/engine/checkout-recovery.js +181 -0
  43. package/dist/engine/checkout-recovery.js.map +1 -0
  44. package/dist/engine/engine.d.ts +57 -24
  45. package/dist/engine/engine.d.ts.map +1 -1
  46. package/dist/engine/engine.js +144 -120
  47. package/dist/engine/engine.js.map +1 -1
  48. package/dist/engine/error.d.ts +36 -9
  49. package/dist/engine/error.d.ts.map +1 -1
  50. package/dist/engine/error.js +35 -7
  51. package/dist/engine/error.js.map +1 -1
  52. package/dist/engine/lifecycle.d.ts +81 -28
  53. package/dist/engine/lifecycle.d.ts.map +1 -1
  54. package/dist/engine/lifecycle.js +83 -44
  55. package/dist/engine/lifecycle.js.map +1 -1
  56. package/dist/engine/retry.d.ts +16 -0
  57. package/dist/engine/retry.d.ts.map +1 -0
  58. package/dist/engine/retry.js +18 -0
  59. package/dist/engine/retry.js.map +1 -0
  60. package/dist/engine/run-again.d.ts +45 -0
  61. package/dist/engine/run-again.d.ts.map +1 -0
  62. package/dist/engine/run-again.js +56 -0
  63. package/dist/engine/run-again.js.map +1 -0
  64. package/dist/engine/run-driver.d.ts +54 -0
  65. package/dist/engine/run-driver.d.ts.map +1 -0
  66. package/dist/engine/run-driver.js +362 -0
  67. package/dist/engine/run-driver.js.map +1 -0
  68. package/dist/engine/shutdown.d.ts +3 -4
  69. package/dist/engine/shutdown.d.ts.map +1 -1
  70. package/dist/engine/shutdown.js +3 -4
  71. package/dist/engine/shutdown.js.map +1 -1
  72. package/dist/engine/submission.d.ts +31 -11
  73. package/dist/engine/submission.d.ts.map +1 -1
  74. package/dist/engine/submission.js +42 -12
  75. package/dist/engine/submission.js.map +1 -1
  76. package/dist/item-projection/item-projection.d.ts +12 -4
  77. package/dist/item-projection/item-projection.d.ts.map +1 -1
  78. package/dist/item-projection/item-projection.js +41 -6
  79. package/dist/item-projection/item-projection.js.map +1 -1
  80. package/dist/item-projection/model.d.ts +5 -1
  81. package/dist/item-projection/model.d.ts.map +1 -1
  82. package/dist/item-projection/model.js +6 -2
  83. package/dist/item-projection/model.js.map +1 -1
  84. package/dist/loop-control/loop-control.d.ts +5 -5
  85. package/dist/loop-control/loop-control.d.ts.map +1 -1
  86. package/dist/loop-control/loop-control.js +4 -4
  87. package/dist/loop-control/loop-control.js.map +1 -1
  88. package/dist/loop-control/model.d.ts +1 -1
  89. package/dist/loop-control/model.d.ts.map +1 -1
  90. package/dist/loop-control/model.js +1 -1
  91. package/dist/loop-control/model.js.map +1 -1
  92. package/dist/repository-label-projection/model.d.ts +2 -2
  93. package/dist/repository-label-projection/model.d.ts.map +1 -1
  94. package/dist/repository-label-projection/model.js +2 -2
  95. package/dist/repository-label-projection/model.js.map +1 -1
  96. package/dist/repository-label-projection/repository-label-projection.d.ts +1 -1
  97. package/dist/repository-label-projection/repository-label-projection.d.ts.map +1 -1
  98. package/dist/repository-label-projection/repository-label-projection.js +1 -1
  99. package/dist/repository-label-projection/repository-label-projection.js.map +1 -1
  100. package/dist/run-reader/model.d.ts +62 -4
  101. package/dist/run-reader/model.d.ts.map +1 -1
  102. package/dist/run-reader/model.js +66 -7
  103. package/dist/run-reader/model.js.map +1 -1
  104. package/dist/run-reader/run-reader.d.ts +19 -9
  105. package/dist/run-reader/run-reader.d.ts.map +1 -1
  106. package/dist/run-reader/run-reader.js +23 -7
  107. package/dist/run-reader/run-reader.js.map +1 -1
  108. package/dist/step-executor.d.ts +65 -9
  109. package/dist/step-executor.d.ts.map +1 -1
  110. package/dist/step-executor.js +10 -2
  111. package/dist/step-executor.js.map +1 -1
  112. package/dist/store/attempt-windows.d.ts +8 -0
  113. package/dist/store/attempt-windows.d.ts.map +1 -0
  114. package/dist/store/attempt-windows.js +53 -0
  115. package/dist/store/attempt-windows.js.map +1 -0
  116. package/dist/store/codec.d.ts +381 -42
  117. package/dist/store/codec.d.ts.map +1 -1
  118. package/dist/store/codec.js +59 -15
  119. package/dist/store/codec.js.map +1 -1
  120. package/dist/store/leftovers.d.ts +10 -0
  121. package/dist/store/leftovers.d.ts.map +1 -0
  122. package/dist/store/leftovers.js +43 -0
  123. package/dist/store/leftovers.js.map +1 -0
  124. package/dist/store/loop-items.d.ts +16 -0
  125. package/dist/store/loop-items.d.ts.map +1 -0
  126. package/dist/store/loop-items.js +185 -0
  127. package/dist/store/loop-items.js.map +1 -0
  128. package/dist/store/queries.d.ts +345 -37
  129. package/dist/store/queries.d.ts.map +1 -1
  130. package/dist/store/queries.js +333 -160
  131. package/dist/store/queries.js.map +1 -1
  132. package/dist/store/store.d.ts +91 -54
  133. package/dist/store/store.d.ts.map +1 -1
  134. package/dist/store/store.js +481 -190
  135. package/dist/store/store.js.map +1 -1
  136. package/dist/store/transcript.d.ts +9 -0
  137. package/dist/store/transcript.d.ts.map +1 -0
  138. package/dist/store/transcript.js +90 -0
  139. package/dist/store/transcript.js.map +1 -0
  140. package/dist/transcript.d.ts +41 -20
  141. package/dist/transcript.d.ts.map +1 -1
  142. package/dist/transcript.js +45 -25
  143. package/dist/transcript.js.map +1 -1
  144. package/dist/trigger-condition.d.ts +23 -0
  145. package/dist/trigger-condition.d.ts.map +1 -0
  146. package/dist/trigger-condition.js +8 -0
  147. package/dist/trigger-condition.js.map +1 -0
  148. package/drizzle/20260912111855_operator_intervention/migration.sql +42 -0
  149. package/drizzle/20260912111855_operator_intervention/snapshot.json +1461 -0
  150. package/drizzle/20260917071139_resolve_run_failure/migration.sql +1 -0
  151. package/drizzle/20260917071139_resolve_run_failure/snapshot.json +1471 -0
  152. package/drizzle/20260918032643_attempt_salvage/migration.sql +1 -0
  153. package/drizzle/20260918032643_attempt_salvage/snapshot.json +1481 -0
  154. package/drizzle/20261011153856_drop_workflow_tables/migration.sql +4 -0
  155. package/drizzle/20261011153856_drop_workflow_tables/snapshot.json +1433 -0
  156. package/drizzle/20261017155043_attempt_salvage_check/migration.sql +41 -0
  157. package/drizzle/20261017155043_attempt_salvage_check/snapshot.json +1421 -0
  158. package/drizzle/20261018162700_discard_attempt_leftovers/migration.sql +1 -0
  159. package/drizzle/20261018162700_discard_attempt_leftovers/snapshot.json +1431 -0
  160. package/drizzle/20261018172605_loop_items_and_reopenings/migration.sql +15 -0
  161. package/drizzle/20261018172605_loop_items_and_reopenings/snapshot.json +1574 -0
  162. package/drizzle/20261018180339_attempt_ended_at/migration.sql +1 -0
  163. package/drizzle/20261018180339_attempt_ended_at/snapshot.json +1584 -0
  164. package/drizzle/20261019104043_run_approval_source/migration.sql +15 -0
  165. package/drizzle/20261019104043_run_approval_source/snapshot.json +1610 -0
  166. package/drizzle/20261019133538_board_moves/migration.sql +14 -0
  167. package/drizzle/20261019133538_board_moves/snapshot.json +1731 -0
  168. package/drizzle/20261019170538_item_projection_gone/migration.sql +1 -0
  169. package/drizzle/20261019170538_item_projection_gone/snapshot.json +1741 -0
  170. package/drizzle/20261019180649_run_again_events/migration.sql +7 -0
  171. package/drizzle/20261019180649_run_again_events/snapshot.json +1804 -0
  172. package/drizzle/20261019185008_trigger_event_permissions/migration.sql +1 -0
  173. package/drizzle/20261019185008_trigger_event_permissions/snapshot.json +1814 -0
  174. package/drizzle/20261020103746_attempt_start/migration.sql +5 -0
  175. package/drizzle/20261020103746_attempt_start/snapshot.json +1844 -0
  176. package/drizzle/20261020125211_attempt_comments/migration.sql +1 -0
  177. package/drizzle/20261020125211_attempt_comments/snapshot.json +1854 -0
  178. package/drizzle/20261020191320_run_closed_at/migration.sql +6 -0
  179. package/drizzle/20261020191320_run_closed_at/snapshot.json +1864 -0
  180. package/drizzle/20261023091428_rename_loop_item_hold_to_suppression/migration.sql +2 -0
  181. package/drizzle/20261023091428_rename_loop_item_hold_to_suppression/snapshot.json +1867 -0
  182. package/package.json +15 -5
  183. package/dist/workflow/admission.d.ts.map +0 -1
  184. package/dist/workflow/admission.js.map +0 -1
  185. package/dist/workflow/command.d.ts +0 -13
  186. package/dist/workflow/command.d.ts.map +0 -1
  187. package/dist/workflow/command.js +0 -17
  188. package/dist/workflow/command.js.map +0 -1
  189. package/dist/workflow/workflow.d.ts +0 -18
  190. package/dist/workflow/workflow.d.ts.map +0 -1
  191. package/dist/workflow/workflow.js +0 -108
  192. package/dist/workflow/workflow.js.map +0 -1
@@ -0,0 +1,56 @@
1
+ import { AttemptContext } from "@usine/core/attempt";
2
+ import { CycleLimit } from "@usine/core/cycle-budget";
3
+ import { DedupKey, Event, EventId } from "@usine/core/event";
4
+ import { ApprovalRequirement, LoopPermissions } from "@usine/core/loop";
5
+ import { OperatorLogin } from "@usine/core/operator";
6
+ import { StepName } from "@usine/core/step";
7
+ import { Schema } from "effect";
8
+ import { Claimed, CycleBlocked, Submission } from "./submission.js";
9
+ /**
10
+ * An operator request to run a succeeded or canceled Run again with the Loop's current settings
11
+ * (#152). `requestedBy` is `None` if `usine.yaml` sets no operator login.
12
+ */
13
+ export class RunAgainRequest extends Schema.Class("@usine/engine/RunAgainRequest")({
14
+ step: StepName,
15
+ approval: ApprovalRequirement,
16
+ /** The cycle limit, or `None` for a schedule Loop. */
17
+ cycleLimit: Schema.Option(CycleLimit),
18
+ permissions: LoopPermissions,
19
+ context: AttemptContext,
20
+ requestedBy: Schema.Option(OperatorLogin),
21
+ }) {
22
+ }
23
+ /**
24
+ * The result of a run again: `Claimed` with the new Run, or `CycleBlocked` with the Ask opened
25
+ * because the Item's cycle budget is used up.
26
+ */
27
+ export const RunAgainResult = Schema.Union([Claimed, CycleBlocked]);
28
+ /**
29
+ * Returns the Event for a run again, with the closed Run's Item state and revision, the Loop's
30
+ * current settings, and the operator's task and Agent. Its dedup key,
31
+ * `["operator-run-again", n, <trigger key>]`, never collides with a polled Event.
32
+ */
33
+ export const runAgainSubmission = (ran, request, identity) => {
34
+ const dedupKey = DedupKey.make(JSON.stringify(["operator-run-again", identity.reopening, identity.trigger]));
35
+ return new Submission({
36
+ event: new Event({
37
+ id: EventId.make(dedupKey),
38
+ dedupKey,
39
+ payload: ran.event.payload,
40
+ receivedAt: identity.receivedAt,
41
+ }),
42
+ itemKey: ran.itemKey,
43
+ loop: ran.run.loop,
44
+ step: request.step,
45
+ approval: request.approval,
46
+ permissions: request.permissions,
47
+ cycleLimit: request.cycleLimit,
48
+ cycleGeneration: identity.generation,
49
+ repository: ran.repository,
50
+ revision: ran.revision,
51
+ task: request.context.task,
52
+ agent: request.context.agent,
53
+ parentModel: request.context.parentModel,
54
+ });
55
+ };
56
+ //# sourceMappingURL=run-again.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-again.js","sourceRoot":"","sources":["../../src/engine/run-again.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAwB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAiB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEpE;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,KAAK,CAAkB,+BAA+B,CAAC,CACjG;IACE,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,mBAAmB;IAC7B,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;IACrC,WAAW,EAAE,eAAe;IAC5B,OAAO,EAAE,cAAc;IACvB,WAAW,EAAE,MAAM,CAAC,M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empt";
2
+ import type { RunId } from "@usine/core/run";
3
+ import { Context, Crypto, Effect, Layer } from "effect";
4
+ import { ItemProjectionWriter } from "../item-projection/item-projection.ts";
5
+ import { StepExecutor } from "../step-executor.ts";
6
+ import { RunStore } from "../store/store.ts";
7
+ import { TriggerCondition } from "../trigger-condition.ts";
8
+ import { AttemptAdmission } from "./admission.ts";
9
+ import type { RunStoreError } from "./error.ts";
10
+ declare const RunDriver_base: Context.ServiceClass<RunDriver, "@usine/engine/internal/RunDriver", {
11
+ /** Starts the fiber of an open Run, unless one already runs here. */
12
+ readonly launch: (runId: RunId) => Effect.Effect<void>;
13
+ /** Starts the fiber of a Run that an approval or operator retry reopened, after its previous fiber ends. */
14
+ readonly resume: (runId: RunId) => Effect.Effect<void>;
15
+ /** Interrupts the fiber of a closed Run and waits for it to end. */
16
+ readonly stop: (runId: RunId) => Effect.Effect<void>;
17
+ /**
18
+ * Gives the newest queued Event of the closed Run's Item its turn, after re-evaluating the
19
+ * trigger against the Item's current state. If the Item is gone, marks its projection gone.
20
+ */
21
+ readonly continueWithNewest: (closedRunId: RunId) => Effect.Effect<void, RunStoreError>;
22
+ /**
23
+ * Opens the queued Events whose continuation didn't run and starts a fiber for every open Run
24
+ * without one, except Runs waiting for approval. Also retries the parent task stops that
25
+ * `releaseKept` or `recoverWorkspaces` couldn't confirm.
26
+ */
27
+ readonly reconcile: () => Effect.Effect<void, RunStoreError>;
28
+ /**
29
+ * Reconciles at startup the checkout of every persisted Attempt on a configured Worker, before
30
+ * any Run admits its next Attempt. Keeps the checkout and occupies a Worker slot (#177) for
31
+ * an open Attempt whose parent task is live or unreadable, and for a closed Attempt whose
32
+ * parent task isn't confirmed stopped. See `checkoutRecoveryFor`.
33
+ */
34
+ readonly recoverWorkspaces: () => Effect.Effect<void, RunStoreError>;
35
+ /**
36
+ * Releases what `recoverWorkspaces` kept for reattaching `attemptId`, for a Run that closes the
37
+ * Attempt before its execution acquired the checkout. Once the parent task is confirmed
38
+ * stopped, reconciles the checkout and releases the slot; until then both stay kept (#177) and
39
+ * each `reconcile` retries.
40
+ */
41
+ readonly releaseKept: (attemptId: AttemptId) => Effect.Effect<void>;
42
+ }>;
43
+ /**
44
+ * The service that drives open Runs in this process, one fiber per Run. A fiber parks a gated
45
+ * Run for approval, then reserves a Worker, starts or reattaches the Attempt, records its
46
+ * outcome, and repeats until the Run closes. The fiber that closes a Run gives the Item's newest
47
+ * queued Event its turn; cancel, supersede, and revoke do that themselves. A fiber that ends
48
+ * without closing its Run leaves it for `resume` or `reconcile`.
49
+ */
50
+ export declare class RunDriver extends RunDriver_base {
51
+ static readonly layer: Layer.Layer<RunDriver, never, AttemptAdmission | Crypto.Crypto | ItemProjectionWriter | RunStore | StepExecutor | TriggerCondition>;
52
+ }
53
+ export {};
54
+ //# sourceMappingURL=run-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-driver.d.ts","sourceRoot":"","sources":["../../src/engine/run-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAEL,OAAO,EACP,MAAM,EAEN,MAAM,EAGN,KAAK,EAKN,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAKV,aAAa,EACd,MAAM,YAAY,CAAC;;IA+EhB,qEAAqE;qBACpD,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IACtD,4GAA4G;qBAC3F,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IACtD,oEAAoE;mBACrD,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IACpD;;;OAGG;iCAC0B,CAAC,WAAW,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;IACvF;;;;OAIG;wBACiB,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;IAC5D;;;;;OAKG;gCACyB,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;IACpE;;;;;OAKG;0BACmB,CAAC,SAAS,EAAE,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;AAxCvE;;;;;;GAMG;AACH,qBAAa,SAAU,SAAQ,cAmCQ;IACrC,MAAM,CAAC,QAAQ,CAAC,KAAK,sIAkbnB;CACH"}
@@ -0,0 +1,362 @@
1
+ import * as AttemptChannel from "@usine/core/attempt/channel";
2
+ import { DefectFailure, InfraFailure } from "@usine/core/attempt/failure";
3
+ import { Cause, Context, Crypto, DateTime, Effect, Fiber, FiberMap, Layer, Option, Ref, Result, Schedule, } from "effect";
4
+ import { ItemProjectionWriter } from "../item-projection/item-projection.js";
5
+ import { StepExecutor } from "../step-executor.js";
6
+ import { RunStore } from "../store/store.js";
7
+ import { TranscriptAllQuery } from "../transcript.js";
8
+ import { TriggerCondition } from "../trigger-condition.js";
9
+ import { AttemptAdmission } from "./admission.js";
10
+ import { checkoutRecoveryFor } from "./checkout-recovery.js";
11
+ import { runIdFor } from "./submission.js";
12
+ // Executor sinks fail with `AttemptFailure`: a persistence error becomes an `InfraFailure`, and
13
+ // other store errors are defects.
14
+ const asAttemptFailure = (effect) => Effect.catchTags(effect, {
15
+ EnginePersistenceError: (error) => new InfraFailure({
16
+ message: `Runtime store error: could not ${error.operation}`,
17
+ cause: error,
18
+ }),
19
+ RunNotFoundError: (error) => Effect.die(error),
20
+ RunOperationRejectedError: (error) => Effect.die(error),
21
+ RunRetryBlockedError: (error) => Effect.die(error),
22
+ });
23
+ /** The number of retries for a store operation that failed to persist. */
24
+ const STORE_RETRIES = 4;
25
+ /** The delay before the first retry; each later delay doubles. */
26
+ const STORE_RETRY_DELAY = "100 millis";
27
+ /**
28
+ * Retries a store operation that fails with `EnginePersistenceError`, with exponential backoff.
29
+ * Returns other errors and the last persistence error.
30
+ */
31
+ const retryingStore = (runId, operation) => (effect) => effect.pipe(Effect.tapError((error) => error._tag === "EnginePersistenceError"
32
+ ? Effect.logWarning("A Run store operation failed to persist", {
33
+ runId,
34
+ operation,
35
+ cause: error.cause,
36
+ })
37
+ : Effect.void), Effect.retry({
38
+ schedule: Schedule.exponential(STORE_RETRY_DELAY),
39
+ times: STORE_RETRIES,
40
+ while: (error) => error._tag === "EnginePersistenceError",
41
+ }));
42
+ /** Returns the open Attempt if its parent task is live. */
43
+ const reattaching = (open) => Option.flatMap(open, (found) => found._tag === "Live" ? Option.some(found.attempt) : Option.none());
44
+ /**
45
+ * The service that drives open Runs in this process, one fiber per Run. A fiber parks a gated
46
+ * Run for approval, then reserves a Worker, starts or reattaches the Attempt, records its
47
+ * outcome, and repeats until the Run closes. The fiber that closes a Run gives the Item's newest
48
+ * queued Event its turn; cancel, supersede, and revoke do that themselves. A fiber that ends
49
+ * without closing its Run leaves it for `resume` or `reconcile`.
50
+ */
51
+ export class RunDriver extends Context.Service()("@usine/engine/internal/RunDriver") {
52
+ static layer = Layer.effect(RunDriver, Effect.gen(function* () {
53
+ const store = yield* RunStore;
54
+ const executor = yield* StepExecutor;
55
+ const admission = yield* AttemptAdmission;
56
+ const condition = yield* TriggerCondition;
57
+ const items = yield* ItemProjectionWriter;
58
+ const crypto = yield* Crypto.Crypto;
59
+ const fibers = yield* FiberMap.make();
60
+ const checkouts = yield* checkoutRecoveryFor(store, executor);
61
+ // Closed Attempts whose parent task isn't confirmed stopped; each reconcile retries the stop.
62
+ const unconfirmed = yield* Ref.make(new Set());
63
+ // Annotated because a fiber's continuation calls launch again, which TypeScript cannot infer.
64
+ const launch = Effect.fn("RunDriver.launch")(function* (runId) {
65
+ yield* Effect.annotateCurrentSpan({ runId });
66
+ if (yield* FiberMap.has(fibers, runId)) {
67
+ yield* Effect.logDebug("The Run's fiber already runs in this process", { runId });
68
+ return;
69
+ }
70
+ yield* Effect.logDebug("Starting the Run's fiber", { runId });
71
+ yield* FiberMap.run(fibers, runId, drive(runId).pipe(Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause)
72
+ ? Effect.failCause(cause)
73
+ : Effect.logError("The Run's fiber stopped on an engine failure; the next reconcile or a restart resumes it", { runId, cause }))), { onlyIfMissing: true });
74
+ });
75
+ const resume = Effect.fn("RunDriver.resume")(function* (runId) {
76
+ yield* Effect.annotateCurrentSpan({ runId });
77
+ const previous = yield* FiberMap.get(fibers, runId);
78
+ if (Option.isSome(previous)) {
79
+ // The previous fiber ends right after its last write; wait until it leaves the map.
80
+ yield* Effect.logDebug("Waiting for the Run's previous fiber to end", { runId });
81
+ yield* Fiber.await(previous.value);
82
+ }
83
+ yield* launch(runId);
84
+ });
85
+ const stop = Effect.fn("RunDriver.stop")(function* (runId) {
86
+ yield* Effect.annotateCurrentSpan({ runId });
87
+ if (!(yield* FiberMap.has(fibers, runId))) {
88
+ yield* Effect.logDebug("The closed Run has no fiber in this process", { runId });
89
+ return;
90
+ }
91
+ yield* FiberMap.remove(fibers, runId);
92
+ yield* Effect.logInfo("The closed Run's fiber stopped", { runId });
93
+ });
94
+ const markItemGone = Effect.fn("RunDriver.markItemGone")(function* (closedRunId, submission) {
95
+ yield* Effect.annotateCurrentSpan({ runId: closedRunId, itemKey: submission.itemKey });
96
+ return yield* items.markGone(submission.itemKey, yield* DateTime.now).pipe(retryingStore(closedRunId, "mark the item's projection gone"), Effect.catch((error) => Effect.logWarning("Could not mark the gone Item's projection; its Board card stays in place", {
97
+ completedRunId: closedRunId,
98
+ itemKey: submission.itemKey,
99
+ errorTag: error._tag,
100
+ }).pipe(Effect.as(false))));
101
+ });
102
+ const continueWithNewest = Effect.fn("RunDriver.continueWithNewest")(function* (closedRunId) {
103
+ yield* Effect.annotateCurrentSpan({ runId: closedRunId });
104
+ const queued = yield* store
105
+ .nextQueued(closedRunId)
106
+ .pipe(retryingStore(closedRunId, "read the queued events"));
107
+ if (Option.isNone(queued))
108
+ return;
109
+ const submission = queued.value.submission;
110
+ const fields = {
111
+ completedRunId: closedRunId,
112
+ eventId: submission.event.id,
113
+ loop: submission.loop,
114
+ itemKey: submission.itemKey,
115
+ };
116
+ const recheck = yield* condition.recheck(submission);
117
+ if (recheck !== "matches") {
118
+ // Revoke only the queue read before the remote check.
119
+ const revoked = yield* store
120
+ .revokeQueued(queued.value)
121
+ .pipe(retryingStore(closedRunId, "revoke the queued events"));
122
+ if (recheck === "no-longer-matches") {
123
+ yield* Effect.logInfo("Queued Event no longer matches its trigger; revoked", {
124
+ ...fields,
125
+ revokedEvents: revoked,
126
+ });
127
+ return;
128
+ }
129
+ const projectionMarkedGone = yield* markItemGone(closedRunId, submission);
130
+ yield* Effect.logInfo("Queued Event's Item is gone from its source; revoked its queued Events", { ...fields, revokedEvents: revoked, projectionMarkedGone });
131
+ return;
132
+ }
133
+ const runId = yield* runIdFor(submission).pipe(Effect.provideService(Crypto.Crypto, crypto));
134
+ const claimed = yield* store
135
+ .claimQueued(submission, runId)
136
+ .pipe(retryingStore(closedRunId, "claim the queued event"));
137
+ if (Option.isNone(claimed)) {
138
+ // During the check, the Event was ignored, another Run opened for the Item, or a cycle
139
+ // reset superseded the Event.
140
+ yield* Effect.logInfo("Queued Event still matches its trigger but could no longer be claimed; no Run opened", fields);
141
+ return;
142
+ }
143
+ yield* Effect.logInfo("Queued Event still matches its trigger; opening its Run", {
144
+ ...fields,
145
+ runId: claimed.value,
146
+ });
147
+ yield* launch(claimed.value);
148
+ });
149
+ /**
150
+ * Reads the state of the Run's open Attempt, or `None` if there is none. If a read fails,
151
+ * logs a warning and returns `Interrupted`.
152
+ */
153
+ const openAttempt = Effect.fn("RunDriver.openAttempt")(function* (runId) {
154
+ yield* Effect.annotateCurrentSpan({ runId });
155
+ const current = yield* store.snapshot(runId).pipe(retryingStore(runId, "read the run"));
156
+ const open = current.attempts.at(-1);
157
+ if (current.run.state._tag !== "Running" ||
158
+ open === undefined ||
159
+ Option.isSome(open.outcome))
160
+ return Option.none();
161
+ const fields = { runId, attemptId: open.id, worker: open.worker };
162
+ yield* Effect.annotateCurrentSpan({ attemptId: open.id, worker: open.worker });
163
+ const live = yield* executor.isLive(open.id).pipe(Effect.result);
164
+ if (Result.isFailure(live)) {
165
+ yield* Effect.logWarning("Could not read whether the open Attempt is live; the Run does not reattach it", { ...fields, errorTag: live.failure._tag, message: live.failure.message });
166
+ return Option.some({ _tag: "Interrupted", attempt: open });
167
+ }
168
+ if (live.success) {
169
+ yield* Effect.logInfo("The open Attempt's parent task is live; reattaching it", fields);
170
+ return Option.some({ _tag: "Live", attempt: open });
171
+ }
172
+ const stored = yield* executor.outcome(open.id).pipe(Effect.result);
173
+ if (Result.isFailure(stored)) {
174
+ yield* Effect.logWarning("Could not read the open Attempt's stored outcome; the Run does not reattach it", { ...fields, errorTag: stored.failure._tag, message: stored.failure.message });
175
+ return Option.some({ _tag: "Interrupted", attempt: open });
176
+ }
177
+ if (Option.isNone(stored.success)) {
178
+ yield* Effect.logInfo("The open Attempt's parent task is gone; the Run does not reattach it", fields);
179
+ return Option.some({ _tag: "Interrupted", attempt: open });
180
+ }
181
+ const result = stored.success.value;
182
+ yield* Effect.logInfo("The open Attempt's parent task finished before this process recorded it; finishing the Attempt with its stored result", {
183
+ ...fields,
184
+ outcome: Result.match(result, {
185
+ onSuccess: () => "Succeeded",
186
+ onFailure: ({ _tag }) => _tag,
187
+ }),
188
+ });
189
+ return Option.some({ _tag: "Finished", attempt: open, result });
190
+ });
191
+ /**
192
+ * Returns the slot for the Run's next Attempt and the effect that reads the open Attempt once
193
+ * the slot is held. A reattaching Run uses the slot startup occupied or waits for one on the
194
+ * Attempt's Worker. Only the wait, through `restore`, is interruptible.
195
+ */
196
+ const slotFor = Effect.fn("RunDriver.slot")(function* (runId, submission, open, restore) {
197
+ yield* Effect.annotateCurrentSpan({ runId });
198
+ const found = Effect.succeed(open);
199
+ const reattached = reattaching(open);
200
+ if (Option.isSome(reattached)) {
201
+ const occupied = yield* checkouts.reattachSlot(reattached.value.id);
202
+ if (Option.isSome(occupied)) {
203
+ yield* Effect.logInfo("The Run reattaches its open Attempt in the slot startup occupied on its Worker", { runId, attemptId: reattached.value.id, worker: occupied.value.worker });
204
+ return { lease: occupied.value, open: found };
205
+ }
206
+ }
207
+ const lease = yield* restore(executor.reserve(submission, Option.map(reattached, ({ worker }) => worker)));
208
+ // The parent task can stop during the wait, so read it again before reattaching.
209
+ return { lease, open: Option.isSome(reattached) ? openAttempt(runId) : found };
210
+ });
211
+ /**
212
+ * Runs one Attempt on the reserved Worker and returns the resulting decision tag. `current`
213
+ * reads the open Attempt once the slot is held.
214
+ */
215
+ const executeAttempt = Effect.fn("RunDriver.attempt")(function* (runId, worker, current) {
216
+ yield* Effect.annotateCurrentSpan({ runId, worker });
217
+ const open = yield* current;
218
+ if (Option.isSome(open) && open.value._tag === "Finished") {
219
+ const finished = yield* store
220
+ .finishAttempt(open.value.attempt, open.value.result)
221
+ .pipe(retryingStore(runId, "finish the attempt"));
222
+ if (finished._tag !== "RetryAttempt")
223
+ return finished._tag;
224
+ }
225
+ const started = yield* store
226
+ .beginAttempt(runId, worker, Option.map(reattaching(open), ({ id }) => id))
227
+ .pipe(retryingStore(runId, "begin the attempt"));
228
+ if (started._tag === "AttemptRecoveryFailed")
229
+ return "RunFailed";
230
+ if (started._tag === "RunClosed")
231
+ return "Unchanged";
232
+ // An executor defect becomes a `DefectFailure`, which isn't retried automatically (ADR 0003).
233
+ const result = yield* executor
234
+ .execute(started.execution, {
235
+ append: (direction, envelope) => store.appendTranscript(direction, envelope).pipe(asAttemptFailure),
236
+ salvage: (salvage) => store.recordSalvage(started.execution.attempt.id, salvage).pipe(asAttemptFailure),
237
+ comments: (comments) => store.recordComments(started.execution.attempt.id, comments).pipe(asAttemptFailure),
238
+ windows: store
239
+ .attemptWindows(started.execution.attempt.id)
240
+ .pipe(retryingStore(runId, "read the attempt windows"), asAttemptFailure),
241
+ transcript: store
242
+ .transcript(new TranscriptAllQuery({ attemptId: started.execution.attempt.id }))
243
+ .pipe(retryingStore(runId, "read the attempt transcript"), asAttemptFailure,
244
+ // Reattached Attempts recorded the current protocol version. A version bump must
245
+ // convert retired envelopes here for Attempts open across the upgrade.
246
+ Effect.map((entries) => entries.flatMap(({ envelope }) => envelope.version === AttemptChannel.PROTOCOL_VERSION ? [envelope] : []))),
247
+ // Until this point, the driver reconciles a checkout that startup kept, for example on
248
+ // a cancel (#180).
249
+ checkoutAcquired: checkouts.acquired(started.execution.attempt.id),
250
+ })
251
+ .pipe(Effect.catchDefect((defect) => Effect.logError("Step executor defect; operator intervention required", {
252
+ runId,
253
+ attemptId: started.execution.attempt.id,
254
+ defect: defect instanceof Error ? defect.message : String(defect),
255
+ }).pipe(Effect.andThen(new DefectFailure({
256
+ message: "The step executor crashed with an unexpected error",
257
+ cause: defect,
258
+ })))), Effect.result);
259
+ if (started.execution.reattach && Result.isFailure(result)) {
260
+ // Reconcile a reattach that failed before acquiring the kept checkout, such as on a
261
+ // credential error, so the next Attempt resumes from its salvage. `reconcile` does nothing
262
+ // once the checkout was acquired, and fails this fiber while the stop is unconfirmed.
263
+ yield* checkouts.reconcile(started.execution.attempt.id);
264
+ }
265
+ const finished = yield* store
266
+ .finishAttempt(started.execution.attempt, result)
267
+ .pipe(retryingStore(runId, "finish the attempt"));
268
+ return finished._tag;
269
+ });
270
+ const drive = Effect.fn("RunDriver.drive")(function* (runId) {
271
+ const submission = yield* store
272
+ .submission(runId)
273
+ .pipe(retryingStore(runId, "read the run's submission"));
274
+ yield* Effect.annotateCurrentSpan({
275
+ runId,
276
+ loop: submission.loop,
277
+ itemKey: submission.itemKey,
278
+ });
279
+ if (submission.approval === "required" &&
280
+ (yield* store
281
+ .parkForApproval(runId)
282
+ .pipe(retryingStore(runId, "park the run for approval")))._tag === "Waiting") {
283
+ yield* Effect.logInfo("Run waits for its approval", { runId });
284
+ return;
285
+ }
286
+ let outcome;
287
+ do {
288
+ // A reattached Attempt uses a slot on the Worker it started on (#177).
289
+ const open = yield* openAttempt(runId);
290
+ if (Option.isSome(open) && open.value._tag !== "Live") {
291
+ // Reconcile before waiting for a slot, so the next Attempt resumes from the salvage and
292
+ // the slot startup occupied is freed. If the stop can't be confirmed, this fiber fails
293
+ // and keeps the slot; the next reconcile drives the Run again.
294
+ yield* checkouts.reconcile(open.value.attempt.id);
295
+ }
296
+ // Only the slot wait is interruptible, so a cancel can stop a Run in `reserve`; the
297
+ // scheduler releases or reoffers the slot on interrupt. `lease.release` runs once the
298
+ // lease exists.
299
+ outcome = yield* Effect.uninterruptibleMask((restore) => slotFor(runId, submission, open, restore).pipe(Effect.flatMap(({ lease, open: current }) => restore(admission.withAttempt(runId, executeAttempt(runId, lease.worker, current))).pipe(Effect.ensuring(lease.release)))));
300
+ } while (outcome === "RetryAttempt");
301
+ // Cancel, supersede, and revoke handle the Item's queued Events themselves and can
302
+ // interrupt this fiber at any point.
303
+ if (outcome === "Unchanged") {
304
+ yield* Effect.logInfo("Run closed by another operation; its fiber ends", { runId });
305
+ return;
306
+ }
307
+ yield* continueWithNewest(runId);
308
+ });
309
+ const releaseKept = Effect.fn("RunDriver.releaseKept")(function* (attemptId) {
310
+ yield* Effect.annotateCurrentSpan({ attemptId });
311
+ const stopped = yield* checkouts.reconcile(attemptId).pipe(Effect.result);
312
+ yield* Ref.update(unconfirmed, (ids) => {
313
+ const next = new Set(ids);
314
+ if (Result.isSuccess(stopped))
315
+ next.delete(attemptId);
316
+ else
317
+ next.add(attemptId);
318
+ return next;
319
+ });
320
+ if (Result.isFailure(stopped))
321
+ yield* Effect.logWarning("The parent task of an Attempt whose Run closed is not confirmed stopped; its checkout and its Worker's slot stay kept, and the next reconcile tries the stop again", { attemptId });
322
+ });
323
+ const recoverWorkspaces = Effect.fn("RunDriver.recoverWorkspaces")(function* () {
324
+ // Closed Attempts whose parent task stop wasn't confirmed before the restart.
325
+ const unstopped = yield* checkouts.atStartup();
326
+ yield* Ref.update(unconfirmed, (ids) => new Set([...ids, ...unstopped]));
327
+ });
328
+ const reconcile = Effect.fn("RunDriver.reconcile")(function* () {
329
+ // No Run fiber retries these stops, so reconcile does.
330
+ const unstopped = [...(yield* Ref.get(unconfirmed))];
331
+ yield* Effect.forEach(unstopped, releaseKept, { discard: true });
332
+ const continuations = yield* store.pendingContinuations;
333
+ yield* Effect.forEach(continuations, (runId) => continueWithNewest(runId).pipe(Effect.tapError((error) => Effect.logError("Could not continue the queued Events behind a closed Run", {
334
+ runId,
335
+ errorTag: error._tag,
336
+ })), Effect.ignore), { discard: true });
337
+ const driven = yield* store.runIdsToDrive;
338
+ const withoutFiber = yield* Effect.filter(driven, (runId) => Effect.map(FiberMap.has(fibers, runId), (running) => !running));
339
+ yield* Effect.forEach(withoutFiber, launch, { discard: true });
340
+ const fields = {
341
+ continuedAfterRunIds: continuations,
342
+ startedRunIds: withoutFiber,
343
+ drivenRunIds: driven.length,
344
+ retriedStopAttemptIds: unstopped,
345
+ };
346
+ if (continuations.length === 0 && withoutFiber.length === 0 && unstopped.length === 0)
347
+ yield* Effect.logDebug("Every Run to drive already has its fiber", fields);
348
+ else
349
+ yield* Effect.logInfo("Runs recovered from the run tables", fields);
350
+ });
351
+ return {
352
+ launch,
353
+ resume,
354
+ stop,
355
+ continueWithNewest,
356
+ reconcile,
357
+ recoverWorkspaces,
358
+ releaseKept,
359
+ };
360
+ }));
361
+ }
362
+ //# sourceMappingURL=run-driver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-driver.js","sourceRoot":"","sources":["../../src/engine/run-driver.ts"],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,EAAE,IAAI,EAAE,CAClB,CAAC;YACF,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC;YAC1C,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAC1D,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAC/D,CAAC;YACF,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAC/D,MAAM,MAAM,GAAG;gBACb,oBAAoB,EAAE,aAAa;gBACnC,aAAa,EAAE,YAAY;gBAC3B,YAAY,EAAE,MAAM,CAAC,MAAM;gBAC3B,qBAAqB,EAAE,SAAS;aACjC,CAAC;YACF,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;gBACnF,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,0CAA0C,EAAE,MAAM,CAAC,CAAC;;gBACxE,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,oCAAoC,EAAE,MAAM,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,MAAM;YACN,MAAM;YACN,IAAI;YACJ,kBAAkB;YAClB,SAAS;YACT,iBAAiB;YACjB,WAAW;SACZ,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;CACH"}
@@ -1,10 +1,9 @@
1
1
  import { Context, Deferred } from "effect";
2
2
  declare const RunEngineShutdown_base: Context.ServiceClass<RunEngineShutdown, "@usine/engine/RunEngineShutdown", Deferred.Deferred<void, never>>;
3
3
  /**
4
- * Optional host-owned shutdown latch, provided before building an engine runtime.
5
- * Completing it closes Attempt admission even while startup recovery is running.
6
- * After startup, RunEngine.drain waits for admitted Attempts to persist their outcomes.
7
- * Allocate a fresh latch for each runtime; it cannot be reopened (ADR 0023).
4
+ * An optional shutdown latch owned by the host, provided before building an engine runtime.
5
+ * Completing it closes Attempt admission, even during startup recovery. It can't be reopened,
6
+ * so each runtime needs a new one (ADR 0023).
8
7
  */
9
8
  export declare class RunEngineShutdown extends RunEngineShutdown_base {
10
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../src/engine/shutdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;;AAE3C;;;;;GAKG;AACH,qBAAa,iBAAkB,SAAQ,sBAGD;CAAG"}
1
+ {"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../src/engine/shutdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;;AAE3C;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,sBAGD;CAAG"}
@@ -1,9 +1,8 @@
1
1
  import { Context, Deferred } from "effect";
2
2
  /**
3
- * Optional host-owned shutdown latch, provided before building an engine runtime.
4
- * Completing it closes Attempt admission even while startup recovery is running.
5
- * After startup, RunEngine.drain waits for admitted Attempts to persist their outcomes.
6
- * Allocate a fresh latch for each runtime; it cannot be reopened (ADR 0023).
3
+ * An optional shutdown latch owned by the host, provided before building an engine runtime.
4
+ * Completing it closes Attempt admission, even during startup recovery. It can't be reopened,
5
+ * so each runtime needs a new one (ADR 0023).
7
6
  */
8
7
  export class RunEngineShutdown extends Context.Service()("@usine/engine/RunEngineShutdown") {
9
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../../src/engine/shutdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,OAAO,CAAC,OAAO,EAGnD,CAAC,iCAAiC,CAAC;CAAG"}
1
+ {"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../../src/engine/shutdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAE3C;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,OAAO,CAAC,OAAO,EAGnD,CAAC,iCAAiC,CAAC;CAAG"}