@usine/engine 0.3.0 → 0.5.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.
- package/LICENSE +661 -21
- package/README.md +112 -38
- package/dist/board-moves/board-moves.d.ts +20 -0
- package/dist/board-moves/board-moves.d.ts.map +1 -0
- package/dist/board-moves/board-moves.js +74 -0
- package/dist/board-moves/board-moves.js.map +1 -0
- package/dist/board-moves/model.d.ts +21 -0
- package/dist/board-moves/model.d.ts.map +1 -0
- package/dist/board-moves/model.js +22 -0
- package/dist/board-moves/model.js.map +1 -0
- package/dist/cursor/cursor.d.ts +2 -6
- package/dist/cursor/cursor.d.ts.map +1 -1
- package/dist/cursor/cursor.js +2 -6
- package/dist/cursor/cursor.js.map +1 -1
- package/dist/cycle-budget/cycle-budget.d.ts +14 -8
- package/dist/cycle-budget/cycle-budget.d.ts.map +1 -1
- package/dist/cycle-budget/cycle-budget.js +51 -10
- package/dist/cycle-budget/cycle-budget.js.map +1 -1
- package/dist/cycle-budget/model.d.ts +6 -2
- package/dist/cycle-budget/model.d.ts.map +1 -1
- package/dist/cycle-budget/model.js +5 -2
- package/dist/cycle-budget/model.js.map +1 -1
- package/dist/cycle-budget/queries.d.ts +1 -1
- package/dist/cycle-budget/queries.d.ts.map +1 -1
- package/dist/cycle-budget/queries.js +3 -3
- package/dist/cycle-budget/queries.js.map +1 -1
- package/dist/database/database.d.ts +1 -1
- package/dist/database/database.d.ts.map +1 -1
- package/dist/database/local-sqlite.d.ts +13 -10
- package/dist/database/local-sqlite.d.ts.map +1 -1
- package/dist/database/local-sqlite.js +22 -17
- package/dist/database/local-sqlite.js.map +1 -1
- package/dist/database/schema.d.ts +668 -36
- package/dist/database/schema.d.ts.map +1 -1
- package/dist/database/schema.js +123 -23
- package/dist/database/schema.js.map +1 -1
- package/dist/{workflow → engine}/admission.d.ts +2 -2
- package/dist/engine/admission.d.ts.map +1 -0
- package/dist/{workflow → engine}/admission.js +4 -4
- package/dist/engine/admission.js.map +1 -0
- package/dist/engine/checkout-recovery.d.ts +79 -0
- package/dist/engine/checkout-recovery.d.ts.map +1 -0
- package/dist/engine/checkout-recovery.js +238 -0
- package/dist/engine/checkout-recovery.js.map +1 -0
- package/dist/engine/engine.d.ts +67 -26
- package/dist/engine/engine.d.ts.map +1 -1
- package/dist/engine/engine.js +136 -129
- package/dist/engine/engine.js.map +1 -1
- package/dist/engine/error.d.ts +29 -10
- package/dist/engine/error.d.ts.map +1 -1
- package/dist/engine/error.js +28 -8
- package/dist/engine/error.js.map +1 -1
- package/dist/engine/lifecycle.d.ts +83 -28
- package/dist/engine/lifecycle.d.ts.map +1 -1
- package/dist/engine/lifecycle.js +94 -45
- package/dist/engine/lifecycle.js.map +1 -1
- package/dist/engine/retry.d.ts +16 -0
- package/dist/engine/retry.d.ts.map +1 -0
- package/dist/engine/retry.js +18 -0
- package/dist/engine/retry.js.map +1 -0
- package/dist/engine/run-again.d.ts +45 -0
- package/dist/engine/run-again.d.ts.map +1 -0
- package/dist/engine/run-again.js +56 -0
- package/dist/engine/run-again.js.map +1 -0
- package/dist/engine/run-driver.d.ts +68 -0
- package/dist/engine/run-driver.d.ts.map +1 -0
- package/dist/engine/run-driver.js +448 -0
- package/dist/engine/run-driver.js.map +1 -0
- package/dist/engine/shutdown.d.ts +3 -4
- package/dist/engine/shutdown.d.ts.map +1 -1
- package/dist/engine/shutdown.js +3 -4
- package/dist/engine/shutdown.js.map +1 -1
- package/dist/engine/submission.d.ts +31 -11
- package/dist/engine/submission.d.ts.map +1 -1
- package/dist/engine/submission.js +43 -12
- package/dist/engine/submission.js.map +1 -1
- package/dist/engine/unconfirmed-stops.d.ts +27 -0
- package/dist/engine/unconfirmed-stops.d.ts.map +1 -0
- package/dist/engine/unconfirmed-stops.js +26 -0
- package/dist/engine/unconfirmed-stops.js.map +1 -0
- package/dist/item-projection/item-projection.d.ts +14 -4
- package/dist/item-projection/item-projection.d.ts.map +1 -1
- package/dist/item-projection/item-projection.js +60 -14
- package/dist/item-projection/item-projection.js.map +1 -1
- package/dist/item-projection/model.d.ts +5 -1
- package/dist/item-projection/model.d.ts.map +1 -1
- package/dist/item-projection/model.js +6 -2
- package/dist/item-projection/model.js.map +1 -1
- package/dist/loop-control/loop-control.d.ts +5 -5
- package/dist/loop-control/loop-control.d.ts.map +1 -1
- package/dist/loop-control/loop-control.js +4 -4
- package/dist/loop-control/loop-control.js.map +1 -1
- package/dist/loop-control/model.d.ts +1 -1
- package/dist/loop-control/model.d.ts.map +1 -1
- package/dist/loop-control/model.js +1 -1
- package/dist/loop-control/model.js.map +1 -1
- package/dist/repository-label-projection/model.d.ts +2 -2
- package/dist/repository-label-projection/model.d.ts.map +1 -1
- package/dist/repository-label-projection/model.js +2 -2
- package/dist/repository-label-projection/model.js.map +1 -1
- package/dist/repository-label-projection/repository-label-projection.d.ts +1 -1
- package/dist/repository-label-projection/repository-label-projection.d.ts.map +1 -1
- package/dist/repository-label-projection/repository-label-projection.js +1 -1
- package/dist/repository-label-projection/repository-label-projection.js.map +1 -1
- package/dist/run-reader/model.d.ts +62 -4
- package/dist/run-reader/model.d.ts.map +1 -1
- package/dist/run-reader/model.js +66 -7
- package/dist/run-reader/model.js.map +1 -1
- package/dist/run-reader/run-reader.d.ts +25 -10
- package/dist/run-reader/run-reader.d.ts.map +1 -1
- package/dist/run-reader/run-reader.js +25 -7
- package/dist/run-reader/run-reader.js.map +1 -1
- package/dist/step-executor.d.ts +86 -13
- package/dist/step-executor.d.ts.map +1 -1
- package/dist/step-executor.js +10 -2
- package/dist/step-executor.js.map +1 -1
- package/dist/store/attempt-windows.d.ts +8 -0
- package/dist/store/attempt-windows.d.ts.map +1 -0
- package/dist/store/attempt-windows.js +53 -0
- package/dist/store/attempt-windows.js.map +1 -0
- package/dist/store/codec.d.ts +242 -43
- package/dist/store/codec.d.ts.map +1 -1
- package/dist/store/codec.js +61 -16
- package/dist/store/codec.js.map +1 -1
- package/dist/store/leftovers.d.ts +10 -0
- package/dist/store/leftovers.d.ts.map +1 -0
- package/dist/store/leftovers.js +43 -0
- package/dist/store/leftovers.js.map +1 -0
- package/dist/store/loop-items.d.ts +16 -0
- package/dist/store/loop-items.d.ts.map +1 -0
- package/dist/store/loop-items.js +185 -0
- package/dist/store/loop-items.js.map +1 -0
- package/dist/store/queries.d.ts +385 -36
- package/dist/store/queries.d.ts.map +1 -1
- package/dist/store/queries.js +355 -107
- package/dist/store/queries.js.map +1 -1
- package/dist/store/store.d.ts +106 -54
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +497 -190
- package/dist/store/store.js.map +1 -1
- package/dist/store/transcript.d.ts +3 -3
- package/dist/store/transcript.d.ts.map +1 -1
- package/dist/store/transcript.js +25 -6
- package/dist/store/transcript.js.map +1 -1
- package/dist/transcript.d.ts +19 -20
- package/dist/transcript.d.ts.map +1 -1
- package/dist/transcript.js +23 -21
- package/dist/transcript.js.map +1 -1
- package/dist/trigger-condition.d.ts +23 -0
- package/dist/trigger-condition.d.ts.map +1 -0
- package/dist/trigger-condition.js +8 -0
- package/dist/trigger-condition.js.map +1 -0
- package/drizzle/20260917071139_resolve_run_failure/migration.sql +1 -0
- package/drizzle/20260917071139_resolve_run_failure/snapshot.json +1471 -0
- package/drizzle/20260918032643_attempt_salvage/migration.sql +1 -0
- package/drizzle/20260918032643_attempt_salvage/snapshot.json +1481 -0
- package/drizzle/20261011153856_drop_workflow_tables/migration.sql +4 -0
- package/drizzle/20261011153856_drop_workflow_tables/snapshot.json +1433 -0
- package/drizzle/20261017155043_attempt_salvage_check/migration.sql +41 -0
- package/drizzle/20261017155043_attempt_salvage_check/snapshot.json +1421 -0
- package/drizzle/20261018162700_discard_attempt_leftovers/migration.sql +1 -0
- package/drizzle/20261018162700_discard_attempt_leftovers/snapshot.json +1431 -0
- package/drizzle/20261018172605_loop_items_and_reopenings/migration.sql +15 -0
- package/drizzle/20261018172605_loop_items_and_reopenings/snapshot.json +1574 -0
- package/drizzle/20261018180339_attempt_ended_at/migration.sql +1 -0
- package/drizzle/20261018180339_attempt_ended_at/snapshot.json +1584 -0
- package/drizzle/20261019104043_run_approval_source/migration.sql +15 -0
- package/drizzle/20261019104043_run_approval_source/snapshot.json +1610 -0
- package/drizzle/20261019133538_board_moves/migration.sql +14 -0
- package/drizzle/20261019133538_board_moves/snapshot.json +1731 -0
- package/drizzle/20261019170538_item_projection_gone/migration.sql +1 -0
- package/drizzle/20261019170538_item_projection_gone/snapshot.json +1741 -0
- package/drizzle/20261019180649_run_again_events/migration.sql +7 -0
- package/drizzle/20261019180649_run_again_events/snapshot.json +1804 -0
- package/drizzle/20261019185008_trigger_event_permissions/migration.sql +1 -0
- package/drizzle/20261019185008_trigger_event_permissions/snapshot.json +1814 -0
- package/drizzle/20261020103746_attempt_start/migration.sql +5 -0
- package/drizzle/20261020103746_attempt_start/snapshot.json +1844 -0
- package/drizzle/20261020125211_attempt_comments/migration.sql +1 -0
- package/drizzle/20261020125211_attempt_comments/snapshot.json +1854 -0
- package/drizzle/20261020191320_run_closed_at/migration.sql +6 -0
- package/drizzle/20261020191320_run_closed_at/snapshot.json +1864 -0
- package/drizzle/20261023091428_rename_loop_item_hold_to_suppression/migration.sql +2 -0
- package/drizzle/20261023091428_rename_loop_item_hold_to_suppression/snapshot.json +1867 -0
- package/drizzle/20261024162954_cycle_ask_closures/migration.sql +10 -0
- package/drizzle/20261024162954_cycle_ask_closures/snapshot.json +1948 -0
- package/drizzle/20261027104206_attempt_out_of_memory/migration.sql +1 -0
- package/drizzle/20261027104206_attempt_out_of_memory/snapshot.json +1958 -0
- package/drizzle/20261027191944_failure_resolution/migration.sql +1 -0
- package/drizzle/20261027191944_failure_resolution/snapshot.json +1968 -0
- package/package.json +22 -12
- package/dist/workflow/admission.d.ts.map +0 -1
- package/dist/workflow/admission.js.map +0 -1
- package/dist/workflow/command.d.ts +0 -13
- package/dist/workflow/command.d.ts.map +0 -1
- package/dist/workflow/command.js +0 -17
- package/dist/workflow/command.js.map +0 -1
- package/dist/workflow/workflow.d.ts +0 -18
- package/dist/workflow/workflow.d.ts.map +0 -1
- package/dist/workflow/workflow.js +0 -108
- package/dist/workflow/workflow.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Attempt, AttemptId, AttemptNumber } from "@usine/core/attempt";
|
|
2
2
|
import { AttemptFailure, InfraFailure } from "@usine/core/attempt/failure";
|
|
3
3
|
import { AttemptCanceled, AttemptFailed, AttemptSucceeded } from "@usine/core/attempt/outcome";
|
|
4
|
+
import { SalvagePushed } from "@usine/core/attempt/salvage";
|
|
5
|
+
import { type AttemptStart, type OperatorRetryStart } from "@usine/core/attempt/start";
|
|
4
6
|
import { EventId } from "@usine/core/event";
|
|
5
7
|
import { Run, RunId } from "@usine/core/run";
|
|
6
8
|
import * as RunState from "@usine/core/run/state";
|
|
7
9
|
import { StepResult } from "@usine/core/step/result";
|
|
8
10
|
import { Option, Result } from "effect";
|
|
9
|
-
import type {
|
|
10
|
-
/** A Run and its Attempts
|
|
11
|
+
import type { IgnoreReason } from "./submission.ts";
|
|
12
|
+
/** A Run and its Attempts, ordered by Attempt number. */
|
|
11
13
|
interface RunProgress {
|
|
12
14
|
readonly run: Run;
|
|
13
15
|
readonly attempts: ReadonlyArray<Attempt>;
|
|
@@ -34,38 +36,39 @@ type RunSucceeded = {
|
|
|
34
36
|
readonly state: RunState.Succeeded;
|
|
35
37
|
readonly result: StepResult;
|
|
36
38
|
};
|
|
37
|
-
/**
|
|
39
|
+
/** The changes committed together when an Attempt finishes. */
|
|
38
40
|
export type FinishDecision = RetryAttempt | RunFailed | RunSucceeded | Unchanged;
|
|
39
41
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
+
* Returns the changes for the executor result of `attemptId`. An infrastructure failure is
|
|
43
|
+
* retried up to 3 Attempts in total; a late or repeated result returns `Unchanged`.
|
|
42
44
|
*/
|
|
43
45
|
export declare const finishAttempt: (current: RunProgress, attemptId: AttemptId, result: Result.Result<StepResult, AttemptFailure>) => FinishDecision;
|
|
44
|
-
/**
|
|
45
|
-
* Repairs an open Attempt from a final durable result. The workflow has already
|
|
46
|
-
* ended, so even an infrastructure failure closes the Run without auto-retry.
|
|
47
|
-
* The runtime must first translate its completion into a typed result; defects
|
|
48
|
-
* and suspension are not Attempt outcomes here (ADRs 0003 and 0010).
|
|
49
|
-
*/
|
|
50
|
-
export declare const reconcileAttempt: (current: RunProgress, result: Result.Result<StepResult, AttemptFailure>) => FinishDecision;
|
|
51
46
|
type StartDecision = {
|
|
52
47
|
readonly _tag: "StartAttempt";
|
|
53
48
|
readonly state: RunState.Running;
|
|
54
49
|
readonly number: AttemptNumber;
|
|
50
|
+
readonly start: AttemptStart;
|
|
55
51
|
readonly interrupted: Option.Option<RetryAttempt>;
|
|
52
|
+
readonly resume: Option.Option<SalvagePushed>;
|
|
53
|
+
} | {
|
|
54
|
+
readonly _tag: "ReattachAttempt";
|
|
55
|
+
readonly state: RunState.Running;
|
|
56
|
+
readonly attempt: Attempt;
|
|
57
|
+
readonly resume: Option.Option<SalvagePushed>;
|
|
56
58
|
} | RunFailed | {
|
|
57
59
|
readonly _tag: "RunClosed";
|
|
58
60
|
readonly state: RunState.RunState;
|
|
59
61
|
};
|
|
60
62
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* The caller creates the new Attempt's identity and timestamp only when admitted.
|
|
63
|
+
* Returns how the next Attempt starts after a Worker reservation. If an open Attempt's parent
|
|
64
|
+
* task is `live`, reattaches it without using a retry; otherwise fails it with `interruption`,
|
|
65
|
+
* counted against the retry cap. `requested` is the operator retry that reopened the Run, if any.
|
|
65
66
|
*/
|
|
66
|
-
export declare const beginAttempt: (current: RunProgress, interruption: InfraFailure) => StartDecision;
|
|
67
|
+
export declare const beginAttempt: (current: RunProgress, interruption: InfraFailure, live: Option.Option<AttemptId>, requested: Option.Option<OperatorRetryStart>) => StartDecision;
|
|
67
68
|
type CancelDecision = {
|
|
68
69
|
readonly _tag: "AlreadyClosed";
|
|
70
|
+
} | {
|
|
71
|
+
readonly _tag: "CancelRejected";
|
|
69
72
|
} | {
|
|
70
73
|
readonly _tag: "Canceled";
|
|
71
74
|
readonly state: RunState.Canceled;
|
|
@@ -74,10 +77,7 @@ type CancelDecision = {
|
|
|
74
77
|
readonly outcome: AttemptCanceled;
|
|
75
78
|
}>;
|
|
76
79
|
};
|
|
77
|
-
/**
|
|
78
|
-
* Cancels open work and, if executing, its unfinished Attempt. A Run awaiting
|
|
79
|
-
* capacity may have no Attempt, or only the closed Attempt preceding a retry.
|
|
80
|
-
*/
|
|
80
|
+
/** Returns the cancel decision for an open Run and its open Attempt, if any. */
|
|
81
81
|
export declare const cancelRun: (current: RunProgress) => CancelDecision;
|
|
82
82
|
type RetryDecision = {
|
|
83
83
|
readonly _tag: "Resume";
|
|
@@ -88,11 +88,67 @@ type RetryDecision = {
|
|
|
88
88
|
readonly _tag: "RetryRejected";
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
|
|
91
|
+
* Returns the operator retry decision, regardless of the Attempt count. A retry of a running Run
|
|
92
|
+
* with no open Attempt changes nothing; a retry of a running Attempt is rejected.
|
|
93
|
+
*/
|
|
94
|
+
export declare const retryRun: (current: RunProgress) => RetryDecision;
|
|
95
|
+
/**
|
|
96
|
+
* The Loop's previous sighting of an Item: `None` if never seen, `Some(None)` after a
|
|
97
|
+
* non-matching sighting, and `Some(Some(event))` for the last submitted Event.
|
|
98
|
+
*/
|
|
99
|
+
export type PreviousSighting = Option.Option<Option.Option<EventId>>;
|
|
100
|
+
/**
|
|
101
|
+
* Returns whether the previous sighting was a non-match or another Event than `eventId`. Returns
|
|
102
|
+
* `false` if the Loop never saw the Item.
|
|
103
|
+
*/
|
|
104
|
+
export declare const cameBack: (previous: PreviousSighting, eventId: EventId) => boolean;
|
|
105
|
+
/** The state of a recorded Event that has a Run or was ignored. */
|
|
106
|
+
export type Settlement = {
|
|
107
|
+
readonly _tag: "Owned";
|
|
108
|
+
readonly run: Run;
|
|
109
|
+
} | {
|
|
110
|
+
readonly _tag: "Ignored";
|
|
111
|
+
readonly reason: IgnoreReason;
|
|
112
|
+
};
|
|
113
|
+
type SightingDecision = {
|
|
114
|
+
readonly _tag: "JoinRun";
|
|
115
|
+
readonly run: Run;
|
|
116
|
+
} | {
|
|
117
|
+
readonly _tag: "StayIgnored";
|
|
118
|
+
readonly reason: IgnoreReason;
|
|
119
|
+
} | {
|
|
120
|
+
readonly _tag: "ReopenEvent";
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Returns what a new sighting of the `settled` Event does. The Event reopens only if the Item
|
|
124
|
+
* came back (#267) and its Run was canceled or the queued Event was revoked.
|
|
125
|
+
*/
|
|
126
|
+
export declare const resightEvent: (settled: Settlement, itemCameBack: boolean) => SightingDecision;
|
|
127
|
+
/**
|
|
128
|
+
* The state that keeps a Loop from opening Runs for an Item after an Attempt stopped for the
|
|
129
|
+
* operator: the stopped Run, and the Item's state after the stop once seen (#241, #341).
|
|
130
|
+
*/
|
|
131
|
+
export interface Suppression {
|
|
132
|
+
readonly runId: RunId;
|
|
133
|
+
readonly suppressedEventId: Option.Option<EventId>;
|
|
134
|
+
}
|
|
135
|
+
/** The kind of operator stop: a question or a blocker. */
|
|
136
|
+
export type OperatorStop = "question" | "blocker";
|
|
137
|
+
/** Returns the kind of operator stop that fails the Run in `decision`, or `None` (ADR 0017). */
|
|
138
|
+
export declare const operatorStop: (decision: FinishDecision) => Option.Option<OperatorStop>;
|
|
139
|
+
type SuppressionDecision = {
|
|
140
|
+
readonly _tag: "Suppress";
|
|
141
|
+
} | {
|
|
142
|
+
readonly _tag: "SuppressFrom";
|
|
143
|
+
} | {
|
|
144
|
+
readonly _tag: "Lift";
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Returns what an unclaimed Event does during a suppression. The first Event after the stop,
|
|
148
|
+
* which usually contains the Agent's own comment, becomes the suppressed state (`SuppressFrom`);
|
|
149
|
+
* a different later Event lifts the suppression.
|
|
94
150
|
*/
|
|
95
|
-
export declare const
|
|
151
|
+
export declare const suppressionDecision: (suppression: Suppression, eventId: EventId) => SuppressionDecision;
|
|
96
152
|
type ClaimDecision = {
|
|
97
153
|
readonly _tag: "OpenRun";
|
|
98
154
|
} | {
|
|
@@ -103,9 +159,8 @@ type ClaimDecision = {
|
|
|
103
159
|
readonly state: RunState.Canceled;
|
|
104
160
|
};
|
|
105
161
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* ignored Events before this decision; running Attempts always finish (ADR 0007).
|
|
162
|
+
* Returns what an unclaimed Event does: open a Run, queue behind the Item's running Run, or
|
|
163
|
+
* supersede the Item's unstarted Run (ADR 0007).
|
|
109
164
|
*/
|
|
110
165
|
export declare const claimRun: (blocking: Option.Option<Run>, eventId: EventId) => ClaimDecision;
|
|
111
166
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/engine/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAmB,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,
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/engine/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,S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KACf,mBAKC,CAAC;AAEL,KAAK,aAAa,GACd;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAA;CAAE,CAAC;AAEhG;;;GAGG;AACH,eAAO,MAAM,QAAQ,aAAc,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,OAAO,KAAG,aAQzE,CAAC"}
|
package/dist/engine/lifecycle.js
CHANGED
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
import { Attempt, AttemptId, AttemptNumber, shouldAutoRetry } from "@usine/core/attempt";
|
|
2
2
|
import { AttemptFailure, InfraFailure } from "@usine/core/attempt/failure";
|
|
3
3
|
import { AttemptCanceled, AttemptFailed, AttemptSucceeded } from "@usine/core/attempt/outcome";
|
|
4
|
+
import { SalvagePushed } from "@usine/core/attempt/salvage";
|
|
5
|
+
import { StartedAfterRestart, StartedByEvent, StartedByInfraRetry, } from "@usine/core/attempt/start";
|
|
4
6
|
import { EventId } from "@usine/core/event";
|
|
5
7
|
import { Run, RunId } from "@usine/core/run";
|
|
6
8
|
import * as RunState from "@usine/core/run/state";
|
|
7
9
|
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
|
+
import { Array as EffectArray, Match, Option, Result } from "effect";
|
|
10
11
|
const MAX_AUTO_ATTEMPTS = AttemptNumber.make(3);
|
|
11
12
|
const openAttempt = (current) => Option.fromNullishOr(current.attempts.at(-1)).pipe(Option.filter((attempt) => Option.isNone(attempt.outcome)));
|
|
12
|
-
const failRunningAttempt = (state, attempt, failure
|
|
13
|
+
const failRunningAttempt = (state, attempt, failure) => {
|
|
13
14
|
const outcome = new AttemptFailed({ failure });
|
|
14
|
-
if (
|
|
15
|
-
shouldAutoRetry({ failure, number: attempt.number, maxAutoAttempts: MAX_AUTO_ATTEMPTS })) {
|
|
15
|
+
if (shouldAutoRetry({ failure, number: attempt.number, maxAutoAttempts: MAX_AUTO_ATTEMPTS })) {
|
|
16
16
|
return { _tag: "RetryAttempt", attempt, outcome };
|
|
17
17
|
}
|
|
18
18
|
return { _tag: "RunFailed", attempt, outcome, state: RunState.fail(state) };
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Returns the changes for the executor result of `attemptId`. An infrastructure failure is
|
|
22
|
+
* retried up to 3 Attempts in total; a late or repeated result returns `Unchanged`.
|
|
23
|
+
*/
|
|
24
|
+
export const finishAttempt = (current, attemptId, result) => {
|
|
21
25
|
if (current.run.state._tag !== "Running") {
|
|
22
26
|
return { _tag: "Unchanged", reason: "RunNotRunning" };
|
|
23
27
|
}
|
|
24
28
|
const attempt = openAttempt(current);
|
|
25
29
|
if (Option.isNone(attempt))
|
|
26
30
|
return { _tag: "Unchanged", reason: "NoOpenAttempt" };
|
|
27
|
-
// A
|
|
28
|
-
// replacement Attempt, even though the Run is Running again.
|
|
31
|
+
// A result from before a restart or retry doesn't apply to the replacement Attempt.
|
|
29
32
|
if (attempt.value.id !== attemptId)
|
|
30
33
|
return { _tag: "Unchanged", reason: "AttemptReplaced" };
|
|
31
34
|
if (Result.isFailure(result)) {
|
|
32
|
-
return failRunningAttempt(current.run.state, attempt.value, result.failure
|
|
35
|
+
return failRunningAttempt(current.run.state, attempt.value, result.failure);
|
|
33
36
|
}
|
|
34
37
|
return {
|
|
35
38
|
_tag: "RunSucceeded",
|
|
@@ -39,30 +42,21 @@ const finish = (current, attemptId, result, policy) => {
|
|
|
39
42
|
result: result.success,
|
|
40
43
|
};
|
|
41
44
|
};
|
|
45
|
+
/** Returns the part of `salvage` that another Worker can fetch, if any. */
|
|
46
|
+
const pushedPart = (salvage) => Match.valueTags(salvage, {
|
|
47
|
+
Pushed: (pushed) => Option.some(pushed),
|
|
48
|
+
PartlyPushed: ({ ref, commit }) => Option.some(new SalvagePushed({ ref, commit })),
|
|
49
|
+
Retained: () => Option.none(),
|
|
50
|
+
Rejected: () => Option.none(),
|
|
51
|
+
});
|
|
52
|
+
// Only a pushed salvage can be fetched on another Worker, so a retry resumes from the newest one.
|
|
53
|
+
const newestPushedSalvage = (attempts) => EffectArray.findLast(attempts, (attempt) => Option.flatMap(attempt.salvage, pushedPart));
|
|
42
54
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
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.
|
|
55
|
+
* Returns how the next Attempt starts after a Worker reservation. If an open Attempt's parent
|
|
56
|
+
* task is `live`, reattaches it without using a retry; otherwise fails it with `interruption`,
|
|
57
|
+
* counted against the retry cap. `requested` is the operator retry that reopened the Run, if any.
|
|
64
58
|
*/
|
|
65
|
-
export const beginAttempt = (current, interruption) => {
|
|
59
|
+
export const beginAttempt = (current, interruption, live, requested) => {
|
|
66
60
|
const state = current.run.state;
|
|
67
61
|
if (!RunState.isStartable(state) && state._tag !== "Running") {
|
|
68
62
|
return { _tag: "RunClosed", state };
|
|
@@ -70,25 +64,37 @@ export const beginAttempt = (current, interruption) => {
|
|
|
70
64
|
let interrupted = Option.none();
|
|
71
65
|
const attempt = openAttempt(current);
|
|
72
66
|
if (state._tag === "Running" && Option.isSome(attempt)) {
|
|
73
|
-
|
|
67
|
+
if (Option.contains(live, attempt.value.id)) {
|
|
68
|
+
return {
|
|
69
|
+
_tag: "ReattachAttempt",
|
|
70
|
+
state,
|
|
71
|
+
attempt: attempt.value,
|
|
72
|
+
resume: newestPushedSalvage(current.attempts),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const recovery = failRunningAttempt(state, attempt.value, interruption);
|
|
74
76
|
if (recovery._tag === "RunFailed")
|
|
75
77
|
return recovery;
|
|
76
78
|
interrupted = Option.some(recovery);
|
|
77
79
|
}
|
|
80
|
+
const start = Option.isSome(interrupted)
|
|
81
|
+
? new StartedAfterRestart()
|
|
82
|
+
: Option.getOrElse(requested, () => current.attempts.length === 0 ? new StartedByEvent() : new StartedByInfraRetry());
|
|
78
83
|
return {
|
|
79
84
|
_tag: "StartAttempt",
|
|
80
85
|
state: state._tag === "Running" ? state : RunState.start(state),
|
|
81
86
|
number: AttemptNumber.make((current.attempts.at(-1)?.number ?? 0) + 1),
|
|
87
|
+
start,
|
|
82
88
|
interrupted,
|
|
89
|
+
resume: newestPushedSalvage(current.attempts),
|
|
83
90
|
};
|
|
84
91
|
};
|
|
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
|
-
*/
|
|
92
|
+
/** Returns the cancel decision for an open Run and its open Attempt, if any. */
|
|
89
93
|
export const cancelRun = (current) => {
|
|
90
|
-
if (
|
|
94
|
+
if (current.run.state._tag === "Canceled")
|
|
91
95
|
return { _tag: "AlreadyClosed" };
|
|
96
|
+
if (!RunState.isOpen(current.run.state))
|
|
97
|
+
return { _tag: "CancelRejected" };
|
|
92
98
|
return {
|
|
93
99
|
_tag: "Canceled",
|
|
94
100
|
state: RunState.cancelByOperator(current.run.state),
|
|
@@ -101,22 +107,65 @@ export const cancelRun = (current) => {
|
|
|
101
107
|
};
|
|
102
108
|
};
|
|
103
109
|
/**
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* after delivery, retrying a Running Run is rejected.
|
|
110
|
+
* Returns the operator retry decision, regardless of the Attempt count. A retry of a running Run
|
|
111
|
+
* with no open Attempt changes nothing; a retry of a running Attempt is rejected.
|
|
107
112
|
*/
|
|
108
|
-
export const retryRun = (
|
|
113
|
+
export const retryRun = (current) => {
|
|
114
|
+
const state = current.run.state;
|
|
109
115
|
if (state._tag === "Failed")
|
|
110
116
|
return { _tag: "Resume", state: RunState.retry(state) };
|
|
111
|
-
if (state._tag === "Running" &&
|
|
117
|
+
if (state._tag === "Running" && Option.isNone(openAttempt(current))) {
|
|
112
118
|
return { _tag: "ResumePending" };
|
|
113
119
|
}
|
|
114
120
|
return { _tag: "RetryRejected" };
|
|
115
121
|
};
|
|
116
122
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
|
|
123
|
+
* Returns whether the previous sighting was a non-match or another Event than `eventId`. Returns
|
|
124
|
+
* `false` if the Loop never saw the Item.
|
|
125
|
+
*/
|
|
126
|
+
export const cameBack = (previous, eventId) => Option.match(previous, {
|
|
127
|
+
onNone: () => false,
|
|
128
|
+
onSome: (observed) => !Option.contains(observed, eventId),
|
|
129
|
+
});
|
|
130
|
+
/**
|
|
131
|
+
* Returns what a new sighting of the `settled` Event does. The Event reopens only if the Item
|
|
132
|
+
* came back (#267) and its Run was canceled or the queued Event was revoked.
|
|
133
|
+
*/
|
|
134
|
+
export const resightEvent = (settled, itemCameBack) => {
|
|
135
|
+
if (settled._tag === "Owned") {
|
|
136
|
+
return settled.run.state._tag === "Canceled" && itemCameBack
|
|
137
|
+
? { _tag: "ReopenEvent" }
|
|
138
|
+
: { _tag: "JoinRun", run: settled.run };
|
|
139
|
+
}
|
|
140
|
+
return settled.reason === "revoked" && itemCameBack
|
|
141
|
+
? { _tag: "ReopenEvent" }
|
|
142
|
+
: { _tag: "StayIgnored", reason: settled.reason };
|
|
143
|
+
};
|
|
144
|
+
/** Returns the kind of operator stop that fails the Run in `decision`, or `None` (ADR 0017). */
|
|
145
|
+
export const operatorStop = (decision) => {
|
|
146
|
+
if (decision._tag !== "RunFailed")
|
|
147
|
+
return Option.none();
|
|
148
|
+
switch (decision.outcome.failure._tag) {
|
|
149
|
+
case "QuestionFailure":
|
|
150
|
+
return Option.some("question");
|
|
151
|
+
case "BlockedFailure":
|
|
152
|
+
return Option.some("blocker");
|
|
153
|
+
default:
|
|
154
|
+
return Option.none();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Returns what an unclaimed Event does during a suppression. The first Event after the stop,
|
|
159
|
+
* which usually contains the Agent's own comment, becomes the suppressed state (`SuppressFrom`);
|
|
160
|
+
* a different later Event lifts the suppression.
|
|
161
|
+
*/
|
|
162
|
+
export const suppressionDecision = (suppression, eventId) => Option.match(suppression.suppressedEventId, {
|
|
163
|
+
onNone: () => ({ _tag: "SuppressFrom" }),
|
|
164
|
+
onSome: (suppressed) => suppressed === eventId ? { _tag: "Suppress" } : { _tag: "Lift" },
|
|
165
|
+
});
|
|
166
|
+
/**
|
|
167
|
+
* Returns what an unclaimed Event does: open a Run, queue behind the Item's running Run, or
|
|
168
|
+
* supersede the Item's unstarted Run (ADR 0007).
|
|
120
169
|
*/
|
|
121
170
|
export const claimRun = (blocking, eventId) => {
|
|
122
171
|
if (Option.isNone(blocking))
|
|
@@ -1 +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,EAAE,MAAM,QAAQ,CAAC;
|
|
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,EAAuB,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjF,OAAO,EAGL,mBAAmB,EACnB,cAAc,EACd,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,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,KAAK,IAAI,W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C,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;CACnE,CAAC,CAAC;AAOL;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,QAA4B,EAAE,OAAgB,EAAiB,EAAE;IACxF,IAAI,MAAM,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,16 @@
|
|
|
1
|
+
import { AttemptContext } from "@usine/core/attempt";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
declare const RetryRequest_base: Schema.Class<RetryRequest, Schema.Struct<{
|
|
4
|
+
readonly requestedBy: Schema.Option<Schema.brand<Schema.String, "OperatorLogin">>;
|
|
5
|
+
readonly amendment: Schema.Option<typeof AttemptContext>;
|
|
6
|
+
}>, {}>;
|
|
7
|
+
/**
|
|
8
|
+
* An operator retry of a failed Run. `requestedBy` is `None` if `usine.yaml` sets no operator
|
|
9
|
+
* login, and `amendment` is the edit-and-retry task and Agent (ADR 0018).
|
|
10
|
+
*/
|
|
11
|
+
export declare class RetryRequest extends RetryRequest_base {
|
|
12
|
+
}
|
|
13
|
+
/** A retry without a login that keeps the Run's task and Agent. */
|
|
14
|
+
export declare const plainRetry: RetryRequest;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/engine/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;AAExC;;;GAGG;AACH,qBAAa,YAAa,SAAQ,iBAGhC;CAAG;AAEL,mEAAmE;AACnE,eAAO,MAAM,UAAU,cAGrB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AttemptContext } from "@usine/core/attempt";
|
|
2
|
+
import { OperatorLogin } from "@usine/core/operator";
|
|
3
|
+
import { Option, Schema } from "effect";
|
|
4
|
+
/**
|
|
5
|
+
* An operator retry of a failed Run. `requestedBy` is `None` if `usine.yaml` sets no operator
|
|
6
|
+
* login, and `amendment` is the edit-and-retry task and Agent (ADR 0018).
|
|
7
|
+
*/
|
|
8
|
+
export class RetryRequest extends Schema.Class("@usine/engine/RetryRequest")({
|
|
9
|
+
requestedBy: Schema.Option(OperatorLogin),
|
|
10
|
+
amendment: Schema.Option(AttemptContext),
|
|
11
|
+
}) {
|
|
12
|
+
}
|
|
13
|
+
/** A retry without a login that keeps the Run's task and Agent. */
|
|
14
|
+
export const plainRetry = new RetryRequest({
|
|
15
|
+
requestedBy: Option.none(),
|
|
16
|
+
amendment: Option.none(),
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/engine/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,KAAK,CAAe,4BAA4B,CAAC,CAAC;IACzF,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;CACzC,CAAC;CAAG;AAEL,mEAAmE;AACnE,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,YAAY,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC,IAAI,EAAE;IAC1B,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE;CACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AttemptContext } from "@usine/core/attempt";
|
|
2
|
+
import { type CycleGeneration } from "@usine/core/cycle-budget";
|
|
3
|
+
import { DedupKey } from "@usine/core/event";
|
|
4
|
+
import { type DateTime, Schema } from "effect";
|
|
5
|
+
import type { RunSnapshot } from "../run-reader/model.ts";
|
|
6
|
+
import { Claimed, CycleBlocked, Submission } from "./submission.ts";
|
|
7
|
+
declare const RunAgainRequest_base: Schema.Class<RunAgainRequest, Schema.Struct<{
|
|
8
|
+
readonly step: Schema.brand<Schema.NonEmptyString, "StepName">;
|
|
9
|
+
readonly approval: Schema.Literals<readonly ["none", "required"]>;
|
|
10
|
+
/** The cycle limit, or `None` for a schedule Loop. */
|
|
11
|
+
readonly cycleLimit: Schema.Option<Schema.brand<Schema.Int, "CycleLimit">>;
|
|
12
|
+
readonly permissions: Schema.Literals<readonly ["write", "read"]>;
|
|
13
|
+
readonly context: typeof AttemptContext;
|
|
14
|
+
readonly requestedBy: Schema.Option<Schema.brand<Schema.String, "OperatorLogin">>;
|
|
15
|
+
}>, {}>;
|
|
16
|
+
/**
|
|
17
|
+
* An operator request to run a succeeded or canceled Run again with the Loop's current settings
|
|
18
|
+
* (#152). `requestedBy` is `None` if `usine.yaml` sets no operator login.
|
|
19
|
+
*/
|
|
20
|
+
export declare class RunAgainRequest extends RunAgainRequest_base {
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The result of a run again: `Claimed` with the new Run, or `CycleBlocked` with the Ask opened
|
|
24
|
+
* because the Item's cycle budget is used up.
|
|
25
|
+
*/
|
|
26
|
+
export declare const RunAgainResult: Schema.Union<readonly [typeof Claimed, typeof CycleBlocked]>;
|
|
27
|
+
export type RunAgainResult = typeof RunAgainResult.Type;
|
|
28
|
+
/** The position of a run again among the Events opened for one trigger Event. */
|
|
29
|
+
export interface RunAgainIdentity {
|
|
30
|
+
/** The dedup key of the trigger Event that the closed Run's Event is or reopened. */
|
|
31
|
+
readonly trigger: DedupKey;
|
|
32
|
+
/** The trigger Event's next reopening number, shared with reopenings (#267). */
|
|
33
|
+
readonly reopening: number;
|
|
34
|
+
/** The Item's cycle generation at the time of the request. */
|
|
35
|
+
readonly generation: CycleGeneration;
|
|
36
|
+
readonly receivedAt: DateTime.Utc;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns the Event for a run again, with the closed Run's Item state and revision, the Loop's
|
|
40
|
+
* current settings, and the operator's task and Agent. Its dedup key,
|
|
41
|
+
* `["operator-run-again", n, <trigger key>]`, never collides with a polled Event.
|
|
42
|
+
*/
|
|
43
|
+
export declare const runAgainSubmission: (ran: RunSnapshot, request: RunAgainRequest, identity: RunAgainIdentity) => Submission;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=run-again.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-again.d.ts","sourceRoot":"","sources":["../../src/engine/run-again.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,KAAK,eAAe,EAAc,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAkB,MAAM,mBAAmB,CAAC;AAI7D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;;;;IAUhE,sDAAsD;;;;;;AAR1D;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,oBAUpC;CAAG;AAEJ;;;GAGG;AACH,eAAO,MAAM,cAAc,8DAAwC,CAAC;AAEpE,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8DAA8D;IAC9D,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC;CACnC;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QACxB,WAAW,WACP,eAAe,YACd,gBAAgB,KACzB,UAwBF,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AttemptContext } from "@usine/core/attempt";
|
|
2
|
+
import { CycleLimit } from "@usine/core/cycle-budget";
|
|
3
|
+
import { DedupKey, Event, EventId } from "@usine/core/event";
|
|
4
|
+
import { ApprovalRequirement, LoopPermissions } from "@usine/core/loop";
|
|
5
|
+
import { OperatorLogin } from "@usine/core/operator";
|
|
6
|
+
import { StepName } from "@usine/core/step";
|
|
7
|
+
import { Schema } from "effect";
|
|
8
|
+
import { Claimed, CycleBlocked, Submission } from "./submission.js";
|
|
9
|
+
/**
|
|
10
|
+
* An operator request to run a succeeded or canceled Run again with the Loop's current settings
|
|
11
|
+
* (#152). `requestedBy` is `None` if `usine.yaml` sets no operator login.
|
|
12
|
+
*/
|
|
13
|
+
export class RunAgainRequest extends Schema.Class("@usine/engine/RunAgainRequest")({
|
|
14
|
+
step: StepName,
|
|
15
|
+
approval: ApprovalRequirement,
|
|
16
|
+
/** The cycle limit, or `None` for a schedule Loop. */
|
|
17
|
+
cycleLimit: Schema.Option(CycleLimit),
|
|
18
|
+
permissions: LoopPermissions,
|
|
19
|
+
context: AttemptContext,
|
|
20
|
+
requestedBy: Schema.Option(OperatorLogin),
|
|
21
|
+
}) {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The result of a run again: `Claimed` with the new Run, or `CycleBlocked` with the Ask opened
|
|
25
|
+
* because the Item's cycle budget is used up.
|
|
26
|
+
*/
|
|
27
|
+
export const RunAgainResult = Schema.Union([Claimed, CycleBlocked]);
|
|
28
|
+
/**
|
|
29
|
+
* Returns the Event for a run again, with the closed Run's Item state and revision, the Loop's
|
|
30
|
+
* current settings, and the operator's task and Agent. Its dedup key,
|
|
31
|
+
* `["operator-run-again", n, <trigger key>]`, never collides with a polled Event.
|
|
32
|
+
*/
|
|
33
|
+
export const runAgainSubmission = (ran, request, identity) => {
|
|
34
|
+
const dedupKey = DedupKey.make(JSON.stringify(["operator-run-again", identity.reopening, identity.trigger]));
|
|
35
|
+
return new Submission({
|
|
36
|
+
event: new Event({
|
|
37
|
+
id: EventId.make(dedupKey),
|
|
38
|
+
dedupKey,
|
|
39
|
+
payload: ran.event.payload,
|
|
40
|
+
receivedAt: identity.receivedAt,
|
|
41
|
+
}),
|
|
42
|
+
itemKey: ran.itemKey,
|
|
43
|
+
loop: ran.run.loop,
|
|
44
|
+
step: request.step,
|
|
45
|
+
approval: request.approval,
|
|
46
|
+
permissions: request.permissions,
|
|
47
|
+
cycleLimit: request.cycleLimit,
|
|
48
|
+
cycleGeneration: identity.generation,
|
|
49
|
+
repository: ran.repository,
|
|
50
|
+
revision: ran.revision,
|
|
51
|
+
task: request.context.task,
|
|
52
|
+
agent: request.context.agent,
|
|
53
|
+
parentModel: request.context.parentModel,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=run-again.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-again.js","sourceRoot":"","sources":["../../src/engine/run-again.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAwB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAiB,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEpE;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,KAAK,CAAkB,+BAA+B,CAAC,CACjG;IACE,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,mBAAmB;IAC7B,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;IACrC,WAAW,EAAE,eAAe;IAC5B,OAAO,EAAE,cAAc;IACvB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;CAC1C,CACF;CAAG;AAEJ;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;AAepE;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,GAAgB,EA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