@usine/engine 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +91 -2
  2. package/dist/cursor/cursor.d.ts +20 -0
  3. package/dist/cursor/cursor.d.ts.map +1 -0
  4. package/dist/cursor/cursor.js +55 -0
  5. package/dist/cursor/cursor.js.map +1 -0
  6. package/dist/cycle-budget/cycle-budget.d.ts +25 -0
  7. package/dist/cycle-budget/cycle-budget.d.ts.map +1 -0
  8. package/dist/cycle-budget/cycle-budget.js +117 -0
  9. package/dist/cycle-budget/cycle-budget.js.map +1 -0
  10. package/dist/cycle-budget/model.d.ts +26 -0
  11. package/dist/cycle-budget/model.d.ts.map +1 -0
  12. package/dist/cycle-budget/model.js +20 -0
  13. package/dist/cycle-budget/model.js.map +1 -0
  14. package/dist/cycle-budget/queries.d.ts +27 -0
  15. package/dist/cycle-budget/queries.d.ts.map +1 -0
  16. package/dist/cycle-budget/queries.js +175 -0
  17. package/dist/cycle-budget/queries.js.map +1 -0
  18. package/dist/database/database.d.ts +15 -0
  19. package/dist/database/database.d.ts.map +1 -0
  20. package/dist/database/database.js +5 -0
  21. package/dist/database/database.js.map +1 -0
  22. package/dist/database/local-sqlite.d.ts +37 -0
  23. package/dist/database/local-sqlite.d.ts.map +1 -0
  24. package/dist/database/local-sqlite.js +144 -0
  25. package/dist/database/local-sqlite.js.map +1 -0
  26. package/dist/database/schema.d.ts +1341 -0
  27. package/dist/database/schema.d.ts.map +1 -0
  28. package/dist/database/schema.js +224 -0
  29. package/dist/database/schema.js.map +1 -0
  30. package/dist/engine/engine.d.ts +55 -0
  31. package/dist/engine/engine.d.ts.map +1 -0
  32. package/dist/engine/engine.js +193 -0
  33. package/dist/engine/engine.js.map +1 -0
  34. package/dist/engine/error.d.ts +37 -0
  35. package/dist/engine/error.d.ts.map +1 -0
  36. package/dist/engine/error.js +41 -0
  37. package/dist/engine/error.js.map +1 -0
  38. package/dist/engine/lifecycle.d.ts +112 -0
  39. package/dist/engine/lifecycle.d.ts.map +1 -0
  40. package/dist/engine/lifecycle.js +132 -0
  41. package/dist/engine/lifecycle.js.map +1 -0
  42. package/dist/engine/shutdown.d.ts +12 -0
  43. package/dist/engine/shutdown.d.ts.map +1 -0
  44. package/dist/engine/shutdown.js +10 -0
  45. package/dist/engine/shutdown.js.map +1 -0
  46. package/dist/engine/submission.d.ts +58 -0
  47. package/dist/engine/submission.d.ts.map +1 -0
  48. package/dist/engine/submission.js +54 -0
  49. package/dist/engine/submission.js.map +1 -0
  50. package/dist/item-projection/item-projection.d.ts +25 -0
  51. package/dist/item-projection/item-projection.d.ts.map +1 -0
  52. package/dist/item-projection/item-projection.js +100 -0
  53. package/dist/item-projection/item-projection.js.map +1 -0
  54. package/dist/item-projection/model.d.ts +18 -0
  55. package/dist/item-projection/model.d.ts.map +1 -0
  56. package/dist/item-projection/model.js +16 -0
  57. package/dist/item-projection/model.js.map +1 -0
  58. package/dist/loop-control/loop-control.d.ts +21 -0
  59. package/dist/loop-control/loop-control.d.ts.map +1 -0
  60. package/dist/loop-control/loop-control.js +71 -0
  61. package/dist/loop-control/loop-control.js.map +1 -0
  62. package/dist/loop-control/model.d.ts +10 -0
  63. package/dist/loop-control/model.d.ts.map +1 -0
  64. package/dist/loop-control/model.js +9 -0
  65. package/dist/loop-control/model.js.map +1 -0
  66. package/dist/repository-label-projection/model.d.ts +19 -0
  67. package/dist/repository-label-projection/model.d.ts.map +1 -0
  68. package/dist/repository-label-projection/model.js +20 -0
  69. package/dist/repository-label-projection/model.js.map +1 -0
  70. package/dist/repository-label-projection/repository-label-projection.d.ts +20 -0
  71. package/dist/repository-label-projection/repository-label-projection.d.ts.map +1 -0
  72. package/dist/repository-label-projection/repository-label-projection.js +83 -0
  73. package/dist/repository-label-projection/repository-label-projection.js.map +1 -0
  74. package/dist/run-reader/model.d.ts +46 -0
  75. package/dist/run-reader/model.d.ts.map +1 -0
  76. package/dist/run-reader/model.js +44 -0
  77. package/dist/run-reader/model.js.map +1 -0
  78. package/dist/run-reader/run-reader.d.ts +29 -0
  79. package/dist/run-reader/run-reader.d.ts.map +1 -0
  80. package/dist/run-reader/run-reader.js +44 -0
  81. package/dist/run-reader/run-reader.js.map +1 -0
  82. package/dist/step-executor.d.ts +43 -0
  83. package/dist/step-executor.d.ts.map +1 -0
  84. package/dist/step-executor.js +25 -0
  85. package/dist/step-executor.js.map +1 -0
  86. package/dist/store/codec.d.ts +495 -0
  87. package/dist/store/codec.d.ts.map +1 -0
  88. package/dist/store/codec.js +162 -0
  89. package/dist/store/codec.js.map +1 -0
  90. package/dist/store/queries.d.ts +107 -0
  91. package/dist/store/queries.d.ts.map +1 -0
  92. package/dist/store/queries.js +543 -0
  93. package/dist/store/queries.js.map +1 -0
  94. package/dist/store/store.d.ts +101 -0
  95. package/dist/store/store.d.ts.map +1 -0
  96. package/dist/store/store.js +432 -0
  97. package/dist/store/store.js.map +1 -0
  98. package/dist/transcript.d.ts +64 -0
  99. package/dist/transcript.d.ts.map +1 -0
  100. package/dist/transcript.js +59 -0
  101. package/dist/transcript.js.map +1 -0
  102. package/dist/workflow/admission.d.ts +13 -0
  103. package/dist/workflow/admission.d.ts.map +1 -0
  104. package/dist/workflow/admission.js +55 -0
  105. package/dist/workflow/admission.js.map +1 -0
  106. package/dist/workflow/command.d.ts +13 -0
  107. package/dist/workflow/command.d.ts.map +1 -0
  108. package/dist/workflow/command.js +17 -0
  109. package/dist/workflow/command.js.map +1 -0
  110. package/dist/workflow/workflow.d.ts +18 -0
  111. package/dist/workflow/workflow.d.ts.map +1 -0
  112. package/dist/workflow/workflow.js +108 -0
  113. package/dist/workflow/workflow.js.map +1 -0
  114. package/drizzle/20260825055549_initial_runtime/migration.sql +73 -0
  115. package/drizzle/20260825055549_initial_runtime/snapshot.json +592 -0
  116. package/drizzle/20260830191125_polling_cursors/migration.sql +5 -0
  117. package/drizzle/20260830191125_polling_cursors/snapshot.json +629 -0
  118. package/drizzle/20260831073158_attempt_channel/migration.sql +36 -0
  119. package/drizzle/20260831073158_attempt_channel/snapshot.json +845 -0
  120. package/drizzle/20260831133534_agent_context/migration.sql +49 -0
  121. package/drizzle/20260831133534_agent_context/snapshot.json +897 -0
  122. package/drizzle/20260831134612_attempt_brain/migration.sql +26 -0
  123. package/drizzle/20260831134612_attempt_brain/snapshot.json +923 -0
  124. package/drizzle/20260831194605_loop_runtime/migration.sql +4 -0
  125. package/drizzle/20260831194605_loop_runtime/snapshot.json +954 -0
  126. package/drizzle/20260901073233_projection_revision/migration.sql +55 -0
  127. package/drizzle/20260901073233_projection_revision/snapshot.json +991 -0
  128. package/drizzle/20260901180433_item_projections/migration.sql +22 -0
  129. package/drizzle/20260901180433_item_projections/snapshot.json +1110 -0
  130. package/drizzle/20260901185146_repository_label_projections/migration.sql +17 -0
  131. package/drizzle/20260901185146_repository_label_projections/snapshot.json +1147 -0
  132. package/drizzle/20260903091940_queued_approved_runs/migration.sql +3 -0
  133. package/drizzle/20260903091940_queued_approved_runs/snapshot.json +1147 -0
  134. package/drizzle/20260905150403_item_cycle_budgets/migration.sql +58 -0
  135. package/drizzle/20260905150403_item_cycle_budgets/snapshot.json +1417 -0
  136. package/drizzle/20260905174009_item_run_history/migration.sql +1 -0
  137. package/drizzle/20260905174009_item_run_history/snapshot.json +1431 -0
  138. package/package.json +60 -6
  139. package/dist/index.d.ts +0 -8
  140. package/dist/index.d.ts.map +0 -1
  141. package/dist/index.js +0 -8
  142. package/dist/index.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/database/schema.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASlB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2B9B,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUpB,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYzB,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgB5B,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOnB,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgB3B,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYtC,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGtB,CAAC;AAEH,wEAAwE;AACxE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO9B,CAAC"}
@@ -0,0 +1,224 @@
1
+ import { ModelId } from "@usine/core/agent/brain";
2
+ import { AttemptNumber, AttemptTask, AttemptId } from "@usine/core/attempt";
3
+ import * as AttemptChannel from "@usine/core/attempt/channel";
4
+ import { DedupKey, EventId } from "@usine/core/event";
5
+ import { ItemKey } from "@usine/core/item";
6
+ import { CycleLimit, CycleBudgetAskId } from "@usine/core/cycle-budget";
7
+ import { LoopName, APPROVAL_REQUIREMENTS } from "@usine/core/loop";
8
+ import { RepositoryName, RepositoryRevision } from "@usine/core/repository";
9
+ import { RunId } from "@usine/core/run";
10
+ import { StepName } from "@usine/core/step";
11
+ import { WorkerName } from "@usine/core/worker";
12
+ import { sql } from "drizzle-orm";
13
+ import { check, foreignKey, index, integer, primaryKey, snakeCase, text, uniqueIndex, } from "drizzle-orm/sqlite-core";
14
+ import { IGNORED_REASONS } from "../engine/submission.js";
15
+ import { WORKFLOW_COMMANDS } from "../workflow/command.js";
16
+ export const events = snakeCase.table("usine_events", {
17
+ eventId: text().$type().primaryKey(),
18
+ dedupKey: text().$type().notNull().unique(),
19
+ payloadJson: text({ mode: "json" }).$type().notNull(),
20
+ receivedAt: text().notNull(),
21
+ }, (table) => [check("usine_events_payload_json_valid", sql `json_valid(${table.payloadJson})`)]);
22
+ export const triggerEvents = snakeCase.table("usine_trigger_events", {
23
+ eventId: text()
24
+ .$type()
25
+ .primaryKey()
26
+ .references(() => events.eventId),
27
+ itemKey: text().$type().notNull(),
28
+ loopName: text().$type().notNull(),
29
+ stepName: text().$type().notNull(),
30
+ approval: text({ enum: APPROVAL_REQUIREMENTS }).$type().notNull(),
31
+ cycleLimit: integer().$type(),
32
+ // Item allowance observed before fetching this Event's trigger input.
33
+ cycleGeneration: integer().notNull().default(0),
34
+ // The execution context as submitted, part of the immutable Event fact. A
35
+ // queued Event is claimed later from these columns, while execution reads
36
+ // the Run's own copy below.
37
+ repository: text().$type().notNull(),
38
+ revision: text().$type().notNull(),
39
+ task: text().$type().notNull(),
40
+ agentJson: text({ mode: "json" }).$type().notNull(),
41
+ parentModel: text().$type(),
42
+ }, (table) => [
43
+ check("usine_trigger_events_approval", sql `${table.approval} in ('none', 'required')`),
44
+ check("usine_trigger_events_cycle_limit", sql `${table.cycleLimit} is null or ${table.cycleLimit} >= 1`),
45
+ check("usine_trigger_events_agent_json_valid", sql `json_valid(${table.agentJson})`),
46
+ index("usine_trigger_events_item").on(table.loopName, table.itemKey),
47
+ index("usine_trigger_events_item_history").on(table.itemKey),
48
+ ]);
49
+ export const itemCycleBudgets = snakeCase.table("usine_item_cycle_budgets", {
50
+ itemKey: text().$type().primaryKey(),
51
+ repository: text().$type().notNull(),
52
+ generation: integer().notNull().default(0),
53
+ askJson: text({ mode: "json" }).$type(),
54
+ resetPending: integer({ mode: "boolean" }).notNull().default(false),
55
+ }, (table) => [
56
+ check("usine_item_cycle_generation", sql `${table.generation} >= 0`),
57
+ check("usine_item_cycle_ask_json", sql `${table.askJson} is null or json_valid(${table.askJson})`),
58
+ ]);
59
+ export const cycleReservations = snakeCase.table("usine_cycle_reservations", {
60
+ runId: text()
61
+ .$type()
62
+ .primaryKey()
63
+ .references(() => runs.runId),
64
+ itemKey: text()
65
+ .$type()
66
+ .notNull()
67
+ .references(() => itemCycleBudgets.itemKey),
68
+ generation: integer().notNull(),
69
+ loop: text().$type().notNull(),
70
+ }, (table) => [
71
+ index("usine_cycle_reservations_item").on(table.itemKey, table.generation, table.loop),
72
+ check("usine_cycle_reservations_generation", sql `${table.generation} >= 0`),
73
+ ]);
74
+ export const cycleResets = snakeCase.table("usine_cycle_resets", {
75
+ askId: text().$type().primaryKey(),
76
+ eventId: text()
77
+ .$type()
78
+ .notNull()
79
+ .unique()
80
+ .references(() => events.eventId),
81
+ itemKey: text()
82
+ .$type()
83
+ .notNull()
84
+ .references(() => itemCycleBudgets.itemKey),
85
+ });
86
+ export const runs = snakeCase.table("usine_runs", {
87
+ runId: text().$type().primaryKey(),
88
+ eventId: text()
89
+ .$type()
90
+ .notNull()
91
+ .unique()
92
+ .references(() => triggerEvents.eventId),
93
+ loopName: text().$type().notNull(),
94
+ stateJson: text({ mode: "json" }).$type().notNull(),
95
+ openedAt: text().notNull(),
96
+ // The Run's effective context, seeded from the claiming submission.
97
+ // Edit-and-retry amends these columns; the Event columns never change (ADR 0018).
98
+ repository: text().$type().notNull(),
99
+ revision: text().$type().notNull(),
100
+ task: text().$type().notNull(),
101
+ agentJson: text({ mode: "json" }).$type().notNull(),
102
+ parentModel: text().$type(),
103
+ }, (table) => [
104
+ check("usine_runs_state_json_valid", sql `json_valid(${table.stateJson})`),
105
+ check("usine_runs_agent_json_valid", sql `json_valid(${table.agentJson})`),
106
+ ]);
107
+ export const steps = snakeCase.table("usine_steps", {
108
+ runId: text()
109
+ .$type()
110
+ .notNull()
111
+ .references(() => runs.runId),
112
+ stepName: text().$type().notNull(),
113
+ result: text({ mode: "json" }).$type(),
114
+ }, (table) => [
115
+ primaryKey({ columns: [table.runId, table.stepName] }),
116
+ check("usine_steps_result_json_valid", sql `${table.result} is null or json_valid(${table.result})`),
117
+ ]);
118
+ export const attempts = snakeCase.table("usine_attempts", {
119
+ attemptId: text().$type().primaryKey(),
120
+ runId: text().$type().notNull(),
121
+ stepName: text().$type().notNull(),
122
+ workerName: text().$type().notNull(),
123
+ attemptNumber: integer({ mode: "number" }).$type().notNull(),
124
+ brainJson: text({ mode: "json" }).$type().notNull(),
125
+ parentModel: text().$type(),
126
+ startedAt: text().notNull(),
127
+ outcomeJson: text({ mode: "json" }).$type(),
128
+ }, (table) => [
129
+ check("usine_attempts_number", sql `${table.attemptNumber} >= 1`),
130
+ check("usine_attempts_brain_json_valid", sql `json_valid(${table.brainJson})`),
131
+ check("usine_attempts_outcome_json_valid", sql `${table.outcomeJson} is null or json_valid(${table.outcomeJson})`),
132
+ uniqueIndex("usine_attempt_number").on(table.runId, table.stepName, table.attemptNumber),
133
+ uniqueIndex("usine_one_in_flight_attempt")
134
+ .on(table.runId)
135
+ .where(sql `${table.outcomeJson} is null`),
136
+ foreignKey({
137
+ columns: [table.runId, table.stepName],
138
+ foreignColumns: [steps.runId, steps.stepName],
139
+ }),
140
+ ]);
141
+ export const attemptTranscripts = snakeCase.table("usine_attempt_transcripts", {
142
+ sequence: integer({ mode: "number" }).primaryKey({ autoIncrement: true }),
143
+ attemptId: text()
144
+ .$type()
145
+ .notNull()
146
+ .references(() => attempts.attemptId),
147
+ direction: text({ enum: AttemptChannel.DIRECTIONS }).notNull(),
148
+ channelSequence: integer({ mode: "number" }).$type().notNull(),
149
+ envelope: text({ mode: "json" }).$type().notNull(),
150
+ receivedAt: text().notNull(),
151
+ }, (table) => [
152
+ check("usine_attempt_transcripts_direction", sql `${table.direction} in ('inbound', 'outbound')`),
153
+ check("usine_attempt_transcripts_sequence", sql `${table.channelSequence} >= 1`),
154
+ check("usine_attempt_transcripts_envelope_json_valid", sql `json_valid(${table.envelope})`),
155
+ uniqueIndex("usine_attempt_transcript_envelope").on(table.attemptId, table.direction, table.channelSequence),
156
+ index("usine_attempt_transcript_tail").on(table.attemptId, table.sequence),
157
+ ]);
158
+ export const approvals = snakeCase.table("usine_approvals", {
159
+ runId: text()
160
+ .$type()
161
+ .primaryKey()
162
+ .references(() => runs.runId),
163
+ eventId: text()
164
+ .$type()
165
+ .notNull()
166
+ .unique()
167
+ .references(() => events.eventId),
168
+ });
169
+ export const ignoredEvents = snakeCase.table("usine_ignored_events", {
170
+ eventId: text()
171
+ .$type()
172
+ .primaryKey()
173
+ .references(() => triggerEvents.eventId),
174
+ reason: text({ enum: IGNORED_REASONS }).$type().notNull(),
175
+ }, (table) => [
176
+ check("usine_ignored_events_reason", sql `${table.reason} in ('superseded', 'revoked')`),
177
+ ]);
178
+ export const workflowCommands = snakeCase.table("usine_workflow_commands", {
179
+ runId: text()
180
+ .$type()
181
+ .notNull()
182
+ .references(() => runs.runId),
183
+ command: text({ enum: WORKFLOW_COMMANDS }).$type().notNull(),
184
+ }, (table) => [
185
+ check("usine_workflow_commands_command", sql `${table.command} in ('Approve', 'Continue', 'Interrupt', 'Resume')`),
186
+ primaryKey({ columns: [table.runId, table.command] }),
187
+ ]);
188
+ /** Cursors that only save work; each owner validates its own value. */
189
+ export const cursors = snakeCase.table("usine_cursors", {
190
+ cursorKey: text().primaryKey(),
191
+ valueJson: text({ mode: "json" }).$type().notNull(),
192
+ }, (table) => [check("usine_cursors_value_json_valid", sql `json_valid(${table.valueJson})`)]);
193
+ /** The latest payload seen for each Item, for operator reads. */
194
+ export const itemProjections = snakeCase.table("usine_item_projections", {
195
+ itemKey: text().$type().primaryKey(),
196
+ repository: text().$type().notNull(),
197
+ source: text().notNull(),
198
+ itemNumber: integer({ mode: "number" }).notNull(),
199
+ contentHash: text().notNull(),
200
+ payloadJson: text({ mode: "json" }).$type().notNull(),
201
+ }, (table) => [
202
+ check("usine_item_projections_number", sql `${table.itemNumber} >= 1`),
203
+ check("usine_item_projections_payload_json_valid", sql `json_valid(${table.payloadJson})`),
204
+ uniqueIndex("usine_item_projection_number").on(table.repository, table.itemNumber),
205
+ index("usine_item_projection_repository").on(table.repository, table.itemNumber),
206
+ ]);
207
+ /** The latest complete label catalog for each managed repository. */
208
+ export const repositoryLabelProjections = snakeCase.table("usine_repository_label_projections", {
209
+ repository: text().$type().primaryKey(),
210
+ labelsJson: text({ mode: "json" }).$type().notNull(),
211
+ }, (table) => [
212
+ check("usine_repository_label_projections_labels_json_valid", sql `json_valid(${table.labelsJson})`),
213
+ ]);
214
+ /** Operator-owned runtime toggles, kept apart from authored loop files (ADR 0009). */
215
+ export const loopRuntime = snakeCase.table("usine_loop_runtime", {
216
+ loopName: text().$type().primaryKey(),
217
+ paused: integer({ mode: "boolean" }).notNull(),
218
+ });
219
+ /** Single row whose version invalidates cached operator projections. */
220
+ export const projectionRevision = snakeCase.table("usine_projection_revision", {
221
+ singleton: integer({ mode: "number" }).primaryKey().default(1),
222
+ revision: integer({ mode: "number" }).notNull().default(0),
223
+ }, (table) => [check("usine_projection_revision_singleton", sql `${table.singleton} = 1`)]);
224
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/database/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACtD,OA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CAAC,CAAC,OAAO,EAAE;CAC/C,CAAC,CAAC;AAEH,wEAAwE;AACxE,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC,KAAK,CAC/C,2BAA2B,EAC3B;IACE,SAAS,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9D,QAAQ,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;CAC3D,EACD,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,qCAAqC,EAAE,GAAG,CAAA,GAAG,KAAK,CAAC,SAAS,MAAM,CAAC,CAAC,CACvF,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { Event } from "@usine/core/event";
2
+ import { ItemKey } from "@usine/core/item";
3
+ import { LoopName } from "@usine/core/loop";
4
+ import { RunId } from "@usine/core/run";
5
+ import { Context, Crypto, Effect, Layer } from "effect";
6
+ import { SqlClient } from "effect/unstable/sql";
7
+ import { RunDatabase } from "../database/database.ts";
8
+ import { type RunEngineError } from "./error.ts";
9
+ import type { RunSnapshot } from "../run-reader/model.ts";
10
+ import type { Submission, SubmissionResult } from "./submission.ts";
11
+ import type { TranscriptEntry, TranscriptQuery } from "../transcript.ts";
12
+ import { RunReader } from "../run-reader/run-reader.ts";
13
+ import { ItemProjectionReader, ItemProjectionWriter } from "../item-projection/item-projection.ts";
14
+ import { RepositoryLabelProjectionReader, RepositoryLabelProjectionWriter } from "../repository-label-projection/repository-label-projection.ts";
15
+ import { StepExecutor } from "../step-executor.ts";
16
+ import { CursorStore } from "../cursor/cursor.ts";
17
+ import { LoopControl } from "../loop-control/loop-control.ts";
18
+ import { CycleBudgets } from "../cycle-budget/cycle-budget.ts";
19
+ declare const RunEngine_base: Context.ServiceClass<RunEngine, "@usine/engine/RunEngine", {
20
+ /** Stops admitting Attempts, including retries, and waits for admitted work to settle. Interrupting this wait keeps admission closed until restart. */
21
+ readonly drain: () => Effect.Effect<void>;
22
+ /** Records the operator's approval Event and opens the Run's gate; execution still waits for a Worker slot. */
23
+ readonly approve: (runId: RunId, approval: Event) => Effect.Effect<void, RunEngineError>;
24
+ /** Cancels an open Run and interrupts its active Attempt. An already closed Run is unchanged. */
25
+ readonly cancel: (runId: RunId) => Effect.Effect<void, RunEngineError>;
26
+ /** Reads the Run's current state, effective task and Agent, Step result, and Attempt history. */
27
+ readonly inspect: (runId: RunId) => Effect.Effect<RunSnapshot, RunEngineError>;
28
+ /** Recovers unfinished Runs and outstanding actions from stored state; also runs when the engine starts. */
29
+ readonly reconcile: () => Effect.Effect<void, RunEngineError>;
30
+ /** Requests another Attempt for a failed Run using its existing Event and effective task and Agent. */
31
+ readonly retry: (runId: RunId) => Effect.Effect<void, RunEngineError>;
32
+ /** Cancels unstarted Runs and discards queued Events for a Loop's Item when it stops matching; running Attempts continue. */
33
+ readonly revoke: (loop: LoopName, itemKey: ItemKey) => Effect.Effect<ReadonlyArray<RunId>, RunEngineError>;
34
+ /**
35
+ * Records a matching Event and claims its Run, or queues it behind the Item's
36
+ * running Attempt. Repeated Events are deduplicated; execution continues separately.
37
+ */
38
+ readonly submit: (submission: Submission) => Effect.Effect<SubmissionResult, RunEngineError>;
39
+ /** Reads the requested portion of an Attempt's persisted transcript in append order. */
40
+ readonly transcript: (query: TranscriptQuery) => Effect.Effect<ReadonlyArray<TranscriptEntry>, RunEngineError>;
41
+ }>;
42
+ /** Records Events and manages their Runs through approval, execution, retry, and cancellation. */
43
+ export declare class RunEngine extends RunEngine_base {
44
+ }
45
+ /**
46
+ * Provides Run execution and recovery on the supplied database.
47
+ * `database` must supply Drizzle and Effect SQL clients for the same database,
48
+ * so Run records and pending execution remain together across restarts.
49
+ * The deployment supplies `Crypto` and the Worker implementation through `StepExecutor`.
50
+ */
51
+ export declare const layerWithDatabase: <DatabaseError, DatabaseRequirements>(database: Layer.Layer<RunDatabase | SqlClient.SqlClient, DatabaseError, DatabaseRequirements>) => Layer.Layer<CursorStore | CycleBudgets | ItemProjectionReader | ItemProjectionWriter | LoopControl | RepositoryLabelProjectionReader | RepositoryLabelProjectionWriter | RunEngine | RunReader, RunEngineError | DatabaseError, Crypto.Crypto | StepExecutor | DatabaseRequirements>;
52
+ export { Submission, Claimed, Queued, Ignored, CycleBlocked, IgnoreReason, SubmissionResult, } from "./submission.ts";
53
+ export { RunEngineShutdown } from "./shutdown.ts";
54
+ export { RunNotFoundError, RunOperationRejectedError, EnginePersistenceError, AttemptCancellationError, RunStoreError, RunEngineError, } from "./error.ts";
55
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/engine/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAkB,MAAM,QAAQ,CAAC;AAExE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC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,aAAa,CAAC,eAAe,CAAC,EAAE,cAAc,CAAC;;AA7BtE,kGAAkG;AAClG,qBAAa,SAAU,SAAQ,cA8BD;CAAG;AAEjC;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,aAAa,EAAE,oBAAoB,YACzD,KAAK,CAAC,KAAK,CAAC,WAAW,GAAG,SAAS,CAAC,SAAS,EAAE,aAAa,EAAE,oBAAoB,CAAC,KAC5F,KAAK,CAAC,KAAK,CACV,WAAW,GACX,YAAY,GACZ,oBAAoB,GACpB,oBAAoB,GACpB,WAAW,GACX,+BAA+B,GAC/B,+BAA+B,GAC/B,SAAS,GACT,SAAS,EACX,cAAc,GAAG,aAAa,EAC9B,MAAM,CAAC,MAAM,GAAG,YAAY,GAAG,oBAAoB,CA8BpD,CAAC;AAEF,OAAO,EACL,UAAU,EACV,OAAO,EACP,MAAM,EACN,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC"}
@@ -0,0 +1,193 @@
1
+ import { Event } from "@usine/core/event";
2
+ import { ItemKey } from "@usine/core/item";
3
+ import { LoopName } from "@usine/core/loop";
4
+ import { RunId } from "@usine/core/run";
5
+ import { Context, Crypto, Effect, Layer, Option, Result } from "effect";
6
+ import { ClusterWorkflowEngine, SingleRunner } from "effect/unstable/cluster";
7
+ import { SqlClient } from "effect/unstable/sql";
8
+ import { DurableDeferred, WorkflowEngine } from "effect/unstable/workflow";
9
+ import { RunDatabase } from "../database/database.js";
10
+ import { AttemptCancellationError } from "./error.js";
11
+ import { RunStore } from "../store/store.js";
12
+ import { RunReader } from "../run-reader/run-reader.js";
13
+ import { ItemProjectionReader, ItemProjectionWriter } from "../item-projection/item-projection.js";
14
+ import { RepositoryLabelProjectionReader, RepositoryLabelProjectionWriter, } from "../repository-label-projection/repository-label-projection.js";
15
+ import { ApprovalGate, DurableRun, continueWithNewest, durableRunLayer, runIdFor, } from "../workflow/workflow.js";
16
+ import { StepExecutor } from "../step-executor.js";
17
+ import { CursorStore } from "../cursor/cursor.js";
18
+ import { LoopControl } from "../loop-control/loop-control.js";
19
+ import { CycleBudgets } from "../cycle-budget/cycle-budget.js";
20
+ import { AttemptAdmission } from "../workflow/admission.js";
21
+ const MAX_SETTLEMENT_POLLS = 500;
22
+ const makeRunEngine = Effect.gen(function* () {
23
+ const store = yield* RunStore;
24
+ const admission = yield* AttemptAdmission;
25
+ const stepExecutor = yield* StepExecutor;
26
+ const workflowEngine = yield* WorkflowEngine.WorkflowEngine;
27
+ const provideWorkflowEngine = (effect) => Effect.provideService(effect, WorkflowEngine.WorkflowEngine, workflowEngine);
28
+ const launch = Effect.fn("RunEngine.launch")(function* (submission) {
29
+ yield* DurableRun.execute({ submission }, { discard: true }).pipe(provideWorkflowEngine);
30
+ });
31
+ const deliverInterrupt = Effect.fn("RunEngine.deliverInterrupt")(function* (runId) {
32
+ yield* DurableRun.interrupt(runId).pipe(provideWorkflowEngine);
33
+ yield* store.completeWorkflowCommand(runId, "Interrupt");
34
+ });
35
+ const deliverApproval = Effect.fn("RunEngine.deliverApproval")(function* (runId) {
36
+ const token = DurableDeferred.tokenFromExecutionId(ApprovalGate, {
37
+ workflow: DurableRun,
38
+ executionId: runId,
39
+ });
40
+ yield* DurableDeferred.succeed(ApprovalGate, { token, value: undefined }).pipe(provideWorkflowEngine);
41
+ yield* store.completeWorkflowCommand(runId, "Approve");
42
+ });
43
+ const deliverContinuation = Effect.fn("RunEngine.deliverContinuation")(function* (runId) {
44
+ yield* continueWithNewest(store, runId).pipe(provideWorkflowEngine);
45
+ });
46
+ const awaitWorkflowSettlement = Effect.fn("RunEngine.awaitWorkflowSettlement")(function* (runId) {
47
+ // A Failed projection commits before the workflow finishes suspending, so
48
+ // poll across that handover or an immediate operator retry is lost. A
49
+ // workflow still absent at the deadline means a corrupted instance
50
+ // database, so fail loudly instead of hanging.
51
+ for (let poll = 0; poll < MAX_SETTLEMENT_POLLS; poll += 1) {
52
+ const status = yield* DurableRun.poll(runId).pipe(provideWorkflowEngine);
53
+ if (Option.isSome(status))
54
+ return status.value;
55
+ yield* Effect.sleep("10 millis");
56
+ }
57
+ return yield* Effect.die(new Error(`Run ${runId} has no durable workflow execution to settle`));
58
+ });
59
+ const deliverResume = Effect.fn("RunEngine.deliverResume")(function* (runId) {
60
+ const status = yield* awaitWorkflowSettlement(runId);
61
+ if (status._tag === "Complete") {
62
+ yield* store.reconcileCompletion(runId, status);
63
+ yield* store.completeWorkflowCommand(runId, "Resume");
64
+ yield* deliverContinuation(runId);
65
+ return;
66
+ }
67
+ yield* DurableRun.resume(runId).pipe(provideWorkflowEngine);
68
+ yield* store.completeWorkflowCommand(runId, "Resume");
69
+ });
70
+ const commandHandlers = {
71
+ Approve: deliverApproval,
72
+ Continue: deliverContinuation,
73
+ Interrupt: deliverInterrupt,
74
+ Resume: deliverResume,
75
+ };
76
+ const submit = Effect.fn("RunEngine.submit")(function* (submission) {
77
+ const requestedRunId = yield* runIdFor(submission);
78
+ const claim = yield* store.recordAndClaim(submission, requestedRunId);
79
+ if (Option.isSome(claim.supersededRun)) {
80
+ yield* deliverInterrupt(claim.supersededRun.value);
81
+ }
82
+ if (claim.result._tag === "Claimed") {
83
+ yield* launch(claim.submission);
84
+ }
85
+ return claim.result;
86
+ });
87
+ const approve = Effect.fn("RunEngine.approve")(function* (runId, approval) {
88
+ yield* store.approve(runId, approval);
89
+ yield* deliverApproval(runId);
90
+ });
91
+ const retry = Effect.fn("RunEngine.retry")(function* (runId) {
92
+ yield* store.retry(runId);
93
+ yield* deliverResume(runId);
94
+ });
95
+ const cancel = Effect.fn("RunEngine.cancel")(function* (runId) {
96
+ // The closing transaction decides both facts at once: whether the run was
97
+ // still open, and which attempt was in flight when it closed.
98
+ const outcome = yield* store.cancel(runId);
99
+ if (outcome._tag === "AlreadyClosed") {
100
+ yield* Effect.logDebug("Cancel was a no-op; the run was already closed", { runId });
101
+ return;
102
+ }
103
+ yield* Effect.logInfo("Run canceled", {
104
+ runId,
105
+ openAttempt: Option.getOrElse(outcome.openAttempt, () => "none"),
106
+ });
107
+ const handshake = Option.isSome(outcome.openAttempt)
108
+ ? yield* stepExecutor.interrupt(outcome.openAttempt.value).pipe(Effect.result)
109
+ : Result.succeed(undefined);
110
+ yield* deliverInterrupt(runId);
111
+ yield* deliverContinuation(runId);
112
+ if (Option.isSome(outcome.openAttempt) && Result.isFailure(handshake)) {
113
+ return yield* new AttemptCancellationError({
114
+ attemptId: outcome.openAttempt.value,
115
+ cause: handshake.failure,
116
+ });
117
+ }
118
+ });
119
+ const revoke = Effect.fn("RunEngine.revoke")(function* (loop, itemKey) {
120
+ const revoked = yield* store.revoke(loop, itemKey);
121
+ yield* Effect.forEach(revoked, deliverInterrupt, {
122
+ concurrency: "unbounded",
123
+ discard: true,
124
+ });
125
+ return revoked;
126
+ });
127
+ const inspect = Effect.fn("RunEngine.inspect")(function* (runId) {
128
+ return yield* store.snapshot(runId);
129
+ });
130
+ const transcript = Effect.fn("RunEngine.transcript")(function* (query) {
131
+ return yield* store.transcript(query);
132
+ });
133
+ const reconcile = Effect.fn("RunEngine.reconcile")(function* () {
134
+ yield* Effect.forEach(yield* store.pendingWorkflowCommands, ({ command, runId }) => commandHandlers[command](runId), { discard: true });
135
+ const recoverable = yield* store.recoverable;
136
+ yield* Effect.forEach(recoverable, ({ runId, state, submission }) => Effect.gen(function* () {
137
+ const status = yield* DurableRun.poll(runId).pipe(provideWorkflowEngine);
138
+ if (Option.isSome(status) && status.value._tag === "Complete") {
139
+ yield* store.reconcileCompletion(runId, status.value);
140
+ yield* deliverContinuation(runId);
141
+ return;
142
+ }
143
+ if (Option.isSome(status) && status.value._tag === "Suspended") {
144
+ if (state._tag === "Running") {
145
+ yield* deliverResume(runId);
146
+ }
147
+ return;
148
+ }
149
+ yield* launch(submission);
150
+ }), { concurrency: "unbounded", discard: true });
151
+ });
152
+ yield* reconcile();
153
+ return {
154
+ approve,
155
+ cancel,
156
+ drain: admission.drain,
157
+ inspect,
158
+ reconcile,
159
+ retry,
160
+ revoke,
161
+ submit,
162
+ transcript,
163
+ };
164
+ });
165
+ /** Records Events and manages their Runs through approval, execution, retry, and cancellation. */
166
+ export class RunEngine extends Context.Service()("@usine/engine/RunEngine") {
167
+ }
168
+ /**
169
+ * Provides Run execution and recovery on the supplied database.
170
+ * `database` must supply Drizzle and Effect SQL clients for the same database,
171
+ * so Run records and pending execution remain together across restarts.
172
+ * The deployment supplies `Crypto` and the Worker implementation through `StepExecutor`.
173
+ */
174
+ export const layerWithDatabase = (database) => {
175
+ const store = RunStore.layer.pipe(Layer.provide(database));
176
+ const cluster = SingleRunner.layer({
177
+ runnerStorage: "memory",
178
+ shardingConfig: {
179
+ availableShardGroups: ["default", "workflow"],
180
+ assignedShardGroups: ["default", "workflow"],
181
+ entityTerminationTimeout: 0,
182
+ },
183
+ }).pipe(Layer.provide(database), Layer.orDie);
184
+ const workflowEngine = ClusterWorkflowEngine.layer.pipe(Layer.provide(cluster));
185
+ const admission = AttemptAdmission.layer;
186
+ const runtime = durableRunLayer.pipe(Layer.provideMerge(workflowEngine), Layer.provideMerge(store), Layer.provideMerge(admission));
187
+ const runEngine = Layer.effect(RunEngine, makeRunEngine).pipe(Layer.provide(runtime));
188
+ return Layer.mergeAll(runEngine, CycleBudgets.layer.pipe(Layer.provide(database)), RunReader.layer.pipe(Layer.provide(database)), CursorStore.layer.pipe(Layer.provide(database)), ItemProjectionReader.layer.pipe(Layer.provide(database)), ItemProjectionWriter.layer.pipe(Layer.provide(database)), RepositoryLabelProjectionReader.layer.pipe(Layer.provide(database)), RepositoryLabelProjectionWriter.layer.pipe(Layer.provide(database)), LoopControl.layer.pipe(Layer.provide(database)));
189
+ };
190
+ export { Submission, Claimed, Queued, Ignored, CycleBlocked, IgnoreReason, SubmissionResult, } from "./submission.js";
191
+ export { RunEngineShutdown } from "./shutdown.js";
192
+ export { RunNotFoundError, RunOperationRejectedError, EnginePersistenceError, AttemptCancellationError, RunStoreError, RunEngineError, } from "./error.js";
193
+ //# sourceMappingURL=engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/engine/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAuB,MAAM,YAAY,CAAC;AAI3E,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EACL,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,+DAA+D,CAAC;AACvE,OAAO,EACL,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,QAAQ,GACT,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY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AO,CAAC,QAAQ,CAAC,CAAC,EACnE,+BAA+B,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EACnE,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAChD,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,EACL,UAAU,EACV,OAAO,EACP,MAAM,EACN,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { Schema } from "effect";
2
+ declare const RunNotFoundError_base: Schema.Class<RunNotFoundError, Schema.TaggedStruct<"RunNotFoundError", {
3
+ readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
4
+ }>, import("effect/Cause").YieldableError>;
5
+ /** No Run with the requested identity exists in this instance's records. */
6
+ export declare class RunNotFoundError extends RunNotFoundError_base {
7
+ }
8
+ declare const RunOperationRejectedError_base: Schema.Class<RunOperationRejectedError, Schema.TaggedStruct<"RunOperationRejectedError", {
9
+ readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
10
+ readonly operation: Schema.Literals<readonly ["approve", "retry"]>;
11
+ readonly state: Schema.String;
12
+ }>, import("effect/Cause").YieldableError>;
13
+ /** The Run's current state does not allow the requested approval or retry. */
14
+ export declare class RunOperationRejectedError extends RunOperationRejectedError_base {
15
+ }
16
+ declare const EnginePersistenceError_base: Schema.Class<EnginePersistenceError, Schema.TaggedStruct<"EnginePersistenceError", {
17
+ readonly operation: Schema.String;
18
+ readonly cause: Schema.Defect;
19
+ }>, import("effect/Cause").YieldableError>;
20
+ /** An operation could not read or update the instance's durable records. */
21
+ export declare class EnginePersistenceError extends EnginePersistenceError_base {
22
+ }
23
+ declare const AttemptCancellationError_base: Schema.Class<AttemptCancellationError, Schema.TaggedStruct<"AttemptCancellationError", {
24
+ readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
25
+ readonly cause: Schema.Defect;
26
+ }>, import("effect/Cause").YieldableError>;
27
+ /** The Run is canceled, but interrupting its active Attempt failed. */
28
+ export declare class AttemptCancellationError extends AttemptCancellationError_base {
29
+ }
30
+ /** Everything the store itself can fail with. */
31
+ export declare const RunStoreError: Schema.Union<readonly [typeof RunNotFoundError, typeof RunOperationRejectedError, typeof EnginePersistenceError]>;
32
+ export type RunStoreError = typeof RunStoreError.Type;
33
+ /** The store's failures plus the cancellation handshake failure only the engine raises. */
34
+ export declare const RunEngineError: Schema.Union<readonly [typeof RunNotFoundError, typeof RunOperationRejectedError, typeof EnginePersistenceError, typeof AttemptCancellationError]>;
35
+ export type RunEngineError = typeof RunEngineError.Type;
36
+ export {};
37
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/engine/error.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;AAEhC,4EAA4E;AAC5E,qBAAa,gBAAiB,SAAQ,qBAIpC;CAAG;;;;;;AAEL,8EAA8E;AAC9E,qBAAa,yBAA0B,SAAQ,8BAM7C;CAAG;;;;;AAEL,4EAA4E;AAC5E,qBAAa,sBAAuB,SAAQ,2BAK1C;CAAG;;;;;AAEL,uEAAuE;AACvE,qBAAa,wBAAyB,SAAQ,6BAK5C;CAAG;AAEL,iDAAiD;AACjD,eAAO,MAAM,aAAa,mHAIxB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC;AAEtD,2FAA2F;AAC3F,eAAO,MAAM,cAAc,oJAKzB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { AttemptId } from "@usine/core/attempt";
2
+ import { RunId } from "@usine/core/run";
3
+ import { Schema } from "effect";
4
+ /** No Run with the requested identity exists in this instance's records. */
5
+ export class RunNotFoundError extends Schema.TaggedError("@usine/engine/RunNotFoundError")("RunNotFoundError", {
6
+ runId: RunId,
7
+ }) {
8
+ }
9
+ /** The Run's current state does not allow the requested approval or retry. */
10
+ export class RunOperationRejectedError extends Schema.TaggedError("@usine/engine/RunOperationRejectedError")("RunOperationRejectedError", {
11
+ runId: RunId,
12
+ operation: Schema.Literals(["approve", "retry"]),
13
+ state: Schema.String,
14
+ }) {
15
+ }
16
+ /** An operation could not read or update the instance's durable records. */
17
+ export class EnginePersistenceError extends Schema.TaggedError("@usine/engine/EnginePersistenceError")("EnginePersistenceError", {
18
+ operation: Schema.String,
19
+ cause: Schema.Defect(),
20
+ }) {
21
+ }
22
+ /** The Run is canceled, but interrupting its active Attempt failed. */
23
+ export class AttemptCancellationError extends Schema.TaggedError("@usine/engine/AttemptCancellationError")("AttemptCancellationError", {
24
+ attemptId: AttemptId,
25
+ cause: Schema.Defect(),
26
+ }) {
27
+ }
28
+ /** Everything the store itself can fail with. */
29
+ export const RunStoreError = Schema.Union([
30
+ RunNotFoundError,
31
+ RunOperationRejectedError,
32
+ EnginePersistenceError,
33
+ ]);
34
+ /** The store's failures plus the cancellation handshake failure only the engine raises. */
35
+ export const RunEngineError = Schema.Union([
36
+ RunNotFoundError,
37
+ RunOperationRejectedError,
38
+ EnginePersistenceError,
39
+ AttemptCancellationError,
40
+ ]);
41
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/engine/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC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