@usine/engine 0.1.0 → 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 (150) hide show
  1. package/README.md +37 -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 +113 -14
  23. package/dist/database/local-sqlite.js.map +1 -1
  24. package/dist/database/schema.d.ts +254 -9
  25. package/dist/database/schema.d.ts.map +1 -1
  26. package/dist/database/schema.js +65 -12
  27. package/dist/database/schema.js.map +1 -1
  28. package/dist/engine/engine.d.ts +55 -0
  29. package/dist/engine/engine.d.ts.map +1 -0
  30. package/dist/{engine.js → engine/engine.js} +44 -30
  31. package/dist/engine/engine.js.map +1 -0
  32. package/dist/engine/error.d.ts +37 -0
  33. package/dist/engine/error.d.ts.map +1 -0
  34. package/dist/engine/error.js +41 -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 +34 -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 +104 -40
  85. package/dist/store/codec.d.ts.map +1 -1
  86. package/dist/store/codec.js +66 -44
  87. package/dist/store/codec.js.map +1 -1
  88. package/dist/store/queries.d.ts +47 -15
  89. package/dist/store/queries.d.ts.map +1 -1
  90. package/dist/store/queries.js +74 -39
  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 +185 -127
  95. package/dist/store/store.js.map +1 -1
  96. package/dist/transcript.d.ts +64 -0
  97. package/dist/transcript.d.ts.map +1 -0
  98. package/dist/transcript.js +59 -0
  99. package/dist/transcript.js.map +1 -0
  100. package/dist/workflow/admission.d.ts +13 -0
  101. package/dist/workflow/admission.d.ts.map +1 -0
  102. package/dist/workflow/admission.js +55 -0
  103. package/dist/workflow/admission.js.map +1 -0
  104. package/dist/workflow/command.d.ts +13 -0
  105. package/dist/workflow/command.d.ts.map +1 -0
  106. package/dist/workflow/command.js +17 -0
  107. package/dist/workflow/command.js.map +1 -0
  108. package/dist/workflow/workflow.d.ts +18 -0
  109. package/dist/workflow/workflow.d.ts.map +1 -0
  110. package/dist/workflow/workflow.js +108 -0
  111. package/dist/workflow/workflow.js.map +1 -0
  112. package/drizzle/20260903091940_queued_approved_runs/migration.sql +3 -0
  113. package/drizzle/20260903091940_queued_approved_runs/snapshot.json +1147 -0
  114. package/drizzle/20260905150403_item_cycle_budgets/migration.sql +58 -0
  115. package/drizzle/20260905150403_item_cycle_budgets/snapshot.json +1417 -0
  116. package/drizzle/20260905174009_item_run_history/migration.sql +1 -0
  117. package/drizzle/20260905174009_item_run_history/snapshot.json +1431 -0
  118. package/package.json +41 -5
  119. package/dist/cursor/model.d.ts +0 -5
  120. package/dist/cursor/model.d.ts.map +0 -1
  121. package/dist/cursor/model.js +0 -4
  122. package/dist/cursor/model.js.map +0 -1
  123. package/dist/cursor/store.d.ts.map +0 -1
  124. package/dist/cursor/store.js.map +0 -1
  125. package/dist/engine.d.ts +0 -39
  126. package/dist/engine.d.ts.map +0 -1
  127. package/dist/engine.js.map +0 -1
  128. package/dist/index.d.ts +0 -20
  129. package/dist/index.d.ts.map +0 -1
  130. package/dist/index.js +0 -20
  131. package/dist/index.js.map +0 -1
  132. package/dist/item-projection/service.d.ts.map +0 -1
  133. package/dist/item-projection/service.js.map +0 -1
  134. package/dist/loop-control.d.ts +0 -16
  135. package/dist/loop-control.d.ts.map +0 -1
  136. package/dist/loop-control.js.map +0 -1
  137. package/dist/model.d.ts +0 -185
  138. package/dist/model.d.ts.map +0 -1
  139. package/dist/model.js +0 -174
  140. package/dist/model.js.map +0 -1
  141. package/dist/repository-label-projection/service.d.ts.map +0 -1
  142. package/dist/repository-label-projection/service.js.map +0 -1
  143. package/dist/run-reader.d.ts +0 -20
  144. package/dist/run-reader.d.ts.map +0 -1
  145. package/dist/run-reader.js +0 -19
  146. package/dist/run-reader.js.map +0 -1
  147. package/dist/workflow.d.ts +0 -14
  148. package/dist/workflow.d.ts.map +0 -1
  149. package/dist/workflow.js +0 -105
  150. package/dist/workflow.js.map +0 -1
@@ -0,0 +1,132 @@
1
+ import { Attempt, AttemptId, AttemptNumber, shouldAutoRetry } from "@usine/core/attempt";
2
+ import { AttemptFailure, InfraFailure } from "@usine/core/attempt/failure";
3
+ import { AttemptCanceled, AttemptFailed, AttemptSucceeded } from "@usine/core/attempt/outcome";
4
+ import { EventId } from "@usine/core/event";
5
+ import { Run, RunId } from "@usine/core/run";
6
+ import * as RunState from "@usine/core/run/state";
7
+ import { StepResult } from "@usine/core/step/result";
8
+ import { Option, Result } from "effect";
9
+ // Engine policy, not a limit imposed on consumers of the core Attempt model.
10
+ const MAX_AUTO_ATTEMPTS = AttemptNumber.make(3);
11
+ const openAttempt = (current) => Option.fromNullishOr(current.attempts.at(-1)).pipe(Option.filter((attempt) => Option.isNone(attempt.outcome)));
12
+ const failRunningAttempt = (state, attempt, failure, policy) => {
13
+ const outcome = new AttemptFailed({ failure });
14
+ if (policy === "Execution" &&
15
+ shouldAutoRetry({ failure, number: attempt.number, maxAutoAttempts: MAX_AUTO_ATTEMPTS })) {
16
+ return { _tag: "RetryAttempt", attempt, outcome };
17
+ }
18
+ return { _tag: "RunFailed", attempt, outcome, state: RunState.fail(state) };
19
+ };
20
+ const finish = (current, attemptId, result, policy) => {
21
+ if (current.run.state._tag !== "Running") {
22
+ return { _tag: "Unchanged", reason: "RunNotRunning" };
23
+ }
24
+ const attempt = openAttempt(current);
25
+ if (Option.isNone(attempt))
26
+ return { _tag: "Unchanged", reason: "NoOpenAttempt" };
27
+ // A completion from before restart or operator retry cannot settle the
28
+ // replacement Attempt, even though the Run is Running again.
29
+ if (attempt.value.id !== attemptId)
30
+ return { _tag: "Unchanged", reason: "AttemptReplaced" };
31
+ if (Result.isFailure(result)) {
32
+ return failRunningAttempt(current.run.state, attempt.value, result.failure, policy);
33
+ }
34
+ return {
35
+ _tag: "RunSucceeded",
36
+ attempt: attempt.value,
37
+ outcome: new AttemptSucceeded(),
38
+ state: RunState.succeed(current.run.state),
39
+ result: result.success,
40
+ };
41
+ };
42
+ /**
43
+ * Settles the current Attempt from its executor result. Infrastructure failure
44
+ * can retry up to three total Attempts; a late or repeated completion changes nothing.
45
+ */
46
+ export const finishAttempt = (current, attemptId, result) => finish(current, attemptId, result, "Execution");
47
+ /**
48
+ * Repairs an open Attempt from a final durable result. The workflow has already
49
+ * ended, so even an infrastructure failure closes the Run without auto-retry.
50
+ * The runtime must first translate its completion into a typed result; defects
51
+ * and suspension are not Attempt outcomes here (ADRs 0003 and 0010).
52
+ */
53
+ export const reconcileAttempt = (current, result) => {
54
+ const attempt = openAttempt(current);
55
+ return Option.isNone(attempt)
56
+ ? { _tag: "Unchanged", reason: "NoOpenAttempt" }
57
+ : finish(current, attempt.value.id, result, "FinalReconciliation");
58
+ };
59
+ /**
60
+ * Admits the next Attempt after a Worker reservation. An unfinished previous
61
+ * Attempt indicates a restart and counts against the same retry cap as ordinary
62
+ * infrastructure failure. `interruption` records the runtime's explanation.
63
+ * The caller creates the new Attempt's identity and timestamp only when admitted.
64
+ */
65
+ export const beginAttempt = (current, interruption) => {
66
+ const state = current.run.state;
67
+ if (!RunState.isStartable(state) && state._tag !== "Running") {
68
+ return { _tag: "RunClosed", state };
69
+ }
70
+ let interrupted = Option.none();
71
+ const attempt = openAttempt(current);
72
+ if (state._tag === "Running" && Option.isSome(attempt)) {
73
+ const recovery = failRunningAttempt(state, attempt.value, interruption, "Execution");
74
+ if (recovery._tag === "RunFailed")
75
+ return recovery;
76
+ interrupted = Option.some(recovery);
77
+ }
78
+ return {
79
+ _tag: "StartAttempt",
80
+ state: state._tag === "Running" ? state : RunState.start(state),
81
+ number: AttemptNumber.make((current.attempts.at(-1)?.number ?? 0) + 1),
82
+ interrupted,
83
+ };
84
+ };
85
+ /**
86
+ * Cancels open work and, if executing, its unfinished Attempt. A Run awaiting
87
+ * capacity may have no Attempt, or only the closed Attempt preceding a retry.
88
+ */
89
+ export const cancelRun = (current) => {
90
+ if (!RunState.isOpen(current.run.state))
91
+ return { _tag: "AlreadyClosed" };
92
+ return {
93
+ _tag: "Canceled",
94
+ state: RunState.cancelByOperator(current.run.state),
95
+ attempt: current.run.state._tag === "Running"
96
+ ? Option.map(openAttempt(current), (attempt) => ({
97
+ id: attempt.id,
98
+ outcome: new AttemptCanceled(),
99
+ }))
100
+ : Option.none(),
101
+ };
102
+ };
103
+ /**
104
+ * Reopens a failed Run for operator retry regardless of its Attempt count.
105
+ * Repeating the request is accepted while its Resume command remains pending;
106
+ * after delivery, retrying a Running Run is rejected.
107
+ */
108
+ export const retryRun = (state, pendingCommands) => {
109
+ if (state._tag === "Failed")
110
+ return { _tag: "Resume", state: RunState.retry(state) };
111
+ if (state._tag === "Running" && pendingCommands.includes("Resume")) {
112
+ return { _tag: "ResumePending" };
113
+ }
114
+ return { _tag: "RetryRejected" };
115
+ };
116
+ /**
117
+ * Places a previously unclaimed Event behind its Item's running work, or
118
+ * replaces unstarted work. The ledger must resolve permanent deduplication and
119
+ * ignored Events before this decision; running Attempts always finish (ADR 0007).
120
+ */
121
+ export const claimRun = (blocking, eventId) => {
122
+ if (Option.isNone(blocking))
123
+ return { _tag: "OpenRun" };
124
+ const run = blocking.value;
125
+ if (run.state._tag === "Running")
126
+ return { _tag: "QueueEvent" };
127
+ if (RunState.isUnstarted(run.state)) {
128
+ return { _tag: "SupersedeRun", runId: run.id, state: RunState.supersede(run.state, eventId) };
129
+ }
130
+ return { _tag: "OpenRun" };
131
+ };
132
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/engine/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM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CAAC,MAAM,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IACxD,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC3B,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAChE,IAAI,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;IAChG,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Context, Deferred } from "effect";
2
+ declare const RunEngineShutdown_base: Context.ServiceClass<RunEngineShutdown, "@usine/engine/RunEngineShutdown", Deferred.Deferred<void, never>>;
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).
8
+ */
9
+ export declare class RunEngineShutdown extends RunEngineShutdown_base {
10
+ }
11
+ export {};
12
+ //# sourceMappingURL=shutdown.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,10 @@
1
+ import { Context, Deferred } from "effect";
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).
7
+ */
8
+ export class RunEngineShutdown extends Context.Service()("@usine/engine/RunEngineShutdown") {
9
+ }
10
+ //# sourceMappingURL=shutdown.js.map
@@ -0,0 +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"}
@@ -0,0 +1,58 @@
1
+ import { Agent } from "@usine/core/agent";
2
+ import { CycleBudgetAsk } from "@usine/core/cycle-budget";
3
+ import { Event } from "@usine/core/event";
4
+ import { Schema } from "effect";
5
+ declare const Submission_base: Schema.Class<Submission, Schema.Struct<{
6
+ readonly event: typeof Event;
7
+ readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
8
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
9
+ readonly step: Schema.brand<Schema.NonEmptyString, "StepName">;
10
+ readonly approval: Schema.Literals<readonly ["none", "required"]>;
11
+ /** Item Runs default to three rounds; schedule adapters explicitly supply None. */
12
+ readonly cycleLimit: Schema.withConstructorDefault<Schema.withDecodingDefaultTypeKey<Schema.Option<Schema.brand<Schema.Int, "CycleLimit">>, never>>;
13
+ /** Capture before fetching trigger input. A reset supersedes older observations. */
14
+ readonly cycleGeneration: Schema.withConstructorDefault<Schema.withDecodingDefaultKey<Schema.brand<Schema.Int, "CycleGeneration">, never>>;
15
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
16
+ readonly revision: Schema.brand<Schema.String, "RepositoryRevision">;
17
+ readonly task: Schema.brand<Schema.String, "AttemptTask">;
18
+ readonly agent: typeof Agent;
19
+ readonly parentModel: Schema.Option<Schema.brand<Schema.String, "ModelId">>;
20
+ }>, {}>;
21
+ /** A matched Event with the Loop, Item, and execution choices that determine the work owed. */
22
+ export declare class Submission extends Submission_base {
23
+ }
24
+ declare const Claimed_base: Schema.Class<Claimed, Schema.TaggedStruct<"Claimed", {
25
+ readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
26
+ readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
27
+ }>, {}>;
28
+ /** The Event now owns a Run; submitting it again returns the same run id. */
29
+ export declare class Claimed extends Claimed_base {
30
+ }
31
+ declare const Queued_base: Schema.Class<Queued, Schema.TaggedStruct<"Queued", {
32
+ readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
33
+ }>, {}>;
34
+ /** A running Attempt on the same Item must finish before this Event is reconsidered. */
35
+ export declare class Queued extends Queued_base {
36
+ }
37
+ export declare const IGNORED_REASONS: readonly ["superseded", "revoked"];
38
+ export declare const IgnoreReason: Schema.Literals<readonly ["superseded", "revoked"]>;
39
+ export type IgnoreReason = typeof IgnoreReason.Type;
40
+ declare const Ignored_base: Schema.Class<Ignored, Schema.TaggedStruct<"Ignored", {
41
+ readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
42
+ readonly reason: Schema.Literals<readonly ["superseded", "revoked"]>;
43
+ }>, {}>;
44
+ /** The Event stays in the ledger but can no longer open a Run. */
45
+ export declare class Ignored extends Ignored_base {
46
+ }
47
+ declare const CycleBlocked_base: Schema.Class<CycleBlocked, Schema.TaggedStruct<"CycleBlocked", {
48
+ readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
49
+ readonly ask: typeof CycleBudgetAsk;
50
+ }>, {}>;
51
+ /** No Run opened because this Item requires an explicit cycle-budget reset. */
52
+ export declare class CycleBlocked extends CycleBlocked_base {
53
+ }
54
+ /** Whether a recorded Event owns a Run, waits behind running work, or can no longer open a Run. */
55
+ export declare const SubmissionResult: Schema.Union<readonly [typeof Claimed, typeof Queued, typeof Ignored, typeof CycleBlocked]>;
56
+ export type SubmissionResult = typeof SubmissionResult.Type;
57
+ export {};
58
+ //# sourceMappingURL=submission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submission.d.ts","sourceRoot":"","sources":["../../src/engine/submission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EACL,cAAc,EAIf,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,KAAK,EAAW,MAAM,mBAAmB,CAAC;AAMnD,OAAO,EAAkB,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;;IAS9C,mFAAmF;;IAKnF,oFAAoF;;;;;;;;AAZtF,+FAA+F;AAC/F,qBAAa,UAAW,SAAQ,eAqB9B;CAAG;;;;;AAEL,6EAA6E;AAC7E,qBAAa,OAAQ,SAAQ,YAG3B;CAAG;;;;AAEL,wFAAwF;AACxF,qBAAa,MAAO,SAAQ,WAE1B;CAAG;AAEL,eAAO,MAAM,eAAe,YAAI,YAAY,EAAE,SAAS,CAAU,CAAC;AAElE,eAAO,MAAM,YAAY,qDAAmC,CAAC;AAE7D,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;;;;;AAEpD,kEAAkE;AAClE,qBAAa,OAAQ,SAAQ,YAG3B;CAAG;;;;;AAEL,+EAA+E;AAC/E,qBAAa,YAAa,SAAQ,iBAGjC;CAAG;AAEJ,mGAAmG;AACnG,eAAO,MAAM,gBAAgB,6FAAyD,CAAC;AAEvF,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { Agent } from "@usine/core/agent";
2
+ import { CycleBudgetAsk, CycleGeneration, CycleLimit, DEFAULT_CYCLE_LIMIT, } from "@usine/core/cycle-budget";
3
+ import { ModelId } from "@usine/core/agent/brain";
4
+ import { AttemptTask } from "@usine/core/attempt";
5
+ import { Event, EventId } from "@usine/core/event";
6
+ import { ItemKey } from "@usine/core/item";
7
+ import { LoopName, ApprovalRequirement } 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 { Effect, Option, Schema } from "effect";
12
+ /** A matched Event with the Loop, Item, and execution choices that determine the work owed. */
13
+ export class Submission extends Schema.Class("@usine/engine/Submission")({
14
+ event: Event,
15
+ itemKey: ItemKey,
16
+ loop: LoopName,
17
+ step: StepName,
18
+ approval: ApprovalRequirement,
19
+ /** Item Runs default to three rounds; schedule adapters explicitly supply None. */
20
+ cycleLimit: Schema.Option(CycleLimit).pipe(Schema.withDecodingDefaultTypeKey(Effect.succeed(Option.some(DEFAULT_CYCLE_LIMIT))), Schema.withConstructorDefault(Effect.succeed(Option.some(DEFAULT_CYCLE_LIMIT)))),
21
+ /** Capture before fetching trigger input. A reset supersedes older observations. */
22
+ cycleGeneration: CycleGeneration.pipe(Schema.withDecodingDefaultKey(Effect.succeed(CycleGeneration.make(0))), Schema.withConstructorDefault(Effect.succeed(CycleGeneration.make(0)))),
23
+ repository: RepositoryName,
24
+ revision: RepositoryRevision,
25
+ task: AttemptTask,
26
+ agent: Agent,
27
+ parentModel: Schema.Option(ModelId),
28
+ }) {
29
+ }
30
+ /** The Event now owns a Run; submitting it again returns the same run id. */
31
+ export class Claimed extends Schema.TaggedClass("@usine/engine/Claimed")("Claimed", {
32
+ eventId: EventId,
33
+ runId: RunId,
34
+ }) {
35
+ }
36
+ /** A running Attempt on the same Item must finish before this Event is reconsidered. */
37
+ export class Queued extends Schema.TaggedClass("@usine/engine/Queued")("Queued", {
38
+ eventId: EventId,
39
+ }) {
40
+ }
41
+ export const IGNORED_REASONS = ["superseded", "revoked"];
42
+ export const IgnoreReason = Schema.Literals(IGNORED_REASONS);
43
+ /** The Event stays in the ledger but can no longer open a Run. */
44
+ export class Ignored extends Schema.TaggedClass("@usine/engine/Ignored")("Ignored", {
45
+ eventId: EventId,
46
+ reason: IgnoreReason,
47
+ }) {
48
+ }
49
+ /** No Run opened because this Item requires an explicit cycle-budget reset. */
50
+ export class CycleBlocked extends Schema.TaggedClass("@usine/engine/CycleBlocked")("CycleBlocked", { eventId: EventId, ask: CycleBudgetAsk }) {
51
+ }
52
+ /** Whether a recorded Event owns a Run, waits behind running work, or can no longer open a Run. */
53
+ export const SubmissionResult = Schema.Union([Claimed, Queued, Ignored, CycleBlocked]);
54
+ //# sourceMappingURL=submission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submission.js","sourceRoot":"","sources":["../../src/engine/submission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EACL,cAAc,EACd,eAAe,EACf,UAAU,EACV,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhD,+FAA+F;AAC/F,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,KAAK,CAAa,0BAA0B,CAAC,CAAC;IACnF,KAAK,EAAE,KAAK;IACZ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AM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAI7D,kEAAkE;AAClE,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,CAAU,uBAAuB,CAAC,CAAC,SAAS,EAAE;IAC3F,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,YAAY;CACrB,CAAC;CAAG;AAEL,+EAA+E;AAC/E,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,CAAe,4BAA4B,CAAC,CAC9F,cAAc,EACd,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAC1C;CAAG;AAEJ,mGAAmG;AACnG,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC"}
@@ -1,15 +1,15 @@
1
- import { Repository } from "@usine/core";
1
+ import { RepositoryName } from "@usine/core/repository";
2
2
  import { Context, Effect, Layer } from "effect";
3
3
  import { RunDatabase } from "../database/database.ts";
4
- import { EnginePersistenceError } from "../model.ts";
4
+ import { EnginePersistenceError } from "../engine/error.ts";
5
5
  import { ItemProjection } from "./model.ts";
6
- /** Newest Items first; the bound keeps a long-lived repository's Board response finite. */
6
+ /** Newest Items first. The bound keeps a long-lived repository's Board response finite. */
7
7
  export interface ItemProjectionListOptions {
8
8
  readonly limit: number;
9
9
  }
10
10
  declare const ItemProjectionReader_base: Context.ServiceClass<ItemProjectionReader, "@usine/engine/ItemProjectionReader", {
11
11
  /** The newest `limit` Item projections of one repository, highest number first. */
12
- readonly list: (repository: Repository.Name, options: ItemProjectionListOptions) => Effect.Effect<ReadonlyArray<ItemProjection>, EnginePersistenceError>;
12
+ readonly list: (repository: RepositoryName, options: ItemProjectionListOptions) => Effect.Effect<ReadonlyArray<ItemProjection>, EnginePersistenceError>;
13
13
  }>;
14
14
  export declare class ItemProjectionReader extends ItemProjectionReader_base {
15
15
  static readonly layer: Layer.Layer<ItemProjectionReader, never, RunDatabase>;
@@ -21,5 +21,5 @@ declare const ItemProjectionWriter_base: Context.ServiceClass<ItemProjectionWrit
21
21
  export declare class ItemProjectionWriter extends ItemProjectionWriter_base {
22
22
  static readonly layer: Layer.Layer<ItemProjectionWriter, never, RunDatabase>;
23
23
  }
24
- export {};
25
- //# sourceMappingURL=service.d.ts.map
24
+ export { ItemContentHash, ItemProjection, ItemProjectionSource } from "./model.ts";
25
+ //# sourceMappingURL=item-projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-projection.d.ts","sourceRoot":"","sources":["../../src/item-projection/item-projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAU,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAmB,cAAc,EAAwB,MAAM,YAAY,CAAC;AAmBnF,2FAA2F;AAC3F,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;;IAqFG,mFAAmF;mBACpE,CACb,UAAU,EAAE,cAAc,EAC1B,OAAO,EAAE,yBAAyB,KAC/B,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,sBAAsB,CAAC;;AAP7E,qBAAa,oBAAqB,SAAQ,yBASD;IACvC,MAAM,CAAC,QAAQ,CAAC,KAAK,wDAAkD;CACxE;;IAKG,mDAAmD;qBAClC,CAAC,IAAI,EAAE,cAAc,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,sBAAsB,CAAC;;AAJ7F,qBAAa,oBAAqB,SAAQ,yBAMD;IACvC,MAAM,CAAC,QAAQ,CAAC,KAAK,wDAAkD;CACxE;AAED,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,13 +1,14 @@
1
- import { Repository } from "@usine/core";
1
+ import { RepositoryName } from "@usine/core/repository";
2
2
  import { desc, eq, ne } from "drizzle-orm";
3
3
  import { Context, Effect, Layer, Schema } from "effect";
4
4
  import { RunDatabase } from "../database/database.js";
5
5
  import { itemProjections } from "../database/schema.js";
6
- import { EnginePersistenceError } from "../model.js";
7
- import { ItemContentHash, ItemNumber, ItemProjection, ItemProjectionSource } from "./model.js";
6
+ import { EnginePersistenceError } from "../engine/error.js";
7
+ import { ItemNumber } from "@usine/core/item";
8
+ import { ItemContentHash, ItemProjection, ItemProjectionSource } from "./model.js";
8
9
  const ItemProjectionRow = Schema.Struct({
9
10
  itemKey: ItemProjection.fields.itemKey,
10
- repository: Repository.Name,
11
+ repository: RepositoryName,
11
12
  source: ItemProjectionSource,
12
13
  number: ItemNumber,
13
14
  contentHash: ItemContentHash,
@@ -95,4 +96,5 @@ export class ItemProjectionReader extends Context.Service()("@usine/engine/ItemP
95
96
  export class ItemProjectionWriter extends Context.Service()("@usine/engine/ItemProjectionWriter") {
96
97
  static layer = Layer.effect(ItemProjectionWriter, makeWriter);
97
98
  }
98
- //# sourceMappingURL=service.js.map
99
+ export { ItemContentHash, ItemProjection, ItemProjectionSource } from "./model.js";
100
+ //# sourceMappingURL=item-projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-projection.js","sourceRoot":"","sources":["../../src/item-projection/item-projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,M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gBAC3B,IAAI,EAAE,IAAI,CAAC,MAAM;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,WAAW,EAAE,IAAI,CAAC,WAAW;aAC9B,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,WAAW,CAAC,uBAAuB,CAAC,CAAC;KAChC,CAAC;AACb,CAAC,CAAC,CAAC;AAEH,MAAM,OAAO,oBAAqB,SAAQ,OAAO,CAAC,OAAO,EAStD,CAAC,oCAAoC,CAAC;IACvC,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC;CACxE;AAED,MAAM,OAAO,oBAAqB,SAAQ,OAAO,CAAC,OAAO,EAMtD,CAAC,oCAAoC,CAAC;IACvC,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC;CACxE;AAED,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,20 +1,17 @@
1
- import { Item } from "@usine/core";
2
1
  import { Schema } from "effect";
3
2
  export declare const ItemProjectionSource: Schema.brand<Schema.NonEmptyString, "ItemProjectionSource">;
4
3
  export type ItemProjectionSource = typeof ItemProjectionSource.Type;
5
- export declare const ItemNumber: Schema.brand<Schema.Int, "ItemNumber">;
6
- export type ItemNumber = Item.Number;
7
4
  export declare const ItemContentHash: Schema.brand<Schema.NonEmptyString, "ItemContentHash">;
8
5
  export type ItemContentHash = typeof ItemContentHash.Type;
9
6
  declare const ItemProjection_base: Schema.Class<ItemProjection, Schema.Struct<{
10
7
  readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
11
- readonly repository: Schema.brand<Schema.String, "RepoName">;
8
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
12
9
  readonly source: Schema.brand<Schema.NonEmptyString, "ItemProjectionSource">;
13
10
  readonly number: Schema.brand<Schema.Int, "ItemNumber">;
14
11
  readonly contentHash: Schema.brand<Schema.NonEmptyString, "ItemContentHash">;
15
12
  readonly payload: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
16
13
  }>, {}>;
17
- /** Latest trigger-observed payload for one Item, independent of its source adapter. */
14
+ /** The latest payload a trigger observed for one Item, whatever the source adapter. */
18
15
  export declare class ItemProjection extends ItemProjection_base {
19
16
  }
20
17
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/item-projection/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,oBAAoB,6DAEhC,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAC;AAEpE,eAAO,MAAM,UAAU,wCAAc,CAAC;AACtC,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;AAErC,eAAO,MAAM,eAAe,wDAA8D,CAAC;AAC3F,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;;;;;;;;;AAE1D,uFAAuF;AACvF,qBAAa,cAAe,SAAQ,mBAOlC;CAAG"}
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/item-projection/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,oBAAoB,6DAEhC,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAC;AAEpE,eAAO,MAAM,eAAe,wDAA8D,CAAC;AAC3F,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;;;;;;;;;AAE1D,uFAAuF;AACvF,qBAAa,cAAe,SAAQ,mBAOlC;CAAG"}
@@ -1,12 +1,12 @@
1
- import { Item, Repository } from "@usine/core";
1
+ import { ItemKey, ItemNumber } from "@usine/core/item";
2
+ import { RepositoryName } from "@usine/core/repository";
2
3
  import { Schema } from "effect";
3
4
  export const ItemProjectionSource = Schema.NonEmptyString.pipe(Schema.brand("ItemProjectionSource"));
4
- export const ItemNumber = Item.Number;
5
5
  export const ItemContentHash = Schema.NonEmptyString.pipe(Schema.brand("ItemContentHash"));
6
- /** Latest trigger-observed payload for one Item, independent of its source adapter. */
6
+ /** The latest payload a trigger observed for one Item, whatever the source adapter. */
7
7
  export class ItemProjection extends Schema.Class("@usine/engine/ItemProjection")({
8
- itemKey: Item.ItemKey,
9
- repository: Repository.Name,
8
+ itemKey: ItemKey,
9
+ repository: RepositoryName,
10
10
  source: ItemProjectionSource,
11
11
  number: ItemNumber,
12
12
  contentHash: ItemContentHash,
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/item-projection/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAC5D,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CACrC,CAAC;AAGF,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;AAGtC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAG3F,uFAAuF;AACvF,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,KAAK,CAAiB,8BAA8B,CAAC,CAAC;IAC/F,OAAO,EAAE,IAAI,CAAC,OAAO;IACrB,UAAU,EAAE,UAAU,CAAC,IAAI;IAC3B,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,UAAU;IAClB,WAAW,EAAE,eAAe;IAC5B,OAAO,EAAE,MAAM,CAAC,UAAU;CAC3B,CAAC;CAAG"}
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/item-projection/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAC5D,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CACrC,CAAC;AAGF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;AAG3F,uFAAuF;AACvF,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,KAAK,CAAiB,8BAA8B,CAAC,CAAC;IAC/F,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,cAAc;IAC1B,MAAM,EAAE,oBAAoB;IAC5B,MAAM,EAAE,UAAU;IAClB,WAAW,EAAE,eAAe;IAC5B,OAAO,EAAE,MAAM,CAAC,UAAU;CAC3B,CAAC;CAAG"}
@@ -0,0 +1,21 @@
1
+ import { LoopName } from "@usine/core/loop";
2
+ import { Context, Effect, Layer } from "effect";
3
+ import { RunDatabase } from "../database/database.ts";
4
+ import { EnginePersistenceError } from "../engine/error.ts";
5
+ import { LoopRuntimeState } from "./model.ts";
6
+ declare const LoopControl_base: Context.ServiceClass<LoopControl, "@usine/engine/LoopControl", {
7
+ /** Whether new Runs are paused; a Loop with no recorded runtime state is unpaused. */
8
+ readonly isPaused: (loop: LoopName) => Effect.Effect<boolean, EnginePersistenceError>;
9
+ /** Pauses new trigger work for this Loop without stopping its existing Runs. */
10
+ readonly pause: (loop: LoopName) => Effect.Effect<LoopRuntimeState, EnginePersistenceError>;
11
+ /** Recorded runtime states ordered by Loop name; Loops without stored state are omitted. */
12
+ readonly states: Effect.Effect<ReadonlyArray<LoopRuntimeState>, EnginePersistenceError>;
13
+ /** Allows triggers to open new Runs for this Loop again. */
14
+ readonly unpause: (loop: LoopName) => Effect.Effect<LoopRuntimeState, EnginePersistenceError>;
15
+ }>;
16
+ /** Records whether triggers may open new Runs for each Loop; existing Runs and authored files stay unchanged. */
17
+ export declare class LoopControl extends LoopControl_base {
18
+ static readonly layer: Layer.Layer<LoopControl, never, RunDatabase>;
19
+ }
20
+ export { LoopRuntimeState } from "./model.ts";
21
+ //# sourceMappingURL=loop-control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop-control.d.ts","sourceRoot":"","sources":["../../src/loop-control/loop-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;;IA6E1C,sFAAsF;uBACnE,CAAC,IAAI,EAAE,QAAQ,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACrF,gFAAgF;oBAChE,CAAC,IAAI,EAAE,QAAQ,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;IAC3F,4FAA4F;qBAC3E,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IACvF,4DAA4D;sBAC1C,CAAC,IAAI,EAAE,QAAQ,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,sBAAsB,CAAC;;AAXjG,iHAAiH;AACjH,qBAAa,WAAY,SAAQ,gBAYD;IAC9B,MAAM,CAAC,QAAQ,CAAC,KAAK,+CAA8C;CACpE;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
@@ -1,9 +1,10 @@
1
- import { Loop } from "@usine/core";
1
+ import { LoopName } from "@usine/core/loop";
2
2
  import { asc, eq } from "drizzle-orm";
3
3
  import { Context, Effect, Layer } from "effect";
4
- import { RunDatabase } from "./database/database.js";
5
- import { loopRuntime } from "./database/schema.js";
6
- import { EnginePersistenceError, LoopRuntimeState } from "./model.js";
4
+ import { RunDatabase } from "../database/database.js";
5
+ import { loopRuntime } from "../database/schema.js";
6
+ import { EnginePersistenceError } from "../engine/error.js";
7
+ import { LoopRuntimeState } from "./model.js";
7
8
  const persistence = (operation) => (effect) => effect.pipe(Effect.mapError((cause) => new EnginePersistenceError({ operation, cause })));
8
9
  const makeLoopControl = Effect.gen(function* () {
9
10
  const database = yield* RunDatabase;
@@ -62,8 +63,9 @@ const makeLoopControl = Effect.gen(function* () {
62
63
  unpause: Effect.fn("LoopControl.unpause")((loop) => write(new LoopRuntimeState({ loop, paused: false }))),
63
64
  };
64
65
  });
65
- /** Durable operator control over Loop runtime state. It never edits the instance repo. */
66
+ /** Records whether triggers may open new Runs for each Loop; existing Runs and authored files stay unchanged. */
66
67
  export class LoopControl extends Context.Service()("@usine/engine/LoopControl") {
67
68
  static layer = Layer.effect(LoopControl, makeLoopControl);
68
69
  }
70
+ export { LoopRuntimeState } from "./model.js";
69
71
  //# sourceMappingURL=loop-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop-control.js","sourceRoot":"","sources":["../../src/loop-control/loop-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO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AAC,CAAC,CAAC;AAEH,iHAAiH;AACjH,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAY7C,CAAC,2BAA2B,CAAC;IAC9B,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;CACpE;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Schema } from "effect";
2
+ declare const LoopRuntimeState_base: Schema.Class<LoopRuntimeState, Schema.Struct<{
3
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
4
+ readonly paused: Schema.Boolean;
5
+ }>, {}>;
6
+ /** Runtime state for one Loop. Authored loop files never carry this toggle. */
7
+ export declare class LoopRuntimeState extends LoopRuntimeState_base {
8
+ }
9
+ export {};
10
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/loop-control/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;AAEhC,+EAA+E;AAC/E,qBAAa,gBAAiB,SAAQ,qBAKpC;CAAG"}
@@ -0,0 +1,9 @@
1
+ import { LoopName } from "@usine/core/loop";
2
+ import { Schema } from "effect";
3
+ /** Runtime state for one Loop. Authored loop files never carry this toggle. */
4
+ export class LoopRuntimeState extends Schema.Class("@usine/engine/LoopRuntimeState")({
5
+ loop: LoopName,
6
+ paused: Schema.Boolean,
7
+ }) {
8
+ }
9
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/loop-control/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+EAA+E;AAC/E,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,KAAK,CAChD,gCAAgC,CACjC,CAAC;IACA,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,MAAM,CAAC,OAAO;CACvB,CAAC;CAAG"}
@@ -1,9 +1,18 @@
1
1
  import { Schema } from "effect";
2
+ /** Six hex digits, as GitHub stores label colors. Absent for catalogs stored before colors were kept. */
3
+ export declare const RepositoryLabelColor: Schema.String;
4
+ declare const RepositoryLabel_base: Schema.Class<RepositoryLabel, Schema.Struct<{
5
+ readonly name: Schema.String;
6
+ readonly color: Schema.OptionFromNullOr<Schema.String>;
7
+ readonly description: Schema.OptionFromNullOr<Schema.String>;
8
+ }>, {}>;
9
+ export declare class RepositoryLabel extends RepositoryLabel_base {
10
+ }
2
11
  declare const RepositoryLabelProjection_base: Schema.Class<RepositoryLabelProjection, Schema.Struct<{
3
- readonly repository: Schema.brand<Schema.String, "RepoName">;
4
- readonly labels: Schema.$Array<Schema.String>;
12
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
13
+ readonly labels: Schema.$Array<typeof RepositoryLabel>;
5
14
  }>, {}>;
6
- /** Latest complete repository label catalog observed by trigger polling. */
15
+ /** The latest complete label catalog polling observed for one repository. */
7
16
  export declare class RepositoryLabelProjection extends RepositoryLabelProjection_base {
8
17
  }
9
18
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/repository-label-projection/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;AAOhC,4EAA4E;AAC5E,qBAAa,yBAA0B,SAAQ,8BAK7C;CAAG"}
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/repository-label-projection/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,yGAAyG;AACzG,eAAO,MAAM,oBAAoB,eAEhC,CAAC;;;;;;AAEF,qBAAa,eAAgB,SAAQ,oBAMpC;CAAG;;;;;AAQJ,6EAA6E;AAC7E,qBAAa,yBAA0B,SAAQ,8BAK7C;CAAG"}
@@ -1,10 +1,19 @@
1
- import { Repository } from "@usine/core";
1
+ import { RepositoryName } from "@usine/core/repository";
2
2
  import { Schema } from "effect";
3
- const RepositoryLabel = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank repository label" }));
4
- const RepositoryLabels = Schema.Array(RepositoryLabel).check(Schema.isUnique());
5
- /** Latest complete repository label catalog observed by trigger polling. */
3
+ const RepositoryLabelName = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank repository label" }));
4
+ /** Six hex digits, as GitHub stores label colors. Absent for catalogs stored before colors were kept. */
5
+ export const RepositoryLabelColor = Schema.String.check(Schema.isPattern(/^[0-9a-fA-F]{6}$/u, { message: "Expected a six-digit hex label color" }));
6
+ export class RepositoryLabel extends Schema.Class("@usine/engine/RepositoryLabel")({
7
+ name: RepositoryLabelName,
8
+ color: Schema.OptionFromNullOr(RepositoryLabelColor),
9
+ description: Schema.OptionFromNullOr(Schema.String),
10
+ }) {
11
+ }
12
+ const uniqueLabelNames = Schema.makeFilter((labels) => new Set(labels.map(({ name }) => name)).size === labels.length, { message: "Expected unique label names" });
13
+ const RepositoryLabels = Schema.Array(RepositoryLabel).check(uniqueLabelNames);
14
+ /** The latest complete label catalog polling observed for one repository. */
6
15
  export class RepositoryLabelProjection extends Schema.Class("@usine/engine/RepositoryLabelProjection")({
7
- repository: Repository.Name,
16
+ repository: RepositoryName,
8
17
  labels: RepositoryLabels,
9
18
  }) {
10
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/repository-label-projection/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACzC,MAAM,CAAC,SAAS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AAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,EAC1E,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAC3C,CAAC;AACF,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAE/E,6EAA6E;AAC7E,MAAM,OAAO,yBAA0B,SAAQ,MAAM,CAAC,KAAK,CACzD,yCAAyC,CAC1C,CAAC;IACA,UAAU,EAAE,cAAc;IAC1B,MAAM,EAAE,gBAAgB;CACzB,CAAC;CAAG"}
@@ -1,10 +1,10 @@
1
- import { Repository } from "@usine/core";
1
+ import { RepositoryName } from "@usine/core/repository";
2
2
  import { Context, Effect, Layer, Option } from "effect";
3
3
  import { RunDatabase } from "../database/database.ts";
4
- import { EnginePersistenceError } from "../model.ts";
4
+ import { EnginePersistenceError } from "../engine/error.ts";
5
5
  import { RepositoryLabelProjection } from "./model.ts";
6
6
  declare const RepositoryLabelProjectionReader_base: Context.ServiceClass<RepositoryLabelProjectionReader, "@usine/engine/RepositoryLabelProjectionReader", {
7
- readonly get: (repository: Repository.Name) => Effect.Effect<Option.Option<RepositoryLabelProjection>, EnginePersistenceError>;
7
+ readonly get: (repository: RepositoryName) => Effect.Effect<Option.Option<RepositoryLabelProjection>, EnginePersistenceError>;
8
8
  }>;
9
9
  export declare class RepositoryLabelProjectionReader extends RepositoryLabelProjectionReader_base {
10
10
  static readonly layer: Layer.Layer<RepositoryLabelProjectionReader, never, RunDatabase>;
@@ -16,5 +16,5 @@ declare const RepositoryLabelProjectionWriter_base: Context.ServiceClass<Reposit
16
16
  export declare class RepositoryLabelProjectionWriter extends RepositoryLabelProjectionWriter_base {
17
17
  static readonly layer: Layer.Layer<RepositoryLabelProjectionWriter, never, RunDatabase>;
18
18
  }
19
- export {};
20
- //# sourceMappingURL=service.d.ts.map
19
+ export { RepositoryLabel, RepositoryLabelColor, RepositoryLabelProjection } from "./model.ts";
20
+ //# sourceMappingURL=repository-label-projection.d.ts.map