@usine/engine 0.1.0 → 0.3.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 (156) hide show
  1. package/README.md +39 -12
  2. package/dist/cursor/{store.d.ts → cursor.d.ts} +9 -7
  3. package/dist/cursor/cursor.d.ts.map +1 -0
  4. package/dist/cursor/{store.js → cursor.js} +8 -7
  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 +1 -1
  19. package/dist/database/database.d.ts.map +1 -1
  20. package/dist/database/local-sqlite.d.ts +32 -12
  21. package/dist/database/local-sqlite.d.ts.map +1 -1
  22. package/dist/database/local-sqlite.js +121 -16
  23. package/dist/database/local-sqlite.js.map +1 -1
  24. package/dist/database/schema.d.ts +302 -9
  25. package/dist/database/schema.d.ts.map +1 -1
  26. package/dist/database/schema.js +69 -12
  27. package/dist/database/schema.js.map +1 -1
  28. package/dist/engine/engine.d.ts +59 -0
  29. package/dist/engine/engine.d.ts.map +1 -0
  30. package/dist/{engine.js → engine/engine.js} +80 -32
  31. package/dist/engine/engine.js.map +1 -0
  32. package/dist/engine/error.d.ts +45 -0
  33. package/dist/engine/error.d.ts.map +1 -0
  34. package/dist/engine/error.js +49 -0
  35. package/dist/engine/error.js.map +1 -0
  36. package/dist/engine/lifecycle.d.ts +112 -0
  37. package/dist/engine/lifecycle.d.ts.map +1 -0
  38. package/dist/engine/lifecycle.js +132 -0
  39. package/dist/engine/lifecycle.js.map +1 -0
  40. package/dist/engine/shutdown.d.ts +12 -0
  41. package/dist/engine/shutdown.d.ts.map +1 -0
  42. package/dist/engine/shutdown.js +10 -0
  43. package/dist/engine/shutdown.js.map +1 -0
  44. package/dist/engine/submission.d.ts +58 -0
  45. package/dist/engine/submission.d.ts.map +1 -0
  46. package/dist/engine/submission.js +54 -0
  47. package/dist/engine/submission.js.map +1 -0
  48. package/dist/item-projection/{service.d.ts → item-projection.d.ts} +6 -6
  49. package/dist/item-projection/item-projection.d.ts.map +1 -0
  50. package/dist/item-projection/{service.js → item-projection.js} +7 -5
  51. package/dist/item-projection/item-projection.js.map +1 -0
  52. package/dist/item-projection/model.d.ts +2 -5
  53. package/dist/item-projection/model.d.ts.map +1 -1
  54. package/dist/item-projection/model.js +5 -5
  55. package/dist/item-projection/model.js.map +1 -1
  56. package/dist/loop-control/loop-control.d.ts +21 -0
  57. package/dist/loop-control/loop-control.d.ts.map +1 -0
  58. package/dist/{loop-control.js → loop-control/loop-control.js} +7 -5
  59. package/dist/loop-control/loop-control.js.map +1 -0
  60. package/dist/loop-control/model.d.ts +10 -0
  61. package/dist/loop-control/model.d.ts.map +1 -0
  62. package/dist/loop-control/model.js +9 -0
  63. package/dist/loop-control/model.js.map +1 -0
  64. package/dist/repository-label-projection/model.d.ts +12 -3
  65. package/dist/repository-label-projection/model.d.ts.map +1 -1
  66. package/dist/repository-label-projection/model.js +14 -5
  67. package/dist/repository-label-projection/model.js.map +1 -1
  68. package/dist/repository-label-projection/{service.d.ts → repository-label-projection.d.ts} +5 -5
  69. package/dist/repository-label-projection/repository-label-projection.d.ts.map +1 -0
  70. package/dist/repository-label-projection/{service.js → repository-label-projection.js} +17 -7
  71. package/dist/repository-label-projection/repository-label-projection.js.map +1 -0
  72. package/dist/run-reader/model.d.ts +46 -0
  73. package/dist/run-reader/model.d.ts.map +1 -0
  74. package/dist/run-reader/model.js +44 -0
  75. package/dist/run-reader/model.js.map +1 -0
  76. package/dist/run-reader/run-reader.d.ts +29 -0
  77. package/dist/run-reader/run-reader.d.ts.map +1 -0
  78. package/dist/run-reader/run-reader.js +44 -0
  79. package/dist/run-reader/run-reader.js.map +1 -0
  80. package/dist/step-executor.d.ts +36 -12
  81. package/dist/step-executor.d.ts.map +1 -1
  82. package/dist/step-executor.js +22 -5
  83. package/dist/step-executor.js.map +1 -1
  84. package/dist/store/codec.d.ts +278 -40
  85. package/dist/store/codec.d.ts.map +1 -1
  86. package/dist/store/codec.js +72 -44
  87. package/dist/store/codec.js.map +1 -1
  88. package/dist/store/queries.d.ts +49 -16
  89. package/dist/store/queries.d.ts.map +1 -1
  90. package/dist/store/queries.js +104 -91
  91. package/dist/store/queries.js.map +1 -1
  92. package/dist/store/store.d.ts +44 -26
  93. package/dist/store/store.d.ts.map +1 -1
  94. package/dist/store/store.js +199 -128
  95. package/dist/store/store.js.map +1 -1
  96. package/dist/store/transcript.d.ts +9 -0
  97. package/dist/store/transcript.d.ts.map +1 -0
  98. package/dist/store/transcript.js +71 -0
  99. package/dist/store/transcript.js.map +1 -0
  100. package/dist/transcript.d.ts +86 -0
  101. package/dist/transcript.d.ts.map +1 -0
  102. package/dist/transcript.js +77 -0
  103. package/dist/transcript.js.map +1 -0
  104. package/dist/workflow/admission.d.ts +13 -0
  105. package/dist/workflow/admission.d.ts.map +1 -0
  106. package/dist/workflow/admission.js +55 -0
  107. package/dist/workflow/admission.js.map +1 -0
  108. package/dist/workflow/command.d.ts +13 -0
  109. package/dist/workflow/command.d.ts.map +1 -0
  110. package/dist/workflow/command.js +17 -0
  111. package/dist/workflow/command.js.map +1 -0
  112. package/dist/workflow/workflow.d.ts +18 -0
  113. package/dist/workflow/workflow.d.ts.map +1 -0
  114. package/dist/workflow/workflow.js +108 -0
  115. package/dist/workflow/workflow.js.map +1 -0
  116. package/drizzle/20260903091940_queued_approved_runs/migration.sql +3 -0
  117. package/drizzle/20260903091940_queued_approved_runs/snapshot.json +1147 -0
  118. package/drizzle/20260905150403_item_cycle_budgets/migration.sql +58 -0
  119. package/drizzle/20260905150403_item_cycle_budgets/snapshot.json +1417 -0
  120. package/drizzle/20260905174009_item_run_history/migration.sql +1 -0
  121. package/drizzle/20260905174009_item_run_history/snapshot.json +1431 -0
  122. package/drizzle/20260912111855_operator_intervention/migration.sql +42 -0
  123. package/drizzle/20260912111855_operator_intervention/snapshot.json +1461 -0
  124. package/package.json +41 -5
  125. package/dist/cursor/model.d.ts +0 -5
  126. package/dist/cursor/model.d.ts.map +0 -1
  127. package/dist/cursor/model.js +0 -4
  128. package/dist/cursor/model.js.map +0 -1
  129. package/dist/cursor/store.d.ts.map +0 -1
  130. package/dist/cursor/store.js.map +0 -1
  131. package/dist/engine.d.ts +0 -39
  132. package/dist/engine.d.ts.map +0 -1
  133. package/dist/engine.js.map +0 -1
  134. package/dist/index.d.ts +0 -20
  135. package/dist/index.d.ts.map +0 -1
  136. package/dist/index.js +0 -20
  137. package/dist/index.js.map +0 -1
  138. package/dist/item-projection/service.d.ts.map +0 -1
  139. package/dist/item-projection/service.js.map +0 -1
  140. package/dist/loop-control.d.ts +0 -16
  141. package/dist/loop-control.d.ts.map +0 -1
  142. package/dist/loop-control.js.map +0 -1
  143. package/dist/model.d.ts +0 -185
  144. package/dist/model.d.ts.map +0 -1
  145. package/dist/model.js +0 -174
  146. package/dist/model.js.map +0 -1
  147. package/dist/repository-label-projection/service.d.ts.map +0 -1
  148. package/dist/repository-label-projection/service.js.map +0 -1
  149. package/dist/run-reader.d.ts +0 -20
  150. package/dist/run-reader.d.ts.map +0 -1
  151. package/dist/run-reader.js +0 -19
  152. package/dist/run-reader.js.map +0 -1
  153. package/dist/workflow.d.ts +0 -14
  154. package/dist/workflow.d.ts.map +0 -1
  155. package/dist/workflow.js +0 -105
  156. package/dist/workflow.js.map +0 -1
package/dist/model.js DELETED
@@ -1,174 +0,0 @@
1
- import { Agent, Attempt, AttemptChannel, Event, Instance, Item, Loop, Repository, Run, Step, } from "@usine/core";
2
- import { Schema } from "effect";
3
- /** Whether a loop parks new runs until an approval Event arrives. */
4
- export const APPROVAL_REQUIREMENTS = Loop.APPROVAL_REQUIREMENTS;
5
- export const ApprovalRequirement = Loop.ApprovalRequirement;
6
- /** Absolute or caller-resolved path to the instance folder. */
7
- export const InstanceDirectory = Instance.Directory;
8
- /** Durable runtime state for one Loop. Authored loop files never carry this toggle. */
9
- export class LoopRuntimeState extends Schema.Class("@usine/engine/LoopRuntimeState")({
10
- loop: Loop.LoopName,
11
- paused: Schema.Boolean,
12
- }) {
13
- }
14
- /** The complete routing context needed to turn one Event into a Run. */
15
- export class Submission extends Schema.Class("@usine/engine/Submission")({
16
- event: Event.Event,
17
- itemKey: Item.ItemKey,
18
- loop: Loop.LoopName,
19
- step: Step.StepName,
20
- approval: ApprovalRequirement,
21
- repository: Repository.Name,
22
- revision: Repository.Revision,
23
- task: AttemptChannel.Task,
24
- agent: Agent.Agent,
25
- parentModel: Schema.Option(Agent.ModelId),
26
- }) {
27
- }
28
- /** The Event owns a Run and repeated submissions return the same identity. */
29
- export class Claimed extends Schema.TaggedClass("@usine/engine/Claimed")("Claimed", {
30
- eventId: Event.EventId,
31
- runId: Run.RunId,
32
- }) {
33
- }
34
- /** A running Attempt on the same Item must finish before this Event is reconsidered. */
35
- export class Queued extends Schema.TaggedClass("@usine/engine/Queued")("Queued", {
36
- eventId: Event.EventId,
37
- }) {
38
- }
39
- export const IGNORED_REASONS = ["superseded", "revoked"];
40
- export const IgnoreReason = Schema.Literals(IGNORED_REASONS);
41
- /** Durable one-shot requests from the store to the workflow runtime. */
42
- export const WORKFLOW_COMMANDS = ["Approve", "Continue", "Interrupt", "Resume"];
43
- export const WorkflowCommand = Schema.Literals(WORKFLOW_COMMANDS);
44
- /**
45
- * Replay order after a restart, first delivered first. Interrupt must precede
46
- * Continue: on a cancel replay the canceled workflow stops before the next
47
- * queued Event opens, preserving one open Run per Item. The length constraint
48
- * forces this list to name every command exactly once.
49
- */
50
- export const WORKFLOW_COMMAND_PRIORITY = [
51
- "Resume",
52
- "Interrupt",
53
- "Continue",
54
- "Approve",
55
- ];
56
- /** The Event remains in the permanent ledger but can no longer open a Run. */
57
- export class Ignored extends Schema.TaggedClass("@usine/engine/Ignored")("Ignored", {
58
- eventId: Event.EventId,
59
- reason: IgnoreReason,
60
- }) {
61
- }
62
- export const SubmissionResult = Schema.Union([Claimed, Queued, Ignored]);
63
- /** Observable durable projection for one Run. */
64
- export class RunSnapshot extends Schema.Class("@usine/engine/RunSnapshot")({
65
- event: Event.Event,
66
- itemKey: Item.ItemKey,
67
- run: Run.Run,
68
- step: Step.Step,
69
- attempts: Schema.Array(Attempt.Attempt),
70
- repository: Repository.Name,
71
- revision: Repository.Revision,
72
- task: AttemptChannel.Task,
73
- agent: Agent.Agent,
74
- parentModel: Schema.Option(Agent.ModelId),
75
- }) {
76
- }
77
- /** Lightweight durable projection used when listing Runs for operators. */
78
- export class RunSummary extends Schema.Class("@usine/engine/RunSummary")({
79
- itemKey: Item.ItemKey,
80
- run: Run.Run,
81
- step: Step.Step,
82
- attempts: Schema.Array(Attempt.Attempt),
83
- repository: Repository.Name,
84
- task: AttemptChannel.Task,
85
- agent: Agent.Agent,
86
- }) {
87
- }
88
- /** Monotonic version of the durable operator projection. */
89
- export const ProjectionRevision = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("ProjectionRevision"));
90
- /** Input passed to the attempt-execution port. */
91
- export class StepExecution extends Schema.Class("@usine/engine/StepExecution")({
92
- attempt: Attempt.Attempt,
93
- event: Event.Event,
94
- run: Run.Run,
95
- step: Step.Step,
96
- repository: Repository.Name,
97
- revision: Repository.Revision,
98
- task: AttemptChannel.Task,
99
- agent: Agent.Agent,
100
- parentModel: Schema.Option(Agent.ModelId),
101
- }) {
102
- }
103
- /**
104
- * Value object: global append order of the persisted transcript — the tail
105
- * cursor. Distinct from `AttemptChannel.Sequence`, which orders messages
106
- * within one Attempt's channel direction.
107
- */
108
- export const TranscriptSequence = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("TranscriptSequence"));
109
- /** One append-only row in an Attempt transcript. */
110
- export class TranscriptEntry extends Schema.Class("@usine/engine/TranscriptEntry")({
111
- sequence: TranscriptSequence,
112
- attemptId: Attempt.AttemptId,
113
- direction: AttemptChannel.Direction,
114
- envelope: AttemptChannel.Envelope,
115
- receivedAt: Schema.DateTimeUtc,
116
- }) {
117
- }
118
- /** Read every row for one Attempt. Intended for execution and diagnostic consumers. */
119
- export class TranscriptAllQuery extends Schema.TaggedClass("@usine/engine/TranscriptAllQuery")("TranscriptAllQuery", { attemptId: Attempt.AttemptId }) {
120
- }
121
- /** Read rows appended after a cursor while tailing a live Attempt. */
122
- export class TranscriptTailQuery extends Schema.TaggedClass("@usine/engine/TranscriptTailQuery")("TranscriptTailQuery", {
123
- attemptId: Attempt.AttemptId,
124
- after: TranscriptSequence,
125
- limit: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
126
- }) {
127
- }
128
- /** Read the newest bounded page before a cursor, or from the current tail. */
129
- export class TranscriptPageQuery extends Schema.TaggedClass("@usine/engine/TranscriptPageQuery")("TranscriptPageQuery", {
130
- attemptId: Attempt.AttemptId,
131
- before: Schema.Option(TranscriptSequence),
132
- limit: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
133
- }) {
134
- }
135
- /** Illegal combinations of full, tail, and backward-page reads are unrepresentable. */
136
- export const TranscriptQuery = Schema.Union([
137
- TranscriptAllQuery,
138
- TranscriptTailQuery,
139
- TranscriptPageQuery,
140
- ]);
141
- export class RunNotFoundError extends Schema.TaggedError("@usine/engine/RunNotFoundError")("RunNotFoundError", {
142
- runId: Run.RunId,
143
- }) {
144
- }
145
- export class RunOperationRejectedError extends Schema.TaggedError("@usine/engine/RunOperationRejectedError")("RunOperationRejectedError", {
146
- runId: Run.RunId,
147
- operation: Schema.Literals(["approve", "retry"]),
148
- state: Schema.String,
149
- }) {
150
- }
151
- export class EnginePersistenceError extends Schema.TaggedError("@usine/engine/EnginePersistenceError")("EnginePersistenceError", {
152
- operation: Schema.String,
153
- cause: Schema.Defect(),
154
- }) {
155
- }
156
- export class AttemptCancellationError extends Schema.TaggedError("@usine/engine/AttemptCancellationError")("AttemptCancellationError", {
157
- attemptId: Attempt.AttemptId,
158
- cause: Schema.Defect(),
159
- }) {
160
- }
161
- /** Everything the store itself can fail with. */
162
- export const RunStoreError = Schema.Union([
163
- RunNotFoundError,
164
- RunOperationRejectedError,
165
- EnginePersistenceError,
166
- ]);
167
- /** The store's failures plus the engine-only cancellation handshake failure. */
168
- export const RunEngineError = Schema.Union([
169
- RunNotFoundError,
170
- RunOperationRejectedError,
171
- EnginePersistenceError,
172
- AttemptCancellationError,
173
- ]);
174
- //# sourceMappingURL=model.js.map
package/dist/model.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,OAAO,EACP,cAAc,EACd,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,GAAG,EACH,IAAI,GACL,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,qEAAqE;AACrE,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,CAAC;AAG5D,+DAA+D;AAC/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC;AAGpD,uFAAuF;AACvF,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,KAAK,CAChD,gCAAgC,CACjC,CAAC;IACA,IAAI,EAAE,IAAI,CAAC,QAAQ;IACnB,MAAM,EAAE,MAAM,CAAC,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WAAW,CAAC,mCAAmC,CAAC,CAAC;KAC5C,CAAC;AACb,CAAC,CAAC,CAAC;AAEH,MAAM,OAAO,+BAAgC,SAAQ,OAAO,CAAC,OAAO,EAOjE,CAAC,+CAA+C,CAAC;IAClD,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,+BAA+B,EAAE,UAAU,CAAC,CAAC;CACnF;AAED,MAAM,OAAO,+BAAgC,SAAQ,OAAO,CAAC,OAAO,EAQjE,CAAC,+CAA+C,CAAC;IAClD,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,+BAA+B,EAAE,UAAU,CAAC,CAAC;CACnF"}
@@ -1,20 +0,0 @@
1
- import { Context, Effect, Layer, Option } from "effect";
2
- import { Run } from "@usine/core";
3
- import { RunDatabase } from "./database/database.ts";
4
- import { ProjectionRevision, RunSnapshot, RunSummary, TranscriptEntry, TranscriptQuery, type RunStoreError } from "./model.ts";
5
- declare const RunReader_base: Context.ServiceClass<RunReader, "@usine/engine/RunReader", {
6
- readonly inspect: (runId: Run.RunId) => Effect.Effect<RunSnapshot, RunStoreError>;
7
- /** Every open Run plus the newest `closedLimit` settled ones, newest first. */
8
- readonly list: (options: {
9
- readonly closedLimit: number;
10
- }) => Effect.Effect<ReadonlyArray<RunSummary>, RunStoreError>;
11
- /** `None` means the invalidation singleton is absent: treat every cached projection as stale. */
12
- readonly revision: () => Effect.Effect<Option.Option<ProjectionRevision>, RunStoreError>;
13
- readonly transcript: (query: TranscriptQuery) => Effect.Effect<ReadonlyArray<TranscriptEntry>, RunStoreError>;
14
- }>;
15
- /** Read-only durable Run projection; safe to build while execution is idle. */
16
- export declare class RunReader extends RunReader_base {
17
- static readonly layer: Layer.Layer<RunReader, never, RunDatabase>;
18
- }
19
- export {};
20
- //# sourceMappingURL=run-reader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-reader.d.ts","sourceRoot":"","sources":["../src/run-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,eAAe,EACf,eAAe,EACf,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;;sBA2BE,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC;IACjF,+EAA+E;mBAChE,CAAC,OAAO,EAAE;QACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;KAC9B,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IAC7D,iGAAiG;uBAC9E,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,aAAa,CAAC;yBACnE,CACnB,KAAK,EAAE,eAAe,KACnB,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC;;AAbrE,+EAA+E;AAC/E,qBAAa,SAAU,SAAQ,cAcD;IAC5B,MAAM,CAAC,QAAQ,CAAC,KAAK,6CAA0C;CAChE"}
@@ -1,19 +0,0 @@
1
- import { Context, Effect, Layer, Option } from "effect";
2
- import { Run } from "@usine/core";
3
- import { RunDatabase } from "./database/database.js";
4
- import { ProjectionRevision, RunSnapshot, RunSummary, TranscriptEntry, TranscriptQuery, } from "./model.js";
5
- import { persistence } from "./store/codec.js";
6
- import { queriesFor } from "./store/queries.js";
7
- const makeRunReader = Effect.gen(function* () {
8
- const queries = queriesFor(yield* RunDatabase);
9
- const inspect = Effect.fn("RunReader.inspect")((runId) => queries.snapshot(runId).pipe(persistence("read run")));
10
- const list = Effect.fn("RunReader.list")((options) => queries.runSummaries(options.closedLimit).pipe(persistence("list runs")));
11
- const revision = Effect.fn("RunReader.revision")(() => queries.revision().pipe(persistence("read projection revision")));
12
- const transcript = Effect.fn("RunReader.transcript")((query) => queries.transcript(query).pipe(persistence("read Attempt transcript")));
13
- return { inspect, list, revision, transcript };
14
- });
15
- /** Read-only durable Run projection; safe to build while execution is idle. */
16
- export class RunReader extends Context.Service()("@usine/engine/RunReader") {
17
- static layer = Layer.effect(RunReader, makeRunReader);
18
- }
19
- //# sourceMappingURL=run-reader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-reader.js","sourceRoot":"","sources":["../src/run-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,eAAe,EACf,eAAe,GAEhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACxC,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAgB,EAAE,EAAE,CAClE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CACtD,CAAC;IACF,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAyC,EAAE,EAAE,CACrF,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CACzE,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,GAAG,EAAE,CACpD,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAAC,CACjE,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC,KAAsB,EAAE,EAAE,CAC9E,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC,CACvE,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAW,CAAC;AAC1D,CAAC,CAAC,CAAC;AAEH,+EAA+E;AAC/E,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAc3C,CAAC,yBAAyB,CAAC;IAC5B,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;CAChE"}
@@ -1,14 +0,0 @@
1
- import { AttemptFailure, Run, StepResult } from "@usine/core";
2
- import { Effect, Schema } from "effect";
3
- import { DurableDeferred, Workflow, WorkflowEngine } from "effect/unstable/workflow";
4
- import { StepExecutor } from "./step-executor.ts";
5
- import { RunStore } from "./store/store.ts";
6
- import { Submission, type RunStoreError } from "./model.ts";
7
- export declare const DurableRun: Workflow.Workflow<"@usine/engine/DurableRun", Schema.Struct<{
8
- readonly submission: typeof Submission;
9
- }>, typeof StepResult.StepResult, Schema.Union<readonly [typeof AttemptFailure.InfraFailure, typeof AttemptFailure.AgentFailure, typeof AttemptFailure.RunawayFailure]>>;
10
- export declare const ApprovalGate: DurableDeferred.DurableDeferred<Schema.Void, Schema.Never>;
11
- export declare const continueWithNewest: (store: RunStore["Service"], completedRunId: Run.RunId) => Effect.Effect<void, RunStoreError, WorkflowEngine.WorkflowEngine>;
12
- export declare const durableRunLayer: import("effect/Layer").Layer<never, never, RunStore | StepExecutor | WorkflowEngine.WorkflowEngine>;
13
- export declare const runIdFor: (submission: Submission) => Effect.Effect<string & import("effect/Brand").Brand<"RunId">, never, never>;
14
- //# sourceMappingURL=workflow.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAkB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAyB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAIL,UAAU,EACV,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAOpB,eAAO,MAAM,UAAU;;wKAKqB,CAAC;AAE7C,eAAO,MAAM,YAAY,4DAAqD,CAAC;AAiB/E,eAAO,MAAM,kBAAkB,EAAE,CAC/B,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,EAC1B,cAAc,EAAE,GAAG,CAAC,KAAK,KACtB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,cAAc,CAAC,cAAc,CAanE,CAAC;AAiFH,eAAO,MAAM,eAAe,qGAAwC,CAAC;AAErE,eAAO,MAAM,QAAQ,yGAEnB,CAAC"}
package/dist/workflow.js DELETED
@@ -1,105 +0,0 @@
1
- import { AttemptFailure, Run, StepResult } from "@usine/core";
2
- import { Effect, Option, Result, Schema } from "effect";
3
- import { DurableDeferred, Workflow, WorkflowEngine } from "effect/unstable/workflow";
4
- import { StepExecutor } from "./step-executor.js";
5
- import { AttemptRecoveryFailed, RunStore } from "./store/store.js";
6
- import { EnginePersistenceError, RunNotFoundError, RunOperationRejectedError, Submission, } from "./model.js";
7
- const WorkflowPayload = Schema.Struct({
8
- submission: Submission,
9
- });
10
- export const DurableRun = Workflow.make("@usine/engine/DurableRun", {
11
- payload: WorkflowPayload,
12
- success: StepResult.StepResult,
13
- error: AttemptFailure.AttemptFailure,
14
- idempotencyKey: ({ submission }) => submission.event.dedupKey,
15
- }).annotate(Workflow.SuspendOnFailure, true);
16
- export const ApprovalGate = DurableDeferred.make("@usine/engine/ApprovalGate");
17
- const asAttemptFailure = (effect) => Effect.catchTags(effect, {
18
- EnginePersistenceError: (error) => new AttemptFailure.InfraFailure({
19
- message: `Engine persistence failed during ${error.operation}`,
20
- cause: error,
21
- }),
22
- RunNotFoundError: (error) => Effect.die(error),
23
- RunOperationRejectedError: (error) => Effect.die(error),
24
- });
25
- const executionId = (submission) => DurableRun.executionId({ submission });
26
- export const continueWithNewest = Effect.fn("DurableRun.continueWithNewest")(function* (store, completedRunId) {
27
- const queued = yield* store.nextQueued(completedRunId);
28
- if (Option.isSome(queued)) {
29
- const nextExecutionId = yield* executionId(queued.value);
30
- const runId = Run.RunId.make(nextExecutionId);
31
- const claimed = yield* store.claimQueued(queued.value, runId);
32
- if (Option.isSome(claimed)) {
33
- yield* DurableRun.execute({ submission: claimed.value.submission }, { discard: true });
34
- }
35
- }
36
- yield* store.completeWorkflowCommand(completedRunId, "Continue");
37
- });
38
- const executeDurableRun = Effect.fn("DurableRun.execute")(function* ({ submission }, executionId) {
39
- const runId = Run.RunId.make(executionId);
40
- const store = yield* RunStore;
41
- const executor = yield* StepExecutor;
42
- if (submission.approval === "required") {
43
- yield* store.parkForApproval(runId).pipe(asAttemptFailure);
44
- yield* DurableDeferred.await(ApprovalGate);
45
- }
46
- while (true) {
47
- // The wait for a worker slot stays interruptible: a cancel must be able
48
- // to reach a run parked in `reserve` (its scheduler releases or reoffers
49
- // the slot in its own onInterrupt). Only after the lease exists does the
50
- // release obligation begin.
51
- const lease = yield* executor.reserve(submission);
52
- const attempted = yield* Effect.gen(function* () {
53
- const started = yield* store.beginAttempt(runId, lease.worker).pipe(asAttemptFailure);
54
- if (started instanceof AttemptRecoveryFailed || started._tag === "RunClosed") {
55
- return started;
56
- }
57
- // Port ACL: the executor's contract is the typed AttemptFailure channel.
58
- // A defect escaping the adapter is infrastructure breakage around the
59
- // agent, so it is translated before reaching the durable workflow.
60
- const result = yield* executor
61
- .execute(started.execution, {
62
- append: (direction, envelope) => store.appendTranscript(direction, envelope).pipe(asAttemptFailure),
63
- })
64
- .pipe(Effect.catchDefect((defect) => new AttemptFailure.InfraFailure({
65
- message: "The step executor crashed outside its typed failure channel",
66
- cause: defect,
67
- })), Effect.result);
68
- return { _tag: "AttemptExecuted", result, started };
69
- }).pipe(Effect.ensuring(lease.release));
70
- if (attempted._tag === "RunClosed") {
71
- // Canceled, superseded, or revoked while queued: release was the only
72
- // obligation; the closing operation already delivered the interrupt.
73
- yield* Effect.logInfo("Run closed while it waited for a worker", {
74
- runId,
75
- state: attempted.state,
76
- });
77
- yield* continueWithNewest(store, runId).pipe(asAttemptFailure);
78
- return yield* new AttemptFailure.AgentFailure({
79
- message: `The run closed (${attempted.state}) before an attempt started`,
80
- });
81
- }
82
- if (attempted instanceof AttemptRecoveryFailed) {
83
- yield* continueWithNewest(store, runId).pipe(asAttemptFailure);
84
- return yield* attempted.failure;
85
- }
86
- const { result, started } = attempted;
87
- if (Result.isSuccess(result)) {
88
- yield* store.succeedAttempt(started.execution.attempt, result.success).pipe(asAttemptFailure);
89
- yield* continueWithNewest(store, runId).pipe(asAttemptFailure);
90
- return result.success;
91
- }
92
- const retry = yield* store
93
- .failAttempt(started.execution.attempt, result.failure)
94
- .pipe(asAttemptFailure);
95
- if (!retry) {
96
- yield* continueWithNewest(store, runId).pipe(asAttemptFailure);
97
- return yield* result.failure;
98
- }
99
- }
100
- });
101
- export const durableRunLayer = DurableRun.toLayer(executeDurableRun);
102
- export const runIdFor = Effect.fn("DurableRun.runIdFor")(function* (submission) {
103
- return Run.RunId.make(yield* executionId(submission));
104
- });
105
- //# sourceMappingURL=workflow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,yBAAyB,EACzB,UAAU,GAEX,MAAM,YAAY,CAAC;AAEpB,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IACpC,UAAU,EAAE,UAAU;CACvB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,0BAA0B,EAAE;IAClE,OAAO,EAAE,eAAe;IACxB,OAAO,EAAE,UAAU,CAAC,UAAU;IAC9B,KAAK,EAAE,cAAc,CAAC,cAAc;IACpC,cAAc,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ;CAC9D,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;AAE/E,MAAM,gBAAgB,GAAG,CACvB,MAA0C,EACU,E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