@systemfsoftware/effect-daemon-spec 3.0.10 → 3.0.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @systemfsoftware/effect-daemon-spec
2
2
 
3
+ ## 3.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Dependencies resolve to Effect 4.0.0-rc.116 and Vitest 5.
8
+
3
9
  ## 3.0.10
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -3,27 +3,27 @@ import { Cause, Context, Duration, Effect, Latch, Layer, Metric, Option, Schedul
3
3
  declare const DynamicLimitExceeded_base: Schema.Class<DynamicLimitExceeded, Schema.TaggedStruct<"DynamicLimitExceeded", {
4
4
  readonly limit: Schema.Int;
5
5
  }>, import("effect/Cause").YieldableError>;
6
- declare class DynamicLimitExceeded extends DynamicLimitExceeded_base {}
7
- interface DaemonHealth {
6
+ export declare class DynamicLimitExceeded extends DynamicLimitExceeded_base {}
7
+ export interface DaemonHealth {
8
8
  readonly name: string;
9
9
  readonly ready: Latch.Latch;
10
10
  readonly healthy: Latch.Latch;
11
11
  readonly paused: Latch.Latch;
12
12
  }
13
- interface SupervisorHealth {
13
+ export interface SupervisorHealth {
14
14
  readonly name: string;
15
15
  readonly ready: Latch.Latch;
16
16
  readonly healthy: Latch.Latch;
17
17
  readonly paused: Latch.Latch;
18
18
  readonly children: readonly (DaemonHealth | SupervisorHealth)[];
19
19
  }
20
- interface DynamicHandle<Args, R = never> {
20
+ export interface DynamicHandle<Args, R = never> {
21
21
  readonly health: SupervisorHealth;
22
22
  readonly startChild: (args: Args) => Effect.Effect<ChildRef, DynamicLimitExceeded, R>;
23
23
  readonly stopChild: (ref: Pick<ChildRef, 'id'>) => Effect.Effect<void>;
24
24
  readonly count: Effect.Effect<number>;
25
25
  }
26
- type ChildRef = {
26
+ export type ChildRef = {
27
27
  readonly id: number;
28
28
  readonly removed: Effect.Effect<void>;
29
29
  };
@@ -32,74 +32,74 @@ type ChildRef = {
32
32
  declare const LeaderLockNotAcquired_base: Schema.Class<LeaderLockNotAcquired, Schema.TaggedStruct<"LeaderLockNotAcquired", {
33
33
  readonly key: Schema.String;
34
34
  }>, import("effect/Cause").YieldableError>;
35
- declare class LeaderLockNotAcquired extends LeaderLockNotAcquired_base {}
35
+ export declare class LeaderLockNotAcquired extends LeaderLockNotAcquired_base {}
36
36
  declare const LeaderLockInfraError_base: Schema.Class<LeaderLockInfraError, Schema.TaggedStruct<"LeaderLockInfraError", {
37
37
  readonly key: Schema.String;
38
38
  readonly cause: Schema.Unknown;
39
39
  }>, import("effect/Cause").YieldableError>;
40
- declare class LeaderLockInfraError extends LeaderLockInfraError_base {}
41
- type LeaderLockAcquireError = LeaderLockNotAcquired | LeaderLockInfraError;
40
+ export declare class LeaderLockInfraError extends LeaderLockInfraError_base {}
41
+ export type LeaderLockAcquireError = LeaderLockNotAcquired | LeaderLockInfraError;
42
42
  //#endregion
43
43
  //#region src/LockPrimitive.schema.d.ts
44
44
  declare const LockPrimitiveError_base: Schema.Class<LockPrimitiveError, Schema.TaggedStruct<"LockPrimitiveError", {
45
45
  readonly key: Schema.String;
46
46
  readonly cause: Schema.Unknown;
47
47
  }>, import("effect/Cause").YieldableError>;
48
- declare class LockPrimitiveError extends LockPrimitiveError_base {}
48
+ export declare class LockPrimitiveError extends LockPrimitiveError_base {}
49
49
  //#endregion
50
50
  //#region src/LeaderLockAdapter.d.ts
51
- interface LeaderLockService {
51
+ export interface LeaderLockService {
52
52
  readonly withLock: <A, E, R>(key: string, self: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E | LeaderLockInfraError, R>;
53
53
  }
54
54
  declare const LeaderLock_base: Context.ServiceClass<LeaderLock, "@systemfsoftware/effect-daemon-spec/LeaderLockAdapter/LeaderLock", LeaderLockService>;
55
- declare class LeaderLock extends LeaderLock_base {
55
+ export declare class LeaderLock extends LeaderLock_base {
56
56
  static readonly Noop: Layer.Layer<LeaderLock>;
57
57
  }
58
- interface LockPrimitiveService {
58
+ export interface LockPrimitiveService {
59
59
  readonly tryAcquire: (key: string) => Effect.Effect<boolean, LockPrimitiveError, Scope.Scope>;
60
60
  }
61
61
  declare const LockPrimitive_base: Context.ServiceClass<LockPrimitive, "@systemfsoftware/effect-daemon-spec/LeaderLockAdapter/LockPrimitive", LockPrimitiveService>;
62
- declare class LockPrimitive extends LockPrimitive_base {}
63
- declare const LeaderLockFromPrimitive: Layer.Layer<LeaderLock, never, LockPrimitive>;
62
+ export declare class LockPrimitive extends LockPrimitive_base {}
63
+ export declare const LeaderLockFromPrimitive: Layer.Layer<LeaderLock, never, LockPrimitive>;
64
64
  //#endregion
65
65
  //#region src/Backoff.d.ts
66
- declare const cappedBackoff: (base: Duration.Input, cap: Duration.Input) => Schedule.Schedule<Duration.Duration>;
66
+ export declare const cappedBackoff: (base: Duration.Input, cap: Duration.Input) => Schedule.Schedule<Duration.Duration>;
67
67
  //#endregion
68
68
  //#region src/Brands.d.ts
69
- declare const WorkerTypeId: unique symbol;
70
- type WorkerTypeId = typeof WorkerTypeId;
71
- declare const SupervisorTypeId: unique symbol;
72
- type SupervisorTypeId = typeof SupervisorTypeId;
73
- declare const DynamicSpecTypeId: unique symbol;
74
- type DynamicSpecTypeId = typeof DynamicSpecTypeId;
69
+ export declare const WorkerTypeId: unique symbol;
70
+ export type WorkerTypeId = typeof WorkerTypeId;
71
+ export declare const SupervisorTypeId: unique symbol;
72
+ export type SupervisorTypeId = typeof SupervisorTypeId;
73
+ export declare const DynamicSpecTypeId: unique symbol;
74
+ export type DynamicSpecTypeId = typeof DynamicSpecTypeId;
75
75
  //#endregion
76
76
  //#region src/DaemonMetrics.d.ts
77
- declare const supervisorRestartsCounter: Metric.Counter<number>;
78
- declare const supervisorExhaustionsCounter: Metric.Counter<number>;
79
- declare const supervisorChildrenGauge: Metric.Gauge<number>;
80
- declare const healthStateGauge: Metric.Gauge<number>;
77
+ export declare const supervisorRestartsCounter: Metric.Counter<number>;
78
+ export declare const supervisorExhaustionsCounter: Metric.Counter<number>;
79
+ export declare const supervisorChildrenGauge: Metric.Gauge<number>;
80
+ export declare const healthStateGauge: Metric.Gauge<number>;
81
81
  //#endregion
82
82
  //#region src/DaemonPolicy.schema.d.ts
83
- declare const IntensityConfig: Schema.Struct<{
83
+ export declare const IntensityConfig: Schema.Struct<{
84
84
  readonly restarts: Schema.Int;
85
85
  readonly window: Schema.Duration;
86
86
  }>;
87
- type IntensityConfig = typeof IntensityConfig.Type;
87
+ export type IntensityConfig = typeof IntensityConfig.Type;
88
88
  declare const IntensityTypeId: unique symbol;
89
89
  type IntensityTypeId = typeof IntensityTypeId;
90
90
  declare const BoundedIntensity_base: Schema.Class<BoundedIntensity, Schema.TaggedStruct<"Bounded", {
91
91
  readonly restarts: Schema.Int;
92
92
  readonly window: Schema.Duration;
93
93
  }>, {}>;
94
- declare class BoundedIntensity extends BoundedIntensity_base {
94
+ export declare class BoundedIntensity extends BoundedIntensity_base {
95
95
  readonly [IntensityTypeId]: symbol;
96
96
  }
97
97
  declare const UnboundedIntensity_base: Schema.Class<UnboundedIntensity, Schema.TaggedStruct<"Unbounded", {}>, {}>;
98
- declare class UnboundedIntensity extends UnboundedIntensity_base {
98
+ export declare class UnboundedIntensity extends UnboundedIntensity_base {
99
99
  readonly [IntensityTypeId]: symbol;
100
100
  }
101
- declare const Intensity: Schema.Union<readonly [typeof BoundedIntensity, typeof UnboundedIntensity]>;
102
- type Intensity = typeof Intensity.Type;
101
+ export declare const Intensity: Schema.Union<readonly [typeof BoundedIntensity, typeof UnboundedIntensity]>;
102
+ export type Intensity = typeof Intensity.Type;
103
103
  declare const ChildPolicyConfig_base: Schema.Class<ChildPolicyConfig, Schema.Struct<{
104
104
  readonly restart: Schema.optional<Schema.Literals<readonly ["permanent", "transient", "temporary"]>>;
105
105
  readonly intensity: Schema.optional<Schema.Struct<{
@@ -107,29 +107,29 @@ declare const ChildPolicyConfig_base: Schema.Class<ChildPolicyConfig, Schema.Str
107
107
  readonly window: Schema.Duration;
108
108
  }>>;
109
109
  }>, {}>;
110
- declare class ChildPolicyConfig extends ChildPolicyConfig_base {}
110
+ export declare class ChildPolicyConfig extends ChildPolicyConfig_base {}
111
111
  declare const LockPolicyConfig_base: Schema.Class<LockPolicyConfig, Schema.Struct<{
112
112
  readonly mode: Schema.optional<Schema.Literals<readonly ["none", "required", "optional"]>>;
113
113
  readonly key: Schema.optional<Schema.String>;
114
114
  }>, {}>;
115
- declare class LockPolicyConfig extends LockPolicyConfig_base {}
115
+ export declare class LockPolicyConfig extends LockPolicyConfig_base {}
116
116
  declare const TickPolicyConfig_base: Schema.Class<TickPolicyConfig, Schema.Struct<{
117
117
  readonly spanName: Schema.optional<Schema.String>;
118
118
  readonly tickTimeout: Schema.Duration;
119
119
  readonly startLogLevel: Schema.optional<Schema.Literals<readonly ["debug", "info"]>>;
120
120
  }>, {}>;
121
- declare class TickPolicyConfig extends TickPolicyConfig_base {}
122
- declare const MaxChildren: Schema.brand<Schema.Int, "MaxChildren">;
123
- type MaxChildren = typeof MaxChildren.Type;
121
+ export declare class TickPolicyConfig extends TickPolicyConfig_base {}
122
+ export declare const MaxChildren: Schema.brand<Schema.Int, "MaxChildren">;
123
+ export type MaxChildren = typeof MaxChildren.Type;
124
124
  //#endregion
125
125
  //#region src/DaemonReporterAdapter.d.ts
126
- interface DaemonReporterService {
126
+ export interface DaemonReporterService {
127
127
  readonly onRestart: (name: string, cause: Cause.Cause<never>) => Effect.Effect<void>;
128
128
  readonly onExhausted: (name: string, cause: Cause.Cause<never>) => Effect.Effect<void>;
129
129
  }
130
130
  declare const DaemonReporter_base: Context.ServiceClass<DaemonReporter, "@systemfsoftware/effect-daemon-spec/DaemonReporterAdapter/DaemonReporter", DaemonReporterService>;
131
- declare class DaemonReporter extends DaemonReporter_base {}
132
- declare const Noop: Layer.Layer<DaemonReporter>;
131
+ export declare class DaemonReporter extends DaemonReporter_base {}
132
+ export declare const Noop: Layer.Layer<DaemonReporter>;
133
133
  //#endregion
134
134
  //#region src/LoopTags.d.ts
135
135
  /**
@@ -138,21 +138,21 @@ declare const Noop: Layer.Layer<DaemonReporter>;
138
138
  * These tags are part of the published type identity of `poll`, `stream`,
139
139
  * and `subscription`. They are not unpublished wiring.
140
140
  */
141
- declare const PollLoopTag: {
141
+ export declare const PollLoopTag: {
142
142
  readonly _tag: 'Poll';
143
143
  };
144
- type PollLoopTag = typeof PollLoopTag;
145
- declare const StreamLoopTag: {
144
+ export type PollLoopTag = typeof PollLoopTag;
145
+ export declare const StreamLoopTag: {
146
146
  readonly _tag: 'Stream';
147
147
  };
148
- type StreamLoopTag = typeof StreamLoopTag;
149
- declare const SubscriptionLoopTag: {
148
+ export type StreamLoopTag = typeof StreamLoopTag;
149
+ export declare const SubscriptionLoopTag: {
150
150
  readonly _tag: 'Subscription';
151
151
  };
152
- type SubscriptionLoopTag = typeof SubscriptionLoopTag;
152
+ export type SubscriptionLoopTag = typeof SubscriptionLoopTag;
153
153
  //#endregion
154
154
  //#region src/DaemonSpec.schema.d.ts
155
- type LockConfig = {
155
+ export type LockConfig = {
156
156
  mode: 'none';
157
157
  } | {
158
158
  mode: 'optional';
@@ -162,14 +162,14 @@ type LockConfig = {
162
162
  key: string;
163
163
  acquireRetryBackoff: Schedule.Schedule<Duration.Duration>;
164
164
  };
165
- interface CommonOpts<L extends LockConfig> {
165
+ export interface CommonOpts<L extends LockConfig> {
166
166
  readonly name: string;
167
167
  readonly child?: ChildPolicyConfig;
168
168
  readonly tick: TickPolicyConfig;
169
169
  readonly tickHooks?: TickPolicyHooks;
170
170
  readonly lock: L;
171
171
  }
172
- type PollOpts<A, E, R, L extends LockConfig> = CommonOpts<L> & {
172
+ export type PollOpts<A, E, R, L extends LockConfig> = CommonOpts<L> & {
173
173
  readonly interval: Duration.Input;
174
174
  } & ({
175
175
  readonly prereq?: undefined;
@@ -178,27 +178,27 @@ type PollOpts<A, E, R, L extends LockConfig> = CommonOpts<L> & {
178
178
  readonly prereq: Effect.Effect<Option.Option<A>, E, R>;
179
179
  readonly work: (data: A) => Effect.Effect<void, E, R>;
180
180
  });
181
- interface TickPolicyHooks {
181
+ export interface TickPolicyHooks {
182
182
  readonly spanAttributes?: Effect.Effect<Record<string, string | number | boolean>>;
183
183
  readonly innerRetry?: Schedule.Schedule<unknown>;
184
184
  readonly trackDuration?: Metric.Histogram<Duration.Duration>;
185
185
  }
186
- interface ReporterPolicyHooks {
186
+ export interface ReporterPolicyHooks {
187
187
  readonly onRestart?: (cause: Cause.Cause<never>) => Effect.Effect<void>;
188
188
  readonly onExhausted?: (cause: Cause.Cause<never>) => Effect.Effect<void>;
189
189
  }
190
- interface PollLoop<E, R> extends PollLoopTag {
190
+ export interface PollLoop<E, R> extends PollLoopTag {
191
191
  readonly gate: Effect.Effect<Option.Option<Effect.Effect<void, E, R>>, E, R>;
192
192
  readonly interval: Duration.Input;
193
193
  }
194
- interface StreamLoop<E, R> extends StreamLoopTag {
194
+ export interface StreamLoop<E, R> extends StreamLoopTag {
195
195
  readonly stream: Stream.Stream<unknown, E, R>;
196
196
  }
197
- interface SubscriptionLoop<E, R> extends SubscriptionLoopTag {
197
+ export interface SubscriptionLoop<E, R> extends SubscriptionLoopTag {
198
198
  readonly acquire: Effect.Effect<void, E, R>;
199
199
  }
200
- type LoopShape<E, R> = PollLoop<E, R> | StreamLoop<E, R> | SubscriptionLoop<E, R>;
201
- interface Worker<E, R, L extends LockConfig = LockConfig> {
200
+ export type LoopShape<E, R> = PollLoop<E, R> | StreamLoop<E, R> | SubscriptionLoop<E, R>;
201
+ export interface Worker<E, R, L extends LockConfig = LockConfig> {
202
202
  readonly [WorkerTypeId]: WorkerTypeId;
203
203
  readonly name: string;
204
204
  readonly loop: LoopShape<E, R>;
@@ -207,7 +207,7 @@ interface Worker<E, R, L extends LockConfig = LockConfig> {
207
207
  readonly tickHooks: TickPolicyHooks;
208
208
  readonly lock: L;
209
209
  }
210
- interface Supervisor<E, R, L extends LockConfig = LockConfig> {
210
+ export interface Supervisor<E, R, L extends LockConfig = LockConfig> {
211
211
  readonly [SupervisorTypeId]: SupervisorTypeId;
212
212
  readonly name: string;
213
213
  readonly strategy: 'one_for_one' | 'one_for_all' | 'rest_for_one';
@@ -216,24 +216,24 @@ interface Supervisor<E, R, L extends LockConfig = LockConfig> {
216
216
  readonly lock: L;
217
217
  readonly reporter: ReporterPolicyHooks;
218
218
  }
219
- interface DynamicSpec<E, R, Args> {
219
+ export interface DynamicSpec<E, R, Args> {
220
220
  readonly [DynamicSpecTypeId]: DynamicSpecTypeId;
221
221
  readonly name: string;
222
222
  readonly child: (args: Args) => Worker<E, R>;
223
223
  readonly maxChildren: MaxChildren;
224
224
  }
225
- type Child<E, R> = Worker<E, R> | Supervisor<E, R>;
226
- interface SupervisionPolicy {
225
+ export type Child<E, R> = Worker<E, R> | Supervisor<E, R>;
226
+ export interface SupervisionPolicy {
227
227
  readonly intensity: Intensity;
228
228
  readonly backoff: Schedule.Schedule<Duration.Duration>;
229
229
  readonly cooldown: Duration.Input;
230
230
  }
231
- interface SupervisionConfig {
231
+ export interface SupervisionConfig {
232
232
  readonly backoffBase: Duration.Input;
233
233
  readonly intensity: Intensity;
234
234
  readonly cooldown: Duration.Input;
235
235
  }
236
- interface SupervisorOpts<E, R, L extends LockConfig> {
236
+ export interface SupervisorOpts<E, R, L extends LockConfig> {
237
237
  readonly name: string;
238
238
  readonly children: readonly Child<E, R>[];
239
239
  readonly supervision: Effect.Effect<SupervisionPolicy>;
@@ -251,7 +251,7 @@ declare const dynamic$1: <E, R, Args>(spec: DynamicSpec<E, R, Args>) => Effect.E
251
251
  * supervisor body via the lock binding. The body itself only ever sees the service
252
252
  * values.
253
253
  */
254
- declare const supervisor: <E, R>(s: Supervisor<E, R, LockConfig>) => Effect.Effect<SupervisorHealth, never, R | DaemonReporter | LeaderLock | Scope.Scope>;
254
+ export declare const supervisor: <E, R>(s: Supervisor<E, R, LockConfig>) => Effect.Effect<SupervisorHealth, never, R | DaemonReporter | LeaderLock | Scope.Scope>;
255
255
  //#endregion
256
256
  //#region src/RunWorker.d.ts
257
257
  /**
@@ -260,7 +260,7 @@ declare const supervisor: <E, R>(s: Supervisor<E, R, LockConfig>) => Effect.Effe
260
260
  * entry point never sees the tag. A worker whose lock is `{ mode: 'none' }`
261
261
  * takes no lock at all.
262
262
  */
263
- declare const worker: {
263
+ export declare const worker: {
264
264
  <E, R>(w: Worker<E, R, {
265
265
  mode: 'none';
266
266
  }>): Effect.Effect<DaemonHealth, never, R | Scope.Scope>;
@@ -276,34 +276,34 @@ interface LeaderLockOptions {
276
276
  /**
277
277
  * Runs `self` while holding the named leader lock.
278
278
  */
279
- declare function withLeaderLock<A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions, lock: LeaderLock['Service']): Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
279
+ export declare function withLeaderLock<A, E, R>(self: Effect.Effect<A, E, R>, options: LeaderLockOptions, lock: LeaderLock['Service']): Effect.Effect<A | void, E | LeaderLockAcquireError, R>;
280
280
  //#endregion
281
281
  //#region src/SupervisionCustom.d.ts
282
282
  declare const custom: <P>(policy: P) => Effect.Effect<P>;
283
283
  //#endregion
284
284
  //#region src/SupervisionLeader.d.ts
285
- declare const LeaderConfig: Context.Reference<SupervisionConfig>;
285
+ export declare const LeaderConfig: Context.Reference<SupervisionConfig>;
286
286
  //#endregion
287
287
  //#region src/SupervisionTask.d.ts
288
- declare const TaskConfig: Context.Reference<SupervisionConfig>;
288
+ export declare const TaskConfig: Context.Reference<SupervisionConfig>;
289
289
  //#endregion
290
290
  //#region src/SupervisionWorker.d.ts
291
- declare const WorkerConfig: Context.Reference<SupervisionConfig>;
291
+ export declare const WorkerConfig: Context.Reference<SupervisionConfig>;
292
292
  //#endregion
293
293
  //#region src/mod.d.ts
294
- declare const poll: <A, E, R, L extends LockConfig>(opts: PollOpts<A, E, R, L>) => Worker<E, R, L>;
295
- declare const stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
294
+ export declare const poll: <A, E, R, L extends LockConfig>(opts: PollOpts<A, E, R, L>) => Worker<E, R, L>;
295
+ export declare const stream: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
296
296
  readonly stream: Stream.Stream<A, E, R>;
297
297
  }) => Worker<E, R, L>;
298
- declare const subscription: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
298
+ export declare const subscription: <A, E, R, L extends LockConfig>(opts: CommonOpts<L> & {
299
299
  readonly acquire: Effect.Effect<A, E, R>;
300
300
  }) => Worker<E, R, L>;
301
- declare const Daemon: {
301
+ export declare const Daemon: {
302
302
  readonly poll: typeof poll;
303
303
  readonly stream: typeof stream;
304
304
  readonly subscription: typeof subscription;
305
305
  };
306
- declare const run: {
306
+ export declare const run: {
307
307
  readonly worker: {
308
308
  <E, R>(w: Worker<E, R, {
309
309
  mode: 'none';
@@ -313,22 +313,22 @@ declare const run: {
313
313
  readonly supervisor: typeof supervisor;
314
314
  readonly dynamic: typeof dynamic$1;
315
315
  };
316
- declare const leader: (cap: Duration.Input) => Effect.Effect<SupervisionPolicy>;
317
- declare const task: (budget: Duration.Input) => Effect.Effect<SupervisionPolicy>;
318
- declare const supervision: (cap: Duration.Input) => Effect.Effect<SupervisionPolicy>;
319
- declare const Supervision: {
316
+ export declare const leader: (cap: Duration.Input) => Effect.Effect<SupervisionPolicy>;
317
+ export declare const task: (budget: Duration.Input) => Effect.Effect<SupervisionPolicy>;
318
+ export declare const supervision: (cap: Duration.Input) => Effect.Effect<SupervisionPolicy>;
319
+ export declare const Supervision: {
320
320
  readonly leader: typeof leader;
321
321
  readonly worker: typeof supervision;
322
322
  readonly task: typeof task;
323
323
  readonly custom: typeof custom;
324
324
  };
325
- declare const dynamic: <E, R, Args>(opts: {
325
+ export declare const dynamic: <E, R, Args>(opts: {
326
326
  readonly name: string;
327
327
  readonly child: (args: Args) => Worker<E, R>;
328
328
  readonly maxChildren?: MaxChildren;
329
329
  }) => DynamicSpec<E, R, Args>;
330
- declare const oneForAll: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
331
- declare const oneForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
332
- declare const restForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
330
+ export declare const oneForAll: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
331
+ export declare const oneForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
332
+ export declare const restForOne: <E, R, L extends LockConfig = LockConfig>(opts: SupervisorOpts<E, R, L>) => Supervisor<E, R, L>;
333
333
  //#endregion
334
- export { BoundedIntensity, Child, ChildPolicyConfig, ChildRef, CommonOpts, Daemon, DaemonHealth, DaemonReporter, DaemonReporterService, DynamicHandle, DynamicLimitExceeded, DynamicSpec, DynamicSpecTypeId, Intensity, IntensityConfig, LeaderConfig, LeaderLock, LeaderLockAcquireError, LeaderLockFromPrimitive, LeaderLockInfraError, LeaderLockNotAcquired, type LeaderLockOptions, LeaderLockService, LockConfig, LockPolicyConfig, LockPrimitive, LockPrimitiveError, LockPrimitiveService, LoopShape, MaxChildren, Noop, PollLoop, PollLoopTag, PollOpts, ReporterPolicyHooks, StreamLoop, StreamLoopTag, SubscriptionLoop, SubscriptionLoopTag, Supervision, SupervisionConfig, SupervisionPolicy, Supervisor, SupervisorHealth, SupervisorOpts, SupervisorTypeId, TaskConfig, TickPolicyConfig, TickPolicyHooks, UnboundedIntensity, Worker, WorkerConfig, WorkerTypeId, cappedBackoff, dynamic, healthStateGauge, leader, oneForAll, oneForOne, poll, restForOne, run, stream, subscription, supervision, supervisor, supervisorChildrenGauge, supervisorExhaustionsCounter, supervisorRestartsCounter, task, withLeaderLock, worker };
334
+ export type { LeaderLockOptions };
package/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
- import { Array, Cause, Clock, Context, Duration, Effect, Equal, Exit, Fiber, HashMap, Latch, Layer, Match, Metric, Option, Predicate, Ref, Result, Schedule, Schema, Scope, Stream } from "effect";
2
- import { Cell, Workflow } from "@systemfsoftware/effect-cell-types";
1
+ import { Array, Cause, Clock, Context, Duration, Effect, Equal, Exit, Fiber, HashMap, Latch, Layer, Match, Metric, Option, Predicate, Ref, Result, Schedule, Schema, SchemaGetter, Scope, Stream } from "effect";
2
+ import { Sandwich, Workflow } from "@systemfsoftware/effect-cell-types";
3
3
  import * as Arr from "effect/Array";
4
4
  import * as Match$1 from "effect/Match";
5
+ import "effect/Option";
5
6
  import * as Result$1 from "effect/Result";
6
7
  import * as S from "effect/Schema";
7
8
  //#region src/Backoff.ts
@@ -95,9 +96,13 @@ const StreamLoopTag = { _tag: "Stream" };
95
96
  const SubscriptionLoopTag = { _tag: "Subscription" };
96
97
  //#endregion
97
98
  //#region src/DaemonPoll.ts
99
+ const orEmpty$2 = (value) => {
100
+ if (typeof value === "undefined") return {};
101
+ return value;
102
+ };
98
103
  const poll$1 = (opts) => {
99
104
  if (typeof opts.prereq === "undefined") {
100
- const gate = Effect.succeed(Option.some(Effect.asVoid(opts.work)));
105
+ const gate = Effect.succeedSome(Effect.asVoid(opts.work));
101
106
  return {
102
107
  [WorkerTypeId]: WorkerTypeId,
103
108
  name: opts.name,
@@ -106,9 +111,9 @@ const poll$1 = (opts) => {
106
111
  gate,
107
112
  interval: opts.interval
108
113
  },
109
- child: opts.child ?? {},
114
+ child: orEmpty$2(opts.child),
110
115
  tick: opts.tick,
111
- tickHooks: opts.tickHooks ?? {},
116
+ tickHooks: orEmpty$2(opts.tickHooks),
112
117
  lock: opts.lock
113
118
  };
114
119
  }
@@ -122,14 +127,18 @@ const poll$1 = (opts) => {
122
127
  gate,
123
128
  interval: opts.interval
124
129
  },
125
- child: opts.child ?? {},
130
+ child: orEmpty$2(opts.child),
126
131
  tick: opts.tick,
127
- tickHooks: opts.tickHooks ?? {},
132
+ tickHooks: orEmpty$2(opts.tickHooks),
128
133
  lock: opts.lock
129
134
  };
130
135
  };
131
136
  //#endregion
132
137
  //#region src/DaemonStream.ts
138
+ const orEmpty$1 = (value) => {
139
+ if (typeof value === "undefined") return {};
140
+ return value;
141
+ };
133
142
  const stream$1 = (opts) => ({
134
143
  [WorkerTypeId]: WorkerTypeId,
135
144
  name: opts.name,
@@ -137,13 +146,17 @@ const stream$1 = (opts) => ({
137
146
  ...StreamLoopTag,
138
147
  stream: opts.stream
139
148
  },
140
- child: opts.child ?? {},
149
+ child: orEmpty$1(opts.child),
141
150
  tick: opts.tick,
142
- tickHooks: opts.tickHooks ?? {},
151
+ tickHooks: orEmpty$1(opts.tickHooks),
143
152
  lock: opts.lock
144
153
  });
145
154
  //#endregion
146
155
  //#region src/DaemonSubscription.ts
156
+ const orEmpty = (value) => {
157
+ if (typeof value === "undefined") return {};
158
+ return value;
159
+ };
147
160
  const subscription$1 = (opts) => ({
148
161
  [WorkerTypeId]: WorkerTypeId,
149
162
  name: opts.name,
@@ -151,9 +164,9 @@ const subscription$1 = (opts) => ({
151
164
  ...SubscriptionLoopTag,
152
165
  acquire: Effect.asVoid(opts.acquire)
153
166
  },
154
- child: opts.child ?? {},
167
+ child: orEmpty(opts.child),
155
168
  tick: opts.tick,
156
- tickHooks: opts.tickHooks ?? {},
169
+ tickHooks: orEmpty(opts.tickHooks),
157
170
  lock: opts.lock
158
171
  });
159
172
  //#endregion
@@ -172,7 +185,7 @@ var LockPrimitiveError = class extends Schema.TaggedError()("LockPrimitiveError"
172
185
  //#endregion
173
186
  //#region src/LeaderLockAdapter.ts
174
187
  var LeaderLock = class LeaderLock extends Context.Service()("@systemfsoftware/effect-daemon-spec/LeaderLockAdapter/LeaderLock") {
175
- static Noop = Layer.succeed(LeaderLock, LeaderLock.of({ withLock: (_key, self) => Effect.map(self, Option.some) }));
188
+ static Noop = Layer.succeed(LeaderLock, LeaderLock.of({ withLock: (_key, self) => Effect.asSome(self) }));
176
189
  };
177
190
  var LockPrimitive = class extends Context.Service()("@systemfsoftware/effect-daemon-spec/LeaderLockAdapter/LockPrimitive") {};
178
191
  const LeaderLockFromPrimitive = Layer.effect(LeaderLock, Effect.gen(function* () {
@@ -440,10 +453,62 @@ const RestartStrategy = Schema.Literals([
440
453
  */
441
454
  const failedIndexAddressesAChild = (input) => input.failedIndex < input.totalChildren;
442
455
  /**
456
+ * The message the cross-field filter reports. One binding, referenced by the filter and
457
+ * by the law that asserts on it: a second copy would let the law pass against a message
458
+ * the schema no longer produces, which is the whole failure the law exists to catch.
459
+ */
460
+ const BOUND_MESSAGE = "failedIndex must be < totalChildren";
461
+ /**
462
+ * Constructive generation for the cross-field invariant. `failedIndexSeed` is independent
463
+ * of `totalChildren` and always in `0 .. MAX-1`; the command's `failedIndex` is that seed
464
+ * modulo `totalChildren`, so every generated sample satisfies `failedIndex < totalChildren`.
465
+ *
466
+ * `FilterConstraint` cannot express a relation between two fields. rc.116's constructor
467
+ * for that case is `toCodecArbitrary`, not an empty `arbitraryConstraint`.
468
+ */
469
+ const DecideInputGenerated = Schema.Struct({
470
+ strategy: RestartStrategy,
471
+ totalChildren: Schema.Int.pipe(Schema.check(Schema.isBetween({
472
+ minimum: 1,
473
+ maximum: MAX_CHILDREN_CEILING
474
+ }))),
475
+ failedIndexSeed: Schema.Int.pipe(Schema.check(Schema.isBetween({
476
+ minimum: 0,
477
+ maximum: 999
478
+ }))),
479
+ exitSuccess: Schema.Boolean,
480
+ intensityExceeded: Schema.Boolean
481
+ });
482
+ const commandFromGenerated = (generated) => ({
483
+ strategy: generated.strategy,
484
+ totalChildren: generated.totalChildren,
485
+ failedIndex: generated.failedIndexSeed % generated.totalChildren,
486
+ exitSuccess: generated.exitSuccess,
487
+ intensityExceeded: generated.intensityExceeded
488
+ });
489
+ const generatedFromCommand = (command) => ({
490
+ strategy: command.strategy,
491
+ totalChildren: command.totalChildren,
492
+ failedIndexSeed: command.failedIndex,
493
+ exitSuccess: command.exitSuccess,
494
+ intensityExceeded: command.intensityExceeded
495
+ });
496
+ const generatedLink = () => Schema.link()(DecideInputGenerated, {
497
+ decode: SchemaGetter.transform(commandFromGenerated),
498
+ encode: SchemaGetter.transform(generatedFromCommand)
499
+ });
500
+ /**
443
501
  * The command's field map and cross-field check, named so the class below extends a binding
444
502
  * rather than an inline factory call. An anonymous base adds a new `ae-forgotten-export`
445
503
  * `*_base` warning to the committed API report, which this package fixes at the source
446
504
  * instead of suppressing.
505
+ *
506
+ * `failedIndex` is at most `MAX_CHILDREN_CEILING - 1` because it must be strictly less
507
+ * than `totalChildren`, whose own maximum is the ceiling.
508
+ *
509
+ * The constructor hangs on the node as `toCodecArbitrary` *before* the check: a filter
510
+ * cannot construct a cross-field sample, and `.pipe(Schema.check)` would hide the
511
+ * annotation from the gate (the check receiver would be `Schema`, not this struct).
447
512
  */
448
513
  const DecideInputBase = Schema.Struct({
449
514
  strategy: RestartStrategy,
@@ -453,37 +518,27 @@ const DecideInputBase = Schema.Struct({
453
518
  }))),
454
519
  failedIndex: Schema.Int.pipe(Schema.check(Schema.isBetween({
455
520
  minimum: 0,
456
- maximum: MAX_CHILDREN_CEILING
521
+ maximum: 999
457
522
  }))),
458
523
  exitSuccess: Schema.Boolean,
459
524
  intensityExceeded: Schema.Boolean
460
- }).pipe(Schema.check(Schema.makeFilter(failedIndexAddressesAChild, {
461
- message: "failedIndex must be < totalChildren",
462
- arbitrary: { candidate: {
463
- weight: 20,
464
- make: (fc) => fc.integer({
465
- min: 1,
466
- max: MAX_CHILDREN_CEILING
467
- }).chain((totalChildren) => fc.record({
468
- strategy: fc.constantFrom("one_for_one", "one_for_all", "rest_for_one"),
469
- totalChildren: fc.constant(totalChildren),
470
- failedIndex: fc.integer({
471
- min: 0,
472
- max: totalChildren - 1
473
- }),
474
- exitSuccess: fc.boolean(),
475
- intensityExceeded: fc.boolean()
476
- }))
477
- } }
478
- })));
525
+ }).annotate({ toCodecArbitrary: generatedLink }).check(Schema.makeFilter(failedIndexAddressesAChild, { message: BOUND_MESSAGE }));
479
526
  /**
480
527
  * The restart command. A `Schema.Class` rather than a `Schema.Struct` because `Workflow.make`
481
528
  * takes the command's class as its first argument, and a struct carries no `identifier` and
482
529
  * no `extend` — the constraint refuses it. Every field schema and the cross-field check are
483
530
  * the ones the struct carried.
531
+ *
532
+ * Class-level `toCodecArbitrary` is what `Arbitrary.schema(DecideInput)` compiles. The
533
+ * self-reference is `Schema.suspend`, the same delay recursive schemas use: the thunk
534
+ * runs at derivation time, after the class exists. The return type is `SchemaAST.Link`
535
+ * so the heritage expression does not infer a cycle through `DecideInput`.
484
536
  */
485
537
  /** @internal */
486
- var DecideInput = class extends Schema.Class("DecideInput")(DecideInputBase) {};
538
+ var DecideInput = class DecideInput extends Schema.Class("DecideInput")(DecideInputBase, { toCodecArbitrary: () => Schema.link()(DecideInputGenerated, {
539
+ decode: SchemaGetter.transform((generated) => new DecideInput(commandFromGenerated(generated))),
540
+ encode: SchemaGetter.transform(generatedFromCommand)
541
+ }) }) {};
487
542
  //#endregion
488
543
  //#region src/internal/choose-restart-strategy.workflow.ts
489
544
  /**
@@ -591,22 +646,26 @@ var ContinueSupervision = class extends Schema.TaggedClass()("ContinueSupervisio
591
646
  Schema.Union([StopSupervision, ContinueSupervision]);
592
647
  //#endregion
593
648
  //#region src/WithLeaderLock.ts
649
+ const acquireWithLock = (self, options, lock) => Effect.gen(function* () {
650
+ const out = yield* lock.withLock(options.key, self);
651
+ if (Option.isSome(out)) return out.value;
652
+ return yield* Match.value(options.mode).pipe(Match.when("required", () => Effect.fail(LeaderLockNotAcquired.make({ key: options.key }))), Match.when("optional", () => Effect.void), Match.exhaustive);
653
+ });
654
+ const retryAcquire = (acquire, current) => Effect.retry(acquire, {
655
+ schedule: current,
656
+ while: Predicate.isTagged("LeaderLockNotAcquired")
657
+ }).pipe(Effect.catchTag("LeaderLockNotAcquired", () => retryAcquire(acquire, current)));
658
+ const withRequiredBackoff = (acquire, backoff) => {
659
+ if (typeof backoff === "undefined") return acquire;
660
+ return retryAcquire(acquire, backoff);
661
+ };
594
662
  /**
595
663
  * Runs `self` while holding the named leader lock.
596
664
  */
597
665
  function withLeaderLock(self, options, lock) {
598
- const acquire = Effect.gen(function* () {
599
- const out = yield* lock.withLock(options.key, self);
600
- if (Option.isSome(out)) return out.value;
601
- return yield* Match.value(options.mode).pipe(Match.when("required", () => Effect.fail(LeaderLockNotAcquired.make({ key: options.key }))), Match.when("optional", () => Effect.void), Match.exhaustive);
602
- });
603
- const retryOnce = (current) => Effect.retry(acquire, {
604
- schedule: current,
605
- while: Predicate.isTagged("LeaderLockNotAcquired")
606
- }).pipe(Effect.catchTag("LeaderLockNotAcquired", () => retryOnce(current)));
607
- const backoff = options.acquireRetryBackoff;
608
- if (options.mode === "required" && backoff !== null && typeof backoff === "object") return retryOnce(backoff);
609
- return acquire;
666
+ const acquire = acquireWithLock(self, options, lock);
667
+ if (options.mode !== "required") return acquire;
668
+ return withRequiredBackoff(acquire, options.acquireRetryBackoff);
610
669
  }
611
670
  //#endregion
612
671
  //#region src/internal/WithLockByModeExecutor.ts
@@ -623,18 +682,21 @@ function withLeaderLock(self, options, lock) {
623
682
  * The worker and the supervisor make the same choice over the same cases, so it is
624
683
  * made here once rather than in each of them.
625
684
  */
626
- /** @internal */
627
- const withLockByMode = (self, binding) => {
628
- if (binding.kind === "unlocked") return self;
629
- if (binding.spec.mode === "required") return withLeaderLock(self, {
630
- key: binding.spec.key,
685
+ const withKeyedLock = (self, spec, lock) => {
686
+ if (spec.mode === "required") return withLeaderLock(self, {
687
+ key: spec.key,
631
688
  mode: "required",
632
- acquireRetryBackoff: binding.spec.acquireRetryBackoff
633
- }, binding.lock);
689
+ acquireRetryBackoff: spec.acquireRetryBackoff
690
+ }, lock);
634
691
  return withLeaderLock(self, {
635
- key: binding.spec.key,
692
+ key: spec.key,
636
693
  mode: "optional"
637
- }, binding.lock);
694
+ }, lock);
695
+ };
696
+ /** @internal */
697
+ const withLockByMode = (self, binding) => {
698
+ if (binding.kind === "unlocked") return self;
699
+ return withKeyedLock(self, binding.spec, binding.lock);
638
700
  };
639
701
  //#endregion
640
702
  //#region src/internal/SupervisorBodyExecutor.ts
@@ -667,22 +729,16 @@ const handleRestart = (ctx, cause, onSignal) => Effect.gen(function* () {
667
729
  * phase signatures hand the command to the read alone. Restarts are rare, so the allocation is
668
730
  * paid only when a supervised child has actually died.
669
731
  */
670
- const restartDescription = (spec) => Cell.layer({
671
- read: (intensity) => Effect.andThen(intensity.record, intensity.isExceeded),
672
- decode: (intensityExceeded) => Result.succeed({
673
- strategy: spec.strategy,
674
- totalChildren: spec.totalChildren,
675
- failedIndex: spec.failedIndex,
676
- exitSuccess: false,
677
- intensityExceeded
678
- }),
679
- decide: chooseRestartStrategy,
680
- encode: (outcome) => outcome,
681
- write: (outcome) => Result.match(outcome, {
682
- onFailure: () => handleExhausted(spec.ctx, spec.cause),
683
- onSuccess: (right) => Match.value(right).pipe(Match.tag("Continue", () => Effect.succeed(StopEpoch.make())), Match.tag("Restart", (decision) => handleRestart(spec.ctx, spec.cause, spec.onRestart(decision))), Match.exhaustive)
684
- })
685
- });
732
+ const restartDescription = (spec) => Sandwich.read((intensity) => Effect.andThen(intensity.record, intensity.isExceeded)).decode(Sandwich.pure((intensityExceeded) => Result.succeed({
733
+ strategy: spec.strategy,
734
+ totalChildren: spec.totalChildren,
735
+ failedIndex: spec.failedIndex,
736
+ exitSuccess: false,
737
+ intensityExceeded
738
+ }))).decide(chooseRestartStrategy).encode(Sandwich.pure((outcome) => Result.succeed(outcome))).write((outcome) => Result.match(outcome, {
739
+ onFailure: () => handleExhausted(spec.ctx, spec.cause),
740
+ onSuccess: (right) => Match.value(right).pipe(Match.tag("Continue", () => Effect.succeed(StopEpoch.make())), Match.tag("Restart", (decision) => handleRestart(spec.ctx, spec.cause, spec.onRestart(decision))), Match.exhaustive)
741
+ }));
686
742
  const reopenHealthyAfterCooldown = (ctx) => Effect.andThen(ctx.health.healthy.open, Metric.update(Metric.withAttributes(healthStateGauge, {
687
743
  daemon: ctx.name,
688
744
  latch: "healthy"
@@ -726,10 +782,55 @@ const isChildIntensityBudgetDone = (tracker) => Option.match(tracker, {
726
782
  return yield* ci.isExceeded;
727
783
  })
728
784
  });
785
+ const childEpochOnRestartable = (ctx, idx, childIntensityOpt, supIntensity, cause) => Effect.gen(function* () {
786
+ if (yield* isChildIntensityBudgetDone(childIntensityOpt)) return StopEpoch.make();
787
+ return yield* restartDescription({
788
+ strategy: "one_for_one",
789
+ failedIndex: idx,
790
+ totalChildren: ctx.booted.length,
791
+ ctx,
792
+ cause,
793
+ onRestart: () => Effect.void
794
+ }).run(supIntensity);
795
+ });
796
+ const childEpochOnFailure = (ctx, child, idx, childIntensityOpt, supIntensity, cause) => {
797
+ if (child.childPolicy.restart === "temporary") return Effect.succeed(StopEpoch.make());
798
+ return childEpochOnRestartable(ctx, idx, childIntensityOpt, supIntensity, cause);
799
+ };
800
+ const childEpochOnExit = (ctx, child, idx, childIntensityOpt, supIntensity, exit) => {
801
+ if (Exit.isSuccess(exit)) return Effect.succeed(StopEpoch.make());
802
+ return childEpochOnFailure(ctx, child, idx, childIntensityOpt, supIntensity, exit.cause);
803
+ };
804
+ const groupEpochOnRestartable = (strategy, ctx, failedIdx, childIntensityTrackers, intensity, cursor, cause) => Effect.gen(function* () {
805
+ const cIntForFailed = Option.flatten(Array.get(childIntensityTrackers, failedIdx));
806
+ if (yield* isChildIntensityBudgetDone(cIntForFailed)) return StopEpoch.make();
807
+ return yield* restartDescription({
808
+ strategy,
809
+ failedIndex: failedIdx,
810
+ totalChildren: ctx.booted.length,
811
+ ctx,
812
+ cause,
813
+ onRestart: (decision) => Ref.set(cursor, decision.indices[0])
814
+ }).run(intensity);
815
+ });
816
+ const groupEpochOnFailedChild = (strategy, ctx, failedBooted, failedIdx, childIntensityTrackers, intensity, cursor, cause) => {
817
+ if (failedBooted.childPolicy.restart === "temporary") return Effect.succeed(StopEpoch.make());
818
+ return groupEpochOnRestartable(strategy, ctx, failedIdx, childIntensityTrackers, intensity, cursor, cause);
819
+ };
820
+ const groupEpochOnFailure = (strategy, ctx, startIdx, failedOffset, childIntensityTrackers, intensity, cursor, cause) => {
821
+ const failedIdx = startIdx + failedOffset;
822
+ const failedBootedOpt = Option.fromNullishOr(ctx.booted[failedIdx]);
823
+ if (Option.isNone(failedBootedOpt)) return Effect.succeed(StopEpoch.make());
824
+ return groupEpochOnFailedChild(strategy, ctx, failedBootedOpt.value, failedIdx, childIntensityTrackers, intensity, cursor, cause);
825
+ };
826
+ const groupEpochOnExit = (strategy, ctx, startIdx, childIntensityTrackers, intensity, cursor, failedOffset, firstExit) => {
827
+ if (Exit.isSuccess(firstExit)) return Effect.succeed(StopEpoch.make());
828
+ return groupEpochOnFailure(strategy, ctx, startIdx, failedOffset, childIntensityTrackers, intensity, cursor, firstExit.cause);
829
+ };
729
830
  const superviseChild = (ctx, child, idx) => Effect.gen(function* () {
730
831
  const childIntensityOpt = yield* Option.match(Option.fromNullishOr(child.childPolicy.intensity), {
731
832
  onNone: () => Effect.succeed(Option.none()),
732
- onSome: (cfg) => Effect.map(make(cfg.restarts, cfg.window), Option.some)
833
+ onSome: (cfg) => Effect.asSome(make(cfg.restarts, cfg.window))
733
834
  });
734
835
  const loop = () => Effect.gen(function* () {
735
836
  const supIntensity = yield* ctx.intensityEff;
@@ -737,19 +838,7 @@ const superviseChild = (ctx, child, idx) => Effect.gen(function* () {
737
838
  yield* ctx.health.paused.await;
738
839
  const fiber = yield* Effect.forkScoped(child.run, { startImmediately: true });
739
840
  const exit = yield* Fiber.await(fiber);
740
- if (!Exit.isSuccess(exit)) {
741
- if (child.childPolicy.restart === "temporary") return StopEpoch.make();
742
- if (yield* isChildIntensityBudgetDone(childIntensityOpt)) return StopEpoch.make();
743
- return yield* restartDescription({
744
- strategy: "one_for_one",
745
- failedIndex: idx,
746
- totalChildren: ctx.booted.length,
747
- ctx,
748
- cause: exit.cause,
749
- onRestart: () => Effect.void
750
- }).run(supIntensity);
751
- }
752
- return StopEpoch.make();
841
+ return yield* childEpochOnExit(ctx, child, idx, childIntensityOpt, supIntensity, exit);
753
842
  });
754
843
  const epochResult = yield* runSupervisionEpochWithBackoff(attempt, ctx);
755
844
  return yield* Match.value(epochResult).pipe(Match.tag("ContinueSupervision", () => loop()), Match.tag("StopSupervision", () => Effect.void), Match.exhaustive);
@@ -767,7 +856,7 @@ const runGroup = (strategy, ctx) => Effect.gen(function* () {
767
856
  const intensity = yield* ctx.intensityEff;
768
857
  const childIntensityTrackers = yield* Effect.forEach(ctx.booted, (b) => Option.match(Option.fromNullishOr(b.childPolicy.intensity), {
769
858
  onNone: () => Effect.succeed(Option.none()),
770
- onSome: (cfg) => Effect.map(make(cfg.restarts, cfg.window), Option.some)
859
+ onSome: (cfg) => Effect.asSome(make(cfg.restarts, cfg.window))
771
860
  }));
772
861
  const cursor = yield* Ref.make(0);
773
862
  const attempt = Effect.gen(function* () {
@@ -778,23 +867,7 @@ const runGroup = (strategy, ctx) => Effect.gen(function* () {
778
867
  yield* Effect.yieldNow;
779
868
  yield* Effect.forkScoped(openAllReady(ctx), { startImmediately: true });
780
869
  const [failedOffset, firstExit] = yield* raceForExit(fibers);
781
- if (!Exit.isSuccess(firstExit)) {
782
- const failedIdx = startIdx + failedOffset;
783
- const failedBootedOpt = Option.fromNullishOr(ctx.booted[failedIdx]);
784
- if (Option.isNone(failedBootedOpt)) return StopEpoch.make();
785
- if (failedBootedOpt.value.childPolicy.restart === "temporary") return StopEpoch.make();
786
- const cIntForFailed = Option.flatten(Array.get(childIntensityTrackers, failedIdx));
787
- if (yield* isChildIntensityBudgetDone(cIntForFailed)) return StopEpoch.make();
788
- return yield* restartDescription({
789
- strategy,
790
- failedIndex: failedIdx,
791
- totalChildren: ctx.booted.length,
792
- ctx,
793
- cause: firstExit.cause,
794
- onRestart: (decision) => Ref.set(cursor, decision.indices[0])
795
- }).run(intensity);
796
- }
797
- return StopEpoch.make();
870
+ return yield* groupEpochOnExit(strategy, ctx, startIdx, childIntensityTrackers, intensity, cursor, failedOffset, firstExit);
798
871
  });
799
872
  const epochResult = yield* runSupervisionEpochWithBackoff(attempt, ctx);
800
873
  return yield* Match.value(epochResult).pipe(Match.tag("ContinueSupervision", () => loop()), Match.tag("StopSupervision", () => Effect.void), Match.exhaustive);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@systemfsoftware/effect-daemon-spec",
3
3
  "license": "Apache-2.0",
4
- "version": "3.0.10",
4
+ "version": "3.0.11",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -37,36 +37,38 @@
37
37
  "dist"
38
38
  ],
39
39
  "dependencies": {
40
- "@systemfsoftware/effect-cell-types": "^8.0.0"
40
+ "@systemfsoftware/effect-cell-types": "^8.3.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@effect/vitest": "4.0.0-rc.112",
44
- "@microsoft/api-extractor": "^7.58.7",
45
- "@systemfsoftware/arethetypeswrong-cli": "^4.1.0",
46
- "@systemfsoftware/stryker-js-cli": "^4.0.1",
47
- "@systemfsoftware/stryker-js-typescript-checker": "^3.0.1",
48
- "@systemfsoftware/stryker-js-vitest-runner": "^2.0.1",
49
- "@systemfsoftware/stryker-plugins": "^1.0.1",
50
- "@systemfsoftware/stryker-test-contribution": "^1.0.1",
51
- "@types/node": "^24",
52
- "@vitest/coverage-v8": "^4",
53
- "effect": "4.0.0-rc.112",
43
+ "@effect/vitest": "4.0.0-rc.116",
44
+ "@microsoft/api-extractor": "^7.59.1",
45
+ "@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
46
+ "@systemfsoftware/stryker-ignorer-effect-schema-declarations": "^0.1.0",
47
+ "@systemfsoftware/stryker-ignorer-in-source-vitest-block": "^0.1.0",
48
+ "@systemfsoftware/stryker-js": "^9.0.0",
49
+ "@systemfsoftware/stryker-js-typescript-checker": "^7.0.2",
50
+ "@systemfsoftware/stryker-js-vitest-runner": "^7.0.0",
51
+ "@systemfsoftware/stryker-test-contribution": "^3.0.2",
52
+ "@types/node": "^26",
53
+ "@vitest/coverage-v8": "^5",
54
+ "effect": "4.0.0-rc.116",
54
55
  "fast-check": "^4",
55
- "oxlint": "^1.77.0",
56
+ "oxlint": "~1.82.0",
56
57
  "rimraf": "^6.1.3",
57
- "tsdown": "^0.22.14",
58
+ "tsdown": "^0.23.0",
58
59
  "typescript": "^7",
59
- "vitest": "^4",
60
- "@systemfsoftware/effect-gherkin-spec": "^4.0.2",
61
- "@systemfsoftware/effect-schema-law": "^2.1.1",
60
+ "vitest": "^5",
61
+ "@systemfsoftware/effect-schema-law": "^2.2.0",
62
+ "@systemfsoftware/all": "^2.1.1",
63
+ "@systemfsoftware/effect-gherkin-spec": "^4.1.0",
62
64
  "@systemfsoftware/oxlint-config": "^0.1.0",
63
- "@systemfsoftware/oxlint-plugin-cell-vocabulary": "^2.0.4",
64
- "@systemfsoftware/effect-schema-vite": "^2.1.1",
65
- "@systemfsoftware/tsconfig": "^1.3.4",
66
- "@systemfsoftware/vitest-config": "^0.1.0"
65
+ "@systemfsoftware/effect-schema-vite": "^2.2.0",
66
+ "@systemfsoftware/stryker-config": "^0.1.0",
67
+ "@systemfsoftware/vitest-config": "^0.1.0",
68
+ "@systemfsoftware/tsconfig": "^1.3.5"
67
69
  },
68
70
  "peerDependencies": {
69
- "effect": "4.0.0-rc.112"
71
+ "effect": "4.0.0-rc.116"
70
72
  },
71
73
  "publishConfig": {
72
74
  "provenance": true