@usine/durable 0.3.1-next.501.g324bfed.1.1 → 0.3.1-next.502.g1d9b8bf.1.1
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/README.md
CHANGED
|
@@ -88,6 +88,25 @@ pi-durable reports failures that don't fail their caller through `onReport`. The
|
|
|
88
88
|
|
|
89
89
|
pi-durable has no cross-process locking: tasks and documents from a second writer can't be read back. `usine up` locks the instance folder to prevent this.
|
|
90
90
|
|
|
91
|
+
## Coordinator rules
|
|
92
|
+
|
|
93
|
+
`src/attempt/coordinator/rules.ts` holds the policy of the event-driven coordinator from [#1150](https://github.com/basaltbytes/usine/issues/1150) as three pure functions. It imports only `@usine/core` schemas and performs no IO. No attempt runs through it yet.
|
|
94
|
+
|
|
95
|
+
- `ruleFor(event, context)` returns the rule's `Decision` for a `CoordinatorEvent`.
|
|
96
|
+
- `clamp(decision, context)` checks a decision from a rule or a model against the event and resolves its defaults.
|
|
97
|
+
- `apply(state, decision)` returns the next `CoordinatorState` and the effect intents: `Delegate` starts a child, `Finish` ends the Attempt, and `Ignored` gives the reason a decision changed nothing.
|
|
98
|
+
|
|
99
|
+
`ModelDecision` is the contract that a model handler answers with. `Schema.toJsonSchemaDocument(ModelDecision)` has one branch per tag, and its free-text fields are optional wherever the event supplies the text. A `RetryChild` without an assignment tells the replacement to continue from the checkout, with the previous child's report when it answers a report. A `Complete` without a message completes with the report, and for an interruption it takes the event's rule, because an interruption has no report to complete with. A rule's `Decision` adds two tags that a model can't choose: `StartChild` and `OverBudget`.
|
|
100
|
+
|
|
101
|
+
The rules handle each lifecycle event as follows:
|
|
102
|
+
|
|
103
|
+
- `AttemptStarted` delegates child 1 with a fixed context.
|
|
104
|
+
- `ChildReported` with a reserved marker fails the Attempt with `BlockedFailure`, `QuestionFailure`, or `AgentFailure`. Without a marker, it completes the Attempt with the report.
|
|
105
|
+
- `ChildInterrupted` delegates one replacement in the next child-session budget slot, with a context that tells the child to inspect the checkout and continue. With no slot left, the Attempt fails with `InfraFailure`.
|
|
106
|
+
- `ChildAtCapacity` fails the Attempt with `ProviderCapacityFailure`, `ChildFailed` with `InfraFailure`, and `BudgetExceeded` with `ChildSessionBudgetFailure`.
|
|
107
|
+
|
|
108
|
+
A model may answer only a report without a marker or an interruption. For every other event, `clamp` applies the rule, so a reserved marker always wins. `clamp` also applies the event's rule when it gets `StartChild` or `OverBudget` for a child event, and it turns a `RetryChild` past the budget into `Failed`. `apply` ignores a decision about a child other than the latest one, a decision about a child before the first child starts, a repeated start, and anything after the Attempt settles, so an interruption gets at most one replacement. For each of these, it returns one `Ignored` intent whose `reason` is `StaleChild`, `NotStarted`, `AlreadyStarted`, or `AttemptSettled`, so the coordinator can log why nothing happened.
|
|
109
|
+
|
|
91
110
|
## Testing
|
|
92
111
|
|
|
93
112
|
```ts
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { AgentFailure, BlockedFailure, ChildSessionBudgetFailure, InfraFailure, ProviderCapacityFailure, QuestionFailure } from "@usine/core/attempt/failure";
|
|
2
|
+
import { type Brand, Schema } from "effect";
|
|
3
|
+
/** The supplemental context of an Attempt's first child. */
|
|
4
|
+
export declare const FIRST_ASSIGNMENT = "Complete the delegated task in this checkout and give the result as your final answer.";
|
|
5
|
+
/** The default supplemental context of a child that replaces an interrupted one. */
|
|
6
|
+
export declare const REPLACEMENT_ASSIGNMENT = "The previous child session stopped before it finished, and it couldn't resume. The checkout keeps everything it did: inspect the checkout and continue the task from its current state.";
|
|
7
|
+
/**
|
|
8
|
+
* The default supplemental context of a child that replaces one that reported, before the
|
|
9
|
+
* previous child's report.
|
|
10
|
+
*/
|
|
11
|
+
export declare const REPORTED_REPLACEMENT_ASSIGNMENT = "The previous child session finished, but its work isn't done. The checkout keeps everything it did: read its final report below, inspect the checkout, and continue the task from its current state.";
|
|
12
|
+
/** The Attempt's message when its child finished with a blank report. */
|
|
13
|
+
export declare const BLANK_REPORT_MESSAGE = "The child session finished without a report";
|
|
14
|
+
/** The reserved marker that a child's final report starts with: blocker, question, or harness failure. */
|
|
15
|
+
export declare const ReservedKind: Schema.Literals<readonly ["blocked", "question", "failed"]>;
|
|
16
|
+
export type ReservedKind = typeof ReservedKind.Type;
|
|
17
|
+
declare const ReservedReport_base: Schema.Class<ReservedReport, Schema.Struct<{
|
|
18
|
+
readonly kind: Schema.Literals<readonly ["blocked", "question", "failed"]>;
|
|
19
|
+
/** The report text after the marker. */
|
|
20
|
+
readonly message: Schema.NonEmptyString;
|
|
21
|
+
}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/ReservedReport">>;
|
|
22
|
+
/** A final report that starts with a reserved marker. */
|
|
23
|
+
export declare class ReservedReport extends ReservedReport_base {
|
|
24
|
+
}
|
|
25
|
+
declare const AttemptStarted_base: Schema.Class<AttemptStarted, Schema.TaggedStruct<"AttemptStarted", {}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/AttemptStarted">>;
|
|
26
|
+
/** The Attempt started and has no child yet. */
|
|
27
|
+
export declare class AttemptStarted extends AttemptStarted_base {
|
|
28
|
+
}
|
|
29
|
+
declare const ChildReported_base: Schema.Class<ChildReported, Schema.TaggedStruct<"ChildReported", {
|
|
30
|
+
readonly child: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
31
|
+
readonly report: Schema.String;
|
|
32
|
+
/** Whether the turn that produced the report started from an operator message (ADR 0018). */
|
|
33
|
+
readonly answeredOperator: Schema.Boolean;
|
|
34
|
+
/** The report's reserved marker, or `None` for an ordinary report. */
|
|
35
|
+
readonly reserved: Schema.OptionFromNullOr<typeof ReservedReport>;
|
|
36
|
+
}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/ChildReported">>;
|
|
37
|
+
/** Child `child` finished its work with a final report. */
|
|
38
|
+
export declare class ChildReported extends ChildReported_base {
|
|
39
|
+
}
|
|
40
|
+
declare const ChildInterrupted_base: Schema.Class<ChildInterrupted, Schema.TaggedStruct<"ChildInterrupted", {
|
|
41
|
+
readonly child: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
42
|
+
readonly reason: Schema.NonEmptyString;
|
|
43
|
+
}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/ChildInterrupted">>;
|
|
44
|
+
/** Child `child` stopped and can't resume: no saved session, worker or checkout gone, or resume refused. */
|
|
45
|
+
export declare class ChildInterrupted extends ChildInterrupted_base {
|
|
46
|
+
}
|
|
47
|
+
declare const ChildAtCapacity_base: Schema.Class<ChildAtCapacity, Schema.TaggedStruct<"ChildAtCapacity", {
|
|
48
|
+
readonly child: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
49
|
+
readonly message: Schema.NonEmptyString;
|
|
50
|
+
}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/ChildAtCapacity">>;
|
|
51
|
+
/** The model provider of child `child` refused it for lack of capacity. */
|
|
52
|
+
export declare class ChildAtCapacity extends ChildAtCapacity_base {
|
|
53
|
+
}
|
|
54
|
+
declare const ChildFailed_base: Schema.Class<ChildFailed, Schema.TaggedStruct<"ChildFailed", {
|
|
55
|
+
readonly child: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
56
|
+
readonly message: Schema.NonEmptyString;
|
|
57
|
+
}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/ChildFailed">>;
|
|
58
|
+
/** Child `child` failed to launch or lost its transport. */
|
|
59
|
+
export declare class ChildFailed extends ChildFailed_base {
|
|
60
|
+
}
|
|
61
|
+
declare const BudgetExceeded_base: Schema.Class<BudgetExceeded, Schema.TaggedStruct<"BudgetExceeded", {
|
|
62
|
+
readonly child: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
63
|
+
/** Admission's count of child requests, including the refused one. */
|
|
64
|
+
readonly attempted: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
65
|
+
}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/BudgetExceeded">>;
|
|
66
|
+
/** Admission refused child `child` because the Attempt's child-session budget is spent. */
|
|
67
|
+
export declare class BudgetExceeded extends BudgetExceeded_base {
|
|
68
|
+
}
|
|
69
|
+
/** A lifecycle event of an Attempt that the coordinator handles. */
|
|
70
|
+
export declare const CoordinatorEvent: Schema.Union<readonly [typeof AttemptStarted, typeof ChildReported, typeof ChildInterrupted, typeof ChildAtCapacity, typeof ChildFailed, typeof BudgetExceeded]>;
|
|
71
|
+
export type CoordinatorEvent = typeof CoordinatorEvent.Type;
|
|
72
|
+
declare const AttemptContext_base: Schema.Class<AttemptContext, Schema.Struct<{
|
|
73
|
+
/** The event being handled, always about the Attempt's latest child. */
|
|
74
|
+
readonly event: Schema.Union<readonly [typeof AttemptStarted, typeof ChildReported, typeof ChildInterrupted, typeof ChildAtCapacity, typeof ChildFailed, typeof BudgetExceeded]>;
|
|
75
|
+
readonly maxChildren: Schema.brand<Schema.Int, "ChildSessionBudget">;
|
|
76
|
+
}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/AttemptContext">>;
|
|
77
|
+
/** What a handler knows when it decides about `event`. */
|
|
78
|
+
export declare class AttemptContext extends AttemptContext_base {
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Completes the Attempt; `message` defaults to the child's report. Without `message`, an event
|
|
82
|
+
* other than a report takes its rule, because it has no report to complete with.
|
|
83
|
+
*/
|
|
84
|
+
export declare const Complete: Schema.TaggedStruct<"Complete", {
|
|
85
|
+
readonly message: Schema.optionalKey<Schema.NonEmptyString>;
|
|
86
|
+
}>;
|
|
87
|
+
/**
|
|
88
|
+
* Replaces the child; `assignment` defaults to `REPORTED_REPLACEMENT_ASSIGNMENT` with the child's
|
|
89
|
+
* report, or to `REPLACEMENT_ASSIGNMENT` for an interruption.
|
|
90
|
+
*/
|
|
91
|
+
export declare const RetryChild: Schema.TaggedStruct<"RetryChild", {
|
|
92
|
+
readonly assignment: Schema.optionalKey<Schema.NonEmptyString>;
|
|
93
|
+
}>;
|
|
94
|
+
/** Fails the Attempt with an unresolved blocker; `message` defaults to the child's report. */
|
|
95
|
+
export declare const Blocked: Schema.TaggedStruct<"Blocked", {
|
|
96
|
+
readonly message: Schema.optionalKey<Schema.NonEmptyString>;
|
|
97
|
+
}>;
|
|
98
|
+
/** Fails the Attempt with a question for the operator. */
|
|
99
|
+
export declare const Question: Schema.TaggedStruct<"Question", {
|
|
100
|
+
readonly question: Schema.NonEmptyString;
|
|
101
|
+
}>;
|
|
102
|
+
/** Fails the Attempt with a failure that waits for the operator. */
|
|
103
|
+
export declare const Failed: Schema.TaggedStruct<"Failed", {
|
|
104
|
+
readonly message: Schema.NonEmptyString;
|
|
105
|
+
}>;
|
|
106
|
+
/** Fails the Attempt with an infrastructure failure, which the engine retries from salvage. */
|
|
107
|
+
export declare const InfraFailed: Schema.TaggedStruct<"InfraFailed", {
|
|
108
|
+
readonly message: Schema.NonEmptyString;
|
|
109
|
+
}>;
|
|
110
|
+
/** Fails the Attempt with a provider capacity refusal, which the engine retries after a delay. */
|
|
111
|
+
export declare const AtCapacity: Schema.TaggedStruct<"AtCapacity", {
|
|
112
|
+
readonly message: Schema.NonEmptyString;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* A model handler's answer to one event. `clamp` checks it against the event, so free text is
|
|
116
|
+
* optional wherever the event supplies it.
|
|
117
|
+
*/
|
|
118
|
+
export declare const ModelDecision: Schema.Union<readonly [Schema.TaggedStruct<"Complete", {
|
|
119
|
+
readonly message: Schema.optionalKey<Schema.NonEmptyString>;
|
|
120
|
+
}>, Schema.TaggedStruct<"RetryChild", {
|
|
121
|
+
readonly assignment: Schema.optionalKey<Schema.NonEmptyString>;
|
|
122
|
+
}>, Schema.TaggedStruct<"Blocked", {
|
|
123
|
+
readonly message: Schema.optionalKey<Schema.NonEmptyString>;
|
|
124
|
+
}>, Schema.TaggedStruct<"Question", {
|
|
125
|
+
readonly question: Schema.NonEmptyString;
|
|
126
|
+
}>, Schema.TaggedStruct<"Failed", {
|
|
127
|
+
readonly message: Schema.NonEmptyString;
|
|
128
|
+
}>, Schema.TaggedStruct<"InfraFailed", {
|
|
129
|
+
readonly message: Schema.NonEmptyString;
|
|
130
|
+
}>, Schema.TaggedStruct<"AtCapacity", {
|
|
131
|
+
readonly message: Schema.NonEmptyString;
|
|
132
|
+
}>]>;
|
|
133
|
+
export type ModelDecision = typeof ModelDecision.Type;
|
|
134
|
+
/** A rule's answer to one event: a `ModelDecision`, or a start or budget refusal only a rule makes. */
|
|
135
|
+
export declare const Decision: Schema.Union<readonly [Schema.TaggedStruct<"StartChild", {}>, Schema.TaggedStruct<"Complete", {
|
|
136
|
+
readonly message: Schema.optionalKey<Schema.NonEmptyString>;
|
|
137
|
+
}>, Schema.TaggedStruct<"RetryChild", {
|
|
138
|
+
readonly assignment: Schema.optionalKey<Schema.NonEmptyString>;
|
|
139
|
+
}>, Schema.TaggedStruct<"Blocked", {
|
|
140
|
+
readonly message: Schema.optionalKey<Schema.NonEmptyString>;
|
|
141
|
+
}>, Schema.TaggedStruct<"Question", {
|
|
142
|
+
readonly question: Schema.NonEmptyString;
|
|
143
|
+
}>, Schema.TaggedStruct<"Failed", {
|
|
144
|
+
readonly message: Schema.NonEmptyString;
|
|
145
|
+
}>, Schema.TaggedStruct<"InfraFailed", {
|
|
146
|
+
readonly message: Schema.NonEmptyString;
|
|
147
|
+
}>, Schema.TaggedStruct<"AtCapacity", {
|
|
148
|
+
readonly message: Schema.NonEmptyString;
|
|
149
|
+
}>, Schema.TaggedStruct<"OverBudget", {
|
|
150
|
+
readonly attempted: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
151
|
+
}>]>;
|
|
152
|
+
export type Decision = typeof Decision.Type;
|
|
153
|
+
/** A decision that `clamp` checked against its event, with every default resolved. */
|
|
154
|
+
declare const ClampedDecision: Schema.Union<readonly [Schema.TaggedStruct<"Start", {}>, Schema.TaggedStruct<"Replace", {
|
|
155
|
+
readonly replaces: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
156
|
+
readonly assignment: Schema.NonEmptyString;
|
|
157
|
+
}>, Schema.TaggedStruct<"Settle", {
|
|
158
|
+
/** The child whose event this outcome answers. */
|
|
159
|
+
readonly answering: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
160
|
+
readonly outcome: Schema.Union<readonly [Schema.TaggedStruct<"AttemptCompleted", {
|
|
161
|
+
readonly message: Schema.NonEmptyString;
|
|
162
|
+
readonly answeredOperator: Schema.Boolean;
|
|
163
|
+
}>, Schema.TaggedStruct<"AttemptFailed", {
|
|
164
|
+
readonly failure: Schema.Union<readonly [typeof import("@usine/core/attempt/failure").GitHubPushFailure, typeof InfraFailure, typeof ProviderCapacityFailure, typeof import("@usine/core/attempt/failure").DefectFailure, typeof AgentFailure, typeof BlockedFailure, typeof QuestionFailure, typeof import("@usine/core/attempt/failure").RunawayFailure, typeof ChildSessionBudgetFailure]>;
|
|
165
|
+
}>]>;
|
|
166
|
+
}>]>;
|
|
167
|
+
export type ClampedDecision = typeof ClampedDecision.Type;
|
|
168
|
+
/**
|
|
169
|
+
* An effect that runs after its transition commits: start a child, finish the Attempt, or log why
|
|
170
|
+
* the decision changed nothing.
|
|
171
|
+
*/
|
|
172
|
+
export declare const EffectIntent: Schema.Union<readonly [Schema.TaggedStruct<"Delegate", {
|
|
173
|
+
/** The child's 1-based number in the Attempt, which is also its child-session budget slot. */
|
|
174
|
+
readonly child: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
175
|
+
readonly assignment: Schema.NonEmptyString;
|
|
176
|
+
}>, Schema.TaggedStruct<"Finish", {
|
|
177
|
+
readonly outcome: Schema.Union<readonly [Schema.TaggedStruct<"AttemptCompleted", {
|
|
178
|
+
readonly message: Schema.NonEmptyString;
|
|
179
|
+
readonly answeredOperator: Schema.Boolean;
|
|
180
|
+
}>, Schema.TaggedStruct<"AttemptFailed", {
|
|
181
|
+
readonly failure: Schema.Union<readonly [typeof import("@usine/core/attempt/failure").GitHubPushFailure, typeof InfraFailure, typeof ProviderCapacityFailure, typeof import("@usine/core/attempt/failure").DefectFailure, typeof AgentFailure, typeof BlockedFailure, typeof QuestionFailure, typeof import("@usine/core/attempt/failure").RunawayFailure, typeof ChildSessionBudgetFailure]>;
|
|
182
|
+
}>]>;
|
|
183
|
+
}>, Schema.TaggedStruct<"Ignored", {
|
|
184
|
+
readonly reason: Schema.Union<readonly [Schema.TaggedStruct<"AttemptSettled", {}>, Schema.TaggedStruct<"AlreadyStarted", {}>, Schema.TaggedStruct<"NotStarted", {
|
|
185
|
+
readonly answering: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
186
|
+
}>, Schema.TaggedStruct<"StaleChild", {
|
|
187
|
+
readonly answering: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
188
|
+
readonly latest: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
189
|
+
}>]>;
|
|
190
|
+
}>]>;
|
|
191
|
+
export type EffectIntent = typeof EffectIntent.Type;
|
|
192
|
+
declare const AwaitingStart_base: Schema.Class<AwaitingStart, Schema.TaggedStruct<"AwaitingStart", {}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/AwaitingStart">>;
|
|
193
|
+
/** The Attempt hasn't started its first child. */
|
|
194
|
+
export declare class AwaitingStart extends AwaitingStart_base {
|
|
195
|
+
}
|
|
196
|
+
declare const Delegating_base: Schema.Class<Delegating, Schema.TaggedStruct<"Delegating", {
|
|
197
|
+
/** The latest child, whose events the coordinator handles. */
|
|
198
|
+
readonly child: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
199
|
+
}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/Delegating">>;
|
|
200
|
+
declare class Delegating extends Delegating_base {
|
|
201
|
+
}
|
|
202
|
+
declare const Settled_base: Schema.Class<Settled, Schema.TaggedStruct<"Settled", {
|
|
203
|
+
readonly outcome: Schema.Union<readonly [Schema.TaggedStruct<"AttemptCompleted", {
|
|
204
|
+
readonly message: Schema.NonEmptyString;
|
|
205
|
+
readonly answeredOperator: Schema.Boolean;
|
|
206
|
+
}>, Schema.TaggedStruct<"AttemptFailed", {
|
|
207
|
+
readonly failure: Schema.Union<readonly [typeof import("@usine/core/attempt/failure").GitHubPushFailure, typeof InfraFailure, typeof ProviderCapacityFailure, typeof import("@usine/core/attempt/failure").DefectFailure, typeof AgentFailure, typeof BlockedFailure, typeof QuestionFailure, typeof import("@usine/core/attempt/failure").RunawayFailure, typeof ChildSessionBudgetFailure]>;
|
|
208
|
+
}>]>;
|
|
209
|
+
}>, Brand.Brand<"@usine/durable/attempt/coordinator/rules/Settled">>;
|
|
210
|
+
declare class Settled extends Settled_base {
|
|
211
|
+
}
|
|
212
|
+
/** The coordinator's state, committed with each transition. */
|
|
213
|
+
export declare const CoordinatorState: Schema.Union<readonly [typeof AwaitingStart, typeof Delegating, typeof Settled]>;
|
|
214
|
+
export type CoordinatorState = typeof CoordinatorState.Type;
|
|
215
|
+
/** Returns the rule's decision for `event`. */
|
|
216
|
+
export declare const ruleFor: (event: CoordinatorEvent, context: AttemptContext) => Decision;
|
|
217
|
+
/**
|
|
218
|
+
* Checks `decision` against `context.event`. A reserved marker and the other typed facts keep their
|
|
219
|
+
* rule over any decision, a rule-only tag about a child takes the event's rule, and a replacement
|
|
220
|
+
* past the child-session budget becomes `Failed`.
|
|
221
|
+
*/
|
|
222
|
+
export declare const clamp: (decision: Decision, context: AttemptContext) => ClampedDecision;
|
|
223
|
+
type Transition = readonly [CoordinatorState, ReadonlyArray<EffectIntent>];
|
|
224
|
+
/**
|
|
225
|
+
* Returns the next state and the effect intents for `decision`. A decision about a child other
|
|
226
|
+
* than the latest one, a repeated start, and anything after the Attempt settled leave the state
|
|
227
|
+
* unchanged and return one `Ignored` intent, so each interruption gets at most one replacement.
|
|
228
|
+
*/
|
|
229
|
+
export declare const apply: (state: CoordinatorState, decision: ClampedDecision) => Transition;
|
|
230
|
+
export {};
|
|
231
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/attempt/coordinator/rules.ts"],"names":[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MAAM,OAAO,UAAW,gBAAgB,WAAW,cAAc,KAAG,QAiBvE,CAAC;AA2EL;;;;GAIG;AACH,eAAO,MAAM,KAAK,aAAc,QAAQ,WAAW,cAAc,KAAG,eAInE,CAAC;AAEF,KAAK,UAAU,GAAG,SAAS,CAAC,gBAAgB,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;AAO3E;;;;GAIG;AACH,eAAO,MAAM,KAAK,UAAW,gBAAgB,YAAY,eAAe,KAAG,UAsB1E,CAAC"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { ChildSessionBudget, ChildSessionCount } from "@usine/core/agent/session";
|
|
2
|
+
import { AgentFailure, AttemptFailure, BlockedFailure, ChildSessionBudgetFailure, InfraFailure, ProviderCapacityFailure, QuestionFailure, } from "@usine/core/attempt/failure";
|
|
3
|
+
import { Match, Option, Schema } from "effect";
|
|
4
|
+
/** The supplemental context of an Attempt's first child. */
|
|
5
|
+
export const FIRST_ASSIGNMENT = "Complete the delegated task in this checkout and give the result as your final answer.";
|
|
6
|
+
/** The default supplemental context of a child that replaces an interrupted one. */
|
|
7
|
+
export const REPLACEMENT_ASSIGNMENT = "The previous child session stopped before it finished, and it couldn't resume. The checkout keeps everything it did: inspect the checkout and continue the task from its current state.";
|
|
8
|
+
/**
|
|
9
|
+
* The default supplemental context of a child that replaces one that reported, before the
|
|
10
|
+
* previous child's report.
|
|
11
|
+
*/
|
|
12
|
+
export const REPORTED_REPLACEMENT_ASSIGNMENT = "The previous child session finished, but its work isn't done. The checkout keeps everything it did: read its final report below, inspect the checkout, and continue the task from its current state.";
|
|
13
|
+
/** The Attempt's message when its child finished with a blank report. */
|
|
14
|
+
export const BLANK_REPORT_MESSAGE = "The child session finished without a report";
|
|
15
|
+
/** The reserved marker that a child's final report starts with: blocker, question, or harness failure. */
|
|
16
|
+
export const ReservedKind = Schema.Literals(["blocked", "question", "failed"]);
|
|
17
|
+
/** A final report that starts with a reserved marker. */
|
|
18
|
+
export class ReservedReport extends Schema.Class("@usine/durable/coordinator/ReservedReport")({
|
|
19
|
+
kind: ReservedKind,
|
|
20
|
+
/** The report text after the marker. */
|
|
21
|
+
message: Schema.NonEmptyString,
|
|
22
|
+
}) {
|
|
23
|
+
}
|
|
24
|
+
/** The Attempt started and has no child yet. */
|
|
25
|
+
export class AttemptStarted extends Schema.TaggedClass("@usine/durable/coordinator/AttemptStarted")("AttemptStarted", {}) {
|
|
26
|
+
}
|
|
27
|
+
/** Child `child` finished its work with a final report. */
|
|
28
|
+
export class ChildReported extends Schema.TaggedClass("@usine/durable/coordinator/ChildReported")("ChildReported", {
|
|
29
|
+
child: ChildSessionCount,
|
|
30
|
+
report: Schema.String,
|
|
31
|
+
/** Whether the turn that produced the report started from an operator message (ADR 0018). */
|
|
32
|
+
answeredOperator: Schema.Boolean,
|
|
33
|
+
/** The report's reserved marker, or `None` for an ordinary report. */
|
|
34
|
+
reserved: Schema.OptionFromNullOr(ReservedReport),
|
|
35
|
+
}) {
|
|
36
|
+
}
|
|
37
|
+
/** Child `child` stopped and can't resume: no saved session, worker or checkout gone, or resume refused. */
|
|
38
|
+
export class ChildInterrupted extends Schema.TaggedClass("@usine/durable/coordinator/ChildInterrupted")("ChildInterrupted", {
|
|
39
|
+
child: ChildSessionCount,
|
|
40
|
+
reason: Schema.NonEmptyString,
|
|
41
|
+
}) {
|
|
42
|
+
}
|
|
43
|
+
/** The model provider of child `child` refused it for lack of capacity. */
|
|
44
|
+
export class ChildAtCapacity extends Schema.TaggedClass("@usine/durable/coordinator/ChildAtCapacity")("ChildAtCapacity", {
|
|
45
|
+
child: ChildSessionCount,
|
|
46
|
+
message: Schema.NonEmptyString,
|
|
47
|
+
}) {
|
|
48
|
+
}
|
|
49
|
+
/** Child `child` failed to launch or lost its transport. */
|
|
50
|
+
export class ChildFailed extends Schema.TaggedClass("@usine/durable/coordinator/ChildFailed")("ChildFailed", {
|
|
51
|
+
child: ChildSessionCount,
|
|
52
|
+
message: Schema.NonEmptyString,
|
|
53
|
+
}) {
|
|
54
|
+
}
|
|
55
|
+
/** Admission refused child `child` because the Attempt's child-session budget is spent. */
|
|
56
|
+
export class BudgetExceeded extends Schema.TaggedClass("@usine/durable/coordinator/BudgetExceeded")("BudgetExceeded", {
|
|
57
|
+
child: ChildSessionCount,
|
|
58
|
+
/** Admission's count of child requests, including the refused one. */
|
|
59
|
+
attempted: ChildSessionCount,
|
|
60
|
+
}) {
|
|
61
|
+
}
|
|
62
|
+
/** A lifecycle event of an Attempt that the coordinator handles. */
|
|
63
|
+
export const CoordinatorEvent = Schema.Union([
|
|
64
|
+
AttemptStarted,
|
|
65
|
+
ChildReported,
|
|
66
|
+
ChildInterrupted,
|
|
67
|
+
ChildAtCapacity,
|
|
68
|
+
ChildFailed,
|
|
69
|
+
BudgetExceeded,
|
|
70
|
+
]);
|
|
71
|
+
/** What a handler knows when it decides about `event`. */
|
|
72
|
+
export class AttemptContext extends Schema.Class("@usine/durable/coordinator/AttemptContext")({
|
|
73
|
+
/** The event being handled, always about the Attempt's latest child. */
|
|
74
|
+
event: CoordinatorEvent,
|
|
75
|
+
maxChildren: ChildSessionBudget,
|
|
76
|
+
}) {
|
|
77
|
+
}
|
|
78
|
+
/** Starts the Attempt's first child. */
|
|
79
|
+
const StartChild = Schema.TaggedStruct("StartChild", {});
|
|
80
|
+
/**
|
|
81
|
+
* Completes the Attempt; `message` defaults to the child's report. Without `message`, an event
|
|
82
|
+
* other than a report takes its rule, because it has no report to complete with.
|
|
83
|
+
*/
|
|
84
|
+
export const Complete = Schema.TaggedStruct("Complete", {
|
|
85
|
+
message: Schema.optionalKey(Schema.NonEmptyString),
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Replaces the child; `assignment` defaults to `REPORTED_REPLACEMENT_ASSIGNMENT` with the child's
|
|
89
|
+
* report, or to `REPLACEMENT_ASSIGNMENT` for an interruption.
|
|
90
|
+
*/
|
|
91
|
+
export const RetryChild = Schema.TaggedStruct("RetryChild", {
|
|
92
|
+
assignment: Schema.optionalKey(Schema.NonEmptyString),
|
|
93
|
+
});
|
|
94
|
+
/** Fails the Attempt with an unresolved blocker; `message` defaults to the child's report. */
|
|
95
|
+
export const Blocked = Schema.TaggedStruct("Blocked", {
|
|
96
|
+
message: Schema.optionalKey(Schema.NonEmptyString),
|
|
97
|
+
});
|
|
98
|
+
/** Fails the Attempt with a question for the operator. */
|
|
99
|
+
export const Question = Schema.TaggedStruct("Question", { question: Schema.NonEmptyString });
|
|
100
|
+
/** Fails the Attempt with a failure that waits for the operator. */
|
|
101
|
+
export const Failed = Schema.TaggedStruct("Failed", { message: Schema.NonEmptyString });
|
|
102
|
+
/** Fails the Attempt with an infrastructure failure, which the engine retries from salvage. */
|
|
103
|
+
export const InfraFailed = Schema.TaggedStruct("InfraFailed", { message: Schema.NonEmptyString });
|
|
104
|
+
/** Fails the Attempt with a provider capacity refusal, which the engine retries after a delay. */
|
|
105
|
+
export const AtCapacity = Schema.TaggedStruct("AtCapacity", { message: Schema.NonEmptyString });
|
|
106
|
+
/** Fails the Attempt because admission refused a child over the budget. */
|
|
107
|
+
const OverBudget = Schema.TaggedStruct("OverBudget", { attempted: ChildSessionCount });
|
|
108
|
+
/**
|
|
109
|
+
* A model handler's answer to one event. `clamp` checks it against the event, so free text is
|
|
110
|
+
* optional wherever the event supplies it.
|
|
111
|
+
*/
|
|
112
|
+
export const ModelDecision = Schema.Union([
|
|
113
|
+
Complete,
|
|
114
|
+
RetryChild,
|
|
115
|
+
Blocked,
|
|
116
|
+
Question,
|
|
117
|
+
Failed,
|
|
118
|
+
InfraFailed,
|
|
119
|
+
AtCapacity,
|
|
120
|
+
]);
|
|
121
|
+
/** A rule's answer to one event: a `ModelDecision`, or a start or budget refusal only a rule makes. */
|
|
122
|
+
export const Decision = Schema.Union([StartChild, ...ModelDecision.members, OverBudget]);
|
|
123
|
+
const AttemptCompleted = Schema.TaggedStruct("AttemptCompleted", {
|
|
124
|
+
message: Schema.NonEmptyString,
|
|
125
|
+
answeredOperator: Schema.Boolean,
|
|
126
|
+
});
|
|
127
|
+
const AttemptFailed = Schema.TaggedStruct("AttemptFailed", { failure: AttemptFailure });
|
|
128
|
+
const TerminalOutcome = Schema.Union([AttemptCompleted, AttemptFailed]);
|
|
129
|
+
const Start = Schema.TaggedStruct("Start", {});
|
|
130
|
+
const Replace = Schema.TaggedStruct("Replace", {
|
|
131
|
+
replaces: ChildSessionCount,
|
|
132
|
+
assignment: Schema.NonEmptyString,
|
|
133
|
+
});
|
|
134
|
+
const Settle = Schema.TaggedStruct("Settle", {
|
|
135
|
+
/** The child whose event this outcome answers. */
|
|
136
|
+
answering: ChildSessionCount,
|
|
137
|
+
outcome: TerminalOutcome,
|
|
138
|
+
});
|
|
139
|
+
/** A decision that `clamp` checked against its event, with every default resolved. */
|
|
140
|
+
const ClampedDecision = Schema.Union([Start, Replace, Settle]);
|
|
141
|
+
const Delegate = Schema.TaggedStruct("Delegate", {
|
|
142
|
+
/** The child's 1-based number in the Attempt, which is also its child-session budget slot. */
|
|
143
|
+
child: ChildSessionCount,
|
|
144
|
+
assignment: Schema.NonEmptyString,
|
|
145
|
+
});
|
|
146
|
+
const Finish = Schema.TaggedStruct("Finish", { outcome: TerminalOutcome });
|
|
147
|
+
/** The decision came after the Attempt settled. */
|
|
148
|
+
const AttemptSettled = Schema.TaggedStruct("AttemptSettled", {});
|
|
149
|
+
/** A `Start` came after the first child started. */
|
|
150
|
+
const AlreadyStarted = Schema.TaggedStruct("AlreadyStarted", {});
|
|
151
|
+
/** A decision about child `answering` came before the first child started. */
|
|
152
|
+
const NotStarted = Schema.TaggedStruct("NotStarted", { answering: ChildSessionCount });
|
|
153
|
+
/** A decision about child `answering` came after child `latest` replaced it. */
|
|
154
|
+
const StaleChild = Schema.TaggedStruct("StaleChild", {
|
|
155
|
+
answering: ChildSessionCount,
|
|
156
|
+
latest: ChildSessionCount,
|
|
157
|
+
});
|
|
158
|
+
/** Why `apply` left the state unchanged. */
|
|
159
|
+
const IgnoredReason = Schema.Union([AttemptSettled, AlreadyStarted, NotStarted, StaleChild]);
|
|
160
|
+
/** `apply` ignored the decision; the coordinator logs `reason` at Info. */
|
|
161
|
+
const Ignored = Schema.TaggedStruct("Ignored", { reason: IgnoredReason });
|
|
162
|
+
/**
|
|
163
|
+
* An effect that runs after its transition commits: start a child, finish the Attempt, or log why
|
|
164
|
+
* the decision changed nothing.
|
|
165
|
+
*/
|
|
166
|
+
export const EffectIntent = Schema.Union([Delegate, Finish, Ignored]);
|
|
167
|
+
/** The Attempt hasn't started its first child. */
|
|
168
|
+
export class AwaitingStart extends Schema.TaggedClass("@usine/durable/coordinator/AwaitingStart")("AwaitingStart", {}) {
|
|
169
|
+
}
|
|
170
|
+
class Delegating extends Schema.TaggedClass("@usine/durable/coordinator/Delegating")("Delegating", {
|
|
171
|
+
/** The latest child, whose events the coordinator handles. */
|
|
172
|
+
child: ChildSessionCount,
|
|
173
|
+
}) {
|
|
174
|
+
}
|
|
175
|
+
class Settled extends Schema.TaggedClass("@usine/durable/coordinator/Settled")("Settled", { outcome: TerminalOutcome }) {
|
|
176
|
+
}
|
|
177
|
+
/** The coordinator's state, committed with each transition. */
|
|
178
|
+
export const CoordinatorState = Schema.Union([AwaitingStart, Delegating, Settled]);
|
|
179
|
+
const reservedDecision = {
|
|
180
|
+
blocked: (message) => Blocked.make({ message }),
|
|
181
|
+
question: (question) => Question.make({ question }),
|
|
182
|
+
failed: (message) => Failed.make({ message }),
|
|
183
|
+
};
|
|
184
|
+
/** Returns the rule's decision for `event`. */
|
|
185
|
+
export const ruleFor = (event, context) => Match.valueTags(event, {
|
|
186
|
+
AttemptStarted: () => StartChild.make({}),
|
|
187
|
+
ChildReported: ({ reserved }) => Option.match(reserved, {
|
|
188
|
+
onNone: () => Complete.make({}),
|
|
189
|
+
onSome: ({ kind, message }) => reservedDecision[kind](message),
|
|
190
|
+
}),
|
|
191
|
+
ChildInterrupted: ({ child, reason }) => child < context.maxChildren
|
|
192
|
+
? RetryChild.make({})
|
|
193
|
+
: InfraFailed.make({
|
|
194
|
+
message: `Child ${child} was interrupted and couldn't resume, and the ${context.maxChildren}-child budget has no room for a replacement: ${reason}`,
|
|
195
|
+
}),
|
|
196
|
+
ChildAtCapacity: ({ message }) => AtCapacity.make({ message }),
|
|
197
|
+
ChildFailed: ({ message }) => InfraFailed.make({ message }),
|
|
198
|
+
BudgetExceeded: ({ attempted }) => OverBudget.make({ attempted }),
|
|
199
|
+
});
|
|
200
|
+
/** Whether a model may answer `event`; every other event takes its rule, so typed facts win. */
|
|
201
|
+
const modelEligible = (event) => event._tag === "ChildInterrupted" ||
|
|
202
|
+
(event._tag === "ChildReported" && Option.isNone(event.reserved));
|
|
203
|
+
const reportText = (event) => event.report.trim() === "" ? BLANK_REPORT_MESSAGE : event.report;
|
|
204
|
+
const defaultMessage = (event) => {
|
|
205
|
+
if (event._tag === "ChildReported")
|
|
206
|
+
return reportText(event);
|
|
207
|
+
if (event._tag === "ChildInterrupted")
|
|
208
|
+
return `Child ${event.child} was interrupted: ${event.reason}`;
|
|
209
|
+
if (event._tag === "BudgetExceeded")
|
|
210
|
+
return `Admission refused child ${event.child} over the child-session budget`;
|
|
211
|
+
return event.message;
|
|
212
|
+
};
|
|
213
|
+
/** The replacement's context: a reported child's report, or the interruption's default. */
|
|
214
|
+
const defaultAssignment = (event) => event._tag === "ChildReported"
|
|
215
|
+
? `${REPORTED_REPLACEMENT_ASSIGNMENT}\n\n${reportText(event).trim()}`
|
|
216
|
+
: REPLACEMENT_ASSIGNMENT;
|
|
217
|
+
const resolve = (decision, event, context) => {
|
|
218
|
+
const settle = (outcome) => Settle.make({ answering: event.child, outcome });
|
|
219
|
+
const fail = (failure) => settle(AttemptFailed.make({ failure }));
|
|
220
|
+
const byRule = () => resolve(ruleFor(event, context), event, context);
|
|
221
|
+
return Match.valueTags(decision, {
|
|
222
|
+
// Only a rule starts an Attempt or reports admission's count.
|
|
223
|
+
StartChild: byRule,
|
|
224
|
+
OverBudget: ({ attempted }) => event._tag === "BudgetExceeded"
|
|
225
|
+
? fail(ChildSessionBudgetFailure.make({
|
|
226
|
+
maxChildren: context.maxChildren,
|
|
227
|
+
attemptedChildren: attempted,
|
|
228
|
+
}))
|
|
229
|
+
: byRule(),
|
|
230
|
+
RetryChild: ({ assignment }) => event.child < context.maxChildren
|
|
231
|
+
? Replace.make({
|
|
232
|
+
replaces: event.child,
|
|
233
|
+
assignment: assignment ?? defaultAssignment(event),
|
|
234
|
+
})
|
|
235
|
+
: fail(AgentFailure.make({
|
|
236
|
+
message: `Child ${event.child} needed a replacement, but the Attempt has used its ${context.maxChildren}-child budget`,
|
|
237
|
+
})),
|
|
238
|
+
Complete: ({ message }) => message === undefined && event._tag !== "ChildReported"
|
|
239
|
+
? // Only a report supplies a success message; no rule for another event completes.
|
|
240
|
+
byRule()
|
|
241
|
+
: settle(AttemptCompleted.make({
|
|
242
|
+
message: message ?? defaultMessage(event),
|
|
243
|
+
answeredOperator: event._tag === "ChildReported" && event.answeredOperator,
|
|
244
|
+
})),
|
|
245
|
+
Blocked: ({ message }) => fail(BlockedFailure.make({ message: message ?? defaultMessage(event) })),
|
|
246
|
+
Question: ({ question }) => fail(QuestionFailure.make({ question })),
|
|
247
|
+
Failed: ({ message }) => fail(AgentFailure.make({ message })),
|
|
248
|
+
InfraFailed: ({ message }) => fail(InfraFailure.make({ message, cause: message })),
|
|
249
|
+
AtCapacity: ({ message }) => fail(ProviderCapacityFailure.make({ message })),
|
|
250
|
+
});
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Checks `decision` against `context.event`. A reserved marker and the other typed facts keep their
|
|
254
|
+
* rule over any decision, a rule-only tag about a child takes the event's rule, and a replacement
|
|
255
|
+
* past the child-session budget becomes `Failed`.
|
|
256
|
+
*/
|
|
257
|
+
export const clamp = (decision, context) => {
|
|
258
|
+
const { event } = context;
|
|
259
|
+
if (event._tag === "AttemptStarted")
|
|
260
|
+
return Start.make({});
|
|
261
|
+
return resolve(modelEligible(event) ? decision : ruleFor(event, context), event, context);
|
|
262
|
+
};
|
|
263
|
+
const ignore = (state, reason) => [
|
|
264
|
+
state,
|
|
265
|
+
[Ignored.make({ reason })],
|
|
266
|
+
];
|
|
267
|
+
/**
|
|
268
|
+
* Returns the next state and the effect intents for `decision`. A decision about a child other
|
|
269
|
+
* than the latest one, a repeated start, and anything after the Attempt settled leave the state
|
|
270
|
+
* unchanged and return one `Ignored` intent, so each interruption gets at most one replacement.
|
|
271
|
+
*/
|
|
272
|
+
export const apply = (state, decision) => {
|
|
273
|
+
if (state._tag === "Settled")
|
|
274
|
+
return ignore(state, AttemptSettled.make({}));
|
|
275
|
+
if (decision._tag === "Start") {
|
|
276
|
+
if (state._tag !== "AwaitingStart")
|
|
277
|
+
return ignore(state, AlreadyStarted.make({}));
|
|
278
|
+
const child = ChildSessionCount.make(1);
|
|
279
|
+
return [Delegating.make({ child }), [Delegate.make({ child, assignment: FIRST_ASSIGNMENT })]];
|
|
280
|
+
}
|
|
281
|
+
const answering = decision._tag === "Replace" ? decision.replaces : decision.answering;
|
|
282
|
+
if (state._tag === "AwaitingStart")
|
|
283
|
+
return ignore(state, NotStarted.make({ answering }));
|
|
284
|
+
if (state.child !== answering)
|
|
285
|
+
return ignore(state, StaleChild.make({ answering, latest: state.child }));
|
|
286
|
+
if (decision._tag === "Replace") {
|
|
287
|
+
const child = ChildSessionCount.make(decision.replaces + 1);
|
|
288
|
+
return [
|
|
289
|
+
Delegating.make({ child }),
|
|
290
|
+
[Delegate.make({ child, assignment: decision.assignment })],
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
return [
|
|
294
|
+
Settled.make({ outcome: decision.outcome }),
|
|
295
|
+
[Finish.make({ outcome: decision.outcome })],
|
|
296
|
+
];
|
|
297
|
+
};
|
|
298
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../src/attempt/coordinator/rules.ts"],"names":[],"m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AC7C,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usine/durable",
|
|
3
|
-
"version": "0.3.1-next.
|
|
3
|
+
"version": "0.3.1-next.502.g1d9b8bf.1.1",
|
|
4
4
|
"description": "The usine Pi parent on pi-durable storage: one durable conversation per Attempt, resumed after an orchestrator restart.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@effect/platform-node": "4.0.6",
|
|
61
61
|
"@effect/platform-node-shared": "4.0.6",
|
|
62
62
|
"undici": "^8.12.2",
|
|
63
|
-
"@usine/agents": "0.7.1-next.
|
|
64
|
-
"@usine/core": "0.7.1-next.
|
|
63
|
+
"@usine/agents": "0.7.1-next.502.g1d9b8bf.1.1",
|
|
64
|
+
"@usine/core": "0.7.1-next.502.g1d9b8bf.1.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@effect/vitest": "4.0.6",
|